PageRenderTime 17ms CodeModel.GetById 8ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/gtk/examples/gtk-demo/button_box.e

http://github.com/tybor/Liberty
Specman e | 154 lines | 21 code | 35 blank | 98 comment | 2 complexity | c1bc5673fb38e2b8e6fd87e5b1e70641 MD5 | raw file
  1indexing
  2	description: "."
  3	copyright: "[
  4					Copyright (C) 2006 Paolo Redaelli, GTK+ team
  5					
  6					This library is free software; you can redistribute it and/or
  7					modify it under the terms of the GNU Lesser General Public License
  8					as published by the Free Software Foundation; either version 2.1 of
  9					the License, or (at your option) any later version.
 10					
 11					This library is distributed in the hope that it will be useful, but
 12					WITHOUT ANY WARRANTY; without even the implied warranty of
 13					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14					Lesser General Public License for more details.
 15
 16					You should have received a copy of the GNU Lesser General Public
 17					License along with this library; if not, write to the Free Software
 18					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 19					02110-1301 USA
 20			]"
 21
 22class BUTTON_BOX
 23
 24creation make
 25
 26feature
 27-- /* Button Boxes
 28--  *
 29--  * The Button Box widgets are used to arrange buttons with padding.
 30--  */
 31
 32-- #include <gtk/gtk.h>
 33
 34-- static GtkWidget *
 35-- create_bbox (gint  horizontal,
 36-- 	     char *title, 
 37-- 	     gint  spacing,
 38-- 	     gint  layout)
 39-- {
 40--   GtkWidget *frame;
 41--   GtkWidget *bbox;
 42--   GtkWidget *button;
 43	
 44--   frame = gtk_frame_new (title);
 45
 46--   if (horizontal)
 47--     bbox = gtk_hbutton_box_new ();
 48--   else
 49--     bbox = gtk_vbutton_box_new ();
 50
 51--   gtk_container_set_border_width (GTK_CONTAINER (bbox), 5);
 52--   gtk_container_add (GTK_CONTAINER (frame), bbox);
 53
 54--   gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout);
 55--   gtk_box_set_spacing (GTK_BOX (bbox), spacing);
 56  
 57--   button = gtk_button_new_from_stock (GTK_STOCK_OK);
 58--   gtk_container_add (GTK_CONTAINER (bbox), button);
 59  
 60--   button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
 61--   gtk_container_add (GTK_CONTAINER (bbox), button);
 62  
 63--   button = gtk_button_new_from_stock (GTK_STOCK_HELP);
 64--   gtk_container_add (GTK_CONTAINER (bbox), button);
 65
 66--   return frame;
 67-- }
 68
 69-- GtkWidget *
 70-- do_button_box (GtkWidget *do_widget)
 71-- {
 72--   static GtkWidget *window = NULL;
 73--   GtkWidget *main_vbox;
 74--   GtkWidget *vbox;
 75--   GtkWidget *hbox;
 76--   GtkWidget *frame_horz;
 77--   GtkWidget *frame_vert;
 78	
 79--   if (!window)
 80--   {
 81--     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 82--     gtk_window_set_screen (GTK_WINDOW (window),
 83-- 			   gtk_widget_get_screen (do_widget));
 84--     gtk_window_set_title (GTK_WINDOW (window), "Button Boxes");
 85	
 86--     g_signal_connect (window, "destroy",
 87-- 		      G_CALLBACK (gtk_widget_destroyed),
 88-- 		      &window);
 89	
 90--     gtk_container_set_border_width (GTK_CONTAINER (window), 10);
 91
 92--     main_vbox = gtk_vbox_new (FALSE, 0);
 93--     gtk_container_add (GTK_CONTAINER (window), main_vbox);
 94	
 95--     frame_horz = gtk_frame_new ("Horizontal Button Boxes");
 96--     gtk_box_pack_start (GTK_BOX (main_vbox), frame_horz, TRUE, TRUE, 10);
 97	
 98--     vbox = gtk_vbox_new (FALSE, 0);
 99--     gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
100--     gtk_container_add (GTK_CONTAINER (frame_horz), vbox);
101
102--     gtk_box_pack_start (GTK_BOX (vbox), 
103-- 			create_bbox (TRUE, "Spread", 40, GTK_BUTTONBOX_SPREAD),
104-- 			TRUE, TRUE, 0);
105
106--     gtk_box_pack_start (GTK_BOX (vbox), 
107-- 			create_bbox (TRUE, "Edge", 40, GTK_BUTTONBOX_EDGE),
108-- 			TRUE, TRUE, 5);
109	
110--     gtk_box_pack_start (GTK_BOX (vbox), 
111-- 			create_bbox (TRUE, "Start", 40, GTK_BUTTONBOX_START),
112-- 			TRUE, TRUE, 5);
113	
114--     gtk_box_pack_start (GTK_BOX (vbox), 
115-- 			create_bbox (TRUE, "End", 40, GTK_BUTTONBOX_END),
116-- 			TRUE, TRUE, 5);
117
118--     frame_vert = gtk_frame_new ("Vertical Button Boxes");
119--     gtk_box_pack_start (GTK_BOX (main_vbox), frame_vert, TRUE, TRUE, 10);
120	
121--     hbox = gtk_hbox_new (FALSE, 0);
122--     gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
123--     gtk_container_add (GTK_CONTAINER (frame_vert), hbox);
124
125--     gtk_box_pack_start (GTK_BOX (hbox), 
126-- 			create_bbox (FALSE, "Spread", 30, GTK_BUTTONBOX_SPREAD),
127-- 			TRUE, TRUE, 0);
128
129--     gtk_box_pack_start (GTK_BOX (hbox), 
130-- 			create_bbox (FALSE, "Edge", 30, GTK_BUTTONBOX_EDGE),
131-- 			TRUE, TRUE, 5);
132
133--     gtk_box_pack_start (GTK_BOX (hbox), 
134-- 			create_bbox (FALSE, "Start", 30, GTK_BUTTONBOX_START),
135-- 			TRUE, TRUE, 5);
136
137--     gtk_box_pack_start (GTK_BOX (hbox), 
138-- 			create_bbox (FALSE, "End", 30, GTK_BUTTONBOX_END),
139-- 			TRUE, TRUE, 5);
140--   }
141
142--   if (!GTK_WIDGET_VISIBLE (window))
143--     {
144--       gtk_widget_show_all (window);
145--     }
146--   else
147--     {	 
148--       gtk_widget_destroy (window);
149--       window = NULL;
150--     }
151
152--   return window;
153-- }
154end