]> git.saurik.com Git - wxWidgets.git/blob - src/mac/classic/statbmp.cpp
Include wx/msgdlg.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / src / mac / classic / statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/classic/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 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17
18 #include "wx/statbmp.h"
19
20 #ifndef WX_PRECOMP
21 #include "wx/dcclient.h"
22 #endif
23
24 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
25
26 /*
27 * wxStaticBitmap
28 */
29
30 BEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase)
31 EVT_PAINT(wxStaticBitmap::OnPaint)
32 END_EVENT_TABLE()
33
34 bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
35 const wxBitmap& bitmap,
36 const wxPoint& pos,
37 const wxSize& s,
38 long style,
39 const wxString& name)
40 {
41 SetName(name);
42 wxSize size = s ;
43 if ( bitmap.Ok() )
44 {
45 if ( size.x == -1 )
46 size.x = bitmap.GetWidth() ;
47 if ( size.y == -1 )
48 size.y = bitmap.GetHeight() ;
49 }
50
51 m_backgroundColour = parent->GetBackgroundColour() ;
52 m_foregroundColour = parent->GetForegroundColour() ;
53
54 m_bitmap = bitmap;
55 if ( id == wxID_ANY )
56 m_windowId = (int)NewControlId();
57 else
58 m_windowId = id;
59
60 m_windowStyle = style;
61
62 bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
63 SetBestSize( size ) ;
64
65 return ret;
66 }
67
68 void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
69 {
70 m_bitmap = bitmap;
71 InvalidateBestSize();
72 SetSize(wxSize(bitmap.GetWidth(), bitmap.GetHeight()));
73 Refresh() ;
74 }
75
76 void wxStaticBitmap::OnPaint( wxPaintEvent& WXUNUSED(event) )
77 {
78 wxPaintDC dc(this);
79 PrepareDC(dc);
80
81 dc.DrawBitmap( m_bitmap , 0 , 0 , true ) ;
82 }
83
84 wxSize wxStaticBitmap::DoGetBestSize() const
85 {
86 return wxWindow::DoGetBestSize() ;
87 }