home *** CD-ROM | disk | FTP | other *** search
/ com!online 2005 April / com_0405_1.iso / opensource / BTpp-0.5.4-bin.exe / $INSTDIR / BT++.exe / TabTrans / Renderer.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2003-04-19  |  5.7 KB  |  118 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.2)
  3.  
  4. from wxPython.wx import *
  5.  
  6. class Default:
  7.     
  8.     def __init__(self):
  9.         self.BgOutline = wxPen(wxColour(10, 36, 106))
  10.         self.BgColor = wxBrush(wxColour(194, 200, 218), wxSOLID)
  11.         self.BgEmpty = wxBrush(wxColour(255, 255, 255), wxSOLID)
  12.         self.FgColor = wxColour(0, 0, 0)
  13.         self.FgFont = wxFont(8, wxDEFAULT, wxNORMAL, wxNORMAL, False, '', wxFONTENCODING_SYSTEM)
  14.  
  15.     
  16.     def Update(self, grid, attr, dc, rect, row, col, isSelected):
  17.         self.Grid = grid
  18.         self.Attr = attr
  19.         self.DC = dc
  20.         self.Rect = rect
  21.         self.Row = row
  22.         self.Col = col
  23.         self.IsSelected = isSelected
  24.         self.Value = grid.GetCellValue(row, col)
  25.         self.ValueStr = str(self.Value)
  26.  
  27.     
  28.     def Draw(self, grid, attr, dc, rect, row, col, isSelected):
  29.         self.Update(grid, attr, dc, rect, row, col, isSelected)
  30.         self.DrawBackground()
  31.         self.DrawForeground()
  32.  
  33.     
  34.     def DrawBackground(self):
  35.         pass
  36.  
  37.     
  38.     def DrawForeground(self):
  39.         
  40.         try:
  41.             self.Rect.width = self.Rect.width - 8
  42.             self.Clip()
  43.             self.DC.SetTextForeground(self.FgColor)
  44.             self.DC.SetFont(self.FgFont)
  45.             self.DC.DrawText(self.ValueStr, self.Rect.x + 6, self.Rect.y + 4)
  46.         finally:
  47.             self.Unclip()
  48.  
  49.  
  50.     
  51.     def Clip(self):
  52.         self.DC.SetClippingRegion(self.Rect.x, self.Rect.y, self.Rect.width, self.Rect.height)
  53.  
  54.     
  55.     def Unclip(self):
  56.         self.DC.DestroyClippingRegion()
  57.  
  58.  
  59.  
  60. class ProgressBar(Default):
  61.     
  62.     def __init__(self):
  63.         Default.__init__(self)
  64.         self.BarHashDone = wxColour(224, 0, 0)
  65.         self.BarHashRemain = wxColour(0, 210, 255)
  66.         self.BarLoadDone = wxColour(0, 244, 0)
  67.         self.BarLoadRemain = wxColour(224, 0, 0)
  68.  
  69.     
  70.     def DrawForeground(self):
  71.         if self.ValueStr == '':
  72.             return None
  73.         
  74.         done = float(self.ValueStr)
  75.         remain = 1 - done
  76.         done_width = self.Rect.width * done
  77.         remain_start = self.Rect.x + done_width
  78.         remain_width = self.Rect.width - done_width
  79.         if done != -1.0:
  80.             status = self.Grid.GetCellValue(self.Row, 5)
  81.             if status == 'Hashing' or status == 'Allocating':
  82.                 color_done = self.BarHashDone
  83.                 color_remain = self.BarHashRemain
  84.             else:
  85.                 color_done = self.BarLoadDone
  86.                 color_remain = self.BarLoadRemain
  87.             self.DrawBCBGradient(wxRect(remain_start, self.Rect.y + 3, remain_width, self.Rect.height - 6), color_remain, 7)
  88.             self.DrawBCBGradient(wxRect(self.Rect.x, self.Rect.y + 3, done_width, self.Rect.height - 6), color_done, 7)
  89.         else:
  90.             self.DrawBCBGradient(wxRect(self.Rect.x, self.Rect.y + 3, self.Rect.width, self.Rect.height - 6), wxColour(0, 210, 255), 7)
  91.  
  92.     
  93.     def DrawBCBGradient(self, rect, color, gradheight):
  94.         if rect.height < 2 * gradheight:
  95.             return None
  96.         
  97.         self.DrawGradient(wxRect(rect.x, rect.y, rect.width, gradheight), wxColour(0, 0, 0), color)
  98.         self.DC.SetPen(wxTRANSPARENT_PEN)
  99.         self.DC.SetBrush(wxBrush(color, wxSOLID))
  100.         self.DC.DrawRectangle(rect.x, rect.y + gradheight, rect.width, rect.height - 2 * gradheight)
  101.         self.DrawGradient(wxRect(rect.x, rect.y + rect.height - gradheight, rect.width, gradheight), color, wxColour(0, 0, 0))
  102.  
  103.     
  104.     def DrawGradient(self, rect, color_start, color_end):
  105.         steps = rect.height
  106.         r_dif = color_end.Red() - color_start.Red()
  107.         g_dif = color_end.Green() - color_start.Green()
  108.         b_dif = color_end.Blue() - color_start.Blue()
  109.         length = rect.x + rect.width
  110.         for y in range(steps):
  111.             mod = float(y) / float(steps - 1)
  112.             color = wxColour(color_start.Red() + mod * r_dif, color_start.Green() + mod * g_dif, color_start.Blue() + mod * b_dif)
  113.             self.DC.SetPen(wxPen(color))
  114.             self.DC.DrawLine(rect.x, rect.y + y, length, rect.y + y)
  115.         
  116.  
  117.  
  118.