diff options
Diffstat (limited to 'tikzit/src')
-rw-r--r-- | tikzit/src/gtk/GraphInputHandler.h | 2 | ||||
-rw-r--r-- | tikzit/src/gtk/InputDelegate.h | 3 | ||||
-rw-r--r-- | tikzit/src/gtk/Surface.h | 4 | ||||
-rw-r--r-- | tikzit/src/gtk/WidgetSurface.h | 7 | ||||
-rw-r--r-- | tikzit/src/gtk/WidgetSurface.m | 16 |
5 files changed, 17 insertions, 15 deletions
diff --git a/tikzit/src/gtk/GraphInputHandler.h b/tikzit/src/gtk/GraphInputHandler.h index caf1528..4dbe5ca 100644 --- a/tikzit/src/gtk/GraphInputHandler.h +++ b/tikzit/src/gtk/GraphInputHandler.h @@ -40,7 +40,7 @@ typedef enum { CanvasDragState } MouseState; -@interface GraphInputHandler: NSObject { +@interface GraphInputHandler: NSObject <InputDelegate> { GraphRenderer *renderer; InputMode mode; MouseState state; diff --git a/tikzit/src/gtk/InputDelegate.h b/tikzit/src/gtk/InputDelegate.h index 1e35223..9f9b426 100644 --- a/tikzit/src/gtk/InputDelegate.h +++ b/tikzit/src/gtk/InputDelegate.h @@ -38,7 +38,8 @@ typedef enum { ScrollRight = 4, } ScrollDirection; -@interface NSObject (InputDelegate) +@protocol InputDelegate <NSObject> +@optional /** * A mouse button was pressed. */ diff --git a/tikzit/src/gtk/Surface.h b/tikzit/src/gtk/Surface.h index 449721f..b6d8d2e 100644 --- a/tikzit/src/gtk/Surface.h +++ b/tikzit/src/gtk/Surface.h @@ -33,7 +33,7 @@ typedef enum { @protocol Surface; -@protocol RenderDelegate +@protocol RenderDelegate <NSObject> - (void) renderWithContext:(id<RenderContext>)context onSurface:(id<Surface>)surface; @end @@ -47,7 +47,7 @@ typedef enum { * The surface should send a "SurfaceSizeChanged" notification * when the width or height changes. */ -@protocol Surface +@protocol Surface <NSObject> /** * The width of the surface, in surface units diff --git a/tikzit/src/gtk/WidgetSurface.h b/tikzit/src/gtk/WidgetSurface.h index 32c8222..02f2cbf 100644 --- a/tikzit/src/gtk/WidgetSurface.h +++ b/tikzit/src/gtk/WidgetSurface.h @@ -17,6 +17,7 @@ #import "TZFoundation.h" #import <gtk/gtk.h> +#import <InputDelegate.h> #import <Surface.h> /** @@ -26,7 +27,7 @@ GtkWidget *widget; Transformer *transformer; id <RenderDelegate> renderDelegate; - id inputDelegate; + id <InputDelegate> inputDelegate; BOOL keepCentered; BOOL grabsFocusOnClick; CGFloat defaultScale; @@ -36,8 +37,8 @@ - (id) initWithWidget:(GtkWidget*)widget; - (GtkWidget*) widget; -- (id) inputDelegate; -- (void) setInputDelegate:(id)delegate; +- (id<InputDelegate>) inputDelegate; +- (void) setInputDelegate:(id<InputDelegate>)delegate; - (BOOL) keepCentered; - (void) setKeepCentered:(BOOL)centered; diff --git a/tikzit/src/gtk/WidgetSurface.m b/tikzit/src/gtk/WidgetSurface.m index 14d799b..91e0218 100644 --- a/tikzit/src/gtk/WidgetSurface.m +++ b/tikzit/src/gtk/WidgetSurface.m @@ -170,11 +170,11 @@ static gboolean scroll_event_cb (GtkWidget *widget, GdkEventScroll *event, Widge } } -- (id) inputDelegate { +- (id<InputDelegate>) inputDelegate { return inputDelegate; } -- (void) setInputDelegate:(id)delegate { +- (void) setInputDelegate:(id<InputDelegate>)delegate { if (delegate == inputDelegate) { return; } @@ -471,7 +471,7 @@ static gboolean button_press_event_cb(GtkWidget *widget, GdkEventButton *event, } } - id delegate = [surface inputDelegate]; + id<InputDelegate> delegate = [surface inputDelegate]; if (delegate != nil) { NSPoint pos = NSMakePoint (event->x, event->y); MouseButton button = (MouseButton)event->button; @@ -491,7 +491,7 @@ static gboolean button_press_event_cb(GtkWidget *widget, GdkEventButton *event, static gboolean button_release_event_cb(GtkWidget *widget, GdkEventButton *event, WidgetSurface *surface) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - id delegate = [surface inputDelegate]; + id<InputDelegate> delegate = [surface inputDelegate]; if (delegate != nil) { if ([delegate respondsToSelector:@selector(mouseReleaseAt:withButton:andMask:)]) { NSPoint pos = NSMakePoint (event->x, event->y); @@ -508,7 +508,7 @@ static gboolean button_release_event_cb(GtkWidget *widget, GdkEventButton *event static gboolean motion_notify_event_cb(GtkWidget *widget, GdkEventMotion *event, WidgetSurface *surface) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - id delegate = [surface inputDelegate]; + id<InputDelegate> delegate = [surface inputDelegate]; if (delegate != nil) { if ([delegate respondsToSelector:@selector(mouseMoveTo:withButtons:andMask:)]) { NSPoint pos = NSMakePoint (event->x, event->y); @@ -525,7 +525,7 @@ static gboolean motion_notify_event_cb(GtkWidget *widget, GdkEventMotion *event, static gboolean key_press_event_cb(GtkWidget *widget, GdkEventKey *event, WidgetSurface *surface) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - id delegate = [surface inputDelegate]; + id<InputDelegate> delegate = [surface inputDelegate]; if (delegate != nil) { if ([delegate respondsToSelector:@selector(keyPressed:withMask:)]) { InputMask mask = mask_from_gdk_modifier_state (event->state); @@ -540,7 +540,7 @@ static gboolean key_press_event_cb(GtkWidget *widget, GdkEventKey *event, Widget static gboolean key_release_event_cb(GtkWidget *widget, GdkEventKey *event, WidgetSurface *surface) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - id delegate = [surface inputDelegate]; + id<InputDelegate> delegate = [surface inputDelegate]; if (delegate != nil) { if ([delegate respondsToSelector:@selector(keyReleased:withMask:)]) { InputMask mask = mask_from_gdk_modifier_state (event->state); @@ -555,7 +555,7 @@ static gboolean key_release_event_cb(GtkWidget *widget, GdkEventKey *event, Widg static gboolean scroll_event_cb (GtkWidget *widget, GdkEventScroll *event, WidgetSurface *surface) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - id delegate = [surface inputDelegate]; + id<InputDelegate> delegate = [surface inputDelegate]; if (delegate != nil) { if ([delegate respondsToSelector:@selector(mouseScrolledAt:inDirection:withMask:)]) { NSPoint pos = NSMakePoint (event->x, event->y); |