[atk] Implement AtkTableCell



commit 1349b6330379191a825955fc8107079ec742bb68
Author: Mike Gorse <mgorse suse com>
Date:   Tue Apr 16 14:40:12 2013 -0500

    Implement AtkTableCell
    
    https://bugzilla.gnome.org/show_bug.cgi?id=651353

 atk/Makefile.am     |    2 +
 atk/atk.h           |    1 +
 atk/atknoopobject.c |    9 ++
 atk/atktablecell.c  |  246 +++++++++++++++++++++++++++++++++++++++++++++++++++
 atk/atktablecell.h  |   84 +++++++++++++++++
 5 files changed, 342 insertions(+), 0 deletions(-)
---
diff --git a/atk/Makefile.am b/atk/Makefile.am
index 1279ff0..3f5be61 100644
--- a/atk/Makefile.am
+++ b/atk/Makefile.am
@@ -54,6 +54,7 @@ atk_sources =         \
        atkstateset.c           \
        atkstreamablecontent.c  \
        atktable.c              \
+       atktablecell.c          \
        atktext.c               \
        atkutil.c               \
        atkmisc.c               \
@@ -92,6 +93,7 @@ atk_headers = \
         atkstateset.h          \
         atkstreamablecontent.h \
         atktable.h             \
+        atktablecell.h         \
         atktext.h              \
         atkutil.h              \
         atkmisc.h              \
diff --git a/atk/atk.h b/atk/atk.h
index 0febcf8..5af7b1e 100755
--- a/atk/atk.h
+++ b/atk/atk.h
@@ -47,6 +47,7 @@
 #include <atk/atkstateset.h>
 #include <atk/atkstreamablecontent.h>
 #include <atk/atktable.h>
+#include <atk/atktablecell.h>
 #include <atk/atktext.h>
 #include <atk/atkutil.h>
 #include <atk/atkmisc.h>
diff --git a/atk/atknoopobject.c b/atk/atknoopobject.c
index 6e670ff..5af3ae3 100644
--- a/atk/atknoopobject.c
+++ b/atk/atknoopobject.c
@@ -101,6 +101,13 @@ atk_no_op_object_get_type (void)
         NULL
     };
 
+    static const GInterfaceInfo atk_table_cell_info =
+    {
+        (GInterfaceInitFunc) NULL,
+        (GInterfaceFinalizeFunc) NULL,
+        NULL
+    };
+
     static const GInterfaceInfo atk_text_info =
     {
         (GInterfaceInitFunc) NULL,
@@ -150,6 +157,8 @@ atk_no_op_object_get_type (void)
                                  &atk_selection_info);
     g_type_add_interface_static (type, ATK_TYPE_TABLE,
                                  &atk_table_info);
+    g_type_add_interface_static (type, ATK_TYPE_TABLE_CELL,
+                                 &atk_table_cell_info);
     g_type_add_interface_static (type, ATK_TYPE_TEXT,
                                  &atk_text_info);
     g_type_add_interface_static (type, ATK_TYPE_HYPERTEXT,
diff --git a/atk/atktablecell.c b/atk/atktablecell.c
new file mode 100644
index 0000000..20baf1a
--- /dev/null
+++ b/atk/atktablecell.c
@@ -0,0 +1,246 @@
+/* ATK -  Accessibility Toolkit
+ * Copyright 2014 SUSE LLC.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "atktablecell.h"
+
+typedef AtkTableCellIface AtkTableCellInterface;
+G_DEFINE_INTERFACE (AtkTableCell, atk_table_cell, ATK_TYPE_OBJECT)
+
+static gboolean atk_table_cell_real_get_row_column_span (AtkTableCell *cell,
+                                                            gint         *row,
+                                                            gint         *column,
+                                                            gint         *row_span,
+                                                            gint         *column_span);
+
+static void
+atk_table_cell_default_init (AtkTableCellInterface *iface)
+{
+  iface->get_row_column_span = atk_table_cell_real_get_row_column_span;
+}
+
+/**
+ * atk_table_cell_get_column_span:
+ * @cell: a GObject instance that implements AtkTableCellIface
+ *
+ * Returns the number of columns occupied by this cell accessible.
+ *
+ * Returns: a gint representing the number of columns occupied by this cell,
+ * or 0 if the cell does not implement this method.
+ */
+gint
+atk_table_cell_get_column_span (AtkTableCell *cell)
+{
+  AtkTableCellIface *iface;
+
+  g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), 0);
+
+  iface = ATK_TABLE_CELL_GET_IFACE (cell);
+
+  if (iface->get_column_span)
+    return (iface->get_column_span) (cell);
+  else
+    return 0;
+}
+
+/**
+ * atk_table_cell_get_column_header_cells:
+ * @cell: a GObject instance that implements AtkTableCellIface
+ *
+ * Returns the column headers as an array of cell accessibles.
+ *
+ * Returns: (element-type AtkObject) (transfer full): a GPtrArray of AtkObjects
+ * representing the column header cells.
+ */
+GPtrArray *
+atk_table_cell_get_column_header_cells (AtkTableCell *cell)
+{
+  AtkTableCellIface *iface;
+
+  g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), NULL);
+
+  iface = ATK_TABLE_CELL_GET_IFACE (cell);
+
+  if (iface->get_column_header_cells)
+    return (iface->get_column_header_cells) (cell);
+  else
+    return NULL;
+}
+
+/**
+ * atk_table_cell_get_position:
+ * @cell: a GObject instance that implements AtkTableCellIface
+ * row: (out): the row of the given cell.
+ * column: (out): the column of the given cell.
+ *
+ * Retrieves the tabular position of this cell.
+ *
+ * Returns: TRUE if successful; FALSE otherwise.
+ */
+gboolean
+atk_table_cell_get_position (AtkTableCell *cell,
+                             gint         *row,
+                             gint         *column)
+{
+  AtkTableCellIface *iface;
+  gint tmp_row, tmp_column;
+  gint *real_row = (row ? row : &tmp_row);
+  gint *real_column = (column ? column : &tmp_column);
+
+  *real_row = -1;
+  *real_column = -1;
+
+  g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
+
+  iface = ATK_TABLE_CELL_GET_IFACE (cell);
+
+  if (iface->get_position)
+    return (iface->get_position) (cell, real_row, real_column);
+  else
+    return FALSE;
+}
+
+/**
+ * atk_table_cell_get_row_span:
+ * @cell: a GObject instance that implements AtkTableCellIface
+ *
+ * Returns the number of rows occupied by this cell accessible.
+ *
+ * Returns: a gint representing the number of rows occupied by this cell,
+ * or 0 if the cell does not implement this method.
+ */
+gint
+atk_table_cell_get_row_span (AtkTableCell *cell)
+{
+  AtkTableCellIface *iface;
+
+  g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), 0);
+
+  iface = ATK_TABLE_CELL_GET_IFACE (cell);
+
+  if (iface->get_row_span)
+    return (iface->get_row_span) (cell);
+  else
+    return 0;
+}
+
+/**
+ * atk_table_cell_get_row_header_cells:
+ * @cell: a GObject instance that implements AtkTableCellIface
+ *
+ * Returns the row headers as an array of cell accessibles.
+ *
+ * Returns: (element-type AtkObject) (transfer full): a GPtrArray of AtkObjects
+ * representing the row header cells.
+ */
+GPtrArray *
+atk_table_cell_get_row_header_cells (AtkTableCell *cell)
+{
+  AtkTableCellIface *iface;
+
+  g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), NULL);
+
+  iface = ATK_TABLE_CELL_GET_IFACE (cell);
+
+  if (iface->get_row_header_cells)
+    return (iface->get_row_header_cells) (cell);
+  else
+    return NULL;
+}
+
+/**
+ * atk_table_cell_get_row_column_span:
+ * @cell: a GObject instance that implements AtkTableCellIface
+ * @row: (out): the row index of the given cell.
+ * @column: (out): the column index of the given cell.
+ * @row_span: (out): the number of rows occupied by this cell.
+ * @column_span: (out): the number of columns occupied by this cell.
+ *
+ * Gets the row and column indexes and span of this cell accessible.
+ *
+ * Note: If the object does not implement this function, then, by default, atk
+ * will implement this function by calling get_row_span and get_column_span
+ * on the object.
+ *
+ * Returns: TRUE if successful; FALSE otherwise.
+ */
+gboolean
+atk_table_cell_get_row_column_span (AtkTableCell *cell,
+                                       gint *row,
+                                       gint *column,
+                                       gint *row_span,
+                                       gint *column_span)
+{
+  AtkTableCellIface *iface;
+  gint local_row = 0, local_column = 0;
+  gint local_row_span = 0, local_column_span = 0;
+  gint *real_row, *real_column;
+  gint *real_row_span, *real_column_span;
+
+  g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
+
+  real_row = (row ? row : &local_row);
+  real_column = (column ? column : &local_column);
+  real_row_span = (row_span ? row_span : &local_row_span);
+  real_column_span = (column_span ? column_span : &local_column_span);
+
+  iface = ATK_TABLE_CELL_GET_IFACE (cell);
+
+  if (iface->get_row_column_span)
+    return (iface->get_row_column_span) (cell, real_row, real_column,
+                                           real_row_span,
+                                           real_column_span);
+  else
+    return FALSE;
+}
+
+/**
+ * atk_table_cell_get_table:
+ * @cell: a GObject instance that implements AtkTableCellIface
+ *
+ * Returns a reference to the accessible of the containing table.
+ *
+ * Returns: (transfer full): the atk object for the containing table.
+ */
+AtkObject *
+atk_table_cell_get_table (AtkTableCell *cell)
+{
+  AtkTableCellIface *iface;
+
+  g_return_val_if_fail (ATK_IS_TABLE_CELL (cell), FALSE);
+
+  iface = ATK_TABLE_CELL_GET_IFACE (cell);
+
+  if (iface->get_table)
+    return (iface->get_table) (cell);
+  else
+    return NULL;
+}
+
+static gboolean
+atk_table_cell_real_get_row_column_span (AtkTableCell *cell,
+                                            gint         *row,
+                                            gint         *column,
+                                            gint         *row_span,
+                                            gint         *column_span)
+{
+  atk_table_cell_get_position (cell, row, column);
+  *row_span = atk_table_cell_get_row_span (cell);
+  *column_span = atk_table_cell_get_column_span (cell);
+  return (row != 0 && column != 0 && row_span > 0 && column_span > 0);
+}
diff --git a/atk/atktablecell.h b/atk/atktablecell.h
new file mode 100755
index 0000000..7926f9f
--- /dev/null
+++ b/atk/atktablecell.h
@@ -0,0 +1,84 @@
+/* ATK -  Accessibility Toolkit
+ * Copyright 2014 SUSE LLC.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if defined(ATK_DISABLE_SINGLE_INCLUDES) && !defined (__ATK_H_INSIDE__) && !defined (ATK_COMPILATION)
+#error "Only <atk/atk.h> can be included directly."
+#endif
+
+#ifndef __ATK_TABLE_CELL_H__
+#define __ATK_TABLE_CELL_H__
+
+#include <atk/atkobject.h>
+
+G_BEGIN_DECLS
+
+/*
+ * AtkTableCell gives access to the cells of a two-dimentional table.
+ */
+
+
+#define ATK_TYPE_TABLE_CELL                    (atk_table_cell_get_type ())
+#define ATK_IS_TABLE_CELL(obj)                 G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATK_TYPE_TABLE_CELL)
+#define ATK_TABLE_CELL(obj)                    G_TYPE_CHECK_INSTANCE_CAST ((obj), ATK_TYPE_TABLE_CELL, 
AtkTableCell)
+#define ATK_TABLE_CELL_GET_IFACE(obj)          (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ATK_TYPE_TABLE_CELL, 
AtkTableCellIface))
+
+#ifndef _TYPEDEF_ATK_TABLE_CELL_
+#define _TYPEDEF_ATK_TABLE_CELL_
+typedef struct _AtkTableCell AtkTableCell;
+#endif
+typedef struct _AtkTableCellIface AtkTableCellIface;
+
+struct _AtkTableCellIface
+{
+  GTypeInterface parent;
+
+  gint        (*get_column_span)       (AtkTableCell *cell);
+  GPtrArray * (*get_column_header_cells) (AtkTableCell *cell);
+  gboolean        (*get_position)            (AtkTableCell *cell,
+                                              gint         *row,
+                                              gint         *column);
+  gint        (*get_row_span)          (AtkTableCell *cell);
+GPtrArray *   (*get_row_header_cells)    (AtkTableCell *cell);
+  gboolean    (*get_row_column_span)  (AtkTableCell *cell,
+                                          gint         *row,
+                                          gint         *column,
+                                          gint         *row_span,
+                                          gint         *column_span);
+  AtkObject * (*get_table)               (AtkTableCell *cell);
+};
+
+GType atk_table_cell_get_type (void);
+
+gint        atk_table_cell_get_column_span       (AtkTableCell *cell);
+GPtrArray * atk_table_cell_get_column_header_cells (AtkTableCell *cell);
+gboolean     atk_table_cell_get_position           (AtkTableCell *cell,
+                                                    gint         *row,
+                                                    gint         *column);
+gint        atk_table_cell_get_row_span          (AtkTableCell *cell);
+GPtrArray * atk_table_cell_get_row_header_cells    (AtkTableCell *cell);
+gboolean    atk_table_cell_get_row_column_span  (AtkTableCell *cell,
+                                                    gint         *row,
+                                                    gint         *column,
+                                                    gint         *row_span,
+                                                    gint         *column_span);
+AtkObject * atk_table_cell_get_table               (AtkTableCell *cell);
+
+G_END_DECLS
+
+#endif /* __ATK_TABLE_CELL_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]