diff options
author | Daniele E. Domenichelli <daniele.domenichelli@iit.it> | 2013-08-06 09:33:59 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-10-08 14:47:06 (GMT) |
commit | 7efef02df29399d37b692e01fb69de63e558585b (patch) | |
tree | 5faedaafc63060018e252aa8c5f876a3ad9fca7b /Tests/FindGTK2/cairo | |
parent | 95fc47aa49515d45afcfb609262bd85025fb4a3d (diff) | |
download | CMake-7efef02df29399d37b692e01fb69de63e558585b.zip CMake-7efef02df29399d37b692e01fb69de63e558585b.tar.gz CMake-7efef02df29399d37b692e01fb69de63e558585b.tar.bz2 |
FindGTK2: Add tests for components and targets in gtk and gtkmm modules
Diffstat (limited to 'Tests/FindGTK2/cairo')
-rw-r--r-- | Tests/FindGTK2/cairo/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/FindGTK2/cairo/main.c | 52 |
2 files changed, 62 insertions, 0 deletions
diff --git a/Tests/FindGTK2/cairo/CMakeLists.txt b/Tests/FindGTK2/cairo/CMakeLists.txt new file mode 100644 index 0000000..97a7369 --- /dev/null +++ b/Tests/FindGTK2/cairo/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.8) + +project(cairo C) + +find_package(GTK2 COMPONENTS gtk REQUIRED) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_executable(cairo WIN32 main.c) +target_link_libraries(cairo GTK2::cairo) diff --git a/Tests/FindGTK2/cairo/main.c b/Tests/FindGTK2/cairo/main.c new file mode 100644 index 0000000..1b61001 --- /dev/null +++ b/Tests/FindGTK2/cairo/main.c @@ -0,0 +1,52 @@ +/* Taken from http://cairographics.org/samples/ */ + + +#include <cairo.h> +#include <math.h> +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + char *filename; + if (argc != 2) + { + fprintf (stderr, "Usage: %s OUTPUT_FILENAME\n", argv[0]); + return 1; + } + filename = argv[1]; + double xc = 128.0; + double yc = 128.0; + double radius = 100.0; + double angle1 = 45.0 * (M_PI/180.0); /* angles are specified */ + double angle2 = 180.0 * (M_PI/180.0); /* in radians */ + + cairo_surface_t *im = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, xc * 2, yc * 2); + cairo_t *cr = cairo_create(im); + + + cairo_set_line_width (cr, 10.0); + cairo_arc (cr, xc, yc, radius, angle1, angle2); + cairo_stroke (cr); + + /* draw helping lines */ + cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6); + cairo_set_line_width (cr, 6.0); + + cairo_arc (cr, xc, yc, 10.0, 0, 2*M_PI); + cairo_fill (cr); + + cairo_arc (cr, xc, yc, radius, angle1, angle1); + cairo_line_to (cr, xc, yc); + cairo_arc (cr, xc, yc, radius, angle2, angle2); + cairo_line_to (cr, xc, yc); + cairo_stroke (cr); + + cairo_status_t status = cairo_surface_write_to_png (im, filename); + cairo_surface_destroy (im); + if (status != CAIRO_STATUS_SUCCESS) { + fprintf(stderr, "Could not save png to '%s'\n", filename); + } + + cairo_destroy(cr); + return 0; +} |