]> git.saurik.com Git - wxWidgets.git/commitdiff
Handle setting of client size for all types of windows
authorDavid Elliott <dfe@tgwbd.org>
Sun, 17 Aug 2003 23:23:26 +0000 (23:23 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Sun, 17 Aug 2003 23:23:26 +0000 (23:23 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22983 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/cocoa/frame.h
include/wx/cocoa/toplevel.h
include/wx/cocoa/window.h
src/cocoa/frame.mm
src/cocoa/toplevel.mm
src/cocoa/window.mm

index 02e19ed615d0626125d4648bf7eeeb90a8fade81..1e82ab5fbc6ab14b961bc97f24817ce305f5ac63 100644 (file)
@@ -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_
index c23c18ff46e4e8acc99ece1b337d4620b98e7b90..075d6dee87df7b19f25189735611cf0ee4130592 100644 (file)
@@ -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;
index 1fbc20590b3662de771d2463560d00b4decbf0e3..0a072ea49a039e27c215c08ce2972c155aaf3048 100644 (file)
@@ -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);
index 7c0387a644f91a7251d6e05c115fcf40957eff79..c9eec7426de1c288bc148bbcb6ef0670e905bb4b 100644 (file)
@@ -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)
index 068d4bd7242e1f57c045440992a113a516fab1f2..3b5bf13131dd8f28f1305d20c6ecf77450abb3ca 100644 (file)
@@ -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);
index 97bcc62a5efcf03fcdb83354c56bc6531e8b8053..017b2de47e04c81f85fce7759996e09091a13302 100644 (file)
@@ -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
 }