]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/statbmp.h
patch from Janos Vegh (2nd try, now it even compiles)
[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
21 WXDLLEXPORT_DATA(extern const char*) wxStaticBitmapNameStr;
22
23 // a control showing an icon or a bitmap
24 class WXDLLEXPORT wxStaticBitmap : public wxControl
25 {
26 DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
27
28 public:
29 wxStaticBitmap() { Init(); }
30
31 wxStaticBitmap(wxWindow *parent,
32 wxWindowID id,
33 const wxBitmap& 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 wxBitmap& 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) { SetBitmap(icon); }
53 virtual void SetBitmap(const wxBitmap& bitmap);
54
55 // assert failure is provoked by an attempt to get an icon from bitmap or
56 // vice versa
57 const wxIcon& GetIcon() const
58 { wxASSERT( m_isIcon ); return *m_image.icon; }
59 const wxBitmap& GetBitmap() const
60 { wxASSERT( !m_isIcon ); return *m_image.bitmap; }
61
62 // overriden base class virtuals
63 virtual bool AcceptsFocus() const { return FALSE; }
64
65 // IMPLEMENTATION
66 virtual void Command(wxCommandEvent& WXUNUSED(event)) { }
67 virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) { }
68
69 #ifdef __WIN16__
70 virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
71 virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
72 #endif // __WIN16__
73
74 protected:
75 void Init() { m_isIcon = TRUE; m_image.icon = NULL; }
76 void Free();
77
78 // TRUE if icon/bitmap is valid
79 bool ImageIsOk() const;
80
81 // we can have either an icon or a bitmap
82 bool m_isIcon;
83 union
84 {
85 wxIcon *icon;
86 wxBitmap *bitmap;
87 } m_image;
88
89 virtual void DoSetSize(int x, int y,
90 int width, int height,
91 int sizeFlags = wxSIZE_AUTO);
92 };
93
94 #endif
95 // _WX_STATBMP_H_