]> git.saurik.com Git - wxWidgets.git/blob - include/wx/palmos/statbmp.h
cleanup of raw access to bitmaps:
[wxWidgets.git] / include / wx / palmos / statbmp.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/statbmp.h
3 // Purpose: wxStaticBitmap class for Palm OS
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by:
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne
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 WXDLLEXPORT_DATA(extern 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 // implement base class virtuals
73 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
74
75 protected:
76 virtual wxBorder GetDefaultBorder() const;
77 virtual wxSize DoGetBestSize() const;
78 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
79
80 // ctor/dtor helpers
81 void Init() { m_isIcon = TRUE; m_image = NULL; }
82 void Free();
83
84 // TRUE if icon/bitmap is valid
85 bool ImageIsOk() const;
86
87 void SetImage(const wxGDIImage* image);
88 void SetImageNoCopy( wxGDIImage* image );
89
90 // we can have either an icon or a bitmap
91 bool m_isIcon;
92 wxGDIImage *m_image;
93
94 private:
95 DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
96 DECLARE_NO_COPY_CLASS(wxStaticBitmap)
97 };
98
99 #endif
100 // _WX_STATBMP_H_