]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/statbmp.h
A little black magic... When the C++ object (for a window or
[wxWidgets.git] / include / wx / os2 / statbmp.h
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 class WXDLLEXPORT wxStaticBitmap : public wxStaticBitmapBase
23 {
24 public:
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; }
56 wxBitmap GetBitmap() const
57 { wxASSERT( !m_bIsIcon ); return *(wxBitmap *)m_pImage; }
58
59 // overriden base class virtuals
60 virtual bool AcceptsFocus() const { return FALSE; }
61 virtual MRESULT OS2WindowProc( WXUINT uMsg
62 ,WXWPARAM wParam
63 ,WXLPARAM lParam
64 );
65
66 protected:
67 virtual wxSize DoGetBestSize() const;
68
69 void Init() { m_bIsIcon = TRUE; m_pImage = NULL; }
70 void Free();
71
72 // TRUE if icon/bitmap is valid
73 bool ImageIsOk() const;
74
75 void SetImage(const wxGDIImage& rImage);
76
77 // we can have either an icon or a bitmap
78 bool m_bIsIcon;
79 wxGDIImage* m_pImage;
80 private:
81 DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
82 }; // end of wxStaticBitmap
83
84 #endif
85 // _WX_STATBMP_H_