Take wxBitmapBundle in wxStaticBitmap::SetBitmap()
This allows using higher resolution bitmaps when using high DPI automatically in this control too.
This commit is contained in:
@@ -18,7 +18,7 @@ public:
|
|||||||
wxGenericStaticBitmap() {}
|
wxGenericStaticBitmap() {}
|
||||||
wxGenericStaticBitmap(wxWindow *parent,
|
wxGenericStaticBitmap(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
@@ -29,22 +29,20 @@ public:
|
|||||||
|
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
||||||
|
|
||||||
virtual void SetBitmap(const wxBitmap& bitmap) wxOVERRIDE
|
virtual void SetBitmap(const wxBitmapBundle& bitmap) wxOVERRIDE
|
||||||
{
|
{
|
||||||
m_bitmap = bitmap;
|
m_bitmapBundle = bitmap;
|
||||||
InvalidateBestSize();
|
InvalidateBestSize();
|
||||||
SetSize(GetBestSize());
|
SetSize(GetBestSize());
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual wxBitmap GetBitmap() const wxOVERRIDE { return m_bitmap; }
|
|
||||||
|
|
||||||
virtual void SetScaleMode(ScaleMode scaleMode) wxOVERRIDE
|
virtual void SetScaleMode(ScaleMode scaleMode) wxOVERRIDE
|
||||||
{
|
{
|
||||||
m_scaleMode = scaleMode;
|
m_scaleMode = scaleMode;
|
||||||
@@ -56,7 +54,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
|
|
||||||
wxBitmap m_bitmap;
|
|
||||||
ScaleMode m_scaleMode;
|
ScaleMode m_scaleMode;
|
||||||
|
|
||||||
wxDECLARE_DYNAMIC_CLASS(wxGenericStaticBitmap);
|
wxDECLARE_DYNAMIC_CLASS(wxGenericStaticBitmap);
|
||||||
|
|||||||
@@ -21,28 +21,25 @@ public:
|
|||||||
wxStaticBitmap();
|
wxStaticBitmap();
|
||||||
wxStaticBitmap( wxWindow *parent,
|
wxStaticBitmap( wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
||||||
bool Create( wxWindow *parent,
|
bool Create( wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
||||||
|
|
||||||
virtual void SetBitmap( const wxBitmap& bitmap ) wxOVERRIDE;
|
virtual void SetBitmap( const wxBitmapBundle& bitmap ) wxOVERRIDE;
|
||||||
virtual wxBitmap GetBitmap() const wxOVERRIDE { return m_bitmap; }
|
|
||||||
|
|
||||||
static wxVisualAttributes
|
static wxVisualAttributes
|
||||||
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxBitmap m_bitmap;
|
|
||||||
|
|
||||||
wxDECLARE_DYNAMIC_CLASS(wxStaticBitmap);
|
wxDECLARE_DYNAMIC_CLASS(wxStaticBitmap);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -21,21 +21,20 @@ public:
|
|||||||
wxStaticBitmap();
|
wxStaticBitmap();
|
||||||
wxStaticBitmap( wxWindow *parent,
|
wxStaticBitmap( wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr) );
|
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr) );
|
||||||
bool Create( wxWindow *parent,
|
bool Create( wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
||||||
|
|
||||||
virtual void SetBitmap( const wxBitmap& bitmap );
|
virtual void SetBitmapBundle( const wxBitmapBundle& bitmap );
|
||||||
virtual wxBitmap GetBitmap() const { return m_bitmap; }
|
|
||||||
|
|
||||||
static wxVisualAttributes
|
static wxVisualAttributes
|
||||||
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public:
|
|||||||
virtual ~wxStaticBitmap();
|
virtual ~wxStaticBitmap();
|
||||||
|
|
||||||
wxStaticBitmap(wxWindow *parent, wxWindowID id,
|
wxStaticBitmap(wxWindow *parent, wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
@@ -33,21 +33,19 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Create(wxWindow *parent, wxWindowID id,
|
bool Create(wxWindow *parent, wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
||||||
|
|
||||||
virtual void SetBitmap(const wxBitmap& bitmap);
|
virtual void SetBitmap(const wxBitmapBundle& bitmap);
|
||||||
|
|
||||||
virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event))
|
virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap GetBitmap() const { return m_messageBitmap; }
|
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
virtual void ChangeBackgroundColour();
|
virtual void ChangeBackgroundColour();
|
||||||
virtual void ChangeForegroundColour();
|
virtual void ChangeForegroundColour();
|
||||||
@@ -57,7 +55,7 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxBitmap m_messageBitmap;
|
wxBitmap m_messageBitmap;
|
||||||
wxBitmap m_messageBitmapOriginal;
|
wxBitmapBundle m_messageBitmapOriginal;
|
||||||
wxBitmapCache m_bitmapCache;
|
wxBitmapCache m_bitmapCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
|
|
||||||
wxStaticBitmap(wxWindow *parent,
|
wxStaticBitmap(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
@@ -51,13 +51,13 @@ public:
|
|||||||
|
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr))
|
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr))
|
||||||
{
|
{
|
||||||
m_bitmap = label;
|
m_bitmapBundle = label;
|
||||||
|
|
||||||
return DoCreate(parent, id, pos, size, style, name);
|
return DoCreate(parent, id, pos, size, style, name);
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
virtual ~wxStaticBitmap() { Free(); }
|
virtual ~wxStaticBitmap() { Free(); }
|
||||||
|
|
||||||
virtual void SetIcon(const wxIcon& icon) wxOVERRIDE;
|
virtual void SetIcon(const wxIcon& icon) wxOVERRIDE;
|
||||||
virtual void SetBitmap(const wxBitmap& bitmap) wxOVERRIDE;
|
virtual void SetBitmap(const wxBitmapBundle& bitmap) wxOVERRIDE;
|
||||||
virtual wxBitmap GetBitmap() const wxOVERRIDE;
|
virtual wxBitmap GetBitmap() const wxOVERRIDE;
|
||||||
virtual wxIcon GetIcon() const wxOVERRIDE;
|
virtual wxIcon GetIcon() const wxOVERRIDE;
|
||||||
|
|
||||||
@@ -103,9 +103,9 @@ private:
|
|||||||
long style,
|
long style,
|
||||||
const wxString& name);
|
const wxString& name);
|
||||||
|
|
||||||
// update the image to correspond to the current m_icon or m_bitmap value,
|
// update the image to correspond to the current m_icon or m_bitmapBundle
|
||||||
// resize the control if the new size is different from the old one and
|
// value, resize the control if the new size is different from the old one
|
||||||
// update its style if the new "is icon" value differs from the old one
|
// and update its style if the new "is icon" value differs from the old one
|
||||||
void DoUpdateImage(const wxSize& sizeOld, bool wasIcon);
|
void DoUpdateImage(const wxSize& sizeOld, bool wasIcon);
|
||||||
|
|
||||||
// draw the bitmap ourselves here if the OS can't do it correctly (if it
|
// draw the bitmap ourselves here if the OS can't do it correctly (if it
|
||||||
@@ -114,15 +114,14 @@ private:
|
|||||||
|
|
||||||
void WXHandleSize(wxSizeEvent& event);
|
void WXHandleSize(wxSizeEvent& event);
|
||||||
|
|
||||||
// return the either m_icon or m_bitmap (may still be invalid of both of
|
// return the size of m_icon or the appropriate size of m_bitmapBundle at
|
||||||
// them are)
|
// the current DPI scaling (may still be invalid of both of them are)
|
||||||
const wxGDIImage& GetImage() const;
|
wxSize GetImageSize() const;
|
||||||
|
|
||||||
|
|
||||||
// we can have either an icon or a bitmap: if m_icon is valid, it is used,
|
// we can have either an icon or a bitmap: if m_icon is valid, it is used,
|
||||||
// otherwise m_bitmap is used if it is valid
|
// otherwise m_bitmapBundle defined in the base class is used if it is valid
|
||||||
wxIcon m_icon;
|
wxIcon m_icon;
|
||||||
wxBitmap m_bitmap;
|
|
||||||
|
|
||||||
// handle used in last call to STM_SETIMAGE
|
// handle used in last call to STM_SETIMAGE
|
||||||
WXHANDLE m_currentHandle;
|
WXHANDLE m_currentHandle;
|
||||||
|
|||||||
@@ -586,7 +586,7 @@ public :
|
|||||||
static wxWidgetImplType* CreateStaticBitmap( wxWindowMac* wxpeer,
|
static wxWidgetImplType* CreateStaticBitmap( wxWindowMac* wxpeer,
|
||||||
wxWindowMac* parent,
|
wxWindowMac* parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size,
|
const wxSize& size,
|
||||||
long style,
|
long style,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public:
|
|||||||
wxStaticBitmap() {}
|
wxStaticBitmap() {}
|
||||||
wxStaticBitmap(wxWindow *parent,
|
wxStaticBitmap(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
@@ -20,15 +20,13 @@ public:
|
|||||||
|
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
||||||
|
|
||||||
virtual void SetBitmap(const wxBitmap& bitmap) wxOVERRIDE;
|
virtual void SetBitmap(const wxBitmapBundle& bitmap) wxOVERRIDE;
|
||||||
|
|
||||||
virtual wxBitmap GetBitmap() const wxOVERRIDE { return m_bitmap; }
|
|
||||||
|
|
||||||
virtual void SetScaleMode(ScaleMode scaleMode) wxOVERRIDE;
|
virtual void SetScaleMode(ScaleMode scaleMode) wxOVERRIDE;
|
||||||
|
|
||||||
@@ -37,7 +35,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
|
|
||||||
wxBitmap m_bitmap;
|
|
||||||
ScaleMode m_scaleMode;
|
ScaleMode m_scaleMode;
|
||||||
|
|
||||||
wxDECLARE_DYNAMIC_CLASS(wxStaticBitmap);
|
wxDECLARE_DYNAMIC_CLASS(wxStaticBitmap);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public:
|
|||||||
wxStaticBitmap();
|
wxStaticBitmap();
|
||||||
wxStaticBitmap( wxWindow *parent,
|
wxStaticBitmap( wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
@@ -24,13 +24,13 @@ public:
|
|||||||
|
|
||||||
bool Create( wxWindow *parent,
|
bool Create( wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
||||||
|
|
||||||
virtual void SetBitmap(const wxBitmap& bitmap) wxOVERRIDE;
|
virtual void SetBitmap(const wxBitmapBundle& bitmap) wxOVERRIDE;
|
||||||
virtual wxBitmap GetBitmap() const wxOVERRIDE;
|
virtual wxBitmap GetBitmap() const wxOVERRIDE;
|
||||||
|
|
||||||
virtual QWidget *GetHandle() const wxOVERRIDE;
|
virtual QWidget *GetHandle() const wxOVERRIDE;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#if wxUSE_STATBMP
|
#if wxUSE_STATBMP
|
||||||
|
|
||||||
#include "wx/control.h"
|
#include "wx/control.h"
|
||||||
#include "wx/bitmap.h"
|
#include "wx/bmpbndl.h"
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
|
|
||||||
extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticBitmapNameStr[];
|
extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticBitmapNameStr[];
|
||||||
@@ -37,8 +37,8 @@ public:
|
|||||||
virtual ~wxStaticBitmapBase();
|
virtual ~wxStaticBitmapBase();
|
||||||
|
|
||||||
// our interface
|
// our interface
|
||||||
virtual void SetBitmap(const wxBitmap& bitmap) = 0;
|
virtual void SetBitmap(const wxBitmapBundle& bitmap) = 0;
|
||||||
virtual wxBitmap GetBitmap() const = 0;
|
virtual wxBitmap GetBitmap() const;
|
||||||
|
|
||||||
virtual void SetIcon(const wxIcon& icon);
|
virtual void SetIcon(const wxIcon& icon);
|
||||||
virtual wxIcon GetIcon() const;
|
virtual wxIcon GetIcon() const;
|
||||||
@@ -56,6 +56,9 @@ protected:
|
|||||||
|
|
||||||
virtual wxSize DoGetBestSize() const wxOVERRIDE;
|
virtual wxSize DoGetBestSize() const wxOVERRIDE;
|
||||||
|
|
||||||
|
// Bitmap bundle passed to ctor or SetBitmap().
|
||||||
|
wxBitmapBundle m_bitmapBundle;
|
||||||
|
|
||||||
wxDECLARE_NO_COPY_CLASS(wxStaticBitmapBase);
|
wxDECLARE_NO_COPY_CLASS(wxStaticBitmapBase);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxStaticBitmap(wxWindow *parent,
|
wxStaticBitmap(wxWindow *parent,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0)
|
long style = 0)
|
||||||
@@ -35,7 +35,7 @@ public:
|
|||||||
|
|
||||||
wxStaticBitmap(wxWindow *parent,
|
wxStaticBitmap(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
@@ -46,14 +46,13 @@ public:
|
|||||||
|
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
const wxString& name = wxASCII_STR(wxStaticBitmapNameStr));
|
||||||
|
|
||||||
virtual void SetBitmap(const wxBitmap& bitmap) wxOVERRIDE;
|
virtual void SetBitmap(const wxBitmapBundle& bitmap) wxOVERRIDE;
|
||||||
virtual wxBitmap GetBitmap() const wxOVERRIDE { return m_bitmap; }
|
|
||||||
|
|
||||||
virtual bool HasTransparentBackground() wxOVERRIDE { return true; }
|
virtual bool HasTransparentBackground() wxOVERRIDE { return true; }
|
||||||
|
|
||||||
@@ -61,9 +60,6 @@ protected:
|
|||||||
virtual void DoDraw(wxControlRenderer *renderer) wxOVERRIDE;
|
virtual void DoDraw(wxControlRenderer *renderer) wxOVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// the bitmap which we show
|
|
||||||
wxBitmap m_bitmap;
|
|
||||||
|
|
||||||
wxDECLARE_DYNAMIC_CLASS(wxStaticBitmap);
|
wxDECLARE_DYNAMIC_CLASS(wxStaticBitmap);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
#include "wx/statbmp.h"
|
#include "wx/statbmp.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
extern WXDLLEXPORT_DATA(const char) wxStaticBitmapNameStr[] = "staticBitmap";
|
extern WXDLLEXPORT_DATA(const char) wxStaticBitmapNameStr[] = "staticBitmap";
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -91,9 +93,29 @@ wxStaticBitmapBase::~wxStaticBitmapBase()
|
|||||||
|
|
||||||
wxSize wxStaticBitmapBase::DoGetBestSize() const
|
wxSize wxStaticBitmapBase::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
|
if ( m_bitmapBundle.IsOk() )
|
||||||
|
{
|
||||||
|
// We return the scaled (i.e. in logical pixels) size of the bitmap
|
||||||
|
// that would be returned by GetBitmap(), but without bothering to
|
||||||
|
// actually create the bitmap here.
|
||||||
|
//
|
||||||
|
// Note that we can use content scale factor rather than DPI scale
|
||||||
|
// because the scaled size is the same as normal size on platforms
|
||||||
|
// without wxHAVE_DPI_INDEPENDENT_PIXELS (e.g. wxMSW) anyhow.
|
||||||
|
const wxSize size = m_bitmapBundle.GetPreferredSizeFor(this);
|
||||||
|
const double scale = GetContentScaleFactor();
|
||||||
|
|
||||||
|
// We have to round up the size to avoid truncating the bitmap.
|
||||||
|
return wxSize(ceil(size.x/scale), ceil(size.y/scale));
|
||||||
|
}
|
||||||
|
|
||||||
// the fall back size is completely arbitrary
|
// the fall back size is completely arbitrary
|
||||||
const wxBitmap bmp = GetBitmap();
|
return wxSize(16, 16);
|
||||||
return bmp.IsOk() ? bmp.GetScaledSize() : wxSize(16, 16);
|
}
|
||||||
|
|
||||||
|
wxBitmap wxStaticBitmapBase::GetBitmap() const
|
||||||
|
{
|
||||||
|
return m_bitmapBundle.GetBitmapFor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only wxMSW handles icons and bitmaps differently, in all the other ports
|
// Only wxMSW handles icons and bitmaps differently, in all the other ports
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool wxGenericStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
bool wxGenericStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
const wxPoint& pos, const wxSize& size,
|
const wxPoint& pos, const wxSize& size,
|
||||||
long style, const wxString& name)
|
long style, const wxString& name)
|
||||||
{
|
{
|
||||||
@@ -38,7 +38,7 @@ bool wxGenericStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
|||||||
// Don't call SetBitmap() here, as it changes the size and refreshes the
|
// Don't call SetBitmap() here, as it changes the size and refreshes the
|
||||||
// window unnecessarily, when we don't need either of these side effects
|
// window unnecessarily, when we don't need either of these side effects
|
||||||
// here.
|
// here.
|
||||||
m_bitmap = bitmap;
|
m_bitmapBundle = bitmap;
|
||||||
SetInitialSize(size);
|
SetInitialSize(size);
|
||||||
|
|
||||||
Bind(wxEVT_PAINT, &wxGenericStaticBitmap::OnPaint, this);
|
Bind(wxEVT_PAINT, &wxGenericStaticBitmap::OnPaint, this);
|
||||||
@@ -47,7 +47,7 @@ bool wxGenericStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
void wxGenericStaticBitmap::OnPaint(wxPaintEvent& WXUNUSED(event))
|
void wxGenericStaticBitmap::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if ( !m_bitmap.IsOk() )
|
if ( !m_bitmapBundle.IsOk() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
@@ -55,13 +55,14 @@ void wxGenericStaticBitmap::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|||||||
if ( !drawSize.x || !drawSize.y )
|
if ( !drawSize.x || !drawSize.y )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const wxSize bmpSize = m_bitmap.GetSize();
|
const wxBitmap bitmap = GetBitmap();
|
||||||
|
const wxSize bmpSize = bitmap.GetSize();
|
||||||
wxDouble w = 0;
|
wxDouble w = 0;
|
||||||
wxDouble h = 0;
|
wxDouble h = 0;
|
||||||
switch ( m_scaleMode )
|
switch ( m_scaleMode )
|
||||||
{
|
{
|
||||||
case Scale_None:
|
case Scale_None:
|
||||||
dc.DrawBitmap(m_bitmap, 0, 0, true);
|
dc.DrawBitmap(bitmap, 0, 0, true);
|
||||||
return;
|
return;
|
||||||
case Scale_Fill:
|
case Scale_Fill:
|
||||||
w = drawSize.x;
|
w = drawSize.x;
|
||||||
@@ -93,9 +94,9 @@ void wxGenericStaticBitmap::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|||||||
#if wxUSE_GRAPHICS_CONTEXT
|
#if wxUSE_GRAPHICS_CONTEXT
|
||||||
wxScopedPtr<wxGraphicsContext> const
|
wxScopedPtr<wxGraphicsContext> const
|
||||||
gc(wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc));
|
gc(wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc));
|
||||||
gc->DrawBitmap(m_bitmap, x, y, w, h);
|
gc->DrawBitmap(bitmap, x, y, w, h);
|
||||||
#else
|
#else
|
||||||
wxImage img = m_bitmap.ConvertToImage();
|
wxImage img = bitmap.ConvertToImage();
|
||||||
img.Rescale(wxRound(w), wxRound(h), wxIMAGE_QUALITY_HIGH);
|
img.Rescale(wxRound(w), wxRound(h), wxIMAGE_QUALITY_HIGH);
|
||||||
dc.DrawBitmap(wxBitmap(img), wxRound(x), wxRound(y), true);
|
dc.DrawBitmap(wxBitmap(img), wxRound(x), wxRound(y), true);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ wxStaticBitmap::wxStaticBitmap(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
|
wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmapBundle &bitmap,
|
||||||
const wxPoint &pos, const wxSize &size,
|
const wxPoint &pos, const wxSize &size,
|
||||||
long style, const wxString &name )
|
long style, const wxString &name )
|
||||||
{
|
{
|
||||||
Create( parent, id, bitmap, pos, size, style, name );
|
Create( parent, id, bitmap, pos, size, style, name );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
|
bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmapBundle &bitmap,
|
||||||
const wxPoint &pos, const wxSize &size,
|
const wxPoint &pos, const wxSize &size,
|
||||||
long style, const wxString &name )
|
long style, const wxString &name )
|
||||||
{
|
{
|
||||||
@@ -54,12 +54,14 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
|
void wxStaticBitmap::SetBitmap( const wxBitmapBundle &bitmap )
|
||||||
{
|
{
|
||||||
const wxSize sizeOld(m_bitmap.IsOk() ? m_bitmap.GetSize() : wxSize());
|
const wxSize sizeOld(DoGetBestSize());
|
||||||
const wxSize sizeNew(bitmap.IsOk() ? bitmap.GetSize() : wxSize());
|
|
||||||
|
m_bitmapBundle = bitmap;
|
||||||
|
|
||||||
|
const wxSize sizeNew(DoGetBestSize());
|
||||||
|
|
||||||
m_bitmap = bitmap;
|
|
||||||
WX_GTK_IMAGE(m_widget)->Set(bitmap);
|
WX_GTK_IMAGE(m_widget)->Set(bitmap);
|
||||||
|
|
||||||
if (sizeNew != sizeOld)
|
if (sizeNew != sizeOld)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ wxStaticBitmap::wxStaticBitmap(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
|
wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmapBundle &bitmap,
|
||||||
const wxPoint &pos, const wxSize &size,
|
const wxPoint &pos, const wxSize &size,
|
||||||
long style, const wxString &name )
|
long style, const wxString &name )
|
||||||
{
|
{
|
||||||
@@ -38,7 +38,7 @@ static char * bogus_xpm[] = {
|
|||||||
" ",
|
" ",
|
||||||
" "};
|
" "};
|
||||||
|
|
||||||
bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
|
bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmapBundle &bitmap,
|
||||||
const wxPoint &pos, const wxSize &size,
|
const wxPoint &pos, const wxSize &size,
|
||||||
long style, const wxString &name )
|
long style, const wxString &name )
|
||||||
{
|
{
|
||||||
@@ -52,6 +52,7 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_bitmap = bitmap;
|
m_bitmap = bitmap;
|
||||||
|
m_bitmapBundle = bitmap;
|
||||||
|
|
||||||
wxBitmap bmp(bitmap.IsOk() ? bitmap : wxBitmap(bogus_xpm));
|
wxBitmap bmp(bitmap.IsOk() ? bitmap : wxBitmap(bogus_xpm));
|
||||||
m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL);
|
m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL);
|
||||||
@@ -65,9 +66,10 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
|
void wxStaticBitmap::SetBitmap( const wxBitmapBundle &bitmap )
|
||||||
{
|
{
|
||||||
m_bitmap = bitmap;
|
m_bitmapBundle = bitmap;
|
||||||
|
m_bitmap = bitmap.GetBitmapFor(this);
|
||||||
|
|
||||||
if (m_bitmap.IsOk())
|
if (m_bitmap.IsOk())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size,
|
const wxSize& size,
|
||||||
long style,
|
long style,
|
||||||
@@ -41,7 +41,6 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
|||||||
return false;
|
return false;
|
||||||
PreCreation();
|
PreCreation();
|
||||||
|
|
||||||
m_messageBitmap = bitmap;
|
|
||||||
m_messageBitmapOriginal = bitmap;
|
m_messageBitmapOriginal = bitmap;
|
||||||
|
|
||||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||||
@@ -58,9 +57,9 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
|||||||
wxSize actualSize(size);
|
wxSize actualSize(size);
|
||||||
// work around the cases where the bitmap is a wxNull(Icon/Bitmap)
|
// work around the cases where the bitmap is a wxNull(Icon/Bitmap)
|
||||||
if (actualSize.x == -1)
|
if (actualSize.x == -1)
|
||||||
actualSize.x = bitmap.IsOk() ? bitmap.GetWidth() : 16;
|
actualSize.x = bitmap.IsOk() ? bitmap.GetDefaultSize().x : 16;
|
||||||
if (actualSize.y == -1)
|
if (actualSize.y == -1)
|
||||||
actualSize.y = bitmap.IsOk() ? bitmap.GetHeight() : 16;
|
actualSize.y = bitmap.IsOk() ? bitmap.GetDefaultSize().y : 16;
|
||||||
|
|
||||||
PostCreation();
|
PostCreation();
|
||||||
DoSetBitmap();
|
DoSetBitmap();
|
||||||
@@ -80,16 +79,17 @@ void wxStaticBitmap::DoSetBitmap()
|
|||||||
Widget widget = (Widget) m_mainWidget;
|
Widget widget = (Widget) m_mainWidget;
|
||||||
int w2, h2;
|
int w2, h2;
|
||||||
|
|
||||||
if (m_messageBitmapOriginal.IsOk())
|
wxBitmap bitmapOriginal = m_messageBitmapOriginal.GetBitmap(wxDefaultSize);
|
||||||
|
if (bitmapOriginal.IsOk())
|
||||||
{
|
{
|
||||||
w2 = m_messageBitmapOriginal.GetWidth();
|
w2 = bitmapOriginal.GetWidth();
|
||||||
h2 = m_messageBitmapOriginal.GetHeight();
|
h2 = bitmapOriginal.GetHeight();
|
||||||
|
|
||||||
Pixmap pixmap;
|
Pixmap pixmap;
|
||||||
|
|
||||||
// Must re-make the bitmap to have its transparent areas drawn
|
// Must re-make the bitmap to have its transparent areas drawn
|
||||||
// in the current widget background colour.
|
// in the current widget background colour.
|
||||||
if (m_messageBitmapOriginal.GetMask())
|
if (bitmapOriginal.GetMask())
|
||||||
{
|
{
|
||||||
WXPixel backgroundPixel;
|
WXPixel backgroundPixel;
|
||||||
XtVaGetValues( widget, XmNbackground, &backgroundPixel,
|
XtVaGetValues( widget, XmNbackground, &backgroundPixel,
|
||||||
@@ -98,13 +98,14 @@ void wxStaticBitmap::DoSetBitmap()
|
|||||||
wxColour col;
|
wxColour col;
|
||||||
col.SetPixel(backgroundPixel);
|
col.SetPixel(backgroundPixel);
|
||||||
|
|
||||||
wxBitmap newBitmap = wxCreateMaskedBitmap(m_messageBitmapOriginal, col);
|
wxBitmap newBitmap = wxCreateMaskedBitmap(bitmapOriginal, col);
|
||||||
m_messageBitmap = newBitmap;
|
m_messageBitmap = newBitmap;
|
||||||
|
|
||||||
pixmap = (Pixmap) m_messageBitmap.GetDrawable();
|
pixmap = (Pixmap) m_messageBitmap.GetDrawable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
m_messageBitmap = bitmapOriginal;
|
||||||
m_bitmapCache.SetBitmap( m_messageBitmap );
|
m_bitmapCache.SetBitmap( m_messageBitmap );
|
||||||
pixmap = (Pixmap)m_bitmapCache.GetLabelPixmap(widget);
|
pixmap = (Pixmap)m_bitmapCache.GetLabelPixmap(widget);
|
||||||
}
|
}
|
||||||
@@ -127,9 +128,8 @@ void wxStaticBitmap::DoSetBitmap()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
void wxStaticBitmap::SetBitmap(const wxBitmapBundle& bitmap)
|
||||||
{
|
{
|
||||||
m_messageBitmap = bitmap;
|
|
||||||
m_messageBitmapOriginal = bitmap;
|
m_messageBitmapOriginal = bitmap;
|
||||||
|
|
||||||
DoSetBitmap();
|
DoSetBitmap();
|
||||||
|
|||||||
@@ -105,34 +105,30 @@ WXDWORD wxStaticBitmap::MSWGetStyle(long style, WXDWORD *exstyle) const
|
|||||||
return msStyle;
|
return msStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxGDIImage& wxStaticBitmap::GetImage() const
|
wxSize wxStaticBitmap::GetImageSize() const
|
||||||
{
|
{
|
||||||
// Note: do not use ternary operator here to avoid unwanted conversions
|
return m_icon.IsOk() ? m_icon.GetSize()
|
||||||
// from wxIcon to wxBitmap.
|
: m_bitmapBundle.GetPreferredSizeFor(this);
|
||||||
if ( m_icon.IsOk() )
|
|
||||||
return m_icon;
|
|
||||||
|
|
||||||
return m_bitmap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxStaticBitmap::SetIcon(const wxIcon& icon)
|
void wxStaticBitmap::SetIcon(const wxIcon& icon)
|
||||||
{
|
{
|
||||||
const wxSize sizeOld = GetImage().GetSize();
|
const wxSize sizeOld = GetImageSize();
|
||||||
const bool wasIcon = m_icon.IsOk();
|
const bool wasIcon = m_icon.IsOk();
|
||||||
|
|
||||||
m_icon = icon;
|
m_icon = icon;
|
||||||
m_bitmap = wxBitmap();
|
m_bitmapBundle = wxBitmapBundle();
|
||||||
|
|
||||||
DoUpdateImage(sizeOld, wasIcon);
|
DoUpdateImage(sizeOld, wasIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
void wxStaticBitmap::SetBitmap(const wxBitmapBundle& bitmap)
|
||||||
{
|
{
|
||||||
const wxSize sizeOld = GetImage().GetSize();
|
const wxSize sizeOld = GetImageSize();
|
||||||
const bool wasIcon = m_icon.IsOk();
|
const bool wasIcon = m_icon.IsOk();
|
||||||
|
|
||||||
m_icon = wxIcon();
|
m_icon = wxIcon();
|
||||||
m_bitmap = bitmap;
|
m_bitmapBundle = bitmap;
|
||||||
|
|
||||||
DoUpdateImage(sizeOld, wasIcon);
|
DoUpdateImage(sizeOld, wasIcon);
|
||||||
}
|
}
|
||||||
@@ -140,15 +136,15 @@ void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
|||||||
wxIcon wxStaticBitmap::GetIcon() const
|
wxIcon wxStaticBitmap::GetIcon() const
|
||||||
{
|
{
|
||||||
wxIcon icon = m_icon;
|
wxIcon icon = m_icon;
|
||||||
if ( !icon.IsOk() && m_bitmap.IsOk() )
|
if ( !icon.IsOk() && m_bitmapBundle.IsOk() )
|
||||||
icon.CopyFromBitmap(m_bitmap);
|
icon.CopyFromBitmap(m_bitmapBundle.GetBitmapFor(this));
|
||||||
|
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap wxStaticBitmap::GetBitmap() const
|
wxBitmap wxStaticBitmap::GetBitmap() const
|
||||||
{
|
{
|
||||||
wxBitmap bitmap = m_bitmap;
|
wxBitmap bitmap = m_bitmapBundle.GetBitmapFor(this);
|
||||||
if ( !bitmap.IsOk() && m_icon.IsOk() )
|
if ( !bitmap.IsOk() && m_icon.IsOk() )
|
||||||
bitmap.CopyFromIcon(m_icon);
|
bitmap.CopyFromIcon(m_icon);
|
||||||
|
|
||||||
@@ -174,13 +170,8 @@ void wxStaticBitmap::Free()
|
|||||||
|
|
||||||
wxSize wxStaticBitmap::DoGetBestClientSize() const
|
wxSize wxStaticBitmap::DoGetBestClientSize() const
|
||||||
{
|
{
|
||||||
wxSize size;
|
wxSize size = GetImageSize();
|
||||||
const wxGDIImage& image = GetImage();
|
if ( size == wxDefaultSize )
|
||||||
if ( image.IsOk() )
|
|
||||||
{
|
|
||||||
size = image.GetSize();
|
|
||||||
}
|
|
||||||
else // No image yet
|
|
||||||
{
|
{
|
||||||
// this is completely arbitrary
|
// this is completely arbitrary
|
||||||
size.x =
|
size.x =
|
||||||
@@ -236,33 +227,42 @@ void wxStaticBitmap::MSWReplaceImageHandle(WXHANDLE handle)
|
|||||||
|
|
||||||
void wxStaticBitmap::DoUpdateImage(const wxSize& sizeOld, bool wasIcon)
|
void wxStaticBitmap::DoUpdateImage(const wxSize& sizeOld, bool wasIcon)
|
||||||
{
|
{
|
||||||
const wxSize sizeNew = GetImage().GetSize();
|
const wxSize sizeNew = GetImageSize();
|
||||||
const bool isIcon = m_icon.IsOk();
|
const bool isIcon = m_icon.IsOk();
|
||||||
|
|
||||||
Free();
|
Free();
|
||||||
|
|
||||||
// Normally we just use the handle of provided image but in some cases we
|
// For the icons we just use its HICON directly, but for bitmaps we create
|
||||||
// create our own temporary bitmap, so the actual handle may end up being
|
// our own temporary bitmap and need to delete its handle manually later.
|
||||||
// different from the original one.
|
|
||||||
const HANDLE handleOrig = (HANDLE)GetImage().GetHandle();
|
|
||||||
HANDLE handle = handleOrig;
|
|
||||||
|
|
||||||
#if wxUSE_WXDIB
|
|
||||||
if ( !isIcon )
|
if ( !isIcon )
|
||||||
{
|
{
|
||||||
|
wxBitmap bitmap = m_bitmapBundle.GetBitmapFor(this);
|
||||||
|
|
||||||
|
#if wxUSE_WXDIB
|
||||||
// wxBitmap normally stores alpha in pre-multiplied format but
|
// wxBitmap normally stores alpha in pre-multiplied format but
|
||||||
// apparently STM_SETIMAGE message handler does pre-multiplication
|
// apparently STM_SETIMAGE message handler does pre-multiplication
|
||||||
// internally so we need to undo the pre-multiplication here for a
|
// internally so we need to undo the pre-multiplication here for a
|
||||||
// while (this is similar to what we do in ImageList::Add()).
|
// while (this is similar to what we do in ImageList::Add()).
|
||||||
if ( m_bitmap.HasAlpha() )
|
if ( bitmap.HasAlpha() )
|
||||||
{
|
{
|
||||||
// For bitmap with alpha channel create temporary DIB with
|
// For bitmap with alpha channel create temporary DIB with
|
||||||
// not-premultiplied alpha values.
|
// not-premultiplied alpha values.
|
||||||
handle = wxDIB(m_bitmap.ConvertToImage(),
|
m_currentHandle = wxDIB(bitmap.ConvertToImage(),
|
||||||
wxDIB::PixelFormat_NotPreMultiplied).Detach();
|
wxDIB::PixelFormat_NotPreMultiplied)
|
||||||
|
.Detach();
|
||||||
|
m_ownsCurrentHandle = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // wxUSE_WXDIB
|
||||||
|
{
|
||||||
|
// Just use the HBITMAP as is.
|
||||||
|
m_currentHandle = bitmap.GetHandle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // wxUSE_WXDIB
|
else // it's an icon
|
||||||
|
{
|
||||||
|
m_currentHandle = m_icon.GetHandle();
|
||||||
|
}
|
||||||
|
|
||||||
if ( isIcon != wasIcon )
|
if ( isIcon != wasIcon )
|
||||||
{
|
{
|
||||||
@@ -271,10 +271,7 @@ void wxStaticBitmap::DoUpdateImage(const wxSize& sizeOld, bool wasIcon)
|
|||||||
.TurnOn(isIcon ? SS_ICON : SS_BITMAP);
|
.TurnOn(isIcon ? SS_ICON : SS_BITMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
MSWReplaceImageHandle(handle);
|
MSWReplaceImageHandle(m_currentHandle);
|
||||||
|
|
||||||
m_currentHandle = (WXHANDLE)handle;
|
|
||||||
m_ownsCurrentHandle = handle != handleOrig;
|
|
||||||
|
|
||||||
if ( sizeNew != sizeOld )
|
if ( sizeNew != sizeOld )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ void wxStaticBitmap::SetScaleMode(ScaleMode scaleMode)
|
|||||||
wxWidgetImplType* wxWidgetImpl::CreateStaticBitmap( wxWindowMac* wxpeer,
|
wxWidgetImplType* wxWidgetImpl::CreateStaticBitmap( wxWindowMac* wxpeer,
|
||||||
wxWindowMac* WXUNUSED(parent),
|
wxWindowMac* WXUNUSED(parent),
|
||||||
wxWindowID WXUNUSED(id),
|
wxWindowID WXUNUSED(id),
|
||||||
const wxBitmap& WXUNUSED(bitmap),
|
const wxBitmapBundle& WXUNUSED(bitmap),
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size,
|
const wxSize& size,
|
||||||
long WXUNUSED(style),
|
long WXUNUSED(style),
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ void wxStaticBitmap::SetScaleMode(ScaleMode scaleMode)
|
|||||||
wxWidgetImplType* wxWidgetImpl::CreateStaticBitmap( wxWindowMac* wxpeer,
|
wxWidgetImplType* wxWidgetImpl::CreateStaticBitmap( wxWindowMac* wxpeer,
|
||||||
wxWindowMac* WXUNUSED(parent),
|
wxWindowMac* WXUNUSED(parent),
|
||||||
wxWindowID WXUNUSED(id),
|
wxWindowID WXUNUSED(id),
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& WXUNUSED(bitmap),
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size,
|
const wxSize& size,
|
||||||
long WXUNUSED(style),
|
long WXUNUSED(style),
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
bool wxStaticBitmap::Create(wxWindow *parent,
|
bool wxStaticBitmap::Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmapBundle& bitmap,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size,
|
const wxSize& size,
|
||||||
long style,
|
long style,
|
||||||
@@ -49,7 +49,7 @@ bool wxStaticBitmap::Create(wxWindow *parent,
|
|||||||
|
|
||||||
// Don't call SetBitmap() here, as we don't need to change the size nor
|
// Don't call SetBitmap() here, as we don't need to change the size nor
|
||||||
// refresh the window here.
|
// refresh the window here.
|
||||||
m_bitmap = bitmap;
|
m_bitmapBundle = bitmap;
|
||||||
GetPeer()->SetBitmap(bitmap);
|
GetPeer()->SetBitmap(bitmap);
|
||||||
|
|
||||||
SetInitialSize(size);
|
SetInitialSize(size);
|
||||||
@@ -58,9 +58,9 @@ bool wxStaticBitmap::Create(wxWindow *parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
void wxStaticBitmap::SetBitmap(const wxBitmapBundle& bitmap)
|
||||||
{
|
{
|
||||||
m_bitmap = bitmap;
|
m_bitmapBundle = bitmap;
|
||||||
GetPeer()->SetBitmap(bitmap);
|
GetPeer()->SetBitmap(bitmap);
|
||||||
|
|
||||||
InvalidateBestSize();
|
InvalidateBestSize();
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ wxStaticBitmap::wxStaticBitmap() :
|
|||||||
|
|
||||||
wxStaticBitmap::wxStaticBitmap( wxWindow *parent,
|
wxStaticBitmap::wxStaticBitmap( wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size,
|
const wxSize& size,
|
||||||
long style,
|
long style,
|
||||||
@@ -39,7 +39,7 @@ wxStaticBitmap::wxStaticBitmap( wxWindow *parent,
|
|||||||
|
|
||||||
bool wxStaticBitmap::Create( wxWindow *parent,
|
bool wxStaticBitmap::Create( wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap& label,
|
const wxBitmapBundle& label,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size,
|
const wxSize& size,
|
||||||
long style,
|
long style,
|
||||||
@@ -57,9 +57,9 @@ static void SetPixmap( QLabel *label, const QPixmap *pixMap )
|
|||||||
label->setPixmap( *pixMap );
|
label->setPixmap( *pixMap );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
void wxStaticBitmap::SetBitmap(const wxBitmapBundle& bitmap)
|
||||||
{
|
{
|
||||||
SetPixmap( m_qtLabel, bitmap.GetHandle() );
|
SetPixmap( m_qtLabel, bitmap.GetBitmapFor(this).GetHandle() );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap wxStaticBitmap::GetBitmap() const
|
wxBitmap wxStaticBitmap::GetBitmap() const
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
bool wxStaticBitmap::Create(wxWindow *parent,
|
bool wxStaticBitmap::Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxBitmap &label,
|
const wxBitmapBundle &label,
|
||||||
const wxPoint &pos,
|
const wxPoint &pos,
|
||||||
const wxSize &size,
|
const wxSize &size,
|
||||||
long style,
|
long style,
|
||||||
@@ -64,9 +64,9 @@ bool wxStaticBitmap::Create(wxWindow *parent,
|
|||||||
// bitmap/icon setting/getting and converting between
|
// bitmap/icon setting/getting and converting between
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
void wxStaticBitmap::SetBitmap(const wxBitmapBundle& bitmap)
|
||||||
{
|
{
|
||||||
m_bitmap = bitmap;
|
m_bitmapBundle = bitmap;
|
||||||
|
|
||||||
InvalidateBestSize();
|
InvalidateBestSize();
|
||||||
SetSize(GetBestSize());
|
SetSize(GetBestSize());
|
||||||
|
|||||||
Reference in New Issue
Block a user