Page 1 of 1
Column-Component like in a wxListCtrl without list
Posted: Tue Jul 28, 2009 1:45 pm
I'm trying to write a component with consists of columns like in a wxListCtrl but only the header (with other bg-coloring). I created the Columns by deriving it from wxPanel and add the separator for resizing to the right. It works. I only need help on sizing. If the mouse is over the separator the resizing-cursor should appear. On mouse-down with dragging the Panel (Column-Header), the panel should resize.
Has somebody a piece a code or some tips?
Thank you very much.
Posted: Tue Jul 28, 2009 2:12 pm
Code: Select all
and add the separator for resizing to the right
which separator did you use for this?
I never used it, but this class seems appropriate : http://docs.wxwidgets.org/stable/wx_wxsashwindow.html
Posted: Wed Jul 29, 2009 9:32 am
I used wxPanel for the column and for the separator i used a wxPanel, too with an horizontal line in it and placed it to be right alignment.
Is it easier with the the wxSashWindow? Can i manipulate the look & feel of a wxSashWindow ? change the bg and more ?
Thank you very much!
Posted: Wed Jul 29, 2009 2:14 pm
About panel, you could probably* catch the mouse pressed event, capture the mouse, then receive all mouse motion events and move the panel along. This is a somewhat similar example : http://wiki.wxwidgets.org/Dragging_a_wxWindow_around
I have no idea of how it'd go with a sash window, never used this class
* never tried it
Posted: Wed Jul 29, 2009 2:58 pm
Dragging a window around is no problem and not actual the problem. I've had problems with dragging before. The problem is how to resize each if they are in a row like in a wxListCtrl...manual resizing....how to calculate the new size by mouse position and the new position of the follwoing wxPanel and so on..
But thank you very much.
Any ideas out there ?
Posted: Wed Jul 29, 2009 5:44 pm
Hmm, well maybe if the resize panel is moved by e.g. 5 pixels to the right, enlarge the panel it's tied to by 5 pixels too. You could also get the coord of the resize panel, and resize the other panel so that its edge reaches this coord.
Maybe instead of using panels you could just draw it all on a DC (depends what you want of course)
Posted: Wed Jul 29, 2009 6:50 pm
Maybe I misunderstand what you want, but you seem to be trying to re-invent http://docs.wxwidgets.org/trunk/classwx ... _ctrl.html
Posted: Fri Jul 31, 2009 6:44 am
you're right. I need to re-invent it because i need footers where a summary appears (SUM or COUNT) for each column.
I still could not solve the problem. No ideas?
Posted: Sun Aug 02, 2009 10:38 am
Probably the easiest route to take would be to code up a custom drawn window that only consists of the column summaries, and tie in event handlers into a wxGrid, wxListCtrl or wxDataViewCtrl (whichever works best for you) for when column sizes change, and update that window accordingly.
This would simplify the task immensely compared with writing up your own custom list control.
Posted: Sun Aug 02, 2009 2:55 pm
I wrote my own header control too.
In my case it is one simple window. I don't use distinct windows for every column, nor are the separators own windows.
It is way to simple to check if the mouse is over a column (wich can be dragged around too in my control, to change their order) or a separator to go through all the trouble with multiple windows.
Posted: Tue Aug 04, 2009 3:05 pm
Is there any chance to get the code you use?
It would make me much more relaxed...till i'm very frustrated.