]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/statbmp.cpp
'[1219035] cleanup: miscellaneous' and minor source cleaning.
[wxWidgets.git] / src / mac / carbon / statbmp.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: statbmp.cpp
3// Purpose: wxStaticBitmap
a31a5f85 4// Author: Stefan Csomor
e9576ca5 5// Modified by:
a31a5f85 6// Created: 1998-01-01
e9576ca5 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
3d1a4878 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
b698c8e9 13 #pragma implementation "statbmp.h"
e9576ca5
SC
14#endif
15
3d1a4878 16#include "wx/wxprec.h"
d8c736e5 17
179e085f
RN
18#if wxUSE_STATBMP
19
e9576ca5 20#include "wx/statbmp.h"
03e11df5 21#include "wx/dcclient.h"
e9576ca5 22
90b959ae 23IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
e9576ca5
SC
24
25/*
26 * wxStaticBitmap
27 */
28
584bede0 29BEGIN_EVENT_TABLE(wxStaticBitmap, wxStaticBitmapBase)
519cb848
SC
30 EVT_PAINT(wxStaticBitmap::OnPaint)
31END_EVENT_TABLE()
32
e9576ca5
SC
33bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
34 const wxBitmap& bitmap,
35 const wxPoint& pos,
982a831b 36 const wxSize& size,
e9576ca5
SC
37 long style,
38 const wxString& name)
39{
e9576ca5 40 SetName(name);
7c551d95
SC
41
42 m_backgroundColour = parent->GetBackgroundColour() ;
43 m_foregroundColour = parent->GetForegroundColour() ;
44
584bede0 45 m_bitmap = bitmap;
e9576ca5 46 if ( id == -1 )
e40298d5 47 m_windowId = (int)NewControlId();
e9576ca5 48 else
e40298d5 49 m_windowId = id;
e9576ca5
SC
50
51 m_windowStyle = style;
52
37e2cb08 53 bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
e40298d5 54 SetBestSize( size ) ;
7c551d95 55
519cb848 56 return ret;
e9576ca5
SC
57}
58
e9576ca5
SC
59void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
60{
584bede0 61 m_bitmap = bitmap;
9f884528 62 InvalidateBestSize();
982a831b 63 SetSize(GetBestSize());
2883443e 64 Refresh() ;
519cb848 65}
3dec57ad 66
eb22f2a6 67void wxStaticBitmap::OnPaint( wxPaintEvent& WXUNUSED(event) )
519cb848
SC
68{
69 wxPaintDC dc(this);
70 PrepareDC(dc);
3dec57ad 71
584bede0 72 dc.DrawBitmap( m_bitmap , 0 , 0 , TRUE ) ;
7c551d95
SC
73}
74
75wxSize wxStaticBitmap::DoGetBestSize() const
76{
0bf1e7cb
SC
77 if ( m_bitmap.Ok() )
78 return DoGetSizeFromClientSize( wxSize(m_bitmap.GetWidth(), m_bitmap.GetHeight()) );
79
80 // this is completely arbitrary
81 return DoGetSizeFromClientSize( wxSize(16, 16) );
e9576ca5
SC
82}
83
179e085f
RN
84#endif
85