]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/statbmp.cpp
using a dynamic cast to wxFrame in order to get the MenuBar correctly from the frontm...
[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 #include "wx/wxprec.h"
13
14 #if wxUSE_STATBMP
15
16 #include "wx/statbmp.h"
17 #include "wx/dcclient.h"
18
19 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
20
21 /*
22 * wxStaticBitmap
23 */
24
25 BEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase)
26 EVT_PAINT(wxStaticBitmap::OnPaint)
27 END_EVENT_TABLE()
28
29 bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
30 const wxBitmap& bitmap,
31 const wxPoint& pos,
32 const wxSize& size,
33 long style,
34 const wxString& name)
35 {
36 SetName(name);
37
38 m_backgroundColour = parent->GetBackgroundColour() ;
39 m_foregroundColour = parent->GetForegroundColour() ;
40
41 m_bitmap = bitmap;
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 SetBestSize( size ) ;
51
52 return ret;
53 }
54
55 void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
56 {
57 m_bitmap = bitmap;
58 InvalidateBestSize();
59 SetSize(GetBestSize());
60 Refresh() ;
61 }
62
63 void wxStaticBitmap::OnPaint( wxPaintEvent& WXUNUSED(event) )
64 {
65 wxPaintDC dc(this);
66 PrepareDC(dc);
67
68 if (m_bitmap.Ok())
69 {
70 dc.DrawBitmap( m_bitmap , 0 , 0 , TRUE ) ;
71 }
72 }
73
74 wxSize wxStaticBitmap::DoGetBestSize() const
75 {
76 if ( m_bitmap.Ok() )
77 return DoGetSizeFromClientSize( wxSize(m_bitmap.GetWidth(), m_bitmap.GetHeight()) );
78
79 // this is completely arbitrary
80 return DoGetSizeFromClientSize( wxSize(16, 16) );
81 }
82
83 #endif
84