]> git.saurik.com Git - wxWidgets.git/blame - src/mac/bmpbuttn.cpp
some wxArtProv docs
[wxWidgets.git] / src / mac / bmpbuttn.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: bmpbuttn.cpp
3// Purpose: wxBitmapButton
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
9// Licence: wxWindows licence
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{
32 m_buttonBitmap = bitmap;
7c551d95 33
e9576ca5
SC
34 m_marginX = 0;
35 m_marginY = 0;
36
37 int x = pos.x;
38 int y = pos.y;
39 int width = size.x;
40 int height = size.y;
41
42 if (id == -1)
43 m_windowId = NewControlId();
44 else
45 m_windowId = id;
46
47 if ( width == -1 && bitmap.Ok())
48 width = bitmap.GetWidth() + 2*m_marginX;
49
50 if ( height == -1 && bitmap.Ok())
51 height = bitmap.GetHeight() + 2*m_marginY;
52
7c551d95
SC
53 Rect bounds ;
54 Str255 title ;
3dec57ad
SC
55 m_buttonBitmap = bitmap;
56 wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
57
7c551d95
SC
58 MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
59
76a5e5d2 60 m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 ,
3dec57ad
SC
61 kControlBehaviorOffsetContents +
62 ( bmap->m_bitmapType == kMacBitmapTypeIcon ? kControlContentCIconHandle : kControlContentPictHandle ) , 0,
37e2cb08 63 (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ;
76a5e5d2 64 wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
7c551d95 65
3dec57ad 66 ControlButtonContentInfo info ;
be295828
SC
67 wxMacCreateBitmapButton( &info , m_buttonBitmap ) ;
68 if ( info.contentType != kControlNoContent )
7c551d95 69 {
be295828
SC
70 ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
71 }
7c551d95 72 MacPostControlCreate() ;
e9576ca5 73
7c551d95 74 return TRUE;
e9576ca5
SC
75}
76
77void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
78{
79 m_buttonBitmap = bitmap;
3dec57ad 80
be295828
SC
81 ControlButtonContentInfo info ;
82 wxMacCreateBitmapButton( &info , m_buttonBitmap ) ;
83 if ( info.contentType != kControlNoContent )
7c551d95 84 {
76a5e5d2 85 ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
3dec57ad 86 }
e9576ca5
SC
87}
88