summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Cameron <bcameron@src.gnome.org>2001-06-12 12:13:20 +0000
committerBrian Cameron <bcameron@src.gnome.org>2001-06-12 12:13:20 +0000
commitb686b7f2f0e8cb753d5e51edcf084969aff6341c (patch)
treef52902391d554d9dafec76575d95c97b1f8f0e50
parent5f8117526e078cdcf985be2985a572713a9e0c9a (diff)
downloadatk-b686b7f2f0e8cb753d5e51edcf084969aff6341c.tar.gz
The changes include:
- moved function atk_text_set_run_attributes() to atk_editable_text_set_run_attributes() - defined an enum AtkXYCoords in Atktext.h - moved definitions of AtkAttribute and AtkAttributeSet from atktext.h to atkobject.h (temporary solution until we decide a better place to define them). - Added extra param to atk_text_get_character_extents() and atk_text_get_offset_at_point() of type AtkXYCoords. I decided to make AtkAttributeSet a singly-linked list (a GSList) instead of a doubley-linked list (a GList). There is no need for it to be doubley-linked which is less efficient.
-rw-r--r--ChangeLog8
-rwxr-xr-xatk/atkeditabletext.c44
-rwxr-xr-xatk/atkeditabletext.h17
-rwxr-xr-xatk/atkobject.h10
-rwxr-xr-xatk/atktext.c57
-rwxr-xr-xatk/atktext.h37
6 files changed, 86 insertions, 87 deletions
diff --git a/ChangeLog b/ChangeLog
index f5508e2..3f0fc94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2001-06-12 Brian Cameron <brian.cameron@sun.com>
+
+ * atk/atkeditabletext.[ch], atk/atktext.[ch], atk/atkobject.h
+ Updated atkeditabletext and atktext interfaces so they
+ now properly define the get/set attribute methods and now
+ get_offset_at_point and get_character_extents can request
+ x,y coords by either widget or screen coords.
+
Sat Jun 9 15:17:00 2001 Owen Taylor <otaylor@redhat.com>
* configure.in (DEP_CFLAGS): Only include gthread-2.0 in
diff --git a/atk/atkeditabletext.c b/atk/atkeditabletext.c
index 228db16..2b2e0ad 100755
--- a/atk/atkeditabletext.c
+++ b/atk/atkeditabletext.c
@@ -48,35 +48,41 @@ atk_editable_text_get_type ()
}
/**
- * atk_editable_text_set_attributes:
- * @text: an #AtkEditableText
- * @start_pos: start position
- * @end_pos: end position
- * @attributes: a #PangoAttrList to set for text between @start_pos and @end_pos
+ *atk_editable_text_set_run_attributes:
+ *@text: an #AtkEditableText
+ *@attrib_set: an #AtkAttributeSet
+ *@start_offset: start of range in which to set attributes
+ *@end_offset: end of range in which to set attributes
*
- * Set attributes for text between @start_pos and @end_pos. The characters
- * whose attributes are set are those characters at positions from @start_pos
- * up to, but not including @end_pos. If @end_pos is negative, then the
- * characters selected will be those characters from start_pos to
- * the end of the text.
+ *Sets the attributes for a specified range
+ *
+ *Returns: %TRUE if attributes successfully set for the specified
+ *range, otherwise %FALSE
**/
-void
-atk_editable_text_set_attributes (AtkEditableText *text,
- gint start_pos,
- gint end_pos,
- PangoAttrList *attributes)
+gboolean
+atk_editable_text_set_run_attributes (AtkEditableText *text,
+ AtkAttributeSet *attrib_set,
+ gint start_offset,
+ gint end_offset)
{
AtkEditableTextIface *iface;
- g_return_if_fail (text != NULL);
- g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));
+ g_return_val_if_fail (text != NULL, FALSE);
+ g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (text), FALSE);
iface = ATK_EDITABLE_TEXT_GET_IFACE (text);
- if (iface->set_attributes)
- (*(iface->set_attributes)) (text, start_pos, end_pos, attributes);
+ if (iface->set_run_attributes)
+ {
+ return (*(iface->set_run_attributes)) (text, attrib_set, start_offset, end_offset);
+ }
+ else
+ {
+ return FALSE;
+ }
}
+
/**
* atk_editable_text_set_text_contents:
* @text: an #AtkEditableText
diff --git a/atk/atkeditabletext.h b/atk/atkeditabletext.h
index e4fd654..1341876 100755
--- a/atk/atkeditabletext.h
+++ b/atk/atkeditabletext.h
@@ -47,10 +47,10 @@ struct _AtkEditableTextIface
{
GTypeInterface parent_interface;
- void (* set_attributes) (AtkEditableText *text,
- gint start_pos,
- gint end_pos,
- PangoAttrList *attributes);
+ gboolean (* set_run_attributes) (AtkEditableText *text,
+ AtkAttributeSet *attrib_set,
+ gint start_offset,
+ gint end_offset);
void (* set_text_contents) (AtkEditableText *text,
const gchar *string);
void (* insert_text) (AtkEditableText *text,
@@ -71,10 +71,11 @@ struct _AtkEditableTextIface
};
GType atk_editable_text_get_type (void);
-void atk_editable_text_set_attributes (AtkEditableText *text,
- gint start_pos,
- gint end_pos,
- PangoAttrList *attributes);
+
+gboolean atk_editable_text_set_run_attributes (AtkEditableText *text,
+ AtkAttributeSet *attrib_set,
+ gint start_offset,
+ gint end_offset);
void atk_editable_text_set_text_contents (AtkEditableText *text,
const gchar *string);
void atk_editable_text_insert_text (AtkEditableText *text,
diff --git a/atk/atkobject.h b/atk/atkobject.h
index 7a09b69..dce5388 100755
--- a/atk/atkobject.h
+++ b/atk/atkobject.h
@@ -35,6 +35,16 @@ extern "C" {
* of the following interfaces:
*/
+/* AtkAttributeSet & AtkAttribute are needed by atktext and atkeditable text */
+/* so I am putting them here until a better place for them to be defined is */
+/* decided */
+typedef GSList AtkAttributeSet;
+
+typedef struct _AtkAttribute {
+ gchar* name;
+ gchar* value;
+}AtkAttribute;
+
/**
*AtkRole:
*@ATK_ROLE_INVALID: Invalid role
diff --git a/atk/atktext.c b/atk/atktext.c
index ef762bd..21bf70d 100755
--- a/atk/atktext.c
+++ b/atk/atktext.c
@@ -280,16 +280,17 @@ atk_text_get_caret_offset (AtkText *text)
}
/**
- * atk_text_get_character_extents
+ * atk_text_get_character_extents:
* @text: an #AtkText
* @offset: position
* @x: x-position of character
* @y: y-position of character
* @length: length of character
* @width: width of character
+ * @coords: specify whether coordinates are relative to the screen or widget window
*
* Given an @offset, the @x, @y, @length, and @width values are filled
- * appropriately.
+ * appropriately.
**/
void
atk_text_get_character_extents (AtkText *text,
@@ -297,7 +298,8 @@ atk_text_get_character_extents (AtkText *text,
gint *x,
gint *y,
gint *length,
- gint *width)
+ gint *width,
+ AtkXYCoords coords)
{
AtkTextIface *iface;
@@ -307,7 +309,7 @@ atk_text_get_character_extents (AtkText *text,
iface = ATK_TEXT_GET_IFACE (text);
if (iface->get_character_extents)
- (*(iface->get_character_extents)) (text, offset, x, y, length, width);
+ (*(iface->get_character_extents)) (text, offset, x, y, length, width, coords);
else
{
*x = 0;
@@ -375,12 +377,15 @@ atk_text_get_character_count (AtkText *text)
}
/**
- * atk_text_get_offset_at_point
+ * atk_text_get_offset_at_point:
* @text: an #AtkText
* @x: screen x-position of character
* @y: screen y-position of character
+ * @coords: specify whether coordinates are relative to the screen or widget window
*
- * Gets the x,y screen coordinates of the specified character.
+ * Gets the offset of the character located at coordinates @x and @y. @x and @y are
+ * interpreted as being relative to the screen or this widget's window depending
+ * on @coords.
*
* Returns: the offset to the character which is located at
* the specified @x and @y coordinates.
@@ -388,7 +393,8 @@ atk_text_get_character_count (AtkText *text)
gint
atk_text_get_offset_at_point (AtkText *text,
gint x,
- gint y)
+ gint y,
+ AtkXYCoords coords)
{
AtkTextIface *iface;
@@ -398,7 +404,7 @@ atk_text_get_offset_at_point (AtkText *text,
iface = ATK_TEXT_GET_IFACE (text);
if (iface->get_offset_at_point)
- return (*(iface->get_offset_at_point)) (text, x, y);
+ return (*(iface->get_offset_at_point)) (text, x, y, coords);
else
return -1;
}
@@ -555,41 +561,6 @@ atk_text_set_selection (AtkText *text, gint selection_num,
}
/**
- *atk_text_set_run_attributes:
- *@text: an #AtkText
- *@attrib: an #AtkAttributeSet
- *@start_offset: start of range in which to set attributes
- *@end_offset: end of range in which to set attributes
- *
- *Sets the attributes for a specified range
- *
- *Returns: %TRUE if attributes successfully set for the specified
- *range, otherwise %FALSE
- **/
-gboolean
-atk_text_set_run_attributes (AtkText *text,
- AtkAttributeSet *attrib,
- gint start_offset,
- gint end_offset)
-{
- AtkTextIface *iface;
-
- g_return_val_if_fail (text != NULL, FALSE);
- g_return_val_if_fail (ATK_IS_TEXT (text), FALSE);
-
- iface = ATK_TEXT_GET_IFACE (text);
-
- if (iface->set_run_attributes)
- {
- return (*(iface->set_run_attributes)) (text, attrib, start_offset, end_offset);
- }
- else
- {
- return FALSE;
- }
-}
-
-/**
* atk_text_set_caret_offset
* @text: an #AtkText
* @offset: position
diff --git a/atk/atktext.h b/atk/atktext.h
index 9f55658..30a2078 100755
--- a/atk/atktext.h
+++ b/atk/atktext.h
@@ -40,12 +40,19 @@ typedef struct _AtkText AtkText;
#endif
typedef struct _AtkTextIface AtkTextIface;
-typedef GList AtkAttributeSet;
-typedef struct _AtkAttribute {
- gchar* name;
- gchar* value;
-}AtkAttribute;
+/**
+ *AtkXYCoords:
+ *@ATK_XY_SCREEN: specifies xy coordinates relative to the screen
+ *@ATK_XY_WIDGET: specifies xy coordinates relative to the widgets window
+ *
+ *Specifies what type of coordinates are to be returned for functions that
+ *return position coordinates
+ **/
+typedef enum {
+ ATK_XY_SCREEN,
+ ATK_XY_WIDGET
+}AtkXYCoords;
/**
*AtkTextBoundary:
@@ -99,11 +106,13 @@ struct _AtkTextIface
gint *x,
gint *y,
gint *length,
- gint *width);
+ gint *width,
+ AtkXYCoords coords);
gint (* get_character_count) (AtkText *text);
gint (* get_offset_at_point) (AtkText *text,
gint x,
- gint y);
+ gint y,
+ AtkXYCoords coords);
gint (* get_n_selections) (AtkText *text);
gchar* (* get_selection) (AtkText *text,
gint selection_num,
@@ -120,10 +129,6 @@ struct _AtkTextIface
gint end_offset);
gboolean (* set_caret_offset) (AtkText *text,
gint offset);
- gboolean (* set_run_attributes) (AtkText *text,
- AtkAttributeSet *attrib,
- gint start_offset,
- gint end_offset);
void (* text_changed) (AtkText *text);
void (* caret_changed) (AtkText *text,
gint location);
@@ -158,7 +163,8 @@ void atk_text_get_character_extents (AtkText *tex
gint *x,
gint *y,
gint *length,
- gint *width);
+ gint *width,
+ AtkXYCoords coords);
AtkAttributeSet* atk_text_ref_run_attributes (AtkText *text,
gint offset,
gint *start_offset,
@@ -166,7 +172,8 @@ AtkAttributeSet* atk_text_ref_run_attributes (AtkText *text,
gint atk_text_get_character_count (AtkText *text);
gint atk_text_get_offset_at_point (AtkText *text,
gint x,
- gint y);
+ gint y,
+ AtkXYCoords coords);
gint atk_text_get_n_selections (AtkText *text);
gchar* atk_text_get_selection (AtkText *text,
gint selection_num,
@@ -183,10 +190,6 @@ gboolean atk_text_set_selection (AtkText *tex
gint end_offset);
gboolean atk_text_set_caret_offset (AtkText *text,
gint offset);
-gboolean atk_text_set_run_attributes (AtkText *text,
- AtkAttributeSet *attrib,
- gint start_offset,
- gint end_offset);
#ifdef __cplusplus
}