return a valid bitmap from GetBitmap() even if we created an icon internally
[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 #include "wx/control.h"
16 #include "wx/icon.h"
17 #include "wx/bitmap.h"
18
19 extern WXDLLEXPORT_DATA(const wxChar*) wxStaticBitmapNameStr;
20
21 // a control showing an icon or a bitmap
22 class WXDLLEXPORT wxStaticBitmap : public wxStaticBitmapBase
23 {
24 public:
25 wxStaticBitmap() { Init(); }
26
27 wxStaticBitmap(wxWindow *parent,
28 wxWindowID id,
29 const wxGDIImage& label,
30 const wxPoint& pos = wxDefaultPosition,
31 const wxSize& size = wxDefaultSize,
32 long style = 0,
33 const wxString& name = wxStaticBitmapNameStr)
34 {
35 Init();
36
37 Create(parent, id, label, pos, size, style, name);
38 }
39
40 bool Create(wxWindow *parent,
41 wxWindowID id,
42 const wxGDIImage& label,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 long style = 0,
46 const wxString& name = wxStaticBitmapNameStr);
47
48 virtual ~wxStaticBitmap() { Free(); }
49
50 virtual void SetIcon(const wxIcon& icon) { SetImage(&icon); }
51 virtual void SetBitmap(const wxBitmap& bitmap) { SetImage(&bitmap); }
52
53 // can always be used, whether we have a bitmap or an icon in reality
54 wxBitmap GetBitmap() const;
55
56 // can only be used if an icon had been originally used
57 wxIcon GetIcon() const;
58
59
60 protected:
61 virtual wxBorder GetDefaultBorder() const;
62 virtual wxSize DoGetBestSize() const;
63 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
64
65 // ctor/dtor helpers
66 void Init() { m_isIcon = true; m_image = NULL; }
67 void Free();
68
69 // true if icon/bitmap is valid
70 bool ImageIsOk() const;
71
72 void SetImage(const wxGDIImage* image);
73 void SetImageNoCopy( wxGDIImage* image );
74
75 // we can have either an icon or a bitmap
76 bool m_isIcon;
77 wxGDIImage *m_image;
78
79 private:
80 DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
81 DECLARE_NO_COPY_CLASS(wxStaticBitmap)
82 };
83
84 #endif
85 // _WX_STATBMP_H_