Add some comments to wxGtkImage

Document which pointers can, and can't, be null and when exactly is the
stored bitmap valid, as this is far from being immediately obvious.

No real changes.
This commit is contained in:
Vadim Zeitlin
2021-10-16 17:01:48 +02:00
parent eb54c65e24
commit 8f1be368e9
2 changed files with 13 additions and 0 deletions

View File

@@ -23,9 +23,13 @@ public:
static GtkWidget* New(wxWindow* win = NULL); static GtkWidget* New(wxWindow* win = NULL);
void Set(const wxBitmap& bitmap); void Set(const wxBitmap& bitmap);
// This pointer is never null and is owned by this class.
BitmapProvider* m_provider; BitmapProvider* m_provider;
wxDECLARE_NO_COPY_CLASS(wxGtkImage); wxDECLARE_NO_COPY_CLASS(wxGtkImage);
// This class is constructed by New() and destroyed by its GObject
// finalizer, so neither its ctor nor dtor can ever be used.
wxGtkImage() wxMEMBER_DELETE; wxGtkImage() wxMEMBER_DELETE;
~wxGtkImage() wxMEMBER_DELETE; ~wxGtkImage() wxMEMBER_DELETE;
}; };

View File

@@ -24,8 +24,17 @@ struct BitmapProviderDefault: wxGtkImage::BitmapProvider
BitmapProviderDefault(wxWindow* win) : m_win(win) { } BitmapProviderDefault(wxWindow* win) : m_win(win) { }
virtual wxBitmap Get() const wxOVERRIDE; virtual wxBitmap Get() const wxOVERRIDE;
virtual void Set(const wxBitmap& bitmap) wxOVERRIDE; virtual void Set(const wxBitmap& bitmap) wxOVERRIDE;
// This pointer can be null if there is no associated window.
wxWindow* const m_win; wxWindow* const m_win;
// The bitmap stored here is only valid if it uses scale factor > 1,
// otherwise we leave it invalid to indicate the drawing the bitmap should
// be left to GtkImage itself.
wxBitmap m_bitmap; wxBitmap m_bitmap;
// This bitmap is only valid if m_bitmap is and if we have the associated
// window (as otherwise it would never be used at all).
wxBitmap m_bitmapDisabled; wxBitmap m_bitmapDisabled;
}; };