[Tomoe-cvs 1301] CVS update: libtomoe-gtk/src

アーカイブの一覧に戻る

Hiroyuki Ikezoe ikezo****@users*****
2006年 11月 28日 (火) 15:01:53 JST


Index: libtomoe-gtk/src/tomoe-char-table.c
diff -u libtomoe-gtk/src/tomoe-char-table.c:1.7 libtomoe-gtk/src/tomoe-char-table.c:1.8
--- libtomoe-gtk/src/tomoe-char-table.c:1.7	Mon Nov 27 16:20:53 2006
+++ libtomoe-gtk/src/tomoe-char-table.c	Tue Nov 28 15:01:53 2006
@@ -59,7 +59,7 @@
 
 static void   tomoe_char_table_scrollable_iface_init(TomoeScrollableIFace *iface);
 
-G_DEFINE_TYPE_EXTENDED (TomoeCharTable, tomoe_char_table, GTK_TYPE_DRAWING_AREA, 0,\
+G_DEFINE_TYPE_EXTENDED (TomoeCharTable, tomoe_char_table, GTK_TYPE_WIDGET, 0,\
                         G_IMPLEMENT_INTERFACE (TOMOE_TYPE_SCROLLABLE, tomoe_char_table_scrollable_iface_init))
 
 /* virtual functions for GtkObject class */
@@ -74,10 +74,11 @@
                                     GParamSpec           *pspec);
 
 /* virtual functions for GtkWidget class */
+static void   realize              (GtkWidget            *widget);
+static void   size_allocate        (GtkWidget            *widget,
+                                    GtkAllocation        *allocation);
 static void   size_request         (GtkWidget            *widget,
                                     GtkRequisition       *requisition);
-static gint   configure_event      (GtkWidget            *widget,
-                                    GdkEventConfigure    *event);
 static gint   expose_event         (GtkWidget            *widget,
                                     GdkEventExpose       *event);
 static gint   button_press_event   (GtkWidget            *widget,
@@ -140,8 +141,9 @@
     gobject_class->dispose             = dispose;
     gobject_class->set_property        = set_property;
     gobject_class->get_property        = get_property;
+    widget_class->realize              = realize;
+    widget_class->size_allocate        = size_allocate;
     widget_class->size_request         = size_request;
-    widget_class->configure_event      = configure_event;
     widget_class->expose_event         = expose_event;
     widget_class->button_press_event   = button_press_event;
     widget_class->button_release_event = button_release_event;
@@ -165,26 +167,7 @@
 static void
 tomoe_char_table_init (TomoeCharTable *view)
 {
-    GtkWidget *widget = GTK_WIDGET (view);
     TomoeCharTablePriv *priv = TOMOE_CHAR_TABLE_GET_PRIVATE (view);
-    PangoFontDescription *font_desc;
-    gint size;
-
-    gtk_widget_set_events (widget,
-                           GDK_EXPOSURE_MASK |
-                           GDK_ENTER_NOTIFY_MASK |
-                           GDK_LEAVE_NOTIFY_MASK |
-                           GDK_BUTTON_PRESS_MASK |
-                           GDK_BUTTON_RELEASE_MASK |
-                           GDK_POINTER_MOTION_MASK |
-                           GDK_POINTER_MOTION_HINT_MASK);
-
-    /* Set default font with large scale */
-    font_desc = pango_font_description_copy (widget->style->font_desc);
-    size = pango_font_description_get_size(font_desc);
-    pango_font_description_set_size(font_desc, size * PANGO_SCALE_XX_LARGE);
-    gtk_widget_modify_font (widget, font_desc);
-    pango_font_description_free (font_desc);
 
     priv->layout      = TOMOE_CHAR_TABLE_LAYOUT_SINGLE_HORIZONTAL;
     priv->canvas      = NULL;
@@ -259,6 +242,72 @@
 }
 
 static void
+realize (GtkWidget *widget)
+{
+    GdkWindowAttr attributes;
+    PangoFontDescription *font_desc;
+    gint size;
+
+    GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+
+    attributes.window_type = GDK_WINDOW_CHILD;
+    attributes.wclass = GDK_INPUT_OUTPUT;
+    attributes.visual = gtk_widget_get_visual (widget);
+    attributes.colormap = gtk_widget_get_colormap (widget);
+
+    attributes.x = widget->allocation.x;
+    attributes.y = widget->allocation.y;
+    attributes.width = widget->allocation.width;
+    attributes.height = widget->allocation.height;
+    attributes.event_mask = GDK_EXPOSURE_MASK |
+	    GDK_BUTTON_PRESS_MASK |
+	    GDK_BUTTON_RELEASE_MASK |
+	    GDK_POINTER_MOTION_MASK |
+	    GDK_POINTER_MOTION_HINT_MASK |
+	    GDK_ENTER_NOTIFY_MASK |
+	    GDK_LEAVE_NOTIFY_MASK;
+
+    widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
+		    &attributes,
+		    GDK_WA_X | GDK_WA_Y |
+		    GDK_WA_COLORMAP |
+		    GDK_WA_VISUAL);
+    gdk_window_set_user_data (widget->window, widget);
+    widget->style = gtk_style_attach (widget->style, widget->window);
+
+    gdk_window_set_background (widget->window, &widget->style->bg [GTK_STATE_NORMAL]);
+
+    /* Set default font with large scale */
+    font_desc = pango_font_description_copy (widget->style->font_desc);
+    size = pango_font_description_get_size(font_desc);
+    pango_font_description_set_size(font_desc, size * PANGO_SCALE_XX_LARGE);
+    gtk_widget_modify_font (widget, font_desc);
+    pango_font_description_free (font_desc);
+}
+
+static void
+size_allocate (GtkWidget *widget, GtkAllocation *allocation)
+{
+    TomoeCharTablePriv *priv = TOMOE_CHAR_TABLE_GET_PRIVATE (widget);
+
+    if (GTK_WIDGET_CLASS (tomoe_char_table_parent_class)->size_allocate)
+        GTK_WIDGET_CLASS (tomoe_char_table_parent_class)->size_allocate (widget, allocation);
+
+    if (GTK_WIDGET_REALIZED (widget)) {
+        if (priv->pixmap)
+            g_object_unref(priv->pixmap);
+
+        priv->pixmap = gdk_pixmap_new(widget->window,
+                                      allocation->width,
+                                      allocation->height,
+                                      -1);
+
+        adjust_adjustments (TOMOE_CHAR_TABLE (widget));
+        tomoe_char_table_draw (TOMOE_CHAR_TABLE (widget));
+    }
+}
+
+static void
 size_request (GtkWidget *widget, GtkRequisition *requisition)
 {
     TomoeCharTable *view = TOMOE_CHAR_TABLE (widget);
@@ -375,32 +424,6 @@
 }
 
 static gint
-configure_event (GtkWidget *widget,
-                 GdkEventConfigure *event)
-{
-    TomoeCharTable *view = TOMOE_CHAR_TABLE (widget);
-    TomoeCharTablePriv *priv = TOMOE_CHAR_TABLE_GET_PRIVATE (view);
-    gboolean retval = FALSE;
-
-    if (GTK_WIDGET_CLASS(tomoe_char_table_parent_class)->configure_event)
-        retval = GTK_WIDGET_CLASS(tomoe_char_table_parent_class)->configure_event (widget,
-                                                                                   event);
-
-    if (priv->pixmap)
-        g_object_unref(priv->pixmap);
-
-    priv->pixmap = gdk_pixmap_new(widget->window,
-                                  widget->allocation.width,
-                                  widget->allocation.height,
-                                  -1);
-
-    adjust_adjustments (view);
-    tomoe_char_table_draw (view);
-
-    return retval;
-}
-
-static gint
 expose_event (GtkWidget *widget, GdkEventExpose *event)
 {
     TomoeCharTable *view = TOMOE_CHAR_TABLE (widget);
Index: libtomoe-gtk/src/tomoe-char-table.h
diff -u libtomoe-gtk/src/tomoe-char-table.h:1.2 libtomoe-gtk/src/tomoe-char-table.h:1.3
--- libtomoe-gtk/src/tomoe-char-table.h:1.2	Thu Nov 16 15:01:34 2006
+++ libtomoe-gtk/src/tomoe-char-table.h	Tue Nov 28 15:01:53 2006
@@ -46,14 +46,12 @@
 
 struct _TomoeCharTable
 {
-    /* FIXME: migrate to GtkWidget */
-    GtkDrawingArea   parent_instance;
+    GtkWidget   parent_instance;
 };
 
 struct _TomoeCharTableClass
 {
-    /* FIXME: migrate to GtkWidget */
-    GtkDrawingAreaClass parent_class;
+    GtkWidgetClass parent_class;
 
     /* -- signals -- */
     void (*selected) (TomoeCharTable *view);


tomoe-cvs メーリングリストの案内
アーカイブの一覧に戻る