]>
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 | 21 | |
210a651b | 22 | class WXDLLEXPORT wxStaticBitmap : public wxStaticBitmapBase |
0e320a79 | 23 | { |
0e320a79 | 24 | public: |
3b9e3455 DW |
25 | inline wxStaticBitmap() { Init(); } |
26 | ||
27 | inline wxStaticBitmap( wxWindow* pParent | |
28 | ,wxWindowID nId | |
29 | ,const wxGDIImage& rLabel | |
30 | ,const wxPoint& rPos = wxDefaultPosition | |
31 | ,const wxSize& rSize = wxDefaultSize | |
32 | ,long lStyle = 0 | |
33 | ,const wxString& rName = wxStaticBitmapNameStr | |
34 | ) | |
35 | { | |
36 | Create(pParent, nId, rLabel, rPos, rSize, lStyle, rName); | |
37 | } | |
38 | ||
39 | bool Create( wxWindow* pParent | |
40 | ,wxWindowID nId | |
41 | ,const wxGDIImage& rLabel | |
42 | ,const wxPoint& rPos = wxDefaultPosition | |
43 | ,const wxSize& rSize = wxDefaultSize | |
44 | ,long lStyle = 0 | |
45 | ,const wxString& rName = wxStaticBitmapNameStr | |
46 | ); | |
47 | inline virtual ~wxStaticBitmap() { Free(); } | |
48 | ||
49 | virtual void SetIcon(const wxIcon& rIcon) { SetImage(rIcon); } | |
50 | virtual void SetBitmap(const wxBitmap& rBitmap) { SetImage(rBitmap); }; | |
51 | ||
52 | // assert failure is provoked by an attempt to get an icon from bitmap or | |
53 | // vice versa | |
54 | const wxIcon& GetIcon() const | |
55 | { wxASSERT( m_bIsIcon ); return *(wxIcon *)m_pImage; } | |
210a651b | 56 | wxBitmap GetBitmap() const |
3b9e3455 DW |
57 | { wxASSERT( !m_bIsIcon ); return *(wxBitmap *)m_pImage; } |
58 | ||
59 | // overriden base class virtuals | |
60 | virtual bool AcceptsFocus() const { return FALSE; } | |
3c299c3a DW |
61 | virtual MRESULT OS2WindowProc( WXUINT uMsg |
62 | ,WXWPARAM wParam | |
63 | ,WXLPARAM lParam | |
64 | ); | |
1de4baa3 | 65 | void OnPaint(wxPaintEvent& rEvent); |
0e320a79 | 66 | |
409c9842 | 67 | protected: |
3b9e3455 DW |
68 | virtual wxSize DoGetBestSize() const; |
69 | ||
70 | void Init() { m_bIsIcon = TRUE; m_pImage = NULL; } | |
71 | void Free(); | |
409c9842 | 72 | |
3b9e3455 DW |
73 | // TRUE if icon/bitmap is valid |
74 | bool ImageIsOk() const; | |
409c9842 | 75 | |
3b9e3455 | 76 | void SetImage(const wxGDIImage& rImage); |
54da4255 | 77 | |
3b9e3455 DW |
78 | // we can have either an icon or a bitmap |
79 | bool m_bIsIcon; | |
80 | wxGDIImage* m_pImage; | |
210a651b DW |
81 | private: |
82 | DECLARE_DYNAMIC_CLASS(wxStaticBitmap) | |
1de4baa3 | 83 | DECLARE_EVENT_TABLE() |
3c299c3a | 84 | }; // end of wxStaticBitmap |
0e320a79 DW |
85 | |
86 | #endif | |
87 | // _WX_STATBMP_H_ |