]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/statbmp.cpp
Add support for gradient stops to wxGraphicsContext.
[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 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
23
24 /*
25 * wxStaticBitmap
26 */
27
28 BEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase)
29 EVT_PAINT(wxStaticBitmap::OnPaint)
30 END_EVENT_TABLE()
31
32 bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
33 const wxBitmap& bitmap,
34 const wxPoint& pos,
35 const wxSize& size,
36 long style,
37 const wxString& name)
38 {
39 SetName(name);
40
41 m_backgroundColour = parent->GetBackgroundColour() ;
42 m_foregroundColour = parent->GetForegroundColour() ;
43
44 m_bitmap = bitmap;
45 if ( id == wxID_ANY )
46 m_windowId = (int)NewControlId();
47 else
48 m_windowId = id;
49
50 m_windowStyle = style;
51
52 bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
53 SetInitialSize( size ) ;
54
55 return ret;
56 }
57
58 void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
59 {
60 m_bitmap = bitmap;
61 InvalidateBestSize();
62 SetSize(GetBestSize());
63 Refresh() ;
64 }
65
66 void wxStaticBitmap::OnPaint( wxPaintEvent& WXUNUSED(event) )
67 {
68 wxPaintDC dc(this);
69 PrepareDC(dc);
70
71 if (m_bitmap.Ok())
72 {
73 dc.DrawBitmap( m_bitmap , 0 , 0 , TRUE ) ;
74 }
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