]> git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/statbmp.cpp
Include order is wxprec.h=>defs.h=>platform.h=>setup.h so remove explicit setup.h...
[wxWidgets.git] / src / mac / classic / 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/defs.h"
13
14 #include "wx/statbmp.h"
15 #include "wx/dcclient.h"
16
17 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
18
19 /*
20 * wxStaticBitmap
21 */
22
23 BEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase)
24 EVT_PAINT(wxStaticBitmap::OnPaint)
25 END_EVENT_TABLE()
26
27 bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
28 const wxBitmap& bitmap,
29 const wxPoint& pos,
30 const wxSize& s,
31 long style,
32 const wxString& name)
33 {
34 SetName(name);
35 wxSize size = s ;
36 if ( bitmap.Ok() )
37 {
38 if ( size.x == -1 )
39 size.x = bitmap.GetWidth() ;
40 if ( size.y == -1 )
41 size.y = bitmap.GetHeight() ;
42 }
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(wxSize(bitmap.GetWidth(), bitmap.GetHeight()));
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 return wxWindow::DoGetBestSize() ;
80 }
81