
0Gc           @   s   d  d k  Z  d  d k l Z d  d k Z d  d k Z d  d k Z y e Wn# e j
 o d  d k	 l
 Z n Xd d d     YZ d e  i e f d     YZ d S(	   iN(   t	   quoteattr(   t   Sett   Treec           B   s   e  Z d  Z d d d     YZ d d d  Z d   Z d d  Z d d  Z d   Z	 d d  Z
 d d	 d
  Z d   Z d d  Z RS(   s5       A class to represent a hierarchy of widgets.
    t   Nodec           B   s;   e  Z d Z d d d   Z d   Z d   Z d d  Z RS(   c         C   s   | |  _  | |  _ d  |  _ d  S(   N(   t   widgett   childrent   Nonet   parent(   t   selfR   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt   __init__   s    		c            s>     f d       |   y |  i  i i |   Wn n Xd  S(   Nc            s   |  i  d  j	 o t   |  i   n d  |  _  |  i d  j	 o |  i i } | i t d   t i i	 d  j o t
 i | d  t i _	 n | i   i   d i t i i	  |  i i   n d  |  _ d  S(   Ns   Properties - <>ii    (   R   R   t   mapR   t   property_windowt   SetTitlet   _R   R   t   _Node__empty_wint   wxt   Windowt   GetSizert   GetChildrent	   SetWindowt   delete(   t   nodet   pw(   t
   remove_rec(    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR      s    	(   R   R   t   remove(   R   (    (   R   s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR      s    
c         C   s5   y |  i  i SWn  t j
 o t |  i   Sn Xd  S(   N(   R   t   namet   AttributeErrort   repr(   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt   __repr__1   s    c            s  d d k  } | i   |  i d j	 p t  |  i } t | d | i i  } d } t | d t  o
 d } n   d | d t	 | i
  t	 | i  t	 |  | f  x, | i D]! } | i | i | | d	  q W| d j	 o | i | i
  n t | | i  o`t | i  }	 |  i d j	 o
 |  i p g  }
 h  } x |
 D] } | | | i i <qIWg  }
 d
 d   f d     Y} x3 t d	 |	  D]" } |
 i | i | |     qWx |
 D] } t | d  o|   d | d	 d  | i i } x& | D] } | | i | | d  qW| i | | d |    d | d	 d  q| i | | d	  qWn@ |  i d j	 o/ x, |  i D] } | i | | d	 |  qWn   d | d  d S(   sT               Writes the xml code for the widget to the given output file
            iNt
   _classnamet    t   no_custom_classs    no_custom_class="1"s       s$   <object class=%s name=%s base=%s%s>
i   t   SlotNodec              s   e  Z   f d    Z RS(   c            s     d | d  d  S(   Ns       s   <object class="sizerslot" />
(    (   R   t   outfilet   tabs(   t   fwrite(    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt   writeT   s    (   t   __name__t
   __module__R$   (    (   R#   (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR    S   s   R   s   <object class="sizeritem">
i   s
   </object>
(    (   t   edit_sizersR$   R   R   t   AssertionErrort   getattrt	   __class__R%   t   FalseR    t   klassR   t
   propertiest   addt
   isinstancet	   SizerBaset   lenR   t   post   ranget   appendt   gett   hasattrt   sizer_properties(   R   R!   R"   t   class_namesR'   t   wt	   classnamet	   no_customt   pt   maxposR   t   tmpt   cR    t   it   sp(    (   R#   s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR$   5   sV    		

       "
 %N(   R%   R&   R   R   R	   R   R   R$   (    (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR      s
   		c         C   sN   | |  _  |  i  d  j o t i   |  _  n |  i  |  _ | |  _ h  |  _ d  S(   N(   t   rootR   R   R   t   currentt   appt   names(   R   RB   RD   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR	   j   s
    	#	c         C   sc   | d  j	 p t t d   | i |  i j o | i Sn x! | i |  i j	 o | i } q> W| S(   Ns   None node in _find_toplevel(   R   R(   R   R   RB   (   R   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt   _find_toplevelr   s    c         C   si   | d  j o8 x- |  i D]" } | |  i | j o t Sq q Wt Sn! |  i |  } | |  i | j Sd  S(   N(   R   RE   t   TrueR+   RF   (   R   R   R   t   n(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt   has_namez   s    
 c         C   s   | d  j o |  i } n | i d  j o g  | _ n | i i |  | | _ | |  _ d |  i i |  i |  h   t	 | i
 i  <| |  i j o3 t | i
 i d t  o |  i i | i
 i  n d  S(   Ni   t   _is_toplevel(   R   RB   R   R4   R   RC   RE   t
   setdefaultRF   t   strR   R   R)   R*   R+   RD   t   add_top_window(   R   t   childR   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR.      s    		.c         C   s   | d  j o |  i } n | i d  j o g  | _ n | i i | |  | | _ | |  _ d |  i i |  i |  h   t	 | i
 i  <| |  i j o |  i i | i
 i  n d  S(   Ni   (   R   RB   R   t   insertR   RC   RE   RK   RF   RL   R   R   RD   RM   (   R   RN   R   t   index(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyRO      s    		.c            s   | d  j	 oW    f d     |  | i   i j o   i i | i i  n | i   nH   i i o: x   i i D] } | i   q~ Wd    i _ h    _	 n d  S(   Nc            ss   y'  i   i |   t |  i i  =Wn t t f j
 o n X|  i o" x |  i D] }   |  qW Wn d  S(   N(   RE   RF   RL   R   R   t   KeyErrorR   R   (   RH   R?   (   t
   clear_nameR   (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyRR      s    '

 (
   R   R   RB   RD   t   remove_top_windowR   R   R   R   RE   (   R   R   RH   (    (   R   RR   s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR      s    
 i    c         C   sU  | d j o d d k } | i } n d d k l } d d k } | i d | i |   f  t i	 i
 |  i i i    } |  i i   } |  i i   } t |  i i  }	 |  i i   }
 |  i i   } |  i i   } t t |  i i   } t t |  i i   } t t |  i i   } t t |  i i     } t |  i i  } | i d t g  } | | | |	 | |
 | | | | | | f D] } | t | i |   q~   |  i i o4 t |  i d d  o |  i i i | | d  n t    } |  i! i" d j	 o2 x/ |  i! i" D] } | i | | d |  qWn | i d  | S(	   sP           Writes the xml equivalent of this tree to the given output file
        iN(   t   asctimes>   <?xml version="1.0"?>
<!-- generated by wxGlade %s on %s -->

s   <application path=%s name=%s class=%s option=%s language=%s top_window=%s encoding=%s use_gettext=%s overwrite=%s use_new_namespace=%s for_version=%s is_template=%s>
t   template_datai   s   </application>
(#   R   t   syst   stdoutt   timeRT   t   commonR$   t   versiont   ost   patht
   expanduserRD   t   output_patht   stript   get_namet	   get_classRL   t   codegen_optt   get_top_windowt   get_languaget   get_encodingt   intt   use_gettextt   is_templatet	   overwritet   get_use_old_namespacet   for_versiont   tupleR    t   _encode_to_xmlR)   RU   t   setRB   R   (   R   R!   R"   RV   RT   RY   t   outpathR   R,   t   optiont
   top_windowt   languaget   encodingRg   Rh   Ri   t   use_new_namespaceRk   t   _[1]R@   R8   R?   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR$      sD    		
		1#	 c         C   si   y! |  i  |  i |  | i i =Wn t j
 o n X| | _ d |  i  i |  i |  h   | i <d S(   sF           Changes the node 'node' so that it refers to 'widget'
        i   N(   RE   RF   R   R   RQ   RK   (   R   R   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt   change_node   s    !	c         C   s   | d  j o | i i i |  } n | | j o+ | i i i | |  | i i | d =n( | i i | =| i i i | d |  d  S(   Ni   (   R   R   R   RP   RO   (   R   R   t   new_posRP   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt   change_node_pos   s    &(    N(   R%   R&   t   __doc__R   R   R	   RF   RI   R.   RO   R   R$   Rv   Rx   (    (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR      s   U		,	t
   WidgetTreec           B   s   e  Z d  Z h  Z d   Z d   Z d d d  Z d d  Z d d  Z	 d   Z
 d d  Z d   Z d	   Z d
   Z d e d  Z d   Z d   Z e d  Z d   Z e d  Z d   Z d   Z d   Z d   Z d   Z RS(   sB       Tree with the ability to display the hierarchy of widgets
    c   
      C   s3  t  i   } t  i t  i B} t  i d j o | t  i t  i BO} n# t  i d j o | t  i M} n t  i i	 |  | | d | t
 i |  } d  |  _ t
 i	 |  | |  t  i d d  } | i t  i t i i t i d  t  i   x7 t i D], } | i t i t i |   t i | <q W|  i |  |  i t d  d  | _ |  i | i |  d |  _  d |  _! |  i" |  i!  t# |  _$ t i% d	  |  _& t  i   } |  i& i' | t d
   t  i( |  | |  i)  t  i* |  |  i+  t  i, |  |  i-  t  i. |  | |  i-  d   }	 t  i/ |  |	  d  S(   Nt	   __WXGTK__t	   __WXMAC__t   stylei   s   icons/application.xpmt   Applicationi    t    R   t   Showc         S   s   d } |  i    o t i } n |  i   } xF t i D]; \ } } } | | j o | | j o t i |  Pq6 q6 W|  i   d  S(   Ni    (   t   ControlDownR   t
   ACCEL_CTRLt
   GetKeyCodet   misct   accel_tablet	   CallAftert   Skip(   t   eventt	   evt_flagst   evt_keyt   flagst   keyt   function(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt   on_key_down*  s    
 	(0   R   t   NewIdt   TR_DEFAULT_STYLEt   TR_HAS_VARIABLE_ROW_HEIGHTt   Platformt   TR_NO_LINESt   TR_FULL_ROW_HIGHLIGHTt   TR_ROW_LINESt   TreeCtrlR	   R   R   R   t
   cur_widgett	   ImageListt   Addt   BitmapR[   R\   t   joinRY   t   wxglade_patht   BITMAP_TYPE_XPMRz   t   imagesR   t   get_xpm_bitmapt   AssignImageListt   AddRootR   t   itemt	   SetPyDatat   skip_selectt   titlet	   set_titleRG   t   auto_expandt   wxGladePopupMenut
   _show_menut   Appendt   EVT_TREE_SEL_CHANGEDt   on_change_selectiont   EVT_RIGHT_DOWNt
   popup_menut   EVT_LEFT_DCLICKt   show_toplevelt   EVT_MENUt   EVT_KEY_DOWN(
   R   R   t   applicationt   idR}   t	   root_nodet
   image_listR9   t   SHOW_IDR   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR	     sD    	
 $					c         C   sT   | i  i } | i  i | i  i j o+ | i  i d j o | d | i  i 7} n | S(   Nt   wxScrolledWindows    (%s)(   R   R   R,   t   base(   R   R   t   s(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt   _build_label5  s
    c         C   s   t  i |  | |  d d k } | i i i } t i i | d  } | d j o |  i
   } | _ n |  i | i |  i |  |  | _ |  i | i |  |  i o! |  i | i  |  i |  n | i i   |  i i | i  d S(   s?           appends child to the list of parent's children
        iN(   R   R.   RY   R   R*   R%   Rz   R   R5   R   t   GetRootItemR   t
   AppendItemR   R   R   t   Expandt   select_itemt   show_propertiesRD   t   check_codegen(   R   RN   R   t   imageRY   R   RP   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR.   <  s    $
c         C   s  | i  d j o |  i | | |  d Sn d d k } | i i i } t i i	 | d  } | d j o |  i
   } | _ n d } t i d d  o |  i | i  \ }	 }
 n |  i | i d  \ }	 }
 x^ |	 i   oP |  i |	  i i } | | j  o Pn | d 7} |  i | i |
  \ }	 }
 q Wt i |  | | |  |  i | i | |  i |  |  | _ |  i | i |  |  i o! |  i | i  |  i |  n | i i   |  i i | i  d S(   sM           inserts child to the list of parent's children, before index
        Nii    i   i   i   (   R   R   R.   RY   R   R*   R%   Rz   R   R5   R   R   R   t   check_wx_versiont   GetFirstChildt   IsOkt	   GetPyDataR2   t   GetNextChildR   RO   t   InsertItemBeforeR   R   R   R   R   R   RD   R   (   R   RN   R   R2   R   RY   R   t   image_indexRP   R   t   cookiet   item_pos(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyRO   N  s4    $
 
c         C   s   t  |  i _ t i |  |  | d  j	 oQ y  d  |  _ |  i | i i	  Wn |  i |  i
    n X|  i | i	  n t i i |   d  S(   N(   R+   RD   t   savedR   R   R   R   t
   SelectItemR   R   R   t   DeleteR   R   t   Destroy(   R   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR   p  s    	c         C   s   |  i  i   t |  _ |  i i oP x= |  i i o/ |  i i d } | i o | i i   q& q& Wd  |  i _ n t	 |  _ |  i
 |  i    } | i i   d  S(   Ni(   RD   t   resetRG   R   RB   R   R   R   R   R+   R   R   R   (   R   R?   RD   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt   clear|  s    	 	c         C   s   | d  j	 o5 y |  i |  i |  | =WqB t j
 o qB Xn d |  i i |  i |  h   | i i <|  i | i |  i	 |   d  S(   Ni   (
   R   RE   RF   RQ   RK   R   R   t   SetItemTextR   R   (   R   R   t   oldname(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt   refresh_name  s    	(c         C   sy   t  |  _ |  i | i  t |  _ |  i o |  i i t  n | i |  _ |  i i t   |  i i   |  i t	 _
 d  S(   N(   RG   R   R   R   R+   R   t   update_viewR   R   R   t   focused_widget(   R   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR     s    		c         C   s   |  i  p | i   } yc |  i o |  i i t  n |  i |  i |  _ |  i t _ |  i i	 d   |  i i t  Wq t j
 o q t j
 o d d  k } | i   q Xn d  S(   Ni(   R   t   GetItemR   R   R+   R   R   R   R   R   R   RG   R   t	   Exceptiont	   tracebackt	   print_exc(   R   R   R   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR     s    
c         C   s7  |  i  | i     } | p d  Sn |  i |  | i } | i p | i   oW d d  k } | i |  i j o0 |  i i	 | i
  |  i |  i | i    n d  Sn y] |  i | i    \ } } | i i | | f  \ } } | | | _ | _ | i |  Wn) t j
 o d d  k } | i   n Xd  S(   Ni(   t   _find_item_by_post   GetPositionR   R   t
   is_visiblet   edit_windowsR   RB   R   R   R   t	   PopupMenut   ClientToScreent   ScreenToClientt   m_xt   m_yR   R   R   R   (   R   R   R   R   R   t   xt   yR   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR     s"    	c         C   sI   | d j o |  i } n | o |  i | i  n |  i | i  d S(   s4           expands or collapses the given node
        N(   R   RB   R   R   t   Collapse(   R   R   t   yes(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt   expand  s    c         C   sO   | d  j o
 d } n | |  _ y! |  i   i t d  |  Wn n Xd  S(   NR   s   wxGlade: Tree %s(   R   R   t	   GetParentR   R   (   R   t   value(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR     s    	$c         C   s   |  i  p d |  _  n |  i  S(   NR   (   R   (   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt	   get_title  s    c            sM  | ot  i   p t  i   n | i i p | i i   | i i   n | i o% x" | i D] }   i |  qa Wn | i i   | i i t	  | i i
   | i i i   | i i } d | j o3 | d i   o! | i i o | i i i   n t  i   o t  i   qIn) d d k }    f d     |  d S(   sH           Shows the widget of the given node and all its children
        t   sizeiNc            s]   |  i  i t   i |  t  |  i o" x |  i D] }   |  q4 Wn |  i  i   d  S(   N(   R   t   show_widgetRG   R   R   t	   post_load(   R   R?   (   t   show_recR   (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR     s    

 (   R   t   IsBusyt   BeginBusyCursorR   t   create_widgett   finish_widget_creationR   R   R   RG   R   t   RaiseR-   t	   is_activet   sizert
   fit_parentt   EndBusyCursorR'   (   R   R   t   toplevelR?   t   propsR'   (    (   R   R   s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR     s,    

 c         C   s   y | i    \ } } Wn5 t j
 o) |  i |  i    } |  i |  n X|  i | | t  } | d j	 oi | i i	   p! |  i |  |  i
 | t  q | i i
 t  |  i |  |  i i   | i   n d S(   s           Event handler for left double-clicks: if the click is above a toplevel
        widget and this is hidden, shows it
        N(   R   R   R   t   GetSelectionR   R   RG   R   R   R   R   R+   R   RD   R   R   (   R   R   R   R   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR     s    c         C   sq   |  i  | | f  \ } } | oK | t i t i B@o6 |  i |  } | p | i |  i j o | Sqm n d S(   s           Finds the node which is displayed at the given coordinates.
        Returns None if there's no match.
        If toplevels_only is True, scans only root's children
        N(   t   HitTestR   t   TREE_HITTEST_ONITEMLABELt   TREE_HITTEST_ONITEMICONR   R   RB   R   (   R   R   R   t   toplevels_onlyR   R   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR     s    c         C   s[   t  i |  | |  |  i | i |  i i | i i d   |  i | i |  i	 |   d  S(   Ni(
   R   Rv   t   SetItemImageR   R   R5   R*   R%   R   R   (   R   R   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyRv   %  s    c            s_  |   i  | i i t  j o d  Sn | i i i |  } t i   | | |  | i }   i | i  }   i	   | | j o.   i
 | i i |   i |  |  | _ n/   i
 | i i | d   i |  |  | _   i | i |     f d    | i o% x" | i D] }  | |  qWn   i | i    i |    i   d  S(   Ni   c            s   t  i i | i i i d  }   i |  i   i |  |  | _   i	 | i |  | i
 o% x" | i
 D] }  | |  qi Wn   i | i  d  S(   Ni(   Rz   R   R5   R   R*   R%   R   R   R   R   R   R   (   R   R   t   idxR?   (   R   R4   (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR4   ;  s    

 (   t   GetChildrenCountR   R   R+   R   RP   R   Rx   t   GetItemImaget   FreezeR   R   R   R   R   t   Thaw(   R   R   Rw   RP   t   old_itemR   R?   (    (   R   R4   s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyRx   +  s*    	
((	

 c         C   s/  d d k  l } g  } |  i } d } x | d j	 o | } | i | i  t | d d  } t | d d  d j o | i } q( | d j	 o | i   o
 | } q( t	 | |  o | i
 } q( | i } q( W| i   | d j	 oA | i p t  t i | i  i   } | d | f | d <n | S(   s           returns a list of widget names, from the toplevel to the selected one
        Example:
        ['frame_1', 'sizer_1', 'panel_1', 'sizer_2', 'button_1']
        if button_1 is the currently selected widget.
        i(   R0   R   R   R   i    N(   R'   R0   R   R   R4   R   R)   R   t
   is_virtualR/   t   windowt   reverseR   R(   R   t   get_toplevel_parentR   (   R   R0   t   retR9   t   oldwR   R2   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt   get_selected_pathK  s*    	

c         C   s  d } |  i  |  i    \ } } d } d } d } x | i   o | t |  j  o |  i |  i } | | }	 | d j o) t |	  t d  j o |	 \ }	 } n t i	 | i
 |	  oR | } | d j o |  i |  } n | |  _ |  i  |  \ } } | d 7} q6 |  i |  } q6 W| d j	 ok |  i |  }
 | d j	 o> |  i | t  | d j	 o t i | i  i |  qn |  i |
  n d S(   s}           sets the selected widget from a path_list, which should be in the
        form returned by get_selected_path
        i    i   N(    (   t   _get_first_childR   R   t   OkR1   R   R   t   typeR   t   streqR   R   t   GetNextSiblingR   RG   R
  t   SetPositionR   (   R   R\   RP   R   R   t   itemokR   R2   R   R   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyt   select_pathl  s2    #
&	!c         C   s8   t  i d d  o |  i |  Sn |  i | d  Sd  S(   Ni   i   i   (   R   R   R   (   R   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyR    s    N(   R%   R&   Ry   R   R	   R   R   R.   RO   R   R   R   R   R   R   RG   R   R   R   R+   R   R   R   Rv   Rx   R  R  R  (    (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pyRz      s.   	2	"		
				&			 	!	#(    (   R   t   xml.sax.saxutilsR    R   RY   t   os.pathR[   Rn   t	   NameErrort   setsR   R   R   Rz   (    (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\tree.pys   <module>	   s   $#