1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxStaticBitmap class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_STATBMP_H_
13 #define _WX_STATBMP_H_
16 #pragma interface "statbmp.h"
19 #include "wx/control.h"
22 WXDLLEXPORT_DATA(extern const wxChar
*) wxStaticBitmapNameStr
;
24 // a control showing an icon or a bitmap
25 class WXDLLEXPORT wxStaticBitmap
: public wxControl
27 DECLARE_DYNAMIC_CLASS(wxStaticBitmap
)
30 wxStaticBitmap() { Init(); }
32 wxStaticBitmap(wxWindow
*parent
,
34 const wxGDIImage
& label
,
35 const wxPoint
& pos
= wxDefaultPosition
,
36 const wxSize
& size
= wxDefaultSize
,
38 const wxString
& name
= wxStaticBitmapNameStr
)
40 Create(parent
, id
, label
, pos
, size
, style
, name
);
43 bool Create(wxWindow
*parent
,
45 const wxGDIImage
& label
,
46 const wxPoint
& pos
= wxDefaultPosition
,
47 const wxSize
& size
= wxDefaultSize
,
49 const wxString
& name
= wxStaticBitmapNameStr
);
51 virtual ~wxStaticBitmap() { Free(); }
53 void SetIcon(const wxIcon
& icon
) { SetImage(icon
); }
54 void SetBitmap(const wxBitmap
& bitmap
) { SetImage(bitmap
); }
56 // assert failure is provoked by an attempt to get an icon from bitmap or
58 const wxIcon
& GetIcon() const
59 { wxASSERT( m_isIcon
); return *(wxIcon
*)m_image
; }
60 const wxBitmap
& GetBitmap() const
61 { wxASSERT( !m_isIcon
); return *(wxBitmap
*)m_image
; }
63 // overriden base class virtuals
64 virtual bool AcceptsFocus() const { return FALSE
; }
68 virtual bool MSWOnDraw(WXDRAWITEMSTRUCT
*item
);
69 virtual long MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
73 virtual wxSize
DoGetBestSize() const;
75 void Init() { m_isIcon
= TRUE
; m_image
= NULL
; }
78 // TRUE if icon/bitmap is valid
79 bool ImageIsOk() const;
81 void SetImage(const wxGDIImage
& image
);
83 // we can have either an icon or a bitmap