]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/frame.mm
fixes to allow dragging in multiselection tree ctrl (patch 759421)
[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 #include "wx/statusbr.h"
18
19 #import <AppKit/NSWindow.h>
20 #import <AppKit/NSApplication.h>
21
22 // wxFrame
23
24 BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
25 END_EVENT_TABLE()
26
27 IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
28
29 void wxFrame::Init()
30 {
31 }
32
33 bool 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
46 wxFrame::~wxFrame()
47 {
48 }
49
50 void wxFrame::Cocoa_wxMenuItemAction(wxMenuItem& item)
51 {
52 Command(item.GetId());
53 }
54
55 void 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
65 void wxFrame::DetachMenuBar()
66 {
67 if(m_frameMenuBar)
68 {
69 [m_cocoaNSWindow setMenu:nil];
70 }
71 wxFrameBase::DetachMenuBar();
72 }
73
74 bool 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
82 void wxFrame::Cocoa_FrameChanged(void)
83 {
84 PositionStatusBar();
85 wxFrameBase::Cocoa_FrameChanged();
86 }
87
88 wxPoint wxFrame::GetClientAreaOrigin() const
89 {
90 return wxPoint(0,0);
91 }
92
93 void 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
103 void 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
110 void 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