cleaning up warnings, more common event code
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58092 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -118,12 +118,15 @@ public :
|
|||||||
void InstallEventHandler( WXWidget control = NULL );
|
void InstallEventHandler( WXWidget control = NULL );
|
||||||
|
|
||||||
virtual bool DoHandleMouseEvent(NSEvent *event);
|
virtual bool DoHandleMouseEvent(NSEvent *event);
|
||||||
|
virtual bool DoHandleKeyEvent(NSEvent *event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WXWidget m_osxView;
|
WXWidget m_osxView;
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DECLARE_WXCOCOA_OBJC_CLASS( wxNSWindow );
|
||||||
|
|
||||||
class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl
|
class wxNonOwnedWindowCocoaImpl : public wxNonOwnedWindowImpl
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
@@ -178,7 +181,7 @@ public :
|
|||||||
|
|
||||||
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
|
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
|
||||||
protected :
|
protected :
|
||||||
WX_NSWindow m_macWindow;
|
WX_wxNSWindow m_macWindow;
|
||||||
void * m_macFullScreenData ;
|
void * m_macFullScreenData ;
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl)
|
||||||
};
|
};
|
||||||
@@ -202,6 +205,9 @@ protected :
|
|||||||
-(void)mouseUp:(NSEvent *)event ;\
|
-(void)mouseUp:(NSEvent *)event ;\
|
||||||
-(void)rightMouseUp:(NSEvent *)event ;\
|
-(void)rightMouseUp:(NSEvent *)event ;\
|
||||||
-(void)otherMouseUp:(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 \
|
#define WXCOCOAIMPL_COMMON_MOUSE_IMPLEMENTATION -(void)mouseDown:(NSEvent *)event \
|
||||||
{\
|
{\
|
||||||
@@ -232,6 +238,21 @@ protected :
|
|||||||
{\
|
{\
|
||||||
if ( !impl->DoHandleMouseEvent(event) )\
|
if ( !impl->DoHandleMouseEvent(event) )\
|
||||||
[super otherMouseUp: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;
|
#define WXCOCOAIMPL_COMMON_MEMBERS wxWidgetCocoaImpl* impl;
|
||||||
@@ -286,6 +307,28 @@ protected :
|
|||||||
|
|
||||||
@end
|
@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__
|
#endif // __OBJC__
|
||||||
|
|
||||||
|
@@ -41,8 +41,8 @@ class wxListWidgetCocoaImpl;
|
|||||||
objectValueForTableColumn:(NSTableColumn *)aTableColumn
|
objectValueForTableColumn:(NSTableColumn *)aTableColumn
|
||||||
row:(NSInteger)rowIndex;
|
row:(NSInteger)rowIndex;
|
||||||
|
|
||||||
- (id)tableView:(NSTableView *)aTableView
|
- (void)tableView:(NSTableView *)aTableView
|
||||||
setObjectValue:(NSTableColumn *)aTableColumn
|
setObjectValue:(id)value forTableColumn:(NSTableColumn *)aTableColumn
|
||||||
row:(NSInteger)rowIndex;
|
row:(NSInteger)rowIndex;
|
||||||
|
|
||||||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView;
|
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView;
|
||||||
|
@@ -34,18 +34,6 @@
|
|||||||
// ----------------------
|
// ----------------------
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@class wxNSMenuItem;
|
|
||||||
|
|
||||||
@interface wxNSMenu : NSMenu
|
|
||||||
{
|
|
||||||
wxMenuImpl* impl;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setImplementation:(wxMenuImpl*) item;
|
|
||||||
- (wxMenuImpl*) implementation;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation wxNSMenu
|
@implementation wxNSMenu
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
@@ -128,6 +116,10 @@
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface NSApplication(MissingAppleMenuCall)
|
||||||
|
- (void)setAppleMenu:(NSMenu *)menu;
|
||||||
|
@end
|
||||||
|
|
||||||
class wxMenuCocoaImpl : public wxMenuImpl
|
class wxMenuCocoaImpl : public wxMenuImpl
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
|
@@ -21,19 +21,6 @@
|
|||||||
|
|
||||||
#include "wx/osx/private.h"
|
#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
|
@implementation wxNSMenuItem
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
|
@@ -62,7 +62,7 @@ WXCOCOAIMPL_COMMON_INTERFACE
|
|||||||
wxWidgetCocoaImpl* viewimpl = [view implementation];
|
wxWidgetCocoaImpl* viewimpl = [view implementation];
|
||||||
if ( viewimpl )
|
if ( viewimpl )
|
||||||
{
|
{
|
||||||
wxNotebook* wxpeer = (wxNotebook*) viewimpl->GetWXPeer();
|
// wxNotebook* wxpeer = (wxNotebook*) viewimpl->GetWXPeer();
|
||||||
}
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@@ -18,20 +18,7 @@
|
|||||||
|
|
||||||
@implementation wxNSBox
|
@implementation wxNSBox
|
||||||
|
|
||||||
- (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation
|
WXCOCOAIMPL_COMMON_IMPLEMENTATION
|
||||||
{
|
|
||||||
impl = theImplementation;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (wxWidgetCocoaImpl*) implementation
|
|
||||||
{
|
|
||||||
return impl;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL) isFlipped
|
|
||||||
{
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@@ -53,12 +53,64 @@
|
|||||||
|
|
||||||
WXCOCOAIMPL_COMMON_IMPLEMENTATION
|
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
|
// use our common calls
|
||||||
- (void) setTitle:(NSString *) title
|
- (void) setTitle:(NSString *) title
|
||||||
{
|
{
|
||||||
[self setStringValue: 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
|
@end
|
||||||
|
|
||||||
wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w)
|
wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w)
|
||||||
|
@@ -37,11 +37,6 @@ NSRect wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const
|
|||||||
|
|
||||||
- (void)drawRect: (NSRect) rect;
|
- (void)drawRect: (NSRect) rect;
|
||||||
|
|
||||||
- (void)keyDown:(NSEvent *)event;
|
|
||||||
- (void)keyUp:(NSEvent *)event;
|
|
||||||
- (void)flagsChanged:(NSEvent *)event;
|
|
||||||
- (void)handleKeyEvent:(NSEvent *)event;
|
|
||||||
|
|
||||||
WXCOCOAIMPL_COMMON_INTERFACE
|
WXCOCOAIMPL_COMMON_INTERFACE
|
||||||
|
|
||||||
- (BOOL) becomeFirstResponder;
|
- (BOOL) becomeFirstResponder;
|
||||||
@@ -50,6 +45,26 @@ WXCOCOAIMPL_COMMON_INTERFACE
|
|||||||
|
|
||||||
@end // wxNSView
|
@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 wxOSXTranslateCocoaKey(unsigned short code, int unichar )
|
||||||
{
|
{
|
||||||
long retval = code;
|
long retval = code;
|
||||||
@@ -155,7 +170,6 @@ void SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
|
|||||||
// these parameters are not given for all events
|
// these parameters are not given for all events
|
||||||
UInt32 button = [nsEvent buttonNumber];
|
UInt32 button = [nsEvent buttonNumber];
|
||||||
UInt32 clickCount = [nsEvent clickCount];
|
UInt32 clickCount = [nsEvent clickCount];
|
||||||
UInt32 mouseChord = 0; // TODO does this exist for cocoa
|
|
||||||
|
|
||||||
wxevent.m_x = screenMouseLocation.x;
|
wxevent.m_x = screenMouseLocation.x;
|
||||||
wxevent.m_y = screenMouseLocation.y;
|
wxevent.m_y = screenMouseLocation.y;
|
||||||
@@ -166,6 +180,7 @@ void SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
|
|||||||
wxevent.m_clickCount = clickCount;
|
wxevent.m_clickCount = clickCount;
|
||||||
wxevent.SetTimestamp( [nsEvent timestamp] * 1000.0 ) ;
|
wxevent.SetTimestamp( [nsEvent timestamp] * 1000.0 ) ;
|
||||||
/*
|
/*
|
||||||
|
UInt32 mouseChord = 0; // TODO does this exist for cocoa
|
||||||
// a control click is interpreted as a right click
|
// a control click is interpreted as a right click
|
||||||
bool thisButtonIsFakeRight = false ;
|
bool thisButtonIsFakeRight = false ;
|
||||||
if ( button == kEventMouseButtonPrimary && (modifiers & controlKey) )
|
if ( button == kEventMouseButtonPrimary && (modifiers & controlKey) )
|
||||||
@@ -341,28 +356,6 @@ void SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
|
|||||||
|
|
||||||
WXCOCOAIMPL_COMMON_IMPLEMENTATION
|
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) becomeFirstResponder
|
||||||
{
|
{
|
||||||
BOOL r = [super becomeFirstResponder];
|
BOOL r = [super becomeFirstResponder];
|
||||||
@@ -657,6 +650,13 @@ void wxWidgetCocoaImpl::InstallEventHandler( WXWidget control )
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxWidgetCocoaImpl::DoHandleKeyEvent(NSEvent *event)
|
||||||
|
{
|
||||||
|
wxKeyEvent wxevent(wxEVT_KEY_DOWN);
|
||||||
|
SetupKeyEvent( wxevent, event );
|
||||||
|
return GetWXPeer()->HandleWindowEvent(wxevent);
|
||||||
|
}
|
||||||
|
|
||||||
bool wxWidgetCocoaImpl::DoHandleMouseEvent(NSEvent *event)
|
bool wxWidgetCocoaImpl::DoHandleMouseEvent(NSEvent *event)
|
||||||
{
|
{
|
||||||
NSPoint clickLocation;
|
NSPoint clickLocation;
|
||||||
|
Reference in New Issue
Block a user