Column-Component like in a wxListCtrl without list Topic is solved

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
extreme001
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Fri Dec 22, 2006 9:17 am
Location: Germany
Contact:

Column-Component like in a wxListCtrl without list

Post by extreme001 »

Hi!

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.
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

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
"Keyboard not detected. Press F1 to continue"
-- Windows
extreme001
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Fri Dec 22, 2006 9:17 am
Location: Germany
Contact:

Post by extreme001 »

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!
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

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
"Keyboard not detected. Press F1 to continue"
-- Windows
extreme001
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Fri Dec 22, 2006 9:17 am
Location: Germany
Contact:

Post by extreme001 »

Hi!

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 ?
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

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)
"Keyboard not detected. Press F1 to continue"
-- Windows
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

Hi,

Maybe I misunderstand what you want, but you seem to be trying to re-invent http://docs.wxwidgets.org/trunk/classwx ... _ctrl.html

Regards,

David
extreme001
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Fri Dec 22, 2006 9:17 am
Location: Germany
Contact:

Post by extreme001 »

Yes David,

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?
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 »

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.
Frank
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 211
Joined: Sat Jan 01, 2005 6:19 pm

Post by Frank »

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.
extreme001
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Fri Dec 22, 2006 9:17 am
Location: Germany
Contact:

Post by extreme001 »

Hi Frank!

Is there any chance to get the code you use?
It would make me much more relaxed...till i'm very frustrated.
Post Reply