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