]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/cocoa/frame.mm
minor changes to eliminate unused parameter warning + some cleanup
[wxWidgets.git] / src / cocoa / frame.mm
... / ...
CommitLineData
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#include "wx/cocoa/autorelease.h"
20
21#import <AppKit/NSWindow.h>
22#import <AppKit/NSApplication.h>
23
24// wxFrame
25
26BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
27END_EVENT_TABLE()
28
29IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
30
31void wxFrame::Init()
32{
33}
34
35bool wxFrame::Create(wxWindow *parent,
36 wxWindowID winid,
37 const wxString& title,
38 const wxPoint& pos,
39 const wxSize& size,
40 long style,
41 const wxString& name)
42{
43 bool rt = wxTopLevelWindow::Create(parent,winid,title,pos,size,style,name);
44
45 return rt;
46}
47
48wxFrame::~wxFrame()
49{
50}
51
52void wxFrame::Cocoa_wxMenuItemAction(wxMenuItem& item)
53{
54 Command(item.GetId());
55}
56
57void wxFrame::AttachMenuBar(wxMenuBar *mbar)
58{
59 wxFrameBase::AttachMenuBar(mbar);
60 if(m_frameMenuBar)
61 {
62 wxLogDebug("Attached menu");
63 [m_cocoaNSWindow setMenu:m_frameMenuBar->GetNSMenu()];
64 }
65}
66
67void wxFrame::DetachMenuBar()
68{
69 if(m_frameMenuBar)
70 {
71 [m_cocoaNSWindow setMenu:nil];
72 }
73 wxFrameBase::DetachMenuBar();
74}
75
76bool wxFrame::Show(bool show)
77{
78 wxAutoNSAutoreleasePool pool;
79 bool ret = wxFrameBase::Show(show);
80 if(show && GetMenuBar())
81 [wxTheApp->GetNSApplication() setMenu:GetMenuBar()->GetNSMenu() ];
82 return ret;
83}
84
85void wxFrame::Cocoa_FrameChanged(void)
86{
87 PositionStatusBar();
88 wxFrameBase::Cocoa_FrameChanged();
89}
90
91wxPoint wxFrame::GetClientAreaOrigin() const
92{
93 return wxPoint(0,0);
94}
95
96void wxFrame::DoGetClientSize(int *width, int *height) const
97{
98 wxFrameBase::DoGetClientSize(width,height);
99 if(height)
100 {
101 if(m_frameStatusBar && m_frameStatusBar->IsShown())
102 *height -= m_frameStatusBar->GetSize().y;
103 }
104}
105
106void wxFrame::DoSetClientSize(int width, int height)
107{
108 if(m_frameStatusBar && m_frameStatusBar->IsShown())
109 height += m_frameStatusBar->GetSize().y;
110 wxFrameBase::DoSetClientSize(width,height);
111}
112
113void wxFrame::PositionStatusBar()
114{
115 if( !m_frameStatusBar || !m_frameStatusBar->IsShown() )
116 return;
117
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
121 int w, h;
122 GetClientSize(&w, &h);
123
124 int sh;
125 m_frameStatusBar->GetSize(NULL, &sh);
126
127 m_frameStatusBar->SetSize(0, h, w, sh);
128}
129