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