]> git.saurik.com Git - wxWidgets.git/blobdiff - src/cocoa/mdi.mm
fixing osx_cocoa, there's a reason m_peer is private in the base class
[wxWidgets.git] / src / cocoa / mdi.mm
index 1d069d58b089847865f53e2755d4bdc977e39bdf..741c582dcba09350b7af20fd358d8e4ec2631823 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        cocoa/mdi.mm
+// Name:        src/cocoa/mdi.mm
 // Purpose:     wxMDIParentFrame, wxMDIChildFrame, wxMDIClientWindow
 // Author:      David Elliott
 // Modified by:
 // Purpose:     wxMDIParentFrame, wxMDIChildFrame, wxMDIClientWindow
 // Author:      David Elliott
 // Modified by:
 /////////////////////////////////////////////////////////////////////////////
 
 #include "wx/wxprec.h"
 /////////////////////////////////////////////////////////////////////////////
 
 #include "wx/wxprec.h"
+
+#if wxUSE_MDI
+
+#include "wx/mdi.h"
+
+#include "wx/cocoa/objc/objc_uniquifying.h"
+
 #ifndef WX_PRECOMP
     #include "wx/log.h"
 #ifndef WX_PRECOMP
     #include "wx/log.h"
-    #include "wx/mdi.h"
 #endif // WX_PRECOMP
 
 // #include "wx/cocoa/autorelease.h"
 #endif // WX_PRECOMP
 
 // #include "wx/cocoa/autorelease.h"
@@ -23,7 +29,7 @@
 // #import <AppKit/NSApplication.h>
 // #import <AppKit/NSView.h>
 
 // #import <AppKit/NSApplication.h>
 // #import <AppKit/NSView.h>
 
-#include <wx/listimpl.cpp>
+#include "wx/listimpl.cpp"
 WX_DEFINE_LIST(wxCocoaMDIChildFrameList);
 
 WX_DECLARE_HASH_MAP(int, wxMDIChildFrame*, wxIntegerHash, wxIntegerEqual, wxIntMDIChildFrameHashMap);
 WX_DEFINE_LIST(wxCocoaMDIChildFrameList);
 
 WX_DECLARE_HASH_MAP(int, wxMDIChildFrame*, wxIntegerHash, wxIntegerEqual, wxIntMDIChildFrameHashMap);
@@ -40,11 +46,12 @@ WX_DECLARE_HASH_MAP(int, wxMDIChildFrame*, wxIntegerHash, wxIntegerEqual, wxIntM
 - (id)initWithWxMDIParentFrame: (wxMDIParentFrame *)mdiParent;
 - (void)windowDidBecomeMain: (NSNotification *)notification;
 @end // interface wxMDIParentFrameObserver : NSObject
 - (id)initWithWxMDIParentFrame: (wxMDIParentFrame *)mdiParent;
 - (void)windowDidBecomeMain: (NSNotification *)notification;
 @end // interface wxMDIParentFrameObserver : NSObject
+WX_DECLARE_GET_OBJC_CLASS(wxMDIParentFrameObserver,NSObject)
 
 @implementation wxMDIParentFrameObserver : NSObject
 - (id)init
 {
 
 @implementation wxMDIParentFrameObserver : NSObject
 - (id)init
 {
-    wxFAIL_MSG("[wxMDIParentFrameObserver -init] should never be called!");
+    wxFAIL_MSG(wxT("[wxMDIParentFrameObserver -init] should never be called!"));
     m_mdiParent = NULL;
     return self;
 }
     m_mdiParent = NULL;
     return self;
 }
@@ -63,6 +70,7 @@ WX_DECLARE_HASH_MAP(int, wxMDIChildFrame*, wxIntegerHash, wxIntegerEqual, wxIntM
 }
 
 @end // implementation wxMDIParentFrameObserver : NSObject
 }
 
 @end // implementation wxMDIParentFrameObserver : NSObject
+WX_IMPLEMENT_GET_OBJC_CLASS(wxMDIParentFrameObserver,NSObject)
 
 // ========================================================================
 // wxMDIParentFrame
 
 // ========================================================================
 // wxMDIParentFrame
@@ -75,7 +83,7 @@ void wxMDIParentFrame::Init()
 {
     m_clientWindow = NULL;
     m_currentChild = NULL;
 {
     m_clientWindow = NULL;
     m_currentChild = NULL;
-    m_observer = [[wxMDIParentFrameObserver alloc]
+    m_observer = [[WX_GET_OBJC_CLASS(wxMDIParentFrameObserver) alloc]
             initWithWxMDIParentFrame:this];
     [[NSNotificationCenter defaultCenter] addObserver:m_observer
             selector:@selector(windowDidBecomeMain:)
             initWithWxMDIParentFrame:this];
     [[NSNotificationCenter defaultCenter] addObserver:m_observer
             selector:@selector(windowDidBecomeMain:)
@@ -87,10 +95,12 @@ bool wxMDIParentFrame::Create(wxWindow *parent,
         const wxPoint& pos, const wxSize& size,
         long style, const wxString& name)
 {
         const wxPoint& pos, const wxSize& size,
         long style, const wxString& name)
 {
-    bool success = wxFrame::Create(parent,winid,title,pos,size,style,name);
-    if(success)
-        OnCreateClient();
-    return success;
+    if ( !wxFrame::Create(parent,winid,title,pos,size,style,name) )
+        return false;
+
+    m_clientWindow = OnCreateClient();
+
+    return m_clientWindow != NULL;
 }
 
 wxMDIParentFrame::~wxMDIParentFrame()
 }
 
 wxMDIParentFrame::~wxMDIParentFrame()
@@ -119,36 +129,12 @@ void wxMDIParentFrame::RemoveMDIChild(wxMDIChildFrame *child)
         SetActiveChild(NULL);
 }
 
         SetActiveChild(NULL);
 }
 
-wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
-{
-    return m_currentChild;
-}
-
 void wxMDIParentFrame::SetActiveChild(wxMDIChildFrame *child)
 {
     m_currentChild = child;
     wxMenuBarManager::GetInstance()->UpdateMenuBar();
 }
 
 void wxMDIParentFrame::SetActiveChild(wxMDIChildFrame *child)
 {
     m_currentChild = child;
     wxMenuBarManager::GetInstance()->UpdateMenuBar();
 }
 
-wxMDIClientWindow *wxMDIParentFrame::GetClientWindow() const
-{
-    return m_clientWindow;
-}
-
-wxMDIClientWindow *wxMDIParentFrame::OnCreateClient()
-{
-    m_clientWindow = new wxMDIClientWindow( this );
-    return m_clientWindow;
-}
-
-void wxMDIParentFrame::ActivateNext()
-{
-}
-
-void wxMDIParentFrame::ActivatePrevious()
-{
-}
-
 wxMenuBar *wxMDIParentFrame::GetAppMenuBar(wxCocoaNSWindow *win)
 {
     if(m_currentChild && (win==this))
 wxMenuBar *wxMDIParentFrame::GetAppMenuBar(wxCocoaNSWindow *win)
 {
     if(m_currentChild && (win==this))
@@ -158,7 +144,7 @@ wxMenuBar *wxMDIParentFrame::GetAppMenuBar(wxCocoaNSWindow *win)
 
 void wxMDIParentFrame::CocoaDelegate_windowDidBecomeKey(void)
 {
 
 void wxMDIParentFrame::CocoaDelegate_windowDidBecomeKey(void)
 {
-    wxLogDebug("wxMDIParentFrame=%p::CocoaDelegate_windowDidBecomeKey",this);
+    wxLogTrace(wxTRACE_COCOA,wxT("wxMDIParentFrame=%p::CocoaDelegate_windowDidBecomeKey"),this);
     if(sm_cocoaDeactivateWindow && sm_cocoaDeactivateWindow==m_currentChild)
     {
         sm_cocoaDeactivateWindow = NULL;
     if(sm_cocoaDeactivateWindow && sm_cocoaDeactivateWindow==m_currentChild)
     {
         sm_cocoaDeactivateWindow = NULL;
@@ -183,7 +169,7 @@ void wxMDIParentFrame::CocoaDelegate_windowDidBecomeKey(void)
 
 void wxMDIParentFrame::CocoaDelegate_windowDidResignKey(void)
 {
 
 void wxMDIParentFrame::CocoaDelegate_windowDidResignKey(void)
 {
-    wxLogDebug("wxMDIParentFrame=%p::CocoaDelegate_windowDidResignKey",this);
+    wxLogTrace(wxTRACE_COCOA,wxT("wxMDIParentFrame=%p::CocoaDelegate_windowDidResignKey"),this);
     if(m_closed)
         wxFrame::CocoaDelegate_windowDidResignKey();
     else
     if(m_closed)
         wxFrame::CocoaDelegate_windowDidResignKey();
     else
@@ -228,10 +214,10 @@ void wxMDIParentFrame::WindowDidBecomeMain(NSNotification *notification)
         }
         if(!hashmap.empty())
         {
         }
         if(!hashmap.empty())
         {
-            int windowCount = 0;
+            NSInteger windowCount = 0;
             NSCountWindows(&windowCount);
             wxASSERT(windowCount>0);
             NSCountWindows(&windowCount);
             wxASSERT(windowCount>0);
-            int *windowList = new int[windowCount];
+            NSInteger *windowList = new NSInteger[windowCount];
             NSWindowList(windowCount, windowList);
             wxIntMDIChildFrameHashMap::iterator iter = hashmap.end();
             for(int i=0; i<windowCount && iter == hashmap.end(); i++)
             NSWindowList(windowCount, windowList);
             wxIntMDIChildFrameHashMap::iterator iter = hashmap.end();
             for(int i=0; i<windowCount && iter == hashmap.end(); i++)
@@ -280,7 +266,7 @@ void wxMDIChildFrame::Activate()
 
 void wxMDIChildFrame::CocoaDelegate_windowDidBecomeKey(void)
 {
 
 void wxMDIChildFrame::CocoaDelegate_windowDidBecomeKey(void)
 {
-    wxLogDebug("wxMDIChildFrame=%p::CocoaDelegate_windowDidBecomeKey",this);
+    wxLogTrace(wxTRACE_COCOA,wxT("wxMDIChildFrame=%p::CocoaDelegate_windowDidBecomeKey"),this);
     if(sm_cocoaDeactivateWindow && sm_cocoaDeactivateWindow==m_mdiParent)
     {
         sm_cocoaDeactivateWindow = NULL;
     if(sm_cocoaDeactivateWindow && sm_cocoaDeactivateWindow==m_mdiParent)
     {
         sm_cocoaDeactivateWindow = NULL;
@@ -299,7 +285,7 @@ void wxMDIChildFrame::CocoaDelegate_windowDidBecomeMain(void)
 
 void wxMDIChildFrame::CocoaDelegate_windowDidResignKey(void)
 {
 
 void wxMDIChildFrame::CocoaDelegate_windowDidResignKey(void)
 {
-    wxLogDebug("wxMDIChildFrame=%p::CocoaDelegate_windowDidResignKey",this);
+    wxLogTrace(wxTRACE_COCOA,wxT("wxMDIChildFrame=%p::CocoaDelegate_windowDidResignKey"),this);
     sm_cocoaDeactivateWindow = this;
 }
 
     sm_cocoaDeactivateWindow = this;
 }
 
@@ -315,21 +301,9 @@ bool wxMDIChildFrame::Destroy()
 // ========================================================================
 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow,wxWindow)
 
 // ========================================================================
 IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow,wxWindow)
 
-wxMDIClientWindow::wxMDIClientWindow()
-{
-}
-
-wxMDIClientWindow::wxMDIClientWindow(wxMDIParentFrame *parent, long style)
-:   wxWindow(parent, -1)
-{
-}
-
-wxMDIClientWindow::~wxMDIClientWindow()
-{
-}
-
-bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style)
+bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
 {
 {
-    return false;
+    return Create(parent, wxID_ANY, wxPoint(0, 0), wxSize(0, 0), style);
 }
 
 }
 
+#endif // wxUSE_MDI