]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/statbox.mm
Prevent Cocoa from waiting indefinitely when stopping the event loop
[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
DE
18#include "wx/cocoa/autorelease.h"
19
da0634c1
DE
20#import <AppKit/NSBox.h>
21#import <Foundation/NSString.h>
22
23IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
24BEGIN_EVENT_TABLE(wxStaticBox, wxStaticBoxBase)
25END_EVENT_TABLE()
26WX_IMPLEMENT_COCOA_OWNER(wxStaticBox,NSBox,NSView,NSView)
27
28bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid,
29 const wxString& title,
30 const wxPoint& pos,
31 const wxSize& size,
32 long style, const wxValidator& validator,
33 const wxString& name)
34{
7fc77f30 35 wxAutoNSAutoreleasePool pool;
da0634c1
DE
36 if(!CreateControl(parent,winid,pos,size,style,validator,name))
37 return false;
38 m_cocoaNSView = NULL;
8d656ea9 39 SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]);
da0634c1
DE
40 [GetNSBox() setTitle:[NSString stringWithCString:title.c_str()]];
41 if(m_parent)
42 m_parent->CocoaAddChild(this);
8d656ea9
DE
43 SetInitialFrameRect(pos,size);
44
da0634c1
DE
45 return true;
46}
47
48wxStaticBox::~wxStaticBox()
49{
911e17c6 50 DisassociateNSBox(GetNSBox());
da0634c1
DE
51}
52
2ace5cf6
DE
53void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
54{
55 NSRect contentRect = [[GetNSBox() contentView] frame];
56 NSRect thisRect = [m_cocoaNSView frame];
dc483f61
VZ
57 *borderTop = (int)(thisRect.size.height - (contentRect.origin.y+contentRect.size.height));
58 *borderOther = (int)(thisRect.size.width - (contentRect.origin.x+contentRect.size.width));
59 int nextBorder = (int)contentRect.origin.y;
2ace5cf6
DE
60 if(nextBorder > *borderOther)
61 *borderOther = nextBorder;
dc483f61 62 nextBorder = (int)contentRect.origin.x;
2ace5cf6
DE
63 if(nextBorder > *borderOther)
64 *borderOther = nextBorder;
65}
66