From: Carl G. <cg...@gm...> - 2009-09-07 18:27:02
|
Hi, I have a suggestion for improving wxTreeListCtrl. I wanted to add tool tips to a wxTreeListCtrl but had a little trouble that I have since worked around. I want the tool tips to be based on the item I'm hovering over. To do this, I added a handler for mouse motion and am using HitTest to figure out which item I'm hovering over. There's a problem with this, though: the header. I needed a way to account for the height of the header but m_headerHeight is a private member. My first change was to make a protected GetHeaderHeight() method. Then in my OnMouseMotion handler I can do this: wxPoint point (event.GetX(), event.GetY() + GetHeaderHeight()); wxTreeItemId item = HitTest (point); Second, wxWindow::SetToolTip() doesn't work correctly since it's really the main window that needs to handle the tool tip. So my second change was to override wxTreeListCtrl::SetToolTip() and have my function call m_main_win::SetToolTip(). Here's the whole function that I added to the end of treelistctrl.cpp: void wxTreeListCtrl::SetToolTip (const wxString &tip) { m_main_win->SetToolTip (tip); } And here are the changes I made to the protected section of treelistctrl.h: int GetHeaderHeight() const { return m_headerHeight; } void SetToolTip (const wxString &tip); This leads me to a final question: Why does wxTreeListCtrl have public member functions GetHeaderWindow() and GetMainWindow()? Since the classes they returned are only defined inside treelistctrl.cpp, I don't see how they do me any good. I could have accomplished both of the changes I suggest above if I could get at these classes, but I cannot. Am I missing something obvious? Thanks, carl |