]>
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 | 14 | |
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
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: |
65bc172c | 83 | virtual wxBorder GetDefaultBorder() const; |
6d167489 | 84 | virtual wxSize DoGetBestSize() const; |
46a5e01e | 85 | virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; |
6d167489 | 86 | |
46a5e01e | 87 | // ctor/dtor helpers |
6d167489 | 88 | void Init() { m_isIcon = TRUE; m_image = NULL; } |
9e3e0821 VZ |
89 | void Free(); |
90 | ||
91 | // TRUE if icon/bitmap is valid | |
92 | bool ImageIsOk() const; | |
93 | ||
4004f41e | 94 | void SetImage(const wxGDIImage* image); |
d8bffc13 | 95 | void SetImageNoCopy( wxGDIImage* image ); |
6d167489 | 96 | |
9e3e0821 VZ |
97 | // we can have either an icon or a bitmap |
98 | bool m_isIcon; | |
6d167489 | 99 | wxGDIImage *m_image; |
1e6feb95 VZ |
100 | |
101 | private: | |
102 | DECLARE_DYNAMIC_CLASS(wxStaticBitmap) | |
22f3361e | 103 | DECLARE_NO_COPY_CLASS(wxStaticBitmap) |
2bda0e17 KB |
104 | }; |
105 | ||
106 | #endif | |
bbcdf8bc | 107 | // _WX_STATBMP_H_ |