wxDataViewBitmapRenderer

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

wxDataViewBitmapRenderer

Manolo
Hi
I have a wxDataViewCtrl. The first column is a tree. Some others columns show bitmaps.
I want for some items (not all) to allow toggling between two different bitmaps. A few must allow to chose among several bitmaps. The rest of items don't show any bitmap at all.

My first idea is to derive from wxDataViewBitmapRenderer and override some methods, I don't know which one yet.
And I don't know which events should I handle, EVT_DATAVIEW_ITEM_START_EDITING?

Any help is appreciated.
Manolo

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: wxDataViewBitmapRenderer

Simon Richter
Hi,

On 13.03.2017 23:55, Manolo wrote:

> I have a wxDataViewCtrl. The first column is a tree. Some others columns
> show bitmaps.
> I want for some items (not all) to allow toggling between two different
> bitmaps. A few must allow to chose among several bitmaps. The rest of
> items don't show any bitmap at all.

I have something similar in KiCad, maybe you can get some inspiration there:

https://git.launchpad.net/~sjr/kicad/tree/eeschema/dialogs/dialog_lib_edit_pin_table.cpp

Note that this code is not yet merged into the main KiCad codebase,
because the on-demand created editor widget for the third column doesn't
work.

> My first idea is to derive from wxDataViewBitmapRenderer and override
> some methods, I don't know which one yet.

You can also make your data model select the appropriate bitmap.

> And I don't know which events should I handle,
> EVT_DATAVIEW_ITEM_START_EDITING?

Editing can be handled without custom event handlers, for the most part.
Your Renderer needs to create a widget if asked, and your data model
needs to handle SetValue calls.

   Simon

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: wxDataViewBitmapRenderer

Manolo
In reply to this post by Manolo
Thanks Simon.
I see in your code that you use PinTypeRenderer derived from wxDataViewCustomRenderer with all overrides the wx docs explain. The wxVariant is a "long", which I guess you use it to get/set the proper bitmap. Also, a custom ComboBox editor to chose that "long" (index in the combo).

That looks right to me. I still wonder if it can be also achieved with a custom renderer derived from
wxDataViewBitmapRenderer, in the hope of saving write code that is already written.

THX

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: wxDataViewBitmapRenderer

Manolo
In reply to this post by Manolo
More issues:
I've just realized I need, for a column, to let the user selects a color by calling the OS colour selection dialog.

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: wxDataViewBitmapRenderer

Manolo
In reply to this post by Manolo
For future readers:
The key is wxDataViewCustomRenderer::ActivateCell(). It allows to do whatever you want when the user "clicks" on the cell.
So I was able to do all of what I wanted deriving my own custom render from wxDataViewCustomRenderer

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Loading...