Handle setting of client size for all types of windows
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22983 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -53,6 +53,7 @@ protected:
|
||||
// ------------------------------------------------------------------------
|
||||
protected:
|
||||
virtual void Cocoa_wxMenuItemAction(wxMenuItem& item);
|
||||
virtual void CocoaSetWxWindowSize(int width, int height);
|
||||
|
||||
// Helper function to position status/tool bars
|
||||
void UpdateFrameNSView();
|
||||
@@ -93,9 +94,6 @@ public:
|
||||
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_
|
||||
|
@@ -84,6 +84,7 @@ public:
|
||||
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;
|
||||
|
@@ -149,6 +149,10 @@ public:
|
||||
// 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);
|
||||
|
@@ -91,21 +91,13 @@ wxPoint wxFrame::GetClientAreaOrigin() const
|
||||
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)
|
||||
|
@@ -221,6 +221,22 @@ bool wxTopLevelWindowCocoa::IsFullScreen() const
|
||||
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);
|
||||
|
@@ -600,7 +600,14 @@ void wxWindow::DoGetClientSize(int *x, int *y) const
|
||||
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
|
||||
@@ -664,6 +671,7 @@ void wxWindow::CocoaCreateNSScrollView()
|
||||
void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
|
||||
int range, bool refresh)
|
||||
{
|
||||
CocoaCreateNSScrollView();
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user