]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
1e6feb95 VZ |
2 | // Name: wx/msw/statbmp.h |
3 | // Purpose: wxStaticBitmap class for wxMSW | |
2bda0e17 KB |
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" |
4304b42f | 21 | #include "wx/bitmap.h" |
2bda0e17 | 22 | |
32c1cda2 | 23 | WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBitmapNameStr; |
2bda0e17 | 24 | |
9e3e0821 | 25 | // a control showing an icon or a bitmap |
1e6feb95 | 26 | class WXDLLEXPORT wxStaticBitmap : public wxStaticBitmapBase |
2bda0e17 | 27 | { |
06b57134 | 28 | public: |
9e3e0821 VZ |
29 | wxStaticBitmap() { Init(); } |
30 | ||
31 | wxStaticBitmap(wxWindow *parent, | |
32 | wxWindowID id, | |
6d167489 | 33 | const wxGDIImage& label, |
9e3e0821 VZ |
34 | const wxPoint& pos = wxDefaultPosition, |
35 | const wxSize& size = wxDefaultSize, | |
36 | long style = 0, | |
37 | const wxString& name = wxStaticBitmapNameStr) | |
06b57134 VZ |
38 | { |
39 | Create(parent, id, label, pos, size, style, name); | |
40 | } | |
9e3e0821 VZ |
41 | |
42 | bool Create(wxWindow *parent, | |
43 | wxWindowID id, | |
6d167489 | 44 | const wxGDIImage& label, |
9e3e0821 VZ |
45 | const wxPoint& pos = wxDefaultPosition, |
46 | const wxSize& size = wxDefaultSize, | |
47 | long style = 0, | |
48 | const wxString& name = wxStaticBitmapNameStr); | |
49 | ||
50 | virtual ~wxStaticBitmap() { Free(); } | |
51 | ||
1e6feb95 VZ |
52 | virtual void SetIcon(const wxIcon& icon) { SetImage(&icon); } |
53 | virtual void SetBitmap(const wxBitmap& bitmap) { SetImage(&bitmap); } | |
9e3e0821 VZ |
54 | |
55 | // assert failure is provoked by an attempt to get an icon from bitmap or | |
56 | // vice versa | |
1e6feb95 | 57 | wxIcon GetIcon() const |
6d167489 | 58 | { wxASSERT( m_isIcon ); return *(wxIcon *)m_image; } |
1e6feb95 | 59 | wxBitmap GetBitmap() const |
6d167489 | 60 | { wxASSERT( !m_isIcon ); return *(wxBitmap *)m_image; } |
9e3e0821 | 61 | |
9e3e0821 | 62 | // IMPLEMENTATION |
9e3e0821 | 63 | #ifdef __WIN16__ |
06b57134 | 64 | virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item); |
9e3e0821 | 65 | #endif // __WIN16__ |
d1e418ea | 66 | virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); |
2bda0e17 | 67 | |
06b57134 | 68 | protected: |
6d167489 VZ |
69 | virtual wxSize DoGetBestSize() const; |
70 | ||
71 | void Init() { m_isIcon = TRUE; m_image = NULL; } | |
9e3e0821 VZ |
72 | void Free(); |
73 | ||
74 | // TRUE if icon/bitmap is valid | |
75 | bool ImageIsOk() const; | |
76 | ||
4004f41e | 77 | void SetImage(const wxGDIImage* image); |
6d167489 | 78 | |
9e3e0821 VZ |
79 | // we can have either an icon or a bitmap |
80 | bool m_isIcon; | |
6d167489 | 81 | wxGDIImage *m_image; |
1e6feb95 VZ |
82 | |
83 | private: | |
84 | DECLARE_DYNAMIC_CLASS(wxStaticBitmap) | |
2bda0e17 KB |
85 | }; |
86 | ||
87 | #endif | |
bbcdf8bc | 88 | // _WX_STATBMP_H_ |