
0Gc           @   s  d  Z  d d k Z d d k 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	 Z	 y e
 Wn# e j
 o d d k l Z
 n Xd Z e i e Z d g Z e a h  Z h  Z e a g  a g  Z g  Z e a e a e a g  a e  a! d   Z" d   Z# d d	 f a$ d
 f  d     YZ% d f  d     YZ& e a' d   Z( e a) e a* e	 i+ d  Z, d   Z- e  e  d  Z. d   Z/ d   Z0 d   Z1 d   Z2 d   Z3 d   Z4 e a5 d   Z6 d   Z7 d   Z8 d   Z9 d   Z: d   Z; d   Z< e d  Z= d    Z> d!   Z? d"   Z@ d#   ZA d$   ZB d% f  d&     YZC d' f  d(     YZD d) eE f d*     YZF h  eC d+ <eF d, <ZG h  ZH h  ZI h  aJ d-   ZK e d.  ZL d/ f  d0     YZM d1   ZN d2   ZO d S(3   s  How the code is generated: every time the end of an object is reached during
the parsing of the xml tree, either the function 'add_object' or the function
'add_class' is called: the latter when the object is a toplevel one, the former
when it is not. In the last case, 'add_object' calls the appropriate ``writer''
function for the specific object, found in the 'obj_builders' dict. Such
function accepts one argument, the CodeObject representing the object for
which the code has to be written, and returns 3 lists of strings, representing
the lines to add to the '__init__', '__set_properties' and '__do_layout'
methods of the parent object.
iN(   t   XmlParsingError(   t   Sett   lispc         C   sM   t  oB |  d  d j o d |  d SqI |  d  d j o d |  SqI n |  S(   Ni   t   wxi   t   EVT_(   t   use_new_namespace(   t
   class_name(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   cnO   s    c         C   sV   t  oA d i g  } t |   i d  D] } | t |  q' ~  Sn t |   Sd  S(   Nt   |(   R   t   joint   strt   splitR   (   t   flagst   _[1]t   f(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   cn_fW   s    Ai   i   t
   ClassLinesc           B   s   e  Z d  Z d   Z RS(   s9       Stores the lines of lisp code for a custom class
    c         C   sL   g  |  _  g  |  _ g  |  _ g  |  _ g  |  _ h  |  _ t |  _ g  |  _ d  S(   N(	   t   initt   parents_initt   sizers_initt   propst   layoutt   dependenciest   Falset   donet   event_handlers(   t   self(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   __init__f   s    							(   t   __name__t
   __module__t   __doc__R   (    (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR   b   s   t   SourceFileContentc           B   s;   e  Z d  Z d d d d  Z d   Z d   Z d   Z RS(   s       Keeps info about an existing file that has to be updated, to replace only
    the lines inside a wxGlade block, an to keep the rest of the file as it was
    c         C   sr   | |  _  | |  _ | |  _ g  |  _ | d  j o h  |  _ n h  |  _ h  |  _ |  i d  j o |  i   n d  S(   N(   t   namet   contentt   classest   new_classest   Nonet   spacesR   t   build_untouched_content(   R   R    R!   R"   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR   ~   s    						c         C   s  d } t } t i d  } t i d  } t i d  } t i d  } t } t } d }	 t |  i  }
 g  } x)|
 D]!} d } | p} | i d  } | i d  } | d j o | } d } q| d j o | } d } qt | d f | d f  \ } } n | o | d j o t } | }	 n | o7 | i	 |	  } | | j  o | d j o
 t } qin | i
 |  } | ob | d j	 oU | d j o | i d t  t } n | i d	  } d	 |  i | <| i |  qv | p| i
 |  } | o | d j	 o | i d	  } | i d
  } | i d  } | d j o
 | } n | |  i | <t } | d j o | i d t | f  qs| i d t | | f  q| i
 |  } | oH | d j	 o; | i d	  } | i d
  } d	 |  i i | h   | <n | d j	 o+ |  i |  o | i d t | f  n | i |  |  i |  o | i d t  qqv | i
 |  d j	 o
 t } qv qv W| p | i d t  n |
 i   d i |  |  _ d S(   s           Builds a string with the contents of the file that must be left as is,
        and replaces the wxGlade blocks with tags that in turn will be replaced
        by the new wxGlade blocks
        s2   ^\s*class\s+([a-zA-Z_]\w*)\s*(\([\s\w.,]*\))?:\s*$s;   ^(\s*)#\s*begin\s+wxGlade:\s*([A-Za-z_]+\w*)??[.]?(\w+)\s*$s   ^\s*#\s*end\s+wxGlade\s*$sO   ^\s+def\s+([A-Za-z_]+\w*)\s*\(.*\):\s*#\s*wxGlade:\s*(\w+)\.<event_handler>\s*$is   """s   '''s   <%swxGlade insert new_classes>i   i   i   s   <%swxGlade replace %s>s   <%swxGlade replace %s %s>s   <%swxGlade event_handlers %s>s   <%swxGlade extra_modules>
t    N(   R$   R   t   ret   compilet   openR    t   findt   mint   Truet   rfindt   matcht   appendt   noncet   groupR"   R%   R   t
   setdefaultt   is_end_of_classt   is_import_linet   closeR	   R!   (   R   R   t   new_classes_insertedt
   class_declt   block_startt	   block_endt   event_handlert   inside_blockt   inside_triple_quotet   triple_quote_strt   tmp_int	   out_linest   linet   quote_indext   triple_dquote_indext   triple_squote_indext   tmp_quote_strt	   end_indext   resultR%   t   which_classt   which_blockt   which_handler(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR&      s     

	
	
				
c         C   s)   t  o | i d  Sn | i d  Sd  S(   Ns	   import wxs   from wxLisp.wx import *(   R   t
   startswith(   R   RA   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR5      s    c         C   s   | i    i d  S(   Ns   # end of class (   t   stripRK   (   R   RA   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR4     s    N(   R   R   R   R$   R   R&   R5   R4   (    (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR   y   s
   	q	c         C   s   d |  S(   Ns       (    (   t   number(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   tabs  s    s   \\[natbv"]?c         C   s/   |  i  d  d j o d Sn |  i  d  Sd  S(   Ni    s   \s   \\(   R2   (   R/   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   _do_replace  s    c         C   s   |  p d Sn |  i  d d  }  | o t i t |   }  n |  i  d d  }  y; t |  d  t o | o d |  d Sn d |  d SWn= t j
 o1 t o | o d	 |  d Sq d
 |  d Sn Xd S(   s       returns a quoted version of 's', suitable to insert in a lisp source file
    as a string object. Takes care also of gettext support
    s   ""t   "s   \"s   \s   \\t   asciis   _("s   ")s   _(u"s   u"N(   t   replacet   _quote_str_patternt   subRO   t   unicodet   _use_gettextt   UnicodeDecodeError(   t   st	   translatet   escape_chars(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt	   quote_str   s    c      #   C   sM  |  d } |  d } d d k  } d d k } y t |  d  a Wn t t f j
 o t a n Xy t |  d  a Wn t t f j
 o t a n Xd t | i     i	 d d	  | i
 d" d#  f a y t |  d  a Wn t t f j
 o n XyB t g  } |  d i d  d  D] } | t |  q~  a WnB t t f j
 o0 t i d j	 o t i i i a qd$ a n Xy t |  d  a Wn t t f j
 o t a n Xy t |  d  a Wn t t f j
 o t a n Xy |  d } Wn t t f j
 o d } n Xh  a h  a d t i | i   t i   f d d g a t i i p! d t i t i   f t d <n t d d d d d d d d g  a | a t pe t o# t  i! i" |  o t# |  a$ qId a$ t% i&   a' | a( t' i) d t  t' i) d   n0 d a$ t  i! i* |  p t+ d!   n | a, d S(%   sQ      Writer initialization function.
    - app_attrs: dict of attributes of the application. The following two
        are always present:
            path: output path for the generated code (a file if multi_files is
                False, a dir otherwise)
            option: if True, generate a separate file for each custom class
    t   patht   optioniNt   use_gettextt	   overwrites   %s%st   .R'   i
   i   i   R   t   for_versioni   i   t   encodings%   ;;; generated by wxGlade %s on %s%s

s#   (asdf:operate 'asdf:load-op 'wxcl)
s:   (use-package "FFI")
(ffi:default-foreign-language :stdc)

s   ;;; generated by wxGlade %s%s

i    t   wxCLt   wxFramet   wx_maint
   wx_wrappert   wxWindowt   wxColourt   wxEvtHandlert   wxEvents   <%swxGlade extra_modules>
s   
s@   'path' must be a directory when generating multiple output filesi@B i (   i   i   (-   t   timet   randomt   intRV   t   KeyErrort
   ValueErrorR   t
   _overwriteR
   RR   t	   randrangeR1   R   t   tupleR   Ra   t   commont   app_treeR$   t   appR"   t   _current_extra_modulest   versiont   asctimet   generated_fromt   header_linest   configt   preferencest   write_timestampt   sett   import_packagest   multiple_filest   osR\   t   isfileR   t   previous_sourcet	   cStringIOt   StringIOt   output_filet   output_file_namet   writet   isdirR    t   out_dir(   t	   app_attrst   out_patht   multi_filesRk   Rl   R   t   tt	   _encoding(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt
   initialize2  sd    	


8	c          C   s  t  d j	 oSd t }  t  i o d i t  i  } n d } t  i i |  |  t  _ d t }  d i t i    } t  i i |  |  t  _ t	 i
 d t t  i  } xY | D]Q }  t  i i |  d t d   } d | | f } t  i i |  d |  t  _ q Wt	 i
 d	 t t  i  } x& | D] }  t  i i |  d  t  _ q!Wt i t  i t  i d
  n t p d i t i    } t i   i d t |  } t i   y2 t i t | d
  t o t i t d  n Wn9 t j
 o } t t |    n t j
 o n Xb n d S(   sR       Writer ``finalization'' function: flushes buffers, closes open files, ...
    s   <%swxGlade insert new_classes>R'   s   <%swxGlade extra_modules>
s)   (<%swxGlade replace ([a-zA-Z_]\w*) +\w+>)i   i   sG   %s# content of this block not found: did you rename this class?
%spass
i    s   <%swxGlade event_handlers \w+>t   codegeni  N(   R   R$   R1   R#   R	   R!   RR   Rv   t   keysR(   t   findallR%   t   getRN   Rs   t	   save_fileR    R   R   t   getvalueR6   R   t
   _app_addedR   t   chmodt   IOErrorR    R
   t   OSError(   t   tagt   codet   tagst   indentt   commentt   emR!   t   e(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   finalize  sL    


  
c         C   s9   y t  |  i d  SWn t t f j
 o t Sn Xd S(   s       Returns True if 'obj' should be added as an attribute of its parent's
    class, False if it should be created as a local variable of __do_layout.
    To do so, tests for the presence of the special property 'attribute'
    t	   attributeN(   Rm   t
   propertiesRn   Ro   R-   (   t   obj(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   test_attribute  s    c         C   s  y t  |  i } Wn' t j
 o t   } t  |  i <n Xy t | i } Wn< t j
 o0 | i i d d | i | i f d g  n)Xy| i i	 d d  | _ | i
 i i	 d d  | i
 _ | i d j o t i | i  n | i d j p0 | i d j p  | i d j p | i d	 j o t t d
 g  Ba n+ | i d j o t t | i g  Ba n | i d j o t t d g  Ba n | i |  \ } } } Wn | GH  n X| i o<| i o) | i o | i   | i i |  n | i i |  t | d t  } t | d  oL | i |  } x | D]. \ }	 }
 } | i i |	 | |
  | f  q@Wqd | i j ow t |  \ } }	 |	 d j o d | i }	 n xD | i d i   D]+ \ }
 } | i i |	 | |
  | f  qWqn | i i |  | i i |  | i i |  t  oD | i o: | i | i j o' d | i | i f } d | i! | <n x3 t t i" | i  d g   D] } d | i! | <qWd S(   sI       adds the code to build 'sub_obj' to the class body of 'top_obj'.
    s   
sA   ;;; code for %s (type %s) not generated: no suitable writer foundt   _t   -t   spacert
   wxBoxSizert   wxStaticBoxSizert   wxGridSizert   wxFlexGridSizert   wxSizert	   wxMenuBart   wxMenuR   t
   get_eventst   eventss   -1s   #obj.%ss   from %s import %s
i   t   import_modulesN(#   R"   t   klassRn   R   t   obj_builderst   baseR   t   extendR    RR   t   parentt   class_linesR0   R   R~   t   get_codet
   in_windowst   is_containert   is_toplevelt   reverseR   t   getattrR   t   hasattrR   R   R   t   generate_code_idt	   iteritemsR   R   R   R   R   R   (   t   top_objt   sub_objR   t   builderR   R   R   t   mycnt   evtst   idt   eventt   handlert   id_namet   keyt   dep(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt
   add_object  sf    '  

 ' +
 c         C   s  | i  i d d  | _  | i  } y: g  } | i d  D] } | t |  q8 ~ \ }	 }
 WnH t j
 o< | i d j o% t d j  o t d  d | } q n Xd	 |	 |
 f } y t |  i	 } Wn' t
 j
 o t   } t |  i	 <n Xd
 t |  } | i   i d d  } | i d  d j o d | } n | i	 d j p0 | i	 d j p  | i	 d j p | i	 d j o& d | i  | | | t |  f } n# d | i  | | | t |  f } H| i i |  d S(   sc       writes the code to add the object 'obj' to the sizer 'sizer'
    in the 'toplevel' object.
    R   R   t   ,t
   wxNotebooki   i   t   wxNotebookSizers   (%s)s   (%d, %d)s   %sR   t    is   (logior %s)R   R   R   R   s=   (wxSizer_AddSizer (slot-%s  obj) (slot-%s obj) %s %s %s nil)
s=   (wxSizer_AddWindow (slot-%s obj) (slot-%s obj) %s %s %s nil)
N(   i   i   (   R    RR   R   Rm   Ro   R   Ra   R   R"   R   Rn   R   R   RL   R+   R   R0   (   t   toplevelt   sizerR   R]   t   flagt   bordert   obj_nameR   RX   t   wt   hR   t   buffer(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   add_sizeritem  s*    
	='  #c   +   0   C   s  t  p
 t } n` t i i t |  i i d d  d  } t p t i i	 |  o
 d } n t |  } h  a t i |  i  o t |  i i o d Sn y. d } t | d t  } t | d t  } Wn t j
 o
   n X| d j	 o0 | i i |  i  o t } | i |  i } nK t } t d  } t | d	 g   } | o x | D] }	 d
 t |	 <qRWn g  }
 |
 i } x t D] } | |  qWx t D] } | d |  qWt i |  i  p t   t |  i <n | } | o(| |  i  } |  i o= |  i | j o- d d k } |  i d | i dS dT  } n
 |  i } | d |  | d  x0 t  D]( } | d | d | d | d  qeW| d  | d |  | | d |  | | d  | | d  | | d  | | d  | d |  | d  n | | d  |  i  |  i! } | i" d! d  } | o | |  } n | i#   i d d  } | i d" d#  } | i$ d#  d j o d$ | } n |  i d% j o | | d& |  n: |  i d' j o) | | d( |  t t% d' g  Ba n t |  i i& } t |  i i' } | i(   x | D] } | | |  q4Wx | D] } | | |  qSWt) | d)  o, x) | i* |   D] } | | |  qWn t |  i i+ } t) | d*  oC x@ | i, |   D]+ \ } } } | i | | |  | f  qWn | o | d  n t- dU j  p t. o[ x | D]L \ } } } | i/ d,  o | d
 d- } n | | d. | | | f  q;Wni xe | D]] \ } } } | i/ d,  o# | | d/ | d
 | | f  q| | d/ | | | f  qW| | d0  | | d1  | d j	 o| | ot d2 t0 |  i d3 f } | i1 i$ |  d4 j  o t2 i3 d5 IJn" | i1 i | d i |
   | _1 g  }
 |
 i } n t | d6 t4  |   } | i5 t |  i i6  t7 |  } | o | d7 |  n | | d8 |  i  | p | | d9  n  x | D] } | | |  q%W| | d:  | d j	 o| | ot d2 t0 |  i d; f } | i1 i$ |  d4 j  o t2 i3 d< IJn" | i1 i | d i |
   | _1 g  }
 |
 i } n | o | d d= |  n t |  i i8 } t |  i i9 } t) | d>  o | i: |   } n g  } | | d? |  i  | p | p | ok | i(   x | D] } | | |  quWx | D] } | | |  qWx. | D] } | | |  qWn | | d9  | | d:  | d j	 om | oe d2 t0 |  i d@ f } | i1 i$ |  d4 j  o t2 i3 dA IJqe	| i1 i | d i |
   | _1 n | d j	 o| o	| i+ i" |  i h   }  g  }! x | D]{ \ }" } } | |  j o_ |! i dB | |  i f  |! i | dC |  |! i | dD  |! i | dE  d
 |  | <q	q	WdF t0 |  i f } | i1 i$ |  d4 j  o t2 i3 dG IJn" | i1 i | d i |!   | _1 ~! n h  }  x | D]w \ }" } } | |  j o[ | d dB | |  i f  | | dH |  | | dD  | | | dE  d
 |  | <q
q
Wt t |  i _ | dI |  i  t  o9 | d j	 o, | o | i; i d i |
   n d Sn t  o| d j	 o dJ t0 } | i1 i | d  | _1 dK t0 } d i t i<    }# | i1 i | |#  | _1 t |  i i= i<   }$ dL g |$ dM g }% dN t0 } | i1 i | d i |%   | _1 y t> i? | | i1 dO  Wn& t@ dP t | iA |  i f   n Xd Sn t i i t |  i d  } tB iC   }& |& iD } x t D] }' | |'  qW| dQ  x" t |  i i= D] }( | |(  qW| dR  | d  x |
 D] }' | |'  qWy t> i? | |& iE   dO  Wn d d kF }) |) iG   n X|& iH   nJ x" t |  i i= D] }* d
 t |* <qWtI iD } x |
 D] }' | |'  qWd S(V   s/       Generates the code for a custom class.
    R`   R   s   .pyNR'   R   R   i   t   extra_modulesi   s   (use-package :%s)
is   _%di
   i   i	   s   
(defclass %s()
s6   	((top-window :initform nil :accessor slot-top-window)s   
t   (s    :initform nil :accessor slot-t   )s   ))
s   
(defun make-%s ()
s!   (let ((obj (make-instance '%s)))
s     (init obj)
s     (set-properties obj)
s     (do-layout obj)
s     obj))
s   
(defmethod init ((obj %s))
s5   "Method creates the objects contained in the class."
s   ;;;begin wxGlade: %s.__init__
t   styleR   R   s   (logior %s)Rd   sG   (setf (slot-top-window obj) (wxFrame_create nil -1 "" -1 -1 -1 -1 %s))
t   wxDialogsH   (setf (slot-top-window obj) (wxDialog_create nil -1 "" -1 -1 -1 -1 %s))
t   get_init_codeR   i   t   #s   .GetId()s   %s(obj %s obj.%s)
sV   (wxEvtHandler_Connect (slot-top-window obj) %s (exp%s)
		(wxClosure_Create #'%s obj))
s   )
s   ;;; end wxGlade
s   <%swxGlade replace %s %s>R   i    sF   WARNING: wxGlade __init__ block not found, __init__ code NOT generatedt   get_properties_codes&   
(defmethod set-properties ((obj %s))
s&   ;;;begin wxGlade: %s.__set_properties
s   pass
s   )
;;;end wxGlade
t   __set_propertiessV   WARNING: wxGlade __set_properties block not found, __set_properties code NOT generateds    (defmethod do-layout ((obj %s))
t   get_layout_codes!   ;;;begin wxGlade: %s.__do_layout
t   __do_layoutsL   WARNING: wxGlade __do_layout block not found, __do_layout code NOT generateds?   (defun %s (function data event) ;;;wxGlade: %s.<event_handler>
s-   (print "Event handler `%s' not implemented")
s   (when event
s   (wxEvent:wxEvent_Skip event)))
s   <%swxGlade event_handlers %s>sR   WARNING: wxGlade event_handlers block not found, event_handlers code NOT generateds.   (print "Event handler `%s' not implemented!")
s   
;;; end of class %s


s   <%swxGlade insert new_classes>s   <%swxGlade extra_modules>
s   # begin wxGlade: dependencies
s   # end wxGlade
s    <%swxGlade replace dependencies>R   s    py_codegen.add_class: %s, %s, %ss    
;;;begin wxGlade: dependencies
s   ;;;end wxGlade
i i ʚ;(   i   i   (J   R   R   R   R\   R	   R   R   RR   Rp   t   existsR$   R   Rv   R"   t   has_keyR   R   R   R   Rn   R   R%   R-   RN   R0   Rz   R   R   R   t   previewRl   Rq   R   R   R   RL   R+   R~   R   R   R   R   R   R   R   Ra   R   RK   R1   R!   t   syst   stderrt   generate_common_propertiesR   R   t   lenR   R   R   R#   R   R   Rs   R   R   R    R   R   R   R   t	   tracebackt	   print_excR6   R   (+   t   code_objt   prev_srct   filenameR   R   t   mycn_ft   is_newt   indentationt   modst   mR   R   t   lt   tabR   Rl   R   t   propR   t
   init_linesR   R   R   R   R   t   win_idR   t   obj_pt
   write_bodyt   layout_linest   sizers_init_linest   extra_layout_linest   already_theret   bufR    R   R   t   depst   outRA   t   moduleR   R   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt	   add_classA  s   
%$# 	  !	
 ,
	
    $ 	 		
!		 
!
   
% 			! 			$




!	 
 

  	 c         C   s"  t  a |  i d  } | p
 d } n t p
 t } n= t i i t | d  } t i i	 |  p
 d } n d } | d j	 o d Sn |  i d  } |  i d  } | p d Sn g  } | i } | o t d  }	 | d	  nB t d  }	 | d	  t o$ | |	 d
  | |	 d |  n | i d d  } | |	 d | | f  | om | |	 d |  | |	 d |  | d |  t d  }	 t o$ | |	 d
  | |	 d |  qn% | |	 d |  | |	 d |  | d  | d  t o t i i t | d  } t i   }
 |
 i } | d  x t D] } | |  qBW| d | | f  x | D] } | |  qqWy t i | |
 i   d  Wn d d k } | i   n Xy t i | d  Wn t j
 o n X|
 i   n% t i } x | D] } | |  q
Wd S(   s{       Generates the code for a wxApp instance.
    If the file to write into already exists, this function does nothing.
    R    Ru   s   .pyi   Nt   classt
   top_windowi   s    (defun init-func (fun data evt)
s   import gettext
sC   gettext.install("%s") # replace with the appropriate catalog name

R   R   s   (let ((%s (make-%s)))
s+   (ELJApp_SetTopWindow (slot-top-window %s))
s'   (wxWindow_Show (slot-top-window %s))))
s   ;;; end of class %s

sO   
(unwind-protect
	(Eljapp_initializeC (wxclosure_Create #'init-func nil) 0 nil)sD   
  (ffi:close-foreign-library "../miscellaneous/wxc-msw2.6.2.dll"))
s   #!/usr/bin/env lisp
s   from %s import %s

R   ii  (   R-   R   R   R   R   R   R\   R	   R   R   R$   R0   RN   RV   RR   R   R   R   Rz   Rs   R   R   R   R   R   R   R6   R   (   R   t   top_win_classR    R   R   R   t   top_wint   linesR0   R   R  R   RA   R   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   add_app  st    	
		

	
  	 c         C   s9   |  i  o d Sn$ t |   o d |  i Sn |  i Sd  S(   Ns   (slot-top-window obj)s   (slot-%s obj)(   R   R   R    (   R   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   _get_code_name  s    c         C   s   t  |   } |  i i d d  i   } | d d j } t d j  p |  i d j o
 d } n d } | o4 d	 | d
 | d	 t d  d | | d  f Sn | d | d | Sd S(   sJ       returns the code fragment that sets the size of the given object.
    t   sizeR'   it   di   i   t   wxWindow_SetSizet
   SetMinSizeR   R   t	   wxDLG_SZEs   (%s (%s)))
R`   s   ((%s))
N(   i   i   (   R  R   R   RL   Ra   R   R$   R   (   R   R    R  t   use_dialog_unitst   method(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   generate_code_size  s    
c      	   C   s>   d t  |  d d !d  t  |  d d !d  t  |  d d  f S(   Ns   %d %d %di   i   i   i   (   Rm   (   RX   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   _string_to_colour  s    c         C   s   t  |   } y% t d  d t |  i d  } Wn: t t f j
 o( t d  d t |  i d  } n Xt t d g  Ba | d | | f S(   s[       returns the code fragment that sets the foreground colour of
    the given object.
    s   (wxColour_CreateRGB s   %s)t
   foregrounds   (wxSystemSettings_GetColour Rh   s%   (wxWindow_SetForegroundColour %s %s)
(   R  R   R  R   t
   IndexErrorRo   R   R~   (   R   R   t   color(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   generate_code_foreground  s    c         C   s   t  |   } y d d t |  i d  } Wn: t t f j
 o( t d  d t |  i d  } n Xt t d g  Ba t GHd | | f S(   s[       returns the code fragment that sets the background colour of
    the given object.
    s   (wxColour_CreateRGB s   %s)t
   backgrounds   (wxSystemSettings_GetColour Rh   s%   (wxWindow_SetBackgroundColour %s %s)
(   R  R  R   R  Ro   R   R   R~   (   R   R   R  (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   generate_code_background  s    c   	      C   s   |  i  d } | d } t | d  } | d } t | d  } t | d  } d | d i d	 d
  } t |   } t t d g  Ba d | | | | | | | f S(   sJ       returns the code fragment that sets the font of the given object.
    t   fontR  t   familyt
   underlinedR   t   weights   "%s"t   faceRP   s   \"t   wxFontsO   (wxWindow_SetFont %s (wxFont_Create %s %s %s %s %s %s wxFONTENCODING_DEFAULT))
(   R   R   RR   R  R   R~   (	   R   R  R  R  R   R   R!  R"  R   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   generate_code_font  s    

c         C   s!  |  o |  i  o d Sn | d j o |  i i d  } n | d j o d Sn | i d  } t |  d j o | d  \ } } n d | d f S| p d | f Sn | i   d j o t d	  } n | i   } | i   } d
 | j o d | | f | f Sn d | | | f | f S(   s       returns a 2-tuple of strings representing the LOC that sets the id of the
    given object: the first line is the declaration of the variable, and is
    empty if the object's id is a constant, and the second line is the value
    of the id
    R'   s   -1R   t   =i   i   i    t   ?s	   wxNewId()R`   s   %s = %s
s   global %s; %s = %s
(   R'   s   -1N(   R'   s   -1(   R   R$   R   R   R   R   RL   R   (   R   R   t   tokensR    t   val(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR   1  s    '%c         C   s)   t  |   } d | d t |  i d  S(   sM       returns the code fragment that sets the tooltip of the given object.
    s   (wxWindow_SetToolTip s   %s)
t   tooltip(   R  R[   R   (   R   R   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   generate_code_tooltipK  s    
c         C   sN   t  |   } y t |  i d  } Wn t } n X| o d | d Sn d  S(   Nt   disableds   (wxWindow_IsEnabled s   0)
(   R  Rm   R   R   (   R   R   R+  (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   generate_code_disabledT  s
    c         C   sN   t  |   } y t |  i d  } Wn t } n X| o d | d Sn d  S(   Nt   focuseds   (wxWindow_SetFocus s   )
(   R  Rm   R   R   (   R   R   R-  (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   generate_code_focused\  s
    c         C   sN   t  |   } y t |  i d  } Wn t } n X| o d | d Sn d  S(   Nt   hiddens   (wxWindow_Hide s   )
(   R  Rm   R   R   (   R   R   R/  (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   generate_code_hiddend  s
    c         C   sT  |  i  } g  } | i d d  i   o | i t |    n | i d  o | i t |    n | i d  o | i t |    n | i d  o | i t |    n | i d  o | i t |    n | i d  o | i t	 |    n | i d  o | i t
 |    n | i d	  o | i t |    n | S(
   s       generates the code for various properties common to all widgets (background
    and foreground colors, font, ...)
    Returns a list of strings containing the generated code
    R  R'   R  R  R  R)  R+  R-  R/  (   R   R   RL   R0   R  R  R  R$  R*  R,  R.  R0  (   t   widgetR   R  (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR   l  s    	0'''''''t   FontPropertyHandlerc           B   s   e  Z d  Z h  d d <d d <d d <d d <d	 d
 <d d <d d <Z h  d d <d d <d d <Z h  d d <d d <d d <Z d   Z d   Z d   Z d   Z	 RS(   s   Handler for font propertiest	   wxDEFAULTt   defaultt   wxDECORATIVEt
   decorativet   wxROMANt   romant   wxSWISSt   swisst   wxSCRIPTt   scriptt   wxMODERNt   modernt
   wxTELETYPEt   teletypet   wxNORMALt   normalt   wxSLANTt   slantt   wxITALICt   italict   wxLIGHTt   lightt   wxBOLDt   boldc         C   s   h  |  i  d <|  i d <|  i d <|  _ h  d d <d d <d d <d d <d d <d d <|  _ d  |  _ g  |  _ d  S(	   NR  R   R!  t   0R  R   R'   R"  (   t   font_familiest   font_stylest   font_weightst   dictst   attrsR$   t   currentt	   curr_data(   R   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR     s    (	c         C   s@   g  |  _  | d j o | |  i j o | |  _ n
 d  |  _ d  S(   NR  (   RR  RP  RQ  R$   (   R   R    RP  (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt
   start_elem  s    	c         C   s   | d j o |  i  | i d <t Snu |  i d  j	 od |  i i |  i  } | o" | i d i |  i  d  } n d i |  i  } | |  i  |  i <n d  S(   NR  R'   RK  (	   RP  R   R-   RQ  R$   RO  R   R	   RR  (   R   R    R   t   decodeR(  (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   end_elem  s    )c         C   s   |  i  i |  d  S(   N(   RR  R0   (   R   t   data(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt	   char_data  s    (
   R   R   R   RL  RM  RN  R   RS  RU  RW  (    (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR2    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    RP  (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyRS    s    c         C   s   t  S(   N(   R-   (   R   R    R   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyRU    s    c         C   s   d  S(   N(    (   R   RV  (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyRW    s    (   R   R   R   RS  RU  RW  (    (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyRX    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   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR     s    		c         C   s"   | d j o | d |  _  n d  S(   NR   R   (   R[  (   R   R    RP  (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyRS    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'   R   (   R[  R\  R	   RZ  R$   R   R-   (   R   R    R   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyRU    s     	c         C   s+   | i    } | o |  i i |  n d  S(   N(   RL   R\  R0   (   R   RV  (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyRW    s    (   R   R   R   RS  RU  RW  (    (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyRY    s   			
R  R   c         C   sP   y t  | |  } Wn% t j
 o t i |  d   } n X| o |   Sn d  S(   N(   t   _property_writersRn   t   _global_property_writersR   R$   (   t   property_namet   widget_namet   cls(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_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]  Rn   (   R_  R   R`  (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   add_property_handler  s    t   WidgetHandlerc           B   s8   e  Z d  Z g  Z d   Z d   Z d   Z d   Z RS(   sM       Interface the various code generators for the widgets must implement
    c         C   s   g  g  g  f S(   s           Handler for normal widgets (non-toplevel): returns 3 lists of strings,
        init, properties and layout, that contain the code for the
        corresponding methods of the class to generate
        (    (   R   R   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR     s    c         C   s   g  S(   s           Handler for the code of the set_properties method of toplevel objects.
        Returns a list of strings containing the code to generate
        (    (   R   R   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR     s    c         C   s   g  S(   s2          Handler for the code of the constructor of toplevel objects.  Returns a
        list of strings containing the code to generate.  Usually the default
        implementation is ok (i.e. there are no extra lines to add). The
        generated lines are appended at the end of the constructor
        (    (   R   R   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR     s    c         C   s   g  S(   s           Handler for the code of the do_layout method of toplevel objects.
        Returns a list of strings containing the code to generate.
        Usually the default implementation is ok (i.e. there are no
        extra lines to add)
        (    (   R   R   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyR     s    (   R   R   R   R   R   R   R   R   (    (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyRd    s   				c         C   s   | t  |  <d  S(   N(   R   (   R`  R   (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   add_widget_handler   s    c       
   C   sC  t  i i t i d  }  t  i i |  d  } t  i i |  p | i d | IJd Sn d d k } | i i |   t	 |  } x | D] } | i
   } | p | i d  o q n | i d  d i
   } y* t | d h  h  d	 g  } | i   Wq t t f j
 o q Xq W| i   d d k } | i i   d S(
   sn       Code generator setup function. This is called once, when the code
    generator is loaded in wxglade.
    t   widgetss   widgets.txts   widgets file (%s) doesn't existNiR   i    s   .lisp_codegenR   (   R   R\   R	   Rs   t   wxglade_pathR   R   R   R0   R*   RL   RK   R   t
   __import__R   t   ImportErrort   AttributeErrorR6   t   edit_sizers.lisp_sizers_codegent   lisp_sizers_codegen(   t   _widgets_dirt   widgets_fileR   t   modulesRA   t   module_nameR   t   edit_sizers(    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pyt   setup$  s,     	
(P   R   R   R   t   os.pathRs   R{   R   t	   xml_parseR    R(   R~   t	   NameErrort   setsR   t   languageRo  R   t   writert   default_extensionsR$   R"   R   t   obj_propertiesR1   Rz   R   R   R   R   R   R   R   R-   R   R   R   Ra   R   R   R   RN   Rp   RV   R)   RS   RO   R[   R   R   R   R   R   R  R   R  R  R  R  R  R  R$  R   R*  R,  R.  R0  R   R2  RX  t   objectRY  R^  R]  t   _widget_extra_modulesRv   Rb  Rc  Rd  Re  Rr  (    (    (    sJ   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\lisp_codegen.pys   <module>   s   $						e	5	
	F	%	 F	W												)		,	