1 /////////////////////////////////////////////////////////////////////////////// 2 // Name: wx/generic/statbmpg.h 3 // Purpose: wxGenericStaticBitmap header 4 // Author: Marcin Wojdyr, Stefan Csomor 5 // Created: 2008-06-16 6 // Copyright: wxWidgets developers 7 // Licence: wxWindows licence 8 /////////////////////////////////////////////////////////////////////////////// 9 10 #ifndef _WX_GENERIC_STATBMP_H_ 11 #define _WX_GENERIC_STATBMP_H_ 12 13 #include "wx/statbmp.h" 14 15 class WXDLLIMPEXP_CORE wxGenericStaticBitmap : public wxStaticBitmapBase 16 { 17 public: wxGenericStaticBitmap()18 wxGenericStaticBitmap() {} 19 wxGenericStaticBitmap(wxWindow *parent, 20 wxWindowID id, 21 const wxBitmap& bitmap, 22 const wxPoint& pos = wxDefaultPosition, 23 const wxSize& size = wxDefaultSize, 24 long style = 0, 25 const wxString& name = wxASCII_STR(wxStaticBitmapNameStr)) 26 { 27 Create(parent, id, bitmap, pos, size, style, name); 28 } 29 30 bool Create(wxWindow *parent, 31 wxWindowID id, 32 const wxBitmap& bitmap, 33 const wxPoint& pos = wxDefaultPosition, 34 const wxSize& size = wxDefaultSize, 35 long style = 0, 36 const wxString& name = wxASCII_STR(wxStaticBitmapNameStr)); 37 SetBitmap(const wxBitmap & bitmap)38 virtual void SetBitmap(const wxBitmap& bitmap) wxOVERRIDE 39 { 40 m_bitmap = bitmap; 41 SetInitialSize(GetBitmapSize()); 42 Refresh(); 43 } 44 GetBitmap()45 virtual wxBitmap GetBitmap() const wxOVERRIDE { return m_bitmap; } 46 SetIcon(const wxIcon & icon)47 virtual void SetIcon(const wxIcon& icon) wxOVERRIDE 48 { 49 m_bitmap.CopyFromIcon(icon); 50 SetInitialSize(GetBitmapSize()); 51 Refresh(); 52 } 53 54 #if defined(__WXGTK20__) || defined(__WXMAC__) 55 // icons and bitmaps are really the same thing in wxGTK and wxMac GetIcon()56 wxIcon GetIcon() const wxOVERRIDE { return (const wxIcon &)m_bitmap; } 57 #endif 58 SetScaleMode(ScaleMode scaleMode)59 virtual void SetScaleMode(ScaleMode scaleMode) wxOVERRIDE 60 { 61 m_scaleMode = scaleMode; 62 Refresh(); 63 } 64 GetScaleMode()65 virtual ScaleMode GetScaleMode() const wxOVERRIDE { return m_scaleMode; } 66 67 private: GetBitmapSize()68 wxSize GetBitmapSize() 69 { 70 return m_bitmap.IsOk() ? m_bitmap.GetScaledSize() 71 : wxSize(16, 16); // this is completely arbitrary 72 } 73 74 void OnPaint(wxPaintEvent& event); 75 76 wxBitmap m_bitmap; 77 ScaleMode m_scaleMode; 78 79 wxDECLARE_DYNAMIC_CLASS(wxGenericStaticBitmap); 80 }; 81 82 83 #endif //_WX_GENERIC_STATBMP_H_ 84