more libgoffice help



Hi all,

I'm displaying a chart with libgoffice and I'd like to map motion
notify event coordinates to axis positions.

I've got fairly close, but I can't see how to take account of the
margins around the edges of the chart :-( Can anyone point me to some
sample code that does this?

Here's what I have:

        axes = gog_chart_get_axes( plotpresent->gchart, GOG_AXIS_X );
        x_axis = GOG_AXIS( axes->data );
        g_slist_free( axes );

        axes = gog_chart_get_axes( plotpresent->gchart, GOG_AXIS_Y );
        y_axis = GOG_AXIS( axes->data );
        g_slist_free( axes );

        gog_chart_get_plot_area( plotpresent->gchart, &plot_area );

        map = gog_chart_map_new( plotpresent->gchart,
                &plot_area, x_axis, y_axis, NULL, FALSE );

        x_map = gog_chart_map_get_axis_map( map, 0 );
        y_map = gog_chart_map_get_axis_map( map, 1 );

        x_canvas = event->x / (double) allocation->width;
        y_canvas = event->y / (double) allocation->height;

        x = gog_axis_map_from_view( x_map, x_canvas );
        y = gog_axis_map_from_view( y_map, y_canvas );

        gog_chart_map_free( map );

        printf( "event->x = %g, event->y = %g\n", event->x, event->y );
        printf( "x_canvas = %g, y_canvas = %g\n", x_canvas, y_canvas );
        printf( "x = %g, y = %g\n", x, y );

John



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]