/*
* 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
{
///
/// The Background is a widget that use for setting (solid) background decorations to a window (unless it has transparency enabled)
/// or to any container object.
///
/// preview
public class Background : Layout
{
///
/// Creates and initializes a new instance of the Background class.
///
/// The EvasObject to which the new background will be attached as a child.
/// preview
public Background(EvasObject parent) : base(parent)
{
Style = "transparent";
}
///
/// Sets or gets the color to the background.
///
/// preview
public override Color Color
{
get
{
return BackgroundColor;
}
set
{
BackgroundColor = value;
}
}
///
/// Sets or gets the image to the background.
///
/// preview
public string File
{
get
{
return Interop.Elementary.BackgroundFileGet(RealHandle);
}
set
{
Interop.Elementary.elm_bg_file_set(RealHandle, value, IntPtr.Zero);
}
}
///
/// Sets or gets the mode of display for a given background widget's image.
///
///
/// This sets how the background widget will display its image.
/// This will only work if the file was previously set with an image file on object.
/// The image can be display tiled, scaled, centered, or stretched. Scaled by default.
///
/// preview
public BackgroundOptions BackgroundOption
{
get
{
return (BackgroundOptions)Interop.Elementary.elm_bg_option_get(RealHandle);
}
set
{
Interop.Elementary.elm_bg_option_set(RealHandle, (Interop.Elementary.BackgroundOptions)value);
}
}
///
/// Sets the size of the pixmap representation of the image set on a given background widget.
/// This method just makes sense if an image file was set.
/// This is just a hint for the underlying system.
/// The real size of the pixmap may differ depending on the type of image being loaded, being bigger than requested.
///
/// The new width of the image pixmap representation.
/// The new height of the image pixmap representation.
/// preview
public void SetFileLoadSize(int w, int h)
{
if (File != null)
{
Interop.Elementary.elm_bg_load_size_set(RealHandle, w, h);
}
else
{
throw new InvalidOperationException("This method just makes sense if an image file was set.");
}
}
///
/// Creates a widget handle.
///
/// Parent EvasObject.
/// Handle IntPtr.
/// preview
protected override IntPtr CreateHandle(EvasObject parent)
{
return Interop.Elementary.elm_bg_add(parent.Handle);
}
}
///
/// Enumeration for the background types.
///
/// preview
public enum BackgroundOptions
{
///
/// Centers the background image.
///
Center,
///
/// Scales the background image, retaining the aspect ratio.
///
Scale,
///
/// Stretches the background image to fill the UI component's area.
///
Stretch,
///
/// Tiles the background image at its original size.
///
Tile
}
}