Back to index

lightning-sunbird  0.9+nobinonly
test_container.c
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* vim:expandtab:shiftwidth=4:tabstop=4:
00003  */
00004 #include <gtk/gtkmain.h>
00005 #include <gtk/gtkwindow.h>
00006 #include <gtk/gtkvscrollbar.h>
00007 #include <gtk/gtkbutton.h>
00008 #include <gtk/gtkcontainer.h>
00009 #include <gtk/gtksignal.h>
00010 #include <gdk/gdkwindow.h>
00011 
00012 #include "mozcontainer.h"
00013 #include "mozdrawingarea.h"
00014 
00015 #include <stdio.h>
00016 
00017 GtkWidget      *toplevel_window = NULL;
00018 GtkWidget      *moz_container   = NULL;
00019 MozDrawingarea *drawingarea1    = NULL;
00020 GtkWidget      *button          = NULL;
00021 GtkWidget      *scrollbar       = NULL;
00022 
00023 static gint
00024 expose_handler (GtkWidget *widget, GdkEventExpose *event);
00025 
00026 static void
00027 size_allocate_handler (GtkWidget *widget, GtkAllocation *allocation);
00028 
00029 int main(int argc, char **argv)
00030 {
00031   gtk_init(&argc, &argv);
00032 
00033   //  gdk_window_set_debug_updates(TRUE);
00034 
00035   toplevel_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
00036   printf("toplevel window is %p\n", toplevel_window);
00037 
00038   moz_container = moz_container_new();
00039   printf("moz_container is %p\n", moz_container);
00040   gtk_signal_connect(GTK_OBJECT(moz_container), "expose_event",
00041                      GTK_SIGNAL_FUNC(expose_handler), NULL);
00042   gtk_signal_connect(GTK_OBJECT(moz_container), "size_allocate",
00043                      GTK_SIGNAL_FUNC(size_allocate_handler), NULL);
00044 
00045   gtk_container_add(GTK_CONTAINER(toplevel_window),
00046                     moz_container);
00047 
00048   gtk_widget_realize(moz_container);
00049 
00050   drawingarea1 = moz_drawingarea_new (NULL, MOZ_CONTAINER(moz_container));
00051   moz_drawingarea_set_visibility (drawingarea1, TRUE);
00052   moz_drawingarea_move(drawingarea1, 10, 10);
00053 
00054   button = gtk_button_new_with_label("foo");
00055   scrollbar = gtk_vscrollbar_new(NULL);
00056 
00057   gtk_widget_set_parent_window(button, drawingarea1->inner_window);
00058   gtk_widget_set_parent_window(scrollbar, drawingarea1->inner_window);
00059 
00060   moz_container_put(MOZ_CONTAINER(moz_container), button, 0, 0);
00061   moz_container_put(MOZ_CONTAINER(moz_container), scrollbar, 0, 50);
00062 
00063   gtk_widget_show(button); 
00064   gtk_widget_show(scrollbar);
00065   gtk_widget_show(toplevel_window);
00066   gtk_widget_show(moz_container);
00067 
00068   gtk_main();
00069 
00070   return 0;
00071 }
00072 
00073 gint
00074 expose_handler (GtkWidget *widget, GdkEventExpose *event)
00075 {
00076   printf("expose %p %p %d %d %d %d\n",
00077          widget,
00078          event->window,
00079          event->area.x,
00080          event->area.y,
00081          event->area.width,
00082          event->area.height);
00083   return FALSE;
00084 }
00085 
00086 void
00087 size_allocate_handler (GtkWidget *widget, GtkAllocation *allocation)
00088 {
00089   printf("size_allocate_handler %p %d %d %d %d\n", widget,
00090          allocation->x, allocation->y, allocation->width, allocation->height);
00091   moz_drawingarea_resize(drawingarea1, allocation->width, allocation->height);
00092 }