예제 #1
0
 def draw_all(self, surface):
     if self.visible:
         surf_rect = surface.get_rect()
         bg_image = self.bg_image
         if bg_image:
             assert isinstance(bg_image, Surface)
             if self.scale_bg:
                 bg_width, bg_height = bg_image.get_size()
                 width, height = self.size
                 if width > bg_width or height > bg_height:
                     hscale = width / bg_width
                     vscale = height / bg_height
                     bg_image = rotozoom(bg_image, 0.0, max(hscale, vscale))
             r = bg_image.get_rect()
             r.center = surf_rect.center
             surface.blit(bg_image, r)
         else:
             bg = self.bg_color
             if bg:
                 surface.fill(bg)
         self.draw(surface)
         bw = self.border_width
         if bw:
             bc = self.border_color or self.fg_color
             frame_rect(surface, bc, surf_rect, bw)
         for widget in self.subwidgets:
             sub_rect = widget.rect
             if debug_rect:
                 print "Widget: Drawing subwidget %s of %s with rect %s" % (
                     widget, self, sub_rect)
             sub_rect = surf_rect.clip(sub_rect)
             if sub_rect.width > 0 and sub_rect.height > 0:
                 try:
                     sub = surface.subsurface(sub_rect)
                 except ValueError, e:
                     if str(
                             e
                     ) == "subsurface rectangle outside surface area":
                         self.diagnose_subsurface_problem(surface, widget)
                     else:
                         raise
                 else:
                     widget.draw_all(sub)
         self.draw_over(surface)
예제 #2
0
파일: widget.py 프로젝트: 18986064/mcedit
 def draw_all(self, surface):
     if self.visible:
         surf_rect = surface.get_rect()
         bg_image = self.bg_image
         if bg_image:
             assert isinstance(bg_image, Surface)
             if self.scale_bg:
                 bg_width, bg_height = bg_image.get_size()
                 width, height = self.size
                 if width > bg_width or height > bg_height:
                     hscale = width / bg_width
                     vscale = height / bg_height
                     bg_image = rotozoom(bg_image, 0.0, max(hscale, vscale))
             r = bg_image.get_rect()
             r.center = surf_rect.center
             surface.blit(bg_image, r)
         else:
             bg = self.bg_color
             if bg:
                 surface.fill(bg)
         self.draw(surface)
         bw = self.border_width
         if bw:
             bc = self.border_color or self.fg_color
             frame_rect(surface, bc, surf_rect, bw)
         for widget in self.subwidgets:
             sub_rect = widget.rect
             if debug_rect:
                 print "Widget: Drawing subwidget %s of %s with rect %s" % (
                     widget, self, sub_rect)
             sub_rect = surf_rect.clip(sub_rect)
             if sub_rect.width > 0 and sub_rect.height > 0:
                 try:
                     sub = surface.subsurface(sub_rect)
                 except ValueError, e:
                     if str(e) == "subsurface rectangle outside surface area":
                         self.diagnose_subsurface_problem(surface, widget)
                     else:
                         raise
                 else:
                     widget.draw_all(sub)
         self.draw_over(surface)
예제 #3
0
	def draw_all(self, surface):
		if self.visible:
			bg = self.bg_color
			if bg:
				surface.fill(bg)
			self.draw(surface)
			bw = self.border_width
			if bw:
				bc = self.border_color or self.fg_color
				r = surface.get_rect()
				#r.inflate_ip(1 - bw, 1 - bw)
				#draw.rect(surface, bc, r, bw)
				frame_rect(surface, bc, r, bw)
			for widget in self.subwidgets:
				if debug_rect:
					print "Widget: Drawing subwidget %s of %s with rect %s" % (
						widget, self, widget.rect)
				try:
					sub = surface.subsurface(widget.rect)
				except ValueError:
					raise ValueError("Widget %s %s outside parent %s %s" % (
						widget, widget.rect, self, self.rect))
				widget.draw_all(sub)
			self.draw_over(surface)
예제 #4
0
	def draw_prehighlight(self, surface, i, rect):
		if self.highlight_style == 'frame':
			frame_rect(surface, self.sel_color, rect, self.sel_width)
		else:
			surface.fill(self.sel_color, rect)
예제 #5
0
 def draw_prehighlight_with(self, surface, i, rect, color):
     style = self.highlight_style
     if style == 'frame':
         frame_rect(surface, color, rect, self.sel_width)
     elif style == 'fill' or style == 'reverse':
         surface.fill(color, rect)
예제 #6
0
 def draw_prehighlight_with(self, surface, i, rect, color):
     style = self.highlight_style
     if style == 'frame':
         frame_rect(surface, color, rect, self.sel_width)
     elif style == 'fill' or style == 'reverse':
         surface.fill(color, rect)