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
TableTest.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 #include "gtkInterface.H"
18 #include "Table.H"
19 #include "Buttons.H"
20 #include "Labels.H"
21 
22 static void quit(void *wid, gpointer data){
23  gtk_main_quit();
24 }
25 
26 static void callback(void *wid, gpointer data){
27  cout<<((int*)data)[0]<<endl;
28 }
29 
30 int main(int argc, char *argv[]){
31 
32  gtk_init( &argc, &argv ); // init GTK
33 
34  GtkInterface topWindow; // Create the top box
35 
36  Buttons buttons; // create the buttons to show
37  buttons<<BUTTONLABELSTRUCT("1", callback, (int[1]){1})
38  <<BUTTONLABELSTRUCT("2", callback, (int[1]){2})
39  <<BUTTONLABELSTRUCT("3", callback, (int[1]){3})
40  <<BUTTONLABELSTRUCT("4", callback, (int[1]){4})
41  <<BUTTONLABELSTRUCT("5", callback, (int[1]){5})
42  <<BUTTONLABELSTRUCT("6", callback, (int[1]){6})
43  <<BUTTONLABELSTRUCT("7", callback, (int[1]){7})
44  <<BUTTONLABELSTRUCT("8", callback, (int[1]){8})
45  <<BUTTONLABELSTRUCT("Quit", quit, NULL);
46 
47  // add some buttons for the first table
48  Table table(2, 2); table.show();
49  table<<buttons.grab(1)<<buttons.grab(2)<<buttons.grab(3)<<buttons.grab(4);
50 
51  // example of a manually placed table
52  Table table2(2,2); table2.show();
53  table2.setOptions((GtkAttachOptions)(GTK_FILL|GTK_EXPAND), (GtkAttachOptions)(GTK_FILL|GTK_EXPAND));
54  table2<<(int[4]){0, 1, 1, 2}<<buttons.grab(5); // bottom left
55  table2<<(int[4]){1, 2, 0, 1}<<buttons.grab(6); // top right
56  table2<<(int[4]){0, 1, 0, 1}<<buttons.grab(7); // top left
57  table2<<(int[4]){1, 2, 1, 2}<<buttons.grab(8); // bottom right
58 
59  HBox hBox; // create an HBox
60 
61  // put the first table, then the quit button, then the second table into the HBox
62  hBox<< BoxIS(true,true, true)<<table.getWidget()<< BoxIS(false,false, true)<<buttons.grab(buttons.getCount())<< BoxIS(true,true, true)<<table2.getWidget();
63 
64  hBox.show(); // show the HBox
65  topWindow << hBox; // Load the HBox into the top window
66 
67  gtk_main(); // run GTK+
68 }