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
ButtonsFontTest.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 "xpm/play.xpm"
24 #include "Pango.H"
25 
26 static void quit(void *wid, gpointer data){
27  gtk_main_quit();
28 }
29 
30 static void toggleButton(void *widget, gpointer data){
31  cout<<"ToggleButton "<<gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))<<endl;
32 }
33 static void playButton(void *widget, gpointer data){
34  cout<<"playButton "<<endl;
35 }
36 
37 int main(int argc, char *argv[]){
38 
39  gtk_init( &argc, &argv );
40 
41  GtkInterface topWindow;
42  Buttons buttons;
43  HBox hBox;
44 
45  buttons<<BUTTONLABELSTRUCT("Quit", quit, &buttons)<<BUTTONTOGGLESTRUCT("TOGGLE",toggleButton, 0) // normal and toggle buttons
46  <<BUTTONPIXMAPSTRUCTTRANSPARENT(playXPM, (void (*)(void*, void*))GTK_SIGNAL_FUNC(playButton), 0) // transparent pixmap button
47  <<BUTTONPIXMAPSTRUCT(playXPM, (void (*)(void*, void*))GTK_SIGNAL_FUNC(playButton), 0); // regular buttons are the same
48 
49  buttons<<BUTTONLABELSTRUCT("quit", quit, NULL);
50 
51  Font font("Sans 24");
52  buttons.setLabelsFont(font.getPangoFontDescription());
53 
54  hBox<<buttons; // Same as hBox<< buttons.grab(1)<< buttons.grab(2)<< buttons.grab(3)<< buttons.grab(4);
55  hBox.show();
56  topWindow<< hBox;
57 
58  gtk_main();
59 }