statbmpg.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifndef _WX_GENERIC_STATBMP_H_
  10. #define _WX_GENERIC_STATBMP_H_
  11. #include "wx/statbmp.h"
  12. class WXDLLIMPEXP_CORE wxGenericStaticBitmap : public wxStaticBitmapBase
  13. {
  14. public:
  15. wxGenericStaticBitmap() {}
  16. wxGenericStaticBitmap(wxWindow *parent,
  17. wxWindowID id,
  18. const wxBitmap& bitmap,
  19. const wxPoint& pos = wxDefaultPosition,
  20. const wxSize& size = wxDefaultSize,
  21. long style = 0,
  22. const wxString& name = wxStaticBitmapNameStr)
  23. {
  24. Create(parent, id, bitmap, pos, size, style, name);
  25. }
  26. bool Create(wxWindow *parent,
  27. wxWindowID id,
  28. const wxBitmap& bitmap,
  29. const wxPoint& pos = wxDefaultPosition,
  30. const wxSize& size = wxDefaultSize,
  31. long style = 0,
  32. const wxString& name = wxStaticBitmapNameStr);
  33. virtual void SetBitmap(const wxBitmap& bitmap)
  34. {
  35. m_bitmap = bitmap;
  36. SetInitialSize(GetBitmapSize());
  37. Refresh();
  38. }
  39. virtual wxBitmap GetBitmap() const { return m_bitmap; }
  40. virtual void SetIcon(const wxIcon& icon)
  41. {
  42. m_bitmap.CopyFromIcon(icon);
  43. SetInitialSize(GetBitmapSize());
  44. Refresh();
  45. }
  46. #if defined(__WXGTK20__) || defined(__WXMAC__)
  47. // icons and bitmaps are really the same thing in wxGTK and wxMac
  48. wxIcon GetIcon() const { return (const wxIcon &)m_bitmap; }
  49. #endif
  50. private:
  51. wxSize GetBitmapSize()
  52. {
  53. return m_bitmap.IsOk() ? m_bitmap.GetScaledSize()
  54. : wxSize(16, 16); // this is completely arbitrary
  55. }
  56. void OnPaint(wxPaintEvent& event);
  57. wxBitmap m_bitmap;
  58. DECLARE_DYNAMIC_CLASS(wxGenericStaticBitmap)
  59. };
  60. #endif //_WX_GENERIC_STATBMP_H_