// ========================================================================
// wxMenuBar
// ========================================================================
-class WXDLLEXPORT wxMenuBar : public wxMenuBarBase, public wxCocoaNSMenu
+class WXDLLEXPORT wxMenuBar : public wxMenuBarBase
{
public:
// ctors and dtor
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/objc/NSMenu.h
-// Purpose: wxPoserNSMenu class
+// Purpose: WXNSMenu class
// Author: David Elliott
// Modified by:
// Created: 2007/04/20 (move from NSMenu.mm)
#import <AppKit/NSMenu.h>
// ============================================================================
-// @class wxPoserNSMenu
+// @class WXNSMenu
// ============================================================================
-@interface wxPoserNSMenu : NSMenu
+@interface WXNSMenu : NSMenu
{
}
- (void)dealloc;
-@end // wxPoserNSMenu
+@end // WXNSMenu
#endif //ndef __WX_COCOA_OBJC_NSMENU_H__
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/objc/NSView.h
-// Purpose: wxPoserNSView class
+// Purpose: WXNSView class
// Author: David Elliott
// Modified by:
// Created: 2007/04/20 (move from NSView.mm)
#import <AppKit/NSView.h>
// ============================================================================
-// @class wxPoserNSView
+// @class WXNSView
// ============================================================================
-@interface wxPoserNSView : NSView
+@interface WXNSView : NSView
{
}
- (void)otherMouseDragged:(NSEvent *)theEvent;
- (void)otherMouseUp:(NSEvent *)theEvent;
- (void)resetCursorRects;
-@end // wxPoserNSView
+@end // WXNSView
#endif //ndef __WX_COCOA_OBJC_NSVIEW_H__
///////////////////////////////////////////////////////////////////////////////
// Name: wx/cocoa/objc/NSWindow.h
-// Purpose: wxPoserNSWindow class
+// Purpose: WXNSWindow class
// Author: David Elliott
// Modified by:
// Created: 2007/04/20 (move from NSWindow.mm)
///////////////////////////////////////////////////////////////////////////////
#import <AppKit/NSWindow.h>
+#import <AppKit/NSPanel.h>
// ============================================================================
-// @class wxPoserNSWindow
+// @class WXNSWindow
// ============================================================================
-@interface wxPoserNSWindow : NSWindow
+@interface WXNSWindow : NSWindow
{
}
- (BOOL)canBecomeKeyWindow;
- (BOOL)canBecomeMainWindow;
-@end // wxPoserNSwindow
+@end // WXNSWindow
+
+// ============================================================================
+// @class WXNSPanel
+// ============================================================================
+@interface WXNSPanel : NSPanel
+{
+}
+
+- (BOOL)canBecomeKeyWindow;
+- (BOOL)canBecomeMainWindow;
+@end // WXNSPanel
#include "wx/cocoa/objc/NSMenu.h"
// ============================================================================
-// @class wxPoserNSMenu
+// @class WXNSMenu
// ============================================================================
-WX_IMPLEMENT_POSER(wxPoserNSMenu);
-@implementation wxPoserNSMenu : NSMenu
+@implementation WXNSMenu : NSMenu
- (void)dealloc
{
[super dealloc];
}
-@end // wxPoserNSMenu
+@end // WXNSMenu
// ============================================================================
// @class wxNSMenuNotificationObserver
}
// ============================================================================
-// @class wxPoserNSView
+// @class WXNSView
// ============================================================================
-WX_IMPLEMENT_POSER(wxPoserNSView);
-@implementation wxPoserNSView : NSView
+
+@implementation WXNSView : NSView
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
{
[super resetCursorRects];
}
-@end // implementation wxPoserNSView
+@end // implementation WXNSView
@interface wxNSViewNotificationObserver : NSObject
{
}
// ============================================================================
-// @class wxPoserNSWindow
+// @class WXNSWindow
// ============================================================================
-WX_IMPLEMENT_POSER(wxPoserNSWindow);
-@implementation wxPoserNSWindow : NSWindow
+@implementation WXNSWindow : NSWindow
- (BOOL)canBecomeKeyWindow
{
return canBecome;
}
-@end // implementation wxPoserNSWindow
+@end // implementation WXNSWindow
+
+// ============================================================================
+// @class WXNSPanel
+// ============================================================================
+@implementation WXNSPanel : NSPanel
+
+- (BOOL)canBecomeKeyWindow
+{
+ bool canBecome = false;
+ wxCocoaNSWindow *tlw = wxCocoaNSWindow::GetFromCocoa(self);
+ if(!tlw || !tlw->Cocoa_canBecomeKeyWindow(canBecome))
+ canBecome = [super canBecomeKeyWindow];
+ return canBecome;
+}
+
+- (BOOL)canBecomeMainWindow
+{
+ bool canBecome = false;
+ wxCocoaNSWindow *tlw = wxCocoaNSWindow::GetFromCocoa(self);
+ if(!tlw || !tlw->Cocoa_canBecomeMainWindow(canBecome))
+ canBecome = [super canBecomeMainWindow];
+ return canBecome;
+}
+
+@end // implementation WXNSPanel
}
- (void)drawRect: (NSRect)rect;
+- (void)mouseDown:(NSEvent *)theEvent;
+- (void)mouseDragged:(NSEvent *)theEvent;
+- (void)mouseUp:(NSEvent *)theEvent;
+- (void)mouseMoved:(NSEvent *)theEvent;
+- (void)mouseEntered:(NSEvent *)theEvent;
+- (void)mouseExited:(NSEvent *)theEvent;
+- (void)rightMouseDown:(NSEvent *)theEvent;
+- (void)rightMouseDragged:(NSEvent *)theEvent;
+- (void)rightMouseUp:(NSEvent *)theEvent;
+- (void)otherMouseDown:(NSEvent *)theEvent;
+- (void)otherMouseDragged:(NSEvent *)theEvent;
+- (void)otherMouseUp:(NSEvent *)theEvent;
+- (void)resetCursorRects;
@end // wxNonControlNSControl
@implementation wxNonControlNSControl : NSControl
+
+- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
+{
+ bool acceptsFirstMouse = false;
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if(!win || !win->Cocoa_acceptsFirstMouse(acceptsFirstMouse, theEvent))
+ acceptsFirstMouse = [super acceptsFirstMouse:theEvent];
+ return acceptsFirstMouse;
+}
+
- (void)drawRect: (NSRect)rect
{
wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
if( !win || !win->Cocoa_drawRect(rect) )
[super drawRect:rect];
}
+
+- (void)mouseDown:(NSEvent *)theEvent
+{
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if( !win || !win->Cocoa_mouseDown(theEvent) )
+ [super mouseDown:theEvent];
+}
+
+- (void)mouseDragged:(NSEvent *)theEvent
+{
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if( !win || !win->Cocoa_mouseDragged(theEvent) )
+ [super mouseDragged:theEvent];
+}
+
+- (void)mouseUp:(NSEvent *)theEvent
+{
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if( !win || !win->Cocoa_mouseUp(theEvent) )
+ [super mouseUp:theEvent];
+}
+
+- (void)mouseMoved:(NSEvent *)theEvent
+{
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if( !win || !win->Cocoa_mouseMoved(theEvent) )
+ [super mouseMoved:theEvent];
+}
+
+- (void)mouseEntered:(NSEvent *)theEvent
+{
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if( !win || !win->Cocoa_mouseEntered(theEvent) )
+ [super mouseEntered:theEvent];
+}
+
+- (void)mouseExited:(NSEvent *)theEvent
+{
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if( !win || !win->Cocoa_mouseExited(theEvent) )
+ [super mouseExited:theEvent];
+}
+
+- (void)rightMouseDown:(NSEvent *)theEvent
+{
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if( !win || !win->Cocoa_rightMouseDown(theEvent) )
+ [super rightMouseDown:theEvent];
+}
+
+- (void)rightMouseDragged:(NSEvent *)theEvent
+{
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if( !win || !win->Cocoa_rightMouseDragged(theEvent) )
+ [super rightMouseDragged:theEvent];
+}
+
+- (void)rightMouseUp:(NSEvent *)theEvent
+{
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if( !win || !win->Cocoa_rightMouseUp(theEvent) )
+ [super rightMouseUp:theEvent];
+}
+
+- (void)otherMouseDown:(NSEvent *)theEvent
+{
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if( !win || !win->Cocoa_otherMouseDown(theEvent) )
+ [super otherMouseDown:theEvent];
+}
+
+- (void)otherMouseDragged:(NSEvent *)theEvent
+{
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if( !win || !win->Cocoa_otherMouseDragged(theEvent) )
+ [super otherMouseDragged:theEvent];
+}
+
+- (void)otherMouseUp:(NSEvent *)theEvent
+{
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if( !win || !win->Cocoa_otherMouseUp(theEvent) )
+ [super otherMouseUp:theEvent];
+}
+
+- (void)resetCursorRects
+{
+ wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self);
+ if( !win || !win->Cocoa_resetCursorRects() )
+ [super resetCursorRects];
+}
+
@end // wxNonControlNSControl
IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
void wxFrame::UpdateFrameNSView()
{
if(!m_frameNSView)
- {
+ { // NOTE: We only need a plain NSView here since we don't associate it with ourselves.
m_frameNSView = [[NSView alloc] initWithFrame:[[m_cocoaNSWindow contentView] frame]];
[m_cocoaNSWindow setContentView: m_frameNSView];
[m_frameNSView addSubview:m_cocoaNSView];
#include "wx/cocoa/string.h"
#import <Foundation/NSString.h>
-#import <AppKit/NSMenu.h>
+#include "wx/cocoa/objc/NSMenu.h"
#if wxUSE_MENUS
bool wxMenu::Create(const wxString& title, long style)
{
wxAutoNSAutoreleasePool pool;
- m_cocoaNSMenu = [[NSMenu alloc] initWithTitle: wxNSStringWithWxString(title)];
+ m_cocoaNSMenu = [[WXNSMenu alloc] initWithTitle: wxNSStringWithWxString(title)];
AssociateNSMenu(m_cocoaNSMenu);
return true;
}
#include "wx/arrstr.h"
#endif //WX_PRECOMP
-#import <AppKit/NSView.h>
+#include "wx/cocoa/objc/NSView.h"
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
BEGIN_EVENT_TABLE(wxRadioBox, wxControl)
{
if(!CreateControl(parent,winid,pos,size,style,validator,name))
return false;
- SetNSView([[NSView alloc] initWithFrame: MakeDefaultNSRect(size)]);
+ SetNSView([[WXNSView alloc] initWithFrame: MakeDefaultNSRect(size)]);
[m_cocoaNSView release];
if(m_parent)
m_parent->CocoaAddChild(this);
#include "wx/cocoa/autorelease.h"
#include "wx/cocoa/string.h"
-#import <AppKit/NSView.h>
-#import <AppKit/NSWindow.h>
+#include "wx/cocoa/objc/NSView.h"
+#include "wx/cocoa/objc/NSWindow.h"
#import <AppKit/NSPanel.h>
// ----------------------------------------------------------------------------
// globals
m_cocoaNSWindow = NULL;
m_cocoaNSView = NULL;
+ // NOTE: We may need to deal with the contentView becoming a wx NSView as well.
+ NSWindow *newWindow;
+ // Create a WXNSPanel or a WXNSWindow depending on what type of window is desired.
if(style & wxFRAME_TOOL_WINDOW)
- SetNSWindow([[NSPanel alloc] initWithContentRect:cocoaRect styleMask:cocoaStyle backing:NSBackingStoreBuffered defer:NO]);
+ newWindow = [[WXNSPanel alloc] initWithContentRect:cocoaRect styleMask:cocoaStyle backing:NSBackingStoreBuffered defer:NO];
else
- SetNSWindow([[NSWindow alloc] initWithContentRect:cocoaRect styleMask:cocoaStyle backing:NSBackingStoreBuffered defer:NO]);
+ newWindow = [[WXNSWindow alloc] initWithContentRect:cocoaRect styleMask:cocoaStyle backing:NSBackingStoreBuffered defer:NO];
+ // Make sure the default content view is a WXNSView
+ [newWindow setContentView: [[WXNSView alloc] initWithFrame: [[newWindow contentView] frame]]];
+ // Associate the window and view
+ SetNSWindow(newWindow);
+
// NOTE: SetNSWindow has retained the Cocoa object for this object.
// Because we do not release on close, the following release matches the
// above alloc and thus the retain count will be 1.
[cocoaNSWindow retain];
[m_cocoaNSWindow release];
m_cocoaNSWindow = cocoaNSWindow;
+ // NOTE: We are no longer using posing so we won't get events on the
+ // window's view unless it was explicitly created as the wx view class.
if(m_cocoaNSWindow)
SetNSView([m_cocoaNSWindow contentView]);
else
#include "wx/cocoa/autorelease.h"
#include "wx/cocoa/string.h"
-#import <AppKit/NSView.h>
+#include "wx/cocoa/objc/NSView.h"
#import <AppKit/NSEvent.h>
#import <AppKit/NSScrollView.h>
#import <AppKit/NSColor.h>
// TODO: create the window
m_cocoaNSView = NULL;
- SetNSView([[NSView alloc] initWithFrame: MakeDefaultNSRect(size)]);
+ SetNSView([[WXNSView alloc] initWithFrame: MakeDefaultNSRect(size)]);
[m_cocoaNSView release];
if (m_parent)