a
    §ˆcA  ã                   @   sò   d Z ddlmZ ddlmZ ddlmZmZm	Z	 ej
jjej
jjej
jjej
jjej
jjej
jjdœZej
jjej
jjej
jjdœZej
jjej
jjdœZg d¢Zd	d
„ Zdd„ ZG dd„ dej
ƒZG dd„ deƒZdd„ Z eeƒ eƒ e d�Z!dS )z) Trait definition for a PyQt-based font.
é    )ÚQtGui)ÚFont)ÚTraitÚTraitHandlerÚ
TraitError)ÚdefaultÚ
decorativeÚromanÚscriptÚswissÚmodern)ZslantZobliqueZitalic)ÚlightZbold)ÚptZpointÚfamilyc              
   C   s¸   t jjjdt jjjdt jjjdt jjjdt jjjdi |  	¡ d¡}t jj
jdt jj
jdi |  ¡ d¡}t jjjd	t jjjd
i |  ¡ d¡}d}|  ¡ ršd}d|  ¡ t|  ¡ ƒ|||f S )z5Converts a QFont into a string description of itself.r   r	   r
   r   r   Ú z Lightz Boldz Obliquez Italicz
 underlinez%s point %s%s%s%s)r   ÚQFontÚ	StyleHintÚ
DecorativeÚSerifÚCursiveÚ	SansSerifÚ
TypeWriterÚgetZ	styleHintÚWeightÚLightÚBoldÚweightÚStyleÚStyleObliqueÚStyleItalicÚstyleÚ	underlineÚ	pointSizeÚstrr   )ÚfontÚ
style_hintr   r    r!   © r&   úZ/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/traitsui/qt4/font_trait.pyÚfont_to_str<   s4    




ûúÿ

þý
ûr(   c              	   C   sj  t | tƒrt|  ¡ ƒS t | tjƒr*t| ƒS d}d}tjjj}tjjj	}tjj
j}d}g }|  ¡ D ]Ž}| ¡ }	|	tv r~t|	 }q`|	tv r�t|	 }q`|	tv r¢t|	 }q`|	dkr°d}q`|	tvr`|du räzt|	ƒ}W q`W n tyâ   Y n0 | |¡ q`|rþd |¡}|�rt|ƒ}
ntƒ }
|
 |¡ |
 |¡ |
 |¡ |
 |¡ |du �r\|
 tj ¡  ¡ ¡ n
|
 |¡ |
S )zkCreate a TraitsFont object.

    This can take either a string description, a QFont, or a Pyface Font.
    Nr   Fr!   Tú )Ú
isinstanceÚ
PyfaceFontÚ
TraitsFontZ
to_toolkitr   r   r   ÚAnyStyler   ZStyleNormalr   ZNormalÚsplitÚlowerÚfont_familiesÚfont_stylesÚfont_weightsÚ
font_noiseÚintÚ
ValueErrorÚappendÚjoinZsetStyleHintZsetStyleZ	setWeightZsetUnderlineZsetPointSizeZQApplicationr$   r"   )ÚvalueZ
point_sizer   r%   r    r   r!   ZfacenameÚwordZlwordZfntr&   r&   r'   Úcreate_traitsfontX   sT    














r:   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )r,   zA Traits-specific QFont.c                 C   s   t t| ƒffS )z3Returns the pickleable form of a TraitsFont object.)r:   r(   )ÚselfÚprotocolr&   r&   r'   Ú__reduce_ex__•   s    zTraitsFont.__reduce_ex__c                 C   s   t | ƒS )z%Returns a printable form of the font.)r(   ©r;   r&   r&   r'   Ú__str__™   s    zTraitsFont.__str__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r=   r?   r&   r&   r&   r'   r,   ’   s   r,   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚTraitPyQtFontzžEnsures that values assigned to a trait attribute are valid font
    descriptor strings; the value actually assigned is the corresponding
    TraitsFont.
    c                 C   s:   |du rdS z
t |ƒW S    Y n0 t||dt|ƒƒ‚dS )z§Validates that the value is a valid font descriptor string. If so,
        it returns the corresponding TraitsFont; otherwise, it raises a
        TraitError.
        Nza font descriptor string)r:   r   Úrepr)r;   ÚobjectÚnamer8   r&   r&   r'   Úvalidate©   s    
zTraitPyQtFont.validatec                 C   s   dS )NzXa string describing a font (e.g. '12 pt bold italic swiss family Arial' or 'default 12')r&   r>   r&   r&   r'   Úinfo¸   s    ÿzTraitPyQtFont.infoN)r@   rA   rB   rC   rH   rI   r&   r&   r&   r'   rD   £   s   rD   c                  O   s   ddl m} || i |¤ŽS )Nr   )ÚToolkitEditorFactory)Ztraitsui.qt4.font_editorrJ   )ÚargsZtraitsrJ   r&   r&   r'   Úget_font_editorÊ   s    rL   )ZeditorN)"rC   Z	pyface.qtr   Zpyface.fontr   r+   Z
traits.apir   r   r   r   r   r-   r   r   r   r   r   r0   r   r   r   r1   r   r   r   r2   r3   r(   r:   r,   rD   rL   ZPyQtFontr&   r&   r&   r'   Ú<module>   s,   	úý:'
