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 #import <AppKit/NSWindow.h>
20 #import <AppKit/NSApplication.h>
24 BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
27 IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
33 bool wxFrame::Create(wxWindow *parent,
35 const wxString& title,
41 bool rt = wxTopLevelWindow::Create(parent,winid,title,pos,size,style,name);
50 void wxFrame::Cocoa_wxMenuItemAction(wxMenuItem& item)
52 Command(item.GetId());
55 void wxFrame::AttachMenuBar(wxMenuBar *mbar)
57 wxFrameBase::AttachMenuBar(mbar);
60 wxLogDebug("Attached menu");
61 [m_cocoaNSWindow setMenu:m_frameMenuBar->GetNSMenu()];
65 void wxFrame::DetachMenuBar()
69 [m_cocoaNSWindow setMenu:nil];
71 wxFrameBase::DetachMenuBar();
74 bool wxFrame::Show(bool show)
76 bool ret = wxFrameBase::Show(show);
77 if(show && GetMenuBar())
78 [wxTheApp->GetNSApplication() setMenu:GetMenuBar()->GetNSMenu() ];
82 void wxFrame::Cocoa_FrameChanged(void)
85 wxFrameBase::Cocoa_FrameChanged();
88 wxPoint wxFrame::GetClientAreaOrigin() const
93 void wxFrame::DoGetClientSize(int *width, int *height) const
95 wxFrameBase::DoGetClientSize(width,height);
98 if(m_frameStatusBar && m_frameStatusBar->IsShown())
99 *height -= m_frameStatusBar->GetSize().y;
103 void wxFrame::DoSetClientSize(int width, int height)
105 if(m_frameStatusBar && m_frameStatusBar->IsShown())
106 height += m_frameStatusBar->GetSize().y;
107 wxFrameBase::DoSetClientSize(width,height);
110 void wxFrame::PositionStatusBar()
112 if( !m_frameStatusBar || !m_frameStatusBar->IsShown() )
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
119 GetClientSize(&w, &h);
122 m_frameStatusBar->GetSize(NULL, &sh);
124 m_frameStatusBar->SetSize(0, h, w, sh);