]> git.saurik.com Git - wxWidgets.git/blame - src/mac/classic/statbmp.cpp
Include wx/textctrl.h according to precompiled headers of wx/wx.h (with other minor...
[wxWidgets.git] / src / mac / classic / statbmp.cpp
CommitLineData
2646f485 1/////////////////////////////////////////////////////////////////////////////
18f3decb 2// Name: src/mac/classic/statbmp.cpp
2646f485
SC
3// Purpose: wxStaticBitmap
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
18f3decb 9// Licence: wxWindows licence
2646f485
SC
10/////////////////////////////////////////////////////////////////////////////
11
18f3decb
WS
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
2646f485
SC
17
18#include "wx/statbmp.h"
ed4b0fdc
WS
19
20#ifndef WX_PRECOMP
21 #include "wx/dcclient.h"
22#endif
2646f485 23
2646f485 24IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
2646f485
SC
25
26/*
27 * wxStaticBitmap
28 */
29
30BEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase)
31 EVT_PAINT(wxStaticBitmap::OnPaint)
32END_EVENT_TABLE()
33
34bool 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;
ed4b0fdc 55 if ( id == wxID_ANY )
2646f485
SC
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 ) ;
18f3decb 64
2646f485
SC
65 return ret;
66}
67
68void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
69{
70 m_bitmap = bitmap;
9f884528 71 InvalidateBestSize();
2646f485
SC
72 SetSize(wxSize(bitmap.GetWidth(), bitmap.GetHeight()));
73 Refresh() ;
74}
75
18f3decb 76void wxStaticBitmap::OnPaint( wxPaintEvent& WXUNUSED(event) )
2646f485
SC
77{
78 wxPaintDC dc(this);
79 PrepareDC(dc);
80
18f3decb 81 dc.DrawBitmap( m_bitmap , 0 , 0 , true ) ;
2646f485
SC
82}
83
84wxSize wxStaticBitmap::DoGetBestSize() const
85{
86 return wxWindow::DoGetBestSize() ;
87}