1 #ifndef _EFL_CANVAS_TEXTBLOCK_INTERNAL_H
2 #define _EFL_CANVAS_TEXTBLOCK_INTERNAL_H
3 
4 #include <Evas.h>
5 
6 #define _REPLACEMENT_CHAR_UTF8 "\xEF\xBF\xBC"
7 #define _PARAGRAPH_SEPARATOR_UTF8 "\xE2\x80\xA9"
8 #define _NEWLINE_UTF8 "\n"
9 #define _TAB_UTF8 "\t"
10 
11 /* private struct for textblock object internal data */
12 /**
13  * @internal
14  * @typedef Efl_Canvas_Textblock_Data
15  * The actual textblock object.
16  */
17 typedef struct _Evas_Object_Textblock             Efl_Canvas_Textblock_Data;
18 /**
19  * @internal
20  * @typedef Evas_Object_Style_Tag
21  * The structure used for finding style tags.
22  */
23 typedef struct _Evas_Object_Style_Tag             Evas_Object_Style_Tag;
24 /**
25  * @internal
26  * @typedef Evas_Object_Style_Tag
27  * The structure used for finding style tags.
28  */
29 typedef struct _Evas_Object_Style_Tag_Base        Evas_Object_Style_Tag_Base;
30 /**
31  * @internal
32  * @typedef Evas_Object_Textblock_Node_Text
33  * A text node.
34  */
35 typedef struct _Evas_Object_Textblock_Node_Text   Evas_Object_Textblock_Node_Text;
36 /*
37  * Defined in Evas.h
38 typedef struct _Evas_Object_Textblock_Node_Format Evas_Object_Textblock_Node_Format;
39 */
40 typedef struct _Evas_Textblock_Node_Format Evas_Textblock_Node_Format;
41 
42 /**
43  * @internal
44  * @typedef Evas_Object_Textblock_Paragraph
45  * A layouting paragraph.
46  */
47 typedef struct _Evas_Object_Textblock_Paragraph   Evas_Object_Textblock_Paragraph;
48 /**
49  * @internal
50  * @typedef Evas_Object_Textblock_Line
51  * A layouting line.
52  */
53 typedef struct _Evas_Object_Textblock_Line        Evas_Object_Textblock_Line;
54 /**
55  * @internal
56  * @typedef Evas_Object_Textblock_Item
57  * A layouting item.
58  */
59 typedef struct _Evas_Object_Textblock_Item        Evas_Object_Textblock_Item;
60 /**
61  * @internal
62  * @typedef Evas_Object_Textblock_Item
63  * A layouting text item.
64  */
65 typedef struct _Evas_Object_Textblock_Text_Item        Evas_Object_Textblock_Text_Item;
66 /**
67  * @internal
68  * @typedef Evas_Object_Textblock_Format_Item
69  * A layouting format item.
70  */
71 typedef struct _Evas_Object_Textblock_Format_Item Evas_Object_Textblock_Format_Item;
72 /**
73  * @internal
74  * @typedef Evas_Object_Textblock_Format
75  * A textblock format.
76  */
77 typedef struct _Evas_Object_Textblock_Format      Evas_Object_Textblock_Format;
78 /**
79  * @internal
80  * @typedef Evas_Textblock_Selection_Iterator
81  * A textblock selection iterator.
82  */
83 typedef struct _Evas_Textblock_Selection_Iterator Evas_Textblock_Selection_Iterator;
84 /**
85  * @internal
86  * @typedef Efl_Text_Attribute_Handle_Iterator
87  * A textblock annotation iterator.
88  */
89 typedef struct _Efl_Text_Attribute_Handle_Iterator Efl_Text_Attribute_Handle_Iterator;
90 /**
91  * @internal
92  * @typedef Efl_Canvas_Textblock_Filter
93  * A structure holding gfx filter information for a text item
94  */
95 typedef struct _Efl_Canvas_Textblock_Filter Efl_Canvas_Textblock_Filter;
96 /**
97  * @internal
98  * @typedef Efl_Canvas_Textblock_Filter_Post_Render
99  * Post-render data for async rendering of gfx filters
100  */
101 typedef struct _Efl_Canvas_Textblock_Filter_Post_Render Efl_Canvas_Textblock_Filter_Post_Render;
102 /**
103  * @internal
104  * @typedef Efl_Canvas_Textblock_Filter_Program
105  * Filter name - code database
106  */
107 typedef struct _Efl_Canvas_Textblock_Filter_Program Efl_Canvas_Textblock_Filter_Program;
108 /**
109  * @internal
110  * @typedef Text_Item_Filter
111  * Text item filter properties (run context, output buffer, ...)
112  */
113 typedef struct _Text_Item_Filter Text_Item_Filter;
114 
115 
116 struct _Evas_Object_Style_Tag_Base
117 {
118    const char *tag;  /**< Format Identifier: b=Bold, i=Italic etc. */
119    const char *replace;  /**< Replacement string. "font_weight=Bold", "font_style=Italic" etc. */
120    size_t tag_len;  /**< Strlen of tag. */
121 };
122 
123 struct _Evas_Object_Style_Tag
124 {
125    EINA_INLIST;
126    Evas_Object_Style_Tag_Base tag;  /**< Base style object for holding style information. */
127 };
128 
129 struct _Evas_Object_Textblock_Node_Text
130 {
131    EINA_INLIST;
132    Eina_UStrbuf                       *unicode;  /**< Actual paragraph text. */
133    char                               *utf8;  /**< Text in utf8 format. */
134    Evas_Object_Textblock_Node_Format  *format_node; /**< Points to the last format node before the paragraph, or if there is none, to the first format node within the paragraph.*/
135    Evas_Object_Textblock_Paragraph    *par;  /**< Points to the paragraph node of which this node is a part. */
136    Eina_Bool                           dirty : 1;  /**< EINA_TRUE if already handled/format changed, else EINA_FALSE. */
137    Eina_Bool                           is_new : 1;  /**< EINA_TRUE if its a new paragraph, else EINA_FALSE. */
138 };
139 
140 struct _Evas_Textblock_Node_Format
141 {
142    EINA_INLIST;
143    const char                         *format;  /**< Cached, parsed and translated version of orig_format. */
144    const char                         *orig_format;  /**< Original format information. */
145    Evas_Object_Textblock_Node_Text    *text_node;  /**< The text node it's pointing to. */
146    Efl_Text_Attribute_Handle          *annotation; /**< Pointer to this node's annotation handle (if exists). */
147    size_t                              offset;  /**< Offset from the last format node of the same text. */
148    struct {
149       unsigned char l, r, t, b;
150    } pad;  /**< Amount of padding required. */
151    unsigned char                       anchor : 2;  /**< ANCHOR_NONE, ANCHOR_A or ANCHOR_ITEM. */
152    Eina_Bool                           opener : 1;  /**< EINA_TRUE if opener, else EINA_FALSE. */
153    Eina_Bool                           own_closer : 1;  /**< EINA_TRUE if own_closer, else EINA_FALSE. */
154    Eina_Bool                           visible : 1;  /**< EINA_TRUE if format is visible format, else EINA_FALSE. */
155    Eina_Bool                           format_change : 1;  /**< EINA_TRUE if the format of the textblock has changed, else EINA_FALSE. */
156    Eina_Bool                           is_new : 1;  /**< EINA_TRUE if its a new format node, else EINA_FALSE */
157 };
158 
159 struct _Efl_Text_Cursor_Handle
160 {
161    Evas_Object                     *obj;
162    Eina_List                       *cur_objs;
163    size_t                           pos;
164    Evas_Object_Textblock_Node_Text *node;
165    unsigned int                     ref_count;
166    Eina_Bool                        changed : 1;
167 };
168 
169 struct _Efl_Text_Attribute_Handle
170 {
171    EINA_INLIST;
172    Evas_Object                       *obj;
173    Evas_Object_Textblock_Node_Format *start_node, *end_node;
174    Eina_Bool                         is_item : 1; /**< indicates it is an item/object placeholder */
175 };
176 
177 void evas_textblock_cursor_line_jump_by(Efl_Text_Cursor_Handle *cur, int by);
178 int _cursor_text_append(Efl_Text_Cursor_Handle *cur, const char *text);
179 void evas_textblock_async_block(Evas_Object *eo_object);
180 
181 
182 // Used in Efl.Text.Cursor, where multible objects can have same handle.
183 Efl_Text_Cursor_Handle *
184 evas_textblock_cursor_ref(Efl_Text_Cursor_Handle *cursor, Eo * cursor_obj);
185 
186 // Used in Efl.Text.Cursor, where multible objects can have same handle.
187 void
188 evas_textblock_cursor_unref(Efl_Text_Cursor_Handle *cursor, Eo * cursor_obj);
189 void _evas_textblock_cursor_init(Efl_Text_Cursor_Handle *cur, const Evas_Object *tb);
190 
191 /*Annoation Functions*/
192 /**
193   * @internal
194   * Returns the value of the current data of list node,
195   * and goes to the next list node.
196   *
197   * @param it the iterator.
198   * @param data the data of the current list node.
199   * @return EINA_FALSE if unsuccessful. Otherwise, returns EINA_TRUE.
200   */
201 Eina_Bool
202 _evas_textblock_annotation_iterator_next(Efl_Text_Attribute_Handle_Iterator *it, void **data);
203 
204 /**
205   * @internal
206   * Frees the annotation iterator.
207   * @param it the iterator to free
208   * @return EINA_FALSE if unsuccessful. Otherwise, returns EINA_TRUE.
209   */
210 void
211 _evas_textblock_annotation_iterator_free(Efl_Text_Attribute_Handle_Iterator *it);
212 
213 
214 /**
215   * @internal
216   * Creates newly allocated  iterator associated to a list.
217   * @param list The list.
218   * @return If the memory cannot be allocated, NULL is returned.
219   * Otherwise, a valid iterator is returned.
220   */
221 Eina_Iterator *
222 _evas_textblock_annotation_iterator_new(Eina_List *list);
223 
224 
225 
226 void
227 _textblock_cursor_pos_at_fnode_set(Efl_Text_Cursor_Handle *cur,
228       Evas_Object_Textblock_Node_Format *fnode);
229 
230 
231 Eina_Bool
232 _evas_textblock_annotations_set(Evas_Object *eo_obj,
233       Efl_Text_Attribute_Handle *an,
234       Efl_Text_Cursor_Handle *start, Efl_Text_Cursor_Handle *end,
235       const char *format, Eina_Bool is_item);
236 
237 void
238 _evas_textblock_annotation_remove(Evas_Object *eo_obj, Efl_Canvas_Textblock_Data *o,
239       Efl_Text_Attribute_Handle *an, Eina_Bool remove_nodes, Eina_Bool invalidate);
240 
241 void
242 _evas_textblock_annotations_clear(const Evas_Object *eo_obj);
243 
244 
245 Efl_Text_Attribute_Handle *
246 _evas_textblock_annotations_insert(Eo *eo_obj,
247       Efl_Text_Cursor_Handle *start, Efl_Text_Cursor_Handle *end,
248       const char *format, Eina_Bool is_item);
249 
250 
251 Eina_Inlist *
252 _evas_textblock_annotations_get(Evas_Object *o);
253 
254 void
255 _evas_textblock_annotations_node_format_remove(Evas_Object *o, Evas_Object_Textblock_Node_Format *n, int visual_adjustment);
256 
257 void
258 _evas_textblock_relayout_if_needed(Evas_Object *o);
259 
260 #ifdef EAPI
261 # undef EAPI
262 #endif
263 
264 #ifdef _WIN32
265 # ifdef EFL_BUILD
266 #  ifdef DLL_EXPORT
267 #   define EAPI __declspec(dllexport)
268 #  else
269 #   define EAPI
270 #  endif
271 # else
272 #  define EAPI __declspec(dllimport)
273 # endif
274 #else
275 # ifdef __GNUC__
276 #  if __GNUC__ >= 4
277 #   define EAPI __attribute__ ((visibility("default")))
278 #  else
279 #   define EAPI
280 #  endif
281 # else
282 #  define EAPI
283 # endif
284 #endif
285 
286 /**
287  * Internally sets given text_object into cursor object.
288  *
289  * @param canvas_text_obj  the cursor object.
290  * @param canvas_text_obj  the canvas text object, where cursor methods will take effect.
291  * @param text_obj         the text_object that user can get using cursor text_object property.
292  */
293 EAPI void efl_text_cursor_object_text_object_set(Eo *cursor, Eo *canvas_text_obj, Eo *text_obj);
294 
295 
296 /**
297  * Internally create instance of cursor object.
298  *
299  * @param parent  the parent of the cursor object.
300  */
301 EAPI Eo* efl_text_cursor_object_create(Eo *parent);
302 
303 
304 /**
305  * Internally sets cursor handle(legacy textblock cursor) into cursor object.
306  *
307  * @param obj     the cursor object.
308  * @param handle  the text cursor handle.
309  */
310 EAPI void efl_text_cursor_object_handle_set(Eo *obj, Efl_Text_Cursor_Handle *handle);
311 
312 /**
313  * Internally gets cursor handle(legacy textblock cursor) from cursor object.
314  *
315  * @param obj     the cursor object.
316  * @return        the internal text cursor handle.
317  */
318 EAPI Efl_Text_Cursor_Handle *efl_text_cursor_object_handle_get(const Eo *obj);
319 
320 #undef EAPI
321 #define EAPI
322 
323 #endif//#ifndef _EFL_CANVAS_TEXTBLOCK_INTERNAL_H
324