]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/nonownedwnd.mm
fix positioning bug with window disabler and hidden windows
[wxWidgets.git] / src / osx / cocoa / nonownedwnd.mm
index d23a92aeeedfbf711ec4145215afa639aa1c8502..4b73f1e26afade85dc9f9a3ade6e3f9f1b3e6bb1 100644 (file)
@@ -15,6 +15,8 @@
     #include "wx/frame.h"
     #include "wx/app.h"
     #include "wx/dialog.h"
     #include "wx/frame.h"
     #include "wx/app.h"
     #include "wx/dialog.h"
+    #include "wx/menuitem.h"
+    #include "wx/menu.h"
 #endif
 
 #include "wx/osx/private.h"
 #endif
 
 #include "wx/osx/private.h"
@@ -77,6 +79,7 @@ bool shouldHandleSelector(SEL selector)
             || selector == @selector(deleteForward:)
             || selector == @selector(insertNewline:)
             || selector == @selector(insertTab:)
             || selector == @selector(deleteForward:)
             || selector == @selector(insertNewline:)
             || selector == @selector(insertTab:)
+            || selector == @selector(insertBacktab:)
             || selector == @selector(keyDown:)
             || selector == @selector(keyUp:)
             || selector == @selector(scrollPageUp:)
             || selector == @selector(keyDown:)
             || selector == @selector(keyUp:)
             || selector == @selector(scrollPageUp:)
@@ -262,6 +265,8 @@ bool shouldHandleSelector(SEL selector)
 
 @end
 
 
 @end
 
+extern int wxOSXGetIdFromSelector(SEL action );
+
 @implementation wxNonOwnedWindowController
 
 - (id) init
 @implementation wxNonOwnedWindowController
 
 - (id) init
@@ -270,6 +275,72 @@ bool shouldHandleSelector(SEL selector)
     return self;
 }
 
     return self;
 }
 
+- (BOOL) triggerMenu:(SEL) action
+{
+    wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar();
+    if ( mbar )
+    {
+        wxMenu* menu = NULL;
+        wxMenuItem* menuitem = mbar->FindItem(wxOSXGetIdFromSelector(action), &menu);
+        if ( menu != NULL && menuitem != NULL)
+            return menu->HandleCommandProcess(menuitem);
+    }
+    return NO;
+}
+
+- (BOOL)validateMenuItem:(NSMenuItem *)menuItem 
+{    
+    SEL action = [menuItem action];
+
+    wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar();
+    if ( mbar )
+    {
+        wxMenu* menu = NULL;
+        wxMenuItem* menuitem = mbar->FindItem(wxOSXGetIdFromSelector(action), &menu);
+        if ( menu != NULL && menuitem != NULL)
+        {
+            if ( menu->HandleCommandUpdateStatus(menuitem) )
+                return menuitem->IsEnabled();
+        }
+    }
+    return YES;
+}
+
+- (void)undo:(id)sender 
+{
+    [self triggerMenu:_cmd];
+}
+
+- (void)redo:(id)sender 
+{
+    [self triggerMenu:_cmd];
+}
+
+- (void)cut:(id)sender 
+{
+    [self triggerMenu:_cmd];
+}
+
+- (void)copy:(id)sender
+{
+    [self triggerMenu:_cmd];
+}
+
+- (void)paste:(id)sender
+{
+    [self triggerMenu:_cmd];
+}
+
+- (void)delete:(id)sender 
+{
+    [self triggerMenu:_cmd];
+}
+
+- (void)selectAll:(id)sender 
+{
+    [self triggerMenu:_cmd];
+}
+
 - (BOOL)windowShouldClose:(id)nwindow
 {
     wxNonOwnedWindowCocoaImpl* windowimpl = [(NSWindow*) nwindow WX_implementation];
 - (BOOL)windowShouldClose:(id)nwindow
 {
     wxNonOwnedWindowCocoaImpl* windowimpl = [(NSWindow*) nwindow WX_implementation];
@@ -588,7 +659,7 @@ WXWindow wxNonOwnedWindowCocoaImpl::GetWXWindow() const
 
 void wxNonOwnedWindowCocoaImpl::Raise()
 {
 
 void wxNonOwnedWindowCocoaImpl::Raise()
 {
-    [m_macWindow orderWindow:NSWindowAbove relativeTo:0];
+    [m_macWindow makeKeyAndOrderFront:nil];
 }
 
 void wxNonOwnedWindowCocoaImpl::Lower()
 }
 
 void wxNonOwnedWindowCocoaImpl::Lower()
@@ -713,8 +784,6 @@ void wxNonOwnedWindowCocoaImpl::GetSize( int &width, int &height ) const
 
 void wxNonOwnedWindowCocoaImpl::GetContentArea( int& left, int &top, int &width, int &height ) const
 {
 
 void wxNonOwnedWindowCocoaImpl::GetContentArea( int& left, int &top, int &width, int &height ) const
 {
-    NSRect outer = NSMakeRect(100,100,100,100);
-    NSRect content = [NSWindow contentRectForFrameRect:outer styleMask:[m_macWindow styleMask] ];
     NSRect rect = [[m_macWindow contentView] frame];
     left = (int)rect.origin.x;
     top = (int)rect.origin.y;
     NSRect rect = [[m_macWindow contentView] frame];
     left = (int)rect.origin.x;
     top = (int)rect.origin.y;