2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 /// The Background is a widget that use for setting (solid) background decorations to a window (unless it has transparency enabled)
23 /// or to any container object.
25 /// <since_tizen> preview </since_tizen>
26 public class Background : Layout
29 /// Creates and initializes a new instance of the Background class.
31 /// <param name="parent">The EvasObject to which the new background will be attached as a child.</param>
32 /// <since_tizen> preview </since_tizen>
33 public Background(EvasObject parent) : base(parent)
35 Style = "transparent";
39 /// Sets or gets the color to the background.
41 /// <since_tizen> preview </since_tizen>
42 public override Color Color
50 var swallowContent = GetPartContent("elm.swallow.rectangle");
51 if (swallowContent != IntPtr.Zero)
53 Interop.Evas.evas_object_color_get(swallowContent, out r, out g, out b, out a);
55 return new Color(r, g, b, a);
59 var swallowContent = GetPartContent("elm.swallow.rectangle");
60 if (swallowContent == IntPtr.Zero)
62 Interop.Elementary.elm_bg_color_set(RealHandle, value.R, value.G, value.B);
63 swallowContent = GetPartContent("elm.swallow.rectangle");
65 Interop.Evas.evas_object_color_set(swallowContent, value.R, value.G, value.B, value.A);
70 /// Sets or gets the image to the background.
72 /// <since_tizen> preview </since_tizen>
77 return Interop.Elementary.BackgroundFileGet(RealHandle);
81 Interop.Elementary.elm_bg_file_set(RealHandle, value, IntPtr.Zero);
86 /// Sets or gets the mode of display for a given background widget's image.
89 /// This sets how the background widget will display its image.
90 /// This will only work if the file was previously set with an image file on object.
91 /// The image can be display tiled, scaled, centered, or stretched. Scaled by default.
93 /// <since_tizen> preview </since_tizen>
94 public BackgroundOptions BackgroundOption
98 return (BackgroundOptions)Interop.Elementary.elm_bg_option_get(RealHandle);
102 Interop.Elementary.elm_bg_option_set(RealHandle, (Interop.Elementary.BackgroundOptions)value);
107 /// Sets the size of the pixmap representation of the image set on a given background widget.
108 /// This method just makes sense if an image file was set.
109 /// This is just a hint for the underlying system.
110 /// The real size of the pixmap may differ depending on the type of image being loaded, being bigger than requested.
112 /// <param name="w">The new width of the image pixmap representation.</param>
113 /// <param name="h">The new height of the image pixmap representation.</param>
114 /// <since_tizen> preview </since_tizen>
115 public void SetFileLoadSize(int w, int h)
119 Interop.Elementary.elm_bg_load_size_set(RealHandle, w, h);
123 throw new Exception("This method just makes sense if an image file was set.");
128 /// Creates a widget handle.
130 /// <param name="parent">Parent EvasObject.</param>
131 /// <returns>Handle IntPtr.</returns>
132 /// <since_tizen> preview </since_tizen>
133 protected override IntPtr CreateHandle(EvasObject parent)
135 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
136 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
138 RealHandle = Interop.Elementary.elm_bg_add(handle);
139 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
146 /// Enumeration for the background types.
148 /// <since_tizen> preview </since_tizen>
149 public enum BackgroundOptions
152 /// Centers the background image.
157 /// Scales the background image, retaining the aspect ratio.
162 /// Stretches the background image to fill the UI component's area.
167 /// Tiles the background image at its original size.