~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/widget/src/gtk2/test_container.c

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 
2
/* vim:expandtab:shiftwidth=4:tabstop=4:
 
3
 */
 
4
#include <gtk/gtkmain.h>
 
5
#include <gtk/gtkwindow.h>
 
6
#include <gtk/gtkvscrollbar.h>
 
7
#include <gtk/gtkbutton.h>
 
8
#include <gtk/gtkcontainer.h>
 
9
#include <gtk/gtksignal.h>
 
10
#include <gdk/gdkwindow.h>
 
11
 
 
12
#include "mozcontainer.h"
 
13
#include "mozdrawingarea.h"
 
14
 
 
15
#include <stdio.h>
 
16
 
 
17
GtkWidget      *toplevel_window = NULL;
 
18
GtkWidget      *moz_container   = NULL;
 
19
MozDrawingarea *drawingarea1    = NULL;
 
20
GtkWidget      *button          = NULL;
 
21
GtkWidget      *scrollbar       = NULL;
 
22
 
 
23
static gint
 
24
expose_handler (GtkWidget *widget, GdkEventExpose *event);
 
25
 
 
26
static void
 
27
size_allocate_handler (GtkWidget *widget, GtkAllocation *allocation);
 
28
 
 
29
int main(int argc, char **argv)
 
30
{
 
31
  gtk_init(&argc, &argv);
 
32
 
 
33
  //  gdk_window_set_debug_updates(TRUE);
 
34
 
 
35
  toplevel_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 
36
  printf("toplevel window is %p\n", toplevel_window);
 
37
 
 
38
  moz_container = moz_container_new();
 
39
  printf("moz_container is %p\n", moz_container);
 
40
  gtk_signal_connect(GTK_OBJECT(moz_container), "expose_event",
 
41
                     GTK_SIGNAL_FUNC(expose_handler), NULL);
 
42
  gtk_signal_connect(GTK_OBJECT(moz_container), "size_allocate",
 
43
                     GTK_SIGNAL_FUNC(size_allocate_handler), NULL);
 
44
 
 
45
  gtk_container_add(GTK_CONTAINER(toplevel_window),
 
46
                    moz_container);
 
47
 
 
48
  gtk_widget_realize(moz_container);
 
49
 
 
50
  drawingarea1 = moz_drawingarea_new (NULL, MOZ_CONTAINER(moz_container));
 
51
  moz_drawingarea_set_visibility (drawingarea1, TRUE);
 
52
  moz_drawingarea_move(drawingarea1, 10, 10);
 
53
 
 
54
  button = gtk_button_new_with_label("foo");
 
55
  scrollbar = gtk_vscrollbar_new(NULL);
 
56
 
 
57
  gtk_widget_set_parent_window(button, drawingarea1->inner_window);
 
58
  gtk_widget_set_parent_window(scrollbar, drawingarea1->inner_window);
 
59
 
 
60
  moz_container_put(MOZ_CONTAINER(moz_container), button, 0, 0);
 
61
  moz_container_put(MOZ_CONTAINER(moz_container), scrollbar, 0, 50);
 
62
 
 
63
  gtk_widget_show(button); 
 
64
  gtk_widget_show(scrollbar);
 
65
  gtk_widget_show(toplevel_window);
 
66
  gtk_widget_show(moz_container);
 
67
 
 
68
  gtk_main();
 
69
 
 
70
  return 0;
 
71
}
 
72
 
 
73
gint
 
74
expose_handler (GtkWidget *widget, GdkEventExpose *event)
 
75
{
 
76
  printf("expose %p %p %d %d %d %d\n",
 
77
         widget,
 
78
         event->window,
 
79
         event->area.x,
 
80
         event->area.y,
 
81
         event->area.width,
 
82
         event->area.height);
 
83
  return FALSE;
 
84
}
 
85
 
 
86
void
 
87
size_allocate_handler (GtkWidget *widget, GtkAllocation *allocation)
 
88
{
 
89
  printf("size_allocate_handler %p %d %d %d %d\n", widget,
 
90
         allocation->x, allocation->y, allocation->width, allocation->height);
 
91
  moz_drawingarea_resize(drawingarea1, allocation->width, allocation->height);
 
92
}