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
MessageDialogTest.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 "MessageDialog.H"
24 
25 static void run(void *wid, gpointer data) {
26  GtkWidget *win=(GtkWidget*)data;
27 {MessageInfo messageInfo(win, (char *)"info");
28 messageInfo.title((char *)"this is the title");
29 messageInfo.run();}
30 {MessageError messageError(win, (char *)"Error");
31 messageError.run();}
32 {MessageQuestion messageQuestion(win, (char *)"Question");
33 messageQuestion.run();}
34 {
35 string txt("Warning");
36 MessageWarning messageWarning(win, txt);
37 messageWarning.run();}
38  gtk_main_quit();
39 }
40 
41 static void runPango(void *wid, gpointer data) {
42  GtkWidget *win=(GtkWidget*)data;
43  Pango pango; pango<< Font((char *)"Sans 12") << ColourLineSpec((char *)"r") <<(char *) " Sans font size 12 text"<<Font((char *)"")<<(char *)" and this is not formatted";
44 MessageInfo messageInfo(win, pango);
45 messageInfo.title((char *)"this is the title");
46 messageInfo.run();
47  gtk_main_quit();
48 }
49 
50 int main(int argc, char *argv[]) {
51 
52  gtk_init( &argc, &argv ); // init GTK
53 
54  GtkInterface topWindow; // Create the top box
55 
56  Buttons buttons;
57  HBox hBox;
58 
59  //Pango pango; pango<<"this is the message";
60 
61  //messageDialog<<pango;
62  //MessageDialog messageDialog("text");
63 // messageDialog.show();
64 
65 //cout<<"here"<<endl;
66 // topWindow<< messageDialog;
67 buttons<<BUTTONLABELSTRUCT((char *)"Run", run, topWindow.getWidget())<<BUTTONLABELSTRUCT((char *)"Run with Pango", runPango, topWindow.getWidget());
68  hBox<<buttons;
69  hBox.show();
70  topWindow<<hBox;
71  gtk_main();
72 }
73 
74 // setup the possible plot colours ...
75 int ColourLineSpec::colourCnt=10; // match this number with the number of colours below
76 const char *ColourLineSpec::shortColours[]= {(char *)"y",(char *)"m",(char *)"c",(char *)"r",(char *)"g",(char *)"b",(char *)"w",(char *)"k",(char *)"o",(char *)"a"}; // standard colours
77 const char *ColourLineSpec::X11Colours[]= {(char *)"yellow", (char *)"magenta", (char *)"cyan", (char *)"red", (char *)"green", (char *)"blue", (char *)"white", (char *)"black", (char *)"orange", (char *)"gray"};