]> git.saurik.com Git - wxWidgets.git/blame - src/mac/bmpbuttn.cpp
Fix building wxSTC as a DLL using MinGW GCC 3.x.
[wxWidgets.git] / src / mac / bmpbuttn.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: bmpbuttn.cpp
3// Purpose: wxBitmapButton
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
e40298d5 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "bmpbuttn.h"
14#endif
15
d8c736e5 16#include "wx/window.h"
e9576ca5
SC
17#include "wx/bmpbuttn.h"
18
2f1ae414 19#if !USE_SHARED_LIBRARY
e9576ca5 20IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
2f1ae414 21#endif
e9576ca5 22
d497dca4 23#include "wx/mac/uma.h"
72055702 24#include "wx/bitmap.h"
7c551d95 25
e9576ca5
SC
26bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
27 const wxPoint& pos,
28 const wxSize& size, long style,
29 const wxValidator& validator,
30 const wxString& name)
31{
b45ed7a2
VZ
32 if ( !wxBitmapButtonBase::Create(parent, id, _T(""), pos, size,
33 style, validator, name) )
34 return false;
35
d460ed40 36 m_bmpNormal = bitmap;
7c551d95 37
e9576ca5
SC
38 m_marginX = 0;
39 m_marginY = 0;
40
d460ed40
GD
41 // int x = pos.x;
42 // int y = pos.y;
e9576ca5
SC
43 int width = size.x;
44 int height = size.y;
45
e9576ca5 46 if ( width == -1 && bitmap.Ok())
b45ed7a2 47 width = bitmap.GetWidth() + 2*m_marginX;
e9576ca5
SC
48
49 if ( height == -1 && bitmap.Ok())
b45ed7a2 50 height = bitmap.GetHeight() + 2*m_marginY;
e9576ca5 51
e40298d5
JS
52 Rect bounds ;
53 Str255 title ;
f125ccf2 54 m_bmpNormal = bitmap;
e40298d5
JS
55 wxBitmapRefData * bmap = NULL ;
56
57 if ( m_bmpNormal.Ok() )
58 bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ;
59
427ff662 60 MacPreControlCreate( parent , id , wxEmptyString , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
7c551d95 61
e40298d5
JS
62 m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 ,
63 kControlBehaviorOffsetContents +
64 ( bmap && bmap->m_bitmapType == kMacBitmapTypeIcon ?
65 kControlContentCIconHandle : kControlContentPictHandle ) , 0,
66 (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ;
427ff662 67 wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
e40298d5
JS
68
69 ControlButtonContentInfo info ;
70 wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
71 if ( info.contentType != kControlNoContent )
72 {
73 ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
be295828 74 }
e40298d5 75 MacPostControlCreate() ;
e9576ca5 76
7c551d95 77 return TRUE;
e9576ca5
SC
78}
79
80void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
81{
d460ed40 82 m_bmpNormal = bitmap;
3dec57ad 83
d460ed40
GD
84 ControlButtonContentInfo info ;
85 wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
86 if ( info.contentType != kControlNoContent )
87 {
88 ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
3dec57ad 89 }
e9576ca5
SC
90}
91