]>
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 |
65571936 | 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 | |
ef359b43 | 23 | extern WXDLLEXPORT_DATA(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 | |
6aa01033 JS |
76 | // implement base class virtuals |
77 | virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
78 | ||
06b57134 | 79 | protected: |
65bc172c | 80 | virtual wxBorder GetDefaultBorder() const; |
9d17ee60 | 81 | virtual wxSize DoGetBestSize() const; |
46a5e01e | 82 | virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const; |
6d167489 | 83 | |
46a5e01e | 84 | // ctor/dtor helpers |
57f4f925 | 85 | void Init() { m_isIcon = true; m_image = NULL; } |
9e3e0821 VZ |
86 | void Free(); |
87 | ||
57f4f925 | 88 | // true if icon/bitmap is valid |
9e3e0821 VZ |
89 | bool ImageIsOk() const; |
90 | ||
4004f41e | 91 | void SetImage(const wxGDIImage* image); |
d8bffc13 | 92 | void SetImageNoCopy( wxGDIImage* image ); |
6d167489 | 93 | |
9e3e0821 VZ |
94 | // we can have either an icon or a bitmap |
95 | bool m_isIcon; | |
6d167489 | 96 | wxGDIImage *m_image; |
1e6feb95 VZ |
97 | |
98 | private: | |
99 | DECLARE_DYNAMIC_CLASS(wxStaticBitmap) | |
22f3361e | 100 | DECLARE_NO_COPY_CLASS(wxStaticBitmap) |
2bda0e17 KB |
101 | }; |
102 | ||
103 | #endif | |
bbcdf8bc | 104 | // _WX_STATBMP_H_ |