]> git.saurik.com Git - wxWidgets.git/blame - src/osx/bmpbuttn_osx.cpp
Forgot header with OSX prefix
[wxWidgets.git] / src / osx / bmpbuttn_osx.cpp
CommitLineData
e53b3d16
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/osx/bmpbuttn_osx.cpp
3// Purpose: wxBitmapButton
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id: bmpbuttn.cpp 54820 2008-07-29 20:04:11Z SC $
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#if wxUSE_BMPBUTTON
15
16#include "wx/bmpbuttn.h"
17#include "wx/image.h"
18
19#ifndef WX_PRECOMP
20 #include "wx/dcmemory.h"
21#endif
22
23IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
24
25#include "wx/osx/private.h"
26
27//---------------------------------------------------------------------------
28
29bool wxBitmapButton::Create( wxWindow *parent,
30 wxWindowID id, const wxBitmap& bitmap,
31 const wxPoint& pos,
32 const wxSize& size,
33 long style,
34 const wxValidator& validator,
35 const wxString& name )
36{
37 m_macIsUserPane = false;
38
39 // since bitmapbuttonbase is subclass of button calling wxBitmapButtonBase::Create
40 // essentially creates an additional button
41 if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
42 return false;
43
44 if ( style & wxBU_AUTODRAW )
45 {
46 m_marginX =
47 m_marginY = wxDEFAULT_BUTTON_MARGIN;
48 }
49 else
50 {
51 m_marginX =
52 m_marginY = 0;
53 }
54
55 m_bmpNormal = bitmap;
56
57 m_peer = wxWidgetImpl::CreateBitmapButton( this, parent, id, bitmap, pos, size, style, GetExtraStyle() );
58
59 MacPostControlCreate( pos, size );
60
61 return true;
62}
63
64void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap )
65{
66 InvalidateBestSize();
67
68 m_peer->SetBitmap( bitmap );
69}
70
71wxSize wxBitmapButton::DoGetBestSize() const
72{
73 wxSize best;
74
75 best.x = 2 * m_marginX;
76 best.y = 2 * m_marginY;
77 if ( m_bmpNormal.Ok() )
78 {
79 best.x += m_bmpNormal.GetWidth();
80 best.y += m_bmpNormal.GetHeight();
81 }
82
83 return best;
84}
85
86#endif