#NEWLINE# def layout( self ) : #NEWLINE# #INDENT# assert ( ( self . parent . height is not None ) and ( self . parent . width is not None ) ) #NEWLINE# for child in self . getChildren ( ) : #NEWLINE# #INDENT# assert ( ( child . height is not None ) and ( child . width is not None ) ) , ( '%r missing dimensions' % child ) #NEWLINE# #UNINDENT# rect = self . parent . inner_rect #NEWLINE# x = 0 #NEWLINE# if ( self . halign == CENTER ) : #NEWLINE# #INDENT# x = ( ( rect . width // 2 ) - ( self . width // 2 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . halign == RIGHT ) : #NEWLINE# #INDENT# x = ( rect . width - self . width ) #NEWLINE# #UNINDENT# #UNINDENT# wrap = ( self . wrap and self . wrap . calculate ( ) ) #NEWLINE# fill_padding = self . padding #NEWLINE# for col in self . determineColumns ( ) : #NEWLINE# #INDENT# cw = max ( ( child . width for child in col ) ) #NEWLINE# if ( self . valign == FILL ) : #NEWLINE# #INDENT# h = rect . height #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# h = ( sum ( ( c . height for c in col ) ) + ( self . padding * ( len ( col ) - 1 ) ) ) #NEWLINE# #UNINDENT# if ( self . valign == BOTTOM ) : #NEWLINE# #INDENT# y = h #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . valign == TOP ) : #NEWLINE# #INDENT# y = rect . height #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . valign == CENTER ) : #NEWLINE# #INDENT# y = ( ( ( rect . height // 2 ) - ( h // 2 ) ) + h ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . valign == FILL ) : #NEWLINE# #INDENT# y = rect . height #NEWLINE# if ( len ( col ) == 1 ) : #NEWLINE# #INDENT# fill_padding = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# h = sum ( ( x . height for c in col ) ) #NEWLINE# fill_padding = ( ( rect . height - h ) / float ( ( len ( col ) - 1 ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# for child in col : #NEWLINE# #INDENT# y -= child . height #NEWLINE# child . y = int ( y ) #NEWLINE# y -= fill_padding #NEWLINE# if ( self . halign == LEFT ) : #NEWLINE# #INDENT# child . x = int ( x ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . halign == CENTER ) : #NEWLINE# #INDENT# child . x = int ( ( x + ( ( cw // 2 ) - ( child . width // 2 ) ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . halign == RIGHT ) : #NEWLINE# #INDENT# child . x = int ( ( x + ( cw - child . width ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if wrap : #NEWLINE# #INDENT# x += ( self . padding + cw )