]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/statbmp.cpp
Fix STL compilation (note: this is not the correct fix, but since
[wxWidgets.git] / src / mac / carbon / statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "statbmp.h"
14 #endif
15
16 #include "wx/wxprec.h"
17
18 #if wxUSE_STATBMP
19
20 #include "wx/statbmp.h"
21 #include "wx/dcclient.h"
22
23 #if !USE_SHARED_LIBRARY
24 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
25 #endif
26
27 /*
28 * wxStaticBitmap
29 */
30
31 BEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase)
32 EVT_PAINT(wxStaticBitmap::OnPaint)
33 END_EVENT_TABLE()
34
35 bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
36 const wxBitmap& bitmap,
37 const wxPoint& pos,
38 const wxSize& size,
39 long style,
40 const wxString& name)
41 {
42 SetName(name);
43
44 m_backgroundColour = parent->GetBackgroundColour() ;
45 m_foregroundColour = parent->GetForegroundColour() ;
46
47 m_bitmap = bitmap;
48 if ( id == -1 )
49 m_windowId = (int)NewControlId();
50 else
51 m_windowId = id;
52
53 m_windowStyle = style;
54
55 bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
56 SetBestSize( size ) ;
57
58 return ret;
59 }
60
61 void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
62 {
63 m_bitmap = bitmap;
64 InvalidateBestSize();
65 SetSize(GetBestSize());
66 Refresh() ;
67 }
68
69 void wxStaticBitmap::OnPaint( wxPaintEvent& WXUNUSED(event) )
70 {
71 wxPaintDC dc(this);
72 PrepareDC(dc);
73
74 dc.DrawBitmap( m_bitmap , 0 , 0 , TRUE ) ;
75 }
76
77 wxSize wxStaticBitmap::DoGetBestSize() const
78 {
79 if ( m_bitmap.Ok() )
80 return DoGetSizeFromClientSize( wxSize(m_bitmap.GetWidth(), m_bitmap.GetHeight()) );
81
82 // this is completely arbitrary
83 return DoGetSizeFromClientSize( wxSize(16, 16) );
84 }
85
86 #endif
87