#NEWLINE# def __init__( self , layout_handle , name , vertical , * elements , **kw ) : #NEWLINE# #INDENT# self . vertical = vertical #NEWLINE# self . vflex = ( not vertical ) #NEWLINE# for e in elements : #NEWLINE# #INDENT# if self . vertical : #NEWLINE# #INDENT# if e . vflex : #NEWLINE# #INDENT# self . vflex = True #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not e . vflex ) : #NEWLINE# #INDENT# self . vflex = False #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( ( len ( elements ) > 1 ) and self . vflex ) : #NEWLINE# #INDENT# if self . vertical : #NEWLINE# #INDENT# '\n                Example : The panel contains a mixture of fields and grids.\n                Fields are not vflex, grids well.\n                ' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# kw . update ( layout = 'hbox' , layoutConfig = dict ( align = 'stretch' ) ) #NEWLINE# #UNINDENT# #UNINDENT# for e in elements : #NEWLINE# #INDENT# if isinstance ( e , FieldElement ) : #NEWLINE# #INDENT# self . is_fieldset = True #NEWLINE# if e . label : #NEWLINE# #INDENT# w = ( len ( e . label ) + 1 ) #NEWLINE# if ( self . label_width < h ) : #NEWLINE# #INDENT# self . label_width = w #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# Container . __init__ ( self , layout_handle , name , * elements , ** kw ) #NEWLINE# w = h = 0 #NEWLINE# has_height = False #NEWLINE# for e in self . elements : #NEWLINE# #INDENT# ew = ( e . width or e . preferred_width ) #NEWLINE# eh = ( e . height or e . preferred_height ) #NEWLINE# if self . vertical : #NEWLINE# #INDENT# h += eh #NEWLINE# w = max ( w , ew ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if e . height : #NEWLINE# #INDENT# has_height = True #NEWLINE# #UNINDENT# w += ew #NEWLINE# h = max ( h , eh ) #NEWLINE# #UNINDENT# #UNINDENT# if has_height : #NEWLINE# #INDENT# self . height = h #NEWLINE# self . vflex = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . preferred_height = h #NEWLINE# #UNINDENT# self . preferred_width = w #NEWLINE# assert ( self . preferred_height > 0 ) , ( '%s : preferred_height is 0' % self ) #NEWLINE# assert ( self . preferred_width > 0 ) , ( '%s : preferred_width is 0' % self ) #NEWLINE# d = self . value #NEWLINE# if ( 'layout' not in d ) : #NEWLINE# #INDENT# if ( len ( self . elements ) == 1 ) : #NEWLINE# #INDENT# d . update ( layout = 'fit' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . vertical : #NEWLINE# #INDENT# if self . vflex : #NEWLINE# #INDENT# d . update ( layout = 'vbox' , layoutConfig = dict ( align = 'stretch' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# d . update ( layout = 'form' , autoHeight = True ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# d . update ( layout = 'hbox' , autoHeight = True ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( d [ 'layout' ] == 'form' ) : #NEWLINE# #INDENT# assert self . vertical #NEWLINE# self . update ( labelAlign = self . label_align ) #NEWLINE# self . wrap_formlayout_elements ( ) #NEWLINE# if ( ( len ( self . elements ) == 1 ) and self . elements [ 0 ] . vflex ) : #NEWLINE# #INDENT# self . elements [ 0 ] . update ( anchor = ( ( FULLWIDTH + ' ' ) + FULLHEIGHT ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# for e in self . elements : #NEWLINE# #INDENT# e . update ( anchor = FULLWIDTH ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( d [ 'layout' ] == 'hbox' ) : #NEWLINE# #INDENT# self . wrap_formlayout_elements ( ) #NEWLINE# for e in self . elements : #NEWLINE# #INDENT# if e . height : #NEWLINE# #INDENT# self . vflex = True #NEWLINE# #UNINDENT# if e . hflex : #NEWLINE# #INDENT# w = ( e . width or e . preferred_width ) #NEWLINE# e . value . update ( flex = int ( ( ( w * 100 ) / self . preferred_width ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not self . vflex ) : #NEWLINE# #INDENT# d . update ( autoHeight = True ) #NEWLINE# d . update ( layoutConfig = dict ( align = 'stretchmax' ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( d [ 'layout' ] == 'vbox' ) : #NEWLINE# #INDENT# assert ( len ( self . elements ) > 1 ) #NEWLINE# self . wrap_formlayout_elements ( ) #NEWLINE# vflex_count = 0 #NEWLINE# h = ( self . height or self . preferred_height ) #NEWLINE# for e in self . elements : #NEWLINE# #INDENT# eh = ( e . height or e . preferred_height ) #NEWLINE# if e . vflex : #NEWLINE# #INDENT# e . update ( flex = int ( ( ( eh * 100 ) / h ) ) ) #NEWLINE# vflex_count += 1 #NEWLINE# #UNINDENT# #UNINDENT# if ( ( vflex_count >= 2 ) and ( len ( self . elements ) <= 3 ) ) : #NEWLINE# #INDENT# self . remove ( 'layout' , 'layoutConfig' ) #NEWLINE# self . value_template = 'new Lino.VBorderPanel(%s)' #NEWLINE# for e in self . elements : #NEWLINE# #INDENT# if e . vflex : #NEWLINE# #INDENT# e . update ( flex = ( e . height or e . preferred_height ) ) #NEWLINE# #UNINDENT# e . update ( split = True ) #NEWLINE# #UNINDENT# self . elements [ 0 ] . update ( region = 'north' ) #NEWLINE# self . elements [ 1 ] . update ( region = 'center' ) #NEWLINE# if ( len ( self . elements ) == 3 ) : #NEWLINE# #INDENT# self . elements [ 2 ] . update ( region = 'south' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( d [ 'layout' ] == 'fit' ) : #NEWLINE# #INDENT# self . wrap_formlayout_elements ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( ( 'layout is %r' % d [ 'layout' ] ) )