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_initialize (AtkObject *obj,
65 ATK_OBJECT_CLASS (gail_html_box_parent_class)->initialize (obj, data);
67 obj->role = ATK_ROLE_UNKNOWN;
69 box = HTML_BOX (data);
72 * We do not set the parent here for the root node of a HtmlView
76 atk_object_set_parent (obj,
77 atk_gobject_get_accessible (G_OBJECT (box->parent)));
82 gail_html_box_get_index_in_parent (AtkObject *obj)
91 g_return_val_if_fail (GAIL_IS_HTML_BOX (obj), -1);
93 atk_gobj = ATK_GOBJECT (obj);
94 g_obj = atk_gobject_get_object (atk_gobj);
98 g_return_val_if_fail (HTML_IS_BOX (g_obj), -1);
99 box = HTML_BOX (g_obj);
100 parent = atk_object_get_parent (obj);
101 if (GAIL_IS_HTML_VIEW (parent))
105 else if (ATK_IS_GOBJECT (parent))
107 parent_box = HTML_BOX (atk_gobject_get_object (ATK_GOBJECT (parent)));
111 g_assert_not_reached ();
119 child = parent_box->children;
134 gail_html_box_ref_state_set (AtkObject *obj)
136 AtkGObject *atk_gobj;
138 AtkStateSet *state_set;
140 g_return_val_if_fail (GAIL_IS_HTML_BOX (obj), NULL);
141 atk_gobj = ATK_GOBJECT (obj);
142 state_set = ATK_OBJECT_CLASS (gail_html_box_parent_class)->ref_state_set (obj);
144 g_obj = atk_gobject_get_object (atk_gobj);
147 /* Object is defunct */
148 atk_state_set_add_state (state_set, ATK_STATE_DEFUNCT);
154 box = HTML_BOX (g_obj);
156 if (HTML_BOX_GET_STYLE (box)->display != HTML_DISPLAY_NONE)
158 atk_state_set_add_state (state_set, ATK_STATE_VISIBLE);
159 atk_state_set_add_state (state_set, ATK_STATE_SHOWING);
166 gail_html_box_component_interface_init (AtkComponentIface *iface)
169 * Use default implementation for contains and get_position
171 iface->contains = NULL;
172 iface->get_position = NULL;
173 iface->add_focus_handler = gail_html_box_add_focus_handler;
174 iface->get_extents = gail_html_box_get_extents;
175 iface->get_size = NULL;
176 iface->grab_focus = gail_html_box_grab_focus;
177 iface->remove_focus_handler = gail_html_box_remove_focus_handler;
178 iface->set_extents = NULL;
179 iface->set_position = NULL;
180 iface->set_size = NULL;
184 gail_html_box_add_focus_handler (AtkComponent *component,
185 AtkFocusHandler handler)
187 return g_signal_connect_closure (component,
190 G_CALLBACK (handler), NULL,
191 (GClosureNotify) NULL),
196 gail_html_box_get_extents (AtkComponent *component,
201 AtkCoordType coord_type)
203 AtkGObject *atk_gobj;
207 g_return_if_fail (GAIL_IS_HTML_BOX (component));
209 atk_gobj = ATK_GOBJECT (component);
210 g_obj = atk_gobject_get_object (atk_gobj);
214 g_return_if_fail (HTML_IS_BOX (g_obj));
215 box = HTML_BOX (g_obj);
217 *x = html_box_get_absolute_x (box);
218 *y = html_box_get_absolute_y (box);
220 *height = box->height;
222 g_print ("%d %d %d %d\n",
223 html_box_get_absolute_x (box),
224 html_box_get_absolute_y (box),
225 html_box_get_containing_block_width (box),
226 html_box_get_containing_block_height (box));
230 gail_html_box_grab_focus (AtkComponent *component)
236 gail_html_box_remove_focus_handler (AtkComponent *component,
239 g_signal_handler_disconnect (ATK_OBJECT (component), handler_id);