]> git.saurik.com Git - wxWidgets.git/commitdiff
cleaning up warnings, more common event code
authorStefan Csomor <csomor@advancedconcepts.ch>
Wed, 14 Jan 2009 13:56:05 +0000 (13:56 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Wed, 14 Jan 2009 13:56:05 +0000 (13:56 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58092 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/osx/cocoa/private.h
src/osx/cocoa/listbox.mm
src/osx/cocoa/menu.mm
src/osx/cocoa/menuitem.mm
src/osx/cocoa/notebook.mm
src/osx/cocoa/statbox.mm
src/osx/cocoa/textctrl.mm
src/osx/cocoa/window.mm

index 26f1a90a507210d1465b131b2b7e6aace8794abc..de4b72ae4692ed5b498681c8337374bec815948a 100644 (file)
@@ -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__
 
index 94d57afad60cbb0105b5d1855f121242bb4f60a0..270d3ba4df2532ac0e9aa4365fb4762ec66e4c4b 100644 (file)
@@ -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;
index 09a753f6b56e7af3c143bb1977850ce26b7e639b..312759735621f50f9098742c6b11cce01ed7153e 100644 (file)
 // ----------------------
 #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 :
index 87132b46000e6d5d7f5b4816f504ccf88785a6de..6b05d359fbd999f5b43dc99dfb022afa1f39120f 100644 (file)
 
 #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
index bf86c4fbdf8f6f4dcea22f93c6a932bcf36d5dbc..a0c65acb66211f06510f9dba8e2c6af3ba1b9903 100644 (file)
@@ -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;
 }
index 6f7fecfc38fa6644f3157266bff06a8c906ed98b..c05dc97365a747cde7ab66bc98e3b547d32ae9d5 100644 (file)
 
 @implementation wxNSBox
 
-- (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation
-{
-    impl = theImplementation;
-}
-
-- (wxWidgetCocoaImpl*) implementation
-{
-    return impl;
-}
-
-- (BOOL) isFlipped
-{
-    return NO;
-}
+WXCOCOAIMPL_COMMON_IMPLEMENTATION
 
 @end
 
index 16881be7c73da9193a69e9d253232ff67a8bb364..61b8506db852ed5e564e6a2bb110dee8a6c95d9d 100644 (file)
 
 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)
index 524a5b2645ed8cdd2e8d5293a8b937aac7137b5c..c50baa63a0cf1227dbee7dc829c4c47b7d77bbca 100644 (file)
@@ -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;