statbmp.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/os2/statbmp.h
  3. // Purpose: wxStaticBitmap class
  4. // Author: David Webster
  5. // Modified by:
  6. // Created: 11/27/99
  7. // Copyright: (c) David Webster
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_STATBMP_H_
  11. #define _WX_STATBMP_H_
  12. #include "wx/control.h"
  13. #include "wx/icon.h"
  14. class WXDLLIMPEXP_CORE wxStaticBitmap : public wxStaticBitmapBase
  15. {
  16. public:
  17. inline wxStaticBitmap() { Init(); }
  18. inline wxStaticBitmap( wxWindow* pParent
  19. ,wxWindowID nId
  20. ,const wxGDIImage& rLabel
  21. ,const wxPoint& rPos = wxDefaultPosition
  22. ,const wxSize& rSize = wxDefaultSize
  23. ,long lStyle = 0
  24. ,const wxString& rName = wxStaticBitmapNameStr
  25. )
  26. {
  27. Create(pParent, nId, rLabel, rPos, rSize, lStyle, rName);
  28. }
  29. bool Create( wxWindow* pParent
  30. ,wxWindowID nId
  31. ,const wxGDIImage& rLabel
  32. ,const wxPoint& rPos = wxDefaultPosition
  33. ,const wxSize& rSize = wxDefaultSize
  34. ,long lStyle = 0
  35. ,const wxString& rName = wxStaticBitmapNameStr
  36. );
  37. inline virtual ~wxStaticBitmap() { Free(); }
  38. virtual void SetIcon(const wxIcon& rIcon) { SetImage(rIcon); }
  39. virtual void SetBitmap(const wxBitmap& rBitmap) { SetImage(rBitmap); }
  40. // assert failure is provoked by an attempt to get an icon from bitmap or
  41. // vice versa
  42. wxIcon GetIcon() const
  43. { wxASSERT( m_bIsIcon ); return *(wxIcon *)m_pImage; }
  44. wxBitmap GetBitmap() const
  45. { wxASSERT( !m_bIsIcon ); return *(wxBitmap *)m_pImage; }
  46. // overridden base class virtuals
  47. virtual bool AcceptsFocus() const { return FALSE; }
  48. virtual MRESULT OS2WindowProc( WXUINT uMsg
  49. ,WXWPARAM wParam
  50. ,WXLPARAM lParam
  51. );
  52. void OnPaint(wxPaintEvent& rEvent);
  53. protected:
  54. virtual wxSize DoGetBestSize() const;
  55. void Init() { m_bIsIcon = TRUE; m_pImage = NULL; }
  56. void Free();
  57. // TRUE if icon/bitmap is valid
  58. bool ImageIsOk() const;
  59. void SetImage(const wxGDIImage& rImage);
  60. // we can have either an icon or a bitmap
  61. bool m_bIsIcon;
  62. wxGDIImage* m_pImage;
  63. private:
  64. DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
  65. DECLARE_EVENT_TABLE()
  66. }; // end of wxStaticBitmap
  67. #endif
  68. // _WX_STATBMP_H_