<s> """<STR_LIT>""" <EOL> import wx <EOL> import wx . gizmos <EOL> from customtreectrl import CustomTreeCtrl <EOL> from customtreectrl import DragImage , TreeEvent , GenericTreeItem <EOL> from customtreectrl import TreeRenameTimer as TreeListRenameTimer <EOL> from customtreectrl import EVT_TREE_ITEM_CHECKING , EVT_TREE_ITEM_CHECKED , EVT_TREE_ITEM_HYPERLINK <EOL> __version__ = "<STR_LIT>" <EOL> _NO_IMAGE = - <NUM_LIT:1> <EOL> _DEFAULT_COL_WIDTH = <NUM_LIT:100> <EOL> _LINEHEIGHT = <NUM_LIT:10> <EOL> _LINEATROOT = <NUM_LIT:5> <EOL> _MARGIN = <NUM_LIT:2> <EOL> _MININDENT = <NUM_LIT:16> <EOL> _BTNWIDTH = <NUM_LIT:9> <EOL> _BTNHEIGHT = <NUM_LIT:9> <EOL> _EXTRA_WIDTH = <NUM_LIT:4> <EOL> _EXTRA_HEIGHT = <NUM_LIT:4> <EOL> _MAX_WIDTH = <NUM_LIT> <EOL> _DRAG_TIMER_TICKS = <NUM_LIT> <EOL> _FIND_TIMER_TICKS = <NUM_LIT> <EOL> _RENAME_TIMER_TICKS = <NUM_LIT> <EOL> TREE_HITTEST_ONITEMCHECKICON = <NUM_LIT> <EOL> TR_NO_BUTTONS = wx . TR_NO_BUTTONS <EOL> """<STR_LIT>""" <EOL> TR_HAS_BUTTONS = wx . TR_HAS_BUTTONS <EOL> """<STR_LIT>""" <EOL> TR_NO_LINES = wx . TR_NO_LINES <EOL> """<STR_LIT>""" <EOL> TR_LINES_AT_ROOT = wx . TR_LINES_AT_ROOT <EOL> """<STR_LIT>""" """<STR_LIT>""" <EOL> TR_TWIST_BUTTONS = wx . TR_TWIST_BUTTONS <EOL> """<STR_LIT>""" <EOL> TR_SINGLE = wx . TR_SINGLE <EOL> """<STR_LIT>""" """<STR_LIT>""" <EOL> TR_MULTIPLE = wx . TR_MULTIPLE <EOL> """<STR_LIT>""" """<STR_LIT>""" <EOL> TR_EXTENDED = wx . TR_EXTENDED <EOL> """<STR_LIT>""" """<STR_LIT>""" <EOL> TR_HAS_VARIABLE_ROW_HEIGHT = wx . TR_HAS_VARIABLE_ROW_HEIGHT <EOL> """<STR_LIT>""" """<STR_LIT>""" <EOL> TR_EDIT_LABELS = wx . TR_EDIT_LABELS <EOL> """<STR_LIT>""" <EOL> TR_ROW_LINES = wx . TR_ROW_LINES <EOL> """<STR_LIT>""" <EOL> TR_HIDE_ROOT = wx . TR_HIDE_ROOT <EOL> """<STR_LIT>""" """<STR_LIT>""" <EOL> TR_FULL_ROW_HIGHLIGHT = wx . TR_FULL_ROW_HIGHLIGHT <EOL> """<STR_LIT>""" """<STR_LIT>""" <EOL> TR_AUTO_CHECK_CHILD = <NUM_LIT> <EOL> """<STR_LIT>""" """<STR_LIT>""" <EOL> TR_AUTO_TOGGLE_CHILD = <NUM_LIT> <EOL> """<STR_LIT>""" """<STR_LIT>""" <EOL> TR_AUTO_CHECK_PARENT = <NUM_LIT> <EOL> """<STR_LIT>""" """<STR_LIT>""" <EOL> TR_ALIGN_WINDOWS = <NUM_LIT> <EOL> """<STR_LIT>""" <EOL> TR_VIRTUAL = <NUM_LIT> <EOL> """<STR_LIT>""" <EOL> TR_NO_HEADER = <NUM_LIT> <EOL> """<STR_LIT>""" <EOL> def IsBufferingSupported ( ) : <EOL> """<STR_LIT>""" <EOL> if wx . Platform != "<STR_LIT>" : <EOL> return False <EOL> if wx . App . GetComCtl32Version ( ) >= <NUM_LIT> : <EOL> if wx . GetOsVersion ( ) [ <NUM_LIT:1> ] > <NUM_LIT:5> : <EOL> return False <EOL> return True <EOL> return False <EOL> class TreeListColumnInfo ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , input = "<STR_LIT>" , width = _DEFAULT_COL_WIDTH , flag = wx . ALIGN_LEFT , <EOL> image = - <NUM_LIT:1> , shown = True , colour = None , edit = False ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( input , basestring ) : <EOL> self . _text = input <EOL> self . _width = width <EOL> self . _flag = flag <EOL> self . _image = image <EOL> self . _selected_image = - <NUM_LIT:1> <EOL> self . _shown = shown <EOL> self . _edit = edit <EOL> self . _font = wx . SystemSettings_GetFont ( wx . SYS_DEFAULT_GUI_FONT ) <EOL> if colour is None : <EOL> self . _colour = wx . SystemSettings_GetColour ( wx . SYS_COLOUR_WINDOWTEXT ) <EOL> else : <EOL> self . _colour = colour <EOL> else : <EOL> self . _text = input . _text <EOL> self . _width = input . _width <EOL> self . _flag = input . _flag <EOL> self . _image = input . _image <EOL> self . _selected_image = input . _selected_image <EOL> self . _shown = input . _shown <EOL> self . _edit = input . _edit <EOL> self . _colour = input . _colour <EOL> self . _font = input . _font <EOL> def GetText ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _text <EOL> def SetText ( self , text ) : <EOL> """<STR_LIT>""" <EOL> self . _text = text <EOL> return self <EOL> def GetWidth ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _width <EOL> def SetWidth ( self , width ) : <EOL> """<STR_LIT>""" <EOL> self . _width = width <EOL> return self <EOL> def GetAlignment ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _flag <EOL> def SetAlignment ( self , flag ) : <EOL> """<STR_LIT>""" <EOL> self . _flag = flag <EOL> return self <EOL> def GetColour ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _colour <EOL> def SetColour ( self , colour ) : <EOL> """<STR_LIT>""" <EOL> self . _colour = colour <EOL> return self <EOL> def GetImage ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _image <EOL> def SetImage ( self , image ) : <EOL> """<STR_LIT>""" <EOL> self . _image = image <EOL> return self <EOL> def GetSelectedImage ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _selected_image <EOL> def SetSelectedImage ( self , image ) : <EOL> """<STR_LIT>""" <EOL> self . _selected_image = image <EOL> return self <EOL> def IsEditable ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _edit <EOL> def SetEditable ( self , edit ) : <EOL> """<STR_LIT>""" <EOL> self . _edit = edit <EOL> return self <EOL> def IsShown ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _shown <EOL> def SetShown ( self , shown ) : <EOL> """<STR_LIT>""" <EOL> self . _shown = shown <EOL> return self <EOL> def SetFont ( self , font ) : <EOL> """<STR_LIT>""" <EOL> self . _font = font <EOL> return self <EOL> def GetFont ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _font <EOL> class TreeListHeaderWindow ( wx . Window ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , parent , id = wx . ID_ANY , owner = None , pos = wx . DefaultPosition , <EOL> size = wx . DefaultSize , style = <NUM_LIT:0> , name = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> wx . Window . __init__ ( self , parent , id , pos , size , style , name = name ) <EOL> self . _owner = owner <EOL> self . _currentCursor = wx . StockCursor ( wx . CURSOR_DEFAULT ) <EOL> self . _resizeCursor = wx . StockCursor ( wx . CURSOR_SIZEWE ) <EOL> self . _isDragging = False <EOL> self . _dirty = False <EOL> self . _total_col_width = <NUM_LIT:0> <EOL> self . _hotTrackCol = - <NUM_LIT:1> <EOL> self . _columns = [ ] <EOL> self . _headerCustomRenderer = None <EOL> self . Bind ( wx . EVT_PAINT , self . OnPaint ) <EOL> self . Bind ( wx . EVT_MOUSE_EVENTS , self . OnMouse ) <EOL> self . Bind ( wx . EVT_SET_FOCUS , self . OnSetFocus ) <EOL> self . SetBackgroundStyle ( wx . BG_STYLE_CUSTOM ) <EOL> def SetBuffered ( self , buffered ) : <EOL> """<STR_LIT>""" <EOL> self . _buffered = buffered <EOL> def GetWidth ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _total_col_width <EOL> def GetColumnCount ( self ) : <EOL> """<STR_LIT>""" <EOL> return len ( self . _columns ) <EOL> def GetColumn ( self , column ) : <EOL> """<STR_LIT>""" <EOL> if column < <NUM_LIT:0> or column >= self . GetColumnCount ( ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> return self . _columns [ column ] <EOL> def GetColumnText ( self , column ) : <EOL> """<STR_LIT>""" <EOL> if column < <NUM_LIT:0> or column >= self . GetColumnCount ( ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> return self . _columns [ column ] . GetText ( ) <EOL> def SetColumnText ( self , column , text ) : <EOL> """<STR_LIT>""" <EOL> if column < <NUM_LIT:0> or column >= self . GetColumnCount ( ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> return self . _columns [ column ] . SetText ( text ) <EOL> def GetColumnAlignment ( self , column ) : <EOL> """<STR_LIT>""" <EOL> if column < <NUM_LIT:0> or column >= self . GetColumnCount ( ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> return self . _columns [ column ] . GetAlignment ( ) <EOL> def SetColumnAlignment ( self , column , flag ) : <EOL> """<STR_LIT>""" <EOL> if column < <NUM_LIT:0> or column >= self . GetColumnCount ( ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> return self . _columns [ column ] . SetAlignment ( flag ) <EOL> def GetColumnWidth ( self , column ) : <EOL> """<STR_LIT>""" <EOL> if column < <NUM_LIT:0> or column >= self . GetColumnCount ( ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> return self . _columns [ column ] . GetWidth ( ) <EOL> def GetColumnColour ( self , column ) : <EOL> """<STR_LIT>""" <EOL> if column < <NUM_LIT:0> or column >= self . GetColumnCount ( ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> return self . _columns [ column ] . GetColour ( ) <EOL> def SetColumnColour ( self , column , colour ) : <EOL> """<STR_LIT>""" <EOL> if column < <NUM_LIT:0> or column >= self . GetColumnCount ( ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> return self . _columns [ column ] . SetColour ( colour ) <EOL> def IsColumnEditable ( self , column ) : <EOL> """<STR_LIT>""" <EOL> if column < <NUM_LIT:0> or column >= self . GetColumnCount ( ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> return self . _columns [ column ] . IsEditable ( ) <EOL> def IsColumnShown ( self , column ) : <EOL> """<STR_LIT>""" <EOL> if column < <NUM_LIT:0> or column >= self . GetColumnCount ( ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> return self . _columns [ column ] . IsShown ( ) <EOL> def AdjustDC ( self , dc ) : <EOL> """<STR_LIT>""" <EOL> xpix , dummy = self . _owner . GetScrollPixelsPerUnit ( ) <EOL> x , dummy = self . _owner . GetViewStart ( ) <EOL> dc . SetDeviceOrigin ( - x * xpix , <NUM_LIT:0> ) <EOL> def OnPaint ( self , event ) : <EOL> """<STR_LIT>""" <EOL> if self . _buffered : <EOL> dc = wx . BufferedPaintDC ( self ) <EOL> else : <EOL> dc = wx . PaintDC ( self ) <EOL> self . PrepareDC ( dc ) <EOL> self . AdjustDC ( dc ) <EOL> x = <NUM_LIT:0> <EOL> w , h = self . GetClientSize ( ) <EOL> w , dummy = self . _owner . CalcUnscrolledPosition ( w , <NUM_LIT:0> ) <EOL> dc . SetBackgroundMode ( wx . TRANSPARENT ) <EOL> numColumns = self . GetColumnCount ( ) <EOL> for i in xrange ( numColumns ) : <EOL> if x >= w : <EOL> break <EOL> if not self . IsColumnShown ( i ) : <EOL> continue <EOL> params = wx . HeaderButtonParams ( ) <EOL> column = self . GetColumn ( i ) <EOL> params . m_labelColour = column . GetColour ( ) <EOL> params . m_labelFont = column . GetFont ( ) <EOL> wCol = column . GetWidth ( ) <EOL> flags = <NUM_LIT:0> <EOL> rect = wx . Rect ( x , <NUM_LIT:0> , wCol , h ) <EOL> x += wCol <EOL> if i == self . _hotTrackCol : <EOL> flags |= wx . CONTROL_CURRENT <EOL> params . m_labelText = column . GetText ( ) <EOL> params . m_labelAlignment = column . GetAlignment ( ) <EOL> image = column . GetImage ( ) <EOL> imageList = self . _owner . GetImageList ( ) <EOL> if image != - <NUM_LIT:1> and imageList : <EOL> params . m_labelBitmap = imageList . GetBitmap ( image ) <EOL> if self . _headerCustomRenderer != None : <EOL> self . _headerCustomRenderer . DrawHeaderButton ( dc , rect , flags , params ) <EOL> else : <EOL> wx . RendererNative . Get ( ) . DrawHeaderButton ( self , dc , rect , flags , <EOL> wx . HDR_SORT_ICON_NONE , params ) <EOL> if x < w : <EOL> rect = wx . Rect ( x , <NUM_LIT:0> , w - x , h ) <EOL> if self . _headerCustomRenderer != None : <EOL> self . _headerCustomRenderer . DrawHeaderButton ( dc , rect ) <EOL> else : <EOL> wx . RendererNative . Get ( ) . DrawHeaderButton ( self , dc , rect ) <EOL> def DrawCurrent ( self ) : <EOL> """<STR_LIT>""" <EOL> x1 , y1 = self . _currentX , <NUM_LIT:0> <EOL> x1 , y1 = self . ClientToScreen ( ( x1 , y1 ) ) <EOL> x2 = self . _currentX - <NUM_LIT:1> <EOL> if wx . Platform == "<STR_LIT>" : <EOL> x2 += <NUM_LIT:1> <EOL> y2 = <NUM_LIT:0> <EOL> dummy , y2 = self . _owner . GetClientSize ( ) <EOL> x2 , y2 = self . _owner . ClientToScreen ( ( x2 , y2 ) ) <EOL> dc = wx . ScreenDC ( ) <EOL> dc . SetLogicalFunction ( wx . INVERT ) <EOL> dc . SetPen ( wx . Pen ( wx . BLACK , <NUM_LIT:2> , wx . SOLID ) ) <EOL> dc . SetBrush ( wx . TRANSPARENT_BRUSH ) <EOL> self . AdjustDC ( dc ) <EOL> dc . DrawLine ( x1 , y1 , x2 , y2 ) <EOL> dc . SetLogicalFunction ( wx . COPY ) <EOL> def SetCustomRenderer ( self , renderer = None ) : <EOL> """<STR_LIT>""" <EOL> self . _headerCustomRenderer = renderer <EOL> def XToCol ( self , x ) : <EOL> """<STR_LIT>""" <EOL> colLeft = <NUM_LIT:0> <EOL> numColumns = self . GetColumnCount ( ) <EOL> for col in xrange ( numColumns ) : <EOL> if not self . IsColumnShown ( col ) : <EOL> continue <EOL> column = self . GetColumn ( col ) <EOL> if x < ( colLeft + column . GetWidth ( ) ) : <EOL> return col <EOL> colLeft += column . GetWidth ( ) <EOL> return wx . NOT_FOUND <EOL> def RefreshColLabel ( self , col ) : <EOL> """<STR_LIT>""" <EOL> if col >= self . GetColumnCount ( ) : <EOL> return <EOL> x = idx = width = <NUM_LIT:0> <EOL> while idx <= col : <EOL> if not self . IsColumnShown ( idx ) : <EOL> continue <EOL> column = self . GetColumn ( idx ) <EOL> x += width <EOL> width = column . GetWidth ( ) <EOL> idx += <NUM_LIT:1> <EOL> x , dummy = self . _owner . CalcScrolledPosition ( x , <NUM_LIT:0> ) <EOL> self . RefreshRect ( wx . Rect ( x , <NUM_LIT:0> , width , self . GetSize ( ) . GetHeight ( ) ) ) <EOL> def OnMouse ( self , event ) : <EOL> """<STR_LIT>""" <EOL> x , dummy = self . _owner . CalcUnscrolledPosition ( event . GetX ( ) , <NUM_LIT:0> ) <EOL> y = event . GetY ( ) <EOL> if event . Moving ( ) : <EOL> col = self . XToCol ( x ) <EOL> if col != self . _hotTrackCol : <EOL> self . RefreshColLabel ( col ) <EOL> if self . _hotTrackCol >= <NUM_LIT:0> : <EOL> self . RefreshColLabel ( self . _hotTrackCol ) <EOL> self . _hotTrackCol = col <EOL> if event . Leaving ( ) and self . _hotTrackCol >= <NUM_LIT:0> : <EOL> self . RefreshColLabel ( self . _hotTrackCol ) <EOL> self . _hotTrackCol = - <NUM_LIT:1> <EOL> if self . _isDragging : <EOL> self . SendListEvent ( wx . wxEVT_COMMAND_LIST_COL_DRAGGING , event . GetPosition ( ) ) <EOL> w , dummy = self . GetClientSize ( ) <EOL> w , dummy = self . _owner . CalcUnscrolledPosition ( w , <NUM_LIT:0> ) <EOL> w -= <NUM_LIT:6> <EOL> if self . _currentX < w : <EOL> self . DrawCurrent ( ) <EOL> if event . ButtonUp ( ) : <EOL> self . _isDragging = False <EOL> if self . HasCapture ( ) : <EOL> self . ReleaseMouse ( ) <EOL> self . _dirty = True <EOL> self . SetColumnWidth ( self . _column , self . _currentX - self . _minX ) <EOL> self . Refresh ( ) <EOL> self . SendListEvent ( wx . wxEVT_COMMAND_LIST_COL_END_DRAG , event . GetPosition ( ) ) <EOL> else : <EOL> self . _currentX = max ( self . _minX + <NUM_LIT:7> , x ) <EOL> if self . _currentX < w : <EOL> self . DrawCurrent ( ) <EOL> else : <EOL> self . _minX = <NUM_LIT:0> <EOL> hit_border = False <EOL> xpos = <NUM_LIT:0> <EOL> countCol = self . GetColumnCount ( ) <EOL> for column in xrange ( countCol ) : <EOL> if not self . IsColumnShown ( column ) : <EOL> continue <EOL> xpos += self . GetColumnWidth ( column ) <EOL> self . _column = column <EOL> if abs ( x - xpos ) < <NUM_LIT:3> and y < <NUM_LIT> : <EOL> hit_border = True <EOL> break <EOL> if x < xpos : <EOL> break <EOL> self . _minX = xpos <EOL> if event . LeftDown ( ) or event . RightUp ( ) : <EOL> if hit_border and event . LeftDown ( ) : <EOL> self . _isDragging = True <EOL> self . CaptureMouse ( ) <EOL> self . _currentX = x <EOL> self . DrawCurrent ( ) <EOL> self . SendListEvent ( wx . wxEVT_COMMAND_LIST_COL_BEGIN_DRAG , event . GetPosition ( ) ) <EOL> else : <EOL> evt = ( event . LeftDown ( ) and [ wx . wxEVT_COMMAND_LIST_COL_CLICK ] or [ wx . wxEVT_COMMAND_LIST_COL_RIGHT_CLICK ] ) [ <NUM_LIT:0> ] <EOL> self . SendListEvent ( evt , event . GetPosition ( ) ) <EOL> elif event . LeftDClick ( ) and hit_border : <EOL> self . SetColumnWidth ( self . _column , self . _owner . GetBestColumnWidth ( self . _column ) ) <EOL> self . Refresh ( ) <EOL> elif event . Moving ( ) : <EOL> if hit_border : <EOL> setCursor = self . _currentCursor == wx . STANDARD_CURSOR <EOL> self . _currentCursor = self . _resizeCursor <EOL> else : <EOL> setCursor = self . _currentCursor != wx . STANDARD_CURSOR <EOL> self . _currentCursor = wx . STANDARD_CURSOR <EOL> if setCursor : <EOL> self . SetCursor ( self . _currentCursor ) <EOL> def OnSetFocus ( self , event ) : <EOL> """<STR_LIT>""" <EOL> self . _owner . SetFocus ( ) <EOL> def SendListEvent ( self , evtType , pos ) : <EOL> """<STR_LIT>""" <EOL> parent = self . GetParent ( ) <EOL> le = wx . ListEvent ( evtType , parent . GetId ( ) ) <EOL> le . SetEventObject ( parent ) <EOL> le . m_pointDrag = pos <EOL> le . m_pointDrag . y -= self . GetSize ( ) . y <EOL> le . m_col = self . _column <EOL> parent . GetEventHandler ( ) . ProcessEvent ( le ) <EOL> def AddColumnInfo ( self , colInfo ) : <EOL> """<STR_LIT>""" <EOL> self . _columns . append ( colInfo ) <EOL> self . _total_col_width += colInfo . GetWidth ( ) <EOL> self . _owner . AdjustMyScrollbars ( ) <EOL> self . _owner . _dirty = True <EOL> def AddColumn ( self , text , width = _DEFAULT_COL_WIDTH , flag = wx . ALIGN_LEFT , <EOL> image = - <NUM_LIT:1> , shown = True , colour = None , edit = False ) : <EOL> """<STR_LIT>""" <EOL> colInfo = TreeListColumnInfo ( text , width , flag , image , shown , colour , edit ) <EOL> self . AddColumnInfo ( colInfo ) <EOL> def SetColumnWidth ( self , column , width ) : <EOL> """<STR_LIT>""" <EOL> if column < <NUM_LIT:0> or column >= self . GetColumnCount ( ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> self . _total_col_width -= self . _columns [ column ] . GetWidth ( ) <EOL> self . _columns [ column ] . SetWidth ( width ) <EOL> self . _total_col_width += width <EOL> self . _owner . AdjustMyScrollbars ( ) <EOL> self . _owner . _dirty = True <EOL> def InsertColumnInfo ( self , before , colInfo ) : <EOL> """<STR_LIT>""" <EOL> if before < <NUM_LIT:0> or before >= self . GetColumnCount ( ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> self . _columns . insert ( before , colInfo ) <EOL> self . _total_col_width += colInfo . GetWidth ( ) <EOL> self . _owner . AdjustMyScrollbars ( ) <EOL> self . _owner . _dirty = True <EOL> def InsertColumn ( self , before , text , width = _DEFAULT_COL_WIDTH , <EOL> flag = wx . ALIGN_LEFT , image = - <NUM_LIT:1> , shown = True , colour = None , <EOL> edit = False ) : <EOL> """<STR_LIT>""" <EOL> colInfo = TreeListColumnInfo ( text , width , flag , image , shown , colour , <EOL> edit ) <EOL> self . InsertColumnInfo ( before , colInfo ) <EOL> def RemoveColumn ( self , column ) : <EOL> """<STR_LIT>""" <EOL> if column < <NUM_LIT:0> or column >= self . GetColumnCount ( ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> self . _total_col_width -= self . _columns [ column ] . GetWidth ( ) <EOL> self . _columns . pop ( column ) <EOL> self . _owner . AdjustMyScrollbars ( ) <EOL> self . _owner . _dirty = True <EOL> def SetColumn ( self , column , info ) : <EOL> """<STR_LIT>""" <EOL> if column < <NUM_LIT:0> or column >= self . GetColumnCount ( ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> w = self . _columns [ column ] . GetWidth ( ) <EOL> self . _columns [ column ] = info <EOL> if w != info . GetWidth ( ) : <EOL> self . _total_col_width += info . GetWidth ( ) - w <EOL> self . _owner . AdjustMyScrollbars ( ) <EOL> self . _owner . _dirty = True <EOL> class TreeListItem ( GenericTreeItem ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , mainWin , parent , text = [ ] , ct_type = <NUM_LIT:0> , wnd = None , image = - <NUM_LIT:1> , selImage = - <NUM_LIT:1> , data = None ) : <EOL> """<STR_LIT>""" <EOL> self . _col_images = [ ] <EOL> self . _owner = mainWin <EOL> self . _text_x = <NUM_LIT:0> <EOL> GenericTreeItem . __init__ ( self , parent , text , ct_type , wnd , image , selImage , data ) <EOL> self . _wnd = [ None ] <EOL> self . _hidden = False <EOL> if wnd : <EOL> self . SetWindow ( wnd ) <EOL> def IsHidden ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _hidden <EOL> def Hide ( self , hide ) : <EOL> """<STR_LIT>""" <EOL> self . _hidden = hide <EOL> def DeleteChildren ( self , tree ) : <EOL> """<STR_LIT>""" <EOL> for child in self . _children : <EOL> if tree : <EOL> tree . SendDeleteEvent ( child ) <EOL> child . DeleteChildren ( tree ) <EOL> if child == tree . _selectItem : <EOL> tree . _selectItem = None <EOL> for wnd in child . _wnd : <EOL> if wnd : <EOL> wnd . Hide ( ) <EOL> wnd . Destroy ( ) <EOL> child . _wnd = [ ] <EOL> if child in tree . _itemWithWindow : <EOL> tree . _itemWithWindow . remove ( child ) <EOL> del child <EOL> self . _children = [ ] <EOL> def HitTest ( self , point , theCtrl , flags , column , level ) : <EOL> """<STR_LIT>""" <EOL> if not theCtrl . HasAGWFlag ( wx . TR_HIDE_ROOT ) or level > <NUM_LIT:0> : <EOL> flags = <NUM_LIT:0> <EOL> column = - <NUM_LIT:1> <EOL> header_win = theCtrl . _owner . GetHeaderWindow ( ) <EOL> if point . x > header_win . GetWidth ( ) : <EOL> return None , flags , wx . NOT_FOUND <EOL> h = theCtrl . GetLineHeight ( self ) <EOL> if point . y >= self . _y and point . y <= self . _y + h : <EOL> maincol = theCtrl . GetMainColumn ( ) <EOL> y_mid = self . _y + h / <NUM_LIT:2> <EOL> if point . y < y_mid : <EOL> flags |= wx . TREE_HITTEST_ONITEMUPPERPART <EOL> else : <EOL> flags |= wx . TREE_HITTEST_ONITEMLOWERPART <EOL> if self . HasPlus ( ) and theCtrl . HasButtons ( ) : <EOL> bntX = self . _x - theCtrl . _btnWidth2 <EOL> bntY = y_mid - theCtrl . _btnHeight2 <EOL> if ( ( point . x >= bntX ) and ( point . x <= ( bntX + theCtrl . _btnWidth ) ) and <EOL> ( point . y >= bntY ) and ( point . y <= ( bntY + theCtrl . _btnHeight ) ) ) : <EOL> flags |= wx . TREE_HITTEST_ONITEMBUTTON <EOL> column = maincol <EOL> return self , flags , column <EOL> if self . GetType ( ) != <NUM_LIT:0> : <EOL> imageWidth = <NUM_LIT:0> <EOL> numberOfMargins = <NUM_LIT:1> <EOL> if self . GetCurrentImage ( ) != _NO_IMAGE : <EOL> imageWidth = theCtrl . _imgWidth <EOL> numberOfMargins += <NUM_LIT:1> <EOL> chkX = self . _text_x - imageWidth - numberOfMargins * _MARGIN - theCtrl . _checkWidth <EOL> chkY = y_mid - theCtrl . _checkHeight2 <EOL> if ( ( point . x >= chkX ) and ( point . x <= ( chkX + theCtrl . _checkWidth ) ) and <EOL> ( point . y >= chkY ) and ( point . y <= ( chkY + theCtrl . _checkHeight ) ) ) : <EOL> flags |= TREE_HITTEST_ONITEMCHECKICON <EOL> return self , flags , maincol <EOL> if self . GetCurrentImage ( ) != _NO_IMAGE : <EOL> imgX = self . _text_x - theCtrl . _imgWidth - _MARGIN <EOL> imgY = y_mid - theCtrl . _imgHeight2 <EOL> if ( ( point . x >= imgX ) and ( point . x <= ( imgX + theCtrl . _imgWidth ) ) and <EOL> ( point . y >= imgY ) and ( point . y <= ( imgY + theCtrl . _imgHeight ) ) ) : <EOL> flags |= wx . TREE_HITTEST_ONITEMICON <EOL> column = maincol <EOL> return self , flags , column <EOL> if ( ( point . x >= self . _text_x ) and ( point . x <= ( self . _text_x + self . _width ) ) ) : <EOL> flags |= wx . TREE_HITTEST_ONITEMLABEL <EOL> column = maincol <EOL> return self , flags , column <EOL> if point . x < self . _x : <EOL> flags |= wx . TREE_HITTEST_ONITEMINDENT <EOL> column = - <NUM_LIT:1> <EOL> return self , flags , column <EOL> end = <NUM_LIT:0> <EOL> for i in xrange ( maincol ) : <EOL> end += header_win . GetColumnWidth ( i ) <EOL> if ( ( point . x > ( self . _text_x + self . _width ) ) and ( point . x <= end ) ) : <EOL> flags |= wx . TREE_HITTEST_ONITEMRIGHT <EOL> column = - <NUM_LIT:1> <EOL> return self , flags , column <EOL> x = <NUM_LIT:0> <EOL> for j in xrange ( theCtrl . GetColumnCount ( ) ) : <EOL> if not header_win . IsColumnShown ( j ) : <EOL> continue <EOL> w = header_win . GetColumnWidth ( j ) <EOL> if ( ( j != maincol ) and ( point . x >= x and point . x < x + w ) ) : <EOL> flags |= wx . TREE_HITTEST_ONITEMCOLUMN <EOL> column = j <EOL> return self , flags , column <EOL> x += w <EOL> return self , flags , column <EOL> if not self . IsExpanded ( ) : <EOL> return None , flags , wx . NOT_FOUND <EOL> for child in self . _children : <EOL> hit , flags , column = child . HitTest ( point , theCtrl , flags , column , level + <NUM_LIT:1> ) <EOL> if hit : <EOL> return hit , flags , column <EOL> return None , flags , wx . NOT_FOUND <EOL> def GetText ( self , column = None ) : <EOL> """<STR_LIT>""" <EOL> column = ( column is not None and [ column ] or [ self . _owner . GetMainColumn ( ) ] ) [ <NUM_LIT:0> ] <EOL> if len ( self . _text ) > <NUM_LIT:0> : <EOL> if self . _owner . IsVirtual ( ) : <EOL> return self . _owner . GetItemText ( self . _data , column ) <EOL> else : <EOL> return self . _text [ column ] <EOL> return "<STR_LIT>" <EOL> def GetImage ( self , which = wx . TreeItemIcon_Normal , column = None ) : <EOL> """<STR_LIT>""" <EOL> column = ( column is not None and [ column ] or [ self . _owner . GetMainColumn ( ) ] ) [ <NUM_LIT:0> ] <EOL> if column == self . _owner . GetMainColumn ( ) : <EOL> return self . _images [ which ] <EOL> if column < len ( self . _col_images ) : <EOL> return self . _col_images [ column ] <EOL> return _NO_IMAGE <EOL> def GetCurrentImage ( self , column = None ) : <EOL> """<STR_LIT>""" <EOL> column = ( column is not None and [ column ] or [ self . _owner . GetMainColumn ( ) ] ) [ <NUM_LIT:0> ] <EOL> if column != self . _owner . GetMainColumn ( ) : <EOL> return self . GetImage ( column = column ) <EOL> image = GenericTreeItem . GetCurrentImage ( self ) <EOL> return image <EOL> def SetText ( self , column , text ) : <EOL> """<STR_LIT>""" <EOL> column = ( column is not None and [ column ] or [ self . _owner . GetMainColumn ( ) ] ) [ <NUM_LIT:0> ] <EOL> if column < len ( self . _text ) : <EOL> self . _text [ column ] = text <EOL> elif column < self . _owner . GetColumnCount ( ) : <EOL> self . _text . extend ( [ "<STR_LIT>" ] * ( column - len ( self . _text ) + <NUM_LIT:1> ) ) <EOL> self . _text [ column ] = text <EOL> def SetImage ( self , column , image , which ) : <EOL> """<STR_LIT>""" <EOL> column = ( column is not None and [ column ] or [ self . _owner . GetMainColumn ( ) ] ) [ <NUM_LIT:0> ] <EOL> if column == self . _owner . GetMainColumn ( ) : <EOL> self . _images [ which ] = image <EOL> elif column < len ( self . _col_images ) : <EOL> self . _col_images [ column ] = image <EOL> elif column < self . _owner . GetColumnCount ( ) : <EOL> self . _col_images . extend ( [ _NO_IMAGE ] * ( column - len ( self . _col_images ) + <NUM_LIT:1> ) ) <EOL> self . _col_images [ column ] = image <EOL> def GetTextX ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _text_x <EOL> def SetTextX ( self , text_x ) : <EOL> """<STR_LIT>""" <EOL> self . _text_x = text_x <EOL> def SetWindow ( self , wnd , column = None ) : <EOL> """<STR_LIT>""" <EOL> column = ( column is not None and [ column ] or [ self . _owner . GetMainColumn ( ) ] ) [ <NUM_LIT:0> ] <EOL> if type ( self . _wnd ) != type ( [ ] ) : <EOL> self . _wnd = [ self . _wnd ] <EOL> if column < len ( self . _wnd ) : <EOL> self . _wnd [ column ] = wnd <EOL> elif column < self . _owner . GetColumnCount ( ) : <EOL> self . _wnd . extend ( [ None ] * ( column - len ( self . _wnd ) + <NUM_LIT:1> ) ) <EOL> self . _wnd [ column ] = wnd <EOL> if self not in self . _owner . _itemWithWindow : <EOL> self . _owner . _itemWithWindow . append ( self ) <EOL> wnd . Bind ( wx . EVT_SET_FOCUS , self . OnSetFocus ) <EOL> if self . _isCollapsed : <EOL> wnd . Show ( False ) <EOL> wnd . Enable ( self . _enabled ) <EOL> def OnSetFocus ( self , event ) : <EOL> """<STR_LIT>""" <EOL> treectrl = self . _owner <EOL> select = treectrl . GetSelection ( ) <EOL> if select != self : <EOL> treectrl . _hasFocus = False <EOL> else : <EOL> treectrl . _hasFocus = True <EOL> event . Skip ( ) <EOL> def GetWindow ( self , column = None ) : <EOL> """<STR_LIT>""" <EOL> column = ( column is not None and [ column ] or [ self . _owner . GetMainColumn ( ) ] ) [ <NUM_LIT:0> ] <EOL> if column >= len ( self . _wnd ) : <EOL> return None <EOL> return self . _wnd [ column ] <EOL> def DeleteWindow ( self , column = None ) : <EOL> """<STR_LIT>""" <EOL> column = ( column is not None and [ column ] or [ self . _owner . GetMainColumn ( ) ] ) [ <NUM_LIT:0> ] <EOL> if column >= len ( self . _wnd ) : <EOL> return <EOL> if self . _wnd [ column ] : <EOL> self . _wnd [ column ] . Destroy ( ) <EOL> self . _wnd [ column ] = None <EOL> def GetWindowEnabled ( self , column = None ) : <EOL> """<STR_LIT>""" <EOL> column = ( column is not None and [ column ] or [ self . _owner . GetMainColumn ( ) ] ) [ <NUM_LIT:0> ] <EOL> if not self . _wnd [ column ] : <EOL> raise Exception ( "<STR_LIT>" % column ) <EOL> return self . _wnd [ column ] . IsEnabled ( ) <EOL> def SetWindowEnabled ( self , enable = True , column = None ) : <EOL> """<STR_LIT>""" <EOL> column = ( column is not None and [ column ] or [ self . _owner . GetMainColumn ( ) ] ) [ <NUM_LIT:0> ] <EOL> if not self . _wnd [ column ] : <EOL> raise Exception ( "<STR_LIT>" % column ) <EOL> self . _wnd [ column ] . Enable ( enable ) <EOL> def GetWindowSize ( self , column = None ) : <EOL> """<STR_LIT>""" <EOL> column = ( column is not None and [ column ] or [ self . _owner . GetMainColumn ( ) ] ) [ <NUM_LIT:0> ] <EOL> if not self . _wnd [ column ] : <EOL> raise Exception ( "<STR_LIT>" % column ) <EOL> return self . _wnd [ column ] . GetSize ( ) <EOL> class EditTextCtrl ( wx . TextCtrl ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , parent , id = wx . ID_ANY , item = None , column = None , owner = None , <EOL> value = "<STR_LIT>" , pos = wx . DefaultPosition , size = wx . DefaultSize , style = <NUM_LIT:0> , <EOL> validator = wx . DefaultValidator , name = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> self . _owner = owner <EOL> self . _startValue = value <EOL> self . _finished = False <EOL> self . _itemEdited = item <EOL> column = ( column is not None and [ column ] or [ self . _owner . GetMainColumn ( ) ] ) [ <NUM_LIT:0> ] <EOL> self . _column = column <EOL> w = self . _itemEdited . GetWidth ( ) <EOL> h = self . _itemEdited . GetHeight ( ) <EOL> wnd = self . _itemEdited . GetWindow ( column ) <EOL> if wnd : <EOL> w = w - self . _itemEdited . GetWindowSize ( column ) [ <NUM_LIT:0> ] <EOL> h = <NUM_LIT:0> <EOL> x = item . GetX ( ) <EOL> if column > <NUM_LIT:0> : <EOL> x = <NUM_LIT:0> <EOL> for i in xrange ( column ) : <EOL> if not self . _owner . GetParent ( ) . _header_win . IsColumnShown ( i ) : <EOL> continue <EOL> col = self . _owner . GetParent ( ) . _header_win . GetColumn ( i ) <EOL> wCol = col . GetWidth ( ) <EOL> x += wCol <EOL> x , y = self . _owner . CalcScrolledPosition ( x + <NUM_LIT:2> , item . GetY ( ) ) <EOL> image_w = image_h = wcheck = hcheck = <NUM_LIT:0> <EOL> image = item . GetCurrentImage ( column ) <EOL> if image != _NO_IMAGE : <EOL> if self . _owner . _imageListNormal : <EOL> image_w , image_h = self . _owner . _imageListNormal . GetSize ( image ) <EOL> image_w += <NUM_LIT:2> * _MARGIN <EOL> else : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if column > <NUM_LIT:0> : <EOL> checkimage = item . GetCurrentCheckedImage ( ) <EOL> if checkimage is not None : <EOL> wcheck , hcheck = self . _owner . _imageListCheck . GetSize ( checkimage ) <EOL> wcheck += <NUM_LIT:2> * _MARGIN <EOL> if wnd : <EOL> h = max ( hcheck , image_h ) <EOL> dc = wx . ClientDC ( self . _owner ) <EOL> h = max ( h , dc . GetTextExtent ( "<STR_LIT>" ) [ <NUM_LIT:1> ] ) <EOL> h = h + <NUM_LIT:2> <EOL> x += image_w + wcheck <EOL> w -= image_w + <NUM_LIT:2> * _MARGIN + wcheck <EOL> wx . TextCtrl . __init__ ( self , parent , id , value , wx . Point ( x , y ) , <EOL> wx . Size ( w + <NUM_LIT:15> , h ) , style | wx . SIMPLE_BORDER , validator , name ) <EOL> if wx . Platform == "<STR_LIT>" : <EOL> self . SetFont ( owner . GetFont ( ) ) <EOL> bs = self . GetBestSize ( ) <EOL> self . SetSize ( ( - <NUM_LIT:1> , bs . height ) ) <EOL> self . Bind ( wx . EVT_CHAR , self . OnChar ) <EOL> self . Bind ( wx . EVT_KEY_UP , self . OnKeyUp ) <EOL> self . Bind ( wx . EVT_KILL_FOCUS , self . OnKillFocus ) <EOL> def AcceptChanges ( self ) : <EOL> """<STR_LIT>""" <EOL> value = self . GetValue ( ) <EOL> if value == self . _startValue : <EOL> self . _owner . OnRenameCancelled ( ) <EOL> return True <EOL> if not self . _owner . OnRenameAccept ( value ) : <EOL> return False <EOL> return True <EOL> def Finish ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . _finished : <EOL> self . _finished = True <EOL> self . _owner . SetFocusIgnoringChildren ( ) <EOL> self . _owner . ResetTextControl ( ) <EOL> def OnChar ( self , event ) : <EOL> """<STR_LIT>""" <EOL> keycode = event . GetKeyCode ( ) <EOL> if keycode in [ wx . WXK_RETURN , wx . WXK_NUMPAD_ENTER ] : <EOL> self . _aboutToFinish = True <EOL> self . AcceptChanges ( ) <EOL> wx . CallAfter ( self . Finish ) <EOL> elif keycode == wx . WXK_ESCAPE : <EOL> self . StopEditing ( ) <EOL> else : <EOL> event . Skip ( ) <EOL> def OnKeyUp ( self , event ) : <EOL> """<STR_LIT>""" <EOL> if not self . _finished : <EOL> parentSize = self . _owner . GetSize ( ) <EOL> myPos = self . GetPosition ( ) <EOL> mySize = self . GetSize ( ) <EOL> sx , sy = self . GetTextExtent ( self . GetValue ( ) + "<STR_LIT:M>" ) <EOL> if myPos . x + sx > parentSize . x : <EOL> sx = parentSize . x - myPos . x <EOL> if mySize . x > sx : <EOL> sx = mySize . x <EOL> self . SetSize ( ( sx , - <NUM_LIT:1> ) ) <EOL> event . Skip ( ) <EOL> def OnKillFocus ( self , event ) : <EOL> """<STR_LIT>""" <EOL> event . Skip ( ) <EOL> def StopEditing ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _owner . OnRenameCancelled ( ) <EOL> self . Finish ( ) <EOL> def item ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _itemEdited <EOL> def column ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _column <EOL> class TreeListMainWindow ( CustomTreeCtrl ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , parent , id = wx . ID_ANY , pos = wx . DefaultPosition , size = wx . DefaultSize , <EOL> style = <NUM_LIT:0> , agwStyle = wx . TR_DEFAULT_STYLE , validator = wx . DefaultValidator , <EOL> name = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> CustomTreeCtrl . __init__ ( self , parent , id , pos , size , style , agwStyle , validator , name ) <EOL> self . _shiftItem = None <EOL> self . _editItem = None <EOL> self . _selectItem = None <EOL> self . _curColumn = - <NUM_LIT:1> <EOL> self . _owner = parent <EOL> self . _main_column = <NUM_LIT:0> <EOL> self . _dragItem = None <EOL> self . _imgWidth = self . _imgWidth2 = <NUM_LIT:0> <EOL> self . _imgHeight = self . _imgHeight2 = <NUM_LIT:0> <EOL> self . _btnWidth = self . _btnWidth2 = <NUM_LIT:0> <EOL> self . _btnHeight = self . _btnHeight2 = <NUM_LIT:0> <EOL> self . _checkWidth = self . _checkWidth2 = <NUM_LIT:0> <EOL> self . _checkHeight = self . _checkHeight2 = <NUM_LIT:0> <EOL> self . _agwStyle = agwStyle <EOL> self . _current = None <EOL> self . _renameTimer = TreeListRenameTimer ( self ) <EOL> self . _left_down_selection = False <EOL> self . _dragTimer = wx . Timer ( self ) <EOL> self . _findTimer = wx . Timer ( self ) <EOL> self . Bind ( wx . EVT_PAINT , self . OnPaint ) <EOL> self . Bind ( wx . EVT_MOUSE_EVENTS , self . OnMouse ) <EOL> scroll_evt_handler = wx . EvtHandler ( ) <EOL> self . PushEventHandler ( scroll_evt_handler ) <EOL> scroll_evt_handler . Bind ( wx . EVT_SCROLLWIN , self . OnScroll ) <EOL> self . _default_evt_handler = scroll_evt_handler . GetNextHandler ( ) <EOL> self . SetFocus ( ) <EOL> self . SetBackgroundStyle ( wx . BG_STYLE_CUSTOM ) <EOL> def SetBuffered ( self , buffered ) : <EOL> """<STR_LIT>""" <EOL> self . _buffered = buffered <EOL> if buffered : <EOL> self . SetBackgroundStyle ( wx . BG_STYLE_CUSTOM ) <EOL> else : <EOL> self . SetBackgroundStyle ( wx . BG_STYLE_SYSTEM ) <EOL> def IsVirtual ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . HasAGWFlag ( TR_VIRTUAL ) <EOL> def GetItemImage ( self , item , column = None , which = wx . TreeItemIcon_Normal ) : <EOL> """<STR_LIT>""" <EOL> column = ( column is not None and [ column ] or [ self . _main_column ] ) [ <NUM_LIT:0> ] <EOL> if column < <NUM_LIT:0> : <EOL> return _NO_IMAGE <EOL> return item . GetImage ( which , column ) <EOL> def SetItemImage ( self , item , image , column = None , which = wx . TreeItemIcon_Normal ) : <EOL> """<STR_LIT>""" <EOL> column = ( column is not None and [ column ] or [ self . _main_column ] ) [ <NUM_LIT:0> ] <EOL> if column < <NUM_LIT:0> : <EOL> return <EOL> item . SetImage ( column , image , which ) <EOL> dc = wx . ClientDC ( self ) <EOL> self . CalculateSize ( item , dc ) <EOL> self . RefreshLine ( item ) <EOL> def GetItemWindowEnabled ( self , item , column = None ) : <EOL> """<STR_LIT>""" <EOL> return item . GetWindowEnabled ( column ) <EOL> def GetItemWindow ( self , item , column = None ) : <EOL> """<STR_LIT>""" <EOL> return item . GetWindow ( column ) <EOL> def SetItemWindow ( self , item , window , column = None ) : <EOL> """<STR_LIT>""" <EOL> if window . GetParent ( ) != self : <EOL> window . Reparent ( self ) <EOL> item . SetWindow ( window , column ) <EOL> if window : <EOL> self . _hasWindows = True <EOL> def SetItemWindowEnabled ( self , item , enable = True , column = None ) : <EOL> """<STR_LIT>""" <EOL> item . SetWindowEnabled ( enable , column ) <EOL> def IsItemVisible ( self , item ) : <EOL> """<STR_LIT>""" <EOL> parent = item . GetParent ( ) <EOL> while parent : <EOL> if not parent . IsExpanded ( ) : <EOL> return False <EOL> parent = parent . GetParent ( ) <EOL> startX , startY = self . GetViewStart ( ) <EOL> clientSize = self . GetClientSize ( ) <EOL> rect = self . GetBoundingRect ( item ) <EOL> if not rect : <EOL> return False <EOL> if rect . GetWidth ( ) == <NUM_LIT:0> or rect . GetHeight ( ) == <NUM_LIT:0> : <EOL> return False <EOL> if rect . GetBottom ( ) < <NUM_LIT:0> or rect . GetTop ( ) > clientSize . y : <EOL> return False <EOL> if rect . GetRight ( ) < <NUM_LIT:0> or rect . GetLeft ( ) > clientSize . x : <EOL> return False <EOL> return True <EOL> def GetPrevChild ( self , item , cookie ) : <EOL> """<STR_LIT>""" <EOL> children = item . GetChildren ( ) <EOL> if cookie >= <NUM_LIT:0> : <EOL> return children [ cookie ] , cookie - <NUM_LIT:1> <EOL> else : <EOL> return None , cookie <EOL> def GetFirstExpandedItem ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . GetNextExpanded ( self . GetRootItem ( ) ) <EOL> def GetNextExpanded ( self , item ) : <EOL> """<STR_LIT>""" <EOL> return self . GetNext ( item , False ) <EOL> def GetPrevExpanded ( self , item ) : <EOL> """<STR_LIT>""" <EOL> return self . GetPrev ( item , False ) <EOL> def GetFirstVisibleItem ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . GetNextVisible ( self . GetRootItem ( ) ) <EOL> def GetPrevVisible ( self , item ) : <EOL> """<STR_LIT>""" <EOL> i = self . GetNext ( item , False ) <EOL> while i : <EOL> if self . IsItemVisible ( i ) : <EOL> return i <EOL> i = self . GetPrev ( i , False ) <EOL> return None <EOL> def DoInsertItem ( self , parent , previous , text , ct_type = <NUM_LIT:0> , wnd = None , image = - <NUM_LIT:1> , selImage = - <NUM_LIT:1> , data = None ) : <EOL> """<STR_LIT>""" <EOL> self . _dirty = True <EOL> arr = [ "<STR_LIT>" ] * self . GetColumnCount ( ) <EOL> arr [ self . _main_column ] = text <EOL> if not parent : <EOL> return self . AddRoot ( text , ct_type , wnd , image , selImage , data ) <EOL> self . _dirty = True <EOL> item = TreeListItem ( self , parent , arr , ct_type , wnd , image , selImage , data ) <EOL> if wnd is not None : <EOL> self . _hasWindows = True <EOL> self . _itemWithWindow . append ( item ) <EOL> parent . Insert ( item , previous ) <EOL> return item <EOL> def AddRoot ( self , text , ct_type = <NUM_LIT:0> , wnd = None , image = - <NUM_LIT:1> , selImage = - <NUM_LIT:1> , data = None ) : <EOL> """<STR_LIT>""" <EOL> if self . _anchor : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if wnd is not None and not ( self . _agwStyle & wx . TR_HAS_VARIABLE_ROW_HEIGHT ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if text . find ( "<STR_LIT:\n>" ) >= <NUM_LIT:0> and not ( self . _agwStyle & wx . TR_HAS_VARIABLE_ROW_HEIGHT ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if ct_type < <NUM_LIT:0> or ct_type > <NUM_LIT:2> : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> self . _dirty = True <EOL> arr = [ "<STR_LIT>" ] * self . GetColumnCount ( ) <EOL> arr [ self . _main_column ] = text <EOL> self . _anchor = TreeListItem ( self , None , arr , ct_type , wnd , image , selImage , data ) <EOL> if wnd is not None : <EOL> self . _hasWindows = True <EOL> self . _itemWithWindow . append ( self . _anchor ) <EOL> if self . HasAGWFlag ( wx . TR_HIDE_ROOT ) : <EOL> self . _anchor . SetHasPlus ( ) <EOL> self . _anchor . Expand ( ) <EOL> self . CalculatePositions ( ) <EOL> if not self . HasAGWFlag ( wx . TR_MULTIPLE ) : <EOL> self . _current = self . _key_current = self . _selectItem = self . _anchor <EOL> self . _current . SetHilight ( True ) <EOL> return self . _anchor <EOL> def Delete ( self , item ) : <EOL> """<STR_LIT>""" <EOL> if not item : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> self . _dirty = True <EOL> if self . _textCtrl != None and self . IsDescendantOf ( item , self . _textCtrl . item ( ) ) : <EOL> self . _textCtrl . StopEditing ( ) <EOL> changeKeyCurrent = False <EOL> itemKey = self . _shiftItem <EOL> while itemKey : <EOL> if itemKey == item : <EOL> changeKeyCurrent = True <EOL> break <EOL> itemKey = itemKey . GetParent ( ) <EOL> parent = item . GetParent ( ) <EOL> if parent : <EOL> parent . GetChildren ( ) . remove ( item ) <EOL> if changeKeyCurrent : <EOL> self . _shiftItem = parent <EOL> self . SendDeleteEvent ( item ) <EOL> if self . _selectItem == item : <EOL> self . _selectItem = None <EOL> if item in self . _itemWithWindow : <EOL> for wnd in item . _wnd : <EOL> if wnd : <EOL> wnd . Hide ( ) <EOL> wnd . Destroy ( ) <EOL> item . _wnd = [ ] <EOL> self . _itemWithWindow . remove ( item ) <EOL> item . DeleteChildren ( self ) <EOL> del item <EOL> def ChildrenClosing ( self , item ) : <EOL> """<STR_LIT>""" <EOL> if self . _textCtrl != None and item != self . _textCtrl . item ( ) and self . IsDescendantOf ( item , self . _textCtrl . item ( ) ) : <EOL> self . _textCtrl . StopEditing ( ) <EOL> if self . IsDescendantOf ( item , self . _selectItem ) : <EOL> self . _selectItem = item <EOL> if item != self . _current and self . IsDescendantOf ( item , self . _current ) : <EOL> self . _current . SetHilight ( False ) <EOL> self . _current = None <EOL> def DeleteRoot ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _anchor : <EOL> self . _dirty = True <EOL> self . SendDeleteEvent ( self . _anchor ) <EOL> self . _current = None <EOL> self . _selectItem = None <EOL> self . _anchor . DeleteChildren ( self ) <EOL> del self . _anchor <EOL> self . _anchor = None <EOL> def DeleteAllItems ( self ) : <EOL> """<STR_LIT>""" <EOL> self . DeleteRoot ( ) <EOL> def HideWindows ( self ) : <EOL> """<STR_LIT>""" <EOL> for child in self . _itemWithWindow : <EOL> if not self . IsItemVisible ( child ) : <EOL> for column in xrange ( self . GetColumnCount ( ) ) : <EOL> wnd = child . GetWindow ( column ) <EOL> if wnd and wnd . IsShown ( ) : <EOL> wnd . Hide ( ) <EOL> def EnableItem ( self , item , enable = True , torefresh = True ) : <EOL> """<STR_LIT>""" <EOL> if item . IsEnabled ( ) == enable : <EOL> return <EOL> if not enable and item . IsSelected ( ) : <EOL> self . DoSelectItem ( item , not self . HasAGWFlag ( wx . TR_MULTIPLE ) ) <EOL> item . Enable ( enable ) <EOL> for column in xrange ( self . GetColumnCount ( ) ) : <EOL> wnd = item . GetWindow ( column ) <EOL> if wnd : <EOL> wnd . Enable ( enable ) <EOL> if torefresh : <EOL> dc = wx . ClientDC ( self ) <EOL> self . CalculateSize ( item , dc ) <EOL> self . RefreshLine ( item ) <EOL> def IsItemEnabled ( self , item ) : <EOL> """<STR_LIT>""" <EOL> return item . IsEnabled ( ) <EOL> def GetCurrentItem ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _current <EOL> def GetColumnCount ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _owner . GetHeaderWindow ( ) . GetColumnCount ( ) <EOL> def SetMainColumn ( self , column ) : <EOL> """<STR_LIT>""" <EOL> if column >= <NUM_LIT:0> and column < self . GetColumnCount ( ) : <EOL> self . _main_column = column <EOL> def GetMainColumn ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _main_column <EOL> def ScrollTo ( self , item ) : <EOL> """<STR_LIT>""" <EOL> if self . _dirty : <EOL> self . CalculatePositions ( ) <EOL> xUnit , yUnit = self . GetScrollPixelsPerUnit ( ) <EOL> start_x , start_y = self . GetViewStart ( ) <EOL> start_y *= yUnit <EOL> client_w , client_h = self . GetClientSize ( ) <EOL> x , y = self . _anchor . GetSize ( <NUM_LIT:0> , <NUM_LIT:0> , self ) <EOL> x = self . _owner . GetHeaderWindow ( ) . GetWidth ( ) <EOL> y += yUnit + <NUM_LIT:2> <EOL> x_pos = self . GetScrollPos ( wx . HORIZONTAL ) <EOL> if item . _y < start_y + <NUM_LIT:3> : <EOL> self . SetScrollbars ( xUnit , yUnit , ( xUnit and [ x / xUnit ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] , ( yUnit and [ y / yUnit ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] , <EOL> x_pos , ( yUnit and [ item . _y / yUnit ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] ) <EOL> elif item . _y + self . GetLineHeight ( item ) > start_y + client_h : <EOL> item . _y += yUnit + <NUM_LIT:2> <EOL> self . SetScrollbars ( xUnit , yUnit , ( xUnit and [ x / xUnit ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] , ( yUnit and [ y / yUnit ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] , <EOL> x_pos , ( yUnit and [ ( item . _y + self . GetLineHeight ( item ) - client_h ) / yUnit ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] ) <EOL> def SetDragItem ( self , item ) : <EOL> """<STR_LIT>""" <EOL> prevItem = self . _dragItem <EOL> self . _dragItem = item <EOL> if prevItem : <EOL> self . RefreshLine ( prevItem ) <EOL> if self . _dragItem : <EOL> self . RefreshLine ( self . _dragItem ) <EOL> def AdjustMyScrollbars ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _anchor : <EOL> xUnit , yUnit = self . GetScrollPixelsPerUnit ( ) <EOL> if xUnit == <NUM_LIT:0> : <EOL> xUnit = self . GetCharWidth ( ) <EOL> if yUnit == <NUM_LIT:0> : <EOL> yUnit = self . _lineHeight <EOL> x , y = self . _anchor . GetSize ( <NUM_LIT:0> , <NUM_LIT:0> , self ) <EOL> y += yUnit + <NUM_LIT:2> <EOL> x_pos = self . GetScrollPos ( wx . HORIZONTAL ) <EOL> y_pos = self . GetScrollPos ( wx . VERTICAL ) <EOL> x = self . _owner . GetHeaderWindow ( ) . GetWidth ( ) + <NUM_LIT:2> <EOL> if x < self . GetClientSize ( ) . GetWidth ( ) : <EOL> x_pos = <NUM_LIT:0> <EOL> self . SetScrollbars ( xUnit , yUnit , x / xUnit , y / yUnit , x_pos , y_pos ) <EOL> else : <EOL> self . SetScrollbars ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> def PaintItem ( self , item , dc ) : <EOL> """<STR_LIT>""" <EOL> def _paintText ( text , textrect , alignment ) : <EOL> """<STR_LIT>""" <EOL> txt = text . splitlines ( ) <EOL> if alignment != wx . ALIGN_LEFT and len ( txt ) : <EOL> yorigin = textrect . Y <EOL> for t in txt : <EOL> w , h = dc . GetTextExtent ( t ) <EOL> plus = textrect . Width - w <EOL> if alignment == wx . ALIGN_CENTER : <EOL> plus /= <NUM_LIT:2> <EOL> dc . DrawLabel ( t , wx . Rect ( textrect . X + plus , yorigin , w , yorigin + h ) ) <EOL> yorigin += h <EOL> return <EOL> dc . DrawLabel ( text , textrect ) <EOL> attr = item . GetAttributes ( ) <EOL> if attr and attr . HasFont ( ) : <EOL> dc . SetFont ( attr . GetFont ( ) ) <EOL> elif item . IsBold ( ) : <EOL> dc . SetFont ( self . _boldFont ) <EOL> if item . IsHyperText ( ) : <EOL> dc . SetFont ( self . GetHyperTextFont ( ) ) <EOL> if item . GetVisited ( ) : <EOL> dc . SetTextForeground ( self . GetHyperTextVisitedColour ( ) ) <EOL> else : <EOL> dc . SetTextForeground ( self . GetHyperTextNewColour ( ) ) <EOL> colText = wx . Colour ( * dc . GetTextForeground ( ) ) <EOL> if item . IsSelected ( ) : <EOL> if ( wx . Platform == "<STR_LIT>" and self . _hasFocus ) : <EOL> colTextHilight = wx . SystemSettings_GetColour ( wx . SYS_COLOUR_HIGHLIGHTTEXT ) <EOL> else : <EOL> colTextHilight = wx . SystemSettings_GetColour ( wx . SYS_COLOUR_HIGHLIGHTTEXT ) <EOL> else : <EOL> attr = item . GetAttributes ( ) <EOL> if attr and attr . HasTextColour ( ) : <EOL> colText = attr . GetTextColour ( ) <EOL> if self . _vistaselection : <EOL> colText = colTextHilight = wx . BLACK <EOL> total_w = self . _owner . GetHeaderWindow ( ) . GetWidth ( ) <EOL> total_h = self . GetLineHeight ( item ) <EOL> off_h = ( self . HasAGWFlag ( wx . TR_ROW_LINES ) and [ <NUM_LIT:1> ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] <EOL> off_w = ( self . HasAGWFlag ( wx . TR_COLUMN_LINES ) and [ <NUM_LIT:1> ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] <EOL> text_w , text_h , dummy = dc . GetMultiLineTextExtent ( item . GetText ( self . GetMainColumn ( ) ) ) <EOL> drawItemBackground = False <EOL> if attr and attr . HasBackgroundColour ( ) : <EOL> colBg = attr . GetBackgroundColour ( ) <EOL> drawItemBackground = True <EOL> else : <EOL> colBg = self . _backgroundColour <EOL> dc . SetBrush ( wx . Brush ( colBg , wx . SOLID ) ) <EOL> dc . SetPen ( wx . TRANSPARENT_PEN ) <EOL> if self . HasAGWFlag ( wx . TR_FULL_ROW_HIGHLIGHT ) : <EOL> itemrect = wx . Rect ( <NUM_LIT:0> , item . GetY ( ) + off_h , total_w - <NUM_LIT:1> , total_h - off_h ) <EOL> if item == self . _dragItem : <EOL> dc . SetBrush ( self . _hilightBrush ) <EOL> if wx . Platform == "<STR_LIT>" : <EOL> dc . SetPen ( ( item == self . _dragItem ) and [ wx . BLACK_PEN ] or [ wx . TRANSPARENT_PEN ] ) [ <NUM_LIT:0> ] <EOL> dc . SetTextForeground ( colTextHilight ) <EOL> elif item . IsSelected ( ) : <EOL> wnd = item . GetWindow ( self . _main_column ) <EOL> wndx = <NUM_LIT:0> <EOL> if wnd : <EOL> wndx , wndy = item . GetWindowSize ( self . _main_column ) <EOL> itemrect = wx . Rect ( <NUM_LIT:0> , item . GetY ( ) + off_h , total_w - <NUM_LIT:1> , total_h - off_h ) <EOL> if self . _usegradients : <EOL> if self . _gradientstyle == <NUM_LIT:0> : <EOL> self . DrawHorizontalGradient ( dc , itemrect , self . _hasFocus ) <EOL> else : <EOL> self . DrawVerticalGradient ( dc , itemrect , self . _hasFocus ) <EOL> elif self . _vistaselection : <EOL> self . DrawVistaRectangle ( dc , itemrect , self . _hasFocus ) <EOL> else : <EOL> if wx . Platform in [ "<STR_LIT>" , "<STR_LIT>" ] : <EOL> flags = wx . CONTROL_SELECTED <EOL> if self . _hasFocus : flags = flags | wx . CONTROL_FOCUSED <EOL> wx . RendererNative . Get ( ) . DrawItemSelectionRect ( self . _owner , dc , itemrect , flags ) <EOL> else : <EOL> dc . SetBrush ( ( self . _hasFocus and [ self . _hilightBrush ] or [ self . _hilightUnfocusedBrush ] ) [ <NUM_LIT:0> ] ) <EOL> dc . SetPen ( ( self . _hasFocus and [ self . _borderPen ] or [ wx . TRANSPARENT_PEN ] ) [ <NUM_LIT:0> ] ) <EOL> dc . DrawRectangleRect ( itemrect ) <EOL> dc . SetTextForeground ( colTextHilight ) <EOL> elif drawItemBackground : <EOL> itemrect = wx . Rect ( <NUM_LIT:0> , item . GetY ( ) + off_h , total_w - <NUM_LIT:1> , total_h - off_h ) <EOL> dc . SetBrush ( wx . Brush ( colBg , wx . SOLID ) ) <EOL> dc . DrawRectangleRect ( itemrect ) <EOL> dc . SetTextForeground ( colText ) <EOL> else : <EOL> dc . SetTextForeground ( colText ) <EOL> else : <EOL> dc . SetTextForeground ( colText ) <EOL> text_extraH = ( total_h > text_h and [ ( total_h - text_h ) / <NUM_LIT:2> ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] <EOL> img_extraH = ( total_h > self . _imgHeight and [ ( total_h - self . _imgHeight ) / <NUM_LIT:2> ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] <EOL> x_colstart = <NUM_LIT:0> <EOL> for i in xrange ( self . GetColumnCount ( ) ) : <EOL> if not self . _owner . GetHeaderWindow ( ) . IsColumnShown ( i ) : <EOL> continue <EOL> col_w = self . _owner . GetHeaderWindow ( ) . GetColumnWidth ( i ) <EOL> dc . SetClippingRegion ( x_colstart , item . GetY ( ) , col_w , total_h ) <EOL> image = _NO_IMAGE <EOL> x = image_w = wcheck = hcheck = <NUM_LIT:0> <EOL> if i == self . GetMainColumn ( ) : <EOL> x = item . GetX ( ) + _MARGIN <EOL> if self . HasButtons ( ) : <EOL> x += ( self . _btnWidth - self . _btnWidth2 ) + _LINEATROOT <EOL> else : <EOL> x -= self . _indent / <NUM_LIT:2> <EOL> if self . _imageListNormal : <EOL> image = item . GetCurrentImage ( i ) <EOL> if item . GetType ( ) != <NUM_LIT:0> and self . _imageListCheck : <EOL> checkimage = item . GetCurrentCheckedImage ( ) <EOL> wcheck , hcheck = self . _imageListCheck . GetSize ( item . GetType ( ) ) <EOL> else : <EOL> wcheck , hcheck = <NUM_LIT:0> , <NUM_LIT:0> <EOL> else : <EOL> x = x_colstart + _MARGIN <EOL> image = item . GetImage ( column = i ) <EOL> if image != _NO_IMAGE : <EOL> image_w = self . _imgWidth + _MARGIN <EOL> text = item . GetText ( i ) <EOL> alignment = self . _owner . GetHeaderWindow ( ) . GetColumn ( i ) . GetAlignment ( ) <EOL> text_w , dummy , dummy = dc . GetMultiLineTextExtent ( text ) <EOL> if alignment == wx . ALIGN_RIGHT : <EOL> w = col_w - ( image_w + wcheck + text_w + off_w + _MARGIN + <NUM_LIT:1> ) <EOL> x += ( w > <NUM_LIT:0> and [ w ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] <EOL> elif alignment == wx . ALIGN_CENTER : <EOL> w = ( col_w - ( image_w + wcheck + text_w + off_w + _MARGIN ) ) / <NUM_LIT:2> <EOL> x += ( w > <NUM_LIT:0> and [ w ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] <EOL> else : <EOL> if not item . HasPlus ( ) and image_w == <NUM_LIT:0> and wcheck : <EOL> x += <NUM_LIT:3> * _MARGIN <EOL> text_x = x + image_w + wcheck + <NUM_LIT:1> <EOL> if i == self . GetMainColumn ( ) : <EOL> item . SetTextX ( text_x ) <EOL> if not self . HasAGWFlag ( wx . TR_FULL_ROW_HIGHLIGHT ) : <EOL> dc . SetBrush ( ( self . _hasFocus and [ self . _hilightBrush ] or [ self . _hilightUnfocusedBrush ] ) [ <NUM_LIT:0> ] ) <EOL> dc . SetPen ( ( self . _hasFocus and [ self . _borderPen ] or [ wx . TRANSPARENT_PEN ] ) [ <NUM_LIT:0> ] ) <EOL> if i == self . GetMainColumn ( ) : <EOL> if item == self . _dragItem : <EOL> if wx . Platform == "<STR_LIT>" : <EOL> dc . SetPen ( ( item == self . _dragItem and [ wx . BLACK_PEN ] or [ wx . TRANSPARENT_PEN ] ) [ <NUM_LIT:0> ] ) <EOL> dc . SetTextForeground ( colTextHilight ) <EOL> elif item . IsSelected ( ) : <EOL> itemrect = wx . Rect ( text_x - <NUM_LIT:2> , item . GetY ( ) + off_h , text_w + <NUM_LIT:2> * _MARGIN , total_h - off_h ) <EOL> if self . _usegradients : <EOL> if self . _gradientstyle == <NUM_LIT:0> : <EOL> self . DrawHorizontalGradient ( dc , itemrect , self . _hasFocus ) <EOL> else : <EOL> self . DrawVerticalGradient ( dc , itemrect , self . _hasFocus ) <EOL> elif self . _vistaselection : <EOL> self . DrawVistaRectangle ( dc , itemrect , self . _hasFocus ) <EOL> else : <EOL> if wx . Platform in [ "<STR_LIT>" , "<STR_LIT>" ] : <EOL> flags = wx . CONTROL_SELECTED <EOL> if self . _hasFocus : flags = flags | wx . CONTROL_FOCUSED <EOL> wx . RendererNative . Get ( ) . DrawItemSelectionRect ( self . _owner , dc , itemrect , flags ) <EOL> else : <EOL> dc . DrawRectangleRect ( itemrect ) <EOL> dc . SetTextForeground ( colTextHilight ) <EOL> elif item == self . _current : <EOL> dc . SetPen ( ( self . _hasFocus and [ wx . BLACK_PEN ] or [ wx . TRANSPARENT_PEN ] ) [ <NUM_LIT:0> ] ) <EOL> elif drawItemBackground : <EOL> itemrect = wx . Rect ( text_x - <NUM_LIT:2> , item . GetY ( ) + off_h , text_w + <NUM_LIT:2> * _MARGIN , total_h - off_h ) <EOL> dc . SetBrush ( wx . Brush ( colBg , wx . SOLID ) ) <EOL> dc . DrawRectangleRect ( itemrect ) <EOL> else : <EOL> dc . SetTextForeground ( colText ) <EOL> else : <EOL> dc . SetTextForeground ( colText ) <EOL> if self . HasAGWFlag ( wx . TR_COLUMN_LINES ) : <EOL> pen = wx . Pen ( wx . SystemSettings_GetColour ( wx . SYS_COLOUR_3DLIGHT ) , <NUM_LIT:1> , wx . SOLID ) <EOL> dc . SetPen ( ( self . GetBackgroundColour ( ) == wx . WHITE and [ pen ] or [ wx . WHITE_PEN ] ) [ <NUM_LIT:0> ] ) <EOL> dc . DrawLine ( x_colstart + col_w - <NUM_LIT:1> , item . GetY ( ) , x_colstart + col_w - <NUM_LIT:1> , item . GetY ( ) + total_h ) <EOL> dc . SetBackgroundMode ( wx . TRANSPARENT ) <EOL> if image != _NO_IMAGE : <EOL> y = item . GetY ( ) + img_extraH <EOL> if wcheck : <EOL> x += wcheck <EOL> if item . IsEnabled ( ) : <EOL> imglist = self . _imageListNormal <EOL> else : <EOL> imglist = self . _grayedImageList <EOL> imglist . Draw ( image , dc , x , y , wx . IMAGELIST_DRAW_TRANSPARENT ) <EOL> if wcheck : <EOL> if item . IsEnabled ( ) : <EOL> imglist = self . _imageListCheck <EOL> else : <EOL> imglist = self . _grayedCheckList <EOL> if self . HasButtons ( ) : <EOL> btnWidth = self . _btnWidth <EOL> else : <EOL> btnWidth = - self . _btnWidth <EOL> imglist . Draw ( checkimage , dc , <EOL> item . GetX ( ) + btnWidth + _MARGIN , <EOL> item . GetY ( ) + ( ( total_h > hcheck ) and [ ( total_h - hcheck ) / <NUM_LIT:2> ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] + <NUM_LIT:1> , <EOL> wx . IMAGELIST_DRAW_TRANSPARENT ) <EOL> text_w , text_h , dummy = dc . GetMultiLineTextExtent ( text ) <EOL> text_extraH = ( total_h > text_h and [ ( total_h - text_h ) / <NUM_LIT:2> ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] <EOL> text_y = item . GetY ( ) + text_extraH <EOL> textrect = wx . Rect ( text_x , text_y , text_w , text_h ) <EOL> if not item . IsEnabled ( ) : <EOL> foreground = dc . GetTextForeground ( ) <EOL> dc . SetTextForeground ( self . _disabledColour ) <EOL> _paintText ( text , textrect , alignment ) <EOL> dc . SetTextForeground ( foreground ) <EOL> else : <EOL> if wx . Platform == "<STR_LIT>" and item . IsSelected ( ) and self . _hasFocus : <EOL> dc . SetTextForeground ( wx . WHITE ) <EOL> _paintText ( text , textrect , alignment ) <EOL> wnd = item . GetWindow ( i ) <EOL> if wnd : <EOL> if text_w == <NUM_LIT:0> : <EOL> wndx = text_x <EOL> else : <EOL> wndx = text_x + text_w + <NUM_LIT:2> * _MARGIN <EOL> xa , ya = self . CalcScrolledPosition ( ( <NUM_LIT:0> , item . GetY ( ) ) ) <EOL> wndx += xa <EOL> if item . GetHeight ( ) > item . GetWindowSize ( i ) [ <NUM_LIT:1> ] : <EOL> ya += ( item . GetHeight ( ) - item . GetWindowSize ( i ) [ <NUM_LIT:1> ] ) / <NUM_LIT:2> <EOL> if not wnd . IsShown ( ) : <EOL> wnd . Show ( ) <EOL> if wnd . GetPosition ( ) != ( wndx , ya ) : <EOL> wnd . SetPosition ( ( wndx , ya ) ) <EOL> x_colstart += col_w <EOL> dc . DestroyClippingRegion ( ) <EOL> dc . SetFont ( self . _normalFont ) <EOL> def PaintLevel ( self , item , dc , level , y , x_maincol ) : <EOL> """<STR_LIT>""" <EOL> if item . IsHidden ( ) : <EOL> return y , x_maincol <EOL> if self . HasAGWFlag ( wx . TR_HIDE_ROOT ) and level == <NUM_LIT:0> : <EOL> for child in item . GetChildren ( ) : <EOL> y , x_maincol = self . PaintLevel ( child , dc , <NUM_LIT:1> , y , x_maincol ) <EOL> return y , x_maincol <EOL> x = x_maincol + _MARGIN <EOL> if self . HasAGWFlag ( wx . TR_LINES_AT_ROOT ) : <EOL> x += _LINEATROOT <EOL> if self . HasButtons ( ) : <EOL> x += ( self . _btnWidth - self . _btnWidth2 ) <EOL> else : <EOL> x += ( self . _indent - self . _indent / <NUM_LIT:2> ) <EOL> if self . HasAGWFlag ( wx . TR_HIDE_ROOT ) : <EOL> x += self . _indent * ( level - <NUM_LIT:1> ) <EOL> else : <EOL> x += self . _indent * level <EOL> item . SetX ( x ) <EOL> item . SetY ( y ) <EOL> h = self . GetLineHeight ( item ) <EOL> y_top = y <EOL> y_mid = y_top + ( h / <NUM_LIT:2> ) <EOL> y += h <EOL> exposed_x = dc . LogicalToDeviceX ( <NUM_LIT:0> ) <EOL> exposed_y = dc . LogicalToDeviceY ( y_top ) <EOL> draw_row_lines = self . HasAGWFlag ( wx . TR_ROW_LINES ) <EOL> if self . IsExposed ( exposed_x , exposed_y , _MAX_WIDTH , h + draw_row_lines ) : <EOL> if draw_row_lines : <EOL> total_width = self . _owner . GetHeaderWindow ( ) . GetWidth ( ) <EOL> pen = wx . Pen ( wx . SystemSettings_GetColour ( wx . SYS_COLOUR_3DLIGHT ) , <NUM_LIT:1> , wx . SOLID ) <EOL> dc . SetPen ( ( self . GetBackgroundColour ( ) == wx . WHITE and [ pen ] or [ wx . WHITE_PEN ] ) [ <NUM_LIT:0> ] ) <EOL> dc . DrawLine ( <NUM_LIT:0> , y_top , total_width , y_top ) <EOL> dc . DrawLine ( <NUM_LIT:0> , y_top + h , total_width , y_top + h ) <EOL> self . PaintItem ( item , dc ) <EOL> dc . SetBrush ( wx . WHITE_BRUSH ) <EOL> dc . SetPen ( self . _dottedPen ) <EOL> clip_width = self . _owner . GetHeaderWindow ( ) . GetColumn ( self . _main_column ) . GetWidth ( ) <EOL> if not self . HasAGWFlag ( wx . TR_NO_LINES ) : <EOL> dc . SetPen ( self . _dottedPen ) <EOL> x2 = x - self . _indent <EOL> if x2 < ( x_maincol + _MARGIN ) : <EOL> x2 = x_maincol + _MARGIN <EOL> x3 = x + ( self . _btnWidth - self . _btnWidth2 ) <EOL> if self . HasButtons ( ) : <EOL> if item . HasPlus ( ) : <EOL> dc . DrawLine ( x2 , y_mid , x - self . _btnWidth2 , y_mid ) <EOL> dc . DrawLine ( x3 , y_mid , x3 + _LINEATROOT , y_mid ) <EOL> else : <EOL> dc . DrawLine ( x2 , y_mid , x3 + _LINEATROOT , y_mid ) <EOL> else : <EOL> dc . DrawLine ( x2 , y_mid , x - self . _indent / <NUM_LIT:2> , y_mid ) <EOL> if item . HasPlus ( ) and self . HasButtons ( ) : <EOL> if self . _imageListButtons : <EOL> image = wx . TreeItemIcon_Normal <EOL> if item . IsExpanded ( ) : <EOL> image = wx . TreeItemIcon_Expanded <EOL> if item . IsSelected ( ) : <EOL> image += wx . TreeItemIcon_Selected - wx . TreeItemIcon_Normal <EOL> xx = x - self . _btnWidth2 + _MARGIN <EOL> yy = y_mid - self . _btnHeight2 <EOL> dc . SetClippingRegion ( xx , yy , self . _btnWidth , self . _btnHeight ) <EOL> self . _imageListButtons . Draw ( image , dc , xx , yy , wx . IMAGELIST_DRAW_TRANSPARENT ) <EOL> dc . DestroyClippingRegion ( ) <EOL> elif self . HasAGWFlag ( wx . TR_TWIST_BUTTONS ) : <EOL> dc . SetPen ( wx . BLACK_PEN ) <EOL> dc . SetBrush ( self . _hilightBrush ) <EOL> button = [ wx . Point ( ) for j in xrange ( <NUM_LIT:3> ) ] <EOL> if item . IsExpanded ( ) : <EOL> button [ <NUM_LIT:0> ] . x = x - ( self . _btnWidth2 + <NUM_LIT:1> ) <EOL> button [ <NUM_LIT:0> ] . y = y_mid - ( self . _btnHeight / <NUM_LIT:3> ) <EOL> button [ <NUM_LIT:1> ] . x = x + ( self . _btnWidth2 + <NUM_LIT:1> ) <EOL> button [ <NUM_LIT:1> ] . y = button [ <NUM_LIT:0> ] . y <EOL> button [ <NUM_LIT:2> ] . x = x <EOL> button [ <NUM_LIT:2> ] . y = button [ <NUM_LIT:0> ] . y + ( self . _btnHeight2 + <NUM_LIT:1> ) <EOL> else : <EOL> button [ <NUM_LIT:0> ] . x = x - ( self . _btnWidth / <NUM_LIT:3> ) <EOL> button [ <NUM_LIT:0> ] . y = y_mid - ( self . _btnHeight2 + <NUM_LIT:1> ) <EOL> button [ <NUM_LIT:1> ] . x = button [ <NUM_LIT:0> ] . x <EOL> button [ <NUM_LIT:1> ] . y = y_mid + ( self . _btnHeight2 + <NUM_LIT:1> ) <EOL> button [ <NUM_LIT:2> ] . x = button [ <NUM_LIT:0> ] . x + ( self . _btnWidth2 + <NUM_LIT:1> ) <EOL> button [ <NUM_LIT:2> ] . y = y_mid <EOL> dc . DrawPolygon ( button ) <EOL> else : <EOL> rect = wx . Rect ( x - self . _btnWidth2 , y_mid - self . _btnHeight2 , self . _btnWidth , self . _btnHeight ) <EOL> flag = ( item . IsExpanded ( ) and [ wx . CONTROL_EXPANDED ] or [ <NUM_LIT:0> ] ) [ <NUM_LIT:0> ] <EOL> wx . RendererNative . GetDefault ( ) . DrawTreeItemButton ( self , dc , rect , flag ) <EOL> dc . SetBrush ( wx . WHITE_BRUSH ) <EOL> dc . SetPen ( self . _dottedPen ) <EOL> dc . SetTextForeground ( wx . BLACK ) <EOL> if item . IsExpanded ( ) : <EOL> if self . _imgWidth > <NUM_LIT:0> : <EOL> oldY = y_mid + self . _imgHeight2 <EOL> else : <EOL> oldY = y_mid + h / <NUM_LIT:2> <EOL> for child in item . GetChildren ( ) : <EOL> y , x_maincol = self . PaintLevel ( child , dc , level + <NUM_LIT:1> , y , x_maincol ) <EOL> if not self . HasAGWFlag ( wx . TR_NO_LINES ) : <EOL> Y1 = child . GetY ( ) + child . GetHeight ( ) / <NUM_LIT:2> <EOL> dc . DrawLine ( x , oldY , x , Y1 ) <EOL> return y , x_maincol <EOL> def OnEraseBackground ( self , event ) : <EOL> """<STR_LIT>""" <EOL> if not self . _buffered : <EOL> CustomTreeCtrl . OnEraseBackground ( self , event ) <EOL> def OnPaint ( self , event ) : <EOL> """<STR_LIT>""" <EOL> if self . _buffered : <EOL> dc = wx . BufferedPaintDC ( self ) <EOL> rect = self . GetUpdateRegion ( ) . GetBox ( ) <EOL> dc . SetClippingRect ( rect ) <EOL> dc . SetBackground ( wx . Brush ( self . GetBackgroundColour ( ) ) ) <EOL> if self . _backgroundImage : <EOL> self . TileBackground ( dc ) <EOL> else : <EOL> dc . Clear ( ) <EOL> else : <EOL> dc = wx . PaintDC ( self ) <EOL> self . PrepareDC ( dc ) <EOL> if not self . _anchor or self . GetColumnCount ( ) <= <NUM_LIT:0> : <EOL> return <EOL> if self . _imageListButtons : <EOL> self . _btnWidth , self . _btnHeight = self . _imageListButtons . GetSize ( <NUM_LIT:0> ) <EOL> elif self . HasButtons ( ) : <EOL> self . _btnWidth = _BTNWIDTH <EOL> self . _btnHeight = _BTNHEIGHT <EOL> self . _btnWidth2 = self . _btnWidth / <NUM_LIT:2> <EOL> self . _btnHeight2 = self . _btnHeight / <NUM_LIT:2> <EOL> if self . _imageListNormal : <EOL> self . _imgWidth , self . _imgHeight = self . _imageListNormal . GetSize ( <NUM_LIT:0> ) <EOL> self . _imgWidth2 = self . _imgWidth / <NUM_LIT:2> <EOL> self . _imgHeight2 = self . _imgHeight / <NUM_LIT:2> <EOL> if self . _imageListCheck : <EOL> self . _checkWidth , self . _checkHeight = self . _imageListCheck . GetSize ( <NUM_LIT:0> ) <EOL> self . _checkWidth2 = self . _checkWidth / <NUM_LIT:2> <EOL> self . _checkHeight2 = self . _checkHeight / <NUM_LIT:2> <EOL> if self . _imageListButtons : <EOL> self . _indent = max ( _MININDENT , self . _btnWidth + _MARGIN ) <EOL> elif self . HasButtons ( ) : <EOL> self . _indent = max ( _MININDENT , self . _btnWidth + _LINEATROOT ) <EOL> dc . SetFont ( self . _normalFont ) <EOL> dc . SetPen ( self . _dottedPen ) <EOL> x_maincol = <NUM_LIT:0> <EOL> for i in xrange ( self . GetMainColumn ( ) ) : <EOL> if not self . _owner . GetHeaderWindow ( ) . IsColumnShown ( i ) : <EOL> continue <EOL> x_maincol += self . _owner . GetHeaderWindow ( ) . GetColumnWidth ( i ) <EOL> y , x_maincol = self . PaintLevel ( self . _anchor , dc , <NUM_LIT:0> , <NUM_LIT:0> , x_maincol ) <EOL> def HitTest ( self , point , flags = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> w , h = self . GetSize ( ) <EOL> column = - <NUM_LIT:1> <EOL> if not isinstance ( point , wx . Point ) : <EOL> point = wx . Point ( * point ) <EOL> if point . x < <NUM_LIT:0> : <EOL> flags |= wx . TREE_HITTEST_TOLEFT <EOL> if point . x > w : <EOL> flags |= wx . TREE_HITTEST_TORIGHT <EOL> if point . y < <NUM_LIT:0> : <EOL> flags |= wx . TREE_HITTEST_ABOVE <EOL> if point . y > h : <EOL> flags |= wx . TREE_HITTEST_BELOW <EOL> if flags : <EOL> return None , flags , column <EOL> if not self . _anchor : <EOL> flags = wx . TREE_HITTEST_NOWHERE <EOL> column = - <NUM_LIT:1> <EOL> return None , flags , column <EOL> hit , flags , column = self . _anchor . HitTest ( self . CalcUnscrolledPosition ( point ) , self , flags , column , <NUM_LIT:0> ) <EOL> if not hit : <EOL> flags = wx . TREE_HITTEST_NOWHERE <EOL> column = - <NUM_LIT:1> <EOL> return None , flags , column <EOL> return hit , flags , column <EOL> def EditLabel ( self , item , column = None ) : <EOL> """<STR_LIT>""" <EOL> if not item : <EOL> return <EOL> column = ( column is not None and [ column ] or [ self . _main_column ] ) [ <NUM_LIT:0> ] <EOL> if column < <NUM_LIT:0> or column >= self . GetColumnCount ( ) : <EOL> return <EOL> self . _editItem = item <EOL> te = TreeEvent ( wx . wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT , self . _owner . GetId ( ) ) <EOL> te . SetItem ( self . _editItem ) <EOL> te . SetInt ( column ) <EOL> te . SetEventObject ( self . _owner ) <EOL> self . _owner . GetEventHandler ( ) . ProcessEvent ( te ) <EOL> if not te . IsAllowed ( ) : <EOL> return <EOL> if self . _dirty : <EOL> self . CalculatePositions ( ) <EOL> header_win = self . _owner . GetHeaderWindow ( ) <EOL> alignment = header_win . GetColumnAlignment ( column ) <EOL> if alignment == wx . ALIGN_LEFT : <EOL> style = wx . TE_LEFT <EOL> elif alignment == wx . ALIGN_RIGHT : <EOL> style = wx . TE_RIGHT <EOL> elif alignment == wx . ALIGN_CENTER : <EOL> style = wx . TE_CENTER <EOL> if self . _textCtrl != None and ( item != self . _textCtrl . item ( ) or column != self . _textCtrl . column ( ) ) : <EOL> self . _textCtrl . StopEditing ( ) <EOL> self . _textCtrl = EditTextCtrl ( self , - <NUM_LIT:1> , self . _editItem , column , <EOL> self , self . _editItem . GetText ( column ) , <EOL> style = style | wx . TE_PROCESS_ENTER ) <EOL> self . _textCtrl . SetFocus ( ) <EOL> def OnRenameTimer ( self ) : <EOL> """<STR_LIT>""" <EOL> self . EditLabel ( self . _current , self . _curColumn ) <EOL> def OnRenameAccept ( self , value ) : <EOL> """<STR_LIT>""" <EOL> le = TreeEvent ( wx . wxEVT_COMMAND_TREE_END_LABEL_EDIT , self . _owner . GetId ( ) ) <EOL> le . SetItem ( self . _editItem ) <EOL> le . SetEventObject ( self . _owner ) <EOL> le . SetLabel ( value ) <EOL> le . _editCancelled = False <EOL> self . _owner . GetEventHandler ( ) . ProcessEvent ( le ) <EOL> if not le . IsAllowed ( ) : <EOL> return <EOL> if self . _curColumn == - <NUM_LIT:1> : <EOL> self . _curColumn = <NUM_LIT:0> <EOL> self . SetItemText ( self . _editItem , value , self . _curColumn ) <EOL> def OnRenameCancelled ( self ) : <EOL> """<STR_LIT>""" <EOL> le = TreeEvent ( wx . wxEVT_COMMAND_TREE_END_LABEL_EDIT , self . _owner . GetId ( ) ) <EOL> le . SetItem ( self . _editItem ) <EOL> le . SetEventObject ( self . _owner ) <EOL> le . SetLabel ( "<STR_LIT>" ) <EOL> le . _editCancelled = True <EOL> self . _owner . GetEventHandler ( ) . ProcessEvent ( le ) <EOL> def OnMouse ( self , event ) : <EOL> """<STR_LIT>""" <EOL> if not self . _anchor : <EOL> return <EOL> if not ( event . LeftDown ( ) or event . LeftUp ( ) or event . RightDown ( ) or event . RightUp ( ) or event . LeftDClick ( ) or event . Dragging ( ) or event . GetWheelRotation ( ) != <NUM_LIT:0> or event . Moving ( ) ) : <EOL> self . _owner . GetEventHandler ( ) . ProcessEvent ( event ) <EOL> return <EOL> if event . LeftDown ( ) or event . RightDown ( ) : <EOL> self . _hasFocus = True <EOL> self . SetFocusIgnoringChildren ( ) <EOL> p = wx . Point ( event . GetX ( ) , event . GetY ( ) ) <EOL> flags = <NUM_LIT:0> <EOL> item , flags , column = self . _anchor . HitTest ( self . CalcUnscrolledPosition ( p ) , self , flags , self . _curColumn , <NUM_LIT:0> ) <EOL> underMouse = item <EOL> underMouseChanged = underMouse != self . _underMouse <EOL> if underMouse and ( flags & wx . TREE_HITTEST_ONITEM ) and not event . LeftIsDown ( ) and not self . _isDragging and ( not self . _renameTimer or not self . _renameTimer . IsRunning ( ) ) : <EOL> underMouse = underMouse <EOL> else : <EOL> underMouse = None <EOL> if underMouse != self . _underMouse : <EOL> if self . _underMouse : <EOL> self . _underMouse = None <EOL> self . _underMouse = underMouse <EOL> hoverItem = item <EOL> if ( event . LeftDown ( ) or event . LeftUp ( ) or event . RightDown ( ) or event . RightUp ( ) or event . LeftDClick ( ) or event . Dragging ( ) ) : <EOL> if self . _textCtrl != None and item != self . _textCtrl . item ( ) : <EOL> self . _textCtrl . StopEditing ( ) <EOL> if underMouseChanged and not self . _isDragging and ( not self . _renameTimer or not self . _renameTimer . IsRunning ( ) ) : <EOL> if hoverItem is not None : <EOL> hevent = TreeEvent ( wx . wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP , self . GetId ( ) ) <EOL> hevent . SetItem ( hoverItem ) <EOL> hevent . SetEventObject ( self ) <EOL> if self . GetEventHandler ( ) . ProcessEvent ( hevent ) and hevent . IsAllowed ( ) : <EOL> self . SetToolTip ( hevent . _label ) <EOL> if hoverItem . IsHyperText ( ) and ( flags & wx . TREE_HITTEST_ONITEMLABEL ) and hoverItem . IsEnabled ( ) : <EOL> self . SetCursor ( wx . StockCursor ( wx . CURSOR_HAND ) ) <EOL> self . _isonhyperlink = True <EOL> else : <EOL> if self . _isonhyperlink : <EOL> self . SetCursor ( wx . StockCursor ( wx . CURSOR_ARROW ) ) <EOL> self . _isonhyperlink = False <EOL> if event . Dragging ( ) : <EOL> if self . _isDragging : <EOL> if not self . _dragImage : <EOL> self . _dragImage = DragImage ( self , self . _current or item ) <EOL> self . _dragImage . BeginDrag ( wx . Point ( <NUM_LIT:0> , <NUM_LIT:0> ) , self ) <EOL> self . _dragImage . Show ( ) <EOL> self . _dragImage . Move ( p ) <EOL> if self . _countDrag == <NUM_LIT:0> and item : <EOL> self . _oldItem = self . _current <EOL> self . _oldSelection = self . _current <EOL> if item != self . _dropTarget : <EOL> if self . _dropTarget : <EOL> self . _dropTarget . SetHilight ( False ) <EOL> self . RefreshLine ( self . _dropTarget ) <EOL> if item : <EOL> item . SetHilight ( True ) <EOL> self . RefreshLine ( item ) <EOL> self . _countDrag = self . _countDrag + <NUM_LIT:1> <EOL> self . _dropTarget = item <EOL> self . Update ( ) <EOL> if self . _countDrag >= <NUM_LIT:3> and self . _oldItem is not None : <EOL> self . RefreshLine ( self . _oldItem ) <EOL> self . _countDrag = <NUM_LIT:0> <EOL> return <EOL> if item == None : <EOL> return <EOL> if self . _dragCount == <NUM_LIT:0> : <EOL> self . _dragTimer . Start ( _DRAG_TIMER_TICKS , wx . TIMER_ONE_SHOT ) <EOL> self . _dragCount += <NUM_LIT:1> <EOL> if self . _dragCount < <NUM_LIT:3> : <EOL> return <EOL> if self . _dragTimer . IsRunning ( ) : <EOL> return <EOL> self . _dragCount = <NUM_LIT:0> <EOL> command = ( event . LeftIsDown ( ) and [ wx . wxEVT_COMMAND_TREE_BEGIN_DRAG ] or [ wx . wxEVT_COMMAND_TREE_BEGIN_RDRAG ] ) [ <NUM_LIT:0> ] <EOL> nevent = TreeEvent ( command , self . _owner . GetId ( ) ) <EOL> nevent . SetEventObject ( self . _owner ) <EOL> nevent . SetItem ( self . _current ) <EOL> nevent . SetPoint ( p ) <EOL> nevent . Veto ( ) <EOL> if self . GetEventHandler ( ) . ProcessEvent ( nevent ) and nevent . IsAllowed ( ) : <EOL> self . _isDragging = True <EOL> self . CaptureMouse ( ) <EOL> self . RefreshSelected ( ) <EOL> if not ( self . _agwStyle & wx . TR_MULTIPLE ) : <EOL> if self . _oldSelection : <EOL> self . _oldSelection . SetHilight ( False ) <EOL> self . RefreshLine ( self . _oldSelection ) <EOL> else : <EOL> selections = self . GetSelections ( ) <EOL> if len ( selections ) == <NUM_LIT:1> : <EOL> self . _oldSelection = selections [ <NUM_LIT:0> ] <EOL> self . _oldSelection . SetHilight ( False ) <EOL> self . RefreshLine ( self . _oldSelection ) <EOL> elif self . _isDragging : <EOL> self . _dragCount = <NUM_LIT:0> <EOL> self . _isDragging = False <EOL> if self . HasCapture ( ) : <EOL> self . ReleaseMouse ( ) <EOL> self . RefreshSelected ( ) <EOL> nevent = TreeEvent ( wx . wxEVT_COMMAND_TREE_END_DRAG , self . _owner . GetId ( ) ) <EOL> nevent . SetEventObject ( self . _owner ) <EOL> nevent . SetItem ( item ) <EOL> nevent . SetPoint ( p ) <EOL> self . _owner . GetEventHandler ( ) . ProcessEvent ( nevent ) <EOL> if self . _dragImage : <EOL> self . _dragImage . EndDrag ( ) <EOL> if self . _dropTarget : <EOL> self . _dropTarget . SetHilight ( False ) <EOL> self . RefreshLine ( self . _dropTarget ) <EOL> if self . _oldSelection : <EOL> self . _oldSelection . SetHilight ( True ) <EOL> self . RefreshLine ( self . _oldSelection ) <EOL> self . _oldSelection = None <EOL> self . _isDragging = False <EOL> self . _dropTarget = None <EOL> if self . _dragImage : <EOL> self . _dragImage = None <EOL> self . Refresh ( ) <EOL> elif self . _dragCount > <NUM_LIT:0> : <EOL> self . _dragCount = <NUM_LIT:0> <EOL> if item == None or not self . IsItemEnabled ( item ) : <EOL> self . _owner . GetEventHandler ( ) . ProcessEvent ( event ) <EOL> return <EOL> if event . ShiftDown ( ) : <EOL> if not self . _shiftItem : <EOL> self . _shiftItem = self . _current <EOL> else : <EOL> self . _shiftItem = None <EOL> if event . RightUp ( ) : <EOL> self . SetFocus ( ) <EOL> nevent = TreeEvent ( wx . wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK , self . _owner . GetId ( ) ) <EOL> nevent . SetEventObject ( self . _owner ) <EOL> nevent . SetItem ( item ) <EOL> nevent . SetInt ( self . _curColumn ) <EOL> nevent . SetPoint ( p ) <EOL> self . _owner . GetEventHandler ( ) . ProcessEvent ( nevent ) <EOL> elif event . LeftUp ( ) : <EOL> if self . _lastOnSame : <EOL> if item == self . _current and self . _curColumn != - <NUM_LIT:1> and self . _owner . GetHeaderWindow ( ) . IsColumnEditable ( self . _curColumn ) and flags & ( wx . TREE_HITTEST_ONITEMLABEL | wx . TREE_HITTEST_ONITEMCOLUMN ) : <EOL> self . _renameTimer . Start ( _RENAME_TIMER_TICKS , wx . TIMER_ONE_SHOT ) <EOL> self . _lastOnSame = False <EOL> if ( ( ( flags & wx . TREE_HITTEST_ONITEMBUTTON ) or ( flags & wx . TREE_HITTEST_ONITEMICON ) ) and self . HasButtons ( ) and item . HasPlus ( ) ) : <EOL> if event . LeftDown ( ) : <EOL> self . Toggle ( item ) <EOL> return <EOL> if not self . _left_down_selection : <EOL> unselect_others = not ( ( event . ShiftDown ( ) or event . ControlDown ( ) ) and self . HasAGWFlag ( wx . TR_MULTIPLE ) ) <EOL> self . DoSelectItem ( item , unselect_others , event . ShiftDown ( ) ) <EOL> self . EnsureVisible ( item ) <EOL> self . _current = self . _key_current = item <EOL> else : <EOL> self . _left_down_selection = False <EOL> elif event . LeftDown ( ) or event . RightDown ( ) or event . LeftDClick ( ) : <EOL> if column >= <NUM_LIT:0> : <EOL> self . _curColumn = column <EOL> if event . LeftDown ( ) or event . RightDown ( ) : <EOL> self . SetFocus ( ) <EOL> self . _lastOnSame = item == self . _current <EOL> if ( ( ( flags & wx . TREE_HITTEST_ONITEMBUTTON ) or ( flags & wx . TREE_HITTEST_ONITEMICON ) ) and self . HasButtons ( ) and item . HasPlus ( ) ) : <EOL> if event . LeftDown ( ) : <EOL> self . Toggle ( item ) <EOL> return <EOL> if flags & TREE_HITTEST_ONITEMCHECKICON and event . LeftDown ( ) : <EOL> if item . GetType ( ) > <NUM_LIT:0> : <EOL> if self . IsItem3State ( item ) : <EOL> checked = self . GetItem3StateValue ( item ) <EOL> checked = ( checked + <NUM_LIT:1> ) % <NUM_LIT:3> <EOL> else : <EOL> checked = not self . IsItemChecked ( item ) <EOL> self . CheckItem ( item , checked ) <EOL> return <EOL> if not item . IsSelected ( ) : <EOL> unselect_others = not ( ( event . ShiftDown ( ) or event . ControlDown ( ) ) and self . HasAGWFlag ( wx . TR_MULTIPLE ) ) <EOL> self . DoSelectItem ( item , unselect_others , event . ShiftDown ( ) ) <EOL> self . EnsureVisible ( item ) <EOL> self . _current = self . _key_current = item <EOL> self . _left_down_selection = True <EOL> if event . LeftDClick ( ) : <EOL> self . _renameTimer . Stop ( ) <EOL> self . _lastOnSame = False <EOL> nevent = TreeEvent ( wx . wxEVT_COMMAND_TREE_ITEM_ACTIVATED , self . _owner . GetId ( ) ) <EOL> nevent . SetEventObject ( self . _owner ) <EOL> nevent . SetItem ( item ) <EOL> nevent . SetInt ( self . _curColumn ) <EOL> nevent . SetPoint ( p ) <EOL> if not self . _owner . GetEventHandler ( ) . ProcessEvent ( nevent ) : <EOL> if item . HasPlus ( ) : <EOL> self . Toggle ( item ) <EOL> else : <EOL> event . Skip ( ) <EOL> def OnScroll ( self , event ) : <EOL> """<STR_LIT>""" <EOL> self . _default_evt_handler . ProcessEvent ( event ) <EOL> if event . GetOrientation ( ) == wx . HORIZONTAL : <EOL> self . _owner . GetHeaderWindow ( ) . Refresh ( ) <EOL> self . _owner . GetHeaderWindow ( ) . Update ( ) <EOL> def CalculateSize ( self , item , dc ) : <EOL> """<STR_LIT>""" <EOL> attr = item . GetAttributes ( ) <EOL> if attr and attr . HasFont ( ) : <EOL> dc . SetFont ( attr . GetFont ( ) ) <EOL> elif item . IsBold ( ) : <EOL> dc . SetFont ( self . _boldFont ) <EOL> else : <EOL> dc . SetFont ( self . _normalFont ) <EOL> text_w = text_h = wnd_w = wnd_h = <NUM_LIT:0> <EOL> for column in xrange ( self . GetColumnCount ( ) ) : <EOL> w , h , dummy = dc . GetMultiLineTextExtent ( item . GetText ( column ) ) <EOL> text_w , text_h = max ( w , text_w ) , max ( h , text_h ) <EOL> wnd = item . GetWindow ( column ) <EOL> if wnd : <EOL> wnd_h = max ( wnd_h , item . GetWindowSize ( column ) [ <NUM_LIT:1> ] ) <EOL> if column == self . _main_column : <EOL> wnd_w = item . GetWindowSize ( column ) [ <NUM_LIT:0> ] <EOL> text_w , dummy , dummy = dc . GetMultiLineTextExtent ( item . GetText ( self . _main_column ) ) <EOL> text_h += <NUM_LIT:2> <EOL> dc . SetFont ( self . _normalFont ) <EOL> image_w , image_h = <NUM_LIT:0> , <NUM_LIT:0> <EOL> image = item . GetCurrentImage ( ) <EOL> if image != _NO_IMAGE : <EOL> if self . _imageListNormal : <EOL> image_w , image_h = self . _imageListNormal . GetSize ( image ) <EOL> image_w += <NUM_LIT:2> * _MARGIN <EOL> total_h = ( ( image_h > text_h ) and [ image_h ] or [ text_h ] ) [ <NUM_LIT:0> ] <EOL> checkimage = item . GetCurrentCheckedImage ( ) <EOL> if checkimage is not None : <EOL> wcheck , hcheck = self . _imageListCheck . GetSize ( checkimage ) <EOL> wcheck += <NUM_LIT:2> * _MARGIN <EOL> else : <EOL> wcheck = <NUM_LIT:0> <EOL> if total_h < <NUM_LIT:30> : <EOL> total_h += <NUM_LIT:2> <EOL> else : <EOL> total_h += total_h / <NUM_LIT:10> <EOL> if total_h > self . _lineHeight : <EOL> self . _lineHeight = max ( total_h , wnd_h + <NUM_LIT:2> ) <EOL> item . SetWidth ( image_w + text_w + wcheck + <NUM_LIT:2> + wnd_w ) <EOL> item . SetHeight ( max ( total_h , wnd_h + <NUM_LIT:2> ) ) <EOL> def CalculateLevel ( self , item , dc , level , y , x_colstart ) : <EOL> """<STR_LIT>""" <EOL> x = x_colstart + _MARGIN <EOL> if self . HasAGWFlag ( wx . TR_LINES_AT_ROOT ) : <EOL> x += _LINEATROOT <EOL> if self . HasButtons ( ) : <EOL> x += ( self . _btnWidth - self . _btnWidth2 ) <EOL> else : <EOL> x += ( self . _indent - self . _indent / <NUM_LIT:2> ) <EOL> if self . HasAGWFlag ( wx . TR_HIDE_ROOT ) : <EOL> x += self . _indent * ( level - <NUM_LIT:1> ) <EOL> else : <EOL> x += self . _indent * level <EOL> if self . HasAGWFlag ( wx . TR_HIDE_ROOT ) and ( level == <NUM_LIT:0> ) : <EOL> children = item . GetChildren ( ) <EOL> count = len ( children ) <EOL> level = level + <NUM_LIT:1> <EOL> for n in xrange ( count ) : <EOL> y = self . CalculateLevel ( children [ n ] , dc , level , y , x_colstart ) <EOL> return y <EOL> self . CalculateSize ( item , dc ) <EOL> item . SetX ( x ) <EOL> item . SetY ( y ) <EOL> y += self . GetLineHeight ( item ) <EOL> if not item . IsExpanded ( ) : <EOL> return y <EOL> children = item . GetChildren ( ) <EOL> count = len ( children ) <EOL> level = level + <NUM_LIT:1> <EOL> for n in xrange ( count ) : <EOL> y = self . CalculateLevel ( children [ n ] , dc , level , y , x_colstart ) <EOL> return y <EOL> def CalculatePositions ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . _anchor : <EOL> return <EOL> dc = wx . ClientDC ( self ) <EOL> self . PrepareDC ( dc ) <EOL> dc . SetFont ( self . _normalFont ) <EOL> dc . SetPen ( self . _dottedPen ) <EOL> y , x_colstart = <NUM_LIT:2> , <NUM_LIT:0> <EOL> for i in xrange ( self . GetMainColumn ( ) ) : <EOL> if not self . _owner . GetHeaderWindow ( ) . IsColumnShown ( i ) : <EOL> continue <EOL> x_colstart += self . _owner . GetHeaderWindow ( ) . GetColumnWidth ( i ) <EOL> self . CalculateLevel ( self . _anchor , dc , <NUM_LIT:0> , y , x_colstart ) <EOL> def SetItemText ( self , item , text , column = None ) : <EOL> """<STR_LIT>""" <EOL> dc = wx . ClientDC ( self ) <EOL> item . SetText ( column , text ) <EOL> self . CalculateSize ( item , dc ) <EOL> self . RefreshLine ( item ) <EOL> def GetItemText ( self , item , column = None ) : <EOL> """<STR_LIT>""" <EOL> if self . IsVirtual ( ) : <EOL> return self . _owner . OnGetItemText ( item , column ) <EOL> else : <EOL> return item . GetText ( column ) <EOL> def GetItemWidth ( self , item , column ) : <EOL> """<STR_LIT>""" <EOL> if not item : <EOL> return <NUM_LIT:0> <EOL> font = self . GetItemFont ( item ) <EOL> if not font . IsOk ( ) : <EOL> if item . IsBold ( ) : <EOL> font = self . _boldFont <EOL> elif item . IsItalic ( ) : <EOL> font = self . _italicFont <EOL> elif item . IsHyperText ( ) : <EOL> font = self . GetHyperTextFont ( ) <EOL> else : <EOL> font = self . _normalFont <EOL> dc = wx . ClientDC ( self ) <EOL> dc . SetFont ( font ) <EOL> w , h , dummy = dc . GetMultiLineTextExtent ( item . GetText ( column ) ) <EOL> w += <NUM_LIT:2> * _MARGIN <EOL> width = w + <NUM_LIT:2> * _MARGIN <EOL> if column == self . GetMainColumn ( ) : <EOL> width += _MARGIN <EOL> if self . HasAGWFlag ( wx . TR_LINES_AT_ROOT ) : <EOL> width += _LINEATROOT <EOL> if self . HasButtons ( ) : <EOL> width += self . _btnWidth + _LINEATROOT <EOL> if item . GetCurrentImage ( ) != _NO_IMAGE : <EOL> width += self . _imgWidth <EOL> level = <NUM_LIT:0> <EOL> parent = item . GetParent ( ) <EOL> root = self . GetRootItem ( ) <EOL> while ( parent and ( not self . HasAGWFlag ( wx . TR_HIDE_ROOT ) or ( parent != root ) ) ) : <EOL> level += <NUM_LIT:1> <EOL> parent = parent . GetParent ( ) <EOL> if level : <EOL> width += level * self . GetIndent ( ) <EOL> wnd = item . GetWindow ( column ) <EOL> if wnd : <EOL> width += wnd . GetSize ( ) [ <NUM_LIT:0> ] + <NUM_LIT:2> * _MARGIN <EOL> return width <EOL> def GetBestColumnWidth ( self , column , parent = None ) : <EOL> """<STR_LIT>""" <EOL> maxWidth , h = self . GetClientSize ( ) <EOL> width = <NUM_LIT:0> <EOL> if not parent : <EOL> parent = self . GetRootItem ( ) <EOL> if not self . HasAGWFlag ( wx . TR_HIDE_ROOT ) : <EOL> w = self . GetItemWidth ( parent , column ) <EOL> if width < w : <EOL> width = w <EOL> if width > maxWidth : <EOL> return maxWidth <EOL> item , cookie = self . GetFirstChild ( parent ) <EOL> while item : <EOL> w = self . GetItemWidth ( item , column ) <EOL> if width < w : <EOL> width = w <EOL> if width > maxWidth : <EOL> return maxWidth <EOL> if item . IsExpanded ( ) : <EOL> w = self . GetBestColumnWidth ( column , item ) <EOL> if width < w : <EOL> width = w <EOL> if width > maxWidth : <EOL> return maxWidth <EOL> item , cookie = self . GetNextChild ( parent , cookie ) <EOL> return width <EOL> def HideItem ( self , item , hide = True ) : <EOL> """<STR_LIT>""" <EOL> item . Hide ( hide ) <EOL> self . Refresh ( ) <EOL> _methods = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> class HyperTreeList ( wx . PyControl ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , parent , id = wx . ID_ANY , pos = wx . DefaultPosition , size = wx . DefaultSize , <EOL> style = <NUM_LIT:0> , agwStyle = wx . TR_DEFAULT_STYLE , validator = wx . DefaultValidator , <EOL> name = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> wx . PyControl . __init__ ( self , parent , id , pos , size , style , validator , name ) <EOL> self . _header_win = None <EOL> self . _main_win = None <EOL> self . _headerHeight = <NUM_LIT:0> <EOL> self . _attr_set = False <EOL> main_style = style & ~ ( wx . SIMPLE_BORDER | wx . SUNKEN_BORDER | wx . DOUBLE_BORDER | <EOL> wx . RAISED_BORDER | wx . STATIC_BORDER ) <EOL> self . _agwStyle = agwStyle <EOL> self . _main_win = TreeListMainWindow ( self , - <NUM_LIT:1> , wx . Point ( <NUM_LIT:0> , <NUM_LIT:0> ) , size , main_style , agwStyle , validator ) <EOL> self . _main_win . _buffered = False <EOL> self . _header_win = TreeListHeaderWindow ( self , - <NUM_LIT:1> , self . _main_win , wx . Point ( <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> wx . DefaultSize , wx . TAB_TRAVERSAL ) <EOL> self . _header_win . _buffered = False <EOL> self . CalculateAndSetHeaderHeight ( ) <EOL> self . Bind ( wx . EVT_SIZE , self . OnSize ) <EOL> self . SetBuffered ( IsBufferingSupported ( ) ) <EOL> self . _main_win . SetAGWWindowStyleFlag ( agwStyle ) <EOL> def SetBuffered ( self , buffered ) : <EOL> """<STR_LIT>""" <EOL> self . _main_win . SetBuffered ( buffered ) <EOL> self . _header_win . SetBuffered ( buffered ) <EOL> def CalculateAndSetHeaderHeight ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _header_win : <EOL> h = wx . RendererNative . Get ( ) . GetHeaderButtonHeight ( self . _header_win ) <EOL> if h != self . _headerHeight : <EOL> self . _headerHeight = h <EOL> self . DoHeaderLayout ( ) <EOL> def DoHeaderLayout ( self ) : <EOL> """<STR_LIT>""" <EOL> w , h = self . GetClientSize ( ) <EOL> has_header = self . _agwStyle & TR_NO_HEADER == <NUM_LIT:0> <EOL> if self . _header_win and has_header : <EOL> self . _header_win . SetDimensions ( <NUM_LIT:0> , <NUM_LIT:0> , w , self . _headerHeight ) <EOL> self . _header_win . Refresh ( ) <EOL> else : <EOL> self . _header_win . SetDimensions ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> if self . _main_win and has_header : <EOL> self . _main_win . SetDimensions ( <NUM_LIT:0> , self . _headerHeight + <NUM_LIT:1> , w , h - self . _headerHeight - <NUM_LIT:1> ) <EOL> else : <EOL> self . _main_win . SetDimensions ( <NUM_LIT:0> , <NUM_LIT:0> , w , h ) <EOL> def OnSize ( self , event ) : <EOL> """<STR_LIT>""" <EOL> self . DoHeaderLayout ( ) <EOL> def SetFont ( self , font ) : <EOL> """<STR_LIT>""" <EOL> if self . _header_win : <EOL> self . _header_win . SetFont ( font ) <EOL> self . CalculateAndSetHeaderHeight ( ) <EOL> self . _header_win . Refresh ( ) <EOL> if self . _main_win : <EOL> return self . _main_win . SetFont ( font ) <EOL> else : <EOL> return False <EOL> def SetHeaderFont ( self , font ) : <EOL> """<STR_LIT>""" <EOL> if not self . _header_win : <EOL> return <EOL> for column in xrange ( self . GetColumnCount ( ) ) : <EOL> self . _header_win . SetColumn ( column , self . GetColumn ( column ) . SetFont ( font ) ) <EOL> self . _header_win . Refresh ( ) <EOL> def SetHeaderCustomRenderer ( self , renderer = None ) : <EOL> """<STR_LIT>""" <EOL> self . _header_win . SetCustomRenderer ( renderer ) <EOL> def SetAGWWindowStyleFlag ( self , agwStyle ) : <EOL> """<STR_LIT>""" <EOL> if self . _main_win : <EOL> self . _main_win . SetAGWWindowStyleFlag ( agwStyle ) <EOL> tmp = self . _agwStyle <EOL> self . _agwStyle = agwStyle <EOL> if abs ( agwStyle - tmp ) & TR_NO_HEADER : <EOL> self . DoHeaderLayout ( ) <EOL> def GetAGWWindowStyleFlag ( self ) : <EOL> """<STR_LIT>""" <EOL> agwStyle = self . _agwStyle <EOL> if self . _main_win : <EOL> agwStyle |= self . _main_win . GetAGWWindowStyleFlag ( ) <EOL> return agwStyle <EOL> def HasAGWFlag ( self , flag ) : <EOL> """<STR_LIT>""" <EOL> agwStyle = self . GetAGWWindowStyleFlag ( ) <EOL> res = ( agwStyle & flag and [ True ] or [ False ] ) [ <NUM_LIT:0> ] <EOL> return res <EOL> def SetBackgroundColour ( self , colour ) : <EOL> """<STR_LIT>""" <EOL> if not self . _main_win : <EOL> return False <EOL> return self . _main_win . SetBackgroundColour ( colour ) <EOL> def SetForegroundColour ( self , colour ) : <EOL> """<STR_LIT>""" <EOL> if not self . _main_win : <EOL> return False <EOL> return self . _main_win . SetForegroundColour ( colour ) <EOL> def SetColumnWidth ( self , column , width ) : <EOL> """<STR_LIT>""" <EOL> if width == wx . LIST_AUTOSIZE_USEHEADER : <EOL> font = self . _header_win . GetFont ( ) <EOL> dc = wx . ClientDC ( self . _header_win ) <EOL> width , dummy , dummy = dc . GetMultiLineTextExtent ( self . _header_win . GetColumnText ( column ) ) <EOL> width += <NUM_LIT:2> * _EXTRA_WIDTH + _MARGIN <EOL> elif width == wx . LIST_AUTOSIZE : <EOL> width = self . _main_win . GetBestColumnWidth ( column ) <EOL> self . _header_win . SetColumnWidth ( column , width ) <EOL> self . _header_win . Refresh ( ) <EOL> def GetColumnWidth ( self , column ) : <EOL> """<STR_LIT>""" <EOL> return self . _header_win . GetColumnWidth ( column ) <EOL> def SetColumnText ( self , column , text ) : <EOL> """<STR_LIT>""" <EOL> self . _header_win . SetColumnText ( column , text ) <EOL> self . _header_win . Refresh ( ) <EOL> def GetColumnText ( self , column ) : <EOL> """<STR_LIT>""" <EOL> return self . _header_win . GetColumnText ( column ) <EOL> def AddColumn ( self , text , width = _DEFAULT_COL_WIDTH , flag = wx . ALIGN_LEFT , <EOL> image = - <NUM_LIT:1> , shown = True , colour = None , edit = False ) : <EOL> """<STR_LIT>""" <EOL> self . _header_win . AddColumn ( text , width , flag , image , shown , colour , edit ) <EOL> self . DoHeaderLayout ( ) <EOL> def AddColumnInfo ( self , colInfo ) : <EOL> """<STR_LIT>""" <EOL> self . _header_win . AddColumnInfo ( colInfo ) <EOL> self . DoHeaderLayout ( ) <EOL> def InsertColumnInfo ( self , before , colInfo ) : <EOL> """<STR_LIT>""" <EOL> self . _header_win . InsertColumnInfo ( before , colInfo ) <EOL> self . _header_win . Refresh ( ) <EOL> def InsertColumn ( self , before , text , width = _DEFAULT_COL_WIDTH , <EOL> flag = wx . ALIGN_LEFT , image = - <NUM_LIT:1> , shown = True , colour = None , <EOL> edit = False ) : <EOL> """<STR_LIT>""" <EOL> self . _header_win . InsertColumn ( before , text , width , flag , image , <EOL> shown , colour , edit ) <EOL> self . _header_win . Refresh ( ) <EOL> def RemoveColumn ( self , column ) : <EOL> """<STR_LIT>""" <EOL> self . _header_win . RemoveColumn ( column ) <EOL> self . _header_win . Refresh ( ) <EOL> def SetColumn ( self , column , colInfo ) : <EOL> """<STR_LIT>""" <EOL> self . _header_win . SetColumn ( column , colInfo ) <EOL> self . _header_win . Refresh ( ) <EOL> def GetColumn ( self , column ) : <EOL> """<STR_LIT>""" <EOL> return self . _header_win . GetColumn ( column ) <EOL> def SetColumnImage ( self , column , image ) : <EOL> """<STR_LIT>""" <EOL> self . _header_win . SetColumn ( column , self . GetColumn ( column ) . SetImage ( image ) ) <EOL> self . _header_win . Refresh ( ) <EOL> def GetColumnImage ( self , column ) : <EOL> """<STR_LIT>""" <EOL> return self . _header_win . GetColumn ( column ) . GetImage ( ) <EOL> def SetColumnEditable ( self , column , edit ) : <EOL> """<STR_LIT>""" <EOL> self . _header_win . SetColumn ( column , self . GetColumn ( column ) . SetEditable ( edit ) ) <EOL> def SetColumnShown ( self , column , shown ) : <EOL> """<STR_LIT>""" <EOL> if self . _main_win . GetMainColumn ( ) == column : <EOL> shown = True <EOL> self . SetColumn ( column , self . GetColumn ( column ) . SetShown ( shown ) ) <EOL> def IsColumnEditable ( self , column ) : <EOL> """<STR_LIT>""" <EOL> return self . _header_win . GetColumn ( column ) . IsEditable ( ) <EOL> def IsColumnShown ( self , column ) : <EOL> """<STR_LIT>""" <EOL> return self . _header_win . GetColumn ( column ) . IsShown ( ) <EOL> def SetColumnAlignment ( self , column , flag ) : <EOL> """<STR_LIT>""" <EOL> self . _header_win . SetColumn ( column , self . GetColumn ( column ) . SetAlignment ( flag ) ) <EOL> self . _header_win . Refresh ( ) <EOL> def GetColumnAlignment ( self , column ) : <EOL> """<STR_LIT>""" <EOL> return self . _header_win . GetColumn ( column ) . GetAlignment ( ) <EOL> def SetColumnColour ( self , column , colour ) : <EOL> """<STR_LIT>""" <EOL> self . _header_win . SetColumn ( column , self . GetColumn ( column ) . SetColour ( colour ) ) <EOL> self . _header_win . Refresh ( ) <EOL> def GetColumnColour ( self , column ) : <EOL> """<STR_LIT>""" <EOL> return self . _header_win . GetColumn ( column ) . GetColour ( ) <EOL> def SetColumnFont ( self , column , font ) : <EOL> """<STR_LIT>""" <EOL> self . _header_win . SetColumn ( column , self . GetColumn ( column ) . SetFont ( font ) ) <EOL> self . _header_win . Refresh ( ) <EOL> def GetColumnFont ( self , column ) : <EOL> """<STR_LIT>""" <EOL> return self . _header_win . GetColumn ( column ) . GetFont ( ) <EOL> def Refresh ( self , erase = True , rect = None ) : <EOL> """<STR_LIT>""" <EOL> self . _main_win . Refresh ( erase , rect ) <EOL> self . _header_win . Refresh ( erase , rect ) <EOL> def SetFocus ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _main_win . SetFocus ( ) <EOL> def GetHeaderWindow ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _header_win <EOL> def GetMainWindow ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _main_win <EOL> def DoGetBestSize ( self ) : <EOL> """<STR_LIT>""" <EOL> return wx . Size ( <NUM_LIT:200> , <NUM_LIT:200> ) <EOL> def OnGetItemText ( self , item , column ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" <EOL> def SortChildren ( self , item ) : <EOL> """<STR_LIT>""" <EOL> if not self . _attr_set : <EOL> setattr ( self . _main_win , "<STR_LIT>" , self . OnCompareItems ) <EOL> self . _attr_set = True <EOL> self . _main_win . SortChildren ( item ) <EOL> def OnCompareItems ( self , item1 , item2 ) : <EOL> """<STR_LIT>""" <EOL> return self . GetItemText ( item1 ) == self . GetItemText ( item2 ) <EOL> def GetClassDefaultAttributes ( self ) : <EOL> """<STR_LIT>""" <EOL> attr = wx . VisualAttributes ( ) <EOL> attr . colFg = wx . SystemSettings_GetColour ( wx . SYS_COLOUR_WINDOWTEXT ) <EOL> attr . colBg = wx . SystemSettings_GetColour ( wx . SYS_COLOUR_LISTBOX ) <EOL> attr . font = wx . SystemSettings_GetFont ( wx . SYS_DEFAULT_GUI_FONT ) <EOL> return attr <EOL> GetClassDefaultAttributes = classmethod ( GetClassDefaultAttributes ) <EOL> def create_delegator_for ( method ) : <EOL> """<STR_LIT>""" <EOL> def delegate ( self , * args , ** kwargs ) : <EOL> return getattr ( self . _main_win , method ) ( * args , ** kwargs ) <EOL> return delegate <EOL> for method in _methods : <EOL> setattr ( HyperTreeList , method , create_delegator_for ( method ) ) </s>
