]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: statbmp.h | |
3 | // Purpose: wxStaticBitmap class | |
3b9e3455 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
3b9e3455 | 6 | // Created: 11/27/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
3b9e3455 DW |
8 | // Copyright: (c) David Webster |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_STATBMP_H_ | |
13 | #define _WX_STATBMP_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "statbmp.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/control.h" | |
3b9e3455 | 20 | #include "wx/icon.h" |
0e320a79 DW |
21 | |
22 | WXDLLEXPORT_DATA(extern const char*) wxStaticBitmapNameStr; | |
23 | ||
210a651b | 24 | class WXDLLEXPORT wxStaticBitmap : public wxStaticBitmapBase |
0e320a79 | 25 | { |
0e320a79 | 26 | public: |
3b9e3455 DW |
27 | inline wxStaticBitmap() { Init(); } |
28 | ||
29 | inline wxStaticBitmap( wxWindow* pParent | |
30 | ,wxWindowID nId | |
31 | ,const wxGDIImage& rLabel | |
32 | ,const wxPoint& rPos = wxDefaultPosition | |
33 | ,const wxSize& rSize = wxDefaultSize | |
34 | ,long lStyle = 0 | |
35 | ,const wxString& rName = wxStaticBitmapNameStr | |
36 | ) | |
37 | { | |
38 | Create(pParent, nId, rLabel, rPos, rSize, lStyle, rName); | |
39 | } | |
40 | ||
41 | bool Create( wxWindow* pParent | |
42 | ,wxWindowID nId | |
43 | ,const wxGDIImage& rLabel | |
44 | ,const wxPoint& rPos = wxDefaultPosition | |
45 | ,const wxSize& rSize = wxDefaultSize | |
46 | ,long lStyle = 0 | |
47 | ,const wxString& rName = wxStaticBitmapNameStr | |
48 | ); | |
49 | inline virtual ~wxStaticBitmap() { Free(); } | |
50 | ||
51 | virtual void SetIcon(const wxIcon& rIcon) { SetImage(rIcon); } | |
52 | virtual void SetBitmap(const wxBitmap& rBitmap) { SetImage(rBitmap); }; | |
53 | ||
54 | // assert failure is provoked by an attempt to get an icon from bitmap or | |
55 | // vice versa | |
56 | const wxIcon& GetIcon() const | |
57 | { wxASSERT( m_bIsIcon ); return *(wxIcon *)m_pImage; } | |
210a651b | 58 | wxBitmap GetBitmap() const |
3b9e3455 DW |
59 | { wxASSERT( !m_bIsIcon ); return *(wxBitmap *)m_pImage; } |
60 | ||
61 | // overriden base class virtuals | |
62 | virtual bool AcceptsFocus() const { return FALSE; } | |
3c299c3a DW |
63 | virtual MRESULT OS2WindowProc( WXUINT uMsg |
64 | ,WXWPARAM wParam | |
65 | ,WXLPARAM lParam | |
66 | ); | |
0e320a79 | 67 | |
409c9842 | 68 | protected: |
3b9e3455 DW |
69 | virtual wxSize DoGetBestSize() const; |
70 | ||
71 | void Init() { m_bIsIcon = TRUE; m_pImage = NULL; } | |
72 | void Free(); | |
409c9842 | 73 | |
3b9e3455 DW |
74 | // TRUE if icon/bitmap is valid |
75 | bool ImageIsOk() const; | |
409c9842 | 76 | |
3b9e3455 | 77 | void SetImage(const wxGDIImage& rImage); |
54da4255 | 78 | |
3b9e3455 DW |
79 | // we can have either an icon or a bitmap |
80 | bool m_bIsIcon; | |
81 | wxGDIImage* m_pImage; | |
210a651b DW |
82 | private: |
83 | DECLARE_DYNAMIC_CLASS(wxStaticBitmap) | |
3c299c3a | 84 | }; // end of wxStaticBitmap |
0e320a79 DW |
85 | |
86 | #endif | |
87 | // _WX_STATBMP_H_ |