Пример #1
0
    def update(self, s):
        updates = []

        if self.myfocus: self.toupdate[self.myfocus] = self.myfocus

        for w in self.topaint:
            if w is self.mywindow:
                continue
            else:
                sub = surface.subsurface(s, w.rect)
                #if (hasattr(w, "_container_bkgr")):
                #    sub.blit(w._container_bkgr,(0,0))
                w.paint(sub)
                updates.append(pygame.rect.Rect(w.rect))

        for w in self.toupdate:
            if w is self.mywindow:
                continue
            else:
                us = w.update(surface.subsurface(s, w.rect))
            if us:
                for u in us:
                    updates.append(
                        pygame.rect.Rect(u.x + w.rect.x, u.y + w.rect.y, u.w,
                                         u.h))

        for w in self.topaint:
            if w is self.mywindow:
                w.paint(self.top_surface(s, w))
                updates.append(pygame.rect.Rect(w.rect))
            else:
                continue

        for w in self.toupdate:
            if w is self.mywindow:
                us = w.update(self.top_surface(s, w))
            else:
                continue
            if us:
                for u in us:
                    updates.append(
                        pygame.rect.Rect(u.x + w.rect.x, u.y + w.rect.y, u.w,
                                         u.h))

        self.topaint = {}
        self.toupdate = {}

        return updates
Пример #2
0
    def paint(self, s):
        self.toupdate = {}
        self.topaint = {}

        for w in self.widgets:
            ok = False
            try:
                sub = surface.subsurface(s, w.rect)
                ok = True
            except:
                print 'container.paint(): %s not in %s' % (
                    w.__class__.__name__, self.__class__.__name__)
                print s.get_width(), s.get_height(), w.rect
                ok = False
            if ok:
                if not (hasattr(w, '_container_bkgr') and
                        w._container_bkgr.get_width() == sub.get_width() and
                        w._container_bkgr.get_height() == sub.get_height()):
                    w._container_bkgr = sub.copy()
                w._container_bkgr.fill((0, 0, 0, 0))
                w._container_bkgr.blit(sub, (0, 0))

                w.paint(sub)

        for w in self.windows:
            w.paint(self.top_surface(s, w))
Пример #3
0
        def func(s):
            if w.disabled:
                orig = s
                s = pygame.Surface((s.get_width(), s.get_height()), 0, s)
                s.blit(orig, (0, 0))

            if hasattr(w, 'background'):
                w.background.paint(surface.subsurface(s, w._rect_border))
            self.box(w, surface.subsurface(s, w._rect_border))
            r = m(surface.subsurface(s, w._rect_content))

            if w.disabled:
                s.set_alpha(128)
                orig.blit(s, (0, 0))

            return r
Пример #4
0
 def func(s):
     if w.disabled:
         orig = s
         s = pygame.Surface((s.get_width(),s.get_height()),0,s)
         s.blit(orig,(0,0))
     
     if hasattr(w,'background'):
         w.background.paint(surface.subsurface(s,w._rect_border))
     self.box(w,surface.subsurface(s,w._rect_border))
     r = m(surface.subsurface(s,w._rect_content))
     
     if w.disabled:
         s.set_alpha(128)
         orig.blit(s,(0,0))
         
     
     return r
Пример #5
0
 def func(s):
     if w.disabled: return []
     r = m(surface.subsurface(s, w._rect_content))
     if type(r) == list:
         dx, dy = w._rect_content.topleft
         for rr in r:
             rr.x, rr.y = rr.x + dx, rr.y + dy
     return r
Пример #6
0
 def paint(self, s):
     rect = self.value.rect
     if self.pcls == "down":
         # Shift the contents down to emphasize the button being pressed. This
         # is defined in the theme config file.
         rect = rect.move((self.style.down_offset_x, self.style.down_offset_y))
     self.value.pcls = self.pcls
     self.value.paint(surface.subsurface(s, rect))
Пример #7
0
 def func(s):
     if w.disabled: return []
     r = m(surface.subsurface(s,w._rect_content))
     if type(r) == list:
         dx,dy = w._rect_content.topleft
         for rr in r:
             rr.x,rr.y = rr.x+dx,rr.y+dy
     return r
Пример #8
0
	def paint(self,s):
		#self.pcls = ""
		#if self.container.myhover is self: self.pcls = "hover"
		#if self.value: img = self.style.on
		#else: img = self.style.off
		#s.blit(img,(0,0))
		self.value.pcls = self.pcls
		self.value.paint(surface.subsurface(s,self.value.rect))
Пример #9
0
 def paint(self, s):
     #self.pcls = ""
     #if self.container.myhover is self: self.pcls = "hover"
     #if self.value: img = self.style.on
     #else: img = self.style.off
     #s.blit(img,(0,0))
     self.value.pcls = self.pcls
     self.value.paint(surface.subsurface(s, self.value.rect))
Пример #10
0
    def update(self, s):
        updates = []

        if self.myfocus: self.toupdate[self.myfocus] = self.myfocus

        for w in self.topaint:
            if w is self.mywindow:
                continue
            else:
                w.paint(surface.subsurface(s, w.rect))
                updates.append(pygame.rect.Rect(w.rect))

        for w in self.toupdate:
            if w is self.mywindow:
                continue
            else:
                us = w.update(surface.subsurface(s, w.rect))
            if us:
                for u in us:
                    updates.append(
                        pygame.rect.Rect(u.x + w.rect.x, u.y + w.rect.y, u.w,
                                         u.h))

        for w in self.topaint:
            if w is self.mywindow:
                w.paint(self.top_surface(s, w))
                updates.append(pygame.rect.Rect(w.rect))
            else:
                continue

        for w in self.toupdate:
            if w is self.mywindow:
                us = w.update(self.top_surface(s, w))
            else:
                continue
            if us:
                for u in us:
                    updates.append(
                        pygame.rect.Rect(u.x + w.rect.x, u.y + w.rect.y, u.w,
                                         u.h))

        self.topaint = {}
        self.toupdate = {}

        return updates
Пример #11
0
 def update(self,s):
     updates = []
     
     if self.myfocus: self.toupdate[self.myfocus] = self.myfocus
     
     for w in self.topaint:
         if w is self.mywindow:
             continue
         else:
             sub = surface.subsurface(s,w.rect)
             #if (hasattr(w, "_container_bkgr")):
             #    sub.blit(w._container_bkgr,(0,0))
             w.paint(sub)
             updates.append(pygame.rect.Rect(w.rect))
     
     for w in self.toupdate:
         if w is self.mywindow:
             continue
         else:            
             us = w.update(surface.subsurface(s,w.rect))
         if us:
             for u in us:
                 updates.append(pygame.rect.Rect(u.x + w.rect.x,u.y+w.rect.y,u.w,u.h))
     
     for w in self.topaint:
         if w is self.mywindow:
             w.paint(self.top_surface(s,w))
             updates.append(pygame.rect.Rect(w.rect))
         else:
             continue 
     
     for w in self.toupdate:
         if w is self.mywindow:
             us = w.update(self.top_surface(s,w))
         else:            
             continue 
         if us:
             for u in us:
                 updates.append(pygame.rect.Rect(u.x + w.rect.x,u.y+w.rect.y,u.w,u.h))
     
     self.topaint = {}
     self.toupdate = {}
     
     return updates
Пример #12
0
	def update(self,s):
		updates = []
		
		if self.myfocus and self.myfocus(): 
			self.toupdate[self.myfocus] = self.myfocus

		for w in self.topaint:
			if self.mywindow and w and w() is self.mywindow():
				continue
			else:
				sub = surface.subsurface(s,w().rect)
				sub.blit(w()._container_bkgr,(0,0))
				w().paint(sub)
				updates.append(pygame.rect.Rect(w().rect))
		
		for w in self.toupdate:
			if self.mywindow and w and w() is self.mywindow():
				continue
			else:			
				us = w().update(surface.subsurface(s,w().rect))
			if us:
				for u in us:
					updates.append(pygame.rect.Rect(u.x + w().rect.x,u.y+w().rect.y,u.w,u.h))
		
		for w in self.topaint:
			if self.mywindow and w and w() is self.mywindow():
				w().paint(self.top_surface(s,w()))
				updates.append(pygame.rect.Rect(w().rect))
			else:
				continue 
		
		for w in self.toupdate:
			if self.mywindow and w and w() is self.mywindow():
				us = w().update(self.top_surface(s,w()))
			else:			
				continue 
			if us:
				for u in us:
					updates.append(pygame.rect.Rect(u.x + w().rect.x,u.y+w().rect.y,u.w,u.h))
		
		self.topaint = {}
		self.toupdate = {}
		
		return updates
Пример #13
0
        def func(s):
            #             if w.disabled:
            #                 if not hasattr(w,'_disabled_bkgr'):
            #                     w._disabled_bkgr = s.convert()
            #                 orig = s
            #                 s = w._disabled_bkgr.convert()

            #             if not hasattr(w,'_theme_paint_bkgr'):
            #                 w._theme_paint_bkgr = s.convert()
            #             else:
            #                 s.blit(w._theme_paint_bkgr,(0,0))
            #
            #             if w.disabled:
            #                 orig = s
            #                 s = w._theme_paint_bkgr.convert()

            if w.disabled:
                if (not (hasattr(w, '_theme_bkgr')
                         and w._theme_bkgr.get_width() == s.get_width()
                         and w._theme_bkgr.get_height() == s.get_height())):
                    w._theme_bkgr = s.copy()
                orig = s
                s = w._theme_bkgr
                s.fill((0, 0, 0, 0))
                s.blit(orig, (0, 0))

            if w.background:
                w.background.paint(surface.subsurface(s, w._rect_border))

            self.box(w, surface.subsurface(s, w._rect_border))
            r = m(surface.subsurface(s, w._rect_content))

            if w.disabled:
                s.set_alpha(128)
                orig.blit(s, (0, 0))


#             if w.disabled:
#                 orig.blit(w._disabled_bkgr,(0,0))
#                 s.set_alpha(128)
#                 orig.blit(s,(0,0))

            w._painted = True
            return r
Пример #14
0
        def func(s):
#             if w.disabled:
#                 if not hasattr(w,'_disabled_bkgr'):
#                     w._disabled_bkgr = s.convert()
#                 orig = s
#                 s = w._disabled_bkgr.convert()

#             if not hasattr(w,'_theme_paint_bkgr'):
#                 w._theme_paint_bkgr = s.convert()
#             else:
#                 s.blit(w._theme_paint_bkgr,(0,0))
#             
#             if w.disabled:
#                 orig = s
#                 s = w._theme_paint_bkgr.convert()

            if w.disabled:
                if (not (hasattr(w,'_theme_bkgr') and 
                         w._theme_bkgr.get_width() == s.get_width() and 
                         w._theme_bkgr.get_height() == s.get_height())):
                    w._theme_bkgr = s.copy()
                orig = s
                s = w._theme_bkgr
                s.fill((0,0,0,0))
                s.blit(orig,(0,0))
                
            if w.background:
                w.background.paint(surface.subsurface(s,w._rect_border))

            self.box(w,surface.subsurface(s,w._rect_border))
            r = m(surface.subsurface(s,w._rect_content))
            
            if w.disabled:
                s.set_alpha(128)
                orig.blit(s,(0,0))
            
#             if w.disabled:
#                 orig.blit(w._disabled_bkgr,(0,0))
#                 s.set_alpha(128)
#                 orig.blit(s,(0,0))
            
            w._painted = True
            return r
Пример #15
0
 def update(self,s):
     updates = []
     
     if self.myfocus: self.toupdate[self.myfocus] = self.myfocus
     
     for w in self.topaint:
         if w is self.mywindow:
             continue
         else:
             w.paint(surface.subsurface(s,w.rect))
             updates.append(pygame.rect.Rect(w.rect))
     
     for w in self.toupdate:
         if w is self.mywindow:
             continue
         else:            
             us = w.update(surface.subsurface(s,w.rect))
         if us:
             for u in us:
                 updates.append(pygame.rect.Rect(u.x + w.rect.x,u.y+w.rect.y,u.w,u.h))
     
     for w in self.topaint:
         if w is self.mywindow:
             w.paint(self.top_surface(s,w))
             updates.append(pygame.rect.Rect(w.rect))
         else:
             continue 
     
     for w in self.toupdate:
         if w is self.mywindow:
             us = w.update(self.top_surface(s,w))
         else:            
             continue 
         if us:
             for u in us:
                 updates.append(pygame.rect.Rect(u.x + w.rect.x,u.y+w.rect.y,u.w,u.h))
     
     self.topaint = {}
     self.toupdate = {}
     
     return updates
Пример #16
0
        def func(s):
#             if w.disabled:
#                 if not hasattr(w,'_disabled_bkgr'):
#                     w._disabled_bkgr = s.convert()
#                 orig = s
#                 s = w._disabled_bkgr.convert()

#             if not hasattr(w,'_theme_paint_bkgr'):
#                 w._theme_paint_bkgr = s.convert()
#             else:
#                 s.blit(w._theme_paint_bkgr,(0,0))
#             
#             if w.disabled:
#                 orig = s
#                 s = w._theme_paint_bkgr.convert()

            if w.disabled:
                orig = s
                s = orig.copy()
                
            if hasattr(w,'background'):
                w.background.paint(surface.subsurface(s,w._rect_border))
            self.box(w,surface.subsurface(s,w._rect_border))
            r = m(surface.subsurface(s,w._rect_content))
            
            if w.disabled:
                s.set_alpha(128)
                orig.blit(s,(0,0))
            
#             if w.disabled:
#                 orig.blit(w._disabled_bkgr,(0,0))
#                 s.set_alpha(128)
#                 orig.blit(s,(0,0))
            
            w._painted = True
            return r
Пример #17
0
    def paint(self,s):
        self.toupdate = {}
        self.topaint = {}
        for w in self.widgets:
            try:
                sub = surface.subsurface(s, w.rect)
            except: 
                print('container.paint(): %s not inside %s' % (
                    w.__class__.__name__,self.__class__.__name__))
                print(s.get_width(), s.get_height(), w.rect)
                print("")
            else:
                w.paint(sub)

        for w in self.windows:
            w.paint(self.top_surface(s,w))
Пример #18
0
 def paint(self,s):
     self.toupdate = {}
     self.topaint = {}
     
     for w in self.widgets:
         ok = False
         try:
             sub = surface.subsurface(s,w.rect)
             ok = True
         except: 
             print 'container.paint(): %s not in %s'%(w.__class__.__name__,self.__class__.__name__)
             print s.get_width(),s.get_height(),w.rect
             ok = False
         if ok: w.paint(sub)
     
     for w in self.windows:
         w.paint(self.top_surface(s,w))
Пример #19
0
    def paint(self, s):
        self.toupdate = {}
        self.topaint = {}

        for w in self.widgets:
            ok = False
            try:
                sub = surface.subsurface(s, w.rect)
                ok = True
            except:
                print 'container.paint(): %s not in %s' % (
                    w.__class__.__name__, self.__class__.__name__)
                print s.get_width(), s.get_height(), w.rect
                ok = False
            if ok: w.paint(sub)

        for w in self.windows:
            w.paint(self.top_surface(s, w))
Пример #20
0
    def paint(self,s):
        self.toupdate = {}
        self.topaint = {}
        for w in self.widgets:
            try:
                sub = surface.subsurface(s, w.rect)
            except: 
                print 'container.paint(): %s not inside %s' % (
                    w.__class__.__name__,self.__class__.__name__)
                print s.get_width(), s.get_height(), w.rect
                print ""
            else:
#                if (not hasattr(w,'_container_bkgr') or 
#                    w._container_bkgr.get_size() != sub.get_size()):
#                         #w._container_bkgr.get_width() == sub.get_width() and 
#                         #w._container_bkgr.get_height() == sub.get_height())):
#                    w._container_bkgr = sub.copy()
#                w._container_bkgr.fill((0,0,0,0))
#                w._container_bkgr.blit(sub,(0,0))
                w.paint(sub)

        for w in self.windows:
            w.paint(self.top_surface(s,w))
Пример #21
0
    def paint(self, s):
        self.toupdate = {}
        self.topaint = {}
        for w in self.widgets:
            try:
                sub = surface.subsurface(s, w.rect)
            except:
                print 'container.paint(): %s not inside %s' % (
                    w.__class__.__name__, self.__class__.__name__)
                print s.get_width(), s.get_height(), w.rect
                print ""
            else:
                #                if (not hasattr(w,'_container_bkgr') or
                #                    w._container_bkgr.get_size() != sub.get_size()):
                #                         #w._container_bkgr.get_width() == sub.get_width() and
                #                         #w._container_bkgr.get_height() == sub.get_height())):
                #                    w._container_bkgr = sub.copy()
                #                w._container_bkgr.fill((0,0,0,0))
                #                w._container_bkgr.blit(sub,(0,0))
                w.paint(sub)

        for w in self.windows:
            w.paint(self.top_surface(s, w))
Пример #22
0
 def paint(self,s):
     self.toupdate = {}
     self.topaint = {}
     
     for w in self.widgets:
         ok = False
         try:
             sub = surface.subsurface(s,w.rect)
             ok = True
         except: 
             print 'container.paint(): %s not in %s'%(w.__class__.__name__,self.__class__.__name__)
             print s.get_width(),s.get_height(),w.rect
             ok = False
         if ok: 
             if not (hasattr(w,'_container_bkgr') and w._container_bkgr.get_width() == sub.get_width() and w._container_bkgr.get_height() == sub.get_height()):
                 w._container_bkgr = sub.copy()
             w._container_bkgr.fill((0,0,0,0))
             w._container_bkgr.blit(sub,(0,0))
             
             w.paint(sub)
     
     for w in self.windows:
         w.paint(self.top_surface(s,w))
Пример #23
0
 def paint(self,s):
     if self.group.value == self.value: self.pcls = "down"
     self.widget.paint(surface.subsurface(s,self.widget.rect))
Пример #24
0
 def top_surface(self,s,w):
     x,y = s.get_abs_offset()
     s = s.get_abs_parent()
     return surface.subsurface(s,(x+w.rect.x,y+w.rect.y,w.rect.w,w.rect.h))
Пример #25
0
 def paint(self,s):
     self.value.paint(surface.subsurface(s,self.value.rect))
Пример #26
0
 def paint(self, s):
     if self.group() and self.group().value == self.value:
         self.pcls = "down"
     self.widget.paint(surface.subsurface(s, self.widget.rect))
Пример #27
0
 def paint(self, s):
     self.value.pcls = self.pcls
     self.value.paint(surface.subsurface(s, self.value.rect))
Пример #28
0
    def paint(self,s):
#        s.blit(self.font.render(self.value.value, 1, (0,0,0)),(0,0))
        self.value.pcls = self.pcls
        self.value.paint(surface.subsurface(s,self.value.rect))
Пример #29
0
 def top_surface(self, s, w):
     x, y = s.get_abs_offset()
     s = s.get_abs_parent()
     return surface.subsurface(
         s, (x + w.rect.x, y + w.rect.y, w.rect.w, w.rect.h))
Пример #30
0
    def update(self,s):
        updates = []
        
        if self.myfocus: self.toupdate[self.myfocus] = self.myfocus
        
        # Paint all child widgets, skipping over the currently open window (if any)
        for w in self.topaint:
            if w is self.mywindow:
                continue
            sub = surface.subsurface(s,w.rect)
            #if (hasattr(w, "_container_bkgr")):
            #    sub.blit(w._container_bkgr,(0,0))

            # Check for the theme alpha hack. This is needed (for now) to accomodate rendering
            # images with alpha blending (eg alpha value between fully opaque and fully transparent). 
            # Normally in PGU when a widget changes state (eg normal to highlighted state) the new 
            # widget appearance is rendered directly overtop of the old image. This usually works okay.
            #
            # However, if the images have a different shape, then the new image may fail to 
            # completely paint over the old image, leaving bits behind. As well, if the images use
            # alpha blending you have a similar situation where the old image isn't completely
            # covered by the new image (since alpha blending preserves some of the pixel data). The
            # work-around is to paint the background behind the image, then paint the new image.
            # And that's what this hack does.
            try:
                # This hack isn't perfect and so it's not enabled by default, but only by
                # themes that explicitly request it.
                alpha = pguglobals.app.theme.getstyle("pgu", "", "themealpha")
            except StyleError,e:
                alpha = False

            if (alpha):
                # Look for the first parent container that has a rendered background
                cnt = self
                (x, y) = w._rect_content.topleft
                while (cnt and not cnt.background):
                    cnt = cnt.container

#                if (cnt and cnt.background):
#                    if (cnt._rect_content):
#                        x += cnt._rect_content.left
#                        y += cnt._rect_content.top
#                    r1 = cnt.get_abs_rect()
#                    r2 = w.get_abs_rect()
#                    x = r2.left - r1.left
#                    y = r2.top - r1.top
#                    subrect = (x, y, sub.get_width(), sub.get_height())
#                    tmp = pygame.Surface(r1.size).convert_alpha()
#                    tmp.set_clip(subrect)
#                    cnt.background.paint(tmp)
#                    tmp.set_clip()
#                    sub.blit(tmp, (0,0), subrect)
                if (cnt):
                    # Paint the background. This works reasonably okay but it's not exactly correct.
                    r1 = cnt.get_abs_rect()
                    r2 = w.get_abs_rect()
                    x = r2.left - r1.left
                    y = r2.top - r1.top
                    cnt.background.paint(sub) #, size=r1.size, offset=(x, y))

            w.paint(sub)
            updates.append(pygame.rect.Rect(w.rect))