]> git.saurik.com Git - wxWidgets.git/blob - src/mac/statbmp.cpp
Added includes needed if not using precompiled headers.
[wxWidgets.git] / src / mac / statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: statbmp.cpp
3 // Purpose: wxStaticBitmap
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "statbmp.h"
14 #endif
15
16 #include "wx/statbmp.h"
17
18 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
19
20 /*
21 * wxStaticBitmap
22 */
23
24 BEGIN_EVENT_TABLE(wxStaticBitmap, wxControl)
25 EVT_PAINT(wxStaticBitmap::OnPaint)
26 END_EVENT_TABLE()
27
28 bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
29 const wxBitmap& bitmap,
30 const wxPoint& pos,
31 const wxSize& size,
32 long style,
33 const wxString& name)
34 {
35 SetName(name);
36
37 m_backgroundColour = parent->GetBackgroundColour() ;
38 m_foregroundColour = parent->GetForegroundColour() ;
39
40 m_messageBitmap = bitmap;
41
42 if ( id == -1 )
43 m_windowId = (int)NewControlId();
44 else
45 m_windowId = id;
46
47 m_windowStyle = style;
48
49 bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
50
51 SetSizeOrDefault() ;
52
53 return ret;
54 }
55
56 void wxStaticBitmap::SetSize(int x, int y, int width, int height, int sizeFlags)
57 {
58 wxControl::SetSize( x , y , width , height , sizeFlags ) ;
59 }
60
61 void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
62 {
63 m_messageBitmap = bitmap;
64 SetSizeOrDefault();
65 }
66 void wxStaticBitmap::OnPaint( wxPaintEvent &event )
67 {
68 wxPaintDC dc(this);
69 PrepareDC(dc);
70 dc.SetPalette( *m_messageBitmap.GetPalette() ) ;
71 dc.DrawBitmap( m_messageBitmap , 0 , 0 ) ;
72 }
73
74 wxSize wxStaticBitmap::DoGetBestSize() const
75 {
76 if ( m_messageBitmap.Ok() )
77 return wxSize(m_messageBitmap.GetWidth(), m_messageBitmap.GetHeight());
78 else
79 return wxSize(16, 16); // completely arbitrary
80 }
81