ad087aacc397888bbccc7a3dbd6dd862778d94cb
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Layout.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18
19 namespace ElmSharp
20 {
21     /// <summary>
22     /// This is a container widget that takes a standard edje design file and wraps it very thinly in a widget.
23     /// Inherits Widget.
24     /// </summary>
25     /// <since_tizen> preview </since_tizen>
26     [Obsolete("This has been deprecated in API12")]
27     public class Layout : Container
28     {
29         SmartEvent _languageChanged;
30         SmartEvent _themeChanged;
31
32         IntPtr _edjeHandle;
33
34         /// <summary>
35         /// Creates and initializes a new instance of the Layout class.
36         /// </summary>
37         /// <param name="parent">The parent is a given container, which will be attached by the layout as a child. It's <see cref="EvasObject"/> type.</param>
38         /// <since_tizen> preview </since_tizen>
39         [Obsolete("This has been deprecated in API12")]
40         public Layout(EvasObject parent) : base(parent)
41         {
42         }
43
44         /// <summary>
45         /// Creates and initializes a new instance of the Layout class.
46         /// </summary>
47         /// <since_tizen> preview </since_tizen>
48         [Obsolete("This has been deprecated in API12")]
49         protected Layout() : base()
50         {
51         }
52
53         /// <summary>
54         /// LanguageChanged will be triggered when the program's language is changed.
55         /// </summary>
56         /// <since_tizen> preview </since_tizen>
57         [Obsolete("This has been deprecated in API12")]
58         public event EventHandler LanguageChanged;
59
60         /// <summary>
61         /// ThemeChanged will be triggered when the theme is changed.
62         /// </summary>
63         /// <since_tizen> preview </since_tizen>
64         [Obsolete("This has been deprecated in API12")]
65         public event EventHandler ThemeChanged;
66
67         /// <summary>
68         /// Gets the edje layout.
69         /// </summary>
70         /// <since_tizen> preview </since_tizen>
71         [Obsolete("This has been deprecated in API12")]
72         public EdjeObject EdjeObject
73         {
74             get
75             {
76                 if (_edjeHandle == IntPtr.Zero)
77                     _edjeHandle = Interop.Elementary.elm_layout_edje_get(RealHandle);
78                 return new EdjeObject(_edjeHandle);
79             }
80         }
81
82         /// <summary>
83         /// Gets or sets the accessibility state of texblock (text) parts in a layout object.
84         /// </summary>
85         /// <since_tizen> preview </since_tizen>
86         [Obsolete("This has been deprecated in API12")]
87         public bool TextBlockAccessibility
88         {
89             get
90             {
91                 return Interop.Elementary.elm_layout_edje_object_can_access_get(RealHandle);
92             }
93             set
94             {
95                 Interop.Elementary.elm_layout_edje_object_can_access_set(RealHandle, value);
96             }
97         }
98
99         /// <summary>
100         /// Freezes the Elementary layout object.
101         /// This function puts all the changes on hold.
102         /// Successive freezes will nest, requiring an equal number of thaws.
103         /// </summary>
104         /// <returns>The frozen state, or 0 if the object is not frozen or on error.</returns>
105         /// <since_tizen> preview </since_tizen>
106         [Obsolete("This has been deprecated in API12")]
107         public int Freeze()
108         {
109             return Interop.Elementary.elm_layout_freeze(RealHandle);
110         }
111
112         /// <summary>
113         /// Thaws the Elementary object.
114         /// If sucessives freezes were done, an equal number of thaws will be required.
115         /// </summary>
116         /// <returns>The frozen state, or 0 if the object is not frozen or on error.</returns>
117         /// <since_tizen> preview </since_tizen>
118         [Obsolete("This has been deprecated in API12")]
119         public int Thaw()
120         {
121             return Interop.Elementary.elm_layout_thaw(RealHandle);
122         }
123
124         /// <summary>
125         /// Eval sizing.
126         /// Manually forces a sizing re-evaluation.
127         /// This is useful when the minimum size required by the edje theme of this layout has changed.
128         /// The change on the minimum size required by the edje theme is not immediately reported to the elementary layout, so one needs to call this function in order to tell the widget (layout) that it needs to reevaluate its own size.
129         /// The minimum size of the theme is calculated based on the minimum size of parts, the size of elements inside containers like the box and table, etc.
130         /// All of this can change due to state changes, and that's when this function should be called.
131         /// </summary>
132         /// <since_tizen> preview </since_tizen>
133         [Obsolete("This has been deprecated in API12")]
134         public void Resizing()
135         {
136             Interop.Elementary.elm_layout_sizing_eval(RealHandle);
137         }
138
139         /// <summary>
140         /// Requests sizing re-evaluation, restricted to the current width and/or height.
141         /// Useful mostly when there are TEXTBLOCK parts defining the height of an object and nothing else, restricting it to a minimum width. Calling this function will restrict minimum size in the Edje calculation to whatever size the layout has at the moment.
142         /// </summary>
143         /// <param name="width">Restrict minimum size of the current width.</param>
144         /// <param name="height">Restrict minimum size of the current height.</param>
145         /// <since_tizen> preview </since_tizen>
146         [Obsolete("This has been deprecated in API12")]
147         public void Resizing(bool width, bool height)
148         {
149             Interop.Elementary.elm_layout_sizing_restricted_eval(RealHandle, width, height);
150         }
151
152         /// <summary>
153         /// Gets the edje data from the given layout.
154         /// This function fetches the data specified inside the edje theme of this layout.
155         /// This function returns null if the data is not found.
156         /// </summary>
157         /// <param name="key">The data key.</param>
158         /// <returns>The data.</returns>
159         /// <since_tizen> preview </since_tizen>
160         [Obsolete("This has been deprecated in API12")]
161         public string GetEdjeData(string key)
162         {
163             return Interop.Elementary.elm_layout_data_get(RealHandle, key);
164         }
165
166         /// <summary>
167         /// Gets the text set in the given part.
168         /// </summary>
169         /// <param name="part">The text part to retrieve the text off.</param>
170         /// <returns></returns>
171         /// <since_tizen> preview </since_tizen>
172         [Obsolete("This has been deprecated in API12")]
173         public override string GetPartText(string part)
174         {
175             return Interop.Elementary.elm_layout_text_get(RealHandle, part);
176         }
177
178         /// <summary>
179         /// Sets the text set in the given part.
180         /// </summary>
181         /// <param name="part">The text part to retrieve the text off.</param>
182         /// <param name="text">The text to set.</param>
183         /// <returns></returns>
184         /// <since_tizen> preview </since_tizen>
185         [Obsolete("This has been deprecated in API12")]
186         public override bool SetPartText(string part, string text)
187         {
188             return Interop.Elementary.elm_layout_text_set(RealHandle, part, text);
189         }
190
191         /// <summary>
192         /// Appends a child to the layout box part.
193         /// Once the object is appended, it will become a child of the layout.
194         /// Its lifetime will be bound to the layout. Whenever the layout dies, the child will be deleted automatically.
195         /// </summary>
196         /// <remarks>
197         /// This will only work if the layout edc have box part.
198         /// </remarks>
199         /// <param name="part">The part.</param>
200         /// <param name="child">The object to append.</param>
201         /// <returns>Success is true.</returns>
202         /// <since_tizen> preview </since_tizen>
203         [Obsolete("This has been deprecated in API12")]
204         public bool BoxAppend(string part, EvasObject child)
205         {
206             AddChild(child);
207             return Interop.Elementary.elm_layout_box_append(RealHandle, part, child.Handle);
208         }
209
210         /// <summary>
211         /// Prepends a child to the layout box part.
212         /// Once the object is prepended, it will become a child of the layout.
213         /// Its lifetime will be bound to the layout. Whenever the layout dies, the child will be deleted automatically.
214         /// </summary>
215         /// <remarks>
216         /// This will only work if the layout edc have box part.
217         /// </remarks>
218         /// <param name="part">The part.</param>
219         /// <param name="child">The object to prepend.</param>
220         /// <returns>Success is true.</returns>
221         /// <since_tizen> preview </since_tizen>
222         [Obsolete("This has been deprecated in API12")]
223         public bool BoxPrepend(string part, EvasObject child)
224         {
225             AddChild(child);
226             return Interop.Elementary.elm_layout_box_prepend(RealHandle, part, child.Handle);
227         }
228
229         /// <summary>
230         /// Removes a child from the given part box.
231         /// The object will be removed from the box part and its lifetime will not be handled by the layout anymore.
232         /// </summary>
233         /// <remarks>
234         /// This will only work if the layout edc have box part.
235         /// </remarks>
236         /// <param name="part">The part.</param>
237         /// <param name="child">The object to remove.</param>
238         /// <returns>Success if true</returns>
239         /// <since_tizen> preview </since_tizen>
240         [Obsolete("This has been deprecated in API12")]
241         public bool BoxRemove(string part, EvasObject child)
242         {
243             RemoveChild(child);
244             return Interop.Elementary.elm_layout_box_remove(RealHandle, part, child.Handle) != IntPtr.Zero;
245         }
246
247         /// <summary>
248         /// Removes all the children from the given part box.
249         /// The objects will be removed from the box part and their lifetime will not be handled by the layout anymore.
250         /// </summary>
251         /// <remarks>
252         /// This will only work if the layout edc have box part.
253         /// </remarks>
254         /// <param name="part">The part.</param>
255         /// <param name="clear">If true, then all the objects will be deleted as well, otherwise they will just be removed and will be dangling on the canvas.</param>
256         /// <returns>Success if true.</returns>
257         /// <since_tizen> preview </since_tizen>
258         [Obsolete("This has been deprecated in API12")]
259         public bool BoxRemoveAll(string part, bool clear)
260         {
261             ClearChildren();
262             return Interop.Elementary.elm_layout_box_remove_all(RealHandle, part, clear);
263         }
264
265         /// <summary>
266         /// Inserts a child to the layout box part at a given position.
267         /// Once the object is inserted, it will become a child of the layout.
268         /// Its lifetime will be bound to the layout. Whenever the layout dies, the child will be deleted automatically.
269         /// </summary>
270         /// <remarks>
271         /// This will only work if the layout edc have box part.
272         /// </remarks>
273         /// <param name="part">The part.</param>
274         /// <param name="child">The child object to insert into the box.</param>
275         /// <param name="position">The numeric position >=0 to insert the child.</param>
276         /// <returns>Success if true.</returns>
277         /// <since_tizen> preview </since_tizen>
278         [Obsolete("This has been deprecated in API12")]
279         public bool BoxInsertAt(string part, EvasObject child, uint position)
280         {
281             AddChild(child);
282             return Interop.Elementary.elm_layout_box_insert_at(RealHandle, part, child.Handle, position);
283         }
284
285         /// <summary>
286         /// Inserts a child to the layout box part before a reference object.
287         /// Once the object is inserted, it will become child of the layout.
288         /// Its lifetime will be bound to the layout. Whenever the layout dies, the child will be deleted automatically.
289         /// </summary>
290         /// <remarks>
291         /// This will only work if the layout edc have box part.
292         /// </remarks>
293         /// <param name="part">The part.</param>
294         /// <param name="child">The child object to insert into the box.</param>
295         /// <param name="reference">Another reference object to insert before the box.</param>
296         /// <returns>Success is true.</returns>
297         /// <since_tizen> preview </since_tizen>
298         [Obsolete("This has been deprecated in API12")]
299         public bool BoxInsertBefore(string part, EvasObject child, EvasObject reference)
300         {
301             AddChild(child);
302             return Interop.Elementary.elm_layout_box_insert_before(RealHandle, part, child.Handle, reference.Handle);
303         }
304
305         /// <summary>
306         /// Sets the layout content.
307         /// </summary>
308         /// <param name="part">The swallow part name in the edje file.</param>
309         /// <param name="content">The child that will be added in this layout object.</param>
310         /// <returns>TRUE on success, FALSE otherwise.</returns>
311         /// <since_tizen> preview </since_tizen>
312         [Obsolete("This has been deprecated in API12")]
313         public override bool SetPartContent(string part, EvasObject content)
314         {
315             return SetPartContent(part, content, false);
316         }
317
318         /// <summary>
319         /// Sets the layout content.
320         /// </summary>
321         /// <param name="part">The name of a particular part.</param>
322         /// <param name="content">The content.</param>
323         /// <param name="preserveOldContent">true, preserve old content will be unset. false, preserve old content will not be unset.</param>
324         /// <returns>TRUE on success, FALSE otherwise.</returns>
325         /// <since_tizen> preview </since_tizen>
326         [Obsolete("This has been deprecated in API12")]
327         public override bool SetPartContent(string part, EvasObject content, bool preserveOldContent)
328         {
329             if (preserveOldContent)
330             {
331                 Interop.Elementary.elm_layout_content_unset(RealHandle, part);
332             }
333             UpdatePartContents(content, part);
334             return Interop.Elementary.elm_layout_content_set(RealHandle, part, content);
335         }
336
337         /// <summary>
338         /// Sets the edje group from the elementary theme that is used as a layout.
339         /// </summary>
340         /// <param name="klass">The class of the group.</param>
341         /// <param name="group">The group.</param>
342         /// <param name="style">The style to use.</param>
343         /// <since_tizen> preview </since_tizen>
344         [Obsolete("This has been deprecated in API12")]
345         public void SetTheme(string klass, string group, string style)
346         {
347             Interop.Elementary.elm_layout_theme_set(RealHandle, klass, group, style);
348         }
349
350         /// <summary>
351         /// Sets the file that is used as a layout.
352         /// </summary>
353         /// <param name="file">The path to the file (edje) that is used as a layout.</param>
354         /// <param name="group">The group that the layout belongs to in the edje file.</param>
355         /// <since_tizen> preview </since_tizen>
356         [Obsolete("This has been deprecated in API12")]
357         public void SetFile(string file, string group)
358         {
359             Interop.Elementary.elm_layout_file_set(RealHandle, file, group);
360         }
361
362         /// <summary>
363         /// Sets the background color of a layout.
364         /// </summary>
365         /// <since_tizen> preview </since_tizen>
366         [Obsolete("This has been deprecated in API12")]
367         public override Color BackgroundColor
368         {
369             set
370             {
371                 if (value.IsDefault)
372                 {
373                     Interop.Elementary.elm_object_color_class_del(RealHandle, "bg");
374                 }
375                 else
376                 {
377                     SetPartColor("bg", value);
378                 }
379                 _backgroundColor = value;
380             }
381         }
382
383         /// <summary>
384         /// Sets the vertical text alignment of the layout's text part.
385         /// </summary>
386         /// <remarks>
387         /// API, elm_layout_text_valign_set, is an internal API only in Tizen. Available since Tizen_4.0.
388         /// </remarks>
389         /// <since_tizen> preview </since_tizen>
390         [Obsolete("This has been deprecated in API12")]
391         public virtual void SetVerticalTextAlignment(string part, double valign)
392         {
393             Interop.Elementary.elm_layout_text_valign_set(RealHandle, part, valign);
394         }
395
396         /// <summary>
397         /// Gets the vertical text alignment of the layout's text part.
398         /// </summary>
399         /// <remarks>
400         /// API, elm_layout_text_valign_get, is an internal API only in Tizen. Available since Tizen_4.0.
401         /// </remarks>
402         /// <since_tizen> preview </since_tizen>
403         [Obsolete("This has been deprecated in API12")]
404         public virtual double GetVerticalTextAlignment(string part)
405         {
406             return Interop.Elementary.elm_layout_text_valign_get(RealHandle, part);
407         }
408
409         /// <summary>
410         /// The callback of the Realized Event.
411         /// </summary>
412         /// <since_tizen> preview </since_tizen>
413         [Obsolete("This has been deprecated in API12")]
414         protected override void OnRealized()
415         {
416             base.OnRealized();
417             _languageChanged = new SmartEvent(this, this.RealHandle, "language,changed");
418             _languageChanged.On += (s, e) =>
419             {
420                 LanguageChanged?.Invoke(this, EventArgs.Empty);
421             };
422
423             _themeChanged = new SmartEvent(this, this.RealHandle, "theme,changed");
424             _themeChanged.On += (s, e) =>
425             {
426                 ThemeChanged?.Invoke(this, EventArgs.Empty);
427             };
428         }
429
430         /// <summary>
431         /// Sets the content at a part of a given container widget.
432         /// </summary>
433         /// <param name="parent">The parent is a given container which will be attached by the layout as a child. It's <see cref="EvasObject"/> type.</param>
434         /// <returns>The new object, otherwise null if it cannot be created.</returns>
435         /// <since_tizen> preview </since_tizen>
436         [Obsolete("This has been deprecated in API12")]
437         protected override IntPtr CreateHandle(EvasObject parent)
438         {
439             return Interop.Elementary.elm_layout_add(parent.Handle);
440         }
441     }
442 }