]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/bmpbuttn.mm
Document wxFileCtrl as being in the core library, not in the base one.
[wxWidgets.git] / src / cocoa / bmpbuttn.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/bmpbuttn.mm
3 // Purpose: wxBitmapButton
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/03/16
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #if wxUSE_BMPBUTTON
15
16 #include "wx/bmpbuttn.h"
17
18 #ifndef WX_PRECOMP
19 #include "wx/log.h"
20 #endif
21
22 #include "wx/cocoa/autorelease.h"
23
24 #import <AppKit/NSButton.h>
25 #import <Foundation/NSString.h>
26
27 BEGIN_EVENT_TABLE(wxBitmapButton, wxBitmapButtonBase)
28 END_EVENT_TABLE()
29 WX_IMPLEMENT_COCOA_OWNER(wxBitmapButton,NSButton,NSControl,NSView)
30
31 bool wxBitmapButton::Create(wxWindow *parent, wxWindowID winid,
32 const wxBitmap& bitmap, const wxPoint& pos,
33 const wxSize& size, long style,
34 const wxValidator& validator, const wxString& name)
35 {
36 wxAutoNSAutoreleasePool pool;
37 wxLogTrace(wxTRACE_COCOA,wxT("Creating control with id=%d"),winid);
38 if(!CreateControl(parent,winid,pos,size,style,validator,name))
39 return false;
40 wxLogTrace(wxTRACE_COCOA,wxT("Created control with id=%d"),GetId());
41 m_cocoaNSView = NULL;
42 SetNSButton([[NSButton alloc] initWithFrame: MakeDefaultNSRect(size)]);
43 // NOTE: YES we want to release this (to match the alloc).
44 // DoAddChild(this) will retain us again since addSubView doesn't.
45 [m_cocoaNSView release];
46
47 [GetNSButton() setBezelStyle: NSRegularSquareBezelStyle];
48 [GetNSButton() setImage:bitmap.GetNSImage(true)];
49 [GetNSControl() sizeToFit];
50
51 if(m_parent)
52 m_parent->CocoaAddChild(this);
53 SetInitialFrameRect(pos,size);
54
55 return true;
56 }
57
58 wxBitmapButton::~wxBitmapButton()
59 {
60 DisassociateNSButton(GetNSButton());
61 }
62
63 void wxBitmapButton::Cocoa_wxNSButtonAction(void)
64 {
65 wxLogTrace(wxTRACE_COCOA,wxT("YAY!"));
66 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
67 InitCommandEvent(event); // event.SetEventObject(this);
68 Command(event);
69 }
70
71 #endif