static void
gtk_gps_init(GtkGps *gps)
{
-g_printf("%s()\n", __PRETTY_FUNCTION__);
-
gps->gc_w=NULL;
gps->gc_s=NULL;
gps->gc_sf=NULL;
{
GtkGps *gps;
-g_printf("%s()\n", __PRETTY_FUNCTION__);
-
g_return_if_fail(GTK_IS_GPS(widget));
g_return_if_fail(requisition!=NULL);
gchar buffer[16];
guint line[12]={0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330};
-g_printf("%s()\n", __PRETTY_FUNCTION__);
-
widget=GTK_WIDGET(gps);
g_return_if_fail(gps->data);
xoffset + size / 6 * 2, yoffset + size / 6 * 2,
size / 6 * 2, size / 6 * 2, 0, 64 * 360);
-for (i = 0; i < 6; i++) {
- /* line */
+for (i = 0; i < 12; i++) {
+ gfloat sint, cost;
+
tmp = (line[i] * (1.f / 180.f)) * G_PI;
+ sint=sinf(tmp);
+ cost=cosf(tmp);
+ /* line */
gdk_draw_line(widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- xoffset + halfsize + (halfsize - 2) * sinf(tmp),
- yoffset + halfsize - (halfsize - 2) * cosf(tmp),
- xoffset + halfsize - (halfsize - 2) * sinf(tmp),
- yoffset + halfsize + (halfsize - 2) * cosf(tmp));
-}
+ xoffset + halfsize + (halfsize - 2) * sint,
+ yoffset + halfsize - (halfsize - 2) * cost,
+ xoffset + halfsize - (halfsize - 2) * sint,
+ yoffset + halfsize + (halfsize - 2) * cost);
+
+ /* Skip angle text if there is no space */
+ if (size<100)
+ continue;
-if (size>100) {
-for (i = 0; i < 12; i++) {
- tmp = (line[i] * (1.f / 180.f)) * G_PI;
- /* azimuth */
if (line[i] == 0)
g_snprintf(buffer, 16, "N");
else
pango_layout_set_text(gps->layout, buffer, -1);
pango_layout_get_pixel_size(gps->layout, &x, &y);
gdk_draw_layout(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
- (xoffset + halfsize + (halfsize - size / 12) * sinf(tmp)) - x / 2,
- (yoffset + halfsize - (halfsize - size / 12) * cosf(tmp)) - y / 2,
+ (xoffset + halfsize + (halfsize - size / 12) * sint) - x / 2,
+ (yoffset + halfsize - (halfsize - size / 12) * cost) - y / 2,
gps->layout);
+
}
-/* elevation 30 */
-tmp = (30 * (1.f / 180.f)) * G_PI;
-g_snprintf(buffer, 16, "30°");
-pango_layout_set_text(gps->layout, buffer, -1);
-pango_layout_get_pixel_size(gps->layout, &x, &y);
-gdk_draw_layout(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
+if (size>100) {
+ tmp = (30 * (1.f / 180.f)) * G_PI;
+ /* elevation 30 */
+ g_snprintf(buffer, 16, "30°");
+ pango_layout_set_text(gps->layout, buffer, -1);
+ pango_layout_get_pixel_size(gps->layout, &x, &y);
+ gdk_draw_layout(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
(xoffset + halfsize + size / 6 * 2 * sinf(tmp)) - x / 2,
(yoffset + halfsize - size / 6 * 2 * cosf(tmp)) - y / 2,
gps->layout);
-/* elevation 60 */
-tmp = (30 * (1.f / 180.f)) * G_PI;
-g_snprintf(buffer, 16, "60°");
-pango_layout_set_text(gps->layout, buffer, -1);
-pango_layout_get_pixel_size(gps->layout, &x, &y);
-gdk_draw_layout(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
+ /* elevation 60 */
+ g_snprintf(buffer, 16, "60°");
+ pango_layout_set_text(gps->layout, buffer, -1);
+ pango_layout_get_pixel_size(gps->layout, &x, &y);
+ gdk_draw_layout(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
(xoffset + halfsize + size / 6 * sinf(tmp)) - x / 2,
(yoffset + halfsize - size / 6 * cosf(tmp)) - y / 2,
gps->layout);
g_return_if_fail(GTK_IS_GPS(widget));
gps=GTK_GPS(widget);
-gtk_gps_paint_by_mode(gps);
+gtk_widget_queue_draw_area(widget, 0, 0, gps->width, gps->height);
}