]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/frame.mm
Avoid paint event recursion when the run loop is restarted inside the paint
[wxWidgets.git] / src / cocoa / frame.mm
CommitLineData
fb896a32
DE
1/////////////////////////////////////////////////////////////////////////////
2// Name: cocoa/frame.mm
3// Purpose: wxFrame
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 license
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/frame.h"
13#include "wx/menu.h"
14#include "wx/menuitem.h"
15#include "wx/app.h"
16#include "wx/log.h"
a58a6614 17#include "wx/statusbr.h"
fb896a32
DE
18
19#import <AppKit/NSWindow.h>
20#import <AppKit/NSApplication.h>
21
22// wxFrame
23
24BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
25END_EVENT_TABLE()
26
27IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
28
29void wxFrame::Init()
30{
31}
32
33bool wxFrame::Create(wxWindow *parent,
34 wxWindowID winid,
35 const wxString& title,
36 const wxPoint& pos,
37 const wxSize& size,
38 long style,
39 const wxString& name)
40{
41 bool rt = wxTopLevelWindow::Create(parent,winid,title,pos,size,style,name);
42
43 return rt;
44}
45
46wxFrame::~wxFrame()
47{
48}
49
50void wxFrame::Cocoa_wxMenuItemAction(wxMenuItem& item)
51{
52 Command(item.GetId());
53}
54
55void wxFrame::AttachMenuBar(wxMenuBar *mbar)
56{
57 wxFrameBase::AttachMenuBar(mbar);
58 if(m_frameMenuBar)
59 {
60 wxLogDebug("Attached menu");
61 [m_cocoaNSWindow setMenu:m_frameMenuBar->GetNSMenu()];
62 }
63}
64
65void wxFrame::DetachMenuBar()
66{
67 if(m_frameMenuBar)
68 {
69 [m_cocoaNSWindow setMenu:nil];
70 }
71 wxFrameBase::DetachMenuBar();
72}
73
74bool wxFrame::Show(bool show)
75{
76 bool ret = wxFrameBase::Show(show);
77 if(show && GetMenuBar())
78 [wxTheApp->GetNSApplication() setMenu:GetMenuBar()->GetNSMenu() ];
79 return ret;
80}
81
a58a6614
DE
82void wxFrame::Cocoa_FrameChanged(void)
83{
84 PositionStatusBar();
85 wxFrameBase::Cocoa_FrameChanged();
86}
87
fb896a32
DE
88wxPoint wxFrame::GetClientAreaOrigin() const
89{
90 return wxPoint(0,0);
91}
92
a58a6614
DE
93void wxFrame::DoGetClientSize(int *width, int *height) const
94{
95 wxFrameBase::DoGetClientSize(width,height);
96 if(height)
97 {
98 if(m_frameStatusBar && m_frameStatusBar->IsShown())
99 *height -= m_frameStatusBar->GetSize().y;
100 }
101}
102
103void wxFrame::DoSetClientSize(int width, int height)
104{
105 if(m_frameStatusBar && m_frameStatusBar->IsShown())
106 height += m_frameStatusBar->GetSize().y;
107 wxFrameBase::DoSetClientSize(width,height);
108}
109
110void wxFrame::PositionStatusBar()
111{
112 if( !m_frameStatusBar || !m_frameStatusBar->IsShown() )
113 return;
114
115 // Get the client size. Since it excludes the StatusBar area we want
116 // the top of the status bar to be directly under it (thus located at h)
117 // The width of the statusbar should then match the client width
118 int w, h;
119 GetClientSize(&w, &h);
120
121 int sh;
122 m_frameStatusBar->GetSize(NULL, &sh);
123
124 m_frameStatusBar->SetSize(0, h, w, sh);
125}
126