³ò
0ŽGc        
   @   sç  d  Z  d d k Z d d k Z d d k Z d d k Z d d k l Z d d k l Z l	 Z	 l
 Z
 d Z e i e Z d g Z d a d a h  Z d a d „  Z d	 a d
 d( d „  ƒ  YZ d a d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" d d) d „  ƒ  YZ# d e$ f d „  ƒ  YZ% d d* d „  ƒ  YZ& d  e$ f d! „  ƒ  YZ' h  e# d" <e% d# <e' d$ <Z( h  Z) d% „  Z* d d& „ Z+ d' „  Z, d S(+   sœ   Generates the xml code for the app in XRC format.
Calls the appropriate ``writers'' of the various objects. These functions
return an instance of XrcObject
iÿÿÿÿN(   t   XmlParsingError(   t   escapet	   quoteattrt   unescapet   XRCt   xrci    c         C   s   d |  S(   Ns       (    (   t   number(    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt   tabs%   s    s
   ISO-8859-1t	   XrcObjectc           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sf       Class to produce the XRC code for a given widget. This is a base class
    which does nothing
    c         C   s   h  |  _  g  |  _ d  S(   N(   t
   propertiest   children(   t   self(    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt   __init__0   s    	c         C   s   d  S(   N(    (   R   t   childt   out_filet   ntabs(    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt   write_child_prologue4   s    c         C   s   d  S(   N(    (   R   R   R   R   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt   write_child_epilogue5   s    c         C   s   d  S(   N(    (   R   t   namet   valt   outfileR   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt   write_property6   s    c         C   s   d  S(   N(    (   R   R   R   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt   write7   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R   (    (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   +   s   				t   SizerItemXrcObjectc           B   s    e  Z d  Z d „  Z d „  Z RS(   s(       XrcObject to handle sizer items
    c         C   s5   t  i |  ƒ | |  _ | |  _ | |  _ | |  _ d  S(   N(   R   R   t   objt   optiont   flagt   border(   R   R   R   R   R   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   L   s
    			c         C   sï   | i  } | t | ƒ d ƒ |  i d j o# | t | d ƒ d |  i ƒ n |  i o3 |  i d j o# | t | d ƒ d |  i ƒ n |  i d j o# | t | d ƒ d |  i ƒ n |  i i  | | d ƒ | t | ƒ d ƒ d  S(   Ns   <object class="sizeritem">
t   0i   s   <option>%s</option>
s   <flag>%s</flag>
s   <border>%s</border>
s
   </object>
(   R   R   R   R   R   R   (   R   R   R   R   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   S   s    	###(   R   R   R   R   R   (    (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   H   s   	t   SpacerXrcObjectc           B   s    e  Z d  Z d „  Z d „  Z RS(   s$       XrcObject to handle widgets
    c         C   s(   | |  _  | |  _ | |  _ | |  _ d  S(   N(   t   size_strR   R   R   (   R   R!   R   R   R   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   g   s    			c         C   sý   | i  } | t | ƒ d ƒ | t | d ƒ d |  i i ƒ  ƒ |  i d j o# | t | d ƒ d |  i ƒ n |  i o3 |  i d j o# | t | d ƒ d |  i ƒ n |  i d j o# | t | d ƒ d |  i ƒ n | t | ƒ d ƒ d  S(	   Ns   <object class="spacer">
i   s   <size>%s</size>
R   s   <option>%s</option>
s   <flag>%s</flag>
s   <border>%s</border>
s
   </object>
(   R   R   R!   t   stripR   R   R   (   R   R   R   R   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   m   s    	%###(   R   R   R   R   R   (    (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR    c   s   	t   DefaultXrcObjectc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s\       Standard XrcObject for every widget, used if no specific XrcObject is
    available
    c         C   sJ   t  i |  ƒ | i |  _ | |  _ | i |  _ | i |  _ | i |  _ d  S(   N(   R   R   R	   t   code_objR   t   baset   klasst   subclass(   R   R$   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR      s    	c         C   sE   | o: t  | ƒ } | i t | ƒ d | t  | ƒ | f ƒ n d  S(   Ns   <%s>%s</%s>
(   R   R   R   (   R   R   R   R   R   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   ‰   s    c         C   s¢  | i  } |  i i o% | t | ƒ d t |  i ƒ ƒ nŽ |  i oS |  i |  i j o@ | t | ƒ d t |  i ƒ t |  i ƒ t |  i ƒ f ƒ n1 | t | ƒ d t |  i ƒ t |  i ƒ f ƒ t | d ƒ } |  i i	 d ƒ o= |  i d i
 d ƒ o |  i d |  i d <n |  i d =n |  i i	 d ƒ o= |  i d i
 d ƒ o |  i d |  i d	 <n |  i d =n |  i i	 d
 ƒ o |  i d
 } |  i d
 =n d  } t |  i i d d ƒ ƒ } | o | d j o |  i d =n d |  i j o |  i d =n d |  i j oV xE |  i d i ƒ  D]0 \ } } | | d t | ƒ t | ƒ f ƒ q+W|  i d =n d |  i j oM y t |  i d ƒ }	 Wn t }	 n X|	 o d |  i d <n |  i d =n d |  i j o+ | |  i d i d d ƒ ƒ |  i d =n d |  i j o |  i d =n d |  i j o+ |  i d }
 |  i d =|  i i |
 ƒ n x= |  i i ƒ  D], \ } }	 |  i t | ƒ |	 | | d ƒ qnW| o | | d ƒ t | d ƒ } xR | i ƒ  D]D \ } }	 |	 o1 | | d t | ƒ t |	 ƒ t | ƒ f ƒ qÐqÐW| t | d ƒ d ƒ n xS |  i D]H } |  i | | | d ƒ | i  | | d ƒ |  i | | | d ƒ q>W| t | ƒ d ƒ d  S(   Ns   <object class=%s>
s&   <object class=%s name=%s subclass=%s>
s   <object class=%s name=%s>
i   t
   foregroundt   #t   fgt
   backgroundt   bgt   fontt   stylet    R   t   idt   eventss   <handler event=%s>%s</handler>
t   disabledt   enabledt	   extracodes   \ns   
t   custom_baset   extrapropertiess   <font>
i   s   <%s>%s</%s>
s   </font>
s
   </object>
(   R   R$   t	   in_sizersR   R   R&   R'   R   R	   t   has_keyt
   startswitht   Nonet   strt   gett	   iteritemsR   t   intt   Falset   replacet   updateR   R
   R   R   (   R   R   R   R   t   tab_strR-   R.   t   handlert   eventR   t   propR   t   keyt   c(    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR      s†    	%! 	
 $ 	,
 (   R   R   R   R   R   R   (    (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR#   |   s   		t   NotImplementedXrcObjectc           B   s    e  Z d  Z d „  Z d „  Z RS(   s‰       XrcObject used when no code for the widget can be generated (for example,
    because XRC does not currently handle such widget)
    c         C   s   t  i |  ƒ | |  _ d  S(   N(   R   R   R$   (   R   R$   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   ë   s    c         C   s@   d |  i  i } t i d | IJ| i t | ƒ d | ƒ d  S(   Ns+   code generator for %s objects not availables   WARNING: %ss   <!-- %s -->
(   R$   R%   t   syst   stderrR   R   (   R   R   R   t   m(    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   ï   s    (   R   R   R   R   R   (    (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyRH   æ   s   	c         C   s  |  d } |  d } d |  j o% |  d a  t  d j o
 d a  qF n | o t d ƒ ‚ n | a t i ƒ  a d d k l } d	 t  d
 t i	 | ƒ  t i
 ƒ  f g } t i i p! d t i	 t i
 ƒ  f | d <n x | D] } t i | d ƒ qÝ Wt i d ƒ d a h  a d S(   s0       Code generator initialization function.
    t   pathR   t   encodings   latin-1s
   ISO-8859-1s,   XRC code cannot be split into multiple filesiÿÿÿÿ(   t   asctimes#   <?xml version="1.0" encoding="%s"?>s(   <!-- generated by wxGlade %s on %s%s -->s"   <!-- generated by wxGlade %s%s -->i   s   
s   
<resource version="2.3.0.1">
N(   t   app_encodingt   IOErrort   output_file_namet	   cStringIOt   StringIOt   output_filet   timeRN   t   commont   versiont   generated_fromt   configt   preferencest   write_timestampR   t   curr_tabt   xrc_objects(   t	   app_attrst   out_patht   multi_filesRN   t   header_linest   line(    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt
   initialize÷   s,    


 c          C   sQ   x$ t  i ƒ  D] }  |  i t d ƒ q Wt i d ƒ t i t t i ƒ  d ƒ d S(   s.       Code generator finalization function.
    i   s   </resource>
t   codegenN(   R]   t
   itervaluesR   RT   RV   t	   save_fileRQ   t   getvalue(   R   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt   finalize  s
     c         C   s×   | i  } t i | i t ƒ } y | i } Wn( t j
 o | | ƒ } | | _ n X| t j o t | =n y t | } WnA t j
 o5 t i | i t ƒ | ƒ } | | _ | t | <n X| i i	 i
 | ƒ d S(   sO       Adds the object sub_obj to the XRC tree. The first argument is unused.
    N(   t   parentt   obj_buildersR<   R%   R#   R   t   AttributeErrorR]   t   KeyErrorR
   t   append(   t   unusedt   sub_objt   top_objt   buildert   xrc_objt   top_xrc(    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt
   add_object%  s    		c      	   C   s>  | i  } | i } | i } y | i }	 Wn7 t j
 o+ t i | i t ƒ | ƒ }	 |	 | _ n X| i i | ƒ }
 | i	 d j or | i
 i d d ƒ } | i
 i d d ƒ } t d | | f t | ƒ t | ƒ t | ƒ ƒ } | i i i | ƒ n; t | t | ƒ t | ƒ t | ƒ ƒ } | i i i | ƒ | i |
 =d S(   sH       Adds a sizeritem to the XRC tree. The first argument is unused.
    t   spacert   widthR   t   heights   %s, %sN(   Ri   R   Rk   Rj   R<   R%   R#   R
   t   indexR&   R	   R    R;   Rm   R   (   Rn   t   sizerR   R   R   R   t   toplevelRs   t   obj_xrct	   sizer_xrcRx   t   wt   ht   sizeritem_xrc(    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt   add_sizeritemD  s$    			"c         C   sL   t  i |  ƒ p8 t i |  i t ƒ } | |  ƒ } | |  _ | t  |  <n d S(   s$      Add class behaves very differently for XRC output than for other lanaguages
    (i.e. pyhton): since custom classes are not supported in XRC, this has
    effect only for true toplevel widgets, i.e. frames and dialogs. For other
    kinds of widgets, this is equivalent to add_object
    N(   R]   R8   Rj   R<   R%   R#   R   (   R$   Rq   Rr   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt	   add_class`  s
    	c         C   s   d  S(   N(    (   R^   t   top_win_class(    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt   add_appo  s    t   FontPropertyHandlerc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   sL   h  d d <d d <d d <d d <d d <d d <|  _  d  |  _ d  S(   NR/   t   sizet   familyR.   t   weightt
   underlinedt   face(   t   propsR:   t   current(   R   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   u  s    (c         C   s   | |  _  d  S(   N(   R‹   (   R   R   t   attrs(    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt
   start_elemz  s    c         C   s)   | d j o |  i  | i d <t Sn d  S(   NR-   (   RŠ   R	   t   True(   R   R   R$   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt   end_elem}  s    c         C   s    t  | i ƒ  ƒ |  i |  i <d  S(   N(   R;   R"   RŠ   R‹   (   R   t   data(    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt	   char_data‚  s    (   R   R   R   R   R   R‘   (    (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR„   t  s   			t   EventsPropertyHandlerc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   s   h  |  _  d  |  _ g  |  _ d  S(   N(   t   handlersR:   t
   event_namet   curr_handler(   R   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   ‰  s    		c         C   s"   | d j o | d |  _  n d  S(   NRC   RD   (   R”   (   R   R   RŒ   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   Ž  s    c         C   s€   | d j oJ |  i  o* |  i o  d i |  i ƒ |  i |  i  <n d  |  _  g  |  _ n& | d j o |  i | i d <t Sn d  S(   NRC   R/   R1   (   R”   R•   t   joinR“   R:   R	   RŽ   (   R   R   R$   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   ’  s     	c         C   s+   | i  ƒ  } | o |  i i | ƒ n d  S(   N(   R"   R•   Rm   (   R   R   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR‘   œ  s    (   R   R   R   R   R   R‘   (    (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR’   ˆ  s   			
t   DummyPropertyHandlerc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s2   Empty handler for properties that do not need codec         C   s   d  S(   N(    (   R   R   RŒ   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   ¦  s    c         C   s   t  S(   N(   RŽ   (   R   R   R$   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   §  s    c         C   s   d  S(   N(    (   R   R   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR‘   ¨  s    (   R   R   R   R   R   R‘   (    (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR—   ¤  s   		t   ExtraPropertiesPropertyHandlerc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   s   h  |  _  d  |  _ g  |  _ d  S(   N(   RŠ   R:   t	   prop_namet	   curr_prop(   R   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   ®  s    		c         C   s"   | d j o | d |  _  n d  S(   Nt   propertyR   (   R™   (   R   R   RŒ   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   ³  s    c         C   s€   | d j oJ |  i  o* |  i o  d i |  i ƒ |  i |  i  <n d  |  _  g  |  _ n& | d j o |  i | i d <t Sn d  S(   NR›   R/   R6   (   R™   Rš   R–   RŠ   R:   R	   RŽ   (   R   R   R$   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR   ·  s     	c         C   s+   | i  ƒ  } | o |  i i | ƒ n d  S(   N(   R"   Rš   Rm   (   R   R   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR‘   Á  s    (   R   R   R   R   R   R‘   (    (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyR˜   ­  s   			
R-   R1   R6   c         C   sP   y t  | |  } Wn% t j
 o t i |  d  ƒ } n X| o | ƒ  Sn d  S(   N(   t   _property_writersRl   t   _global_property_writersR<   R:   (   t   property_namet   widget_namet   cls(    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt   get_property_handlerÔ  s    %c         C   sZ   | d j o | t |  <n< y | t | |  <Wn& t j
 o h  | |  <t | <n Xd S(   sà       sets a function to parse a portion of XML to get the value of the property
    property_name. If widget_name is not None, the function is called only if
    the property in inside a widget whose class is widget_name
    N(   R:   R   Rœ   Rl   (   Rž   RC   RŸ   (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt   add_property_handlerÚ  s    c         O   s   | t  |  <d  S(   N(   Rj   (   RŸ   RC   t   argst   kwds(    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pyt   add_widget_handleræ  s    (    (    (    (-   R   RV   RY   RI   RR   t	   xml_parseR    t   xml.sax.saxutilsR   R   R   t   languaget   modulesR   t   writert   default_extensionsR:   RT   RQ   Rj   R\   R   RO   R   R]   R   R    R#   RH   Rc   Rh   Rt   R€   R   Rƒ   R„   t   objectR’   R—   R˜   R   Rœ   R¡   R¢   R¥   (    (    (    sI   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\xrc_codegen.pys   <module>   sJ   		j	!								