]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: statbmp.h | |
3 | // Purpose: wxStaticBitmap class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
bbcdf8bc | 8 | // Copyright: (c) Julian Smart |
9e3e0821 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_STATBMP_H_ |
13 | #define _WX_STATBMP_H_ | |
2bda0e17 KB |
14 | |
15 | #ifdef __GNUG__ | |
06b57134 | 16 | #pragma interface "statbmp.h" |
2bda0e17 KB |
17 | #endif |
18 | ||
19 | #include "wx/control.h" | |
916d0b61 | 20 | #include "wx/icon.h" |
2bda0e17 | 21 | |
32c1cda2 | 22 | WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBitmapNameStr; |
2bda0e17 | 23 | |
9e3e0821 | 24 | // a control showing an icon or a bitmap |
06b57134 | 25 | class WXDLLEXPORT wxStaticBitmap : public wxControl |
2bda0e17 | 26 | { |
bfc6fde4 | 27 | DECLARE_DYNAMIC_CLASS(wxStaticBitmap) |
2bda0e17 | 28 | |
06b57134 | 29 | public: |
9e3e0821 VZ |
30 | wxStaticBitmap() { Init(); } |
31 | ||
32 | wxStaticBitmap(wxWindow *parent, | |
33 | wxWindowID id, | |
6d167489 | 34 | const wxGDIImage& label, |
9e3e0821 VZ |
35 | const wxPoint& pos = wxDefaultPosition, |
36 | const wxSize& size = wxDefaultSize, | |
37 | long style = 0, | |
38 | const wxString& name = wxStaticBitmapNameStr) | |
06b57134 VZ |
39 | { |
40 | Create(parent, id, label, pos, size, style, name); | |
41 | } | |
9e3e0821 VZ |
42 | |
43 | bool Create(wxWindow *parent, | |
44 | wxWindowID id, | |
6d167489 | 45 | const wxGDIImage& label, |
9e3e0821 VZ |
46 | const wxPoint& pos = wxDefaultPosition, |
47 | const wxSize& size = wxDefaultSize, | |
48 | long style = 0, | |
49 | const wxString& name = wxStaticBitmapNameStr); | |
50 | ||
51 | virtual ~wxStaticBitmap() { Free(); } | |
52 | ||
6d167489 VZ |
53 | void SetIcon(const wxIcon& icon) { SetImage(icon); } |
54 | void SetBitmap(const wxBitmap& bitmap) { SetImage(bitmap); } | |
9e3e0821 VZ |
55 | |
56 | // assert failure is provoked by an attempt to get an icon from bitmap or | |
57 | // vice versa | |
58 | const wxIcon& GetIcon() const | |
6d167489 | 59 | { wxASSERT( m_isIcon ); return *(wxIcon *)m_image; } |
9e3e0821 | 60 | const wxBitmap& GetBitmap() const |
6d167489 | 61 | { wxASSERT( !m_isIcon ); return *(wxBitmap *)m_image; } |
9e3e0821 | 62 | |
06b57134 VZ |
63 | // overriden base class virtuals |
64 | virtual bool AcceptsFocus() const { return FALSE; } | |
9e3e0821 VZ |
65 | |
66 | // IMPLEMENTATION | |
9e3e0821 | 67 | #ifdef __WIN16__ |
06b57134 VZ |
68 | virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item); |
69 | virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
9e3e0821 | 70 | #endif // __WIN16__ |
2bda0e17 | 71 | |
06b57134 | 72 | protected: |
6d167489 VZ |
73 | virtual wxSize DoGetBestSize() const; |
74 | ||
75 | void Init() { m_isIcon = TRUE; m_image = NULL; } | |
9e3e0821 VZ |
76 | void Free(); |
77 | ||
78 | // TRUE if icon/bitmap is valid | |
79 | bool ImageIsOk() const; | |
80 | ||
6d167489 VZ |
81 | void SetImage(const wxGDIImage& image); |
82 | ||
9e3e0821 VZ |
83 | // we can have either an icon or a bitmap |
84 | bool m_isIcon; | |
6d167489 | 85 | wxGDIImage *m_image; |
2bda0e17 KB |
86 | }; |
87 | ||
88 | #endif | |
bbcdf8bc | 89 | // _WX_STATBMP_H_ |