]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: 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 | #ifdef __GNUG__ | |
16 | #pragma interface "statbmp.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/control.h" | |
20 | #include "wx/icon.h" | |
21 | ||
22 | WXDLLEXPORT_DATA(extern const char*) wxStaticBitmapNameStr; | |
23 | ||
24 | class WXDLLEXPORT wxStaticBitmap : public wxStaticBitmapBase | |
25 | { | |
26 | public: | |
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; } | |
58 | wxBitmap GetBitmap() const | |
59 | { wxASSERT( !m_bIsIcon ); return *(wxBitmap *)m_pImage; } | |
60 | ||
61 | // overriden base class virtuals | |
62 | virtual bool AcceptsFocus() const { return FALSE; } | |
63 | virtual MRESULT OS2WindowProc( WXUINT uMsg | |
64 | ,WXWPARAM wParam | |
65 | ,WXLPARAM lParam | |
66 | ); | |
67 | ||
68 | protected: | |
69 | virtual wxSize DoGetBestSize() const; | |
70 | ||
71 | void Init() { m_bIsIcon = TRUE; m_pImage = NULL; } | |
72 | void Free(); | |
73 | ||
74 | // TRUE if icon/bitmap is valid | |
75 | bool ImageIsOk() const; | |
76 | ||
77 | void SetImage(const wxGDIImage& rImage); | |
78 | ||
79 | // we can have either an icon or a bitmap | |
80 | bool m_bIsIcon; | |
81 | wxGDIImage* m_pImage; | |
82 | private: | |
83 | DECLARE_DYNAMIC_CLASS(wxStaticBitmap) | |
84 | }; // end of wxStaticBitmap | |
85 | ||
86 | #endif | |
87 | // _WX_STATBMP_H_ |