Added original works and stubs to CVS repository
[wxWidgets.git] / src / cocoa / frame.mm
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"
17
18 #import <AppKit/NSWindow.h>
19 #import <AppKit/NSApplication.h>
20
21 // wxFrame
22
23 BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
24 END_EVENT_TABLE()
25
26 IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
27
28 void wxFrame::Init()
29 {
30 }
31
32 bool wxFrame::Create(wxWindow *parent,
33            wxWindowID winid,
34            const wxString& title,
35            const wxPoint& pos,
36            const wxSize& size,
37            long style,
38            const wxString& name)
39 {
40     bool rt = wxTopLevelWindow::Create(parent,winid,title,pos,size,style,name);
41
42     return rt;
43 }
44
45 wxFrame::~wxFrame()
46 {
47 }
48
49 void wxFrame::Cocoa_wxMenuItemAction(wxMenuItem& item)
50 {
51     Command(item.GetId());
52 }
53
54 void wxFrame::AttachMenuBar(wxMenuBar *mbar)
55 {
56     wxFrameBase::AttachMenuBar(mbar);
57     if(m_frameMenuBar)
58     {
59         wxLogDebug("Attached menu");
60         [m_cocoaNSWindow setMenu:m_frameMenuBar->GetNSMenu()];
61     }
62 }
63
64 void wxFrame::DetachMenuBar()
65 {
66     if(m_frameMenuBar)
67     {
68         [m_cocoaNSWindow setMenu:nil];
69     }
70     wxFrameBase::DetachMenuBar();
71 }
72
73 bool wxFrame::Show(bool show)
74 {
75     bool ret = wxFrameBase::Show(show);
76     if(show && GetMenuBar())
77         [wxTheApp->GetNSApplication() setMenu:GetMenuBar()->GetNSMenu() ];
78     return ret;
79 }
80
81 wxPoint wxFrame::GetClientAreaOrigin() const
82 {
83     return wxPoint(0,0);
84 }
85