Finally getting back to this. First a little relevant background. I have been using wxWidgets since version 2.6. I develop industrial and laboratory interfaces for our test equipment. Those interfaces are as simple as possible, all the magic occurs on the back-end and the major work is in communication and data storage/manipulation. I have used wxStaticBitmap control to display an application header image (logo) but have never used wxDC, or any of the image related functionality. I have never worked with images and had no understanding of image formats. I have managed, with the help of the well above average wxWidgets documentation, to figure out everything I need for this application except for this button text problem.
@PB I use a similar method to draw some button bitmaps, although I used the gradient drawing functions, and then use my DrawLabelOnBitmapButton() algorithm to draw text on those bitmaps and assign to a button. It is two stage (create the bitmap, pass it to DrawLabelOnBitmapbutton()) and works as expected regardless of the background color of the button. Those are the buttons on the left of the attached image.
I added code to set a mask to wxCYAN. which does not occur in the image, to try and ensure that nothing was masked off.
The green/gray buttons start out as png images on disk using alpha channel for transparency.
Those images are loaded into memory at application startup into a wxVecotr<wxBitmap*> bitmaps by calling the following function:
Code: Select all
wxBitmap* GetChoiceStripBitmap(ChoiceStripBitmap csbm)
wxBitmap* bitmap = nullptr;
bitmap = new wxBitmap("resource\\images\\choice_strip\\choice_strip_left_unselected.png", wxBITMAP_TYPE_PNG);
bitmap = new wxBitmap("resource\\images\\choice_strip\\choice_strip_left_selected.png", wxBITMAP_TYPE_PNG);
bitmap = new wxBitmap("resource\\images\\choice_strip\\choice_strip_right_unselected.png", wxBITMAP_TYPE_PNG);
bitmap = new wxBitmap("resource\\images\\choice_strip\\choice_strip_right_selected.png", wxBITMAP_TYPE_PNG);
bitmap = new wxBitmap("resource\\images\\choice_strip\\choice_strip_inside_unselected.png", wxBITMAP_TYPE_PNG);
bitmap = new wxBitmap("resource\\images\\choice_strip\\choice_strip_inside_selected.png", wxBITMAP_TYPE_PNG);
; // do nothing, bitmap is alrady nullptr
then copy the bitmap as needed using CopyBitmap(*bitmaps[target_index]);
The main difference between the buttons which have correct colored text and buttons which have text the same color as the button background is the way the wxBitmap is obtained.
I can change the color of the affected buttons text on the fly by changing the button background color so I am assuming that the text is being drawn transparent somehow.
Attached is an image of how the buttons look and one of the choice strip bitmaps used. The yellow button text was produced simply by changing the background color of that button. The buttons on the left have background set to yellow and cyan but that does not show through the text.
Any ideas to point me in a the direction of figuring this out are appreciated. I have tried to trace though the code but confess that my understanding of the window drawing/painting process is sub-par at best and I usually end up getting lost.