statbmp.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/statbmp.h
  3. // Purpose: wxStaticBitmap class for wxMSW
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 01/02/97
  7. // Copyright: (c) Julian Smart
  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. #include "wx/bitmap.h"
  15. extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticBitmapNameStr[];
  16. // a control showing an icon or a bitmap
  17. class WXDLLIMPEXP_CORE wxStaticBitmap : public wxStaticBitmapBase
  18. {
  19. public:
  20. wxStaticBitmap() { Init(); }
  21. wxStaticBitmap(wxWindow *parent,
  22. wxWindowID id,
  23. const wxGDIImage& label,
  24. const wxPoint& pos = wxDefaultPosition,
  25. const wxSize& size = wxDefaultSize,
  26. long style = 0,
  27. const wxString& name = wxStaticBitmapNameStr)
  28. {
  29. Init();
  30. Create(parent, id, label, pos, size, style, name);
  31. }
  32. bool Create(wxWindow *parent,
  33. wxWindowID id,
  34. const wxGDIImage& label,
  35. const wxPoint& pos = wxDefaultPosition,
  36. const wxSize& size = wxDefaultSize,
  37. long style = 0,
  38. const wxString& name = wxStaticBitmapNameStr);
  39. virtual ~wxStaticBitmap() { Free(); }
  40. virtual void SetIcon(const wxIcon& icon) { SetImage(&icon); }
  41. virtual void SetBitmap(const wxBitmap& bitmap) { SetImage(&bitmap); }
  42. virtual wxBitmap GetBitmap() const;
  43. virtual wxIcon GetIcon() const;
  44. virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
  45. // returns true if the platform should explicitly apply a theme border
  46. virtual bool CanApplyThemeBorder() const { return false; }
  47. protected:
  48. virtual wxSize DoGetBestClientSize() const;
  49. // ctor/dtor helpers
  50. void Init() { m_isIcon = true; m_image = NULL; m_currentHandle = 0; }
  51. void Free();
  52. // true if icon/bitmap is valid
  53. bool ImageIsOk() const;
  54. void SetImage(const wxGDIImage* image);
  55. void SetImageNoCopy( wxGDIImage* image );
  56. #ifndef __WXWINCE__
  57. // draw the bitmap ourselves here if the OS can't do it correctly (if it
  58. // can we leave it to it)
  59. void DoPaintManually(wxPaintEvent& event);
  60. #endif // !__WXWINCE__
  61. void WXHandleSize(wxSizeEvent& event);
  62. // we can have either an icon or a bitmap
  63. bool m_isIcon;
  64. wxGDIImage *m_image;
  65. // handle used in last call to STM_SETIMAGE
  66. WXHANDLE m_currentHandle;
  67. private:
  68. // Replace the image at the native control level with the given HBITMAP or
  69. // HICON (which can be 0) and destroy the previous image if necessary.
  70. void MSWReplaceImageHandle(WXLPARAM handle);
  71. DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
  72. wxDECLARE_EVENT_TABLE();
  73. wxDECLARE_NO_COPY_CLASS(wxStaticBitmap);
  74. };
  75. #endif
  76. // _WX_STATBMP_H_