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 );
|
||||
|
||||
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 :
|
||||
@@ -178,7 +181,7 @@ public :
|
||||
|
||||
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
|
||||
protected :
|
||||
WX_NSWindow m_macWindow;
|
||||
WX_wxNSWindow m_macWindow;
|
||||
void * m_macFullScreenData ;
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxNonOwnedWindowCocoaImpl)
|
||||
};
|
||||
@@ -202,6 +205,9 @@ protected :
|
||||
-(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 \
|
||||
{\
|
||||
@@ -232,6 +238,21 @@ protected :
|
||||
{\
|
||||
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;
|
||||
@@ -286,6 +307,28 @@ protected :
|
||||
|
||||
@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__
|
||||
|
||||
|
@@ -41,8 +41,8 @@ class wxListWidgetCocoaImpl;
|
||||
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;
|
||||
|
@@ -34,18 +34,6 @@
|
||||
// ----------------------
|
||||
#include <string.h>
|
||||
|
||||
@class wxNSMenuItem;
|
||||
|
||||
@interface wxNSMenu : NSMenu
|
||||
{
|
||||
wxMenuImpl* impl;
|
||||
}
|
||||
|
||||
- (void) setImplementation:(wxMenuImpl*) item;
|
||||
- (wxMenuImpl*) implementation;
|
||||
|
||||
@end
|
||||
|
||||
@implementation wxNSMenu
|
||||
|
||||
- (id) init
|
||||
@@ -128,6 +116,10 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface NSApplication(MissingAppleMenuCall)
|
||||
- (void)setAppleMenu:(NSMenu *)menu;
|
||||
@end
|
||||
|
||||
class wxMenuCocoaImpl : public wxMenuImpl
|
||||
{
|
||||
public :
|
||||
|
@@ -21,19 +21,6 @@
|
||||
|
||||
#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
|
||||
|
@@ -62,7 +62,7 @@ WXCOCOAIMPL_COMMON_INTERFACE
|
||||
wxWidgetCocoaImpl* viewimpl = [view implementation];
|
||||
if ( viewimpl )
|
||||
{
|
||||
wxNotebook* wxpeer = (wxNotebook*) viewimpl->GetWXPeer();
|
||||
// wxNotebook* wxpeer = (wxNotebook*) viewimpl->GetWXPeer();
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
@@ -18,20 +18,7 @@
|
||||
|
||||
@implementation wxNSBox
|
||||
|
||||
- (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation
|
||||
{
|
||||
impl = theImplementation;
|
||||
}
|
||||
|
||||
- (wxWidgetCocoaImpl*) implementation
|
||||
{
|
||||
return impl;
|
||||
}
|
||||
|
||||
- (BOOL) isFlipped
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
WXCOCOAIMPL_COMMON_IMPLEMENTATION
|
||||
|
||||
@end
|
||||
|
||||
|
@@ -53,12 +53,64 @@
|
||||
|
||||
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)
|
||||
|
@@ -37,11 +37,6 @@ NSRect wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const
|
||||
|
||||
- (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;
|
||||
@@ -50,6 +45,26 @@ WXCOCOAIMPL_COMMON_INTERFACE
|
||||
|
||||
@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;
|
||||
@@ -155,7 +170,6 @@ void SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
|
||||
// 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;
|
||||
@@ -166,6 +180,7 @@ void SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
|
||||
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) )
|
||||
@@ -341,28 +356,6 @@ void SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
|
||||
|
||||
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];
|
||||
@@ -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)
|
||||
{
|
||||
NSPoint clickLocation;
|
||||
|
Reference in New Issue
Block a user