1. wxIcon/wxCursor change, wxGDIImage class added
[wxWidgets.git] / include / wx / msw / statbmp.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: statbmp.h
3 // Purpose: wxStaticBitmap class
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
22 WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBitmapNameStr;
23
24 // a control showing an icon or a bitmap
25 class WXDLLEXPORT wxStaticBitmap : public wxControl
26 {
27 DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
28
29 public:
30 wxStaticBitmap() { Init(); }
31
32 wxStaticBitmap(wxWindow *parent,
33 wxWindowID id,
34 const wxGDIImage& label,
35 const wxPoint& pos = wxDefaultPosition,
36 const wxSize& size = wxDefaultSize,
37 long style = 0,
38 const wxString& name = wxStaticBitmapNameStr)
39 {
40 Create(parent, id, label, pos, size, style, name);
41 }
42
43 bool Create(wxWindow *parent,
44 wxWindowID id,
45 const wxGDIImage& label,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize,
48 long style = 0,
49 const wxString& name = wxStaticBitmapNameStr);
50
51 virtual ~wxStaticBitmap() { Free(); }
52
53 void SetIcon(const wxIcon& icon) { SetImage(icon); }
54 void SetBitmap(const wxBitmap& bitmap) { SetImage(bitmap); }
55
56 // assert failure is provoked by an attempt to get an icon from bitmap or
57 // vice versa
58 const wxIcon& GetIcon() const
59 { wxASSERT( m_isIcon ); return *(wxIcon *)m_image; }
60 const wxBitmap& GetBitmap() const
61 { wxASSERT( !m_isIcon ); return *(wxBitmap *)m_image; }
62
63 // overriden base class virtuals
64 virtual bool AcceptsFocus() const { return FALSE; }
65
66 // IMPLEMENTATION
67 #ifdef __WIN16__
68 virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
69 virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
70 #endif // __WIN16__
71
72 protected:
73 virtual wxSize DoGetBestSize() const;
74
75 void Init() { m_isIcon = TRUE; m_image = NULL; }
76 void Free();
77
78 // TRUE if icon/bitmap is valid
79 bool ImageIsOk() const;
80
81 void SetImage(const wxGDIImage& image);
82
83 // we can have either an icon or a bitmap
84 bool m_isIcon;
85 wxGDIImage *m_image;
86 };
87
88 #endif
89 // _WX_STATBMP_H_