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