SearchResultPanel.py
changeset 572 1af3cc2b207c
parent 571 79af7b821233
child 574 8c525217ef1f
equal deleted inserted replaced
571:79af7b821233 572:1af3cc2b207c
    87               name='HeaderLabel', parent=self,
    87               name='HeaderLabel', parent=self,
    88               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
    88               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
    89 
    89 
    90         self.SearchResultsTree = CT.CustomTreeCtrl(id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE,
    90         self.SearchResultsTree = CT.CustomTreeCtrl(id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE,
    91               name="SearchResultsTree", parent=self,
    91               name="SearchResultsTree", parent=self,
    92               pos=wx.Point(0, 0), style=CT.TR_HAS_BUTTONS|CT.TR_NO_LINES|CT.TR_HAS_VARIABLE_ROW_HEIGHT)
    92               pos=wx.Point(0, 0), style=0)
       
    93         self.SearchResultsTree.SetAGWWindowStyleFlag(CT.TR_HAS_BUTTONS|CT.TR_NO_LINES|CT.TR_HAS_VARIABLE_ROW_HEIGHT)
    93         self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnSearchResultsTreeItemActivated,
    94         self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnSearchResultsTreeItemActivated,
    94               id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE)
    95               id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE)
    95         
    96         
    96         self.ResetButton = wx.Button(id=ID_SEARCHRESULTPANELRESETBUTTON, label=_('Reset'),
    97         self.ResetButton = wx.Button(id=ID_SEARCHRESULTPANELRESETBUTTON, label=_('Reset'),
    97               name='ResetButton', parent=self, pos=wx.Point(0, 0),
    98               name='ResetButton', parent=self, pos=wx.Point(0, 0),
   273             text = _("(%d matches)") % infos["matches"]
   274             text = _("(%d matches)") % infos["matches"]
   274             start_idx, end_idx = 0, len(text)
   275             start_idx, end_idx = 0, len(text)
   275             style = wx.TextAttr(wx.Colour(0, 127, 174))
   276             style = wx.TextAttr(wx.Colour(0, 127, 174))
   276         
   277         
   277         if text is not None:
   278         if text is not None:
   278             background_colour = self.SearchResultsTree.GetBackgroundColour()
   279             text_ctrl_style = wx.BORDER_NONE|wx.TE_READONLY|wx.TE_RICH2
   279             if wx.Platform != '__WXMSW__':
   280             if wx.Platform != '__WXMSW__' or len(text.splitlines()) > 1:
   280                 text_ctrl = wx.TextCtrl(id=-1, parent=self.SearchResultsTree, pos=wx.Point(0, 0), 
   281                 text_ctrl_style |= wx.TE_MULTILINE
   281                         value=text, style=wx.BORDER_NONE|wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH2)
   282             text_ctrl = wx.TextCtrl(id=-1, parent=self.SearchResultsTree, pos=wx.Point(0, 0), 
   282                 width, height = text_ctrl.GetTextExtent(text)
   283                     value=text, style=text_ctrl_style)
   283                 text_ctrl.SetClientSize(wx.Size(width + 1, height))
   284             width, height = text_ctrl.GetTextExtent(text)
   284                 self.SearchResultsTree.SetItemWindow(root, text_ctrl)
   285             text_ctrl.SetClientSize(wx.Size(width + 1, height))
   285             else:
   286             text_ctrl.SetBackgroundColour(self.SearchResultsTree.GetBackgroundColour())
   286                 panel = wx.Panel(id=-1, parent=self.SearchResultsTree)
       
   287                 panel.SetBackgroundColour(background_colour)
       
   288                 sizer = wx.BoxSizer(wx.HORIZONTAL)
       
   289                 if len(text.splitlines()) > 1:
       
   290                     text_ctrl = wx.TextCtrl(id=-1, parent=panel, pos=wx.Point(0, 0), 
       
   291                           value=text, style=wx.BORDER_NONE|wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH2)
       
   292                 else:
       
   293                     text_ctrl = wx.TextCtrl(id=-1, parent=panel, pos=wx.Point(0, 0), 
       
   294                            value=text, size=wx.Size(0, 13), style=wx.BORDER_NONE|wx.TE_READONLY|wx.TE_RICH2)
       
   295                 width, height = text_ctrl.GetTextExtent(text)
       
   296                 sizer.AddWindow(text_ctrl, 1, border=0, flags=wx.ALIGN_CENTER_VERTICAL)
       
   297                 panel.SetSizer(sizer)
       
   298                 panel.SetClientSize(wx.Size(width + 1, height + 5))
       
   299                 self.SearchResultsTree.SetItemWindow(root, panel)
       
   300             
       
   301             text_ctrl.SetBackgroundColour(background_colour)
       
   302             text_ctrl.Bind(wx.EVT_LEFT_DOWN, self.GetTextCtrlClickFunction(root))
   287             text_ctrl.Bind(wx.EVT_LEFT_DOWN, self.GetTextCtrlClickFunction(root))
   303             text_ctrl.Bind(wx.EVT_LEFT_DCLICK, self.GetTextCtrlDClickFunction(root))
   288             text_ctrl.Bind(wx.EVT_LEFT_DCLICK, self.GetTextCtrlDClickFunction(root))
   304             text_ctrl.SetInsertionPoint(0)
   289             text_ctrl.SetInsertionPoint(0)
   305             text_ctrl.SetStyle(start_idx, end_idx, style)
   290             text_ctrl.SetStyle(start_idx, end_idx, style)
       
   291             self.SearchResultsTree.SetItemWindow(root, text_ctrl)
   306             
   292             
   307         if wx.VERSION >= (2, 6, 0):
   293         if wx.VERSION >= (2, 6, 0):
   308             item, root_cookie = self.SearchResultsTree.GetFirstChild(root)
   294             item, root_cookie = self.SearchResultsTree.GetFirstChild(root)
   309         else:
   295         else:
   310             item, root_cookie = self.SearchResultsTree.GetFirstChild(root, 0)
   296             item, root_cookie = self.SearchResultsTree.GetFirstChild(root, 0)