How to get the Pressed, Focused and Disabled state bitmaps from a Normal state wxBitmap?

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
tomay3000
I live to help wx-kind
I live to help wx-kind
Posts: 191
Joined: Mon Apr 24, 2017 4:23 am

How to get the Pressed, Focused and Disabled state bitmaps from a Normal state wxBitmap?

Post by tomay3000 » Sun Mar 28, 2021 10:29 pm

Hello,

I need to get the Pressed, Focused and Disabled state bitmaps from a Normal state wxBitmap?
Is this possible?
I can't see it anywhere in the documentation.

TIA.

User avatar
doublemax
Moderator
Moderator
Posts: 16012
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to get the Pressed, Focused and Disabled state bitmaps from a Normal state wxBitmap?

Post by doublemax » Sun Mar 28, 2021 11:06 pm

Not possible because they don't exist. Maybe there is a misunderstanding, you *can* provide different bitmaps for all these states when creating a wxButton, but a single bitmap doesn't have these states hidden somewhere ;)

There is a method wxImage::ConvertToDisabled() to generate a disabled version from a normal bitmap, but that's it.
https://docs.wxwidgets.org/trunk/classw ... b3120f77db
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5152
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to get the Pressed, Focused and Disabled state bitmaps from a Normal state wxBitmap?

Post by ONEEYEMAN » Mon Mar 29, 2021 12:29 pm

Hi,
Why do you need to get it? What problem you are trying to solve?

Thank you.

tomay3000
I live to help wx-kind
I live to help wx-kind
Posts: 191
Joined: Mon Apr 24, 2017 4:23 am

Re: How to get the Pressed, Focused and Disabled state bitmaps from a Normal state wxBitmap?

Post by tomay3000 » Mon Mar 29, 2021 6:13 pm

ONEEYEMAN wrote:
Mon Mar 29, 2021 12:29 pm
Hi,
Why do you need to get it? What problem you are trying to solve?

Thank you.
Hello,
I am trying to implement an owner-draw bitmap button that changes the lightness on mouse hover, click or disabled states.

One state (Disabled) is already implemented [wxBitmap|wxImage]::ConvertToDisabled(), but the other state functions are not implemented.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5152
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to get the Pressed, Focused and Disabled state bitmaps from a Normal state wxBitmap?

Post by ONEEYEMAN » Mon Mar 29, 2021 6:52 pm

Hi,
This will the call for setter, not getter.

Why do you need the getters?

Thank you.

User avatar
doublemax
Moderator
Moderator
Posts: 16012
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to get the Pressed, Focused and Disabled state bitmaps from a Normal state wxBitmap?

Post by doublemax » Mon Mar 29, 2021 7:12 pm

tomay3000 wrote:
Mon Mar 29, 2021 6:13 pm
One state (Disabled) is already implemented [wxBitmap|wxImage]::ConvertToDisabled(), but the other state functions are not implemented.
If you really need these states (do you?), you have to implement the functions yourself, or create/edit them in an image editor.
Use the source, Luke!

tomay3000
I live to help wx-kind
I live to help wx-kind
Posts: 191
Joined: Mon Apr 24, 2017 4:23 am

Re: How to get the Pressed, Focused and Disabled state bitmaps from a Normal state wxBitmap?

Post by tomay3000 » Mon Mar 29, 2021 7:35 pm

doublemax wrote:
Mon Mar 29, 2021 7:12 pm
If you really need these states (do you?)
Sure I do, and I guess I have found where to start,
doublemax wrote:
Mon Mar 29, 2021 7:12 pm
you have to implement the functions yourself
I have to copy the function implementation

Code: Select all

wxImage wxImage::ConvertToDisabled(unsigned char brightness) const
source code and simply change the code

Code: Select all

wxColour::MakeDisabled(&r, &g, &b, brightness);
to

Code: Select all

wxColour::ChangeLightness(&r, &g, &b, ialpha);
I don't know if this is the correct approach or not!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 5152
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How to get the Pressed, Focused and Disabled state bitmaps from a Normal state wxBitmap?

Post by ONEEYEMAN » Mon Mar 29, 2021 7:51 pm

Hi,
But this is incorrect.
You are asking:

"How to get the Pressed state bitmap",

when you should be asking:

"How to modify the regular bitmap in order to set it as pressed"

Do you see the difference?

Is English you second language?

Thank you.

User avatar
doublemax
Moderator
Moderator
Posts: 16012
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to get the Pressed, Focused and Disabled state bitmaps from a Normal state wxBitmap?

Post by doublemax » Mon Mar 29, 2021 7:58 pm

Usually focus is indicated by a dotted rectangle, which you could draw using wxRendererNative::DrawFocusRect
https://docs.wxwidgets.org/trunk/classw ... 9559a8c4c9
(Focus is not the same as hover).

For the pressed state, usually the content is moved 2 pixel to the bottom right and a 3d-shared rectangle is drawn around the content.
Use the source, Luke!

tomay3000
I live to help wx-kind
I live to help wx-kind
Posts: 191
Joined: Mon Apr 24, 2017 4:23 am

Re: How to get the Pressed, Focused and Disabled state bitmaps from a Normal state wxBitmap?

Post by tomay3000 » Mon Mar 29, 2021 10:48 pm

ONEEYEMAN wrote:
Mon Mar 29, 2021 7:51 pm
Hi,
But this is incorrect.
You are asking:

"How to get the Pressed state bitmap",

when you should be asking:

"How to modify the regular bitmap in order to set it as pressed"
I am really sorry about that.
ONEEYEMAN wrote:
Mon Mar 29, 2021 7:51 pm
Is English you second language?

Thank you.
Actually, it is the third one.
Thank you for your understanding.

But doublemax, got it in the first-place.

tomay3000
I live to help wx-kind
I live to help wx-kind
Posts: 191
Joined: Mon Apr 24, 2017 4:23 am

Re: How to get the Pressed, Focused and Disabled state bitmaps from a Normal state wxBitmap?

Post by tomay3000 » Sat May 01, 2021 8:03 pm

Hello,
it is now possible.
It has been merged in wxWidgets github master:
https://github.com/wxWidgets/wxWidgets/pull/2310
https://github.com/wxWidgets/wxWidgets/ ... 793de2fc1b

Thank you.

User avatar
doublemax
Moderator
Moderator
Posts: 16012
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How to get the Pressed, Focused and Disabled state bitmaps from a Normal state wxBitmap?

Post by doublemax » Mon May 03, 2021 7:14 am

Nice. Thanks for the contribution =D>
Use the source, Luke!

Post Reply