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 |
From: Christian B. <ex...@gm...> - 2009-09-08 09:58:08
|
Carl Godkin schrieb: > 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. Hi Carl, I tried it some weeks ago, too. But I am not a crack! ;) I am very interested in the progress of your work and would test your code. Please let me know if I can help you! -- publictimestamp.org/ptb/PTB-7091 sha384 2009-09-08 09:00:04 1203EAF9E9A2629AF64B1F28BB8E81D29A86D41774A3392F5415C8A05B8155BDA8934E 40CDAAE113C4862B99D446B1EE |
From: Carl G. <cg...@gm...> - 2009-09-08 21:51:36
|
On Tue, Sep 8, 2009 at 2:56 AM, Christian Buhtz <ex...@gm...> wrote: > Carl Godkin schrieb: > > 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. > > Hi Carl, > > I tried it some weeks ago, too. But I am not a crack! ;) > > I am very interested in the progress of your work and would test your > code. Please let me know if I can help you! > > If you just make the small changes I mentioned in the email it should all work, at least on wxMSW and wxGTK. Note that there are a couple of funny problems with wxGTK, however: 1. If you select a tree item, then tooltips stop working until you move out and then back into the window. 2. The tool tip is positioned at the bottom of the window. Both of these problems were discussed in this thread on the wx-users list: http://article.gmane.org/gmane.comp.lib.wxwidgets.general/46477 I should mention that I'm using wx 2.8.8. carl |
From: Christian B. <ex...@gm...> - 2009-09-08 23:02:31
|
Carl Godkin schrieb: > If you just make the small changes I mentioned in the email it should > all work, Please make a diff/patch > I should mention that I'm using wx 2.8.8. against TRUNK. ;) -- publictimestamp.org/ptb/PTB-7095 sha160 2009-09-08 21:00:04 A6D12B1189391091CD6B2F4514CFB4ABA2A75472 |
From: Ronan C. <pgr...@ya...> - 2009-09-13 17:15:18
|
> Hi, Hi Carl, and sorry about the delay, I was off on a trip > 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. > . . . . . I find it a very good idea. In fact, IMHO the functionality should be supported directly by the control, without you having to worry about gory details --although I am very thankful that you already did the job :-) Would you be happy with the following methods ? // set default tip (header, blank area) treeListCtrl->SetToolTip(const wxString &tip); // set tip for specific row treeListCtrl->SetToolTip(const wxTreeItemId& item, const wxString &tip); If so I would merge your code into the control and add these 2 public methods > 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? Ahum... maybe not everything in the class definition makes sense anymore, the control went through several hands... Ideally you should not have to access the underlying windows, i.e. those methods should not be public. Like you pointed out they are useless outside treelistctrl.cpp, so I will change them to protected. Thanks for the remark! Ronan |
From: Carl G. <cg...@gm...> - 2009-09-13 19:31:36
|
On Sun, Sep 13, 2009 at 9:40 AM, Ronan Chartois <pgr...@ya...> wrote: > > Would you be happy with the following methods ? > > // set default tip (header, blank area) > treeListCtrl->SetToolTip(const wxString &tip); > // set tip for specific row > treeListCtrl->SetToolTip(const wxTreeItemId& item, const wxString &tip); > > If so I would merge your code into the control and add these 2 public > methods > > Hi Ronan, I think this is a fine idea. Thanks! carl |
From: Ronan C. <pgr...@ya...> - 2009-09-14 18:16:36
|
Carl Godkin <cgodkin@...> writes: > On Sun, Sep 13, 2009 at 9:40 AM, Ronan Chartois <pgriddev <at> yahoo.fr> wrote: > > Would you be happy with the following methods ? > // set default tip (header, blank area) > treeListCtrl->SetToolTip(const wxString &tip); > // set tip for specific row > treeListCtrl->SetToolTip(const wxTreeItemId& item, const wxString &tip); > If so I would merge your code into the control and add these 2 public methods > > > Hi Ronan, > > I think this is a fine idea. Thanks! In that case, I opened wxCode feature tracker ticket 2858734 on your behalf, follow-up on: https://sourceforge.net/tracker/index.php? func=detail&aid=2858734&group_id=51305&atid=462819 Ronan |