These days I was working in a program that will use wxWidgets framework.
Basically, the application will have many panels and all of them must have a background image.
In my mind I had 2 options:
- for each panel I could put a background image in wxPanel plus all the controls that each panel required
- create a base class derived from wxPanel that would contain the background image and make it the base class for each panel in the application.
The second approach is better because that way I’d eliminate code duplication. That was the path I followed.
How would that work? When a class that inherited from BaseScreen were created, always the paint event of BaseScreen would be called prior to the paint event from the child class.
This way the image would be draw in on top of it the controls from child class would be draw. It would give the effect of having a background image. Continue reading “How to put a background image in a panel in wxWidgets”