SearchResultPanel.py
changeset 572 1af3cc2b207c
parent 571 79af7b821233
child 574 8c525217ef1f
--- a/SearchResultPanel.py	Mon Oct 10 02:22:26 2011 +0200
+++ b/SearchResultPanel.py	Mon Oct 10 10:14:24 2011 +0200
@@ -89,7 +89,8 @@
 
         self.SearchResultsTree = CT.CustomTreeCtrl(id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE,
               name="SearchResultsTree", parent=self,
-              pos=wx.Point(0, 0), style=CT.TR_HAS_BUTTONS|CT.TR_NO_LINES|CT.TR_HAS_VARIABLE_ROW_HEIGHT)
+              pos=wx.Point(0, 0), style=0)
+        self.SearchResultsTree.SetAGWWindowStyleFlag(CT.TR_HAS_BUTTONS|CT.TR_NO_LINES|CT.TR_HAS_VARIABLE_ROW_HEIGHT)
         self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnSearchResultsTreeItemActivated,
               id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE)
         
@@ -275,34 +276,19 @@
             style = wx.TextAttr(wx.Colour(0, 127, 174))
         
         if text is not None:
-            background_colour = self.SearchResultsTree.GetBackgroundColour()
-            if wx.Platform != '__WXMSW__':
-                text_ctrl = wx.TextCtrl(id=-1, parent=self.SearchResultsTree, pos=wx.Point(0, 0), 
-                        value=text, style=wx.BORDER_NONE|wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH2)
-                width, height = text_ctrl.GetTextExtent(text)
-                text_ctrl.SetClientSize(wx.Size(width + 1, height))
-                self.SearchResultsTree.SetItemWindow(root, text_ctrl)
-            else:
-                panel = wx.Panel(id=-1, parent=self.SearchResultsTree)
-                panel.SetBackgroundColour(background_colour)
-                sizer = wx.BoxSizer(wx.HORIZONTAL)
-                if len(text.splitlines()) > 1:
-                    text_ctrl = wx.TextCtrl(id=-1, parent=panel, pos=wx.Point(0, 0), 
-                          value=text, style=wx.BORDER_NONE|wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH2)
-                else:
-                    text_ctrl = wx.TextCtrl(id=-1, parent=panel, pos=wx.Point(0, 0), 
-                           value=text, size=wx.Size(0, 13), style=wx.BORDER_NONE|wx.TE_READONLY|wx.TE_RICH2)
-                width, height = text_ctrl.GetTextExtent(text)
-                sizer.AddWindow(text_ctrl, 1, border=0, flags=wx.ALIGN_CENTER_VERTICAL)
-                panel.SetSizer(sizer)
-                panel.SetClientSize(wx.Size(width + 1, height + 5))
-                self.SearchResultsTree.SetItemWindow(root, panel)
-            
-            text_ctrl.SetBackgroundColour(background_colour)
+            text_ctrl_style = wx.BORDER_NONE|wx.TE_READONLY|wx.TE_RICH2
+            if wx.Platform != '__WXMSW__' or len(text.splitlines()) > 1:
+                text_ctrl_style |= wx.TE_MULTILINE
+            text_ctrl = wx.TextCtrl(id=-1, parent=self.SearchResultsTree, pos=wx.Point(0, 0), 
+                    value=text, style=text_ctrl_style)
+            width, height = text_ctrl.GetTextExtent(text)
+            text_ctrl.SetClientSize(wx.Size(width + 1, height))
+            text_ctrl.SetBackgroundColour(self.SearchResultsTree.GetBackgroundColour())
             text_ctrl.Bind(wx.EVT_LEFT_DOWN, self.GetTextCtrlClickFunction(root))
             text_ctrl.Bind(wx.EVT_LEFT_DCLICK, self.GetTextCtrlDClickFunction(root))
             text_ctrl.SetInsertionPoint(0)
             text_ctrl.SetStyle(start_idx, end_idx, style)
+            self.SearchResultsTree.SetItemWindow(root, text_ctrl)
             
         if wx.VERSION >= (2, 6, 0):
             item, root_cookie = self.SearchResultsTree.GetFirstChild(root)