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
PangoTest2.C
Go to the documentation of this file.
1 /* Copyright 2000-2012 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` PangoTest.C -o PangoTest `gtk-config --libs`
19 */
20 #include "gtkInterface.H"
21 #include "Buttons.H"
22 #include "Labels.H"
23 #include "Pango.H"
24 #include "ColourLineSpec.H"
25 
26 static void quit(void *wid, gpointer data) {
27  gtk_main_quit();
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 a quit button
37  Labels labs; // create a labels list
38  Pango pango; // Create a Pango class for marking up the labels
39  HBox hBox; // create an HBox
40  VBox vBox; // create a VBox
41  vBox.start=true; // ensure packing is from the start
42 
43 
44  // try a pango type with only text, no other markup information
45  pango<<"text test"; // same label with different colours/sizes
46 
47  labs<<pango; // load a formatted label
48 
49  vBox << labs; // load the labels into a vertical box
50  hBox << vBox // load the vertically stacked labels into the horizontal box
51  << (buttons<<BUTTONLABELSTRUCT("Quit", quit, NULL)); // create and add the button to the HBox
52 
53  vBox.show(); // show the VBox
54  hBox.show(); // show the HBox
55  topWindow << hBox; // Load the HBox into the top window
56 
57  gtk_main(); // run GTK+
58 }
59 
60 // setup the possible plot colours ...
61 int ColourLineSpec::colourCnt=9; // this number matches with the number of colours below
62 const char *ColourLineSpec::shortColours[]= {(char *)"y",(char *)"m",(char *)"c",(char *)"r",(char *)"g",(char *)"b",(char *)"w",(char *)"k",(char *)"o"}; // standard colours
63 const char *ColourLineSpec::X11Colours[]= {(char *)"yellow", (char *)"magenta", (char *)"cyan", (char *)"red", (char *)"green", (char *)"blue", (char *)"white", (char *)"black", (char *)"orange"};