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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "statbmp.h"
19 #include "wx/control.h"
21 #include "wx/bitmap.h"
23 WXDLLEXPORT_DATA(extern const wxChar
*) wxStaticBitmapNameStr
;
25 // a control showing an icon or a bitmap
26 class WXDLLEXPORT wxStaticBitmap
: public wxStaticBitmapBase
29 wxStaticBitmap() { Init(); }
31 wxStaticBitmap(wxWindow
*parent
,
33 const wxGDIImage
& label
,
34 const wxPoint
& pos
= wxDefaultPosition
,
35 const wxSize
& size
= wxDefaultSize
,
37 const wxString
& name
= wxStaticBitmapNameStr
)
41 Create(parent
, id
, label
, pos
, size
, style
, name
);
44 bool Create(wxWindow
*parent
,
46 const wxGDIImage
& label
,
47 const wxPoint
& pos
= wxDefaultPosition
,
48 const wxSize
& size
= wxDefaultSize
,
50 const wxString
& name
= wxStaticBitmapNameStr
);
52 virtual ~wxStaticBitmap() { Free(); }
54 virtual void SetIcon(const wxIcon
& icon
) { SetImage(&icon
); }
55 virtual void SetBitmap(const wxBitmap
& bitmap
) { SetImage(&bitmap
); }
57 // assert failure is provoked by an attempt to get an icon from bitmap or
59 wxIcon
GetIcon() const
61 wxASSERT_MSG( m_isIcon
, _T("no icon in this wxStaticBitmap") );
63 return *(wxIcon
*)m_image
;
66 wxBitmap
GetBitmap() const
68 wxASSERT_MSG( !m_isIcon
, _T("no bitmap in this wxStaticBitmap") );
70 return *(wxBitmap
*)m_image
;
73 // implementation only from now on
74 // -------------------------------
76 // implement base class virtuals
78 virtual bool MSWOnDraw(WXDRAWITEMSTRUCT
*item
);
80 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
83 virtual wxBorder
GetDefaultBorder() const;
84 virtual wxSize
DoGetBestSize() const;
85 virtual WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
88 void Init() { m_isIcon
= TRUE
; m_image
= NULL
; }
91 // TRUE if icon/bitmap is valid
92 bool ImageIsOk() const;
94 void SetImage(const wxGDIImage
* image
);
95 void SetImageNoCopy( wxGDIImage
* image
);
97 // we can have either an icon or a bitmap
102 DECLARE_DYNAMIC_CLASS(wxStaticBitmap
)
103 DECLARE_NO_COPY_CLASS(wxStaticBitmap
)