#include "wx/cocoa/NSView.h"
+#ifdef __OBJC__
+ #import <Foundation/NSGeometry.h>
+#endif //def __OBJC__
+
class wxWindowCocoaHider;
// ========================================================================
bool m_isInPaint;
static wxWindow *sm_capturedWindow;
virtual void CocoaReplaceView(WX_NSView oldView, WX_NSView newView);
+ void SetInitialFrameRect(const wxPoint& pos, const wxSize& size);
+#ifdef __OBJC__
+ inline NSRect MakeDefaultNSRect(const wxSize& size)
+ {
+ // NOTE: position is 10,10 to make it "obvious" that it's out of place
+ return NSMakeRect(10.0,10.0,WidthDefault(size.x),HeightDefault(size.y));
+ }
+#endif //def __OBJC__
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
return false;
// TODO: create the window
- NSRect cocoaRect = NSMakeRect(10,10,20,20);
m_cocoaNSView = NULL;
- SetNSView([[NSView alloc] initWithFrame: cocoaRect]);
+ SetNSView([[NSView alloc] initWithFrame: MakeDefaultNSRect(size)]);
[m_cocoaNSView release];
if (m_parent)
m_parent->AddChild(this);
m_parent->CocoaAddChild(this);
}
+ SetInitialFrameRect(pos,size);
return TRUE;
}
[nsview setFrame: cocoaRect];
}
+void wxWindowCocoa::SetInitialFrameRect(const wxPoint& pos, const wxSize& size)
+{
+ NSView *nsview = GetNSViewForSuperview();
+ NSView *superview = [nsview superview];
+ wxCHECK_RET(superview,"NSView does not have a superview");
+ NSRect parentRect = [superview frame];
+ NSRect frameRect = [nsview frame];
+ if(size.x!=-1)
+ frameRect.size.width = size.x;
+ if(size.y!=-1)
+ frameRect.size.height = size.y;
+ frameRect.origin.x = pos.x;
+ frameRect.origin.y = parentRect.size.height-(pos.y+size.y);
+ [nsview setFrame: frameRect];
+}
+
// Get total size
void wxWindow::DoGetSize(int *w, int *h) const
{