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 public class Background : Layout
28 /// Creates and initializes a new instance of the Background class.
30 /// <param name="parent">The EvasObject to which the new Background will be attached as a child.</param>
31 public Background(EvasObject parent) : base(parent)
33 Style = "transparent";
37 /// Sets or gets color to Background.
39 public override Color Color
47 var swallowContent = GetPartContent("elm.swallow.rectangle");
48 if (swallowContent != IntPtr.Zero)
50 Interop.Evas.evas_object_color_get(swallowContent, out r, out g, out b, out a);
52 return new Color(r, g, b, a);
56 var swallowContent = GetPartContent("elm.swallow.rectangle");
57 if (swallowContent == IntPtr.Zero)
59 Interop.Elementary.elm_bg_color_set(RealHandle, value.R, value.G, value.B);
60 swallowContent = GetPartContent("elm.swallow.rectangle");
62 Interop.Evas.evas_object_color_set(swallowContent, value.R, value.G, value.B, value.A);
67 /// Sets or gets image to Background.
73 return Interop.Elementary.BackgroundFileGet(RealHandle);
77 Interop.Elementary.elm_bg_file_set(RealHandle, value, IntPtr.Zero);
82 /// Sets or gets the mode of display for a given background widget's image.
85 /// This sets how the background widget will display its image.
86 /// This will only work if the File was previously set with an image file on obj.
87 /// The image can be display tiled, scaled, centered or stretched. scaled by default.
89 public BackgroundOptions BackgroundOption
93 return (BackgroundOptions)Interop.Elementary.elm_bg_option_get(RealHandle);
97 Interop.Elementary.elm_bg_option_set(RealHandle, (Interop.Elementary.BackgroundOptions)value);
102 /// Set the size of the pixmap representation of the image set on a given background widget.
103 /// This method just makes sense if an image file was set.
104 /// This is just a hint for the underlying system.
105 /// The real size of the pixmap may differ depending on the type of image being loaded, being bigger than requested.
107 /// <param name="w">The new width of the image pixmap representation.</param>
108 /// <param name="h">The new height of the image pixmap representation.</param>
109 public void SetFileLoadSize(int w, int h)
113 Interop.Elementary.elm_bg_load_size_set(RealHandle, w, h);
117 throw new Exception("This method just makes sense if an image file was set.");
121 protected override IntPtr CreateHandle(EvasObject parent)
123 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
124 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
126 RealHandle = Interop.Elementary.elm_bg_add(handle);
127 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
134 /// Enumeration for the background type.
136 public enum BackgroundOptions
139 /// Centers the background image
144 /// Scales the background image, retaining the aspect ratio
149 /// Stretches the background image to fill the UI component's area.
154 /// Tiles the background image at its original size