]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/statbmp.h
wxCLOSE->wxCLOSE_BOX
[wxWidgets.git] / include / wx / msw / statbmp.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/statbmp.h
3 // Purpose: wxStaticBitmap class for wxMSW
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
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 #include "wx/bitmap.h"
22
23 WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBitmapNameStr;
24
25 // a control showing an icon or a bitmap
26 class WXDLLEXPORT wxStaticBitmap : public wxStaticBitmapBase
27 {
28 public:
29 wxStaticBitmap() { Init(); }
30
31 wxStaticBitmap(wxWindow *parent,
32 wxWindowID id,
33 const wxGDIImage& label,
34 const wxPoint& pos = wxDefaultPosition,
35 const wxSize& size = wxDefaultSize,
36 long style = 0,
37 const wxString& name = wxStaticBitmapNameStr)
38 {
39 Init();
40
41 Create(parent, id, label, pos, size, style, name);
42 }
43
44 bool Create(wxWindow *parent,
45 wxWindowID id,
46 const wxGDIImage& label,
47 const wxPoint& pos = wxDefaultPosition,
48 const wxSize& size = wxDefaultSize,
49 long style = 0,
50 const wxString& name = wxStaticBitmapNameStr);
51
52 virtual ~wxStaticBitmap() { Free(); }
53
54 virtual void SetIcon(const wxIcon& icon) { SetImage(&icon); }
55 virtual void SetBitmap(const wxBitmap& bitmap) { SetImage(&bitmap); }
56
57 // assert failure is provoked by an attempt to get an icon from bitmap or
58 // vice versa
59 wxIcon GetIcon() const
60 {
61 wxASSERT_MSG( m_isIcon, _T("no icon in this wxStaticBitmap") );
62
63 return *(wxIcon *)m_image;
64 }
65
66 wxBitmap GetBitmap() const
67 {
68 wxASSERT_MSG( !m_isIcon, _T("no bitmap in this wxStaticBitmap") );
69
70 return *(wxBitmap *)m_image;
71 }
72
73 // implementation only from now on
74 // -------------------------------
75
76 // implement base class virtuals
77 #ifdef __WIN16__
78 virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
79 #endif // __WIN16__
80 virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
81
82 protected:
83 virtual wxSize DoGetBestSize() const;
84 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
85
86 // ctor/dtor helpers
87 void Init() { m_isIcon = TRUE; m_image = NULL; }
88 void Free();
89
90 // TRUE if icon/bitmap is valid
91 bool ImageIsOk() const;
92
93 void SetImage(const wxGDIImage* image);
94 void SetImageNoCopy( wxGDIImage* image );
95
96 // we can have either an icon or a bitmap
97 bool m_isIcon;
98 wxGDIImage *m_image;
99
100 private:
101 DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
102 DECLARE_NO_COPY_CLASS(wxStaticBitmap)
103 };
104
105 #endif
106 // _WX_STATBMP_H_