]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/statbmp.h
reverted Julian's unintentional breakage of wxChoice
[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 Create(parent, id, label, pos, size, style, name);
40 }
41
42 bool Create(wxWindow *parent,
43 wxWindowID id,
44 const wxGDIImage& label,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize,
47 long style = 0,
48 const wxString& name = wxStaticBitmapNameStr);
49
50 virtual ~wxStaticBitmap() { Free(); }
51
52 virtual void SetIcon(const wxIcon& icon) { SetImage(&icon); }
53 virtual void SetBitmap(const wxBitmap& bitmap) { SetImage(&bitmap); }
54
55 // assert failure is provoked by an attempt to get an icon from bitmap or
56 // vice versa
57 wxIcon GetIcon() const
58 { wxASSERT( m_isIcon ); return *(wxIcon *)m_image; }
59 wxBitmap GetBitmap() const
60 { wxASSERT( !m_isIcon ); return *(wxBitmap *)m_image; }
61
62 // IMPLEMENTATION
63 #ifdef __WIN16__
64 virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
65 #endif // __WIN16__
66 virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
67
68 protected:
69 virtual wxSize DoGetBestSize() const;
70
71 void Init() { m_isIcon = TRUE; m_image = NULL; }
72 void Free();
73
74 // TRUE if icon/bitmap is valid
75 bool ImageIsOk() const;
76
77 void SetImage(const wxGDIImage* image);
78 void SetImageNoCopy( wxGDIImage* image );
79
80 // we can have either an icon or a bitmap
81 bool m_isIcon;
82 wxGDIImage *m_image;
83
84 private:
85 DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
86 };
87
88 #endif
89 // _WX_STATBMP_H_