b5fb610b825704b9a074239b53543c7220671ac4
[framework/uifw/elementary.git] / src / lib / elc_anchorview.h
1    /**
2     * @defgroup Anchorview Anchorview
3     *
4     * @image html img/widget/anchorview/preview-00.png
5     * @image latex img/widget/anchorview/preview-00.eps
6     *
7     * Anchorview is for displaying text that contains markup with anchors
8     * like <c>\<a href=1234\>something\</\></c> in it.
9     *
10     * Besides being styled differently, the anchorview widget provides the
11     * necessary functionality so that clicking on these anchors brings up a
12     * popup with user defined content such as "call", "add to contacts" or
13     * "open web page". This popup is provided using the @ref Hover widget.
14     *
15     * This widget is very similar to @ref Anchorblock, so refer to that
16     * widget for an example. The only difference Anchorview has is that the
17     * widget is already provided with scrolling functionality, so if the
18     * text set to it is too large to fit in the given space, it will scroll,
19     * whereas the @ref Anchorblock widget will keep growing to ensure all the
20     * text can be displayed.
21     *
22     * This widget emits the following signals:
23     * @li "anchor,clicked": will be called when an anchor is clicked. The
24     * @p event_info parameter on the callback will be a pointer of type
25     * ::Elm_Entry_Anchorview_Info.
26     *
27     * See @ref Anchorblock for an example on how to use both of them.
28     *
29     * @see Anchorblock
30     * @see Entry
31     * @see Hover
32     *
33     * @{
34     */
35
36    /**
37     * @typedef Elm_Entry_Anchorview_Info
38     *
39     * The info sent in the callback for "anchor,clicked" signals emitted by
40     * the Anchorview widget.
41     */
42    typedef struct _Elm_Entry_Anchorview_Info Elm_Entry_Anchorview_Info;
43
44    /**
45     * @struct _Elm_Entry_Anchorview_Info
46     *
47     * The info sent in the callback for "anchor,clicked" signals emitted by
48     * the Anchorview widget.
49     */
50    struct _Elm_Entry_Anchorview_Info
51      {
52         const char     *name; /**< Name of the anchor, as indicated in its href
53                                    attribute */
54         int             button; /**< The mouse button used to click on it */
55         Evas_Object    *hover; /**< The hover object to use for the popup */
56         struct {
57              Evas_Coord    x, y, w, h;
58         } anchor, /**< Geometry selection of text used as anchor */
59           hover_parent; /**< Geometry of the object used as parent by the
60                              hover */
61         Eina_Bool       hover_left : 1; /**< Hint indicating if there's space
62                                              for content on the left side of
63                                              the hover. Before calling the
64                                              callback, the widget will make the
65                                              necessary calculations to check
66                                              which sides are fit to be set with
67                                              content, based on the position the
68                                              hover is activated and its distance
69                                              to the edges of its parent object
70                                              */
71         Eina_Bool       hover_right : 1; /**< Hint indicating content fits on
72                                               the right side of the hover.
73                                               See @ref hover_left */
74         Eina_Bool       hover_top : 1; /**< Hint indicating content fits on top
75                                             of the hover. See @ref hover_left */
76         Eina_Bool       hover_bottom : 1; /**< Hint indicating content fits
77                                                below the hover. See @ref
78                                                hover_left */
79      };
80
81    /**
82     * Add a new Anchorview object
83     *
84     * @param parent The parent object
85     * @return The new object or NULL if it cannot be created
86     */
87    EAPI Evas_Object *elm_anchorview_add(Evas_Object *parent) EINA_ARG_NONNULL(1);
88
89    /**
90     * Set the text to show in the anchorview
91     *
92     * Sets the text of the anchorview to @p text. This text can include markup
93     * format tags, including <c>\<a href=anchorname\></c> to begin a segment of
94     * text that will be specially styled and react to click events, ended with
95     * either of \</a\> or \</\>. When clicked, the anchor will emit an
96     * "anchor,clicked" signal that you can attach a callback to with
97     * evas_object_smart_callback_add(). The name of the anchor given in the
98     * event info struct will be the one set in the href attribute, in this
99     * case, anchorname.
100     *
101     * Other markup can be used to style the text in different ways, but it's
102     * up to the style defined in the theme which tags do what.
103     * @deprecated use elm_object_text_set() instead.
104     */
105    EINA_DEPRECATED EAPI void         elm_anchorview_text_set(Evas_Object *obj, const char *text) EINA_ARG_NONNULL(1);
106
107    /**
108     * Get the markup text set for the anchorview
109     *
110     * Retrieves the text set on the anchorview, with markup tags included.
111     *
112     * @param obj The anchorview object
113     * @return The markup text set or @c NULL if nothing was set or an error
114     * occurred
115     * @deprecated use elm_object_text_set() instead.
116     */
117    EINA_DEPRECATED EAPI const char  *elm_anchorview_text_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
118
119    /**
120     * Set the parent of the hover popup
121     *
122     * Sets the parent object to use by the hover created by the anchorview
123     * when an anchor is clicked. See @ref Hover for more details on this.
124     * If no parent is set, the same anchorview object will be used.
125     *
126     * @param obj The anchorview object
127     * @param parent The object to use as parent for the hover
128     */
129    EAPI void         elm_anchorview_hover_parent_set(Evas_Object *obj, Evas_Object *parent) EINA_ARG_NONNULL(1);
130
131    /**
132     * Get the parent of the hover popup
133     *
134     * Get the object used as parent for the hover created by the anchorview
135     * widget. See @ref Hover for more details on this.
136     *
137     * @param obj The anchorview object
138     * @return The object used as parent for the hover, NULL if none is set.
139     */
140    EAPI Evas_Object *elm_anchorview_hover_parent_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
141
142    /**
143     * Set the style that the hover should use
144     *
145     * When creating the popup hover, anchorview will request that it's
146     * themed according to @p style.
147     *
148     * @param obj The anchorview object
149     * @param style The style to use for the underlying hover
150     *
151     * @see elm_object_style_set()
152     */
153    EAPI void         elm_anchorview_hover_style_set(Evas_Object *obj, const char *style) EINA_ARG_NONNULL(1);
154
155    /**
156     * Get the style that the hover should use
157     *
158     * Get the style the hover created by anchorview will use.
159     *
160     * @param obj The anchorview object
161     * @return The style to use by the hover. NULL means the default is used.
162     *
163     * @see elm_object_style_set()
164     */
165    EAPI const char  *elm_anchorview_hover_style_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
166
167    /**
168     * Ends the hover popup in the anchorview
169     *
170     * When an anchor is clicked, the anchorview widget will create a hover
171     * object to use as a popup with user provided content. This function
172     * terminates this popup, returning the anchorview to its normal state.
173     *
174     * @param obj The anchorview object
175     */
176    EAPI void         elm_anchorview_hover_end(Evas_Object *obj) EINA_ARG_NONNULL(1);
177
178    /**
179     * Set bouncing behaviour when the scrolled content reaches an edge
180     *
181     * Tell the internal scroller object whether it should bounce or not
182     * when it reaches the respective edges for each axis.
183     *
184     * @param obj The anchorview object
185     * @param h_bounce Whether to bounce or not in the horizontal axis
186     * @param v_bounce Whether to bounce or not in the vertical axis
187     *
188     * @see elm_scroller_bounce_set()
189     */
190    EAPI void         elm_anchorview_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce) EINA_ARG_NONNULL(1);
191
192    /**
193     * Get the set bouncing behaviour of the internal scroller
194     *
195     * Get whether the internal scroller should bounce when the edge of each
196     * axis is reached scrolling.
197     *
198     * @param obj The anchorview object
199     * @param h_bounce Pointer where to store the bounce state of the horizontal
200     *                 axis
201     * @param v_bounce Pointer where to store the bounce state of the vertical
202     *                 axis
203     *
204     * @see elm_scroller_bounce_get()
205     */
206    EAPI void         elm_anchorview_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce) EINA_ARG_NONNULL(1);
207
208    /**
209     * Appends a custom item provider to the given anchorview
210     *
211     * Appends the given function to the list of items providers. This list is
212     * called, one function at a time, with the given @p data pointer, the
213     * anchorview object and, in the @p item parameter, the item name as
214     * referenced in its href string. Following functions in the list will be
215     * called in order until one of them returns something different to NULL,
216     * which should be an Evas_Object which will be used in place of the item
217     * element.
218     *
219     * Items in the markup text take the form \<item relsize=16x16 vsize=full
220     * href=item/name\>\</item\>
221     *
222     * @param obj The anchorview object
223     * @param func The function to add to the list of providers
224     * @param data User data that will be passed to the callback function
225     *
226     * @see elm_entry_item_provider_append()
227     */
228    EAPI void         elm_anchorview_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorview, const char *item), void *data) EINA_ARG_NONNULL(1, 2);
229
230    /**
231     * Prepend a custom item provider to the given anchorview
232     *
233     * Like elm_anchorview_item_provider_append(), but it adds the function
234     * @p func to the beginning of the list, instead of the end.
235     *
236     * @param obj The anchorview object
237     * @param func The function to add to the list of providers
238     * @param data User data that will be passed to the callback function
239     */
240    EAPI void         elm_anchorview_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorview, const char *item), void *data) EINA_ARG_NONNULL(1, 2);
241
242    /**
243     * Remove a custom item provider from the list of the given anchorview
244     *
245     * Removes the function and data pairing that matches @p func and @p data.
246     * That is, unless the same function and same user data are given, the
247     * function will not be removed from the list. This allows us to add the
248     * same callback several times, with different @p data pointers and be
249     * able to remove them later without conflicts.
250     *
251     * @param obj The anchorview object
252     * @param func The function to remove from the list
253     * @param data The data matching the function to remove from the list
254     */
255    EAPI void         elm_anchorview_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *anchorview, const char *item), void *data) EINA_ARG_NONNULL(1, 2);
256
257    /**
258     * @}
259     */
260