diff options
Diffstat (limited to 'Tests/FindGTK2')
-rw-r--r-- | Tests/FindGTK2/atk/main.c | 6 | ||||
-rw-r--r-- | Tests/FindGTK2/atkmm/main.cpp | 6 | ||||
-rw-r--r-- | Tests/FindGTK2/cairo/main.c | 86 | ||||
-rw-r--r-- | Tests/FindGTK2/cairomm/main.cpp | 70 | ||||
-rw-r--r-- | Tests/FindGTK2/gdk/main.c | 6 | ||||
-rw-r--r-- | Tests/FindGTK2/gdk_pixbuf/main.c | 12 | ||||
-rw-r--r-- | Tests/FindGTK2/gdkmm/main.cpp | 6 | ||||
-rw-r--r-- | Tests/FindGTK2/gio/main.c | 8 | ||||
-rw-r--r-- | Tests/FindGTK2/giomm/main.cpp | 6 | ||||
-rw-r--r-- | Tests/FindGTK2/glib/main.c | 14 | ||||
-rw-r--r-- | Tests/FindGTK2/glibmm/main.cpp | 4 | ||||
-rw-r--r-- | Tests/FindGTK2/gmodule/main.c | 6 | ||||
-rw-r--r-- | Tests/FindGTK2/gobject/main.c | 56 | ||||
-rw-r--r-- | Tests/FindGTK2/gthread/main.c | 6 | ||||
-rw-r--r-- | Tests/FindGTK2/gtk/main.c | 14 | ||||
-rw-r--r-- | Tests/FindGTK2/gtkmm/helloworld.cpp | 24 | ||||
-rw-r--r-- | Tests/FindGTK2/gtkmm/helloworld.h | 12 | ||||
-rw-r--r-- | Tests/FindGTK2/gtkmm/main.cpp | 12 | ||||
-rw-r--r-- | Tests/FindGTK2/pango/main.c | 6 | ||||
-rw-r--r-- | Tests/FindGTK2/pangocairo/main.c | 102 | ||||
-rw-r--r-- | Tests/FindGTK2/pangoft2/main.c | 8 | ||||
-rw-r--r-- | Tests/FindGTK2/pangomm/main.cpp | 6 | ||||
-rw-r--r-- | Tests/FindGTK2/pangoxft/main.c | 6 | ||||
-rw-r--r-- | Tests/FindGTK2/sigc++/main.cpp | 16 |
24 files changed, 246 insertions, 252 deletions
diff --git a/Tests/FindGTK2/atk/main.c b/Tests/FindGTK2/atk/main.c index e25030e..4dc8d4d 100644 --- a/Tests/FindGTK2/atk/main.c +++ b/Tests/FindGTK2/atk/main.c @@ -1,7 +1,7 @@ #include <atk/atk.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - const gchar *name = atk_get_toolkit_name(); - return 0; + const gchar* name = atk_get_toolkit_name(); + return 0; } diff --git a/Tests/FindGTK2/atkmm/main.cpp b/Tests/FindGTK2/atkmm/main.cpp index f455c7a..89a97f7 100644 --- a/Tests/FindGTK2/atkmm/main.cpp +++ b/Tests/FindGTK2/atkmm/main.cpp @@ -1,8 +1,8 @@ #include <atkmm.h> #include <atkmm/init.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - Atk::init(); - return 0; + Atk::init(); + return 0; } diff --git a/Tests/FindGTK2/cairo/main.c b/Tests/FindGTK2/cairo/main.c index 1b61001..e2be60c 100644 --- a/Tests/FindGTK2/cairo/main.c +++ b/Tests/FindGTK2/cairo/main.c @@ -1,52 +1,50 @@ /* Taken from http://cairographics.org/samples/ */ - #include <cairo.h> #include <math.h> #include <stdio.h> -int main(int argc, char *argv[]) +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; + 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; } diff --git a/Tests/FindGTK2/cairomm/main.cpp b/Tests/FindGTK2/cairomm/main.cpp index 0db3a04..1a669c3 100644 --- a/Tests/FindGTK2/cairomm/main.cpp +++ b/Tests/FindGTK2/cairomm/main.cpp @@ -1,5 +1,5 @@ -// Taken from http://cgit.freedesktop.org/cairomm/plain/examples/surfaces/image-surface.cc - +// Taken from +// http://cgit.freedesktop.org/cairomm/plain/examples/surfaces/image-surface.cc /* M_PI is defined in math.h in the case of Microsoft Visual C++, Solaris, * et. al. @@ -18,45 +18,47 @@ int main() { - Cairo::RefPtr<Cairo::ImageSurface> surface = - Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 600, 400); - - Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface); - - cr->save(); // save the state of the context - cr->set_source_rgb(0.86, 0.85, 0.47); - cr->paint(); // fill image with the color - cr->restore(); // color is back to black now - - cr->save(); - // draw a border around the image - cr->set_line_width(20.0); // make the line wider - cr->rectangle(0.0, 0.0, surface->get_width(), surface->get_height()); - cr->stroke(); - - cr->set_source_rgba(0.0, 0.0, 0.0, 0.7); - // draw a circle in the center of the image - cr->arc(surface->get_width() / 2.0, surface->get_height() / 2.0, - surface->get_height() / 4.0, 0.0, 2.0 * M_PI); - cr->stroke(); - - // draw a diagonal line - cr->move_to(surface->get_width() / 4.0, surface->get_height() / 4.0); - cr->line_to(surface->get_width() * 3.0 / 4.0, surface->get_height() * 3.0 / 4.0); - cr->stroke(); - cr->restore(); + Cairo::RefPtr<Cairo::ImageSurface> surface = + Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 600, 400); + + Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface); + + cr->save(); // save the state of the context + cr->set_source_rgb(0.86, 0.85, 0.47); + cr->paint(); // fill image with the color + cr->restore(); // color is back to black now + + cr->save(); + // draw a border around the image + cr->set_line_width(20.0); // make the line wider + cr->rectangle(0.0, 0.0, surface->get_width(), surface->get_height()); + cr->stroke(); + + cr->set_source_rgba(0.0, 0.0, 0.0, 0.7); + // draw a circle in the center of the image + cr->arc(surface->get_width() / 2.0, surface->get_height() / 2.0, + surface->get_height() / 4.0, 0.0, 2.0 * M_PI); + cr->stroke(); + + // draw a diagonal line + cr->move_to(surface->get_width() / 4.0, surface->get_height() / 4.0); + cr->line_to(surface->get_width() * 3.0 / 4.0, + surface->get_height() * 3.0 / 4.0); + cr->stroke(); + cr->restore(); #ifdef CAIRO_HAS_PNG_FUNCTIONS - std::string filename = "image.png"; - surface->write_to_png(filename); + std::string filename = "image.png"; + surface->write_to_png(filename); - std::cout << "Wrote png file \"" << filename << "\"" << std::endl; + std::cout << "Wrote png file \"" << filename << "\"" << std::endl; #else - std::cout << "You must compile cairo with PNG support for this example to work." - << std::endl; + std::cout + << "You must compile cairo with PNG support for this example to work." + << std::endl; #endif } diff --git a/Tests/FindGTK2/gdk/main.c b/Tests/FindGTK2/gdk/main.c index ac1bd4b..71f523b 100644 --- a/Tests/FindGTK2/gdk/main.c +++ b/Tests/FindGTK2/gdk/main.c @@ -1,7 +1,7 @@ #include <gdk/gdk.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - gdk_init(argc, argv); - return 0; + gdk_init(argc, argv); + return 0; } diff --git a/Tests/FindGTK2/gdk_pixbuf/main.c b/Tests/FindGTK2/gdk_pixbuf/main.c index e42b83e..ed9f564 100644 --- a/Tests/FindGTK2/gdk_pixbuf/main.c +++ b/Tests/FindGTK2/gdk_pixbuf/main.c @@ -1,10 +1,10 @@ #include <gdk-pixbuf/gdk-pixbuf.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - const char *version = gdk_pixbuf_version; - const guint major = gdk_pixbuf_major_version; - const guint minor = gdk_pixbuf_minor_version; - const guint micro = gdk_pixbuf_micro_version; - return 0; + const char* version = gdk_pixbuf_version; + const guint major = gdk_pixbuf_major_version; + const guint minor = gdk_pixbuf_minor_version; + const guint micro = gdk_pixbuf_micro_version; + return 0; } diff --git a/Tests/FindGTK2/gdkmm/main.cpp b/Tests/FindGTK2/gdkmm/main.cpp index 935bcc4..639e261 100644 --- a/Tests/FindGTK2/gdkmm/main.cpp +++ b/Tests/FindGTK2/gdkmm/main.cpp @@ -1,7 +1,7 @@ #include <gdkmm.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - Gdk::Color red = Gdk::Color("red"); - return 0; + Gdk::Color red = Gdk::Color("red"); + return 0; } diff --git a/Tests/FindGTK2/gio/main.c b/Tests/FindGTK2/gio/main.c index 13f4304..ebed1fc 100644 --- a/Tests/FindGTK2/gio/main.c +++ b/Tests/FindGTK2/gio/main.c @@ -1,8 +1,8 @@ #include <gio/gio.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - GFile *file = g_file_new_for_path("path"); - g_object_unref(file); - return 0; + GFile* file = g_file_new_for_path("path"); + g_object_unref(file); + return 0; } diff --git a/Tests/FindGTK2/giomm/main.cpp b/Tests/FindGTK2/giomm/main.cpp index 8303ba9..c0d5975 100644 --- a/Tests/FindGTK2/giomm/main.cpp +++ b/Tests/FindGTK2/giomm/main.cpp @@ -1,7 +1,7 @@ #include <giomm.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - Glib::RefPtr<Gio::File> f = Gio::File::create_for_path("path"); - return 0; + Glib::RefPtr<Gio::File> f = Gio::File::create_for_path("path"); + return 0; } diff --git a/Tests/FindGTK2/glib/main.c b/Tests/FindGTK2/glib/main.c index 80d0554..cf5e458 100644 --- a/Tests/FindGTK2/glib/main.c +++ b/Tests/FindGTK2/glib/main.c @@ -1,11 +1,11 @@ #include <glib.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - if (!g_file_test("file", G_FILE_TEST_EXISTS)) { - g_print("File not found. \n"); - } else { - g_print("File found. \n"); - } - return 0; + if (!g_file_test("file", G_FILE_TEST_EXISTS)) { + g_print("File not found. \n"); + } else { + g_print("File found. \n"); + } + return 0; } diff --git a/Tests/FindGTK2/glibmm/main.cpp b/Tests/FindGTK2/glibmm/main.cpp index 0e8cdae..3cdc0bd 100644 --- a/Tests/FindGTK2/glibmm/main.cpp +++ b/Tests/FindGTK2/glibmm/main.cpp @@ -2,6 +2,6 @@ int main(int, char**) { - Glib::init(); - return 0; + Glib::init(); + return 0; } diff --git a/Tests/FindGTK2/gmodule/main.c b/Tests/FindGTK2/gmodule/main.c index 5c85a6f..1ac5c1d 100644 --- a/Tests/FindGTK2/gmodule/main.c +++ b/Tests/FindGTK2/gmodule/main.c @@ -1,7 +1,7 @@ #include <gmodule.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - gboolean b = g_module_supported(); - return 0; + gboolean b = g_module_supported(); + return 0; } diff --git a/Tests/FindGTK2/gobject/main.c b/Tests/FindGTK2/gobject/main.c index d3e13f9..46e2127 100644 --- a/Tests/FindGTK2/gobject/main.c +++ b/Tests/FindGTK2/gobject/main.c @@ -1,18 +1,21 @@ -/* Taken from https://developer.gnome.org/gobject/stable/chapter-gobject.html */ - +/* Taken from https://developer.gnome.org/gobject/stable/chapter-gobject.html + */ #include <glib-object.h> +#define MAMAN_TYPE_BAR (maman_bar_get_type()) +#define MAMAN_BAR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), MAMAN_TYPE_BAR, MamanBar)) +#define MAMAN_IS_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), MAMAN_TYPE_BAR)) +#define MAMAN_BAR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), MAMAN_TYPE_BAR, MamanBarClass)) +#define MAMAN_IS_BAR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), MAMAN_TYPE_BAR)) +#define MAMAN_BAR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), MAMAN_TYPE_BAR, MamanBarClass)) -#define MAMAN_TYPE_BAR (maman_bar_get_type ()) -#define MAMAN_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAMAN_TYPE_BAR, MamanBar)) -#define MAMAN_IS_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAMAN_TYPE_BAR)) -#define MAMAN_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAMAN_TYPE_BAR, MamanBarClass)) -#define MAMAN_IS_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAMAN_TYPE_BAR)) -#define MAMAN_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAMAN_TYPE_BAR, MamanBarClass)) - -typedef struct _MamanBar MamanBar; -typedef struct _MamanBarClass MamanBarClass; +typedef struct _MamanBar MamanBar; +typedef struct _MamanBarClass MamanBarClass; struct _MamanBar { @@ -29,18 +32,17 @@ struct _MamanBarClass }; /* will create maman_bar_get_type and set maman_bar_parent_class */ -G_DEFINE_TYPE (MamanBar, maman_bar, G_TYPE_OBJECT); +G_DEFINE_TYPE(MamanBar, maman_bar, G_TYPE_OBJECT); -static GObject * -maman_bar_constructor (GType gtype, - guint n_properties, - GObjectConstructParam *properties) +static GObject* maman_bar_constructor(GType gtype, guint n_properties, + GObjectConstructParam* properties) { - GObject *obj; + GObject* obj; { /* Always chain up to the parent constructor */ - obj = G_OBJECT_CLASS (maman_bar_parent_class)->constructor (gtype, n_properties, properties); + obj = G_OBJECT_CLASS(maman_bar_parent_class) + ->constructor(gtype, n_properties, properties); } /* update the object state depending on constructor properties */ @@ -48,25 +50,21 @@ maman_bar_constructor (GType gtype, return obj; } -static void -maman_bar_class_init (MamanBarClass *klass) +static void maman_bar_class_init(MamanBarClass* klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GObjectClass* gobject_class = G_OBJECT_CLASS(klass); gobject_class->constructor = maman_bar_constructor; } -static void -maman_bar_init (MamanBar *self) +static void maman_bar_init(MamanBar* self) { /* initialize the object */ } - -int -main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - MamanBar *bar = g_object_new (MAMAN_TYPE_BAR, NULL); - g_object_unref(bar); - return 0; + MamanBar* bar = g_object_new(MAMAN_TYPE_BAR, NULL); + g_object_unref(bar); + return 0; } diff --git a/Tests/FindGTK2/gthread/main.c b/Tests/FindGTK2/gthread/main.c index ce68cbd..9606401 100644 --- a/Tests/FindGTK2/gthread/main.c +++ b/Tests/FindGTK2/gthread/main.c @@ -1,7 +1,7 @@ #include <glib.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - g_thread_init(NULL); - return 0; + g_thread_init(NULL); + return 0; } diff --git a/Tests/FindGTK2/gtk/main.c b/Tests/FindGTK2/gtk/main.c index 309c328..010830a 100644 --- a/Tests/FindGTK2/gtk/main.c +++ b/Tests/FindGTK2/gtk/main.c @@ -1,15 +1,15 @@ #include <gtk/gtk.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - GtkWidget *window; + GtkWidget* window; - gtk_init (&argc, &argv); + gtk_init(&argc, &argv); - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_show (window); + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_widget_show(window); - gtk_main (); + gtk_main(); - return 0; + return 0; } diff --git a/Tests/FindGTK2/gtkmm/helloworld.cpp b/Tests/FindGTK2/gtkmm/helloworld.cpp index 535f44a..5f4e0ae 100644 --- a/Tests/FindGTK2/gtkmm/helloworld.cpp +++ b/Tests/FindGTK2/gtkmm/helloworld.cpp @@ -2,21 +2,21 @@ #include <iostream> HelloWorld::HelloWorld() - : m_button("Hello World") // creates a new button with label "Hello World". + : m_button("Hello World") // creates a new button with label "Hello World". { - // Sets the border width of the window. - set_border_width(10); + // Sets the border width of the window. + set_border_width(10); - // When the button receives the "clicked" signal, it will call the - // on_button_clicked() method defined below. - m_button.signal_clicked().connect(sigc::mem_fun(*this, - &HelloWorld::on_button_clicked)); + // When the button receives the "clicked" signal, it will call the + // on_button_clicked() method defined below. + m_button.signal_clicked().connect( + sigc::mem_fun(*this, &HelloWorld::on_button_clicked)); - // This packs the button into the Window (a container). - add(m_button); + // This packs the button into the Window (a container). + add(m_button); - // The final step is to display this newly created widget... - m_button.show(); + // The final step is to display this newly created widget... + m_button.show(); } HelloWorld::~HelloWorld() @@ -25,5 +25,5 @@ HelloWorld::~HelloWorld() void HelloWorld::on_button_clicked() { - std::cout << "Hello World" << std::endl; + std::cout << "Hello World" << std::endl; } diff --git a/Tests/FindGTK2/gtkmm/helloworld.h b/Tests/FindGTK2/gtkmm/helloworld.h index ab9a076..ae9af17 100644 --- a/Tests/FindGTK2/gtkmm/helloworld.h +++ b/Tests/FindGTK2/gtkmm/helloworld.h @@ -6,15 +6,15 @@ class HelloWorld : public Gtk::Window { public: - HelloWorld(); - virtual ~HelloWorld(); + HelloWorld(); + virtual ~HelloWorld(); protected: - //Signal handlers: - void on_button_clicked(); + // Signal handlers: + void on_button_clicked(); - //Member widgets: - Gtk::Button m_button; + // Member widgets: + Gtk::Button m_button; }; #endif // GTKMM_EXAMPLE_HELLOWORLD_H diff --git a/Tests/FindGTK2/gtkmm/main.cpp b/Tests/FindGTK2/gtkmm/main.cpp index 566a4bd..1637da2 100644 --- a/Tests/FindGTK2/gtkmm/main.cpp +++ b/Tests/FindGTK2/gtkmm/main.cpp @@ -1,13 +1,13 @@ #include "helloworld.h" #include <gtkmm.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - Gtk::Main kit(argc, argv); + Gtk::Main kit(argc, argv); - HelloWorld helloworld; - //Shows the window and returns when it is closed. - Gtk::Main::run(helloworld); + HelloWorld helloworld; + // Shows the window and returns when it is closed. + Gtk::Main::run(helloworld); - return 0; + return 0; } diff --git a/Tests/FindGTK2/pango/main.c b/Tests/FindGTK2/pango/main.c index ef87ce4..aa6ea92 100644 --- a/Tests/FindGTK2/pango/main.c +++ b/Tests/FindGTK2/pango/main.c @@ -1,7 +1,7 @@ #include <pango/pango.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - gboolean ret = pango_color_parse(NULL, "#ffffff"); - return 0; + gboolean ret = pango_color_parse(NULL, "#ffffff"); + return 0; } diff --git a/Tests/FindGTK2/pangocairo/main.c b/Tests/FindGTK2/pangocairo/main.c index 78268d6..15db513 100644 --- a/Tests/FindGTK2/pangocairo/main.c +++ b/Tests/FindGTK2/pangocairo/main.c @@ -1,72 +1,68 @@ -/* Taken from https://developer.gnome.org/pango/stable/pango-Cairo-Rendering.html */ - +/* Taken from + * https://developer.gnome.org/pango/stable/pango-Cairo-Rendering.html */ #include <math.h> #include <pango/pangocairo.h> -static void -draw_text (cairo_t *cr) +static void draw_text(cairo_t* cr) { #define RADIUS 150 #define N_WORDS 10 #define FONT "Sans Bold 27" - PangoLayout *layout; - PangoFontDescription *desc; + PangoLayout* layout; + PangoFontDescription* desc; int i; /* Center coordinates on the middle of the region we are drawing */ - cairo_translate (cr, RADIUS, RADIUS); + cairo_translate(cr, RADIUS, RADIUS); /* Create a PangoLayout, set the font and text */ - layout = pango_cairo_create_layout (cr); - pango_layout_set_text (layout, "Text", -1); - desc = pango_font_description_from_string (FONT); - pango_layout_set_font_description (layout, desc); - pango_font_description_free (desc); + layout = pango_cairo_create_layout(cr); + pango_layout_set_text(layout, "Text", -1); + desc = pango_font_description_from_string(FONT); + pango_layout_set_font_description(layout, desc); + pango_font_description_free(desc); /* Draw the layout N_WORDS times in a circle */ - for (i = 0; i < N_WORDS; i++) - { - int width, height; - double angle = (360. * i) / N_WORDS; - double red; - cairo_save (cr); - /* Gradient from red at angle == 60 to blue at angle == 240 */ - red = (1 + cos ((angle - 60) * G_PI / 180.)) / 2; - cairo_set_source_rgb (cr, red, 0, 1.0 - red); - cairo_rotate (cr, angle * G_PI / 180.); - /* Inform Pango to re-layout the text with the new transformation */ - pango_cairo_update_layout (cr, layout); - pango_layout_get_size (layout, &width, &height); - cairo_move_to (cr, - ((double)width / PANGO_SCALE) / 2, - RADIUS); - pango_cairo_show_layout (cr, layout); - cairo_restore (cr); - } + for (i = 0; i < N_WORDS; i++) { + int width, height; + double angle = (360. * i) / N_WORDS; + double red; + cairo_save(cr); + /* Gradient from red at angle == 60 to blue at angle == 240 */ + red = (1 + cos((angle - 60) * G_PI / 180.)) / 2; + cairo_set_source_rgb(cr, red, 0, 1.0 - red); + cairo_rotate(cr, angle * G_PI / 180.); + /* Inform Pango to re-layout the text with the new transformation */ + pango_cairo_update_layout(cr, layout); + pango_layout_get_size(layout, &width, &height); + cairo_move_to(cr, -((double)width / PANGO_SCALE) / 2, -RADIUS); + pango_cairo_show_layout(cr, layout); + cairo_restore(cr); + } /* free the layout object */ - g_object_unref (layout); + g_object_unref(layout); } -int main (int argc, char **argv) +int main(int argc, char** argv) { - cairo_t *cr; - char *filename; + cairo_t* cr; + char* filename; cairo_status_t status; - cairo_surface_t *surface; - if (argc != 2) - { - g_printerr ("Usage: cairosimple OUTPUT_FILENAME\n"); - return 1; - } + cairo_surface_t* surface; + if (argc != 2) { + g_printerr("Usage: cairosimple OUTPUT_FILENAME\n"); + return 1; + } filename = argv[1]; - surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, - 2 * RADIUS, 2 * RADIUS); - cr = cairo_create (surface); - cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); - cairo_paint (cr); - draw_text (cr); - cairo_destroy (cr); - status = cairo_surface_write_to_png (surface, filename); - cairo_surface_destroy (surface); - if (status != CAIRO_STATUS_SUCCESS) - { - g_printerr ("Could not save png to '%s'\n", filename); - return 1; - } + surface = + cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 2 * RADIUS, 2 * RADIUS); + cr = cairo_create(surface); + cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); + cairo_paint(cr); + draw_text(cr); + cairo_destroy(cr); + status = cairo_surface_write_to_png(surface, filename); + cairo_surface_destroy(surface); + if (status != CAIRO_STATUS_SUCCESS) { + g_printerr("Could not save png to '%s'\n", filename); + return 1; + } return 0; } diff --git a/Tests/FindGTK2/pangoft2/main.c b/Tests/FindGTK2/pangoft2/main.c index cf3459e..317f7ec 100644 --- a/Tests/FindGTK2/pangoft2/main.c +++ b/Tests/FindGTK2/pangoft2/main.c @@ -1,8 +1,8 @@ #include <pango/pangoft2.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - PangoFontMap* pfm = pango_ft2_font_map_new(); - g_object_unref(pfm); - return 0; + PangoFontMap* pfm = pango_ft2_font_map_new(); + g_object_unref(pfm); + return 0; } diff --git a/Tests/FindGTK2/pangomm/main.cpp b/Tests/FindGTK2/pangomm/main.cpp index 32ec914..47bf490 100644 --- a/Tests/FindGTK2/pangomm/main.cpp +++ b/Tests/FindGTK2/pangomm/main.cpp @@ -1,8 +1,8 @@ #include <pangomm.h> #include <pangomm/init.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - Pango::init(); - return 0; + Pango::init(); + return 0; } diff --git a/Tests/FindGTK2/pangoxft/main.c b/Tests/FindGTK2/pangoxft/main.c index cb04f61..181ba27 100644 --- a/Tests/FindGTK2/pangoxft/main.c +++ b/Tests/FindGTK2/pangoxft/main.c @@ -1,7 +1,7 @@ #include <pango/pangoxft.h> -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - pango_xft_get_context(NULL, 0); - return 0; + pango_xft_get_context(NULL, 0); + return 0; } diff --git a/Tests/FindGTK2/sigc++/main.cpp b/Tests/FindGTK2/sigc++/main.cpp index ccf415e..e56b910 100644 --- a/Tests/FindGTK2/sigc++/main.cpp +++ b/Tests/FindGTK2/sigc++/main.cpp @@ -6,24 +6,24 @@ class AlienDetector { public: - AlienDetector() {} + AlienDetector() {} - void run() {} + void run() {} - sigc::signal<void> signal_detected; + sigc::signal<void> signal_detected; }; void warn_people() { - std::cout << "There are aliens in the carpark!" << std::endl; + std::cout << "There are aliens in the carpark!" << std::endl; } int main() { - AlienDetector mydetector; - mydetector.signal_detected.connect( sigc::ptr_fun(warn_people) ); + AlienDetector mydetector; + mydetector.signal_detected.connect(sigc::ptr_fun(warn_people)); - mydetector.run(); + mydetector.run(); - return 0; + return 0; } |