parameters: (self, item, dc, level, y, x_maincol)
return_statement: return y, x_maincol
docstring: Paint a level in the hierarchy of :class:`TreeListMainWindow`.
  
          :param `item`: an instance of :class:`TreeListItem`;
          :param `dc`: an instance of :class:`DC`;
          :param `level`: the item level in the tree hierarchy;
          :param `y`: the current vertical position in the :class:`PyScrolledWindow`;
          :param `x_maincol`: the horizontal position of the main column.
docstring_summary: Paint a level in the hierarchy of :class:`TreeListMainWindow`.
docstring_tokens: Paint a level in the hierarchy of : class : TreeListMainWindow .
function: def PaintLevel(self, item, dc, level, y, x_maincol):
          """
          Paint a level in the hierarchy of :class:`TreeListMainWindow`.
  
          :param `item`: an instance of :class:`TreeListItem`;
          :param `dc`: an instance of :class:`DC`;
          :param `level`: the item level in the tree hierarchy;
          :param `y`: the current vertical position in the :class:`PyScrolledWindow`;
          :param `x_maincol`: the horizontal position of the main column.
          """
  
          if item.IsHidden():
              return y, x_maincol
          
          # Handle hide root (only level 0)
          if self.HasAGWFlag(wx.TR_HIDE_ROOT) and level == 0:
              for child in item.GetChildren():
                  y, x_maincol = self.PaintLevel(child, dc, 1, y, x_maincol)
              
              # end after expanding root
              return y, x_maincol
          
          # calculate position of vertical lines
          x = x_maincol + _MARGIN # start of column
  
          if self.HasAGWFlag(wx.TR_LINES_AT_ROOT):
              x += _LINEATROOT # space for lines at root
              
          if self.HasButtons():
              x += (self._btnWidth-self._btnWidth2) # half button space
          else:
              x += (self._indent-self._indent/2)
          
          if self.HasAGWFlag(wx.TR_HIDE_ROOT):
              x += self._indent*(level-1) # indent but not level 1
          else:
              x += self._indent*level # indent according to level
          
          # set position of vertical line
          item.SetX(x)
          item.SetY(y)
  
          h = self.GetLineHeight(item)
          y_top = y
          y_mid = y_top + (h/2)
          y += h
  
          exposed_x = dc.LogicalToDeviceX(0)
          exposed_y = dc.LogicalToDeviceY(y_top)
  
          # horizontal lines between rows?
          draw_row_lines = self.HasAGWFlag(wx.TR_ROW_LINES)
  
          if self.IsExposed(exposed_x, exposed_y, _MAX_WIDTH, h + draw_row_lines):
              if draw_row_lines:
                  total_width = self._owner.GetHeaderWindow().GetWidth()
                  # if the background colour is white, choose a
                  # contrasting colour for the lines
                  pen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DLIGHT), 1, wx.SOLID)
                  dc.SetPen((self.GetBackgroundColour() == wx.WHITE and [pen] or [wx.WHITE_PEN])[0])
                  dc.DrawLine(0, y_top, total_width, y_top)
                  dc.DrawLine(0, y_top+h, total_width, y_top+h)
              
              # draw item
              self.PaintItem(item, dc)
  
              # restore DC objects
              dc.SetBrush(wx.WHITE_BRUSH)
              dc.SetPen(self._dottedPen)
  
              # clip to the column width
              clip_width = self._owner.GetHeaderWindow().GetColumn(self._main_column).GetWidth()
  ##            clipper = wx.DCClipper(dc, x_maincol, y_top, clip_width, 10000)
  
              if not self.HasAGWFlag(wx.TR_NO_LINES):  # connection lines
  
                  # draw the horizontal line here
                  dc.SetPen(self._dottedPen)
                  x2 = x - self._indent
                  if x2 < (x_maincol + _MARGIN):
                      x2 = x_maincol + _MARGIN
                  x3 = x + (self._btnWidth-self._btnWidth2)
                  if self.HasButtons():
                      if item.HasPlus():
                          dc.DrawLine(x2, y_mid, x - self._btnWidth2, y_mid)
                          dc.DrawLine(x3, y_mid, x3 + _LINEATROOT, y_mid)
                      else:
                          dc.DrawLine(x2, y_mid, x3 + _LINEATROOT, y_mid)
                  else:
                      dc.DrawLine(x2, y_mid, x - self._indent/2, y_mid)
                  
              if item.HasPlus() and self.HasButtons():  # should the item show a button?
                  
                  if self._imageListButtons:
  
                      # draw the image button here
                      image = wx.TreeItemIcon_Normal
                      if item.IsExpanded():
                          image = wx.TreeItemIcon_Expanded
                      if item.IsSelected():
                          image += wx.TreeItemIcon_Selected - wx.TreeItemIcon_Normal
                      xx = x - self._btnWidth2 + _MARGIN
                      yy = y_mid - self._btnHeight2
                      dc.SetClippingRegion(xx, yy, self._btnWidth, self._btnHeight)
                      self._imageListButtons.Draw(image, dc, xx, yy, wx.IMAGELIST_DRAW_TRANSPARENT)
                      dc.DestroyClippingRegion()
  
                  elif self.HasAGWFlag(wx.TR_TWIST_BUTTONS):
  
                      # draw the twisty button here
                      dc.SetPen(wx.BLACK_PEN)
                      dc.SetBrush(self._hilightBrush)
                      button = [wx.Point() for j in xrange(3)]
                      if item.IsExpanded():
                          button[0].x = x - (self._btnWidth2+1)
                          button[0].y = y_mid - (self._btnHeight/3)
                          button[1].x = x + (self._btnWidth2+1)
                          button[1].y = button[0].y
                          button[2].x = x
                          button[2].y = button[0].y + (self._btnHeight2+1)
                      else:
                          button[0].x = x - (self._btnWidth/3)
                          button[0].y = y_mid - (self._btnHeight2+1)
                          button[1].x = button[0].x
                          button[1].y = y_mid + (self._btnHeight2+1)
                          button[2].x = button[0].x + (self._btnWidth2+1)
                          button[2].y = y_mid
                      
                      dc.SetClippingRegion(x_maincol + _MARGIN, y_top, clip_width, h)
                      dc.DrawPolygon(button)
                      dc.DestroyClippingRegion()
  
                  else: # if (HasAGWFlag(wxTR_HAS_BUTTONS))
  
                      rect = wx.Rect(x-self._btnWidth2, y_mid-self._btnHeight2, self._btnWidth, self._btnHeight)
                      flag = (item.IsExpanded() and [wx.CONTROL_EXPANDED] or [0])[0]
                      wx.RendererNative.GetDefault().DrawTreeItemButton(self, dc, rect, flag)        
  
          # restore DC objects
          dc.SetBrush(wx.WHITE_BRUSH)
          dc.SetPen(self._dottedPen)
          dc.SetTextForeground(wx.BLACK)
  
          if item.IsExpanded():
  
              # process lower levels
              if self._imgWidth > 0:
                  oldY = y_mid + self._imgHeight2
              else:
                  oldY = y_mid + h/2
              
              for child in item.GetChildren():
  
                  y, x_maincol = self.PaintLevel(child, dc, level+1, y, x_maincol)
  
                  # draw vertical line
                  if not self.HasAGWFlag(wx.TR_NO_LINES):
                      Y1 = child.GetY() + child.GetHeight()/2
                      dc.DrawLine(x, oldY, x, Y1)
  
          return y, x_maincol
function_tokens: def PaintLevel ( self , item , dc , level , y , x_maincol ) : if item . IsHidden ( ) : return y , x_maincol # Handle hide root (only level 0) if self . HasAGWFlag ( wx . TR_HIDE_ROOT ) and level == 0 : for child in item . GetChildren ( ) : y , x_maincol = self . PaintLevel ( child , dc , 1 , y , x_maincol ) # end after expanding root return y , x_maincol # calculate position of vertical lines x = x_maincol + _MARGIN # start of column if self . HasAGWFlag ( wx . TR_LINES_AT_ROOT ) : x += _LINEATROOT # space for lines at root if self . HasButtons ( ) : x += ( self . _btnWidth - self . _btnWidth2 ) # half button space else : x += ( self . _indent - self . _indent / 2 ) if self . HasAGWFlag ( wx . TR_HIDE_ROOT ) : x += self . _indent * ( level - 1 ) # indent but not level 1 else : x += self . _indent * level # indent according to level # set position of vertical line item . SetX ( x ) item . SetY ( y ) h = self . GetLineHeight ( item ) y_top = y y_mid = y_top + ( h / 2 ) y += h exposed_x = dc . LogicalToDeviceX ( 0 ) exposed_y = dc . LogicalToDeviceY ( y_top ) # horizontal lines between rows? draw_row_lines = self . HasAGWFlag ( wx . TR_ROW_LINES ) if self . IsExposed ( exposed_x , exposed_y , _MAX_WIDTH , h + draw_row_lines ) : if draw_row_lines : total_width = self . _owner . GetHeaderWindow ( ) . GetWidth ( ) # if the background colour is white, choose a # contrasting colour for the lines pen = wx . Pen ( wx . SystemSettings_GetColour ( wx . SYS_COLOUR_3DLIGHT ) , 1 , wx . SOLID ) dc . SetPen ( ( self . GetBackgroundColour ( ) == wx . WHITE and [ pen ] or [ wx . WHITE_PEN ] ) [ 0 ] ) dc . DrawLine ( 0 , y_top , total_width , y_top ) dc . DrawLine ( 0 , y_top + h , total_width , y_top + h ) # draw item self . PaintItem ( item , dc ) # restore DC objects dc . SetBrush ( wx . WHITE_BRUSH ) dc . SetPen ( self . _dottedPen ) # clip to the column width clip_width = self . _owner . GetHeaderWindow ( ) . GetColumn ( self . _main_column ) . GetWidth ( ) ##            clipper = wx.DCClipper(dc, x_maincol, y_top, clip_width, 10000) if not self . HasAGWFlag ( wx . TR_NO_LINES ) : # connection lines # draw the horizontal line here dc . SetPen ( self . _dottedPen ) x2 = x - self . _indent if x2 < ( x_maincol + _MARGIN ) : x2 = x_maincol + _MARGIN x3 = x + ( self . _btnWidth - self . _btnWidth2 ) if self . HasButtons ( ) : if item . HasPlus ( ) : dc . DrawLine ( x2 , y_mid , x - self . _btnWidth2 , y_mid ) dc . DrawLine ( x3 , y_mid , x3 + _LINEATROOT , y_mid ) else : dc . DrawLine ( x2 , y_mid , x3 + _LINEATROOT , y_mid ) else : dc . DrawLine ( x2 , y_mid , x - self . _indent / 2 , y_mid ) if item . HasPlus ( ) and self . HasButtons ( ) : # should the item show a button? if self . _imageListButtons : # draw the image button here image = wx . TreeItemIcon_Normal if item . IsExpanded ( ) : image = wx . TreeItemIcon_Expanded if item . IsSelected ( ) : image += wx . TreeItemIcon_Selected - wx . TreeItemIcon_Normal xx = x - self . _btnWidth2 + _MARGIN yy = y_mid - self . _btnHeight2 dc . SetClippingRegion ( xx , yy , self . _btnWidth , self . _btnHeight ) self . _imageListButtons . Draw ( image , dc , xx , yy , wx . IMAGELIST_DRAW_TRANSPARENT ) dc . DestroyClippingRegion ( ) elif self . HasAGWFlag ( wx . TR_TWIST_BUTTONS ) : # draw the twisty button here dc . SetPen ( wx . BLACK_PEN ) dc . SetBrush ( self . _hilightBrush ) button = [ wx . Point ( ) for j in xrange ( 3 ) ] if item . IsExpanded ( ) : button [ 0 ] . x = x - ( self . _btnWidth2 + 1 ) button [ 0 ] . y = y_mid - ( self . _btnHeight / 3 ) button [ 1 ] . x = x + ( self . _btnWidth2 + 1 ) button [ 1 ] . y = button [ 0 ] . y button [ 2 ] . x = x button [ 2 ] . y = button [ 0 ] . y + ( self . _btnHeight2 + 1 ) else : button [ 0 ] . x = x - ( self . _btnWidth / 3 ) button [ 0 ] . y = y_mid - ( self . _btnHeight2 + 1 ) button [ 1 ] . x = button [ 0 ] . x button [ 1 ] . y = y_mid + ( self . _btnHeight2 + 1 ) button [ 2 ] . x = button [ 0 ] . x + ( self . _btnWidth2 + 1 ) button [ 2 ] . y = y_mid dc . SetClippingRegion ( x_maincol + _MARGIN , y_top , clip_width , h ) dc . DrawPolygon ( button ) dc . DestroyClippingRegion ( ) else : # if (HasAGWFlag(wxTR_HAS_BUTTONS)) rect = wx . Rect ( x - self . _btnWidth2 , y_mid - self . _btnHeight2 , self . _btnWidth , self . _btnHeight ) flag = ( item . IsExpanded ( ) and [ wx . CONTROL_EXPANDED ] or [ 0 ] ) [ 0 ] wx . RendererNative . GetDefault ( ) . DrawTreeItemButton ( self , dc , rect , flag ) # restore DC objects dc . SetBrush ( wx . WHITE_BRUSH ) dc . SetPen ( self . _dottedPen ) dc . SetTextForeground ( wx . BLACK ) if item . IsExpanded ( ) : # process lower levels if self . _imgWidth > 0 : oldY = y_mid + self . _imgHeight2 else : oldY = y_mid + h / 2 for child in item . GetChildren ( ) : y , x_maincol = self . PaintLevel ( child , dc , level + 1 , y , x_maincol ) # draw vertical line if not self . HasAGWFlag ( wx . TR_NO_LINES ) : Y1 = child . GetY ( ) + child . GetHeight ( ) / 2 dc . DrawLine ( x , oldY , x , Y1 ) return y , x_maincol