⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atktext.c

📁 The ATK library provides a set of interfaces for accessibility.By supporting the ATK interfaces, an
💻 C
📖 第 1 页 / 共 3 页
字号:
/* ATK - The Accessibility Toolkit for GTK+ * Copyright 2001 Sun Microsystems Inc. * * 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. */#include "atktext.h"#include "atkmarshal.h"#include "atk-enum-types.h"#include <string.h>static GPtrArray *extra_attributes = NULL;enum {  TEXT_CHANGED,  TEXT_CARET_MOVED,  TEXT_SELECTION_CHANGED,  TEXT_ATTRIBUTES_CHANGED,  LAST_SIGNAL};static const char boolean[] =  "false\0"  "true";static const guint8 boolean_offsets[] = {  0, 6};static const char style[] =  "normal\0"  "oblique\0"  "italic";static const guint8 style_offsets[] = {  0, 7, 15};static const char variant[] =  "normal\0"  "small_caps";static const guint8 variant_offsets[] = {  0, 7};static const char stretch[] =  "ultra_condensed\0"  "extra_condensed\0"  "condensed\0"  "semi_condensed\0"  "normal\0"  "semi_expanded\0"  "expanded\0"  "extra_expanded\0"  "ultra_expanded";static const guint8 stretch_offsets[] = {  0, 16, 32, 42, 57, 64, 78, 87, 102};static const char justification[] =  "left\0"  "right\0"  "center\0"  "fill";static const guint8 justification_offsets[] = {  0, 5, 11, 18};static const char direction[] =  "none\0"  "ltr\0"  "rtl";static const guint8 direction_offsets[] = {  0, 5, 9};static const char wrap_mode[] =  "none\0"  "char\0"  "word";static const guint8 wrap_mode_offsets[] = {  0, 5, 10};static const char underline[] =  "none\0"  "single\0"  "double\0"  "low";static const guint8 underline_offsets[] = {  0, 5, 12, 19};static void atk_text_base_init (AtkTextIface *class);static void atk_text_real_get_range_extents  (AtkText          *text,                                              gint             start_offset,                                              gint             end_offset,                                              AtkCoordType     coord_type,                                              AtkTextRectangle *rect);static AtkTextRange** atk_text_real_get_bounded_ranges (AtkText          *text,                                                        AtkTextRectangle *rect,                                                        AtkCoordType     coord_type,                                                        AtkTextClipType  x_clip_type,                                                        AtkTextClipType  y_clip_type);static guint atk_text_signals[LAST_SIGNAL] = { 0 };GTypeatk_text_get_type (void){  static GType type = 0;  if (!type)     {      static const GTypeInfo tinfo =      {        sizeof (AtkTextIface),        (GBaseInitFunc) atk_text_base_init,        (GBaseFinalizeFunc) NULL,        (GClassInitFunc) NULL /* atk_text_interface_init */ ,        (GClassFinalizeFunc) NULL,      };      type = g_type_register_static (G_TYPE_INTERFACE, "AtkText", &tinfo, 0);    }  return type;}static voidatk_text_base_init (AtkTextIface *class){  static gboolean initialized = FALSE;    if (! initialized)    {      /*        * Note that text_changed signal supports details "insert", "delete",        * possibly "replace".        */           class->get_range_extents = atk_text_real_get_range_extents;       class->get_bounded_ranges = atk_text_real_get_bounded_ranges;       atk_text_signals[TEXT_CHANGED] =	g_signal_new ("text_changed",		      ATK_TYPE_TEXT,		      G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,		      G_STRUCT_OFFSET (AtkTextIface, text_changed), 		      (GSignalAccumulator) NULL, NULL,		      atk_marshal_VOID__INT_INT,		      G_TYPE_NONE,		      2, G_TYPE_INT, G_TYPE_INT);            atk_text_signals[TEXT_CARET_MOVED] =	g_signal_new ("text_caret_moved",		      ATK_TYPE_TEXT,		      G_SIGNAL_RUN_LAST,		      G_STRUCT_OFFSET (AtkTextIface, text_caret_moved),		      (GSignalAccumulator) NULL, NULL,		      g_cclosure_marshal_VOID__INT,		      G_TYPE_NONE,		      1, G_TYPE_INT);      atk_text_signals[TEXT_SELECTION_CHANGED] =        g_signal_new ("text_selection_changed",                      ATK_TYPE_TEXT,                      G_SIGNAL_RUN_LAST,                      G_STRUCT_OFFSET (AtkTextIface, text_selection_changed),                      (GSignalAccumulator) NULL, NULL,                      g_cclosure_marshal_VOID__VOID,                      G_TYPE_NONE, 0);      atk_text_signals[TEXT_ATTRIBUTES_CHANGED] =        g_signal_new ("text_attributes_changed",                      ATK_TYPE_TEXT,                      G_SIGNAL_RUN_LAST,                      G_STRUCT_OFFSET (AtkTextIface, text_attributes_changed),                      (GSignalAccumulator) NULL, NULL,                      g_cclosure_marshal_VOID__VOID,                      G_TYPE_NONE, 0);            initialized = TRUE;    }}/** * atk_text_get_text: * @text: an #AtkText * @start_offset: start position * @end_offset: end position * * Gets the specified text. * * Returns: the text from @start_offset up to, but not including @end_offset. **/gchar*atk_text_get_text (AtkText      *text,                   gint         start_offset,                   gint         end_offset){  AtkTextIface *iface;    g_return_val_if_fail (ATK_IS_TEXT (text), NULL);  iface = ATK_TEXT_GET_IFACE (text);  if (start_offset < 0 || end_offset < -1)    return NULL;  if (iface->get_text)    return (*(iface->get_text)) (text, start_offset, end_offset);  else    return NULL;}/** * atk_text_get_character_at_offset: * @text: an #AtkText * @offset: position * * Gets the specified text. * * Returns: the character at @offset. **/gunicharatk_text_get_character_at_offset (AtkText      *text,                                  gint         offset){  AtkTextIface *iface;  g_return_val_if_fail (ATK_IS_TEXT (text), (gunichar) 0);  iface = ATK_TEXT_GET_IFACE (text);  if (iface->get_character_at_offset)    return (*(iface->get_character_at_offset)) (text, offset);  else    return (gunichar) 0;}/** * atk_text_get_text_after_offset: * @text: an #AtkText * @offset: position * @boundary_type: An #AtkTextBoundary * @start_offset: the start offset of the returned string * @end_offset: the offset of the first character after the  *              returned substring * * Gets the specified text. * * If the boundary_type if ATK_TEXT_BOUNDARY_CHAR the character after the  * offset is returned. * * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START the returned string * is from the word start after the offset to the next word start. * * The returned string will contain the word after the offset if the offset  * is inside a word or if the offset is not inside a word. * * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_END the returned string * is from the word end at or after the offset to the next work end. * * The returned string will contain the word after the offset if the offset * is inside a word and will contain the word after the word after the offset * if the offset is not inside a word. * * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the returned * string is from the sentence start after the offset to the next sentence * start. * * The returned string will contain the sentence after the offset if the offset * is inside a sentence or if the offset is not inside a sentence. * * If the boundary_type is ATK_TEXT_BOUNDARY_SENTENCE_END the returned string * is from the sentence end at or after the offset to the next sentence end. * * The returned string will contain the sentence after the offset if the offset * is inside a sentence and will contain the sentence after the sentence * after the offset if the offset is not inside a sentence. * * If the boundary type is ATK_TEXT_BOUNDARY_LINE_START the returned * string is from the line start after the offset to the next line start. * * If the boundary_type is ATK_TEXT_BOUNDARY_LINE_END the returned string * is from the line end at or after the offset to the next line start. * * Returns: the text after @offset bounded by the specified @boundary_type. **/gchar*atk_text_get_text_after_offset (AtkText          *text,                                gint             offset,                                AtkTextBoundary  boundary_type, 				gint             *start_offset,				gint		 *end_offset){  AtkTextIface *iface;  gint local_start_offset, local_end_offset;  gint *real_start_offset, *real_end_offset;  g_return_val_if_fail (ATK_IS_TEXT (text), NULL);  if (start_offset)    real_start_offset = start_offset;  else    real_start_offset = &local_start_offset;  if (end_offset)    real_end_offset = end_offset;  else    real_end_offset = &local_end_offset;  if (offset < 0)    return NULL;  iface = ATK_TEXT_GET_IFACE (text);  if (iface->get_text_after_offset)    return (*(iface->get_text_after_offset)) (text, offset, boundary_type, real_start_offset, real_end_offset);  else    return NULL;}/** * atk_text_get_text_at_offset: * @text: an #AtkText * @offset: position * @boundary_type: An #AtkTextBoundary * @start_offset: the start offset of the returned string * @end_offset: the offset of the first character after the  *              returned substring * * Gets the specified text. * * If the boundary_type if ATK_TEXT_BOUNDARY_CHAR the character at the * offset is returned. * * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START the returned string * is from the word start at or before the offset to the word start after  * the offset. * * The returned string will contain the word at the offset if the offset * is inside a word and will contain the word before the offset if the  * offset is not inside a word. * * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_END the returned string * is from the word end before the offset to the word end at or after the * offset. * * The returned string will contain the word at the offset if the offset * is inside a word and will contain the word after to the offset if the  * offset is not inside a word. * * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the returned * string is from the sentence start at or before the offset to the sentence * start after the offset. * * The returned string will contain the sentence at the offset if the offset * is inside a sentence and will contain the sentence before the offset  * if the offset is not inside a sentence. * * If the boundary_type is ATK_TEXT_BOUNDARY_SENTENCE_END the returned string * is from the sentence end before the offset to the sentence end at or * after the offset. * * The returned string will contain the sentence at the offset if the offset * is inside a sentence and will contain the sentence after the offset  * if the offset is not inside a sentence. * * If the boundary type is ATK_TEXT_BOUNDARY_LINE_START the returned * string is from the line start at or before the offset to the line * start after the offset. * * If the boundary_type is ATK_TEXT_BOUNDARY_LINE_END the returned string * is from the line end before the offset to the line end at or after * the offset. * * Returns: the text at @offset bounded by the specified @boundary_type. **/gchar*atk_text_get_text_at_offset (AtkText          *text,                             gint             offset,                             AtkTextBoundary  boundary_type,			     gint             *start_offset,			     gint             *end_offset){  AtkTextIface *iface;  gint local_start_offset, local_end_offset;  gint *real_start_offset, *real_end_offset;  g_return_val_if_fail (ATK_IS_TEXT (text), NULL);  if (start_offset)    real_start_offset = start_offset;  else    real_start_offset = &local_start_offset;  if (end_offset)    real_end_offset = end_offset;  else    real_end_offset = &local_end_offset;  iface = ATK_TEXT_GET_IFACE (text);  if (iface->get_text_at_offset)    return (*(iface->get_text_at_offset)) (text, offset, boundary_type, real_start_offset, real_end_offset);  else    return NULL;}/** * atk_text_get_text_before_offset: * @text: an #AtkText * @offset: position * @boundary_type: An #AtkTextBoundary * @start_offset: the start offset of the returned string * @end_offset: the offset of the first character after the  *              returned substring * * Gets the specified text. * * If the boundary_type if ATK_TEXT_BOUNDARY_CHAR the character before the * offset is returned. * * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START the returned string * is from the word start before the word start before the offset to  * the word start before the offset. * * The returned string will contain the word before the offset if the offset * is inside a word and will contain the word before the word before the  * offset if the offset is not inside a word. * * If the boundary_type is ATK_TEXT_BOUNDARY_WORD_END the returned string * is from the word end before the word end at or before the offset to the  * word end at or before the offset. * * The returned string will contain the word before the offset if the offset * is inside a word or if the offset is not inside a word. * * If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the returned * string is from the sentence start before the sentence start before  * the offset to the sentence start before the offset. * * The returned string will contain the sentence before the offset if the  * offset is inside a sentence and will contain the sentence before the 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -