]> git.saurik.com Git - wxWidgets.git/blame - src/mac/classic/statbmp.cpp
[#1472076] Fixes after stock gdi changes within core library.
[wxWidgets.git] / src / mac / classic / statbmp.cpp
CommitLineData
2646f485
SC
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
65571936 9// Licence: wxWindows licence
2646f485
SC
10/////////////////////////////////////////////////////////////////////////////
11
2646f485
SC
12#include "wx/defs.h"
13
14#include "wx/statbmp.h"
15#include "wx/dcclient.h"
16
2646f485 17IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
2646f485
SC
18
19/*
20 * wxStaticBitmap
21 */
22
23BEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase)
24 EVT_PAINT(wxStaticBitmap::OnPaint)
25END_EVENT_TABLE()
26
27bool 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
61void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
62{
63 m_bitmap = bitmap;
9f884528 64 InvalidateBestSize();
2646f485
SC
65 SetSize(wxSize(bitmap.GetWidth(), bitmap.GetHeight()));
66 Refresh() ;
67}
68
69void wxStaticBitmap::OnPaint( wxPaintEvent& WXUNUSED(event) )
70{
71 wxPaintDC dc(this);
72 PrepareDC(dc);
73
74 dc.DrawBitmap( m_bitmap , 0 , 0 , TRUE ) ;
75}
76
77wxSize wxStaticBitmap::DoGetBestSize() const
78{
79 return wxWindow::DoGetBestSize() ;
80}
81