1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/frame.mm
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
14 #include "wx/menuitem.h"
17 #include "wx/statusbr.h"
19 #include "wx/cocoa/autorelease.h"
21 #import <AppKit/NSWindow.h>
22 #import <AppKit/NSApplication.h>
26 BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
29 IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
35 bool wxFrame::Create(wxWindow *parent,
37 const wxString& title,
43 bool rt = wxTopLevelWindow::Create(parent,winid,title,pos,size,style,name);
52 void wxFrame::Cocoa_wxMenuItemAction(wxMenuItem& item)
54 Command(item.GetId());
57 void wxFrame::AttachMenuBar(wxMenuBar *mbar)
59 wxFrameBase::AttachMenuBar(mbar);
62 wxLogDebug("Attached menu");
63 [m_cocoaNSWindow setMenu:m_frameMenuBar->GetNSMenu()];
67 void wxFrame::DetachMenuBar()
71 [m_cocoaNSWindow setMenu:nil];
73 wxFrameBase::DetachMenuBar();
76 bool wxFrame::Show(bool show)
78 wxAutoNSAutoreleasePool pool;
79 bool ret = wxFrameBase::Show(show);
80 if(show && GetMenuBar())
81 [wxTheApp->GetNSApplication() setMenu:GetMenuBar()->GetNSMenu() ];
85 void wxFrame::Cocoa_FrameChanged(void)
88 wxFrameBase::Cocoa_FrameChanged();
91 wxPoint wxFrame::GetClientAreaOrigin() const
96 void wxFrame::DoGetClientSize(int *width, int *height) const
98 wxFrameBase::DoGetClientSize(width,height);
101 if(m_frameStatusBar && m_frameStatusBar->IsShown())
102 *height -= m_frameStatusBar->GetSize().y;
106 void wxFrame::DoSetClientSize(int width, int height)
108 if(m_frameStatusBar && m_frameStatusBar->IsShown())
109 height += m_frameStatusBar->GetSize().y;
110 wxFrameBase::DoSetClientSize(width,height);
113 void wxFrame::PositionStatusBar()
115 if( !m_frameStatusBar || !m_frameStatusBar->IsShown() )
118 // Get the client size. Since it excludes the StatusBar area we want
119 // the top of the status bar to be directly under it (thus located at h)
120 // The width of the statusbar should then match the client width
122 GetClientSize(&w, &h);
125 m_frameStatusBar->GetSize(NULL, &sh);
127 m_frameStatusBar->SetSize(0, h, w, sh);