summaryrefslogtreecommitdiff
path: root/navit/graphics
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-08-24 12:07:07 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-08-24 12:07:07 +0000
commit528e292f92e304da2f9c2eea2581c4147e94e036 (patch)
tree1c6f7d378f6e0a16fbbf33fe2aab071fb00f1e98 /navit/graphics
parent86618a8c5b474c69308d294f69c89c205bb8a20c (diff)
downloadnavit-528e292f92e304da2f9c2eea2581c4147e94e036.tar.gz
Fix:graphics_cocoa:Font rendering and timeouts
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@4705 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/graphics')
-rw-r--r--navit/graphics/cocoa/graphics_cocoa.m55
1 files changed, 44 insertions, 11 deletions
diff --git a/navit/graphics/cocoa/graphics_cocoa.m b/navit/graphics/cocoa/graphics_cocoa.m
index a7d972489..95256de5a 100644
--- a/navit/graphics/cocoa/graphics_cocoa.m
+++ b/navit/graphics/cocoa/graphics_cocoa.m
@@ -70,10 +70,12 @@ iconv_t utf8_macosroman;
struct graphics_gc_priv {
CGFloat rgba[4];
+ int w;
};
struct graphics_font_priv {
int size;
+ char *name;
};
@@ -161,6 +163,16 @@ struct graphics_font_priv {
dbg(0,"Enter %d %d\n",p.x,p.y);
callback_list_call_attr_3(graphics->cbl, attr_button, GINT_TO_POINTER(0), GINT_TO_POINTER(1), (void *)&p);
}
+
+- (void)mouseDragged:(UIEvent *)theEvent
+{
+ struct point p;
+ p.x=theEvent.locationInWindow.x;
+ p.y=graphics->h-theEvent.locationInWindow.y;
+
+ dbg(0,"Enter %d %d\n",p.x,p.y);
+ callback_list_call_attr_1(graphics->cbl, attr_motion, (void *)&p);
+}
#endif
- (void)dealloc {
@@ -216,6 +228,7 @@ struct graphics_font_priv {
CGContextTranslateCTM(myV->layer_context, 0, -frame.size.height);
#endif
CGContextSetRGBFillColor(myV->layer_context, 1, 1, 1, 1);
+ CGContextSetRGBStrokeColor(myV->layer_context, 1, 1, 1, 1);
CGContextFillRect(myV->layer_context, lr);
[myV initWithFrame: frame];
@@ -346,6 +359,9 @@ draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *
points[i].y=p[i].y;
}
CGContextSetStrokeColor(gr->view->layer_context, gc->rgba);
+ CGContextSetLineWidth(gr->view->layer_context, gc->w);
+ CGContextSetLineCap(gr->view->layer_context, kCGLineCapRound);
+ CGContextBeginPath(gr->view->layer_context);
CGContextAddLines(gr->view->layer_context, points, count);
CGContextStrokePath(gr->view->layer_context);
@@ -361,6 +377,7 @@ draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point
points[i].y=p[i].y;
}
CGContextSetFillColor(gr->view->layer_context, gc->rgba);
+ CGContextBeginPath(gr->view->layer_context);
CGContextAddLines(gr->view->layer_context, points, count);
CGContextFillPath(gr->view->layer_context);
}
@@ -384,9 +401,9 @@ draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics
CGContextSetFillColor(gr->view->layer_context, fg->rgba);
- CGContextSelectFont(gr->view->layer_context, "Helvetica Bold", 24.0f, kCGEncodingMacRoman);
+ CGContextSelectFont(gr->view->layer_context, font->name, font->size/16.0, kCGEncodingMacRoman);
CGContextSetTextDrawingMode(gr->view->layer_context, kCGTextFill);
- CGAffineTransform xform = CGAffineTransformMake(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f);
+ CGAffineTransform xform = CGAffineTransformMake(dx/65536.0, dy/65536.0, dy/65536.0, -dx/65536.0, 0.0f, 0.0f);
CGContextSetTextMatrix(gr->view->layer_context, xform);
CGContextShowTextAtPoint(gr->view->layer_context, p->x, p->y, outb, strlen(outb));
}
@@ -420,6 +437,7 @@ static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct grap
*meth=font_methods;
ret->size=size;
+ ret->name="Helvetica";
return ret;
}
@@ -432,6 +450,7 @@ gc_destroy(struct graphics_gc_priv *gc)
static void
gc_set_linewidth(struct graphics_gc_priv *gc, int w)
{
+ gc->w=w;
}
static void
@@ -470,6 +489,7 @@ static struct graphics_gc_methods gc_methods = {
static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
{
struct graphics_gc_priv *gc=g_new(struct graphics_gc_priv, 1);
+ gc->w=1;
*meth=gc_methods;
return gc;
@@ -618,14 +638,6 @@ event_cocoa_main_loop_run(void)
[pool release];
}
-static void *
-event_cocoa_add_timeout(void)
-{
- dbg(0,"enter\n");
- return NULL;
-}
-
-
@interface NavitTimer : NSObject{
@public
struct callback *cb;
@@ -650,6 +662,27 @@ struct event_idle {
NSTimer *timer;
};
+static void *
+event_cocoa_add_timeout(int timeout, int multi, struct callback *cb)
+{
+ NavitTimer *ret=[[NavitTimer alloc]init];
+ ret->cb=cb;
+ ret->timer=[NSTimer scheduledTimerWithTimeInterval:(timeout/1000.0) target:ret selector:@selector(onTimer:) userInfo:nil repeats:multi?YES:NO];
+ dbg(0,"timer=%p\n",ret->timer);
+ return ret;
+}
+
+
+static void
+event_cocoa_remove_timeout(struct event_timeout *ev)
+{
+ NavitTimer *t=(NavitTimer *)ev;
+
+ [t->timer invalidate];
+ [t release];
+}
+
+
static struct event_idle *
event_cocoa_add_idle(int priority, struct callback *cb)
{
@@ -676,7 +709,7 @@ static struct event_methods event_cocoa_methods = {
NULL, /* event_cocoa_add_watch, */
NULL, /* event_cocoa_remove_watch, */
event_cocoa_add_timeout,
- NULL, /* event_cocoa_remove_timeout, */
+ event_cocoa_remove_timeout,
event_cocoa_add_idle,
event_cocoa_remove_idle,
NULL, /* event_cocoa_call_callback, */