]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/statbmp.h
Get/SetTitle only for wxTopLevelWindow (wxMSW part).
[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 // assert failure is provoked by an attempt to get an icon from bitmap or
54 // vice versa
55 wxIcon GetIcon() const
56 {
57 wxASSERT_MSG( m_isIcon, _T("no icon in this wxStaticBitmap") );
58
59 return *(wxIcon *)m_image;
60 }
61
62 wxBitmap GetBitmap() const
63 {
64 wxASSERT_MSG( !m_isIcon, _T("no bitmap in this wxStaticBitmap") );
65
66 return *(wxBitmap *)m_image;
67 }
68
69 // implementation only from now on
70 // -------------------------------
71
72 protected:
73 virtual wxBorder GetDefaultBorder() const;
74 virtual wxSize DoGetBestSize() const;
75 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
76
77 // ctor/dtor helpers
78 void Init() { m_isIcon = true; m_image = NULL; }
79 void Free();
80
81 // true if icon/bitmap is valid
82 bool ImageIsOk() const;
83
84 void SetImage(const wxGDIImage* image);
85 void SetImageNoCopy( wxGDIImage* image );
86
87 // we can have either an icon or a bitmap
88 bool m_isIcon;
89 wxGDIImage *m_image;
90
91 private:
92 DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
93 DECLARE_NO_COPY_CLASS(wxStaticBitmap)
94 };
95
96 #endif
97 // _WX_STATBMP_H_