1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 /* vim:set et sts=4: */
3 /* IBus - The Input Bus
4 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
5 * Copyright (C) 2008-2010 Red Hat, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
24 #error "Only <ibus.h> can be included directly"
28 * SECTION: ibusattribute
29 * @short_description: Attributes of IBusText.
30 * @see_also: #IBusText
33 * An IBusAttribute represents an attribute that associate to IBusText.
34 * It decorates preedit buffer and auxiliary text with underline, foreground and background colors.
36 #ifndef __IBUS_ATTRIBUTE_H_
37 #define __IBUS_ATTRIBUTE_H_
39 #include "ibusserializable.h"
46 /* define IBusAttribute macros */
47 #define IBUS_TYPE_ATTRIBUTE \
48 (ibus_attribute_get_type ())
49 #define IBUS_ATTRIBUTE(obj) \
50 (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_ATTRIBUTE, IBusAttribute))
51 #define IBUS_ATTRIBUTE_CLASS(klass) \
52 (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_ATTRIBUTE, IBusAttributeClass))
53 #define IBUS_IS_ATTRIBUTE(obj) \
54 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_ATTRIBUTE))
55 #define IBUS_IS_ATTRIBUTE_CLASS(klass) \
56 (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_ATTRIBUTE))
57 #define IBUS_ATTRIBUTE_GET_CLASS(obj) \
58 (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_ATTRIBUTE, IBusAttributeClass))
62 * @IBUS_ATTR_TYPE_UNDERLINE: Decorate with underline.
63 * @IBUS_ATTR_TYPE_FOREGROUND: Foreground color.
64 * @IBUS_ATTR_TYPE_BACKGROUND: Background color.
66 * Type enumeration of IBusText attribute.
69 IBUS_ATTR_TYPE_UNDERLINE = 1,
70 IBUS_ATTR_TYPE_FOREGROUND = 2,
71 IBUS_ATTR_TYPE_BACKGROUND = 3,
76 * @IBUS_ATTR_UNDERLINE_NONE: No underline.
77 * @IBUS_ATTR_UNDERLINE_SINGLE: Single underline.
78 * @IBUS_ATTR_UNDERLINE_DOUBLE: Double underline.
79 * @IBUS_ATTR_UNDERLINE_LOW: Low underline ? %FIXME
80 * @IBUS_ATTR_UNDERLINE_ERROR: Error underline
82 * Type of IBusText attribute.
85 IBUS_ATTR_UNDERLINE_NONE = 0,
86 IBUS_ATTR_UNDERLINE_SINGLE = 1,
87 IBUS_ATTR_UNDERLINE_DOUBLE = 2,
88 IBUS_ATTR_UNDERLINE_LOW = 3,
89 IBUS_ATTR_UNDERLINE_ERROR = 4,
92 typedef struct _IBusAttribute IBusAttribute;
93 typedef struct _IBusAttributeClass IBusAttributeClass;
97 * @type: IBusAttributeType
98 * @value: Value for the type.
99 * @start_index: The starting index, inclusive.
100 * @end_index: The ending index, exclusive.
102 * Signify the type, value and scope of the attribute.
103 * The scope starts from @start_index till the @end_index-1.
105 struct _IBusAttribute {
106 IBusSerializable parent;
115 struct _IBusAttributeClass {
116 IBusSerializableClass parent;
120 * ibus_attribute_get_type:
121 * @returns: GType of IBusAttribute.
123 * Returns GType of IBusAttribute.
125 GType ibus_attribute_get_type ();
128 * ibus_attribute_new:
129 * @type: Type of the attribute.
130 * @value: Value of the attribute.
131 * @start_index: Where attribute starts.
132 * @end_index: Where attribute ends.
133 * @returns: (transfer none): A newly allocated IBusAttribute.
135 * New an IBusAttribute.
137 IBusAttribute *ibus_attribute_new (guint type,
143 * ibus_attribute_get_attr_type:
144 * @returns: An enum of #IBusAttrType.
146 * Returns an enum of #IBusAttrType.
148 guint ibus_attribute_get_attr_type
149 (IBusAttribute *attr);
152 * ibus_attribute_get_value:
153 * @returns: An unsigned int value relative with #IBusAttrType.
155 * Returns an unsigned int value relative with #IBusAttrType.
156 * If the type is %IBUS_ATTR_TYPE_UNDERLINE, the return value is
157 * #IBusAttrUnderline. If the type is %IBUS_ATTR_TYPE_FOREGROUND,
158 * the return value is the color RGB.
160 guint ibus_attribute_get_value (IBusAttribute *attr);
163 * ibus_attribute_get_start_index:
164 * @returns: A start unsigned index
166 * Returns a start unsigned index
168 guint ibus_attribute_get_start_index
169 (IBusAttribute *attr);
172 * ibus_attribute_get_end_index:
173 * @returns: A end unsigned index
175 * Returns a end unsigned index
177 guint ibus_attribute_get_end_index
178 (IBusAttribute *attr);
181 * ibus_attr_underline_new:
182 * @underline_type: Type of underline.
183 * @start_index: Where attribute starts.
184 * @end_index: Where attribute ends.
185 * @returns: (transfer none): A newly allocated #IBusAttribute.
187 * New an underline #IBusAttribute.
189 IBusAttribute *ibus_attr_underline_new (guint underline_type,
193 * ibus_attr_foreground_new:
194 * @color: Color in RGB.
195 * @start_index: Where attribute starts.
196 * @end_index: Where attribute ends.
197 * @returns: (transfer none): A newly allocated #IBusAttribute.
199 * New an foreground #IBusAttribute.
201 IBusAttribute *ibus_attr_foreground_new (guint color,
205 * ibus_attr_background_new:
206 * @color: Color in RGB.
207 * @start_index: Where attribute starts.
208 * @end_index: Where attribute ends.
209 * @returns: (transfer none): A newly allocated #IBusAttribute.
211 * New an background #IBusAttribute.
213 IBusAttribute *ibus_attr_background_new (guint color,