1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/statbmp.h
3 // Purpose: wxStaticBitmap class for wxMSW
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_STATBMP_H_
13 #define _WX_STATBMP_H_
15 #include "wx/control.h"
17 #include "wx/bitmap.h"
19 extern WXDLLEXPORT_DATA(const wxChar
*) wxStaticBitmapNameStr
;
21 // a control showing an icon or a bitmap
22 class WXDLLEXPORT wxStaticBitmap
: public wxStaticBitmapBase
25 wxStaticBitmap() { Init(); }
27 wxStaticBitmap(wxWindow
*parent
,
29 const wxGDIImage
& label
,
30 const wxPoint
& pos
= wxDefaultPosition
,
31 const wxSize
& size
= wxDefaultSize
,
33 const wxString
& name
= wxStaticBitmapNameStr
)
37 Create(parent
, id
, label
, pos
, size
, style
, name
);
40 bool Create(wxWindow
*parent
,
42 const wxGDIImage
& label
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
46 const wxString
& name
= wxStaticBitmapNameStr
);
48 virtual ~wxStaticBitmap() { Free(); }
50 virtual void SetIcon(const wxIcon
& icon
) { SetImage(&icon
); }
51 virtual void SetBitmap(const wxBitmap
& bitmap
) { SetImage(&bitmap
); }
53 // assert failure is provoked by an attempt to get an icon from bitmap or
55 wxIcon
GetIcon() const
57 wxASSERT_MSG( m_isIcon
, _T("no icon in this wxStaticBitmap") );
59 return *(wxIcon
*)m_image
;
62 wxBitmap
GetBitmap() const
64 wxASSERT_MSG( !m_isIcon
, _T("no bitmap in this wxStaticBitmap") );
66 return *(wxBitmap
*)m_image
;
69 // implementation only from now on
70 // -------------------------------
73 virtual wxBorder
GetDefaultBorder() const;
74 virtual wxSize
DoGetBestSize() const;
75 virtual WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
78 void Init() { m_isIcon
= true; m_image
= NULL
; }
81 // true if icon/bitmap is valid
82 bool ImageIsOk() const;
84 void SetImage(const wxGDIImage
* image
);
85 void SetImageNoCopy( wxGDIImage
* image
);
87 // we can have either an icon or a bitmap
92 DECLARE_DYNAMIC_CLASS(wxStaticBitmap
)
93 DECLARE_NO_COPY_CLASS(wxStaticBitmap
)