
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 Z	 e i
 e Z d d g Z e a h  Z h  Z e a g  a e a e a e a d   Z d f  d	     YZ d
 f  d     YZ e a e a e a d d k Z e i d  Z  d   Z! d   Z" d   Z# d   Z$ d   Z% d   Z& d   Z' h  d d <d d <d d <d d <d d <d d <Z( d    Z) e a* d!   Z+ d"   Z, d#   Z- d$   Z. d%   Z/ d&   Z0 d'   Z1 e d(  Z2 d)   Z3 d*   Z4 d+   Z5 d,   Z6 d-   Z7 d.   Z8 d/ f  d0     YZ9 d1 f  d2     YZ: d3 e; f d4     YZ< d5 e; f d6     YZ= h  e9 d7 <e< d8 <e= d9 <Z> h  Z? h  Z@ h  aA d:   ZB e d;  ZC d< f  d=     YZD d>   ZE d?   ZF d S(@   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   XmlParsingErrort   perlt   plt   pmc         C   sF   |  d  d j o d |  d Sn" |  d  d j o d |  Sn |  Sd  S(   Ni   t   wxs   Wx::i   t   EVT_(    (   t
   class_name(    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   cnC   s
    t
   ClassLinesc           B   s   e  Z d  Z d   Z RS(   s9       Stores the lines of perl 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(    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   __init__O   s    							(   t   __name__t
   __module__t   __doc__R   (    (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR   K   s   t   SourceFileContentc           B   s2   e  Z d  Z d d d d  Z d   Z d   Z RS(   sY      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
    
    WARNING: NOT YET COMPLETE
    (always overwrites destination file, ALWAYS) -- crazyinsomniac

    alb - the warning above shouldn't be true anymore... but we need testing...
    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   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR   j   s    						c         C   sH  d d k  } d } t } | i d  } | i d  } | i d  } | i d  } | i d  } t }	 t }
 t |  i  } g  } x| D]}} | i |  } | d j	 o
 t }
 n |
 o. | i |  | i	 d  o
 t }
 q q n | i |  } | d j	 oU | d j o | i d	 t
  t } n | i d
  } d
 |  i | <| i |  q |	 p| i |  } | d j	 o | i d
  } | i d  } | i d  } | d j o
 | } n | |  i | <t }	 | d j o | i d t
 | f  q| i d t
 | | f  q| i |  } | d j	 o; | i d  } | i d
  } d
 |  i i | h   | <n | d j	 o+ |  i |  o | i d t
 | f  n | i |  | i   i	 d  o | i d t
  qq | i |  d j	 o
 t }	 q q 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
        
        WARNING: NOT YET COMPLETE -- crazyinsomniac

        alb - almost done :)
        WARNING: There is *NO* support for here documents: if you put wxGlade
        blocks inside a here document, you're likely going into troubles...
        iNs&   ^\s*package\s+([a-zA-Z_][\w:]*)\s*;.*$s:   ^(\s*)#\s*begin\s+wxGlade:\s*([a-zA-Z_][\w:]*?)::(\w+)\s*$s   ^\s*#\s*end\s+wxGlade\s*$s   ^\s*=[A-Za-z_]+\w*.*$s2   #\s*wxGlade:\s*([\w:]+)::(\w+) <event_handler>\s*$s   =cuts   #<%swxGlade insert new_classes>i   i   i   s   #<%swxGlade replace %s>s   #<%swxGlade replace %s %s>s   #<%swxGlade event_handlers %s>s   use Wxs   #<%swxGlade extra_modules>
t    (   t   reR   R   t   compilet   openR   t   matcht   Truet   appendt
   startswitht   noncet   groupR   R   R   t
   setdefaultt   is_end_of_classt   lstript   closet   joinR   (   R   R    R   t   new_classes_insertedt
   class_declt   block_startt	   block_endt   pod_ret   event_handlert   inside_blockt
   inside_podt   tmp_int	   out_linest   linet   resultR   t   which_classt   which_blockt   which_handler(    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR   w   s    	 

	
				
c         C   s   | i    i d  S(   Ns   # end of class (   t   stripR&   (   R   R8   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR*      s    N(   R   R   R   R   R   R   R*   (    (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR   `   s   		fs   \\(?![nrt])c         C   s~   |  p d Sn t  i d |   }  |  i d d  }  |  i d d  }  |  i d d  }  t o d	 |  d
 Sn d |  d Sd S(   s       returns a quoted version of 's', suitable to insert in a perl source file
    as a string object. Takes care also of gettext support
    s   ""s   \\\\t   "s   \"t   $s   \$t   @s   \@s   _T("s   ")N(   t   _quote_str_ret   subt   replacet   _use_gettext(   t   s(    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt	   quote_str   s    c         C   sT   |  i  d d  }  |  i  d d  }  |  i  d d  }  |  i  d d  }  d |  d S(	   s^       escapes all " and \ , thus making a path suitable to
    insert in a perl source file
    s   \s   \\R>   s   \"R?   s   \$R@   s   \@(   RC   (   RE   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt
   quote_path   s
    c         C   s  |  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 yB 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 qSd a 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 | a t p t o# t i i |  o t  |  a! qd a! t" i#   a$ | a% t$ i& d  x t D] } t$ i& |  qWt$ i& d t  t$ i& d  n0 d a! t i i' |  p t( d   n | a) d S(   sW      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   t   for_versioni   i   s"   # generated by wxGlade %s on %s%s
s6   # To get wxPerl visit http://wxPerl.sourceforge.net/

s)   use Wx 0.15 qw[:allclasses];
use strict;
s   # generated by wxGlade %s%s
i    s   #!/usr/bin/perl -w -- 
s   #<%swxGlade extra_modules>
s   
s@   'path' must be a directory when generating multiple output filesi@B i (   i   i   (*   t   timet   randomt   intRD   t   KeyErrort
   ValueErrorR   t
   _overwritet   strRC   t	   randrangeR'   t   tuplet   splitRM   t   commont   app_treeR   t   appR   t   _current_extra_modulest   versiont   asctimet   generated_fromt   header_linest   configt   preferencest   write_timestampt   multiple_filest   osRH   t   isfileR   t   previous_sourcet	   cStringIOt   StringIOt   output_filet   output_file_namet   writet   isdirR    t   out_dir(   t	   app_attrst   out_patht   multi_filesRN   RO   t   _[1]t   tR8   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt
   initialize
  sX    



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  _ d d k	 } | i
 d t t  i  } xM | D]E }  t  i i |  d d  } d	 | } t  i i |  d
 |  t  _ q W| 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>
iNs*   (#<%swxGlade replace ([a-zA-Z_]\w*) +\w+>)i   s   	s@   %s# content of this block not found: did you rename this class?
i    s   #<%swxGlade event_handlers \w+>t   codegeni  (   Rf   R   R'   R   R-   R   RC   R[   t   keysR    t   findallR   t   getRX   t	   save_fileR   Rc   Ri   t   getvalueR,   Rj   t
   _app_addedRd   t   chmodt   IOErrorR    RT   t   OSError(	   t   tagt   codeR    t   tagst   indentt   commentt   emR   t   e(    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   finalizew  sN    


  
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(   RP   t
   propertiesRQ   RR   R$   (   t   obj(    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_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  nBXy | i	 |  \ } } } Wn | GH  n X| i
 o0| i o) | i o | i   | i i |  n | i i |  t | d t  } t | d  oF | i |  } x | D]( \ }	 }
 } | i i |	 |
 | f  q>Wq3d | i j oq t |  \ } }	 |	 d j o d | i }	 n x> | i d i   D]% \ }
 } | i i |	 |
 | f  qWq3nA | i d j o  | i i d	 | i d
   n | i i |  | i i |  | i i |  t o; | i o1 | i | i j o d | i } 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   
s?   # code for %s (type %s) not generated: no suitable writer foundR   t
   get_eventst   eventss   -1s
   #$self->%st   wxStaticBoxSizeri   i    s   use %s;
t   import_modulesN(    R   t   klassRQ   R   t   obj_builderst   baseR	   t   extendR   t   get_codet
   in_windowst   is_containert   is_toplevelt   reverseR
   t   getattrR   t   hasattrR   R   R%   R   t   generate_code_idt	   iteritemst   insertt   popR   R   R   Rc   R   Rw   (   t   top_objt   sub_objR   t   builderR	   R   R   t   mycnt   evtst   idt   eventt   handlert   id_namet   keyt   dep(    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt
   add_object  sT    '

 ! % 
 c         C   s:  | i  } y: g  } | i d  D] } | t |  q  ~ \ }	 }
 Wn t j
 o} | i o t |  o d | } q} n | i d j o t d j  o d | } q | d d !d	 j o d | } q n Xy t |  i	 } Wn' t
 j
 o t   } t |  i	 <n Xd
 | i  | | | | f } | i i |  d S(   sc       writes the code to add the object 'obj' to the sizer 'sizer'
    in the 'toplevel' object.
    t   ,s   $self->{%s}t
   wxNotebooki   i   s   Wx::NotebookSizer->new(%s)i    i   R?   s"   $self->{%s}->Add(%s, %s, %s, %s);
N(   i   i   (   R   RW   RP   RR   R   R   R   RM   R   R   RQ   R   R   R%   (   t   toplevelt   sizerR   RI   t   flagt   bordert   obj_nameRq   RE   t   wt   hR   t   buffer(    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   add_sizeritem  s$    	:
s6   	$parent = undef              unless defined $parent;
s   $parents2   	$id     = -1                 unless defined $id;
s   $ids5   	$title  = ""                 unless defined $title;
s   $titles3   	$pos    = wxDefaultPosition  unless defined $pos;
s   $poss4   	$size   = wxDefaultSize      unless defined $size;
s   $sizes5   	$name   = ""                 unless defined $name;

s   $namec   '   +   C   s(  t  p
 t } nL t i i t |  i d  } t i i |  p
 d } n t	 |  } h  a
 t i |  i  o t |  i i o d Sn y t |  i } Wn t j
 o |  GH  n X| d j	 o  | i i |  i  o
 t } n? t } t | d g   } | o x | D] } d t
 | <q
Wn g  } | i } t i |  i  p t   t |  i <n t | d g   }	 t o  | o d t |  i i d <n | o+| d |  i  | d |  i i d	 d
 d   t o- t  o d t |  i i d <q| d  n t  oG | d  x" t |  i i D] }
 | |
  qW| d  | d  n | d  | d d i |	   |	 o7 xI |	 D]( } t i |  o | t |  qzqzWqd g }	 |  i d GHn | d |  i  |  i } | i d d  } | o | d |  n | d d i |	   t |  i i } t |  i i } | i   x | D] } | d |  qPWx | D] } | d |  qoWt | d  o, x) | i  |   D] } | d |  qWn | d  | d  t |  i i! } t | d  o= x: | i" |   D]% \ } } } | i | | | f  qWn xT | D]L \ } } } | i# d  o d | d d } n | d  | | | f  q;W| o | d  n | d  | o | d!  | d"  n | d j	 o| | ot d# t$ |  i d$ f } | i% i& |  d% j  o t' i( d& IJn" | i% i | d' i |   | _% g  } | i } n t | d( t)  |   } | i* t |  i i+  t, |  } | o | d)  n | d* |  i  | p | d+  n  x | D] } | d |  qW| d,  | o | d-  n | d j	 o| | ot d# t$ |  i d. f } | i% i& |  d% j  o t' i( d/ IJn" | i% i | d' i |   | _% g  } | i } n | o | d0  n t |  i i- } t |  i i. } t | d1  o | i/ |   } n g  } | d2 |  i  | p | p | ok | i   x | D] } | d |  q$Wx | D] } | d |  qCWx* | D] } | d |  qbWn | d+  | d,  | o | d-  n | d j	 om | oe d# t$ |  i d3 f } | i% i& |  d% j  o t' i( d4 IJq!| i% i | d' i |   | _% n | d j	 o | o | i! i |  i h   } g  } xR | D]J \ } } } | | j o. | i d5 | |  i | | f  d | | <q[q[Wd6 t$ |  i f } | i% i& |  d% j  o t' i( d7 IJn" | i% i | d' i |   | _% ~ nY h  } xO | D]G \ } } } | | j o+ | d5 | |  i | | f  d | | <q	q	Wt t |  i _ | d8 |  i  t  o9 | d j	 o, | o | i0 i d' i |   n d Sn t  o| d j	 od9 t$ } | i% i | d'  | _% d: t$ } d' i t
 i1    } | i% i | |  | _% t |  i i i1   }  d g |  d g }! d; t$ |  i f } | i% i | d' i |!   | _% y t2 i3 | | i% d<  Wn& t4 d= t | i5 |  i f   n Xd Sn |  i i d> t i6  d } t i i t |  } t7 i8   }" |" i9 } x t: D] }# | |#  q+Wx | D] }# | |#  qFWyS t i i; |  }$ t i i |$  p t i< |$  n t2 i3 | |" i=   d<  Wn d? d k> }% |% i?   n X|" i@   nJ x" t |  i i D] }& d t
 |& <qWtA i9 } x | D] }# | |#  qWd S(@   s/       Generates the code for a custom class.
    s   .pmNt   extra_modulesi   t   new_signatures    use Wx::Locale gettext => '_T';
s   package %s;

s6   use Wx qw[:everything];
use base qw(%s);
use strict;

R   s   Wx::s    # begin wxGlade: ::dependencies
s   # end wxGlade
s   
s
   sub new {
s   	my( $self, %s ) = @_;
s   , s   @_[1 .. $#_]s    did not declare new_defaults s   # begin wxGlade: %s::new

t   styles(   	$style = %s 
		unless defined $style;

s"   	$self = $self->SUPER::new( %s );
s   	t   get_init_codes   
	$self->__set_properties();
s   	$self->__do_layout();

R   t   #s   $self->{i   s   }->GetIds!   	Wx::Event::%s($self, %s, \&%s);
s   	return $self;

s   }

s   #<%swxGlade replace %s %s>t   newi    sF   WARNING: wxGlade ::new block not found, constructor code NOT generatedR   t   get_properties_codes,   
sub __set_properties {
	my $self = shift;

s'   # begin wxGlade: %s::__set_properties

s	   	return;
s   
# end wxGlade
s   }
t   __set_propertiessV   WARNING: wxGlade __set_properties block not found, __set_properties code NOT generateds'   
sub __do_layout {
	my $self = shift;

t   get_layout_codes"   # begin wxGlade: %s::__do_layout

t   __do_layoutsL   WARNING: wxGlade __do_layout block not found, __do_layout code NOT generateds   
sub %s {
	my ($self, $event) = @_;
# wxGlade: %s::%s <event_handler>

	warn "Event handler (%s) not implemented";
	$event->Skip;

# end wxGlade
}

s   #<%swxGlade event_handlers %s>sR   WARNING: wxGlade event_handlers block not found, event_handlers code NOT generateds   
# end of class %s

1;

s   #<%swxGlade insert new_classes>s   #<%swxGlade extra_modules>
s$   #<%swxGlade replace %s dependencies>Rt   s    pl_codegen.add_class: %s, %s, %ss   ::i(B   Rc   Rf   Rd   RH   R-   Rm   R   t   existsR   R   R[   R   t   has_keyR   R   R   RQ   R   R$   R   R%   R   RD   R   RC   t   new_defaultsR   Rw   R	   R
   R   R   R   R   R   R&   R'   R   t   findt   syst   stderrt   generate_common_propertiesR   R   t   lenR   R   R   R   Ru   RX   Rx   R|   R   t   sepRg   Rh   Rk   R_   t   dirnamet   makedirsRy   t	   tracebackt	   print_excR,   Ri   ('   t   code_objt   prev_srct   filenameR   t   is_newt   modst   mR   Rk   R   t   modulet   kt   propR   t
   init_linesR
   t   lR   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   outR8   R   R   R   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt	   add_class  s   
$#
 	
 

 		
   

  

!	 

!
   


% 	! $



!	   	 c         C   ss  t  a |  i d  } | p
 d } n t p
 t } nN t i i t | d  } t i i	 |  p
 d } n t o
 d } n d } | d j	 o d Sn |  i d  } |  i d  } | p d Sn g  } | i } | o? | d |  | d	  t o | d
 |  n | d  nq | d  t o | d |  n | d  t o$ | d d  | d | d  n | d  | d |  | d  | d | | f  | o | d |  | d |  | d  | d |  | d  t o$ | d d  | d | d  n | d | | f  n# | d | | f  | d |  | d |  t o t i i t | d  } t i   }	 |	 i }
 |
 d   x t D] } |
 |  qWx | D] } |
 |  q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   RZ   s   .pli   Nt   classt
   top_windows   package %s;
s$   
use base qw(Wx::App);
use strict;

s	   use %s;

s$   sub OnInit {
	my( $self ) = shift;

s   1;

package main;
s
   
use %s;

s   
unless(caller){
s4   	my $local = Wx::Locale->new("English", "en", "en");s    # replace with ??
s   	$local->AddCatalog("%s");s.    # replace with the appropriate catalog name

s"   	local *Wx::App::OnInit = sub{1};
s   	my $%s = Wx::App->new();
s   	Wx::InitAllImageHandlers();

s   	my $%s = %s->new();

s   	$self->SetTopWindow($%s);
s   	$%s->Show(1);

s   	return 1;
}
s   # end of class %s

s   package main;

unless(caller){
s   	my $%s = %s->new();
s   	$%s->SetTopWindow($%s);
s   	$%s->Show(1);
s   	$%s->MainLoop();
}
s   #!/usr/bin/perl -w -- 
Rt   ii  (   R$   Rz   Rw   Rc   Rf   Rd   RH   R-   Rm   R   R   RS   R%   RD   Rg   Rh   Rk   R_   RX   Rx   Ry   R   t
   print_wexcR{   R}   R,   Ri   (   Rn   t   top_win_classR   R   R   R   t   top_wint   linesR%   R   Rk   R8   R   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   add_appJ  s    	








	
  	 c         C   s\   |  i  o d SnG t |   o d |  i Sn+ |  i d d j o |  i Sn d |  i Sd S(   sQ       returns the name of the variable ( either $self, $foo, or $self->{foo} )
    s   $selfs   $self->{%s}i    R?   N(   R   R   R   (   R   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_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 } | o" | d	 | d
 | | d  f Sn | d	 | d | S(   sJ       returns the code fragment that sets the size of the given object.
    t   sizeR   it   di   i   t   SetSizet
   SetMinSizes   ->s4   (%s->ConvertDialogSizeToPixels(Wx::Size->new(%s)));
s   (Wx::Size->new(%s));
(   i   i   N(   R   R   Rw   R=   RM   t   parentR   (   R   R   R   t   use_dialog_unitst   method(    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_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   (   RP   (   RE   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   _string_to_colour  s    c         C   s`   t  |   } y d t |  i d  } Wn* t t f j
 o d |  i d } n X| d | S(   s[       returns the code fragment that sets the foreground colour of
    the given object.
    s   Wx::Colour->new(%s)t
   foregrounds!   Wx::SystemSettings::GetColour(%s)s   ->SetForegroundColour(%s);
(   R   R   R   t
   IndexErrorRR   (   R   R   t   color(    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   generate_code_foreground  s    c         C   s`   t  |   } y d t |  i d  } Wn* t t f j
 o d |  i d } n X| d | S(   s[       returns the code fragment that sets the background colour of
    the given object.
    s   Wx::Colour->new(%s)t
   backgrounds!   Wx::SystemSettings::GetColour(%s)s   ->SetBackgroundColour(%s);
(   R   R   R   R   RR   (   R   R   R   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   generate_code_background  s    c   	      C   s   |  i  d } | d } | d } | d } | d } | d } d | d i d	 d
  } t |   } | 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   faceR>   s   \"s2   ->SetFont(Wx::Font->new(%s, %s, %s, %s, %s, %s));
(   R   RC   R   (	   R   R   R   R   R   R   R   R   R   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   generate_code_font  s    
c         C   s   |  o# | 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
 d	 } n 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   R   s   -1t   =i   i   i    t   ?s   Wx::NewId()s   use constant %s => %s;
N(   R   s   -1(   R   R   Rw   RW   R   R=   (   R   R   t   tokensR   t   val(    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR     s    
c         C   s%   t  |   } | d t |  i d  S(   sM       returns the code fragment that sets the tooltip of the given object.
    s   ->SetToolTipString(%s);
t   tooltip(   R   RF   R   (   R   R   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   generate_code_tooltip  s    c         C   sJ   t  |   } y t |  i d  } Wn t } n X| o | d Sn d  S(   Nt   disableds   ->Enable(0);
(   R   RP   R   R   (   R   R   R  (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   generate_code_disabled  s    
c         C   sJ   t  |   } y t |  i d  } Wn t } n X| o | d Sn d  S(   Nt   focuseds   ->SetFocus();
(   R   RP   R   R   (   R   R   R  (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   generate_code_focused)  s    
c         C   sJ   t  |   } y t |  i d  } Wn t } n X| o | d Sn d  S(   Nt   hiddens   ->Show(0);
(   R   RP   R   R   (   R   R   R  (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   generate_code_hidden4  s    
c         C   sY   t  |   } |  i d } g  } x3 t |  D]% } | i | d | | | f  q, W| S(   Nt   extrapropertiess   ->Set%s(%s);
(   R   R   t   sortedR%   (   R   R   R   t   retR   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   generate_code_extraproperties?  s     #c         C   s  |  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 | i d
  o" |  i 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   Rw   R=   R%   R   R   R   R   R  R  R  R	  t   previewR   R  (   t   widgetR   R   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR   H  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   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR   k  s    (	c         C   s@   g  |  _  | d j o | |  i j o | |  _ n
 d  |  _ d  S(   NR   (   R0  R.  R/  R   (   R   R   R.  (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt
   start_elems  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   R)  (	   R.  R   R$   R/  R   R-  Rw   R-   R0  (   R   R   R   t   decodeR  (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   end_elemz  s    "c         C   s   |  i  i |  d  S(   N(   R0  R%   (   R   t   data(    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt	   char_data  s    (
   R   R   R   R*  R+  R,  R   R1  R3  R5  (    (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR  a  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.  (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR1    s    c         C   s   t  S(   N(   R$   (   R   R   R   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR3    s    c         C   s   d  S(   N(    (   R   R4  (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR5    s    (   R   R   R   R1  R3  R5  (    (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR6    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   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR     s    		c         C   s"   | d j o | d |  _  n d  S(   NR   R   (   R9  (   R   R   R.  (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR1    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   (   R9  R:  R-   R8  R   R   R$   (   R   R   R   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR3    s     	c         C   s+   | i    } | o |  i i |  n d  S(   N(   R=   R:  R%   (   R   R4  (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR5    s    (   R   R   R   R1  R3  R5  (    (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR7    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   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR     s    		c         C   s\   | d j oK | d } | o- | d i    o | d i   | d } n | |  _ n d  S(   Nt   propertyR   i    i   (   t   islowert   upperR<  (   R   R   R.  (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR1    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-   R   R   R   R$   (   R   R   R   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR3    s     	c         C   s+   | i    } | o |  i i |  n d  S(   N(   R=   R=  R%   (   R   R4  (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR5    s    (   R   R   R   R1  R3  R5  (    (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR;    s   			
R   R   R
  c         C   sP   y t  | |  } Wn% t j
 o t i |  d   } n X| o |   Sn d  S(   N(   t   _property_writersRQ   t   _global_property_writersRw   R   (   t   property_namet   widget_namet   cls(    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_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   RB  RA  RQ   (   RC  R   RD  (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   add_property_handler  s    t   WidgetHandlerc           B   s>   e  Z d  Z g  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   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_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   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_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   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_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   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyR     s    (	   R   R   R   R   R   R   R   R   R   (    (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyRH    s   				c         C   s   | t  |  <d  S(   N(   R   (   RD  R   (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_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   .perl_codegenRs   (   Rd   RH   R-   RX   t   wxglade_pathRe   R   R   R%   R"   R=   R&   RW   t
   __import__Rs   t   ImportErrort   AttributeErrorR,   t   edit_sizers.perl_sizers_codegent   perl_sizers_codegen(   t   _widgets_dirt   widgets_fileR   t   modulesR8   t   module_nameR   t   edit_sizers(    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pyt   setup+  s,     	
(G   R   R   Rd   t   os.pathRX   R`   Rg   t	   xml_parseR    t   languageRS  R   t   writert   default_extensionsR   R   R   t   obj_propertiesR'   R_   R   Rc   Ri   Rm   R   R   R   Rf   RS   RD   R    R!   RA   RF   RG   Rs   R   R   R   R   R   R   Rz   R   R   R   R   R   R   R   R   R  R  R  R	  R  R   R  R6  t   objectR7  R;  RB  RA  t   _widget_extra_modulesR[   RF  RG  RH  RI  RV  (    (    (    sH   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\codegen\pl_codegen.pys   <module>   s   $				m	5	
	6	!						 1	_														,	 		/	