Add:Core:Initial work for graphics_cocoa
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 21 Jul 2011 21:07:32 +0000 (21:07 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 21 Jul 2011 21:07:32 +0000 (21:07 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@4658 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/CMakeLists.txt
navit/navit/graphics/cocoa/CMakeLists.txt [new file with mode: 0644]
navit/navit/graphics/cocoa/cocoa_if.h [new file with mode: 0644]
navit/navit/graphics/cocoa/cocoa_if.m [new file with mode: 0644]
navit/navit/graphics/cocoa/graphics_cocoa.c [new file with mode: 0644]
navit/navit/graphics/cocoa/nick.h [new file with mode: 0644]
navit/navit/graphics/cocoa/nick.m [new file with mode: 0644]

index 9f12448..cdbb581 100644 (file)
@@ -317,6 +317,7 @@ add_plugin(support/espeak "Default" FALSE)
 add_module(vehicle/android "Default" FALSE)
 add_module(vehicle/iphone "Default" FALSE)
 add_module(vehicle/wince "Default" FALSE)
+add_module(graphics/cocoa "Default" FALSE "-lcocoa" )
 
 # other features
 add_feature(USE_PLUGINS "default" TRUE)
diff --git a/navit/navit/graphics/cocoa/CMakeLists.txt b/navit/navit/graphics/cocoa/CMakeLists.txt
new file mode 100644 (file)
index 0000000..61a8ea3
--- /dev/null
@@ -0,0 +1 @@
+module_add_library(graphics_cocoa graphics_cocoa.c cocoa_if.m cocoa_if.h nick.m nick.h)
diff --git a/navit/navit/graphics/cocoa/cocoa_if.h b/navit/navit/graphics/cocoa/cocoa_if.h
new file mode 100644 (file)
index 0000000..a5f5fb6
--- /dev/null
@@ -0,0 +1,23 @@
+//
+//  HelloWorldAppDelegate.h
+//  HelloWorld
+//
+//  Created by Nick Geoghegan on 21/07/2011.
+//  Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#ifdef __OBJC__
+
+
+#import <Cocoa/Cocoa.h>
+
+@interface HelloWorldAppDelegate : NSObject <NSApplicationDelegate> {
+    NSWindow *window;
+}
+
+@property (assign) IBOutlet NSWindow *window;
+
+@end
+
+int coca_if_main(void);
+#endif
diff --git a/navit/navit/graphics/cocoa/cocoa_if.m b/navit/navit/graphics/cocoa/cocoa_if.m
new file mode 100644 (file)
index 0000000..71078d7
--- /dev/null
@@ -0,0 +1,27 @@
+//
+//  HelloWorldAppDelegate.m
+//  HelloWorld
+//
+//  Created by Nick Geoghegan on 21/07/2011.
+//  Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import "cocoa_if.h"
+
+@implementation HelloWorldAppDelegate
+
+@synthesize window;
+
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
+       // Insert code here to initialize your application 
+}
+
+@end
+
+int cocoa_if_main(void)
+{
+       int  argc=1;
+       char *argv[]={"navit",NULL};
+       return NSApplicationMain(argc,  (const char **) argv);
+}
+
diff --git a/navit/navit/graphics/cocoa/graphics_cocoa.c b/navit/navit/graphics/cocoa/graphics_cocoa.c
new file mode 100644 (file)
index 0000000..0d7b17b
--- /dev/null
@@ -0,0 +1,103 @@
+#include "config.h"
+#include "debug.h"
+#include "plugin.h"
+#include "point.h"
+#include "window.h"
+#include "graphics.h"
+#include "event.h"
+#include <glib.h>
+
+struct graphics_priv {
+       struct window win;
+};
+
+static void *
+get_data(struct graphics_priv *this, const char *type)
+{
+       dbg(0,"enter\n");
+       if (strcmp(type,"window"))
+               return NULL;
+       return &this->win;
+}
+
+
+static struct graphics_methods graphics_methods = {
+       NULL, /* graphics_destroy, */
+       NULL, /* draw_mode, */
+       NULL, /* draw_lines, */
+       NULL, /* draw_polygon, */
+       NULL, /* draw_rectangle, */
+       NULL, /* draw_circle, */
+       NULL, /* draw_text, */
+       NULL, /* draw_image, */
+       NULL, /* draw_image_warp, */
+       NULL, /* draw_restore, */
+       NULL, /* draw_drag, */
+       NULL, /* font_new, */
+       NULL, /* gc_new, */
+       NULL, /* background_gc, */
+       NULL, /* overlay_new, */
+       NULL, /* image_new, */
+       get_data,
+       NULL, /* image_free, */
+       NULL, /* get_text_bbox, */
+       NULL, /* overlay_disable, */
+       NULL, /* overlay_resize, */
+       NULL, /* set_attr, */
+};
+
+
+
+struct graphics_priv *
+graphics_cocoa_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl)
+{
+       *meth=graphics_methods;
+       dbg(0,"enter\n");
+       if(!event_request_system("cocoa","graphics_cocoa"))
+                return NULL;
+       return g_new0(struct graphics_priv, 1);
+}
+
+static void
+event_cocoa_main_loop_run(void)
+{
+       dbg(0,"enter\n");
+       cocoa_if_main();
+}
+
+static void *
+event_cocoa_add_timeout(void)
+{
+       dbg(0,"enter\n");
+       return NULL;
+}
+
+static struct event_methods event_cocoa_methods = {
+       event_cocoa_main_loop_run,
+       NULL, /* event_cocoa_main_loop_quit, */
+       NULL, /* event_cocoa_add_watch, */
+       NULL, /* event_cocoa_remove_watch, */
+       event_cocoa_add_timeout, 
+       NULL, /* event_cocoa_remove_timeout, */
+       NULL, /* event_cocoa_add_idle, */
+       NULL, /* event_cocoa_remove_idle, */
+       NULL, /* event_cocoa_call_callback, */
+};
+
+
+static struct event_priv *
+event_cocoa_new(struct event_methods *meth)
+{
+       dbg(0,"enter\n");
+       *meth=event_cocoa_methods;
+       return NULL;
+}
+
+
+void
+plugin_init(void)
+{
+       dbg(0,"enter\n");
+       plugin_register_graphics_type("cocoa", graphics_cocoa_new);
+       plugin_register_event_type("cocoa", event_cocoa_new);
+}
diff --git a/navit/navit/graphics/cocoa/nick.h b/navit/navit/graphics/cocoa/nick.h
new file mode 100644 (file)
index 0000000..de3037f
--- /dev/null
@@ -0,0 +1,17 @@
+//
+//  nick.h
+//  HelloWorld
+//
+//  Created by Nick Geoghegan on 21/07/2011.
+//  Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface nick : NSView 
+{
+
+}
+
+@end
diff --git a/navit/navit/graphics/cocoa/nick.m b/navit/navit/graphics/cocoa/nick.m
new file mode 100644 (file)
index 0000000..78afb66
--- /dev/null
@@ -0,0 +1,43 @@
+//
+//  nick.m
+//  HelloWorld
+//
+//  Created by Nick Geoghegan on 21/07/2011.
+//  Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#import "nick.h"
+
+
+@implementation nick
+
+- (id)initWithFrame:(NSRect)frame {
+    self = [super initWithFrame:frame];
+    if (self) {
+        // Initialization code here.
+    }
+    return self;
+}
+
+- (void)drawRect:(NSRect)dirtyRect {
+    // Drawing code here.
+       NSString*               hws = @"Hello Navit!";
+       NSPoint                 p;
+       NSMutableDictionary*    attribs;
+       NSColor*                c;
+       NSFont*                 fnt;
+       
+       p = NSMakePoint( 10, 100 );
+       
+       attribs = [[[NSMutableDictionary alloc] init] autorelease];
+       
+       c = [NSColor redColor];
+       fnt = [NSFont fontWithName:@"Times Roman" size:48];
+       
+       [attribs setObject:c forKey:NSForegroundColorAttributeName];
+       [attribs setObject:fnt forKey:NSFontAttributeName];
+       
+       [hws drawAtPoint:p withAttributes:attribs];
+}
+
+@end