wxBitmapToggleButton images

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Rugruth
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Dec 03, 2014 8:59 am

wxBitmapToggleButton images

Post by Rugruth »

Hello all,

I'm working with wxBitmapToggleButton on my UI and I've come across a problem with it (version 3.0.1). I have two images, one for each state of the button (active/inactive) and it works pretty well. The problem is that I haven't defined images for focus or hover status, and if the button has the focus or mouse over it, the standard bitmap is shown (inactive), and it seems reasonable to me that the bitmap should be the corresponding with the activation of the button,

Searching on forums I've found this post: viewtopic.php?f=1&t=33023&p=137491&hili ... on#p161734 where someone suggest patching the library to address this problem.

Is this the best solution? Should I upgrade library to 3.1.0 ? Is there another solution like subclassing and write my own control?

Here i the relevant part of the code:

Code: Select all

m_toggle_Flipper1 = new wxBitmapToggleButton( m_scrolledWindow5, wxID_ANY, wxBitmap( wxT("../../Botones/boton_verde_ON_64.png"), wxBITMAP_TYPE_ANY ), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxNO_BORDER );
	
m_toggle_Flipper1->SetBitmapSelected( wxBitmap( wxT("../../Botones/boton_verde_OFF_64.png"), wxBITMAP_TYPE_ANY ) );
m_toggle_Flipper1->SetBackgroundColour( wxColour( 93, 93, 93 ) );
Thanks in advance,

R.
DenDev
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 231
Joined: Mon Jan 19, 2015 1:45 pm

Re: wxBitmapToggleButton images

Post by DenDev »

It should be straght forward to write you own control that reacts to wxEVT_SET_FOCUS, wxEVT_KILL_FOCUS , wxEVT_ENTER_WINDOW and wxEVT_LEAVE_WINDOW. You could also just bind the events to the parent window and adjust the bitmap in the event handlers.
I have a bad habbit of not testing the code I post :D
Rugruth
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Dec 03, 2014 8:59 am

Re: wxBitmapToggleButton images

Post by Rugruth »

For the records, upgrading to 3.0.2 fixed my problem.

Admins can close this thread if needed.
Post Reply