Change color using cairo instead of deprecated gdk functions
[darcs-mirror-screen-message.git] / gtkzoom.c
1 #include "gtkzoom.h"
2
3 struct _GtkZoomPrivate
4 {
5         int dummy;
6 //  GtkWidget *child;
7 };
8
9 static gboolean
10 gtk_zoom_draw      (GtkWidget      *widget,
11                                      cairo_t        *cr);
12 static void
13 gtk_zoom_size_allocate (GtkWidget     *widget, GtkAllocation *allocation);
14 static void
15 gtk_zoom_get_preferred_width (GtkWidget *widget,
16                                  gint      *minimum,
17                                  gint      *natural);
18 static void
19 gtk_zoom_get_preferred_height (GtkWidget *widget,
20                                  gint      *minimum,
21                                  gint      *natural);
22
23 G_DEFINE_TYPE (GtkZoom, gtk_zoom, GTK_TYPE_BIN)
24
25 static void
26 gtk_zoom_class_init (GtkZoomClass *class)
27 {
28   GtkWidgetClass *widget_class = (GtkWidgetClass*) class;
29
30   widget_class->draw          = gtk_zoom_draw;
31   widget_class->size_allocate = gtk_zoom_size_allocate;
32   widget_class->get_preferred_width = gtk_zoom_get_preferred_width;
33   widget_class->get_preferred_height = gtk_zoom_get_preferred_height;
34
35
36   g_type_class_add_private (class, sizeof (GtkZoomPrivate));
37 }
38
39 static void
40 gtk_zoom_init (GtkZoom *zoom)
41 {
42   GtkZoomPrivate *priv;
43
44   zoom->priv = G_TYPE_INSTANCE_GET_PRIVATE (zoom,
45                                            GTK_TYPE_ZOOM,
46                                            GtkZoomPrivate);
47   priv = zoom->priv;
48 }
49
50 GtkWidget*
51 gtk_zoom_new (void)
52 {
53   return g_object_new (GTK_TYPE_ZOOM, NULL);
54 }
55
56
57 static void
58 gtk_zoom_size_allocate (GtkWidget     *widget, GtkAllocation *allocation)
59 {
60   GtkWidget *main_widget;
61
62   GTK_WIDGET_CLASS (gtk_zoom_parent_class)->size_allocate (widget, allocation);
63
64   main_widget = gtk_bin_get_child (GTK_BIN (widget));
65   if (!main_widget || !gtk_widget_get_visible (main_widget))
66     return;
67
68   gtk_widget_size_allocate (main_widget, allocation);
69 }
70
71 static void
72 gtk_zoom_get_preferred_width (GtkWidget *widget,
73                                  gint      *minimum,
74                                  gint      *natural)
75 {
76   GtkBin *bin = GTK_BIN (widget);
77   GtkWidget *child;
78
79   if (minimum)
80     *minimum = 0;
81
82   if (natural)
83     *natural = 0;
84
85   child = gtk_bin_get_child (bin);
86   if (child && gtk_widget_get_visible (child))
87     gtk_widget_get_preferred_width (child, minimum, natural);
88 }
89
90 static void
91 gtk_zoom_get_preferred_height (GtkWidget *widget,
92                                   gint      *minimum,
93                                   gint      *natural)
94 {
95   GtkBin *bin = GTK_BIN (widget);
96   GtkWidget *child;
97
98   if (minimum)
99     *minimum = 0;
100
101   if (natural)
102     *natural = 0;
103
104   child = gtk_bin_get_child (bin);
105   if (child && gtk_widget_get_visible (child))
106     gtk_widget_get_preferred_height (child, minimum, natural);
107 }
108
109
110
111 static gboolean
112 gtk_zoom_draw (GtkWidget *widget, cairo_t   *cr)
113 {
114         GtkWidget *child;
115         child = gtk_bin_get_child (GTK_BIN(widget));
116         if (child) {
117                 cairo_save(cr);
118                 cairo_scale(cr, 2, 2);
119                 gtk_widget_draw(child, cr);
120                 cairo_restore(cr);
121         }
122
123         //GTK_WIDGET_CLASS (gtk_zoom_parent_class)->draw (widget, cr);
124
125         return FALSE;
126 }
127