<s> """<STR_LIT>""" <EOL> import datetime <EOL> import math <EOL> import wx <EOL> from WordWrapRenderer import WordWrapRenderer <EOL> class ListCtrlPrinter ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , listCtrl = None , title = "<STR_LIT>" ) : <EOL> """<STR_LIT:U+0020>""" <EOL> self . printout = ListCtrlPrintout ( self ) <EOL> self . engine = ReportEngine ( ) <EOL> if listCtrl is not None : <EOL> self . AddListCtrl ( listCtrl , title ) <EOL> def GetPageFooter ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . engine . pageFooter <EOL> def SetPageFooter ( self , leftText = "<STR_LIT>" , centerText = "<STR_LIT>" , rightText = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( leftText , ( tuple , list ) ) : <EOL> self . engine . pageFooter = leftText <EOL> else : <EOL> self . engine . pageFooter = ( leftText , centerText , rightText ) <EOL> def GetPageHeader ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . engine . pageHeader <EOL> def SetPageHeader ( self , leftText = "<STR_LIT>" , centerText = "<STR_LIT>" , rightText = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( leftText , ( tuple , list ) ) : <EOL> self . engine . pageHeader = leftText <EOL> else : <EOL> self . engine . pageHeader = ( leftText , centerText , rightText ) <EOL> def GetPrintData ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . printout . printData <EOL> def GetReportFormat ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . engine . reportFormat <EOL> def SetReportFormat ( self , fmt ) : <EOL> """<STR_LIT>""" <EOL> self . engine . reportFormat = fmt <EOL> def GetWatermark ( self , txt ) : <EOL> """<STR_LIT>""" <EOL> return self . engine . watermark <EOL> def SetWatermark ( self , txt ) : <EOL> """<STR_LIT>""" <EOL> self . engine . watermark = txt <EOL> ReportFormat = property ( GetReportFormat , SetReportFormat ) <EOL> PageFooter = property ( GetPageFooter , SetPageFooter ) <EOL> PageHeader = property ( GetPageHeader , SetPageHeader ) <EOL> PrintData = property ( GetPrintData ) <EOL> Watermark = property ( GetWatermark , SetWatermark ) <EOL> def AddListCtrl ( self , listCtrl , title = None ) : <EOL> """<STR_LIT>""" <EOL> self . engine . AddListCtrl ( listCtrl , title ) <EOL> def Clear ( self ) : <EOL> """<STR_LIT>""" <EOL> self . engine . ClearListCtrls ( ) <EOL> def PageSetup ( self , parent = None ) : <EOL> """<STR_LIT>""" <EOL> self . printout . PageSetup ( parent ) <EOL> def PrintPreview ( self , parent = None , title = "<STR_LIT>" , bounds = ( <NUM_LIT:20> , <NUM_LIT:50> , <NUM_LIT> , <NUM_LIT> ) ) : <EOL> """<STR_LIT>""" <EOL> self . printout . PrintPreview ( parent , title , bounds ) <EOL> def Print ( self , parent = None ) : <EOL> """<STR_LIT>""" <EOL> self . printout . DoPrint ( parent ) <EOL> def CalculateTotalPages ( self , dc , bounds ) : <EOL> """<STR_LIT>""" <EOL> return self . engine . CalculateTotalPages ( dc , bounds ) <EOL> def StartPrinting ( self ) : <EOL> """<STR_LIT>""" <EOL> self . engine . StartPrinting ( ) <EOL> def PrintPage ( self , dc , pageNumber , bounds ) : <EOL> """<STR_LIT>""" <EOL> self . engine . PrintPage ( dc , pageNumber , bounds ) <EOL> class ReportEngine ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> """<STR_LIT:U+0020>""" <EOL> self . currentPage = - <NUM_LIT:1> <EOL> self . totalPages = - <NUM_LIT:1> <EOL> self . blocks = list ( ) <EOL> self . blockInsertionIndex = <NUM_LIT:0> <EOL> self . listCtrls = list ( ) <EOL> self . dateFormat = "<STR_LIT>" <EOL> self . reportFormat = ReportFormat . Normal ( ) <EOL> self . watermark = "<STR_LIT>" <EOL> self . pageHeader = list ( ) <EOL> self . pageFooter = list ( ) <EOL> self . shouldDrawBlocks = True <EOL> def GetNamedFormat ( self , name ) : <EOL> """<STR_LIT>""" <EOL> return self . reportFormat . GetNamedFormat ( name ) <EOL> def GetTotalPages ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . totalPages <EOL> def GetSubstitutionInfo ( self ) : <EOL> """<STR_LIT>""" <EOL> dateString = datetime . datetime . now ( ) . strftime ( self . dateFormat ) <EOL> info = { <EOL> "<STR_LIT>" : self . currentPage , <EOL> "<STR_LIT:date>" : dateString , <EOL> "<STR_LIT>" : self . totalPages , <EOL> } <EOL> return info <EOL> def CalculateTotalPages ( self , dc , bounds ) : <EOL> """<STR_LIT>""" <EOL> self . StartPrinting ( ) <EOL> self . totalPages = <NUM_LIT:1> <EOL> self . shouldDrawBlocks = False <EOL> while self . PrintOnePage ( dc , self . totalPages , bounds ) : <EOL> self . totalPages += <NUM_LIT:1> <EOL> self . shouldDrawBlocks = True <EOL> return self . totalPages <EOL> def AddBlock ( self , block ) : <EOL> """<STR_LIT>""" <EOL> self . blocks . insert ( self . blockInsertionIndex , block ) <EOL> self . blockInsertionIndex += <NUM_LIT:1> <EOL> block . engine = self <EOL> def AddListCtrl ( self , listCtrl , title = None ) : <EOL> """<STR_LIT>""" <EOL> if listCtrl . InReportView ( ) : <EOL> self . listCtrls . append ( [ listCtrl , title ] ) <EOL> def ClearListCtrls ( self ) : <EOL> """<STR_LIT>""" <EOL> self . listCtrls = list ( ) <EOL> def DropCurrentBlock ( self ) : <EOL> """<STR_LIT>""" <EOL> self . blocks . pop ( <NUM_LIT:0> ) <EOL> self . blockInsertionIndex = <NUM_LIT:1> <EOL> def StartPrinting ( self ) : <EOL> """<STR_LIT>""" <EOL> self . currentPage = <NUM_LIT:0> <EOL> self . blockInsertionIndex = <NUM_LIT:0> <EOL> self . blocks = list ( ) <EOL> self . AddBlock ( ReportBlock ( ) ) <EOL> self . runningBlocks = list ( ) <EOL> self . AddRunningBlock ( PageHeaderBlock ( ) ) <EOL> self . AddRunningBlock ( PageFooterBlock ( ) ) <EOL> if self . watermark : <EOL> self . _CreateReplaceWatermarkDecoration ( ) <EOL> def AddRunningBlock ( self , block ) : <EOL> """<STR_LIT>""" <EOL> self . runningBlocks . append ( block ) <EOL> block . engine = self <EOL> def RemoveRunningBlock ( self , block ) : <EOL> """<STR_LIT>""" <EOL> self . runningBlocks . remove ( block ) <EOL> def PrintPage ( self , dc , pageNumber , bounds ) : <EOL> """<STR_LIT>""" <EOL> if pageNumber != self . currentPage + <NUM_LIT:1> : <EOL> self . StartPrinting ( ) <EOL> self . shouldDrawBlocks = False <EOL> for i in range ( <NUM_LIT:1> , pageNumber ) : <EOL> self . PrintOnePage ( dc , i , bounds ) <EOL> self . shouldDrawBlocks = True <EOL> return self . PrintOnePage ( dc , pageNumber , bounds ) <EOL> def PrintOnePage ( self , dc , pageNumber , bounds ) : <EOL> """<STR_LIT>""" <EOL> self . currentPage = pageNumber <EOL> self . pageBounds = list ( bounds ) <EOL> self . workBounds = list ( self . pageBounds ) <EOL> self . SubtractDecorations ( dc ) <EOL> self . DrawPageDecorations ( dc , False ) <EOL> for x in self . runningBlocks : <EOL> x . Print ( dc ) <EOL> while len ( self . blocks ) and self . blocks [ <NUM_LIT:0> ] . Print ( dc ) : <EOL> self . DropCurrentBlock ( ) <EOL> self . DrawPageDecorations ( dc , True ) <EOL> return len ( self . blocks ) > <NUM_LIT:0> <EOL> def SubtractDecorations ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> fmt = self . GetNamedFormat ( "<STR_LIT>" ) <EOL> self . workBounds = fmt . SubtractDecorations ( dc , self . workBounds ) <EOL> def DrawPageDecorations ( self , dc , over ) : <EOL> """<STR_LIT>""" <EOL> if not self . shouldDrawBlocks : <EOL> return <EOL> fmt = self . GetNamedFormat ( "<STR_LIT>" ) <EOL> bounds = list ( self . pageBounds ) <EOL> fmt . DrawDecorations ( dc , bounds , self , over ) <EOL> def _CreateReplaceWatermarkDecoration ( self ) : <EOL> """<STR_LIT>""" <EOL> pageFmt = self . GetNamedFormat ( "<STR_LIT>" ) <EOL> pageFmt . decorations = [ x for x in pageFmt . decorations if not isinstance ( x , WatermarkDecoration ) ] <EOL> watermarkFmt = self . GetNamedFormat ( "<STR_LIT>" ) <EOL> pageFmt . Add ( WatermarkDecoration ( self . watermark , font = watermarkFmt . Font , <EOL> color = watermarkFmt . TextColor , angle = watermarkFmt . Angle , <EOL> over = watermarkFmt . Over ) ) <EOL> class ListCtrlPrintout ( wx . Printout ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , olvPrinter , margins = None ) : <EOL> """<STR_LIT:U+0020>""" <EOL> wx . Printout . __init__ ( self ) <EOL> self . olvPrinter = olvPrinter <EOL> self . margins = margins or ( wx . Point ( <NUM_LIT:15> , <NUM_LIT:15> ) , wx . Point ( <NUM_LIT:15> , <NUM_LIT:15> ) ) <EOL> self . totalPages = - <NUM_LIT:1> <EOL> self . printData = wx . PrintData ( ) <EOL> self . printData . SetPrinterName ( "<STR_LIT>" ) <EOL> self . printData . SetPaperId ( wx . PAPER_A4 ) <EOL> self . printData . SetPrintMode ( wx . PRINT_MODE_PRINTER ) <EOL> def HasPage ( self , page ) : <EOL> """<STR_LIT>""" <EOL> return page <= self . totalPages <EOL> def GetPageInfo ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( <NUM_LIT:1> , self . totalPages , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> def GetPrintPreview ( self ) : <EOL> """<STR_LIT>""" <EOL> data = wx . PrintDialogData ( self . printData ) <EOL> forViewing = ListCtrlPrintout ( self . olvPrinter , self . margins ) <EOL> forPrinter = ListCtrlPrintout ( self . olvPrinter , self . margins ) <EOL> preview = wx . PrintPreview ( forViewing , forPrinter , data ) <EOL> return preview <EOL> def PageSetup ( self , parent ) : <EOL> """<STR_LIT>""" <EOL> data = wx . PageSetupDialogData ( ) <EOL> data . SetPrintData ( self . printData ) <EOL> data . SetDefaultMinMargins ( True ) <EOL> data . SetMarginTopLeft ( self . margins [ <NUM_LIT:0> ] ) <EOL> data . SetMarginBottomRight ( self . margins [ <NUM_LIT:1> ] ) <EOL> dlg = wx . PageSetupDialog ( parent , data ) <EOL> if dlg . ShowModal ( ) == wx . ID_OK : <EOL> data = dlg . GetPageSetupData ( ) <EOL> self . printData = wx . PrintData ( data . GetPrintData ( ) ) <EOL> self . printData . SetPaperId ( data . GetPaperId ( ) ) <EOL> self . margins = ( data . GetMarginTopLeft ( ) , data . GetMarginBottomRight ( ) ) <EOL> dlg . Destroy ( ) <EOL> def PrintPreview ( self , parent , title , bounds ) : <EOL> """<STR_LIT>""" <EOL> self . preview = self . GetPrintPreview ( ) <EOL> if not self . preview . Ok ( ) : <EOL> return False <EOL> pfrm = wx . PreviewFrame ( self . preview , parent , title ) <EOL> pfrm . Initialize ( ) <EOL> pfrm . SetPosition ( bounds [ <NUM_LIT:0> : <NUM_LIT:2> ] ) <EOL> pfrm . SetSize ( bounds [ <NUM_LIT:2> : <NUM_LIT:4> ] ) <EOL> pfrm . Show ( True ) <EOL> return True <EOL> def DoPrint ( self , parent ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> pdd = wx . PrintDialogData ( self . printData ) <EOL> printer = wx . Printer ( pdd ) <EOL> if printer . Print ( parent , self , True ) : <EOL> self . printData = wx . PrintData ( printer . GetPrintDialogData ( ) . GetPrintData ( ) ) <EOL> else : <EOL> wx . MessageBox ( "<STR_LIT>" , "<STR_LIT>" , wx . OK ) <EOL> finally : <EOL> pdd . Destroy ( ) <EOL> def OnPreparePrinting ( self ) : <EOL> """<STR_LIT>""" <EOL> dc = self . GetDC ( ) <EOL> self . SetScaleAndBounds ( dc ) <EOL> self . totalPages = self . olvPrinter . CalculateTotalPages ( dc , self . bounds ) <EOL> self . olvPrinter . StartPrinting ( ) <EOL> def OnBeginDocument ( self , start , end ) : <EOL> """<STR_LIT>""" <EOL> return super ( ListCtrlPrintout , self ) . OnBeginDocument ( start , end ) <EOL> def OnEndDocument ( self ) : <EOL> super ( ListCtrlPrintout , self ) . OnEndDocument ( ) <EOL> def OnBeginPrinting ( self ) : <EOL> super ( ListCtrlPrintout , self ) . OnBeginPrinting ( ) <EOL> def OnEndPrinting ( self ) : <EOL> super ( ListCtrlPrintout , self ) . OnEndPrinting ( ) <EOL> def OnPrintPage ( self , page ) : <EOL> """<STR_LIT>""" <EOL> dc = self . GetDC ( ) <EOL> self . SetScaleAndBounds ( dc ) <EOL> return self . olvPrinter . PrintPage ( dc , page , self . bounds ) <EOL> def SetScaleAndBounds ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> ppiPrinterX , ppiPrinterY = self . GetPPIPrinter ( ) <EOL> ppiScreenX , ppiScreenY = self . GetPPIScreen ( ) <EOL> logicalScale = float ( ppiPrinterX ) / float ( ppiScreenX ) <EOL> pw , ph = self . GetPageSizePixels ( ) <EOL> dw , dh = dc . GetSize ( ) <EOL> scale = logicalScale * float ( dw ) / float ( pw ) <EOL> dc . SetUserScale ( scale , scale ) <EOL> logicalUnitsMM = float ( ppiPrinterX ) / ( logicalScale * <NUM_LIT> ) <EOL> topLeft , bottomRight = self . margins <EOL> left = round ( topLeft . x * logicalUnitsMM ) <EOL> top = round ( topLeft . y * logicalUnitsMM ) <EOL> right = round ( dc . DeviceToLogicalYRel ( dw ) - bottomRight . x * logicalUnitsMM ) <EOL> bottom = round ( dc . DeviceToLogicalYRel ( dh ) - bottomRight . y * logicalUnitsMM ) <EOL> self . bounds = ( left , top , right - left , bottom - top ) <EOL> class ReportFormat ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> """<STR_LIT:U+0020>""" <EOL> self . Page = BlockFormat ( ) <EOL> self . PageHeader = BlockFormat ( ) <EOL> self . ListHeader = BlockFormat ( ) <EOL> self . GroupTitle = BlockFormat ( ) <EOL> self . ColumnHeader = BlockFormat ( ) <EOL> self . Row = BlockFormat ( ) <EOL> self . ListFooter = BlockFormat ( ) <EOL> self . PageFooter = BlockFormat ( ) <EOL> self . Watermark = BlockFormat ( ) <EOL> self . IncludeImages = True <EOL> self . IsColumnHeadingsOnEachPage = False <EOL> self . IsShrinkToFit = False <EOL> self . UseListCtrlTextFormat = True <EOL> self . WatermarkFormat ( ) <EOL> def GetNamedFormat ( self , name ) : <EOL> """<STR_LIT>""" <EOL> return getattr ( self , name ) <EOL> def WatermarkFormat ( self , font = None , color = None , angle = <NUM_LIT:30> , over = False ) : <EOL> """<STR_LIT>""" <EOL> defaultFaceName = "<STR_LIT>" <EOL> self . Watermark . Font = font or wx . FFont ( <NUM_LIT> , wx . FONTFAMILY_DEFAULT , <NUM_LIT:0> , defaultFaceName ) <EOL> self . Watermark . TextColor = color or wx . Colour ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . Watermark . Angle = angle <EOL> self . Watermark . Over = over <EOL> @ staticmethod <EOL> def Minimal ( headerFontName = "<STR_LIT>" , rowFontName = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> fmt = ReportFormat ( ) <EOL> fmt . IsShrinkToFit = False <EOL> fmt . PageHeader . Font = wx . FFont ( <NUM_LIT:12> , wx . FONTFAMILY_DEFAULT , face = headerFontName ) <EOL> fmt . PageHeader . Line ( wx . BOTTOM , wx . BLACK , <NUM_LIT:1> , space = <NUM_LIT:5> ) <EOL> fmt . PageHeader . Padding = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:12> ) <EOL> fmt . ListHeader . Font = wx . FFont ( <NUM_LIT> , wx . FONTFAMILY_DEFAULT , face = headerFontName ) <EOL> fmt . ListHeader . Padding = ( <NUM_LIT:0> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:12> ) <EOL> fmt . ListHeader . Line ( wx . BOTTOM , wx . BLACK , <NUM_LIT:1> , space = <NUM_LIT:5> ) <EOL> fmt . GroupTitle . Font = wx . FFont ( <NUM_LIT:12> , wx . FONTFAMILY_DEFAULT , face = headerFontName ) <EOL> fmt . GroupTitle . Padding = ( <NUM_LIT:0> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:12> ) <EOL> fmt . GroupTitle . Line ( wx . BOTTOM , wx . BLACK , <NUM_LIT:1> , space = <NUM_LIT:5> ) <EOL> fmt . PageFooter . Font = wx . FFont ( <NUM_LIT:10> , wx . FONTFAMILY_DEFAULT , face = headerFontName ) <EOL> fmt . PageFooter . Line ( wx . TOP , wx . BLACK , <NUM_LIT:1> , space = <NUM_LIT:3> ) <EOL> fmt . PageFooter . Padding = ( <NUM_LIT:0> , <NUM_LIT:16> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> fmt . ColumnHeader . Font = wx . FFont ( <NUM_LIT> , wx . FONTFAMILY_DEFAULT , wx . FONTFLAG_BOLD , face = headerFontName ) <EOL> fmt . ColumnHeader . Padding = ( <NUM_LIT:0> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:12> ) <EOL> fmt . ColumnHeader . CellPadding = <NUM_LIT:5> <EOL> fmt . ColumnHeader . Line ( wx . BOTTOM , wx . Colour ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:1> , space = <NUM_LIT:3> ) <EOL> fmt . ColumnHeader . AlwaysCenter = True <EOL> fmt . Row . Font = wx . FFont ( <NUM_LIT:10> , wx . FONTFAMILY_DEFAULT , face = rowFontName ) <EOL> fmt . Row . CellPadding = <NUM_LIT:5> <EOL> fmt . Row . Line ( wx . BOTTOM , wx . Colour ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:1> , space = <NUM_LIT:3> ) <EOL> fmt . Row . CanWrap = True <EOL> return fmt <EOL> @ staticmethod <EOL> def Normal ( headerFontName = "<STR_LIT>" , rowFontName = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> fmt = ReportFormat ( ) <EOL> fmt . IsShrinkToFit = True <EOL> fmt . PageHeader . Font = wx . FFont ( <NUM_LIT:12> , wx . FONTFAMILY_DEFAULT , face = headerFontName ) <EOL> fmt . PageHeader . Line ( wx . BOTTOM , wx . BLUE , <NUM_LIT:2> , space = <NUM_LIT:5> ) <EOL> fmt . PageHeader . Padding = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:12> ) <EOL> fmt . ListHeader . Font = wx . FFont ( <NUM_LIT> , wx . FONTFAMILY_SWISS , wx . FONTFLAG_BOLD , face = headerFontName ) <EOL> fmt . ListHeader . TextColor = wx . WHITE <EOL> fmt . ListHeader . Padding = ( <NUM_LIT:0> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:12> ) <EOL> fmt . ListHeader . TextAlignment = wx . ALIGN_LEFT <EOL> fmt . ListHeader . Background ( wx . BLUE , wx . WHITE , space = ( <NUM_LIT:16> , <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:4> ) ) <EOL> fmt . GroupTitle . Font = wx . FFont ( <NUM_LIT> , wx . FONTFAMILY_DEFAULT , face = headerFontName ) <EOL> fmt . GroupTitle . Line ( wx . BOTTOM , wx . BLUE , <NUM_LIT:4> , toColor = wx . WHITE , space = <NUM_LIT:5> ) <EOL> fmt . GroupTitle . Padding = ( <NUM_LIT:0> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:12> ) <EOL> fmt . PageFooter . Font = wx . FFont ( <NUM_LIT:10> , wx . FONTFAMILY_DEFAULT , face = headerFontName ) <EOL> fmt . PageFooter . Background ( wx . WHITE , wx . BLUE , space = ( <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:4> ) ) <EOL> fmt . ColumnHeader . Font = wx . FFont ( <NUM_LIT> , wx . FONTFAMILY_DEFAULT , wx . FONTFLAG_BOLD , face = headerFontName ) <EOL> fmt . ColumnHeader . CellPadding = <NUM_LIT:2> <EOL> fmt . ColumnHeader . Background ( wx . Colour ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> fmt . ColumnHeader . GridPen = wx . Pen ( wx . WHITE , <NUM_LIT:1> ) <EOL> fmt . ColumnHeader . Padding = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:12> ) <EOL> fmt . ColumnHeader . AlwaysCenter = True <EOL> fmt . Row . Font = wx . FFont ( <NUM_LIT:12> , wx . FONTFAMILY_DEFAULT , face = rowFontName ) <EOL> fmt . Row . Line ( wx . BOTTOM , pen = wx . Pen ( wx . BLUE , <NUM_LIT:1> , wx . DOT ) , space = <NUM_LIT:3> ) <EOL> fmt . Row . CellPadding = <NUM_LIT:2> <EOL> fmt . Row . CanWrap = True <EOL> return fmt <EOL> @ staticmethod <EOL> def TooMuch ( headerFontName = "<STR_LIT>" , rowFontName = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> fmt = ReportFormat ( ) <EOL> fmt . IsShrinkToFit = False <EOL> fmt . PageHeader . Font = wx . FFont ( <NUM_LIT:12> , wx . FONTFAMILY_DECORATIVE , wx . FONTFLAG_BOLD , face = headerFontName ) <EOL> fmt . PageHeader . TextColor = wx . WHITE <EOL> fmt . PageHeader . Background ( wx . GREEN , wx . RED , space = ( <NUM_LIT:16> , <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:4> ) ) <EOL> fmt . PageHeader . Padding = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:12> ) <EOL> fmt . ListHeader . Font = wx . FFont ( <NUM_LIT> , wx . FONTFAMILY_DECORATIVE , face = headerFontName ) <EOL> fmt . ListHeader . TextColor = wx . WHITE <EOL> fmt . ListHeader . Padding = ( <NUM_LIT:0> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:12> ) <EOL> fmt . ListHeader . TextAlignment = wx . ALIGN_CENTER <EOL> fmt . ListHeader . Background ( wx . RED , wx . GREEN , space = ( <NUM_LIT:16> , <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:4> ) ) <EOL> fmt . GroupTitle . Font = wx . FFont ( <NUM_LIT> , wx . FONTFAMILY_DECORATIVE , wx . FONTFLAG_BOLD , face = headerFontName ) <EOL> fmt . GroupTitle . TextColor = wx . BLUE <EOL> fmt . GroupTitle . Padding = ( <NUM_LIT:0> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:12> ) <EOL> fmt . GroupTitle . Line ( wx . BOTTOM , wx . GREEN , <NUM_LIT:4> , toColor = wx . WHITE , space = <NUM_LIT:5> ) <EOL> fmt . PageFooter . Font = wx . FFont ( <NUM_LIT:10> , wx . FONTFAMILY_DECORATIVE , face = headerFontName ) <EOL> fmt . PageFooter . Line ( wx . TOP , wx . GREEN , <NUM_LIT:2> , toColor = wx . RED , space = <NUM_LIT:3> ) <EOL> fmt . PageFooter . Padding = ( <NUM_LIT:0> , <NUM_LIT:16> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> fmt . ColumnHeader . Font = wx . FFont ( <NUM_LIT> , wx . FONTFAMILY_SWISS , wx . FONTFLAG_BOLD , face = headerFontName ) <EOL> fmt . ColumnHeader . Background ( wx . Colour ( <NUM_LIT:255> , <NUM_LIT> , <NUM_LIT:0> ) ) <EOL> fmt . ColumnHeader . CellPadding = <NUM_LIT:5> <EOL> fmt . ColumnHeader . GridPen = wx . Pen ( wx . Colour ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:1> ) <EOL> fmt . Row . Font = wx . FFont ( <NUM_LIT:12> , wx . FONTFAMILY_SWISS , face = rowFontName ) <EOL> fmt . Row . CellPadding = <NUM_LIT:5> <EOL> fmt . Row . GridPen = wx . Pen ( wx . BLUE , <NUM_LIT:1> , wx . DOT ) <EOL> fmt . Row . CanWrap = True <EOL> fmt . Watermark . TextColor = wx . Colour ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> return fmt <EOL> class BlockFormat ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> """<STR_LIT:U+0020>""" <EOL> self . padding = None <EOL> self . decorations = list ( ) <EOL> self . font = wx . FFont ( <NUM_LIT:11> , wx . FONTFAMILY_SWISS , face = "<STR_LIT>" ) <EOL> self . textColor = None <EOL> self . textAlignment = wx . ALIGN_LEFT <EOL> self . alwaysCenter = False <EOL> self . canWrap = False <EOL> self . cellPadding = None <EOL> self . gridPen = None <EOL> def GetFont ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . font <EOL> def SetFont ( self , font ) : <EOL> """<STR_LIT>""" <EOL> self . font = font <EOL> def GetTextAlignment ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . textAlignment <EOL> def SetTextAlignment ( self , alignment ) : <EOL> """<STR_LIT>""" <EOL> self . textAlignment = alignment <EOL> def GetTextColor ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . textColor <EOL> def SetTextColor ( self , color ) : <EOL> """<STR_LIT>""" <EOL> self . textColor = color <EOL> def GetPadding ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . padding <EOL> def SetPadding ( self , padding ) : <EOL> """<STR_LIT>""" <EOL> self . padding = self . _MakePadding ( padding ) <EOL> def GetCellPadding ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . cellPadding <EOL> def SetCellPadding ( self , padding ) : <EOL> """<STR_LIT>""" <EOL> self . cellPadding = self . _MakePadding ( padding ) <EOL> def GetGridPen ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . gridPen <EOL> def SetGridPen ( self , pen ) : <EOL> """<STR_LIT>""" <EOL> self . gridPen = pen <EOL> if self . gridPen : <EOL> self . gridPen . SetCap ( wx . CAP_BUTT ) <EOL> self . gridPen . SetJoin ( wx . JOIN_MITER ) <EOL> def _MakePadding ( self , padding ) : <EOL> try : <EOL> if len ( padding ) < <NUM_LIT:4> : <EOL> return ( tuple ( padding ) + ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) [ : <NUM_LIT:4> ] <EOL> else : <EOL> return padding <EOL> except TypeError : <EOL> return ( padding , ) * <NUM_LIT:4> <EOL> def GetAlwaysCenter ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . alwaysCenter <EOL> def SetAlwaysCenter ( self , value ) : <EOL> """<STR_LIT>""" <EOL> self . alwaysCenter = value <EOL> def GetCanWrap ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . canWrap <EOL> def SetCanWrap ( self , value ) : <EOL> """<STR_LIT>""" <EOL> self . canWrap = value <EOL> Font = property ( GetFont , SetFont ) <EOL> Padding = property ( GetPadding , SetPadding ) <EOL> TextAlignment = property ( GetTextAlignment , SetTextAlignment ) <EOL> TextColor = property ( GetTextColor , SetTextColor ) <EOL> CellPadding = property ( GetCellPadding , SetCellPadding ) <EOL> GridPen = property ( GetGridPen , SetGridPen ) <EOL> AlwaysCenter = property ( GetAlwaysCenter , SetAlwaysCenter ) <EOL> CanWrap = property ( GetCanWrap , SetCanWrap ) <EOL> TextAlign = property ( GetTextAlignment , SetTextAlignment ) <EOL> TextColour = property ( GetTextColor , SetTextColor ) <EOL> def CalculateCellPadding ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . CellPadding : <EOL> cellPadding = list ( self . CellPadding ) <EOL> else : <EOL> cellPadding = <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> <EOL> if self . GridPen : <EOL> penFactor = int ( ( self . GridPen . GetWidth ( ) + <NUM_LIT:1> ) / <NUM_LIT:2> ) <EOL> cellPadding = [ x + penFactor for x in cellPadding ] <EOL> return cellPadding <EOL> def Add ( self , decoration ) : <EOL> """<STR_LIT>""" <EOL> self . decorations . append ( decoration ) <EOL> def Line ( self , side = wx . BOTTOM , color = wx . BLACK , width = <NUM_LIT:1> , toColor = None , space = <NUM_LIT:0> , pen = None ) : <EOL> """<STR_LIT>""" <EOL> if pen : <EOL> self . Add ( LineDecoration ( side , pen , space ) ) <EOL> else : <EOL> self . Add ( RectangleDecoration ( side , None , color , toColor , width , space ) ) <EOL> def Background ( self , color = wx . BLUE , toColor = None , space = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> self . Add ( RectangleDecoration ( color = color , toColor = toColor , space = space ) ) <EOL> def Frame ( self , pen = None , space = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> self . Add ( RectangleDecoration ( pen = pen , space = space ) ) <EOL> def SubtractPadding ( self , bounds ) : <EOL> """<STR_LIT>""" <EOL> if self . padding is None : <EOL> return bounds <EOL> else : <EOL> return RectUtils . InsetRect ( bounds , self . padding ) <EOL> def SubtractDecorations ( self , dc , bounds ) : <EOL> """<STR_LIT>""" <EOL> for x in self . decorations : <EOL> bounds = x . SubtractFrom ( dc , bounds ) <EOL> return bounds <EOL> def DrawDecorations ( self , dc , bounds , block , over ) : <EOL> """<STR_LIT>""" <EOL> for x in self . decorations : <EOL> if x . IsDrawOver ( ) == over : <EOL> x . DrawDecoration ( dc , bounds , block ) <EOL> class Block ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , engine = None ) : <EOL> self . engine = engine <EOL> def GetFont ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . GetFormat ( ) . GetFont ( ) <EOL> def GetTextColor ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . GetFormat ( ) . GetTextColor ( ) <EOL> def GetFormat ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . engine . GetNamedFormat ( self . __class__ . __name__ [ : - <NUM_LIT:5> ] ) <EOL> def GetReducedBlockBounds ( self , dc , bounds = None ) : <EOL> """<STR_LIT>""" <EOL> bounds = bounds or list ( self . GetWorkBounds ( ) ) <EOL> fmt = self . GetFormat ( ) <EOL> bounds = fmt . SubtractPadding ( bounds ) <EOL> bounds = fmt . SubtractDecorations ( dc , bounds ) <EOL> return bounds <EOL> def GetWorkBounds ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . engine . workBounds <EOL> def IsColumnHeadingsOnEachPage ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . engine . reportFormat . IsColumnHeadingsOnEachPage <EOL> def IncludeImages ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . engine . reportFormat . IncludeImages <EOL> def IsShrinkToFit ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . engine . reportFormat . IsShrinkToFit <EOL> def IsUseSubstitution ( self ) : <EOL> """<STR_LIT>""" <EOL> return True <EOL> def CalculateExtrasHeight ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> - RectUtils . Height ( self . GetReducedBlockBounds ( dc , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) ) <EOL> def CalculateExtrasWidth ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> - RectUtils . Width ( self . GetReducedBlockBounds ( dc , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] ) ) <EOL> def CalculateHeight ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> return - <NUM_LIT:1> <EOL> def CalculateTextHeight ( self , dc , txt , bounds = None , font = None ) : <EOL> """<STR_LIT>""" <EOL> bounds = bounds or self . GetReducedBlockBounds ( dc ) <EOL> font = font or self . GetFont ( ) <EOL> dc . SetFont ( font ) <EOL> if self . GetFormat ( ) . CanWrap : <EOL> return WordWrapRenderer . CalculateHeight ( dc , txt , RectUtils . Width ( bounds ) ) <EOL> else : <EOL> return WordWrapRenderer . CalculateHeight ( dc , "<STR_LIT>" , <NUM_LIT:1000> ) <EOL> def CanFit ( self , height ) : <EOL> """<STR_LIT>""" <EOL> return height <= RectUtils . Height ( self . GetWorkBounds ( ) ) <EOL> def Print ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> if not self . ShouldPrint ( ) : <EOL> return True <EOL> bounds = self . CalculateBounds ( dc ) <EOL> if not self . CanFit ( RectUtils . Height ( bounds ) ) : <EOL> return False <EOL> if self . engine . shouldDrawBlocks : <EOL> self . PreDraw ( dc , bounds ) <EOL> self . Draw ( dc , bounds ) <EOL> self . PostDraw ( dc , bounds ) <EOL> self . ChangeWorkBoundsBy ( RectUtils . Height ( bounds ) ) <EOL> return True <EOL> def ShouldPrint ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . GetFormat ( ) is not None <EOL> def CalculateBounds ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> height = self . CalculateHeight ( dc ) <EOL> bounds = list ( self . GetWorkBounds ( ) ) <EOL> bounds = RectUtils . SetHeight ( bounds , height ) <EOL> return bounds <EOL> def ChangeWorkBoundsBy ( self , amt ) : <EOL> """<STR_LIT>""" <EOL> RectUtils . MoveTopBy ( self . engine . workBounds , amt ) <EOL> def Draw ( self , dc , bounds ) : <EOL> """<STR_LIT>""" <EOL> fmt = self . GetFormat ( ) <EOL> decorationBounds = fmt . SubtractPadding ( bounds ) <EOL> fmt . DrawDecorations ( dc , decorationBounds , self , False ) <EOL> textBounds = fmt . SubtractDecorations ( dc , list ( decorationBounds ) ) <EOL> self . DrawSelf ( dc , textBounds ) <EOL> fmt . DrawDecorations ( dc , decorationBounds , self , True ) <EOL> def PreDraw ( self , dc , bounds ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def DrawSelf ( self , dc , bounds ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def PostDraw ( self , dc , bounds ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def DrawText ( self , dc , txt , bounds , font = None , alignment = wx . ALIGN_LEFT , valignment = wx . ALIGN_CENTRE , <EOL> image = None , color = None , canWrap = True , imageIndex = - <NUM_LIT:1> , listCtrl = None ) : <EOL> """<STR_LIT>""" <EOL> GAP_BETWEEN_IMAGE_AND_TEXT = <NUM_LIT:4> <EOL> def _CalcBitmapPosition ( r , height ) : <EOL> if valignment == wx . ALIGN_TOP : <EOL> return RectUtils . Top ( r ) <EOL> elif valignment == wx . ALIGN_CENTER : <EOL> return RectUtils . CenterY ( r ) - height / <NUM_LIT:2> <EOL> elif valignment == wx . ALIGN_BOTTOM : <EOL> return RectUtils . Bottom ( r ) - height <EOL> else : <EOL> return RectUtils . Top ( r ) <EOL> if image : <EOL> y = _CalcBitmapPosition ( bounds , image . Height ) <EOL> dc . DrawBitmap ( image , RectUtils . Left ( bounds ) , y ) <EOL> RectUtils . MoveLeftBy ( bounds , image . GetWidth ( ) + GAP_BETWEEN_IMAGE_AND_TEXT ) <EOL> elif listCtrl and imageIndex >= <NUM_LIT:0> : <EOL> imageList = listCtrl . GetImageList ( wx . IMAGE_LIST_SMALL ) <EOL> y = _CalcBitmapPosition ( bounds , imageList . GetSize ( <NUM_LIT:0> ) [ <NUM_LIT:1> ] ) <EOL> imageList . Draw ( imageIndex , dc , RectUtils . Left ( bounds ) , y , wx . IMAGELIST_DRAW_TRANSPARENT ) <EOL> RectUtils . MoveLeftBy ( bounds , imageList . GetSize ( <NUM_LIT:0> ) [ <NUM_LIT:0> ] + GAP_BETWEEN_IMAGE_AND_TEXT ) <EOL> dc . SetFont ( font or self . GetFont ( ) ) <EOL> dc . SetTextForeground ( color or self . GetTextColor ( ) or wx . BLACK ) <EOL> if canWrap : <EOL> WordWrapRenderer . DrawString ( dc , txt , bounds , alignment , valignment ) <EOL> else : <EOL> WordWrapRenderer . DrawTruncatedString ( dc , txt , bounds , alignment , valignment ) <EOL> def PerformSubstitutions ( self , strings ) : <EOL> """<STR_LIT>""" <EOL> info = self . engine . GetSubstitutionInfo ( ) <EOL> try : <EOL> try : <EOL> return strings % info <EOL> except TypeError : <EOL> return [ x % info for x in strings ] <EOL> except ValueError : <EOL> return strings <EOL> class TextBlock ( Block ) : <EOL> """<STR_LIT>""" <EOL> def ShouldPrint ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . GetText ( ) : <EOL> return Block . ShouldPrint ( self ) <EOL> else : <EOL> return False <EOL> def GetText ( self ) : <EOL> return "<STR_LIT>" % self . __class__ . __name__ <EOL> def GetSubstitutedText ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . IsUseSubstitution ( ) : <EOL> return self . PerformSubstitutions ( self . GetText ( ) ) <EOL> else : <EOL> return self . GetText ( ) <EOL> def CalculateHeight ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> textHeight = self . CalculateTextHeight ( dc , self . GetSubstitutedText ( ) ) <EOL> extras = self . CalculateExtrasHeight ( dc ) <EOL> return textHeight + extras <EOL> def DrawSelf ( self , dc , bounds ) : <EOL> """<STR_LIT>""" <EOL> fmt = self . GetFormat ( ) <EOL> self . DrawText ( dc , self . GetSubstitutedText ( ) , bounds , canWrap = fmt . CanWrap , alignment = fmt . TextAlignment ) <EOL> class CellBlock ( Block ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . scale = <NUM_LIT:1> <EOL> self . oldScale = <NUM_LIT:1> <EOL> def GetCellWidths ( self ) : <EOL> """<STR_LIT>""" <EOL> return list ( ) <EOL> def GetTexts ( self ) : <EOL> """<STR_LIT>""" <EOL> return list ( ) <EOL> def GetAlignments ( self ) : <EOL> """<STR_LIT>""" <EOL> return list ( ) <EOL> def GetImages ( self ) : <EOL> """<STR_LIT>""" <EOL> return list ( ) <EOL> def GetCombinedLists ( self ) : <EOL> """<STR_LIT>""" <EOL> buckets = [ Bucket ( cellWidth = x , text = "<STR_LIT>" , align = None , image = None ) for x in self . GetCellWidths ( ) ] <EOL> for ( i , x ) in enumerate ( self . GetSubstitutedTexts ( ) ) : <EOL> buckets [ i ] . text = x <EOL> for ( i , x ) in enumerate ( self . GetAlignments ( ) ) : <EOL> buckets [ i ] . align = x <EOL> if self . IncludeImages ( ) : <EOL> for ( i , x ) in enumerate ( self . GetImages ( ) ) : <EOL> buckets [ i ] . image = x <EOL> cellPadding = self . GetFormat ( ) . CalculateCellPadding ( ) <EOL> for x in buckets : <EOL> x . innerCellWidth = max ( <NUM_LIT:0> , x . cellWidth - ( cellPadding [ <NUM_LIT:0> ] + cellPadding [ <NUM_LIT:2> ] ) ) <EOL> return buckets <EOL> def GetListCtrl ( self ) : <EOL> """<STR_LIT>""" <EOL> return None <EOL> def GetSubstitutedTexts ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . IsUseSubstitution ( ) : <EOL> return self . PerformSubstitutions ( self . GetTexts ( ) ) <EOL> else : <EOL> return self . GetTexts ( ) <EOL> def CalculateHeight ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> GAP_BETWEEN_IMAGE_AND_TEXT = <NUM_LIT:4> <EOL> if self . GetFormat ( ) . CanWrap : <EOL> font = self . GetFont ( ) <EOL> height = <NUM_LIT:0> <EOL> for x in self . GetCombinedLists ( ) : <EOL> textWidth = x . innerCellWidth <EOL> if self . GetListCtrl ( ) and x . image != - <NUM_LIT:1> : <EOL> imageList = self . GetListCtrl ( ) . GetImageList ( wx . IMAGE_LIST_SMALL ) <EOL> textWidth -= imageList . GetSize ( <NUM_LIT:0> ) [ <NUM_LIT:0> ] + GAP_BETWEEN_IMAGE_AND_TEXT <EOL> bounds = [ <NUM_LIT:0> , <NUM_LIT:0> , textWidth , <NUM_LIT> ] <EOL> height = max ( height , self . CalculateTextHeight ( dc , x . text , bounds , font ) ) <EOL> else : <EOL> height = self . CalculateTextHeight ( dc , "<STR_LIT>" ) <EOL> cellPadding = self . GetFormat ( ) . CalculateCellPadding ( ) <EOL> return height + cellPadding [ <NUM_LIT:1> ] + cellPadding [ <NUM_LIT:3> ] + self . CalculateExtrasHeight ( dc ) <EOL> def CalculateWidth ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> return sum ( x . cellWidth for x in self . GetCombinedLists ( ) ) + self . CalculateExtrasWidth ( dc ) <EOL> def CalculateBounds ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> height = self . CalculateHeight ( dc ) <EOL> bounds = list ( self . GetWorkBounds ( ) ) <EOL> bounds = RectUtils . SetHeight ( bounds , height ) <EOL> bounds = RectUtils . SetWidth ( bounds , self . CalculateWidth ( dc ) ) <EOL> bounds = RectUtils . MultiplyOrigin ( bounds , <NUM_LIT:1> / self . scale ) <EOL> return bounds <EOL> def ChangeWorkBoundsBy ( self , height ) : <EOL> """<STR_LIT>""" <EOL> Block . ChangeWorkBoundsBy ( self , height * self . scale ) <EOL> def PreDraw ( self , dc , bounds ) : <EOL> """<STR_LIT>""" <EOL> self . oldScale = dc . GetUserScale ( ) <EOL> dc . SetUserScale ( self . scale * self . oldScale [ <NUM_LIT:0> ] , self . scale * self . oldScale [ <NUM_LIT:1> ] ) <EOL> def PostDraw ( self , dc , bounds ) : <EOL> """<STR_LIT>""" <EOL> dc . SetUserScale ( * self . oldScale ) <EOL> def DrawSelf ( self , dc , bounds ) : <EOL> """<STR_LIT>""" <EOL> cellFmt = self . GetFormat ( ) <EOL> cellPadding = cellFmt . CalculateCellPadding ( ) <EOL> combined = self . GetCombinedLists ( ) <EOL> cell = list ( bounds ) <EOL> RectUtils . SetWidth ( cell , <NUM_LIT:0> ) <EOL> for x in combined : <EOL> RectUtils . SetLeft ( cell , RectUtils . Right ( cell ) ) <EOL> RectUtils . SetWidth ( cell , x . cellWidth ) <EOL> x . cell = list ( cell ) <EOL> font = self . GetFont ( ) <EOL> for x in combined : <EOL> cellBounds = RectUtils . InsetRect ( x . cell , cellPadding ) <EOL> self . DrawText ( dc , x . text , cellBounds , font , x . align , imageIndex = x . image , <EOL> canWrap = cellFmt . CanWrap , listCtrl = self . GetListCtrl ( ) ) <EOL> if cellFmt . GridPen and combined : <EOL> dc . SetPen ( cellFmt . GridPen ) <EOL> dc . SetBrush ( wx . TRANSPARENT_BRUSH ) <EOL> top = RectUtils . Top ( bounds ) <EOL> bottom = RectUtils . Bottom ( bounds ) <EOL> for x in combined [ : - <NUM_LIT:1> ] : <EOL> right = RectUtils . Right ( x . cell ) <EOL> dc . DrawLine ( right , top , right , bottom ) <EOL> left = RectUtils . Left ( combined [ <NUM_LIT:0> ] . cell ) <EOL> right = RectUtils . Right ( combined [ - <NUM_LIT:1> ] . cell ) <EOL> dc . DrawRectangle ( left , top , right - left , bottom - top ) <EOL> class ThreeCellBlock ( CellBlock ) : <EOL> """<STR_LIT>""" <EOL> def GetCellWidths ( self ) : <EOL> """<STR_LIT>""" <EOL> numNonEmptyTexts = sum ( <NUM_LIT:1> for x in self . GetTexts ( ) if x ) <EOL> if not numNonEmptyTexts : <EOL> return ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> widths = list ( ) <EOL> width = round ( RectUtils . Width ( self . GetWorkBounds ( ) ) / numNonEmptyTexts ) <EOL> for x in self . GetTexts ( ) : <EOL> if x : <EOL> widths . append ( width ) <EOL> else : <EOL> widths . append ( <NUM_LIT:0> ) <EOL> return widths <EOL> def GetAlignments ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( wx . ALIGN_LEFT , wx . ALIGN_CENTER_HORIZONTAL , wx . ALIGN_RIGHT ) <EOL> class ReportBlock ( Block ) : <EOL> """<STR_LIT>""" <EOL> def Print ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> if not self . engine . listCtrls : <EOL> return True <EOL> self . engine . AddBlock ( ListBlock ( * self . engine . listCtrls [ <NUM_LIT:0> ] ) ) <EOL> for ( lv , title ) in self . engine . listCtrls [ <NUM_LIT:1> : ] : <EOL> self . engine . AddBlock ( PageBreakBlock ( ) ) <EOL> self . engine . AddBlock ( ListBlock ( lv , title ) ) <EOL> return True <EOL> class PageHeaderBlock ( ThreeCellBlock ) : <EOL> """<STR_LIT>""" <EOL> def GetTexts ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . engine . pageHeader <EOL> class PageFooterBlock ( ThreeCellBlock ) : <EOL> """<STR_LIT>""" <EOL> def GetTexts ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . engine . pageFooter <EOL> def CalculateBounds ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> height = self . CalculateHeight ( dc ) <EOL> bounds = list ( self . GetWorkBounds ( ) ) <EOL> return [ RectUtils . Left ( bounds ) , RectUtils . Bottom ( bounds ) - height , <EOL> RectUtils . Width ( bounds ) , height ] <EOL> def ChangeWorkBoundsBy ( self , height ) : <EOL> """<STR_LIT>""" <EOL> RectUtils . MoveBottomBy ( self . engine . workBounds , - height ) <EOL> class PageBreakBlock ( Block ) : <EOL> """<STR_LIT>""" <EOL> def Print ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> bounds = self . GetWorkBounds ( ) <EOL> self . ChangeWorkBoundsBy ( RectUtils . Height ( bounds ) ) <EOL> return True <EOL> class RunningBlockPusher ( Block ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , block , push = True ) : <EOL> """<STR_LIT:U+0020>""" <EOL> self . block = block <EOL> self . push = push <EOL> def Print ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> if self . push : <EOL> self . engine . AddRunningBlock ( self . block ) <EOL> else : <EOL> self . engine . RemoveRunningBlock ( self . block ) <EOL> return True <EOL> class ListBlock ( Block ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , lv , title ) : <EOL> self . lv = lv <EOL> self . title = title <EOL> def Print ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> cellWidths = self . CalculateCellWidths ( ) <EOL> boundsWidth = RectUtils . Width ( self . GetWorkBounds ( ) ) <EOL> first = True <EOL> for ( left , right ) in self . CalculateSlices ( boundsWidth , cellWidths ) : <EOL> if not first : <EOL> self . engine . AddBlock ( PageBreakBlock ( ) ) <EOL> self . engine . AddBlock ( ListHeaderBlock ( self . lv , self . title ) ) <EOL> self . engine . AddBlock ( ListSliceBlock ( self . lv , left , right , cellWidths ) ) <EOL> self . engine . AddBlock ( ListFooterBlock ( self . lv , "<STR_LIT>" ) ) <EOL> first = False <EOL> return True <EOL> def CalculateCellWidths ( self ) : <EOL> """<STR_LIT>""" <EOL> columnHeaderFmt = self . engine . GetNamedFormat ( "<STR_LIT>" ) <EOL> cellPadding = columnHeaderFmt . CalculateCellPadding ( ) <EOL> padding = cellPadding [ <NUM_LIT:0> ] + cellPadding [ <NUM_LIT:2> ] <EOL> return [ self . lv . GetColumnWidth ( i ) + padding for i in range ( self . lv . GetColumnCount ( ) ) ] <EOL> def CalculateSlices ( self , maxWidth , columnWidths ) : <EOL> """<STR_LIT>""" <EOL> firstColumn = <NUM_LIT:0> <EOL> if hasattr ( self . lv , "<STR_LIT>" ) and self . lv . useExpansionColumn : <EOL> firstColumn = <NUM_LIT:1> <EOL> if self . IsShrinkToFit ( ) or ( sum ( columnWidths ) ) <= maxWidth : <EOL> return [ [ firstColumn , len ( columnWidths ) - <NUM_LIT:1> ] ] <EOL> pairs = list ( ) <EOL> left = firstColumn <EOL> right = firstColumn <EOL> while right < len ( columnWidths ) : <EOL> if ( sum ( columnWidths [ left : right + <NUM_LIT:1> ] ) ) > maxWidth : <EOL> if left == right : <EOL> pairs . append ( [ left , right ] ) <EOL> left += <NUM_LIT:1> <EOL> right += <NUM_LIT:1> <EOL> else : <EOL> pairs . append ( [ left , right - <NUM_LIT:1> ] ) <EOL> left = right <EOL> else : <EOL> right += <NUM_LIT:1> <EOL> if left < len ( columnWidths ) : <EOL> pairs . append ( [ left , right - <NUM_LIT:1> ] ) <EOL> return pairs <EOL> class ListHeaderBlock ( TextBlock ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , lv , title ) : <EOL> self . lv = lv <EOL> self . title = title <EOL> def GetText ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . title <EOL> class ListFooterBlock ( TextBlock ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , lv , text ) : <EOL> self . lv = lv <EOL> self . text = text <EOL> def GetText ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . text <EOL> class GroupTitleBlock ( TextBlock ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , lv , group ) : <EOL> self . lv = lv <EOL> self . group = group <EOL> def GetText ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . group . title <EOL> class ListSliceBlock ( Block ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , lv , left , right , allCellWidths ) : <EOL> self . lv = lv <EOL> self . left = left <EOL> self . right = right <EOL> self . allCellWidths = allCellWidths <EOL> def Print ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> if self . IsShrinkToFit ( ) : <EOL> scale = self . CalculateShrinkToFit ( dc ) <EOL> else : <EOL> scale = <NUM_LIT:1> <EOL> headerBlock = ColumnHeaderBlock ( self . lv , self . left , self . right , scale , self . allCellWidths ) <EOL> self . engine . AddBlock ( headerBlock ) <EOL> if self . IsColumnHeadingsOnEachPage ( ) : <EOL> self . engine . AddBlock ( RunningBlockPusher ( headerBlock ) ) <EOL> if hasattr ( self . lv , "<STR_LIT>" ) and self . lv . GetShowGroups ( ) : <EOL> self . engine . AddBlock ( GroupListRowsBlock ( self . lv , self . left , self . right , scale , self . allCellWidths ) ) <EOL> else : <EOL> self . engine . AddBlock ( ListRowsBlock ( self . lv , self . left , self . right , scale , self . allCellWidths ) ) <EOL> if self . IsColumnHeadingsOnEachPage ( ) : <EOL> self . engine . AddBlock ( RunningBlockPusher ( headerBlock , False ) ) <EOL> return True <EOL> def CalculateShrinkToFit ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> block = ColumnHeaderBlock ( self . lv , self . left , self . right , <NUM_LIT:1> , self . allCellWidths ) <EOL> block . engine = self . engine <EOL> rowWidth = block . CalculateWidth ( dc ) <EOL> boundsWidth = RectUtils . Width ( self . GetWorkBounds ( ) ) <EOL> if rowWidth > boundsWidth : <EOL> return float ( boundsWidth ) / float ( rowWidth ) <EOL> else : <EOL> return <NUM_LIT:1> <EOL> class ColumnBasedBlock ( CellBlock ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , lv , left , right , scale , allCellWidths ) : <EOL> self . lv = lv <EOL> self . left = left <EOL> self . right = right <EOL> self . scale = scale <EOL> self . allCellWidths = allCellWidths <EOL> def GetListCtrl ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . lv <EOL> def GetCellWidths ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . allCellWidths [ self . left : self . right + <NUM_LIT:1> ] <EOL> def GetColumnAlignments ( self , lv , left , right ) : <EOL> """<STR_LIT>""" <EOL> listAlignments = [ lv . GetColumn ( i ) . GetAlign ( ) for i in range ( left , right + <NUM_LIT:1> ) ] <EOL> mapping = { <EOL> wx . LIST_FORMAT_LEFT : wx . ALIGN_LEFT , <EOL> wx . LIST_FORMAT_RIGHT : wx . ALIGN_RIGHT , <EOL> wx . LIST_FORMAT_CENTRE : wx . ALIGN_CENTRE , <EOL> } <EOL> return [ mapping [ x ] for x in listAlignments ] <EOL> class ColumnHeaderBlock ( ColumnBasedBlock ) : <EOL> """<STR_LIT>""" <EOL> def GetTexts ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ self . lv . GetColumn ( i ) . GetText ( ) for i in range ( self . left , self . right + <NUM_LIT:1> ) ] <EOL> def GetAlignments ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . GetFormat ( ) . AlwaysCenter : <EOL> return [ wx . ALIGN_CENTRE for i in range ( self . left , self . right + <NUM_LIT:1> ) ] <EOL> else : <EOL> return self . GetColumnAlignments ( self . lv , self . left , self . right ) <EOL> def GetImages ( self ) : <EOL> """<STR_LIT>""" <EOL> images = list ( ) <EOL> for i in range ( self . left , self . right + <NUM_LIT:1> ) : <EOL> imageIndex = self . lv . GetColumn ( i ) . GetImage ( ) <EOL> if imageIndex == <NUM_LIT:0> : <EOL> imageIndex = - <NUM_LIT:1> <EOL> images . append ( imageIndex ) <EOL> return images <EOL> def IsUseSubstitution ( self ) : <EOL> """<STR_LIT>""" <EOL> return False <EOL> class ListRowsBlock ( Block ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , lv , left , right , scale , allCellWidths ) : <EOL> """<STR_LIT:U+0020>""" <EOL> self . lv = lv <EOL> self . left = left <EOL> self . right = right <EOL> self . scale = scale <EOL> self . allCellWidths = allCellWidths <EOL> self . currentIndex = <NUM_LIT:0> <EOL> self . totalRows = self . lv . GetItemCount ( ) <EOL> def Print ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> if self . currentIndex < self . totalRows : <EOL> self . engine . AddBlock ( RowBlock ( self . lv , self . currentIndex , self . left , self . right , self . scale , self . allCellWidths ) ) <EOL> self . currentIndex += <NUM_LIT:1> <EOL> self . engine . AddBlock ( self ) <EOL> return True <EOL> class GroupListRowsBlock ( Block ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , lv , left , right , scale , allCellWidths ) : <EOL> """<STR_LIT:U+0020>""" <EOL> self . lv = lv <EOL> self . left = left <EOL> self . right = right <EOL> self . scale = scale <EOL> self . allCellWidths = allCellWidths <EOL> self . currentIndex = <NUM_LIT:0> <EOL> self . totalRows = self . lv . GetItemCount ( ) <EOL> def Print ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> if self . currentIndex >= self . totalRows : <EOL> return True <EOL> if self . lv . GetObjectAt ( self . currentIndex ) : <EOL> self . engine . AddBlock ( RowBlock ( self . lv , self . currentIndex , self . left , self . right , self . scale , self . allCellWidths ) ) <EOL> elif self . lv . innerList [ self . currentIndex ] : <EOL> self . engine . AddBlock ( GroupTitleBlock ( self . lv , self . lv . innerList [ self . currentIndex ] ) ) <EOL> self . currentIndex += <NUM_LIT:1> <EOL> self . engine . AddBlock ( self ) <EOL> return True <EOL> class RowBlock ( ColumnBasedBlock ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , lv , rowIndex , left , right , scale , allCellWidths ) : <EOL> self . lv = lv <EOL> self . rowIndex = rowIndex <EOL> self . left = left <EOL> self . right = right <EOL> self . scale = scale <EOL> self . allCellWidths = allCellWidths <EOL> def GetFont ( self ) : <EOL> """<STR_LIT>""" <EOL> font = None <EOL> if self . engine . reportFormat . UseListCtrlTextFormat and self . GetListCtrl ( ) : <EOL> listCtrl = self . GetListCtrl ( ) <EOL> if listCtrl . IsVirtual ( ) : <EOL> attr = listCtrl . OnGetItemAttr ( self . rowIndex ) <EOL> if attr and attr . HasFont ( ) : <EOL> font = attr . GetFont ( ) <EOL> else : <EOL> font = listCtrl . GetItemFont ( self . rowIndex ) <EOL> if font and font . IsOk ( ) : <EOL> return font <EOL> else : <EOL> return self . GetFormat ( ) . GetFont ( ) <EOL> def GetTextColor ( self ) : <EOL> """<STR_LIT>""" <EOL> color = None <EOL> if self . engine . reportFormat . UseListCtrlTextFormat and self . GetListCtrl ( ) : <EOL> listCtrl = self . GetListCtrl ( ) <EOL> if listCtrl . IsVirtual ( ) : <EOL> attr = listCtrl . OnGetItemAttr ( self . rowIndex ) <EOL> if attr and attr . HasTextColour ( ) : <EOL> color = attr . GetTextColour ( ) <EOL> else : <EOL> color = listCtrl . GetItemTextColour ( self . rowIndex ) <EOL> if color and color . IsOk ( ) : <EOL> return color <EOL> else : <EOL> return self . GetFormat ( ) . GetTextColor ( ) <EOL> def IsUseSubstitution ( self ) : <EOL> """<STR_LIT>""" <EOL> return False <EOL> def GetTexts ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ self . lv . GetItem ( self . rowIndex , i ) . GetText ( ) for i in range ( self . left , self . right + <NUM_LIT:1> ) ] <EOL> def GetAlignments ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . GetColumnAlignments ( self . lv , self . left , self . right ) <EOL> def GetImages ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ self . lv . GetItem ( self . rowIndex , i ) . GetImage ( ) for i in range ( self . left , self . right + <NUM_LIT:1> ) ] <EOL> class Decoration ( object ) : <EOL> """<STR_LIT>""" <EOL> def IsDrawOver ( self ) : <EOL> """<STR_LIT>""" <EOL> return False <EOL> def SubtractFrom ( self , dc , bounds ) : <EOL> """<STR_LIT>""" <EOL> return bounds <EOL> def DrawDecoration ( self , dc , bounds , block ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class RectangleDecoration ( Decoration ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , side = None , pen = None , color = None , toColor = None , width = <NUM_LIT:0> , space = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> self . side = side <EOL> self . pen = pen <EOL> self . color = color <EOL> self . toColor = toColor <EOL> self . width = width <EOL> self . space = space <EOL> def SubtractFrom ( self , dc , bounds ) : <EOL> """<STR_LIT>""" <EOL> if self . side is None : <EOL> return RectUtils . InsetBy ( RectUtils . InsetBy ( bounds , self . space ) , self . width ) <EOL> inset = self . space + self . width <EOL> if self . side == wx . LEFT : return RectUtils . MoveLeftBy ( bounds , inset ) <EOL> if self . side == wx . RIGHT : return RectUtils . MoveRightBy ( bounds , - inset ) <EOL> if self . side == wx . TOP : return RectUtils . MoveTopBy ( bounds , inset ) <EOL> if self . side == wx . BOTTOM : return RectUtils . MoveBottomBy ( bounds , - inset ) <EOL> return bounds <EOL> def DrawDecoration ( self , dc , bounds , block ) : <EOL> """<STR_LIT>""" <EOL> rect = self . _CalculateRect ( bounds ) <EOL> if self . color : <EOL> if self . toColor is None : <EOL> dc . SetPen ( wx . TRANSPARENT_PEN ) <EOL> dc . SetBrush ( wx . Brush ( self . color ) ) <EOL> dc . DrawRectangle ( * rect ) <EOL> else : <EOL> dc . GradientFillLinear ( wx . Rect ( * rect ) , self . color , self . toColor ) <EOL> if self . pen : <EOL> dc . SetPen ( self . pen ) <EOL> dc . SetBrush ( wx . TRANSPARENT_BRUSH ) <EOL> dc . DrawRectangle ( * rect ) <EOL> def _CalculateRect ( self , bounds ) : <EOL> """<STR_LIT>""" <EOL> if self . side is None : <EOL> return bounds <EOL> if self . side == wx . LEFT : <EOL> return ( RectUtils . Left ( bounds ) , RectUtils . Top ( bounds ) , self . width , RectUtils . Height ( bounds ) ) <EOL> if self . side == wx . RIGHT : <EOL> return ( RectUtils . Right ( bounds ) - self . width , RectUtils . Top ( bounds ) , self . width , RectUtils . Height ( bounds ) ) <EOL> if self . side == wx . TOP : <EOL> return ( RectUtils . Left ( bounds ) , RectUtils . Top ( bounds ) , RectUtils . Width ( bounds ) , self . width ) <EOL> if self . side == wx . BOTTOM : <EOL> return ( RectUtils . Left ( bounds ) , RectUtils . Bottom ( bounds ) - self . width , RectUtils . Width ( bounds ) , self . width ) <EOL> return bounds <EOL> class LineDecoration ( Decoration ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , side = wx . BOTTOM , pen = None , space = <NUM_LIT:0> ) : <EOL> self . side = side <EOL> self . pen = pen <EOL> self . space = space <EOL> def SubtractFrom ( self , dc , bounds ) : <EOL> """<STR_LIT>""" <EOL> inset = self . space <EOL> if self . pen is not None : <EOL> inset += self . pen . GetWidth ( ) <EOL> if self . side == wx . LEFT : return RectUtils . MoveLeftBy ( bounds , inset ) <EOL> if self . side == wx . RIGHT : return RectUtils . MoveRightBy ( bounds , - inset ) <EOL> if self . side == wx . TOP : return RectUtils . MoveTopBy ( bounds , inset ) <EOL> if self . side == wx . BOTTOM : return RectUtils . MoveBottomBy ( bounds , - inset ) <EOL> return bounds <EOL> def DrawDecoration ( self , dc , bounds , block ) : <EOL> """<STR_LIT>""" <EOL> if self . pen == None : <EOL> return <EOL> if self . side == wx . LEFT : <EOL> pt1 = RectUtils . TopLeft ( bounds ) <EOL> pt2 = RectUtils . BottomLeft ( bounds ) <EOL> elif self . side == wx . RIGHT : <EOL> pt1 = RectUtils . TopRight ( bounds ) <EOL> pt2 = RectUtils . BottomRight ( bounds ) <EOL> elif self . side == wx . TOP : <EOL> pt1 = RectUtils . TopLeft ( bounds ) <EOL> pt2 = RectUtils . TopRight ( bounds ) <EOL> elif self . side == wx . BOTTOM : <EOL> pt1 = RectUtils . BottomLeft ( bounds ) <EOL> pt2 = RectUtils . BottomRight ( bounds ) <EOL> dc . SetPen ( self . pen ) <EOL> dc . DrawLine ( pt1 [ <NUM_LIT:0> ] , pt1 [ <NUM_LIT:1> ] , pt2 [ <NUM_LIT:0> ] , pt2 [ <NUM_LIT:1> ] ) <EOL> class WatermarkDecoration ( Decoration ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , text , font = None , color = None , angle = <NUM_LIT:30> , over = True ) : <EOL> """<STR_LIT:U+0020>""" <EOL> self . text = text <EOL> self . color = color or wx . Color ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . font = font or wx . FFont ( <NUM_LIT> , wx . SWISS , <NUM_LIT:0> ) <EOL> self . angle = angle <EOL> self . over = over <EOL> def IsDrawOver ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . over <EOL> def DrawDecoration ( self , dc , bounds , block ) : <EOL> """<STR_LIT>""" <EOL> dc . SetFont ( self . font ) <EOL> dc . SetTextForeground ( self . color ) <EOL> cx , cy = RectUtils . Center ( bounds ) <EOL> w , h = dc . GetTextExtent ( self . text ) <EOL> x = cx - w / <NUM_LIT:2> <EOL> y = cy - h / <NUM_LIT:2> + ( w / <NUM_LIT:2> * math . sin ( math . radians ( self . angle ) ) ) <EOL> dc . DrawRotatedText ( self . text , x , y , self . angle ) <EOL> class ImageDecoration ( Decoration ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , image = None , horizontalAlign = wx . CENTER , verticalAlign = wx . CENTER , over = True ) : <EOL> """<STR_LIT>""" <EOL> self . horizontalAlign = horizontalAlign <EOL> self . verticalAlign = verticalAlign <EOL> self . over = True <EOL> self . bitmap = image <EOL> if isinstance ( image , wx . Image ) : <EOL> self . bitmap = wx . BitmapFromImage ( image ) <EOL> def DrawDecoration ( self , dc , bounds , block ) : <EOL> """<STR_LIT>""" <EOL> if not self . bitmap : <EOL> return <EOL> if self . horizontalAlign == wx . LEFT : <EOL> x = RectUtils . Left ( bounds ) <EOL> elif self . horizontalAlign == wx . RIGHT : <EOL> x = RectUtils . Right ( bounds ) - self . bitmap . Width <EOL> else : <EOL> x = RectUtils . CenterX ( bounds ) - self . bitmap . Width / <NUM_LIT:2> <EOL> if self . verticalAlign == wx . TOP : <EOL> y = RectUtils . Top ( bounds ) <EOL> elif self . verticalAlign == wx . BOTTOM : <EOL> y = RectUtils . Bottom ( bounds ) - self . bitmap . Height <EOL> else : <EOL> y = RectUtils . CenterY ( bounds ) - self . bitmap . Height / <NUM_LIT:2> <EOL> dc . DrawBitmap ( self . bitmap , x , y , True ) <EOL> class Bucket ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , ** kwargs ) : <EOL> self . __dict__ . update ( kwargs ) <EOL> def __repr__ ( self ) : <EOL> strs = [ "<STR_LIT>" % kv for kv in self . __dict__ . items ( ) ] <EOL> return "<STR_LIT>" + "<STR_LIT:U+002CU+0020>" . join ( strs ) + "<STR_LIT:)>" <EOL> class RectUtils : <EOL> """<STR_LIT>""" <EOL> @ staticmethod <EOL> def Left ( r ) : return r [ <NUM_LIT:0> ] <EOL> @ staticmethod <EOL> def Top ( r ) : return r [ <NUM_LIT:1> ] <EOL> @ staticmethod <EOL> def Width ( r ) : return r [ <NUM_LIT:2> ] <EOL> @ staticmethod <EOL> def Height ( r ) : return r [ <NUM_LIT:3> ] <EOL> @ staticmethod <EOL> def Right ( r ) : return r [ <NUM_LIT:0> ] + r [ <NUM_LIT:2> ] <EOL> @ staticmethod <EOL> def Bottom ( r ) : return r [ <NUM_LIT:1> ] + r [ <NUM_LIT:3> ] <EOL> @ staticmethod <EOL> def TopLeft ( r ) : return [ r [ <NUM_LIT:0> ] , r [ <NUM_LIT:1> ] ] <EOL> @ staticmethod <EOL> def TopRight ( r ) : return [ r [ <NUM_LIT:0> ] + r [ <NUM_LIT:2> ] , r [ <NUM_LIT:1> ] ] <EOL> @ staticmethod <EOL> def BottomLeft ( r ) : return [ r [ <NUM_LIT:0> ] , r [ <NUM_LIT:1> ] + r [ <NUM_LIT:3> ] ] <EOL> @ staticmethod <EOL> def BottomRight ( r ) : return [ r [ <NUM_LIT:0> ] + r [ <NUM_LIT:2> ] , r [ <NUM_LIT:1> ] + r [ <NUM_LIT:3> ] ] <EOL> @ staticmethod <EOL> def CenterX ( r ) : return r [ <NUM_LIT:0> ] + r [ <NUM_LIT:2> ] / <NUM_LIT:2> <EOL> @ staticmethod <EOL> def CenterY ( r ) : return r [ <NUM_LIT:1> ] + r [ <NUM_LIT:3> ] / <NUM_LIT:2> <EOL> @ staticmethod <EOL> def Center ( r ) : return [ r [ <NUM_LIT:0> ] + r [ <NUM_LIT:2> ] / <NUM_LIT:2> , r [ <NUM_LIT:1> ] + r [ <NUM_LIT:3> ] / <NUM_LIT:2> ] <EOL> @ staticmethod <EOL> def SetLeft ( r , l ) : <EOL> r [ <NUM_LIT:0> ] = l <EOL> return r <EOL> @ staticmethod <EOL> def SetTop ( r , t ) : <EOL> r [ <NUM_LIT:1> ] = t <EOL> return r <EOL> @ staticmethod <EOL> def SetWidth ( r , w ) : <EOL> r [ <NUM_LIT:2> ] = w <EOL> return r <EOL> @ staticmethod <EOL> def SetHeight ( r , h ) : <EOL> r [ <NUM_LIT:3> ] = h <EOL> return r <EOL> @ staticmethod <EOL> def MoveLeftBy ( r , delta ) : <EOL> r [ <NUM_LIT:0> ] += delta <EOL> r [ <NUM_LIT:2> ] -= delta <EOL> return r <EOL> @ staticmethod <EOL> def MoveTopBy ( r , delta ) : <EOL> r [ <NUM_LIT:1> ] += delta <EOL> r [ <NUM_LIT:3> ] -= delta <EOL> return r <EOL> @ staticmethod <EOL> def MoveRightBy ( r , delta ) : <EOL> r [ <NUM_LIT:2> ] += delta <EOL> return r <EOL> @ staticmethod <EOL> def MoveBottomBy ( r , delta ) : <EOL> r [ <NUM_LIT:3> ] += delta <EOL> return r <EOL> @ staticmethod <EOL> def InsetBy ( r , delta ) : <EOL> if delta is None : <EOL> return r <EOL> try : <EOL> delta [ <NUM_LIT:0> ] <EOL> return RectUtils . InsetRect ( r , delta ) <EOL> except : <EOL> return RectUtils . InsetRect ( r , ( delta , delta , delta , delta ) ) <EOL> @ staticmethod <EOL> def InsetRect ( r , r2 ) : <EOL> if r2 is None : <EOL> return r <EOL> else : <EOL> return [ r [ <NUM_LIT:0> ] + r2 [ <NUM_LIT:0> ] , r [ <NUM_LIT:1> ] + r2 [ <NUM_LIT:1> ] , r [ <NUM_LIT:2> ] - ( r2 [ <NUM_LIT:0> ] + r2 [ <NUM_LIT:2> ] ) , r [ <NUM_LIT:3> ] - ( r2 [ <NUM_LIT:1> ] + r2 [ <NUM_LIT:3> ] ) ] <EOL> @ staticmethod <EOL> def MultiplyOrigin ( r , factor ) : <EOL> return [ r [ <NUM_LIT:0> ] * factor , r [ <NUM_LIT:1> ] * factor , r [ <NUM_LIT:2> ] , r [ <NUM_LIT:3> ] ] <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import wx <EOL> from ObjectListView import ObjectListView , FastObjectListView , GroupListView , ColumnDefn <EOL> import sys <EOL> sys . path . append ( "<STR_LIT>" ) <EOL> import ExampleModel <EOL> import ExampleImages <EOL> class MyFrame ( wx . Frame ) : <EOL> def __init__ ( self , * args , ** kwds ) : <EOL> kwds [ "<STR_LIT>" ] = wx . DEFAULT_FRAME_STYLE <EOL> wx . Frame . __init__ ( self , * args , ** kwds ) <EOL> self . panel = wx . Panel ( self , - <NUM_LIT:1> ) <EOL> self . lv = GroupListView ( self . panel , - <NUM_LIT:1> , style = wx . LC_REPORT | wx . SUNKEN_BORDER ) <EOL> sizer_2 = wx . BoxSizer ( wx . VERTICAL ) <EOL> sizer_2 . Add ( self . lv , <NUM_LIT:1> , wx . ALL | wx . EXPAND , <NUM_LIT:4> ) <EOL> self . panel . SetSizer ( sizer_2 ) <EOL> self . panel . Layout ( ) <EOL> sizer_1 = wx . BoxSizer ( wx . VERTICAL ) <EOL> sizer_1 . Add ( self . panel , <NUM_LIT:1> , wx . EXPAND ) <EOL> self . SetSizer ( sizer_1 ) <EOL> self . Layout ( ) <EOL> musicImage = self . lv . AddImages ( ExampleImages . getMusic16Bitmap ( ) , ExampleImages . getMusic32Bitmap ( ) ) <EOL> artistImage = self . lv . AddImages ( ExampleImages . getUser16Bitmap ( ) , ExampleImages . getUser32Bitmap ( ) ) <EOL> self . lv . SetColumns ( [ <EOL> ColumnDefn ( "<STR_LIT>" , "<STR_LIT:left>" , <NUM_LIT:200> , "<STR_LIT:title>" , imageGetter = musicImage ) , <EOL> ColumnDefn ( "<STR_LIT>" , "<STR_LIT:left>" , <NUM_LIT> , "<STR_LIT>" , imageGetter = artistImage ) , <EOL> ColumnDefn ( "<STR_LIT>" , "<STR_LIT:left>" , <NUM_LIT:100> , "<STR_LIT>" ) , <EOL> ColumnDefn ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:100> , "<STR_LIT>" ) , <EOL> ColumnDefn ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:100> , "<STR_LIT>" ) , <EOL> ] ) <EOL> self . lv . SetSortColumn ( self . lv . columns [ <NUM_LIT:2> ] ) <EOL> self . lv . SetObjects ( ExampleModel . GetTracks ( ) ) <EOL> wx . CallLater ( <NUM_LIT:50> , self . run ) <EOL> def run ( self ) : <EOL> printer = ListCtrlPrinter ( self . lv , "<STR_LIT>" ) <EOL> printer . ReportFormat = ReportFormat . Normal ( ) <EOL> printer . ReportFormat . WatermarkFormat ( over = True ) <EOL> printer . ReportFormat . IsColumnHeadingsOnEachPage = True <EOL> printer . PageHeader = "<STR_LIT>" <EOL> printer . PageFooter = ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> printer . Watermark = "<STR_LIT>" <EOL> printer . PrintPreview ( self ) <EOL> app = wx . PySimpleApp ( <NUM_LIT:0> ) <EOL> wx . InitAllImageHandlers ( ) <EOL> frame_1 = MyFrame ( None , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> app . SetTopWindow ( frame_1 ) <EOL> frame_1 . Show ( ) <EOL> app . MainLoop ( ) </s>
