def size(self, dialog): if dialog is None: return Control.size(self, dialog) if not self.set_document_style: self.do_set_document_style(dialog) if self.content is None: self.content = pyglet.text.layout.IncrementalTextLayout( self.document, self.content_width, self.max_height, multiline=True, batch=dialog.batch, group=dialog.fg_group) if self.is_fixed_size or ( self.max_height and self.content.content_height > self.max_height): self.height = self.max_height else: self.height = self.content.content_height self.content.height = self.height if self.always_show_scrollbar or \ (self.max_height and self.content.content_height > self.max_height): if self.scrollbar is None: self.scrollbar = VScrollbar(self.max_height) self.scrollbar.size(dialog) self.scrollbar.set(self.max_height, self.content.content_height) if self.scrollbar is not None: self.width = self.content_width + self.scrollbar.width else: self.width = self.content_width
def size(self, dialog): """ Recalculate the size of the Scrollable. @param dialog Dialog which contains us """ if dialog is None: return Widget.size(self, dialog) if self.is_fixed_size: self.width, self.height = self.max_width, self.max_height self.hscrollbar_height = \ dialog.theme['hscrollbar']['left']['image'].height self.vscrollbar_width = \ dialog.theme['vscrollbar']['up']['image'].width if self.root_group is None: # do we need to re-clone dialog groups? self.theme = dialog.theme self.batch = dialog.batch self.root_group = ScrollableGroup(0, 0, self.width, self.height, parent=dialog.fg_group) self.panel_group = pyglet.graphics.OrderedGroup(0, self.root_group) self.bg_group = pyglet.graphics.OrderedGroup(1, self.root_group) self.fg_group = pyglet.graphics.OrderedGroup(2, self.root_group) self.highlight_group = pyglet.graphics.OrderedGroup( 3, self.root_group) Wrapper.delete(self) # force children to abandon old groups Wrapper.size(self, self) # all children are to use our groups if self.always_show_scrollbars or \ (self.max_width and self.width > self.max_width): if self.hscrollbar is None: self.hscrollbar = HScrollbar(self.max_width) else: if self.hscrollbar is not None: self.hscrollbar.delete() self.hscrollbar = None if self.always_show_scrollbars or \ (self.max_height and self.height > self.max_height): if self.vscrollbar is None: self.vscrollbar = VScrollbar(self.max_height) else: if self.vscrollbar is not None: self.vscrollbar.delete() self.vscrollbar = None self.width = min(self.max_width or self.width, self.width) self.content_width = self.width self.height = min(self.max_height or self.height, self.height) self.content_height = self.height if self.hscrollbar is not None: self.hscrollbar.size(dialog) self.hscrollbar.set(self.max_width, max(self.content.width, self.max_width)) self.height += self.hscrollbar.height if self.vscrollbar is not None: self.vscrollbar.size(dialog) self.vscrollbar.set(self.max_height, max(self.content.height, self.max_height)) self.width += self.vscrollbar.width