home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / Widgets / WidgetsExtra.pyc (.txt) < prev   
Encoding:
Python Compiled Bytecode  |  2000-10-27  |  8.4 KB  |  176 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import BUIx
  5. import BVideo
  6. import Raster
  7. import BBLibc
  8. import math
  9. import sys
  10.  
  11. class B_VideoWidget(BUIx.B_RectWidget):
  12.     
  13.     def __init__(self, Parent, Name, video):
  14.         self.Vid = BVideo.B_Video()
  15.         self.Vid.SetVideo(video)
  16.         (self.vidw, self.vidh) = self.Vid.GetDimension()
  17.         BUIx.B_RectWidget.__init__(self, Parent, Name, self.vidw, self.vidh)
  18.         self.Selected = 0
  19.         self.Solid = 0
  20.         self.Border = 0
  21.         self.SetDrawFunc(self.Draw)
  22.  
  23.     
  24.     def __del__(self):
  25.         pass
  26.  
  27.     
  28.     def Draw(self, x, y, time):
  29.         Raster.SetPosition(x, y)
  30.         Raster.DrawImage(self.vidw, self.vidh, 'BGR', 'UpsideDown', self.Vid.GetData(time))
  31.         self.DefDraw(x, y, time)
  32.  
  33.  
  34.  
  35. class B_ImageWidget(BUIx.B_RectWidget):
  36.     
  37.     def __init__(self, Parent, Name, image):
  38.         self.Bitmap = BBLib.B_BitMap24()
  39.         self.Bitmap.ReadFromBMP(image)
  40.         (self.vidw, self.vidh) = self.Bitmap.GetDimension()
  41.         BUIx.B_RectWidget.__init__(self, Parent, Name, self.vidw, self.vidh)
  42.         self.Selected = 0
  43.         self.Solid = 0
  44.         self.Border = 0
  45.         self.SetDrawFunc(self.Draw)
  46.  
  47.     
  48.     def __del__(self):
  49.         pass
  50.  
  51.     
  52.     def Draw(self, x, y, time):
  53.         Raster.SetPosition(x, y)
  54.         Raster.DrawImage(self.vidw, self.vidh, 'RGB', 'Normal', self.Bitmap.GetData())
  55.         self.DefDraw(x, y, time)
  56.  
  57.  
  58.  
  59. class B_FlashBitmapWidget(BUIx.B_BitmapWidget):
  60.     
  61.     def __init__(self, Parent, Name, width, height, BitmapName, FileName):
  62.         BUIx.B_BitmapWidget.__init__(self, Parent, Name, width, height, BitmapName, FileName)
  63.         self.SetDrawFunc(self.Draw)
  64.         self.Flashing = 0
  65.         self.MinAlpha = 0.0
  66.         self.MaxAlpha = 1.0
  67.         self.Continuous = 0
  68.  
  69.     
  70.     def Draw(self, x, y, time):
  71.         if self.GetVisible() == 0:
  72.             return None
  73.         
  74.         if self.Flashing != 0:
  75.             alpha = self.GetAlpha()
  76.             alpha_range = self.MaxAlpha - self.MinAlpha
  77.             if self.Continuous:
  78.                 self.SetAlpha(0.5 + 0.5 * math.cos(time * self.Flashing) * alpha_range + self.MinAlpha)
  79.             else:
  80.                 self.SetAlpha(max(0.0, math.cos(time * self.Flashing)) * alpha_range + self.MinAlpha)
  81.             self.DefDraw(x, y, time)
  82.             self.SetAlpha(alpha)
  83.         else:
  84.             self.DefDraw(x, y, time)
  85.  
  86.     
  87.     def SetFlash(self, fl):
  88.         self.Flashing = fl
  89.  
  90.     
  91.     def GetFlash(self):
  92.         return self.Flashing
  93.  
  94.  
  95.  
  96. class B_FlashBarWidget(BUIx.B_BarWidget):
  97.     
  98.     def __init__(self, Parent, Name, width, height):
  99.         BUIx.B_BarWidget.__init__(self, Parent, Name, width, height)
  100.         self.SetDrawFunc(self.Draw)
  101.         self.Flashing = 0
  102.         self.NormalColor = (0, 0, 0)
  103.         self.DeltaColor = (0, 0, 0)
  104.         self.Continuous = 0
  105.  
  106.     
  107.     def Draw(self, x, y, time):
  108.         if self.GetVisible() == 0:
  109.             return None
  110.         
  111.         if self.Flashing != 0:
  112.             if self.Continuous:
  113.                 a = 0.5 + 0.5 * math.cos(time * self.Flashing)
  114.             else:
  115.                 a = max(0.0, math.cos(time * self.Flashing))
  116.             BUIx.B_BarWidget.SetColor(self, self.NormalColor[0] + self.DeltaColor[0] * a, self.NormalColor[1] + self.DeltaColor[1] * a, self.NormalColor[2] + self.DeltaColor[2] * a)
  117.             self.DefDraw(x, y, time)
  118.             BUIx.B_BarWidget.SetColor(self, self.NormalColor[0], self.NormalColor[1], self.NormalColor[2])
  119.         else:
  120.             self.DefDraw(x, y, time)
  121.  
  122.     
  123.     def SetFlash(self, fl):
  124.         self.Flashing = fl
  125.  
  126.     
  127.     def GetFlash(self):
  128.         return self.Flashing
  129.  
  130.     
  131.     def SetColor(self, r, g, b):
  132.         dc = (r - self.NormalColor[0], g - self.NormalColor[1], b - self.NormalColor[2])
  133.         self.DeltaColor = (min(self.DeltaColor[0] - dc[0], 255 - r), min(self.DeltaColor[1] - dc[1], 255 - g), min(self.DeltaColor[2] - dc[2], 255 - b))
  134.         self.NormalColor = (r, g, b)
  135.         BUIx.B_BarWidget.SetColor(self, r, g, b)
  136.  
  137.     
  138.     def SetFlashColor(self, r, g, b):
  139.         self.DeltaColor = (r - self.NormalColor[0], g - self.NormalColor[1], b - self.NormalColor[2])
  140.  
  141.     
  142.     def GetFlashColor(self):
  143.         return (self.NormalColor[0] + self.DeltaColor[0], self.NormalColor[1] + self.DeltaColor[1], self.NormalColor[2] + self.DeltaColor[2])
  144.  
  145.  
  146.  
  147. class B_FlashTextWidget(BUIx.B_TextWidget):
  148.     
  149.     def __init__(self, Parent, Name, Text, font_server, font):
  150.         BUIx.B_TextWidget.__init__(self, Parent, Name, Text, font_server, font)
  151.         self.SetDrawFunc(self.Draw)
  152.         self.Flashing = 0
  153.  
  154.     
  155.     def Draw(self, x, y, time):
  156.         if self.GetVisible() == 0:
  157.             return None
  158.         
  159.         if self.Flashing != 0:
  160.             alpha = self.GetAlpha()
  161.             self.SetAlpha(math.cos(time * self.Flashing))
  162.             self.DefDraw(x, y, time)
  163.             self.SetAlpha(alpha)
  164.         else:
  165.             self.DefDraw(x, y, time)
  166.  
  167.     
  168.     def SetFlash(self, fl):
  169.         self.Flashing = fl
  170.  
  171.     
  172.     def GetFlash(self):
  173.         return self.Flashing
  174.  
  175.  
  176.