
0Gc           @   s  d  d k  Z  e  i d j o d e  i f d     YZ n
 e  i Z e  i Z e  i Z d e  i f d     YZ d d+ d     YZ d  d k	 Z	 e	 i
 Z d	   Z d
   Z d   Z d   Z d   Z e  i d j o d e  i f d     YZ n
 e  i Z d d d d  Z e d d d  p d a d   Z n
 e  i Z d a h  Z d d  Z d a d   Z d   Z d   Z d   Z d e  i  e f e  i! e" d  e f e  i! e" d  e f e  i! e" d  e f g Z# d   Z$ d   Z% d Z& d    Z' d!   Z( d"   Z) d#   Z* d d$  Z+ d Z, y
 e- Z- Wn) e. j
 o d% e/ f d&     YZ- n Xd'   Z0 d  d k1 Z1 e1 i2 d(  Z3 [1 d)   Z4 e5 d*  Z6 d S(,   iNt	   __WXMSW__t   wxGladeRadioButtonc           B   s   e  Z d  Z d Z d   Z RS(   s   
        custom wxRadioButton class which tries to implement a better
        GetBestSize than the default one for WXMSW (mostly copied from
        wxCheckBox::DoGetBestSize in checkbox.cpp)
        c         C   s   |  i  p@ t i   } | i t i t i   d | i   d |  _  n |  i   } | oM |  i |  \ } } | |  i  |  i	   7} | |  i  j  o |  i  } q n |  i  } } | | f S(   Ni   i   (
   t   _wxGladeRadioButton__radio_sizet   wxt   ScreenDCt   SetFontt   SystemSettings_GetFontt   SYS_DEFAULT_GUI_FONTt   GetCharHeightt   GetLabelt   GetTextExtentt   GetCharWidth(   t   selft   dct   labelt   wt   h(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   GetBestSize   s    
!N(   t   __name__t
   __module__t   __doc__t   NoneR   R   (    (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR      s   t   SelectionTagc           B   s   e  Z d  Z d d  Z RS(   sd       This is one of the small black squares that appear at the corners of the
    active widgets
    c         C   s[   h  d d <} | o | | d <n t  i i |  | d |  |  i t  i  |  i   d  S(   Ni   t   sizet   positioni(   i   i   (   R   t   Windowt   __init__t   SetBackgroundColourt   BLUEt   Hide(   R   t   parentt   post   kwds(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR   2   s
    N(   R   R   R   R   R   (    (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR   -   s   t   SelectionMarkerc           B   sA   e  Z d  Z e d  Z d d  Z d   Z d   Z d   Z	 RS(   s:       Collection of the 4 SelectionTagS for each widget
    c         C   s   | |  _  | |  _ | |  _ t i d j o | |  _ n d  |  _ d  |  _ |  i   | o" x |  i D] } | i	   qe Wn d  S(   NR    (
   t   visiblet   ownerR   R   t   PlatformR   t   tag_post   tagst   updatet   Show(   R   R#   R   R"   t   t(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR   @   s    					

 c      	      s/  |  i  |  i j o d \   n |  i  i   \   |  i  i   \         f d   } g  } t d  D] } | | |  qv ~ |  _ |  i ow |  i p7 g  } t d  D] } | t |  i  q ~ |  _ n x3 t d  D]! } |  i | i	 |  i |  q Wn | o | i
   n d  S(   Ni    c            sy   |  p    f Sna |  d j o   d   f Sn> |  d j o   d    d f Sn     d f Sd  S(   Ni   i   i   (    (   t   j(   t   yt   xR   R   (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR   P   s    #+i   (   i    i    (   R#   R   t   GetPositiont   GetClientSizet   rangeR%   R"   R&   R   t   SetPositiont   Skip(   R   t   eventR   t   _[1]t   it   _[2](    (   R   R   R+   R,   s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR'   L   s    #0

7 #c         C   s   |  i  | j o | |  _  |  i  o |  i p7 g  } t d  D] } | t |  i  q> ~ |  _ n xk t d  D]2 } |  i | i |  i |  |  i | i   qq Wq x |  i D] } | i   q Wd  |  _ n d  S(   Ni   (
   R"   R&   R/   R   R   R0   R%   R(   t   DestroyR   (   R   R"   R3   R4   t   tag(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR(   _   s    	

7 
 c         C   s9   |  i  o+ x |  i  D] } | i   q Wd  |  _  n d  S(   N(   R&   R6   R   (   R   R7   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR6   n   s    

 c         C   s<   | |  _  |  i o% x" |  i D] } | i |  q Wn d  S(   N(   R   R&   t   Reparent(   R   R   R7   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR8   s   s    	

 N(
   R   R   R   t   FalseR   R   R'   R(   R6   R8   (    (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR!   <   s   		c         C   s   t  t | |   |  S(   N(   t   mint   max(   t   numbert   lowert   upper(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   bound   s    c         C   sQ   d d k  } d t | i g  } |  i   D] } | d t | d d  q) ~  S(   so       returns the hexadecimal string representation of the given color:
    for example: wxWHITE ==> #ffffff
    iNt   #s   %02xi    i   (   t   operatort   reducet   addt   GetR?   (   t   colorRA   R3   t   c(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   color_to_string   s    c      
   C   sh   t  |   d j o
 t  n t t i g  } t d d d  D]! } | t |  | | d !d  q= ~  S(   s       returns the wxColour which corresponds to the given
    hexadecimal string representation:
    for example: #ffffff ==> wxColour(255, 255, 255)
    i   i   i   i   (   t   lent
   ValueErrort   applyR   t   ColourR/   t   int(   RE   R3   R4   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   string_to_color   s    c         C   sS   t  |  t i  p |  i } n |  } x& | o | i   o | i   } q) W| S(   N(   t
   isinstanceR   R   t   widgett
   IsTopLevelt	   GetParent(   t   objt   window(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   get_toplevel_parent   s
     c         C   s   d d k  l } l } d d k l } t |  |  o |  i }  n t |  |  p t t d   x& |  o t |  |  o |  i	 }  qf W|  S(   Ni(   t   EditBaset   TopLevelBase(   t   Sizers#   EditBase or SizerBase object needed(
   t   edit_windowsRU   RV   t   edit_sizersRW   RN   RS   t   AssertionErrort   _R   (   RO   RU   RV   RW   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   get_toplevel_widget   s     t	   __WXGTK__t   wxGladePopupMenuc           B   s   e  Z d    Z d   Z RS(   c         C   s   t  i i |   t  i   |  _ |  i |  i |  } |  i   | i   } | i t  i	  | i
 t  i | i   | i   | i   t  i	   d  S(   N(   R   t   MenuR   t   NewIdt   TITLE_IDt   Appendt   AppendSeparatort   GetFontt	   SetWeightt   BOLDR   t   Fontt   GetPointSizet	   GetFamilyt   GetStyle(   R   t   titlet   itemt   font(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR      s    
c         C   s   |  i  |  i |  d  S(   N(   t   SetLabelRa   (   R   Rk   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   SetTitle   s    (   R   R   R   Ro   (    (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR^      s   	
i    c         C   s)   d d k  } | i d  |  | | | f j S(   sY       returns True if the current wxPython version is at least
    major.minor.release
    iN(   R   t   VERSION(   t   majort   minort   releaset   revisionR   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   check_wx_version   s    i   i   c         O   s   t    } | p t t d   t d j o& t   a | i d d t d    n t   } | i t  |  | _	 | | _
 | | _ t | |  d S(   s   
        Call the specified function after the current and pending event
        handlers have been completed.  This is also good for making GUI
        method calls from non-GUI threads.
        s   No wxApp created yetic         S   s   t  |  i |  i |  i  S(    (   RJ   t   callablet   argst   kw(   R2   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   <lambda>   s    N(   t   wxGetAppRZ   R[   t   _wxCallAfterIdR   t   wxNewIdt   Connectt	   wxPyEventt   SetEventTypeRv   Rw   Rx   t   wxPostEvent(   Rv   Rw   Rx   t   appt   evt(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   wxCallAfter   s    						c         C   s  t  d  j o d d  k } | i i  a  n t i d j o t i d j o
 d a  n d d  k } d d  k } t i	 |  | |  } t i d j o
 d	 } n d
 } | i
 i | i |  } t  o | d  j	 o d  }	 | i d  pw y t | }	 Wqtt j
 oV | i
 i | |  }
 | i
 i |
  o! t i |
 t i  }	 t | <qUd  }	 qtXn t i i | t i d  }	 |	 d  j	 o+ y | i |	  Wqt j
 o qXqn |  i |  d  S(   NiR]   i   i   i   t    i    R    s
   icons/msw/s
   icons/gtk/t   wxART_i   (   i   i   i   i   R   (   i   i   (   t   use_menu_iconsR   t   configt   preferencesR   R$   Rp   t   commont   os.patht   MenuItemt   patht   joint   wxglade_patht
   startswitht   _item_bitmapst   KeyErrort   isfilet   Bitmapt   BITMAP_TYPE_XPMt   ArtProvidert	   GetBitmapt   ART_MENUt	   SetBitmapt   AttributeErrort
   AppendItem(   t   menut   idt   textt   xpm_file_or_artidR   R   t   osRl   R   t   bmpt   f(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   append_item   s2     
!	c           C   s%   t  d  j	 o t  i   d  a  n d  S(   N(   t   focused_widgetR   t   remove(    (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   _remove  s    
c           C   s?   t  d  j	 o. y t  i   Wn t j
 o q; Xd  a  n d  S(   N(   R   R   t   clipboard_cutR   (    (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   _cut  s    c           C   s9   t  d  j	 o( y t  i   Wq5 t j
 o q5 Xn d  S(   N(   R   R   t   clipboard_copyR   (    (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   _copy  s    c           C   s9   t  d  j	 o( y t  i   Wq5 t j
 o q5 Xn d  S(   N(   R   R   t   clipboard_pasteR   (    (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   _paste#  s    t   Ct   Xt   Vc         C   s1   h  } x$ |  i    D] \ } } | | | <q W| S(   sP       Returns a dictionary whose keys are 'src' values and values 'src' keys.
    (   t	   iteritems(   t   srct   rett   keyt   val(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   _reverse_dict2  s
     c         O   sv   t  | d  t  d  j o t |  i | |  n? t | d t  o t |  i | |  n t |  i | |  d S(   s|       This function fixes a bug in wxPython 2.4.0.2, which fails to call
    InsertSizer when the 2nd argument is a Sizer
    i   N(   t   typeRJ   t   InsertSpacerRN   t
   wxSizerPtrt   InsertSizert   InsertWindow(   R   Rw   Rx   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   sizer_fixed_Insert=  s
    c         C   s   |  i    \ } } |  i   \ } } d | j o t i t i  j n o> d | j o t i t i  j n o | | | | f Sn d  S(   Ni    (   R-   t   GetSizeR   t   SystemSettings_GetMetrict   SYS_SCREEN_Xt   SYS_SCREEN_YR   (   t   winR,   R+   R   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   get_geometryP  s    **c      	   C   s   | d  j o d  Sn yw t |  d j o2 |  i g  } | D] } | t |  q< ~   n/ |  i g  } | D] } | t |  qn ~  Wn t j
 o } | GHn Xd  S(   Ni   (   R   RH   t   SetDimensionsRL   R0   t	   Exception(   R   t   geometryR3   R,   R5   t   e(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   set_geometryY  s    22c         C   s   d d  k  } d d  k } | i i |   \ } } | i i |  d } yL | i | | g  \ } } } z | i | | | |  }	 Wd  | i   XWn- t j
 o! d d  k	 }
 |
 i
   d  Sn Xt |	  | S(   Nii    (   t   impR   R   t   splitt   splitextt   find_modulet   load_modulet   closet   ImportErrort	   tracebackt	   print_excR   t   vars(   t   module_patht   nameR   R   R   t   mnamet   mfilet   pathnamet   descriptiont   moduleR   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   import_namef  s    	c         C   s   y |  | j SWnj t  j
 o^ t |   t d  j o |  i t i i i  }  n | i t i i i  } |  | j Sn Xd S(   s       Returns True if the strings or unicode objects s1 and s2 are equal, i.e.
    contain the same text. Appropriate encoding/decoding are performed to
    make the comparison
    u    N(   t   UnicodeErrorR   t   encodeR   t   app_treeR   t   encoding(   t   s1t   s2(    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   streq|  s    c         C   s   | d j o1 t i d j o t |   Sq> t i i i } n t i o8 t |   t d  j o t	 t |   |  Sq |  Sn5 t |   t d  j o |  i
 |  Sn t |   Sd S(   sT       Converts the object s to str or unicode, according to what wxPython expects
    u    N(   R   R   R   t   strR   R   R   t   USE_UNICODER   t   unicodeR   (   t   sR   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   wxstr  s    
t	   enumeratec           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   sF           Python 2.2.x replacement for the `enumerate' builtin.
        c         C   s   | |  _  d |  _ d  S(   Ni(   t   iterablet   index(   R   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR     s    	c         C   s   t  |  i  |  _ |  S(   N(   t   iterR   (   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   __iter__  s    c         C   s+   |  i  i   } |  i d 7_ |  i | f S(   Ni   (   R   t   nextR   (   R   R   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR     s    (   R   R   R   R   R   R   (    (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyR     s   		c         C   s   t  d  |  S(   Ns   <Design> - (   R[   (   Rk   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   design_title  s    s   "(?:[^"]|\\")*"c   
      C   sM  d d  k  } t i } | i i |   pd |  j o d d  k } |  i d d  \ } } | d 7} | i | i  o | i | i d  d } n | i	 |  o y\ | i
 |  i |  } g  } t i |  D] } | | d d !q ~ } t i |  } Wq,d d  k }	 |	 i   t i } q,Xq0qIn t i |  t i  } | S(   Nis   .zipi   (   R   R   t
   NullBitmapR   t   existst   zipfileR   R   t   sept
   is_zipfilet   ZipFilet   readt   _get_xpm_bitmap_ret   findallt   BitmapFromXPMDataR   R   R   R   (
   R   R   R   R   t   archiveR   t   dataR3   t   dR   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   get_xpm_bitmap  s&    	
1c         C   s   d d k  } | i i |   o |  Sn t i i i } | o4 t t i i d d  } t i t i	 |   } n | i i
 |  } | o | i i | |   }  n | i i |   }  |  S(   si       Get an absolute path relative to the current output directory (where the
    code is generated).
    iNt   real_output_pathR   (   R   R   t   isabsR   R   R   t   output_patht   getattrt   _encode_from_xmlt   _encode_to_xmlt   dirnameR   t   abspath(   R   t   for_previewR   t   pR   (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pyt   get_relative_path  s    (    (7   R   R$   t   RadioButtonR   t   FileSelectort   DirSelectorR   R   R!   R   R   t   _encodeR?   RG   RM   RT   R\   R_   R^   Ru   R   R{   R   t	   CallAfterR   R   R   R   R   R   R   R   t
   WXK_DELETEt
   ACCEL_CTRLt   ordt   accel_tableR   R   t   _currently_under_mouseR   R   R   R   R   t   hidden_property_panelR   t	   NameErrort   objectR   t   ret   compileR   R   R9   R  (    (    (    s:   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\misc.pys   <module>	   sj   			@					
				'											
		