3
7ßL]c  ã               @   sv   d Z ddlZddlmZmZmZmZ ddlmZm	Z	 ddl
mZ ddlmZ ddlmZ eeƒG d	d
„ d
e	eƒƒZdS )z$ Enthought pyface package component
é    N)ÚInstanceÚIntÚprovidesÚUnicode)ÚIHeadingTextÚMHeadingText)ÚImageResource)Únew_font_likeé   )ÚWidgetc                   sn   e Zd ZdZedƒZedƒZee	e	dƒƒZ
‡ fdd„Zdd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Z‡  ZS )ÚHeadingTextzz The toolkit specific implementation of a HeadingText.  See the
    IHeadingText interface for the API documentation.
    r
   ZDefaultZheading_level_1c                s"   t t| ƒjf |Ž | j|ƒ| _dS )z Creates the panel. N)Úsuperr   Ú__init__Ú_create_controlÚcontrol)ÚselfÚparentZtraits)Ú	__class__© ú=/tmp/pip-install-5sebvq2j/pyface/pyface/ui/wx/heading_text.pyr   4   s    zHeadingText.__init__c             C   s    | j jƒ }|jƒ | _tjtjƒ}tj|dtjtj	B d�}|j
|ƒ |jdƒ ttjtjd�| _| j| j| jƒ\}}|j||fƒ tj|| jƒ tj|| jƒ |S )zA Create the toolkit-specific control that represents the widget. r
   )ÚstyleT)Úfamilyéÿÿÿÿ)ÚimageZcreate_imageZConvertToBitmapÚ_bmpÚwxZBoxSizerZVERTICALZPanelZCLIP_CHILDRENZSIMPLE_BORDERZSetSizerZSetAutoLayoutr	   ZNORMAL_FONTZSWISSÚ_fontÚ_get_preferred_sizeÚtextZ
SetMinSizeZ	EVT_PAINTÚ_on_paint_backgroundZEVT_ERASE_BACKGROUNDÚ_on_erase_background)r   r   r   ZsizerZpanelÚwidthÚheightr   r   r   r   C   s    



zHeadingText._create_controlc             C   s0   t jƒ }|j|ƒ |j|ƒ\}}|d |d fS )z. Calculates the preferred size of the widget. é
   )r   ZScreenDCÚSetFontZGetTextExtent)r   r   ÚfontÚdcr!   r"   r   r   r   r   Z   s    
zHeadingText._get_preferred_sizec             C   s\   | j jƒ }| j jƒ }d}x>||k rVd}x$||k rJ|j| j ||ƒ || }q(W || }qW dS )z Tiles the background image. r   N)r   ZGetWidthZ	GetHeightZ
DrawBitmap)r   r&   r!   r"   ÚwÚhÚxÚyr   r   r   Ú_tile_background_imaged   s    



z"HeadingText._tile_background_imagec             C   s   | j dk	r| j jƒ  dS )z" Called when the text is changed. N)r   ZRefresh)r   Únewr   r   r   Ú_text_changedw   s    

zHeadingText._text_changedc             C   sH   t j| jƒ}| jjƒ }| j||j|jƒ |j| jƒ |j	| j
ddƒ dS )z5 Called when the background of the panel is painted. é   é   N)r   ZPaintDCr   ÚGetClientSizer+   r!   r"   r$   r   ÚDrawTextr   )r   Úeventr&   Úsizer   r   r   r   �   s    
z HeadingText._on_paint_backgroundc             C   sD   |j ƒ }| jjƒ }| j||j|jƒ |j| jƒ |j| j	ddƒ dS )z4 Called when the background of the panel is erased. r.   r/   N)
ZGetDCr   r0   r+   r!   r"   r$   r   r1   r   )r   r2   r&   r3   r   r   r   r    �   s    
z HeadingText._on_erase_background)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úlevelr   r   r   r   r   r   r   r   r+   r-   r   r    Ú__classcell__r   r   )r   r   r   !   s   

r   )r7   r   Z
traits.apir   r   r   r   Zpyface.i_heading_textr   r   Zpyface.image_resourcer   Zpyface.wx.util.font_helperr	   Zwidgetr   r   r   r   r   r   Ú<module>   s   