]>
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 | 38 | { |
46a5e01e VZ |
39 | Init(); |
40 | ||
06b57134 VZ |
41 | Create(parent, id, label, pos, size, style, name); |
42 | } | |
9e3e0821 VZ |
43 | |
44 | bool Create(wxWindow *parent, | |
45 | wxWindowID id, | |
6d167489 | 46 | const wxGDIImage& label, |
9e3e0821 VZ |
47 | const wxPoint& pos = wxDefaultPosition, |
48 | const wxSize& size = wxDefaultSize, | |
49 | long style = 0, | |
50 | const wxString& name = wxStaticBitmapNameStr); | |
51 | ||
52 | virtual ~wxStaticBitmap() { Free(); } | |
53 | ||
1e6feb95 VZ |
54 | virtual void SetIcon(const wxIcon& icon) { SetImage(&icon); } |
55 | virtual void SetBitmap(const wxBitmap& bitmap) { SetImage(&bitmap); } | |
9e3e0821 VZ |
56 | |
57 | // assert failure is provoked by an attempt to get an icon from bitmap or | |
58 | // vice versa | |
1e6feb95 | 59 | wxIcon GetIcon() const |
46a5e01e VZ |
60 | { |
61 | wxASSERT_MSG( m_isIcon, _T("no icon in this wxStaticBitmap") ); | |
62 | ||
63 | return *(wxIcon *)m_image; | |
64 | } | |
65 | ||
1e6feb95 | 66 | wxBitmap GetBitmap() const |
46a5e01e VZ |
67 | { |
68 | wxASSERT_MSG( !m_isIcon, _T("no bitmap in this wxStaticBitmap") ); | |
69 | ||
70 | return *(wxBitmap *)m_image; | |
71 | } | |
72 | ||
73 | // implementation only from now on | |
74 | // ------------------------------- | |
9e3e0821 | 75 | |
46a5e01e | 76 | // implement base class virtuals |
9e3e0821 | 77 | #ifdef __WIN16__ |
06b57134 | 78 | virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item); |
9e3e0821 | 79 | #endif // __WIN16__ |
d1e418ea | 80 | virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); |
2bda0e17 | 81 | |
06b57134 | 82 | protected: |
6d167489 | 83 | virtual wxSize DoGetBestSize() const; |
46a5e01e | 84 | virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; |
6d167489 | 85 | |
46a5e01e | 86 | // ctor/dtor helpers |
6d167489 | 87 | void Init() { m_isIcon = TRUE; m_image = NULL; } |
9e3e0821 VZ |
88 | void Free(); |
89 | ||
90 | // TRUE if icon/bitmap is valid | |
91 | bool ImageIsOk() const; | |
92 | ||
4004f41e | 93 | void SetImage(const wxGDIImage* image); |
d8bffc13 | 94 | void SetImageNoCopy( wxGDIImage* image ); |
6d167489 | 95 | |
9e3e0821 VZ |
96 | // we can have either an icon or a bitmap |
97 | bool m_isIcon; | |
6d167489 | 98 | wxGDIImage *m_image; |
1e6feb95 VZ |
99 | |
100 | private: | |
101 | DECLARE_DYNAMIC_CLASS(wxStaticBitmap) | |
22f3361e | 102 | DECLARE_NO_COPY_CLASS(wxStaticBitmap) |
2bda0e17 KB |
103 | }; |
104 | ||
105 | #endif | |
bbcdf8bc | 106 | // _WX_STATBMP_H_ |