}
static void
-gtk_compass_draw_mark(GtkCompass *compass, GdkGC *gc, gdouble t)
+gtk_compass_draw_mark(GtkCompass *compass, GdkGC *gc, gdouble angle, gint size)
{
GtkWidget *widget;
gint hs;
hs=compass->size/2;
gdk_draw_line(widget->window,gc,
- compass->xoffset+hs+((hs-5)*sin(t)),
- compass->yoffset+compass->size-((hs-5)*cos(t)),
- compass->xoffset+hs+((hs+5)*sin(t)),
- compass->yoffset+compass->size-((hs+5)*cos(t)));
+ compass->xoffset+hs+((hs-size)*sin(angle)),
+ compass->yoffset+compass->size-((hs-size)*cos(angle)),
+ compass->xoffset+hs+((hs+size)*sin(angle)),
+ compass->yoffset+compass->size-((hs+size)*cos(angle)));
}
static void
pango_context_set_matrix (compass->context, NULL);
g_snprintf(htext, 8, "%3.0f°", compass->data->heading);
+pango_font_description_set_size(compass->fontdesc, (10+fs) * PANGO_SCALE);
+pango_layout_set_font_description(compass->layout, compass->fontdesc);
pango_layout_set_text(compass->layout, htext, -1);
pango_layout_get_pixel_size(compass->layout, &x, &y);
}
tmp = ((dir - compass->data->heading) * (1.f / 180.f)) * G_PI;
- gdk_draw_line(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- compass->xoffset + size / 2 + ((size / 2 - 5) * sinf(tmp)),
- compass->yoffset + size - ((size / 2 - 5) * cosf(tmp)),
- compass->xoffset + size / 2 + ((size / 2 + 5) * sinf(tmp)),
- compass->yoffset + size - ((size / 2 + 5) * cosf(tmp)));
+
+ gtk_compass_draw_mark(compass, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], tmp, 6);
x = fsize[i];
if (abs((guint) (compass->data->heading / 45) * 45 - compass->data->heading)
pango_layout_get_pixel_size(compass->layout, &x, &y);
x = compass->xoffset + size / 2 + ((size / 2 + 15) * sinf(tmp)) - x / 2,
y = compass->yoffset + size - ((size / 2 + 15) * cosf(tmp)) - y / 2,
- gdk_draw_layout(widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- x, y, compass->layout);
+ gdk_draw_layout(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], x, y, compass->layout);
+}
- if (compass->dest_valid) {
- gtk_compass_draw_mark(compass, compass->gc_d, compass->dest_heading);
- }
+if (compass->dest_valid)
+ gtk_compass_draw_mark(compass, compass->gc_d, compass->dest_heading, 10);
- if (compass->way_valid) {
- gtk_compass_draw_mark(compass, compass->gc_w, compass->way_heading);
- }
-}
+if (compass->way_valid)
+ gtk_compass_draw_mark(compass, compass->gc_w, compass->way_heading, 10);
return;
}
-
static gboolean
gtk_compass_expose(GtkWidget *widget, GdkEventExpose *event)
{
void
gtk_compass_set_dest_heading(GtkWidget *widget, gboolean valid, gfloat heading)
{
+GtkCompass *compass;
g_return_if_fail(GTK_IS_COMPASS(widget));
+compass=GTK_COMPASS(widget);
+
compass->dest_valid=valid;
compass->dest_heading=heading;