U
    '1e3                     @   sn   d Z dZddlmZ ddlmZmZmZmZ ddl	m
Z
 ddlmZ G dd deZd	d
 Zedkrje  dS )z3.3.0zThis file is a
    )colors)RectDrawingGroupString)Label)Widgetc                   @   sL   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dS )EventCalendarc                 C   sj   d| _ d| _d| _d| _d | _d| _g | _d | _d | _d | _	d| _
g | _d | _d | _d| _g | _g | _d S )Nr   i,        )xywidthheighttimeColWidthtrackRowHeightdataZ
trackNames	startTimeendTimeday_talksVisible
_startTime_endTime_trackCount
_colWidths_colLeftEdges)self r   G/tmp/pip-unpacked-wheel-109iniqw/reportlab/graphics/widgets/eventcal.py__init__   s"    zEventCalendar.__init__c                 C   s   |  | j| _t|  | _|   | jg| _| j	dkr| j
d| j  }|gd| j  | _t| jD ]}| j| jd |  qdnN| j	g| _| j
| j	 | j }t| jD ]&}| j| | j| jd |  qdS )z4Called at start of draw.  Sets various column widthsN   )getRelevantTalksr   r   lengetAllTracksr   computeStartAndEndTimesr   r   r   r   r   rangeappend)r   wir   r   r   computeSize*   s    


zEventCalendar.computeSizec                 C   s   | j r| j | _n:| jD ]2\}}}}}}| jdkr8|| _q|| jk r|| _q| jrZ| j| _nF| jD ]>\}}}}}}| jdkr|| | _q`|| | jkr`|| | _q`dS )z(Work out first and last times to displayN)r   r   r   r   r   )r   titlespeakertrackIdr   startdurationr   r   r   r%   >   s    




z%EventCalendar.computeStartAndEndTimesc                 C   sB   g }| j D ]*\}}}}}}|d k	r
||kr
|| q
|  |S )N)r   r'   sort)r   Ztracksr+   r,   r-   r   hoursr/   r   r   r   r$   X   s    zEventCalendar.getAllTracksc           
      C   sr   g }|D ]d}|\}}}}}}	|dks,t d|| jkr| jdksN||	 | jkr| jdksb|| jkr|| q|S )zScans for tracks actually usedr   z2trackId must be None or 1,2,3... zero not allowed!N)AssertionErrorr   r   r   r'   )
r   ZtalkListusedtalkr+   r,   r-   r   r1   r/   r   r   r   r"   a   s    
zEventCalendar.getRelevantTalksc                 C   s8   | j | j }|| j | j| j  }| j| ||  }|S )z+Return y-value corresponding to times given)r   r   r   r   r   )r   ZtheTimeZ
axisHeightZproportionUpr   r   r   r   	scaleTimem   s    zEventCalendar.scaleTimec                 C   s   t  }| || }| |}|| }|dkrJ| jd }	| j| jd  }
n| j| }	| j| }
t }|| ||	d|
  |d|   d|_|
|_||_	d|_
t|	||
|tjd}|| || |S )z!Return shapes for a specific talkNr    r         ?c   Z	fillColor)r   r5   r   r   r   r   ZsetTextZ	setOriginZ	boxAnchorr   ZfontSizer   r   Zcyanadd)r   r   r/   r-   textgZy_bottomZy_topZy_heightr   r   Zlabrr   r   r   getTalkRectv   s(    






zEventCalendar.getTalkRectc              	   C   s
  |    t }|t| j| j| jd | j| j t	j
d | j| jd  }| j| j | j }t| jD ]`}| j|d  }t|||| jt	jd}t|d|  |d| dd}|| || || }qf| jD ]6}|\}	}
}}}}| ||||	d |
 }|| q|S )	Nr   r9   r    r6   zTrack %dZmiddle)Zalign
)r*   r   r:   r   r   r   r   r   r   r   Zcornsilkr&   r   Zyellowr   r   r>   )r   r<   r   r   ZtrkZwidr=   sr4   r+   r,   r-   r   r.   r/   r   r   r   draw   s"    ,



zEventCalendar.drawN)__name__
__module____qualname__r   r*   r%   r$   r"   r5   r>   rA   r   r   r   r   r	      s   		!r	   c               B   C   s   t dd} t }d|_d|_ddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFgB|_dG|_| | dHD ].}| |}tdI| dJ	| t
dK|  qdLS )Mz3Make a conference event for day 1 of UP Python 2003i     2      )z1Keynote: Why design another programming language?zGuido van RossumNr          "@      ?)zSiena Web Service ArchitecturezMarc-Andre Lemburgr    r          %@      ?)zExtreme Programming in PythonzChris Withers   r    rJ   rK   )zPattern Experiences in C++zMark Radford   r    rJ   rK   )z"What is the Type of std::toupper()zGabriel Dos Reis   r    rJ   rK   )z6Linguistic Variables: Clear Thinking with Fuzzy Logic zWalter Banks   r    rJ   rK   )0lunch, short presentations, vendor presentations Nr          (@       @)zCORBA? Isn't that obsoletezDuncan Grisbyr    r          ,@rK   )zPython Design PatternsDuncan BoothrL   r    rT   rK   )z*Inside Security Checks and Safe ExceptionsBrandon BrayrM   r    rT   rK   )zStudying at a DistanceCPanel Discussion, Panel to include Alan Lenton & Francis GlassborowrN   r    rT   rK   )zRCoding Standards - Given the ANSI C Standard why do I still need a coding StandardRandy MarquesrO   r    rT   rK   )zRESTful PythonzHamish Lawsonr    r          0@rK   )z(Parsing made easier - a radical old ideazAndrew KoenigrL   r    rY   rK   )zC++ & MultimethodszJulian SmithrM   r    rY   rK   )zC++ ThreadingzKevlin HenneyrN   r    rY   rK   )zThe Organisation Strikes BackzAlan Griffiths & Sarah LeesrO   r    rY   rK   )Birds of a Feather meetingrQ   Nr         1@rS   )zKeynote: In the Spirit of CzGreg ColvinNrL   rH   rI   )z6The Infinite Filing Cabinet - object storage in PythonzJacob Hallenr    rL   rJ   rK   )z>Introduction to Python and Jython for C++ and Java ProgrammerszAlex MartellirL   rL   rJ   rK   )z#Template metaprogramming in HaskellzSimon Peyton JonesrM   rL   rJ   rK   )zQPlenty People Programming: C++ Programming in a Group, Workshop with a differencezNico JosuttisrN   rL   rJ   rK   )z4Design and Implementation of the Boost Graph LibraryzJeremy SiekrO   rL   rJ   rK   )rP   rQ   NrL   rR   rS   )z5Building GUI Applications with PythonCard and PyCrustz	Andy Toddr    rL   rT   rK   )zIntegrating Python, C and C++rU   rL   rL   rT   rK   )z!Secrets and Pitfalls of Templatesz$Nicolai Josuttis & David VandevoorderM   rL   rT   rK   )zBeing a MentorrW   rN   rL   rT   rK   )zThe Embedded C Extensions to CzWillem WakkerrO   rL   rT   rK   )zLightning Talksz
Paul Brianr    rL   rY   rK   )z'Scripting Java Applications with JythonzAnthony EdenrL   rL   rY   rK   )z5Metaprogramming and the Boost Metaprogramming LibraryDavid AbrahamsrM   rL   rY   rK   )z6A Common Vendor ABI for C++ -- GCC's why, what and notz!Nathan Sidwell & Gabriel Dos ReisrN   rL   rY   rK   )zThe Timing and Cost of ChoiceszHubert MatthewsrO   rL   rY   rK   )rZ   rQ   NrL   r[   rS   )z.Keynote: The Cost of C &amp; C++ CompatibilityzAndy KoenigNrM   rH   rI   )z4Prying Eyes: Generic Observer Implementations in C++Andrei Alexandrescur    rL   rJ   rK   )z.The Roadmap to Generative Programming With C++zUlrich EiseneckerrL   rL   rJ   rK   )z=Design Patterns in C++ and C# for the Common Language RuntimerV   rM   rL   rJ   rK   )z@Extreme Hour (XH): (workshop) - Jutta Eckstein and Nico JosuttiszJutta EcsteinrN   rL   rJ   rK   )z.The Lambda Library : Unnamed Functions for C++zJaako JarvirO   rL   rJ   rK   )rP   rQ   NrM   rR   rS   )zReflective MetaprogrammingzDaveed Vandevoorder    rM   rT   rK   )z7Advanced Template Issues and Solutions (double session)zHerb SutterrL   rM   rT   rM   )z/Concurrent Programming in Java (double session)zAngelika LangerrM   rM   rT   rM   )z)What can MISRA-C (2nd Edition) do for us?zChris HillsrN   rM   rT   rK   )z(C++ Metaprogramming Concepts and ResultszWalter E BrownrO   rM   rT   rK   )z3Binding C++ to Python with the Boost Python Libraryr\   r    rM   rY   rK   )zHUsing Aspect Oriented Programming for Enterprise Application IntegrationzArno SchmidmeierrN   rM   rY   rK   )zDefective C++zMarc PaternorO   rM   rY   rK   )z.Speakers' Banquet & Birds of a Feather meetingrQ   NrM   r[   rS   )z=Keynote: The Internet, Software and Computers - A Report CardzAlan LentonNrN   rH   rI   )zEMulti-Platform Software Development; Lessons from the Boost librarieszBeman Dawesr    rO   rJ   rK   )zThe Stability of the C++ ABIzSteve ClamagerL   rO   rJ   rK   )zJGeneric Build Support - A Pragmatic Approach to the Software Build ProcessrX   rM   rO   rJ   rK   )z0How to Handle Project Managers: a survival guidez	Barb ByrorN   rO   rJ   rK   )zlunch, ACCU AGMrQ   NrO   rR   rS   )zESauce: An OO recursive descent parser; its design and implementation.z
Jon Jaggerr    rO   rT   rK   )zKGNIRTS ESAC REWOL -  Bringing the UNIX filters to the C++ iostream library.zJC van WinkelrL   rO   rT   rK   )z Pattern Writing: Live and DirectzFrank Buschmann & Kevlin HenneyrM   rO   rT   g      @)z5The Future of Programming Languages - A Goldfish BowlzFrancis Glassborow and friendsrM   rO   rT   rK   )zSHoney, I Shrunk the Threads: Compile-time checked multithreaded transactions in C++r]   r    rO   rY   rK   )z#Fun and Functionality with FunctorszLois GoldthwaiterL   rO   rY   rK   )zAgile Enough?zAlan GriffithsrN   rO   rY   rK   )z+Conference Closure: A brief plenary sessionrQ   NrO   r[   r6   r    )Zpdfzeventcal.%swbzsaved eventcal.%sN)r   r	   r   r   r   r   r:   asStringopenwriteprint)dcalformatoutr   r   r   test   s    
c

rg   __main__N)__version____doc__Zreportlab.libr   Zreportlab.graphics.shapesr   r   r   r   Z$reportlab.graphics.charts.textlabelsr   Zreportlab.graphics.widgetbaser   r	   rg   rB   r   r   r   r   <module>   s    %v