]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/statbmp.h
New scrolling code.
[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 wxBitmap& 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 wxBitmap& 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 virtual void SetIcon(const wxIcon& icon) { SetBitmap(icon); }
54 virtual void SetBitmap(const wxBitmap& 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 *m_image.icon; }
60 const wxBitmap& GetBitmap() const
61 { wxASSERT( !m_isIcon ); return *m_image.bitmap; }
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 void Init() { m_isIcon = TRUE; m_image.icon = NULL; }
74 void Free();
75
76 // TRUE if icon/bitmap is valid
77 bool ImageIsOk() const;
78
79 // we can have either an icon or a bitmap
80 bool m_isIcon;
81 union
82 {
83 wxIcon *icon;
84 wxBitmap *bitmap;
85 } m_image;
86
87 virtual wxSize DoGetBestSize();
88 };
89
90 #endif
91 // _WX_STATBMP_H_