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.
I implemented a wxImagePanel to display and resize images stored as resources. Unfortunately I'm having problems because I don't want this image to be able to accept focus when the user hits tab.
class wxImagePanel : public wxPanel
{
protected:
// wxImage image;
wxBitmap *bitmap;
// if this is resized then we always own it otherwise it's null
wxBitmap *resizedbmp;
wxSize pnlsize;
// do we delete the bitmap when we're done?
bool bitmapOwned;
public:
wxImagePanel(wxWindow* parent, wxBitmap *bmp, bool owned=false);
virtual ~wxImagePanel();
void SetBitmap(wxBitmap *bmp);
void paintEvent(wxPaintEvent & evt);
void paintNow();
void OnSize(wxSizeEvent& event);
void render(wxDC& dc);
int GetHeight() { if (bitmap) return bitmap->GetHeight(); else return -1; }
virtual bool AcceptsFocus () const { return false; }
DECLARE_EVENT_TABLE()
};
As you can see I've overridden AcceptsFocus and coded it to return false.
When I hit tab SetFocus gets called. AcceptsFocus does not. Digging in the code there is a function called AcceptsFocusFromKeyboard() but it's not virtual so I can't see how to fix this...
I have managed to solve the problem. It turns out that in the Panel base class the methods were not virtual but when implemented in wxwindow they become vitrual so I was able to override them. Here is the code that shows it.