1 /* GAIL - The GNOME Accessibility Implementation Library
2 * Copyright 2001 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
23 #include "gailhtmlbox.h"
24 #include "gailhtmlview.h"
25 #include <libgtkhtml/layout/htmlbox.h>
27 static void gail_html_box_class_init (GailHtmlBoxClass *klass);
28 static void gail_html_box_initialize (AtkObject *obj,
30 static gint gail_html_box_get_index_in_parent (AtkObject *obj);
31 static AtkStateSet* gail_html_box_ref_state_set (AtkObject *obj);
33 static void gail_html_box_component_interface_init (AtkComponentIface *iface);
34 static guint gail_html_box_add_focus_handler (AtkComponent *component,
35 AtkFocusHandler handler);
36 static void gail_html_box_get_extents (AtkComponent *component,
41 AtkCoordType coord_type);
42 static gboolean gail_html_box_grab_focus (AtkComponent *component);
43 static void gail_html_box_remove_focus_handler (AtkComponent *component,
46 G_DEFINE_TYPE_WITH_CODE (GailHtmlBox, gail_html_box, ATK_TYPE_GOBJECT,
47 G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, gail_html_box_component_interface_init))
50 gail_html_box_class_init (GailHtmlBoxClass *klass)
52 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
54 class->get_index_in_parent = gail_html_box_get_index_in_parent;
55 class->ref_state_set = gail_html_box_ref_state_set;
56 class->initialize = gail_html_box_initialize;
60 gail_html_box_new (GObject *obj)
63 AtkObject *atk_object;
65 g_return_val_if_fail (HTML_IS_BOX (obj), NULL);
66 object = g_object_new (GAIL_TYPE_HTML_BOX, NULL);
67 atk_object = ATK_OBJECT (object);
68 atk_object_initialize (atk_object, obj);
69 atk_object->role = ATK_ROLE_UNKNOWN;
74 gail_html_box_initialize (AtkObject *obj,
78 ATK_OBJECT_CLASS (gail_html_box_parent_class)->initialize (obj, data);
80 box = HTML_BOX (data);
83 * We do not set the parent here for the root node of a HtmlView
87 atk_object_set_parent (obj,
88 atk_gobject_get_accessible (G_OBJECT (box->parent)));
93 gail_html_box_get_index_in_parent (AtkObject *obj)
102 g_return_val_if_fail (GAIL_IS_HTML_BOX (obj), -1);
104 atk_gobj = ATK_GOBJECT (obj);
105 g_obj = atk_gobject_get_object (atk_gobj);
109 g_return_val_if_fail (HTML_IS_BOX (g_obj), -1);
110 box = HTML_BOX (g_obj);
111 parent = atk_object_get_parent (obj);
112 if (GAIL_IS_HTML_VIEW (parent))
116 else if (ATK_IS_GOBJECT (parent))
118 parent_box = HTML_BOX (atk_gobject_get_object (ATK_GOBJECT (parent)));
122 g_assert_not_reached ();
130 child = parent_box->children;
145 gail_html_box_ref_state_set (AtkObject *obj)
147 AtkGObject *atk_gobj;
149 AtkStateSet *state_set;
151 g_return_val_if_fail (GAIL_IS_HTML_BOX (obj), NULL);
152 atk_gobj = ATK_GOBJECT (obj);
153 state_set = ATK_OBJECT_CLASS (gail_html_box_parent_class)->ref_state_set (obj);
155 g_obj = atk_gobject_get_object (atk_gobj);
158 /* Object is defunct */
159 atk_state_set_add_state (state_set, ATK_STATE_DEFUNCT);
165 box = HTML_BOX (g_obj);
167 if (HTML_BOX_GET_STYLE (box)->display != HTML_DISPLAY_NONE)
169 atk_state_set_add_state (state_set, ATK_STATE_VISIBLE);
170 atk_state_set_add_state (state_set, ATK_STATE_SHOWING);
177 gail_html_box_component_interface_init (AtkComponentIface *iface)
180 * Use default implementation for contains and get_position
182 iface->contains = NULL;
183 iface->get_position = NULL;
184 iface->add_focus_handler = gail_html_box_add_focus_handler;
185 iface->get_extents = gail_html_box_get_extents;
186 iface->get_size = NULL;
187 iface->grab_focus = gail_html_box_grab_focus;
188 iface->remove_focus_handler = gail_html_box_remove_focus_handler;
189 iface->set_extents = NULL;
190 iface->set_position = NULL;
191 iface->set_size = NULL;
195 gail_html_box_add_focus_handler (AtkComponent *component,
196 AtkFocusHandler handler)
198 return g_signal_connect_closure (component,
201 G_CALLBACK (handler), NULL,
202 (GClosureNotify) NULL),
207 gail_html_box_get_extents (AtkComponent *component,
212 AtkCoordType coord_type)
214 AtkGObject *atk_gobj;
218 g_return_if_fail (GAIL_IS_HTML_BOX (component));
220 atk_gobj = ATK_GOBJECT (component);
221 g_obj = atk_gobject_get_object (atk_gobj);
225 g_return_if_fail (HTML_IS_BOX (g_obj));
226 box = HTML_BOX (g_obj);
228 *x = html_box_get_absolute_x (box);
229 *y = html_box_get_absolute_y (box);
231 *height = box->height;
233 g_print ("%d %d %d %d\n",
234 html_box_get_absolute_x (box),
235 html_box_get_absolute_y (box),
236 html_box_get_containing_block_width (box),
237 html_box_get_containing_block_height (box));
241 gail_html_box_grab_focus (AtkComponent *component)
247 gail_html_box_remove_focus_handler (AtkComponent *component,
250 g_signal_handler_disconnect (ATK_OBJECT (component), handler_id);