]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/statbmp.cpp
Explicitly set "C" locale for the tests using decimal point.
[wxWidgets.git] / src / osx / carbon / statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/statbmp.cpp
3 // Purpose: wxStaticBitmap
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #if wxUSE_STATBMP
15
16 #include "wx/statbmp.h"
17
18 #ifndef WX_PRECOMP
19 #include "wx/dcclient.h"
20 #endif
21
22 /*
23 * wxStaticBitmap
24 */
25
26 BEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase)
27 EVT_PAINT(wxStaticBitmap::OnPaint)
28 END_EVENT_TABLE()
29
30 bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
31 const wxBitmap& bitmap,
32 const wxPoint& pos,
33 const wxSize& size,
34 long style,
35 const wxString& name)
36 {
37 SetName(name);
38
39 m_backgroundColour = parent->GetBackgroundColour() ;
40 m_foregroundColour = parent->GetForegroundColour() ;
41
42 m_bitmap = bitmap;
43 if ( id == wxID_ANY )
44 m_windowId = (int)NewControlId();
45 else
46 m_windowId = id;
47
48 m_windowStyle = style;
49
50 bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
51 SetInitialSize( size ) ;
52
53 return ret;
54 }
55
56 void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
57 {
58 m_bitmap = bitmap;
59 InvalidateBestSize();
60 SetSize(GetBestSize());
61 Refresh() ;
62 }
63
64 void wxStaticBitmap::OnPaint( wxPaintEvent& WXUNUSED(event) )
65 {
66 wxPaintDC dc(this);
67 PrepareDC(dc);
68
69 if (m_bitmap.Ok())
70 {
71 dc.DrawBitmap( m_bitmap , 0 , 0 , TRUE ) ;
72 }
73 }
74
75 wxSize wxStaticBitmap::DoGetBestSize() const
76 {
77 if ( m_bitmap.Ok() )
78 return DoGetSizeFromClientSize( wxSize(m_bitmap.GetWidth(), m_bitmap.GetHeight()) );
79
80 // this is completely arbitrary
81 return DoGetSizeFromClientSize( wxSize(16, 16) );
82 }
83
84 #endif