/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; namespace ElmSharp { /// /// This is a container widget that takes a standard edje design file and wraps it very thinly in a widget. /// Inherits Widget. /// /// preview [Obsolete("This has been deprecated in API12")] public class Layout : Container { SmartEvent _languageChanged; SmartEvent _themeChanged; IntPtr _edjeHandle; /// /// Creates and initializes a new instance of the Layout class. /// /// The parent is a given container, which will be attached by the layout as a child. It's type. /// preview [Obsolete("This has been deprecated in API12")] public Layout(EvasObject parent) : base(parent) { } /// /// Creates and initializes a new instance of the Layout class. /// /// preview [Obsolete("This has been deprecated in API12")] protected Layout() : base() { } /// /// LanguageChanged will be triggered when the program's language is changed. /// /// preview [Obsolete("This has been deprecated in API12")] public event EventHandler LanguageChanged; /// /// ThemeChanged will be triggered when the theme is changed. /// /// preview [Obsolete("This has been deprecated in API12")] public event EventHandler ThemeChanged; /// /// Gets the edje layout. /// /// preview [Obsolete("This has been deprecated in API12")] public EdjeObject EdjeObject { get { if (_edjeHandle == IntPtr.Zero) _edjeHandle = Interop.Elementary.elm_layout_edje_get(RealHandle); return new EdjeObject(_edjeHandle); } } /// /// Gets or sets the accessibility state of texblock (text) parts in a layout object. /// /// preview [Obsolete("This has been deprecated in API12")] public bool TextBlockAccessibility { get { return Interop.Elementary.elm_layout_edje_object_can_access_get(RealHandle); } set { Interop.Elementary.elm_layout_edje_object_can_access_set(RealHandle, value); } } /// /// Freezes the Elementary layout object. /// This function puts all the changes on hold. /// Successive freezes will nest, requiring an equal number of thaws. /// /// The frozen state, or 0 if the object is not frozen or on error. /// preview [Obsolete("This has been deprecated in API12")] public int Freeze() { return Interop.Elementary.elm_layout_freeze(RealHandle); } /// /// Thaws the Elementary object. /// If sucessives freezes were done, an equal number of thaws will be required. /// /// The frozen state, or 0 if the object is not frozen or on error. /// preview [Obsolete("This has been deprecated in API12")] public int Thaw() { return Interop.Elementary.elm_layout_thaw(RealHandle); } /// /// Eval sizing. /// Manually forces a sizing re-evaluation. /// This is useful when the minimum size required by the edje theme of this layout has changed. /// 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. /// 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. /// All of this can change due to state changes, and that's when this function should be called. /// /// preview [Obsolete("This has been deprecated in API12")] public void Resizing() { Interop.Elementary.elm_layout_sizing_eval(RealHandle); } /// /// Requests sizing re-evaluation, restricted to the current width and/or height. /// 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. /// /// Restrict minimum size of the current width. /// Restrict minimum size of the current height. /// preview [Obsolete("This has been deprecated in API12")] public void Resizing(bool width, bool height) { Interop.Elementary.elm_layout_sizing_restricted_eval(RealHandle, width, height); } /// /// Gets the edje data from the given layout. /// This function fetches the data specified inside the edje theme of this layout. /// This function returns null if the data is not found. /// /// The data key. /// The data. /// preview [Obsolete("This has been deprecated in API12")] public string GetEdjeData(string key) { return Interop.Elementary.elm_layout_data_get(RealHandle, key); } /// /// Gets the text set in the given part. /// /// The text part to retrieve the text off. /// /// preview [Obsolete("This has been deprecated in API12")] public override string GetPartText(string part) { return Interop.Elementary.elm_layout_text_get(RealHandle, part); } /// /// Sets the text set in the given part. /// /// The text part to retrieve the text off. /// The text to set. /// /// preview [Obsolete("This has been deprecated in API12")] public override bool SetPartText(string part, string text) { return Interop.Elementary.elm_layout_text_set(RealHandle, part, text); } /// /// Appends a child to the layout box part. /// Once the object is appended, it will become a child of the layout. /// Its lifetime will be bound to the layout. Whenever the layout dies, the child will be deleted automatically. /// /// /// This will only work if the layout edc have box part. /// /// The part. /// The object to append. /// Success is true. /// preview [Obsolete("This has been deprecated in API12")] public bool BoxAppend(string part, EvasObject child) { AddChild(child); return Interop.Elementary.elm_layout_box_append(RealHandle, part, child.Handle); } /// /// Prepends a child to the layout box part. /// Once the object is prepended, it will become a child of the layout. /// Its lifetime will be bound to the layout. Whenever the layout dies, the child will be deleted automatically. /// /// /// This will only work if the layout edc have box part. /// /// The part. /// The object to prepend. /// Success is true. /// preview [Obsolete("This has been deprecated in API12")] public bool BoxPrepend(string part, EvasObject child) { AddChild(child); return Interop.Elementary.elm_layout_box_prepend(RealHandle, part, child.Handle); } /// /// Removes a child from the given part box. /// The object will be removed from the box part and its lifetime will not be handled by the layout anymore. /// /// /// This will only work if the layout edc have box part. /// /// The part. /// The object to remove. /// Success if true /// preview [Obsolete("This has been deprecated in API12")] public bool BoxRemove(string part, EvasObject child) { RemoveChild(child); return Interop.Elementary.elm_layout_box_remove(RealHandle, part, child.Handle) != IntPtr.Zero; } /// /// Removes all the children from the given part box. /// The objects will be removed from the box part and their lifetime will not be handled by the layout anymore. /// /// /// This will only work if the layout edc have box part. /// /// The part. /// If true, then all the objects will be deleted as well, otherwise they will just be removed and will be dangling on the canvas. /// Success if true. /// preview [Obsolete("This has been deprecated in API12")] public bool BoxRemoveAll(string part, bool clear) { ClearChildren(); return Interop.Elementary.elm_layout_box_remove_all(RealHandle, part, clear); } /// /// Inserts a child to the layout box part at a given position. /// Once the object is inserted, it will become a child of the layout. /// Its lifetime will be bound to the layout. Whenever the layout dies, the child will be deleted automatically. /// /// /// This will only work if the layout edc have box part. /// /// The part. /// The child object to insert into the box. /// The numeric position >=0 to insert the child. /// Success if true. /// preview [Obsolete("This has been deprecated in API12")] public bool BoxInsertAt(string part, EvasObject child, uint position) { AddChild(child); return Interop.Elementary.elm_layout_box_insert_at(RealHandle, part, child.Handle, position); } /// /// Inserts a child to the layout box part before a reference object. /// Once the object is inserted, it will become child of the layout. /// Its lifetime will be bound to the layout. Whenever the layout dies, the child will be deleted automatically. /// /// /// This will only work if the layout edc have box part. /// /// The part. /// The child object to insert into the box. /// Another reference object to insert before the box. /// Success is true. /// preview [Obsolete("This has been deprecated in API12")] public bool BoxInsertBefore(string part, EvasObject child, EvasObject reference) { AddChild(child); return Interop.Elementary.elm_layout_box_insert_before(RealHandle, part, child.Handle, reference.Handle); } /// /// Sets the layout content. /// /// The swallow part name in the edje file. /// The child that will be added in this layout object. /// TRUE on success, FALSE otherwise. /// preview [Obsolete("This has been deprecated in API12")] public override bool SetPartContent(string part, EvasObject content) { return SetPartContent(part, content, false); } /// /// Sets the layout content. /// /// The name of a particular part. /// The content. /// true, preserve old content will be unset. false, preserve old content will not be unset. /// TRUE on success, FALSE otherwise. /// preview [Obsolete("This has been deprecated in API12")] public override bool SetPartContent(string part, EvasObject content, bool preserveOldContent) { if (preserveOldContent) { Interop.Elementary.elm_layout_content_unset(RealHandle, part); } UpdatePartContents(content, part); return Interop.Elementary.elm_layout_content_set(RealHandle, part, content); } /// /// Sets the edje group from the elementary theme that is used as a layout. /// /// The class of the group. /// The group. /// The style to use. /// preview [Obsolete("This has been deprecated in API12")] public void SetTheme(string klass, string group, string style) { Interop.Elementary.elm_layout_theme_set(RealHandle, klass, group, style); } /// /// Sets the file that is used as a layout. /// /// The path to the file (edje) that is used as a layout. /// The group that the layout belongs to in the edje file. /// preview [Obsolete("This has been deprecated in API12")] public void SetFile(string file, string group) { Interop.Elementary.elm_layout_file_set(RealHandle, file, group); } /// /// Sets the background color of a layout. /// /// preview [Obsolete("This has been deprecated in API12")] public override Color BackgroundColor { set { if (value.IsDefault) { Interop.Elementary.elm_object_color_class_del(RealHandle, "bg"); } else { SetPartColor("bg", value); } _backgroundColor = value; } } /// /// Sets the vertical text alignment of the layout's text part. /// /// /// API, elm_layout_text_valign_set, is an internal API only in Tizen. Available since Tizen_4.0. /// /// preview [Obsolete("This has been deprecated in API12")] public virtual void SetVerticalTextAlignment(string part, double valign) { Interop.Elementary.elm_layout_text_valign_set(RealHandle, part, valign); } /// /// Gets the vertical text alignment of the layout's text part. /// /// /// API, elm_layout_text_valign_get, is an internal API only in Tizen. Available since Tizen_4.0. /// /// preview [Obsolete("This has been deprecated in API12")] public virtual double GetVerticalTextAlignment(string part) { return Interop.Elementary.elm_layout_text_valign_get(RealHandle, part); } /// /// The callback of the Realized Event. /// /// preview [Obsolete("This has been deprecated in API12")] protected override void OnRealized() { base.OnRealized(); _languageChanged = new SmartEvent(this, this.RealHandle, "language,changed"); _languageChanged.On += (s, e) => { LanguageChanged?.Invoke(this, EventArgs.Empty); }; _themeChanged = new SmartEvent(this, this.RealHandle, "theme,changed"); _themeChanged.On += (s, e) => { ThemeChanged?.Invoke(this, EventArgs.Empty); }; } /// /// Sets the content at a part of a given container widget. /// /// The parent is a given container which will be attached by the layout as a child. It's type. /// The new object, otherwise null if it cannot be created. /// preview [Obsolete("This has been deprecated in API12")] protected override IntPtr CreateHandle(EvasObject parent) { return Interop.Elementary.elm_layout_add(parent.Handle); } } }