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