1bd96df20b700866e5f8c3304fbd41341b216904
8 class _document_widget
:
9 def __init__(self
,w
,align
=None):
10 #w.rect.w,w.rect.h = w.resize()
13 if align
!= None: self
.align
= align
15 class Document(container
.Container
):
16 """A document container contains many widgets strung together in a document format. (How informative!)
21 def __init__(self
,**params
):
22 params
.setdefault('cls','document')
23 container
.Container
.__init
__(self
,**params
)
24 self
.layout
= layout
.Layout(pygame
.Rect(0,0,self
.rect
.w
,self
.rect
.h
))
26 def add(self
,e
,align
=None):
29 <pre>Document.add(e,align=None)</pre>
33 <dt>align<dd>alignment (None,-1,0,1)
36 dw
= _document_widget(e
,align
)
40 self
.widgets
.append(e
)
44 self
.layout
._widgets
.remove(e
._c
_dw
)
45 self
.widgets
.remove(e
)
49 def block(self
,align
):
52 <pre>Document.block(align)</pre>
55 <dt>align<dd>alignment of block (-1,0,1)
58 self
.layout
.add(align
)
63 <pre>Document.space(e)</pre>
66 <dt>e<dd>a (w,h) size for the spacer
74 <pre>Document.br(height)</pre>
77 <dt>height<dd>height of line break
80 self
.layout
.add((0,height
))
82 def resize(self
,width
=None,height
=None):
83 if self
.style
.width
: width
= self
.style
.width
84 if self
.style
.height
: height
= self
.style
.height
86 for w
in self
.widgets
:
87 w
.rect
.w
,w
.rect
.h
= w
.resize()
89 if (width
!= None and w
.rect
.w
> width
) or (height
!= None and w
.rect
.h
> height
):
90 w
.rect
.w
,w
.rect
.h
= w
.resize(width
,height
)
93 dw
.rect
= pygame
.Rect(0,0,w
.rect
.w
,w
.rect
.h
)
95 if width
== None: width
= 65535
96 self
.layout
.rect
= pygame
.Rect(0,0,width
,0)
101 for w
in self
.widgets
:
102 #xt,xl,xb,xr = w.getspacing()
104 w
.style
.x
,w
.style
.y
,w
.rect
.w
,w
.rect
.h
= dw
.rect
.x
,dw
.rect
.y
,dw
.rect
.w
,dw
.rect
.h
106 w
.rect
.x
,w
.rect
.y
= w
.style
.x
,w
.style
.y
107 _max_w
= max(_max_w
,w
.rect
.right
)
109 #self.rect.w = _max_w #self.layout.rect.w
110 #self.rect.h = self.layout.rect.h
111 #print 'document',_max_w,self.layout.rect.h
112 return _max_w
,self
.layout
.rect
.h