GTK+ IOStream  Beta
<< GTK+ >> add C++ IOStream operators to GTK+. Now with extra abilities ... like network serialisation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CairoArrowTest.C
Go to the documentation of this file.
1 /* Copyright 2000-2013 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16  */
17 /* Compile with ...
18 g++ -ggdb `gtk-config --cflags` ButtonsTest.C -o ButtonsTest `gtk-config --libs`
19 `pkg-config --cflags --libs gtk+-2.0`
20 */
21 #include "gtkInterface.H"
22 #include "Buttons.H"
23 #include "Box.H"
24 #include "Pixmap.H"
25 
26 #include "CairoArrow.H"
27 
28 static void quit(void *wid, gpointer data){
29  gtk_main_quit();
30 }
31 
32 static void drawArrow(void *wid, gpointer data){
33  // create a cairo context from the pixmap and setup the line width/colour
34  Pixmap *pixmap=static_cast<Pixmap *>(data);
35  cairo_t *cr=gdk_cairo_create(pixmap->getPixmap());
36  cairo_set_source_rgb(cr, 1.,1.,1.);
37  cairo_set_line_width (cr, 3.);
38 
39  // now draw three arrows - one of each type
40  CairoArrow ca;
41  ca.draw(cr, 10, 150, 550, 100, .2, 20, 0, 1);
42  ca.draw(cr, 250, 380, 200, 200, .2, 20, 0, 0);
43  ca.draw(cr, 550, 200, 350, 350, .2, 20, 1, 0);
44 
45  // destroy the cairo context and redraw the widget
46  cairo_destroy(cr);
47  gtk_widget_queue_draw(pixmap->getWidget());
48 }
49 
50 int main(int argc, char *argv[]){
51 
52  gtk_init( &argc, &argv );
53 
54  VBox vBox;
55  Buttons buttons;
56 
57  Pixmap pixmap(600,400);
58 
59  buttons<<BUTTONLABELSTRUCT("Quit", quit, &buttons)<<BUTTONLABELSTRUCT("draw arrow", drawArrow, &pixmap);
60 
61  GtkInterface topWindow(640,480);
62  topWindow<<(VBox()<<pixmap.getWidget()<<buttons).show();
63  gtk_main();
64 }