void InstallEventHandler( WXWidget control = NULL );
virtual bool DoHandleMouseEvent(NSEvent *event);
+ virtual bool DoHandleKeyEvent(NSEvent *event);
protected:
WXWidget m_osxView;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
};
+DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow );
+
class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl
{
public :
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
protected :
- WX_NSWindow m_macWindow;
+ WX_wxNSWindow m_macWindow;
void * m_macFullScreenData ;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl)
};
-(void)mouseUp:(NSEvent *)event ;\
-(void)rightMouseUp:(NSEvent *)event ;\
-(void)otherMouseUp:(NSEvent *)event ;\
+ - (void)keyDown:(NSEvent *)event;\
+ - (void)keyUp:(NSEvent *)event;\
+ - (void)flagsChanged:(NSEvent *)event;\
#define WXCOCOAIMPL_COMMON_MOUSE_IMPLEMENTATION -(void)mouseDown:(NSEvent *)event \
{\
{\
if ( !impl->DoHandleMouseEvent(event) )\
[super otherMouseUp:event];\
+ }\
+ -(void)keyDown:(NSEvent *)event\
+ {\
+ if ( !impl->DoHandleKeyEvent(event) )\
+ [super keyDown:event];\
+ }\
+ -(void)keyUp:(NSEvent *)event\
+ {\
+ if ( !impl->DoHandleKeyEvent(event) )\
+ [super keyUp:event];\
+ }\
+ -(void)flagsChanged:(NSEvent *)event\
+ {\
+ if ( !impl->DoHandleKeyEvent(event) )\
+ [super flagsChanged:event];\
}
#define WXCOCOAIMPL_COMMON_MEMBERS wxWidgetCocoaImpl* impl;
@end
+ @interface wxNSMenu : NSMenu
+ {
+ wxMenuImpl* impl;
+ }
+
+ - (void) setImplementation:(wxMenuImpl*) item;
+ - (wxMenuImpl*) implementation;
+
+ @end
+
+ @interface wxNSMenuItem : NSMenuItem
+ {
+ wxMenuItemImpl* impl;
+ }
+
+ - (void) setImplementation:(wxMenuItemImpl*) item;
+ - (wxMenuItemImpl*) implementation;
+
+ - (void)clickedAction:(id)sender;
+ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
+
+ @end
#endif // __OBJC__
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(NSInteger)rowIndex;
-- (id)tableView:(NSTableView *)aTableView
- setObjectValue:(NSTableColumn *)aTableColumn
+- (void)tableView:(NSTableView *)aTableView
+ setObjectValue:(id)value forTableColumn:(NSTableColumn *)aTableColumn
row:(NSInteger)rowIndex;
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView;
// ----------------------
#include <string.h>
-@class wxNSMenuItem;
-
-@interface wxNSMenu : NSMenu
-{
- wxMenuImpl* impl;
-}
-
-- (void) setImplementation:(wxMenuImpl*) item;
-- (wxMenuImpl*) implementation;
-
-@end
-
@implementation wxNSMenu
- (id) init
@end
+@interface NSApplication(MissingAppleMenuCall)
+- (void)setAppleMenu:(NSMenu *)menu;
+@end
+
class wxMenuCocoaImpl : public wxMenuImpl
{
public :
#include "wx/osx/private.h"
-@interface wxNSMenuItem : NSMenuItem
-{
- wxMenuItemImpl* impl;
-}
-
-- (void) setImplementation:(wxMenuItemImpl*) item;
-- (wxMenuItemImpl*) implementation;
-
-- (void) clickedAction: (id) sender;
-- (BOOL)validateMenuItem:(NSMenuItem *) menuItem;
-
-@end
-
@implementation wxNSMenuItem
- (id) init
wxWidgetCocoaImpl* viewimpl = [view implementation];
if ( viewimpl )
{
- wxNotebook* wxpeer = (wxNotebook*) viewimpl->GetWXPeer();
+ // wxNotebook* wxpeer = (wxNotebook*) viewimpl->GetWXPeer();
}
return YES;
}
@implementation wxNSBox
-- (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation
-{
- impl = theImplementation;
-}
-
-- (wxWidgetCocoaImpl*) implementation
-{
- return impl;
-}
-
-- (BOOL) isFlipped
-{
- return NO;
-}
+WXCOCOAIMPL_COMMON_IMPLEMENTATION
@end
WXCOCOAIMPL_COMMON_IMPLEMENTATION
+- (id)initWithFrame:(NSRect)frame
+{
+ [super initWithFrame:frame];
+ impl = NULL;
+ [self setDelegate: self];
+ [self setTarget: self];
+// [self setAction: @selector(enterAction:)];
+ return self;
+}
+
// use our common calls
- (void) setTitle:(NSString *) title
{
[self setStringValue: title];
}
+/*
+- (void)controlTextDidChange:(NSNotification *)aNotification
+{
+ if ( impl )
+ {
+ wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
+ if ( wxpeer ) {
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, wxpeer->GetId());
+ event.SetEventObject( wxpeer );
+ event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
+ wxpeer->HandleWindowEvent( event );
+ }
+ }
+}
+
+- (void)controlTextDidEndEditing:(NSNotification *)aNotification
+{
+ if ( impl )
+ {
+ wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
+ if ( wxpeer ) {
+ wxFocusEvent event(wxEVT_KILL_FOCUS, wxpeer->GetId());
+ event.SetEventObject( wxpeer );
+ event.SetWindow( wxpeer );
+ wxpeer->HandleWindowEvent( event );
+ }
+ }
+}
+- (void) enterAction: (id) sender
+{
+ if ( impl )
+ {
+ wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
+ if ( wxpeer && (wxpeer->GetWindowStyle() & wxTE_PROCESS_ENTER) ) {
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, wxpeer->GetId());
+ event.SetEventObject( wxpeer );
+ event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
+ wxpeer->HandleWindowEvent( event );
+ }
+ }
+}
+*/
@end
wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w)
- (void)drawRect: (NSRect) rect;
-- (void)keyDown:(NSEvent *)event;
-- (void)keyUp:(NSEvent *)event;
-- (void)flagsChanged:(NSEvent *)event;
-- (void)handleKeyEvent:(NSEvent *)event;
-
WXCOCOAIMPL_COMMON_INTERFACE
- (BOOL) becomeFirstResponder;
@end // wxNSView
+@interface NSView(PossibleMethods)
+- (void)setImplementation:(wxWidgetCocoaImpl *)theImplementation;
+- (void)setTitle:(NSString *)aString;
+- (void)setStringValue:(NSString *)aString;
+- (void)setIntValue:(int)anInt;
+- (void)setFloatValue:(float)aFloat;
+- (void)setDoubleValue:(double)aDouble;
+
+- (void)setMinValue:(double)aDouble;
+- (void)setMaxValue:(double)aDouble;
+
+- (void)sizeToFit;
+
+- (BOOL)isEnabled;
+- (void)setEnabled:(BOOL)flag;
+
+- (void)setImage:(NSImage *)image;
+- (void)setControlSize:(NSControlSize)size;
+@end
+
long wxOSXTranslateCocoaKey(unsigned short code, int unichar )
{
long retval = code;
// these parameters are not given for all events
UInt32 button = [nsEvent buttonNumber];
UInt32 clickCount = [nsEvent clickCount];
- UInt32 mouseChord = 0; // TODO does this exist for cocoa
wxevent.m_x = screenMouseLocation.x;
wxevent.m_y = screenMouseLocation.y;
wxevent.m_clickCount = clickCount;
wxevent.SetTimestamp( [nsEvent timestamp] * 1000.0 ) ;
/*
+ UInt32 mouseChord = 0; // TODO does this exist for cocoa
// a control click is interpreted as a right click
bool thisButtonIsFakeRight = false ;
if ( button == kEventMouseButtonPrimary && (modifiers & controlKey) )
WXCOCOAIMPL_COMMON_IMPLEMENTATION
-- (void)keyDown:(NSEvent *)event
-{
- [self handleKeyEvent:event];
-}
-
-- (void)keyUp:(NSEvent *)event
-{
- [self handleKeyEvent:event];
-}
-
-- (void)flagsChanged:(NSEvent *)event
-{
- [self handleKeyEvent:event];
-}
-
-- (void)handleKeyEvent:(NSEvent *)event
-{
- wxKeyEvent wxevent(wxEVT_KEY_DOWN);
- SetupKeyEvent( wxevent, event );
- impl->GetWXPeer()->HandleWindowEvent(wxevent);
-}
-
- (BOOL) becomeFirstResponder
{
BOOL r = [super becomeFirstResponder];
{
}
+bool wxWidgetCocoaImpl::DoHandleKeyEvent(NSEvent *event)
+{
+ wxKeyEvent wxevent(wxEVT_KEY_DOWN);
+ SetupKeyEvent( wxevent, event );
+ return GetWXPeer()->HandleWindowEvent(wxevent);
+}
+
bool wxWidgetCocoaImpl::DoHandleMouseEvent(NSEvent *event)
{
NSPoint clickLocation;