]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/statbox.mm
Use "&Help" so wxMac doesn't make an extra help menu
[wxWidgets.git] / src / cocoa / statbox.mm
CommitLineData
da0634c1
DE
1/////////////////////////////////////////////////////////////////////////////
2// Name: cocoa/statbox.mm
3// Purpose: wxStaticBox
4// Author: David Elliott
5// Modified by:
6// Created: 2003/02/15
7// RCS-ID: $Id:
8// Copyright: (c) 2003 David Elliott
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
449c5673
DE
12#include "wx/wxprec.h"
13#ifndef WX_PRECOMP
14 #include "wx/app.h"
15 #include "wx/statbox.h"
16#endif //WX_PRECOMP
da0634c1 17
7fc77f30 18#include "wx/cocoa/autorelease.h"
f9c135f5 19#include "wx/cocoa/string.h"
7fc77f30 20
da0634c1
DE
21#import <AppKit/NSBox.h>
22#import <Foundation/NSString.h>
23
24IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
25BEGIN_EVENT_TABLE(wxStaticBox, wxStaticBoxBase)
26END_EVENT_TABLE()
27WX_IMPLEMENT_COCOA_OWNER(wxStaticBox,NSBox,NSView,NSView)
28
29bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid,
30 const wxString& title,
31 const wxPoint& pos,
32 const wxSize& size,
33 long style, const wxValidator& validator,
34 const wxString& name)
35{
7fc77f30 36 wxAutoNSAutoreleasePool pool;
da0634c1
DE
37 if(!CreateControl(parent,winid,pos,size,style,validator,name))
38 return false;
39 m_cocoaNSView = NULL;
8d656ea9 40 SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]);
f9c135f5 41 [GetNSBox() setTitle:wxNSStringWithWxString(wxStripMenuCodes(title))];
da0634c1
DE
42 if(m_parent)
43 m_parent->CocoaAddChild(this);
8d656ea9
DE
44 SetInitialFrameRect(pos,size);
45
da0634c1
DE
46 return true;
47}
48
49wxStaticBox::~wxStaticBox()
50{
911e17c6 51 DisassociateNSBox(GetNSBox());
da0634c1
DE
52}
53
2ace5cf6
DE
54void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
55{
56 NSRect contentRect = [[GetNSBox() contentView] frame];
57 NSRect thisRect = [m_cocoaNSView frame];
dc483f61
VZ
58 *borderTop = (int)(thisRect.size.height - (contentRect.origin.y+contentRect.size.height));
59 *borderOther = (int)(thisRect.size.width - (contentRect.origin.x+contentRect.size.width));
60 int nextBorder = (int)contentRect.origin.y;
2ace5cf6
DE
61 if(nextBorder > *borderOther)
62 *borderOther = nextBorder;
dc483f61 63 nextBorder = (int)contentRect.origin.x;
2ace5cf6
DE
64 if(nextBorder > *borderOther)
65 *borderOther = nextBorder;
66}
67