]> Pileus Git - ~andy/gtk/blob - examples/aspectframe/aspectframe.c
threads example from Erik Mouw. New question on GtkLabel background
[~andy/gtk] / examples / aspectframe / aspectframe.c
1 /* example-start aspectframe aspectframe.c */
2
3 #include <gtk/gtk.h>
4    
5 int main( int argc,
6           char *argv[] )
7 {
8     GtkWidget *window;
9     GtkWidget *aspect_frame;
10     GtkWidget *drawing_area;
11     gtk_init (&argc, &argv);
12    
13     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
14     gtk_window_set_title (GTK_WINDOW (window), "Aspect Frame");
15     gtk_signal_connect (GTK_OBJECT (window), "destroy",
16                         GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
17     gtk_container_set_border_width (GTK_CONTAINER (window), 10);
18    
19     /* Create an aspect_frame and add it to our toplevel window */
20    
21     aspect_frame = gtk_aspect_frame_new ("2x1", /* label */
22                                          0.5, /* center x */
23                                          0.5, /* center y */
24                                          2, /* xsize/ysize = 2 */
25                                          FALSE /* ignore child's aspect */);
26    
27     gtk_container_add (GTK_CONTAINER(window), aspect_frame);
28     gtk_widget_show (aspect_frame);
29    
30     /* Now add a child widget to the aspect frame */
31    
32     drawing_area = gtk_drawing_area_new ();
33    
34     /* Ask for a 200x200 window, but the AspectFrame will give us a 200x100
35      * window since we are forcing a 2x1 aspect ratio */
36     gtk_widget_set_usize (drawing_area, 200, 200);
37     gtk_container_add (GTK_CONTAINER(aspect_frame), drawing_area);
38     gtk_widget_show (drawing_area);
39    
40     gtk_widget_show (window);
41     gtk_main ();
42     return 0;
43 }
44 /* example-end */