#include <wx/bmpbndl.h>
Base class for custom implementations of wxBitmapBundle.
This class shouldn't be used directly in the application code, but may be derived from to implement custom bitmap bundles.
Example of use:
Full (but still very simple) example of using it can be found in the toolbar sample code.
Public Member Functions | |
virtual wxSize | GetDefaultSize () const =0 |
Return the size of the bitmaps represented by this bundle in the default DPI. More... | |
virtual wxSize | GetPreferredBitmapSizeAtScale (double scale) const =0 |
Return the preferred size that should be used at the given scale. More... | |
virtual wxBitmap | GetBitmap (const wxSize &size)=0 |
Retrieve the bitmap of exactly the given size. More... | |
Public Member Functions inherited from wxRefCounter | |
wxRefCounter () | |
Default constructor. More... | |
void | DecRef () |
Decrements the reference count associated with this shared data and, if it reaches zero, destroys this instance of wxRefCounter releasing its memory. More... | |
int | GetRefCount () const |
Returns the reference count associated with this shared data. More... | |
void | IncRef () |
Increments the reference count associated with this shared data. More... | |
Protected Member Functions | |
wxSize | DoGetPreferredSize (double scale) const |
Helper for implementing GetPreferredBitmapSizeAtScale() in the derived classes. More... | |
size_t | GetIndexToUpscale (const wxSize &size) const |
Return the index of the available scale most suitable to be upscaled to the given size. More... | |
virtual double | GetNextAvailableScale (size_t &i) const |
Return information about the available bitmaps. More... | |
Protected Member Functions inherited from wxRefCounter | |
virtual | ~wxRefCounter () |
Destructor. More... | |
|
protected |
Helper for implementing GetPreferredBitmapSizeAtScale() in the derived classes.
This function implements the standard algorithm used inside wxWidgets itself and tries to find the scale closest to the given one, while also trying to choose one of the available scales, to avoid actually rescaling the bitmaps.
It relies on GetNextAvailableScale() to get information about the available bitmaps, so that function must be overridden if this one is used.
Typically this function is used in the derived classes implementation to forward GetPreferredBitmapSizeAtScale() to it and when this is done, GetBitmap() may also use GetIndexToUpscale() to choose the bitmap to upscale if necessary:
scale | The required scale, typically the same one as passed to GetPreferredBitmapSizeAtScale(). |
Retrieve the bitmap of exactly the given size.
Note that this function is non-const because it may generate the bitmap on demand and cache it.
|
pure virtual |
Return the size of the bitmaps represented by this bundle in the default DPI.
Must always return a valid size.
|
protected |
Return the index of the available scale most suitable to be upscaled to the given size.
See DoGetPreferredSize() for an example of using this function.
size | The required size, typically the same one as passed to GetBitmap() |
|
protectedvirtual |
Return information about the available bitmaps.
Overriding this function is optional and only needs to be done if either DoGetPreferredSize() or GetIndexToUpscale() are called. If you do override it, this function must return the next available scale or 0.0 if there are no more.
The returned scales must be in ascending order and the first returned scale, for the initial i value of 0, should be 1. The function must change i, but the values of this index don't have to be consecutive and it's only used by this function itself, the caller only initializes it to 0 before the first call.
See DoGetPreferredSize() for an example of implementing this function.
|
pure virtual |
Return the preferred size that should be used at the given scale.
Must always return a valid size.