]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/bmpbuttn.mm
re-enable using our own resize grip with GTK3, themes can (and do) disable the native...
[wxWidgets.git] / src / cocoa / bmpbuttn.mm
CommitLineData
da0634c1 1/////////////////////////////////////////////////////////////////////////////
8898456d 2// Name: src/cocoa/bmpbuttn.mm
da0634c1
DE
3// Purpose: wxBitmapButton
4// Author: David Elliott
5// Modified by:
6// Created: 2003/03/16
8898456d 7// RCS-ID: $Id$
da0634c1 8// Copyright: (c) 2003 David Elliott
526954c5 9// Licence: wxWindows licence
da0634c1
DE
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
16c81607
RN
13
14#if wxUSE_BMPBUTTON
15
910b0053
WS
16#include "wx/bmpbuttn.h"
17
da0634c1 18#ifndef WX_PRECOMP
da0634c1
DE
19 #include "wx/log.h"
20#endif
21
c36a70f1
DE
22#include "wx/cocoa/autorelease.h"
23
da0634c1
DE
24#import <AppKit/NSButton.h>
25#import <Foundation/NSString.h>
26
da0634c1
DE
27BEGIN_EVENT_TABLE(wxBitmapButton, wxBitmapButtonBase)
28END_EVENT_TABLE()
29WX_IMPLEMENT_COCOA_OWNER(wxBitmapButton,NSButton,NSControl,NSView)
30
31bool 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{
c36a70f1 36 wxAutoNSAutoreleasePool pool;
48580976 37 wxLogTrace(wxTRACE_COCOA,wxT("Creating control with id=%d"),winid);
da0634c1
DE
38 if(!CreateControl(parent,winid,pos,size,style,validator,name))
39 return false;
48580976 40 wxLogTrace(wxTRACE_COCOA,wxT("Created control with id=%d"),GetId());
da0634c1 41 m_cocoaNSView = NULL;
8d656ea9 42 SetNSButton([[NSButton alloc] initWithFrame: MakeDefaultNSRect(size)]);
da0634c1
DE
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
7b73db07
DE
47 [GetNSButton() setBezelStyle: NSRegularSquareBezelStyle];
48 [GetNSButton() setImage:bitmap.GetNSImage(true)];
da0634c1
DE
49 [GetNSControl() sizeToFit];
50
51 if(m_parent)
52 m_parent->CocoaAddChild(this);
8d656ea9 53 SetInitialFrameRect(pos,size);
da0634c1
DE
54
55 return true;
56}
57
58wxBitmapButton::~wxBitmapButton()
59{
911e17c6 60 DisassociateNSButton(GetNSButton());
da0634c1
DE
61}
62
63void wxBitmapButton::Cocoa_wxNSButtonAction(void)
64{
48580976 65 wxLogTrace(wxTRACE_COCOA,wxT("YAY!"));
da0634c1
DE
66 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
67 InitCommandEvent(event); // event.SetEventObject(this);
68 Command(event);
69}
70
16c81607 71#endif