]> git.saurik.com Git - wxWidgets.git/blame - src/osx/bmpbuttn_osx.cpp
implement new wxBG_STYLE_XXX semantics for wxMSW too
[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,
2352862a
VZ
30 wxWindowID id,
31 const wxBitmap& bitmap,
e53b3d16
SC
32 const wxPoint& pos,
33 const wxSize& size,
34 long style,
35 const wxValidator& validator,
36 const wxString& name )
37{
38 m_macIsUserPane = false;
39
e53b3d16
SC
40 if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
41 return false;
42
43 if ( style & wxBU_AUTODRAW )
44 {
45 m_marginX =
46 m_marginY = wxDEFAULT_BUTTON_MARGIN;
47 }
48 else
49 {
50 m_marginX =
51 m_marginY = 0;
52 }
53
2352862a 54 m_bitmaps[State_Normal] = bitmap;
e53b3d16
SC
55
56 m_peer = wxWidgetImpl::CreateBitmapButton( this, parent, id, bitmap, pos, size, style, GetExtraStyle() );
57
58 MacPostControlCreate( pos, size );
59
60 return true;
61}
62
63void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap )
2352862a 64{
e53b3d16 65 InvalidateBestSize();
2352862a 66
e53b3d16
SC
67 m_peer->SetBitmap( bitmap );
68}
69
70wxSize wxBitmapButton::DoGetBestSize() const
71{
2352862a 72 wxSize best(m_marginX, m_marginY);
e53b3d16 73
2352862a
VZ
74 best *= 2;
75
76 if ( GetBitmapLabel().IsOk() )
e53b3d16 77 {
2352862a 78 best += GetBitmapLabel().GetSize();
e53b3d16
SC
79 }
80
81 return best;
82}
83
2352862a 84#endif // wxUSE_BMPBUTTON