コード例 #1
0
ファイル: container.py プロジェクト: alfem/bgtimer
    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
ファイル: theme.py プロジェクト: illume/zanthor
        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
ファイル: theme.py プロジェクト: rjzaar/Speckpater
 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
ファイル: theme.py プロジェクト: illume/zanthor
 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
ファイル: button.py プロジェクト: bendmorris/jython-pgu
 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
ファイル: theme.py プロジェクト: JonahBrooks/Portfolio
 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
ファイル: button.py プロジェクト: acbart/broadway.activity
	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
ファイル: container.py プロジェクト: illume/zanthor
    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
ファイル: container.py プロジェクト: JonahBrooks/Portfolio
 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
ファイル: theme.py プロジェクト: JonahBrooks/Portfolio
        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
ファイル: container.py プロジェクト: philhassey/zanthor
 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
ファイル: theme.py プロジェクト: Lukc/ospace-lukc
        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
ファイル: container.py プロジェクト: bendmorris/jython-pgu
    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
ファイル: container.py プロジェクト: philhassey/zanthor
 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
ファイル: container.py プロジェクト: illume/zanthor
    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
ファイル: container.py プロジェクト: JonahBrooks/Portfolio
    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
ファイル: container.py プロジェクト: alfem/bgtimer
    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
ファイル: area.py プロジェクト: Stever1975/Scriptorium
 def paint(self,s):
     if self.group.value == self.value: self.pcls = "down"
     self.widget.paint(surface.subsurface(s,self.widget.rect))
コード例 #24
0
ファイル: container.py プロジェクト: Lukc/ospace-lukc
 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
ファイル: button.py プロジェクト: philhassey/zanthor
 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
ファイル: button.py プロジェクト: nchokas/PysProblem
    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
ファイル: container.py プロジェクト: alfem/bgtimer
 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
ファイル: container.py プロジェクト: bendmorris/jython-pgu
    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))