]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/bmpbuttn.cpp
don't let MacIsReallyShown climb over toplevel windows, otherwise tlws with invisible...
[wxWidgets.git] / src / mac / carbon / 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{
bf19e3f6
SC
32 // since bitmapbuttonbase is subclass of button calling wxBitmapButtonBase::Create
33 // essentially creates an additional button
34 if ( !wxControl::Create(parent, id, pos, size,
b45ed7a2
VZ
35 style, validator, name) )
36 return false;
37
d460ed40 38 m_bmpNormal = bitmap;
7c551d95 39
827e7a48
RR
40 if (style & wxBU_AUTODRAW)
41 {
42 m_marginX = wxDEFAULT_BUTTON_MARGIN;
43 m_marginY = wxDEFAULT_BUTTON_MARGIN;
44 }
45 else
46 {
47 m_marginX = 0;
48 m_marginY = 0;
49 }
e9576ca5 50
e9576ca5
SC
51 int width = size.x;
52 int height = size.y;
53
e9576ca5 54 if ( width == -1 && bitmap.Ok())
b45ed7a2 55 width = bitmap.GetWidth() + 2*m_marginX;
e9576ca5
SC
56
57 if ( height == -1 && bitmap.Ok())
b45ed7a2 58 height = bitmap.GetHeight() + 2*m_marginY;
e9576ca5 59
e40298d5
JS
60 Rect bounds ;
61 Str255 title ;
f125ccf2 62 m_bmpNormal = bitmap;
e40298d5
JS
63 wxBitmapRefData * bmap = NULL ;
64
65 if ( m_bmpNormal.Ok() )
66 bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ;
67
427ff662 68 MacPreControlCreate( parent , id , wxEmptyString , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
7c551d95 69
e40298d5
JS
70 m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 ,
71 kControlBehaviorOffsetContents +
72 ( bmap && bmap->m_bitmapType == kMacBitmapTypeIcon ?
73 kControlContentCIconHandle : kControlContentPictHandle ) , 0,
74 (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ;
427ff662 75 wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
e40298d5
JS
76
77 ControlButtonContentInfo info ;
78 wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
79 if ( info.contentType != kControlNoContent )
80 {
81 ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
be295828 82 }
e40298d5 83 MacPostControlCreate() ;
e9576ca5 84
7c551d95 85 return TRUE;
e9576ca5
SC
86}
87
88void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
89{
d460ed40 90 m_bmpNormal = bitmap;
3dec57ad 91
d460ed40
GD
92 ControlButtonContentInfo info ;
93 wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
94 if ( info.contentType != kControlNoContent )
95 {
96 ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
3dec57ad 97 }
e9576ca5
SC
98}
99