// ------------------------------------------------------------------------
protected:
virtual void Cocoa_wxMenuItemAction(wxMenuItem& item);
+ virtual void CocoaSetWxWindowSize(int width, int height);
// Helper function to position status/tool bars
void UpdateFrameNSView();
virtual void SetToolBar(wxToolBar *toolbar);
protected:
void PositionStatusBar();
- // override base class virtuals
- virtual void DoGetClientSize(int *width, int *height) const;
- virtual void DoSetClientSize(int width, int height);
};
#endif // _WX_COCOA_FRAME_H_
virtual bool Show( bool show = true );
virtual bool Close( bool force = false );
virtual void OnCloseWindow(wxCloseEvent& event);
+ virtual void CocoaSetWxWindowSize(int width, int height);
virtual void DoMoveWindow(int x, int y, int width, int height);
virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetPosition(int *x, int *y) const;
// Get/set client (application-useable) size
virtual void DoGetClientSize(int *width, int *height) const;
virtual void DoSetClientSize(int width, int size);
+ // Set the size of the wxWindow (the contentView of an NSWindow)
+ // wxTopLevelWindow will override this and set the NSWindow size
+ // such that the contentView will be this size
+ virtual void CocoaSetWxWindowSize(int width, int height);
// Set overall size and position
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
virtual void DoMoveWindow(int x, int y, int width, int height);
return wxPoint(0,0);
}
-void wxFrame::DoGetClientSize(int *width, int *height) const
+void wxFrame::CocoaSetWxWindowSize(int width, int height)
{
- wxFrameBase::DoGetClientSize(width,height);
- if(height)
- {
- if(m_frameStatusBar && m_frameStatusBar->IsShown())
- *height -= m_frameStatusBar->GetSize().y;
- }
-}
-
-void wxFrame::DoSetClientSize(int width, int height)
-{
- if(m_frameStatusBar && m_frameStatusBar->IsShown())
+ if(m_frameStatusBar)
height += m_frameStatusBar->GetSize().y;
- wxFrameBase::DoSetClientSize(width,height);
+ if(m_frameToolBar)
+ height += m_frameToolBar->GetSize().y;
+ wxTopLevelWindow::CocoaSetWxWindowSize(width,height);
}
void wxFrame::CocoaReplaceView(WX_NSView oldView, WX_NSView newView)
return FALSE;
}
+void wxTopLevelWindowCocoa::CocoaSetWxWindowSize(int width, int height)
+{
+ // Set the NSView size by setting the frame size to enclose it
+ unsigned int styleMask = [m_cocoaNSWindow styleMask];
+ NSRect frameRect = [m_cocoaNSWindow frame];
+ NSRect contentRect = [NSWindow
+ contentRectForFrameRect: frameRect
+ styleMask: styleMask];
+ contentRect.size.width = width;
+ contentRect.size.height = height;
+ frameRect = [NSWindow
+ frameRectForContentRect: contentRect
+ styleMask: styleMask];
+ [m_cocoaNSWindow setFrame: frameRect display: NO];
+}
+
void wxTopLevelWindowCocoa::DoMoveWindow(int x, int y, int width, int height)
{
wxLogDebug("wxTopLevelWindow=%p::DoMoveWindow(%d,%d,%d,%d)",this,x,y,width,height);
void wxWindow::DoSetClientSize(int width, int height)
{
wxLogDebug("DoSetClientSize=(%d,%d)",width,height);
- // TODO
+ if(m_cocoaScroller)
+ m_cocoaScroller->ClientSizeToSize(width,height);
+ CocoaSetWxWindowSize(width,height);
+}
+
+void wxWindow::CocoaSetWxWindowSize(int width, int height)
+{
+ wxWindowCocoa::DoSetSize(-1,-1,width,height,wxSIZE_USE_EXISTING);
}
int wxWindow::GetCharHeight() const
void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
int range, bool refresh)
{
+ CocoaCreateNSScrollView();
// TODO
}