ANN : Enhanced wxTreeListCtrl

Do you like to promote your wxWidgets based application or component!? Post it here and let's see what the critics have to say. Also, if you found that ONE wx component the world needs to know about, put it here for future reference.
gururamnath
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

ANN : Enhanced wxTreeListCtrl

Post by gururamnath »

Hello All,
Finally I was able to fix all the outstanding bugs with my new enhanced wxTreeListCtrl.

Features:
  • 1) Native Header Control
    2) Added Vertical Rule property like the one in wxListCtrl (new flag wxTR_VRULE)
    3) Changed the Grid Line colors to nice color other than the dull black
    4) Native Tree Button instead of the program drawn Expand and Collapse buttons (Only in 2.7)
    5)Added a new flag wxTR_SHOW_ROOT_LABEL_ONLY which can simulate Outlook like Grid Root where the Label can extend multiple columns.
Screenshot :
Image

Source & wxMSW Executable :
http://twinforms.com/wxlib_wxtreelistctrl.htm

If you have any problems or if you have any patch forany enhancements, please send it to [email protected] .

Thanks,
Guru Kathiresan
Last edited by gururamnath on Fri Aug 10, 2007 1:19 pm, edited 1 time in total.
User avatar
tierra
Site Admin
Site Admin
Posts: 1355
Joined: Sun Aug 29, 2004 7:14 pm
Location: Salt Lake City, Utah, USA
Contact:

Post by tierra »

Very nice, I will definately be checking this out soon and replacing a few of my wxTreeListCtrls.
frm
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Sep 09, 2004 7:29 pm
Location: Modena, ITALY
Contact:

Post by frm »

Very nice work!

I wonder: why don't you make (maybe working together with Otto) a patch for wxWidgets; in fact since wxTreeListCtrl has now a native implementation (at least for wxMSW - but I'm sure it could be made native also for wxGTK) I'm quite sure wx developers would accept it as new widget.

Of course there's some work to do to split generic code from MSW-specific one but if you integrate it in wxWidgets everyone will be able to use it !! :D

Thanks!
gururamnath
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Post by gururamnath »

frm wrote: I wonder: why don't you make (maybe working together with Otto) a patch for wxWidgets;
When I made the intial changes back in march, I sent a mail to Otto requesting him to add the changes. Otto was not interested in maintaining my revised version (I mean he dont want to add the native header implementation as he thinks that it is going bring him lot of work. Since the changes I have made was hardly 15-20 lines with a #ifdefs, it can also be turned off easily with a #undef and make it work like the generic control). Although he merged couple of the features (Vertical Rule and Line colors) to the official wxTreeListCtrl this month. He mentioned that I have to talk to the wx maintainer to include this control in the main distribution.
If Otto is willing to add the native control in the official wxTreeListCtrl, I'm willing to maintain it. I'm not sure what he will say about it.
frm wrote: I'm sure it could be made native also for wxGTK
I dont use Linux nowadays so I'm not sure when I can investigate this. If you have some pointers on what widgets I have to use in GTK, I will certainly try to work on it . I checked the GtkTreeViewColumn and it seems to be the likely widgets I have to use. Anyway, I'll try to investigate in the near future.
frm wrote: I'm quite sure wx developers would accept it as new widget.
Just sent an email to Julian. I'll let you know what he say.

In the mean while, if someone can help me split the source for 3 different distributions, please send me an email to [email protected] .

Thanks,
Guru Kathiresan
frm
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Sep 09, 2004 7:29 pm
Location: Modena, ITALY
Contact:

Post by frm »

I dont use Linux nowadays so I'm not sure when I can investigate this. If you have some pointers on what widgets I have to use in GTK, I will certainly try to work on it . I checked the GtkTreeViewColumn and it seems to be the likely widgets I have to use.
exactly: GtkTreeViewColumn is what needs to be used. It's described at:

http://developer.gnome.org/doc/API/2.0/ ... idget.html

and there's a simple demo, which is part of the "gtk-demo" program (which many distro install together with gtk), which shows a wxTreeListCtrl-equivalent:

Image

the gtk-demo program also shows the sources of the demos so that it could be a good start point.

However I need to say that Robert Roebling (wx developer) is working on a wxDataViewCtrl which, as soon as it will be finished, will provide a gtktreeview-similar API in wxWidgets.
So maybe wx developers will want you to implement the GTK port of wxTreeListCtrl with that API; however, since wxDataViewCtrl will be using a generic implementation on wxMSW (at least AFAIK), maybe they will agree to include a component like wxTreeListCtrl which is not based on wxDataViewCtrl. The only way to know is discuss it on wx-dev :wink:

Last, I could help with splitting the sources in generic/MSW/GTK parts but not right now... I won't be able for at least 1 week.
gururamnath
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Post by gururamnath »

Thanks for the link. I'll check that in a weeks time.
frm wrote: However I need to say that Robert Roebling (wx developer) is working on a wxDataViewCtrl which, as soon as it will be finished, will provide a gtktreeview-similar API in wxWidgets.
I looked at the wxDataViewCtrl src and it is almost similar to wxTreeListCtrl. The additional things that are included in wxDataViewCtrl are
1) More Inplace editors for each Grid Cell (TreeList only has inplace Text Edit control).
2)It tends to use the Native Header by using the Native Rendering class. The idea of using Native Rendering has a fundamental flaw . Unlike a natively rendered Tree Expand/Collapse button or Checkbox, the header control needs to updated when the user moves the mouse on it. This needs more window redrawing and I'm using this will render the control useless. This can be overcome by directly implementing a native header similar to my version of treelistctrl.

The only problem I see with wxDataViewCtrl is that it doesnt support Tree Like structure.
frm wrote: The only way to know is discuss it on wx-dev :wink:
Even Julian Smart asked me to discuss this in wx-dev. I'll send a mail to the list asap.
frm wrote: Last, I could help with splitting the sources in generic/MSW/GTK parts but not right now... I won't be able for at least 1 week.
Thanks. When ever you are free, please send an email.

-Guru Kathiresan
gururamnath
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Post by gururamnath »

gururamnath wrote: The idea of using Native Rendering has a fundamental flaw .
Ok, I might be wrong with this one. I based my assertion with XP's modern theme. When ever u hover the mouse on the header control the look of the header changes. This is not the case with win9x,win2k and Mac OSX (and also in GTK ? ) where the state/look of the headers are not changed when mouse is on the control.

I have made some modification in the current code to use the Native Rendering functions. I tested this in winXP classic theme and it seems to work. Please try the current code in wxGTK and let me know if it works.

You can find the current modifications at :

http://twinforms.com/wxlib_wxtreelistctrl.htm

-Guru Kathiresan
Last edited by gururamnath on Fri Aug 10, 2007 1:19 pm, edited 1 time in total.
frm
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Sep 09, 2004 7:29 pm
Location: Modena, ITALY
Contact:

Post by frm »

Hi,
Please try the current code in wxGTK and let me know if it works.
sorry but I was unable to test it on wxGTK as the organization of the component sources isn't the usual one.

In order to be able to submit it as part of wxWidgets, it should really have the following structure:

Code: Select all

include
|- wx
     |---- treelistctrl.h   =     declares wxTreeListCtrlBase
     |---- gtk
     |         |---- treelistctrl.h    = declares wxTreeListCtrl + GTK helpers
     |----- msw
                |---- treelistctrl.h    = declares wxTreeListCtrl + MSW helpers

src
|--- common
|       |----    treelistctrlcmn.cpp = declares all platform-independent functions
|--- gtk
|       |----    treelistctrl.cpp = declares GTK specific functions
|--- msw
|       |----    treelistctrl.cpp = declares MSW specific functions
If you organize the MSW / common parts, I can create the GTK part. However I really need to have a clean treelistctrlcmn.cpp which does not contains #ifdef __WXMSW__ #endif.
All those parts should be embedded in platform-specific functions.

BTW, sorry for the ignorant question but is wxRendererNative the only way to draw the MSW native header ?
I mean: in wxWidgets only wxUniv code uses wxRenderer AFAIK while platform-specific code should always wrap platform-specific controls.
I.e. if wxMSW has a native control for the header window, it should be used instead of wxRenderer.... just like wxGTK won't use the wxRendererNative class for drawing wxTreeListCtrl but rather will wrap the GTK+ native GtkTreeView control.
gururamnath
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Post by gururamnath »

frm wrote:Hi,
sorry but I was unable to test it on wxGTK as the organization of the component sources isn't the usual one.
It doesnt need to be in the proper organization. Make the treelistctrl.cpp/h as a part of your project and just compile the program.

frm wrote: BTW, sorry for the ignorant question but is wxRendererNative the only way to draw the MSW native header ?
No. We can use the win32 Header control directly. Thats what I have done. But just for MAC and GTK I have used the wxRendererNative functions.
frm wrote: I mean: in wxWidgets only wxUniv code uses wxRenderer AFAIK while platform-specific code should always wrap platform-specific controls.
I.e. if wxMSW has a native control for the header window, it should be used instead of wxRenderer.... just like wxGTK won't use the wxRendererNative class for drawing wxTreeListCtrl but rather will wrap the GTK+ native GtkTreeView control.
wxRenderer, to my understanding is specific to very platform and for wxuniv it has got an inbuilt renderer that paints each and every object the way it is. For MSW's checkbox or Header Control, the wxRenderer calls the native apis that associated with the controls.

For MSW, the native renderer does work as advertised but there is a tiny problem with it. Unlike checkbox and radio buttons the header control in XP is not a static control. When you move the mouse over the header control it tends to change its appearance. Only for fixing this issue I implemented hosting the native header control instead of using the wxRenderer. When I use wxRenderer , the header control does look like the winXP one but when I move the mouse it wont change its appearance (which looks very odd).


-Guru Kathiresan
jms
Experienced Solver
Experienced Solver
Posts: 54
Joined: Wed Sep 29, 2004 6:37 am
Location: Finland

Post by jms »

Hi,
gururamnath wrote: When I use wxRenderer , the header control does look like the winXP one but when I move the mouse it wont change its appearance (which looks very odd).
Did you try calling NativeDrawHeaderButton with wxCONTROL_CURRENT flag when mouse hovers over the header cell?
gururamnath
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Post by gururamnath »

jms wrote: Did you try calling NativeDrawHeaderButton with wxCONTROL_CURRENT flag when mouse hovers over the header cell?
Hi,
Yes, I tried repainting the header controls in the mouse move event but there were lot of flickering and it is really horrible. Finally, implementing a native header looks like the correct solution (at least for WinXP).

Other than WinXP, I'm not sure what other OS is having having such effects on the header control.

-Guru Kathiresan
jms
Experienced Solver
Experienced Solver
Posts: 54
Joined: Wed Sep 29, 2004 6:37 am
Location: Finland

Post by jms »

gururamnath wrote: Yes, I tried repainting the header controls in the mouse move event but there were lot of flickering and it is really horrible.
You should use wxBufferedPaintDC and wxWindow::SetBackgroundStyle(wxBG_STYLE_CUSTOM) to eliminate flickering. Also, when you call Refresh, you may need have its eraseBackground parameter as false.
gururamnath wrote: Finally, implementing a native header looks like the correct solution (at least for WinXP).

Other than WinXP, I'm not sure what other OS is having having such effects on the header control.
Even if no OS has currently, it would certainly make your control more future-proof to have header repainting with wxCONTROL_CURRENT in the generic version as well.
priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia »

Can I place Inplace editors for each Grid Cell like checkbox in your control.
gururamnath
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Post by gururamnath »

priyank_bolia wrote:Can I place Inplace editors for each Grid Cell like checkbox in your control.
The inplace editors are specific to a column; so yes you can change it like the grid cell.
If you want to to display different inplace editor in different row then you can set the inplace editor style before each row selection.

Inplace editors like combobox, datepicker, spin ctrl and text are included in

http://twinforms.com/wxlib_wxtreelistctrl.htm

-Guru Kathiresan
Last edited by gururamnath on Fri Aug 10, 2007 1:20 pm, edited 1 time in total.
gururamnath
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Post by gururamnath »

jms wrote: You should use wxBufferedPaintDC and wxWindow::SetBackgroundStyle(wxBG_STYLE_CUSTOM) to eliminate flickering. Also, when you call Refresh, you may need have its eraseBackground parameter as false.
I think modifiying the existing code to use wxBufferedPaintDC should require lot of changes in lot of places. If you have time, can you please have a look the control and suggest where I can use the wxBufferedPaintDC ? If so, I can send my modified copy that uses mouse move event to paint the headers.

Thanks,
Guru
Post Reply