Background

Enumerations | Functions
Background
Elementary

Background object, used for setting a solid color, image or Edje group as a background to a window or any container object. More...

## Enumerations
enum | Elm_Bg_Option { ELM_BG_OPTION_CENTER = 0 , ELM_BG_OPTION_SCALE , ELM_BG_OPTION_STRETCH , ELM_BG_OPTION_TILE , ELM_BG_OPTION_LAST }
| Identifiers on how a background widget is to display its image. More...

## Functions
Evas_Object * | elm_bg_add (Evas_Object *parent)
| Adds a new background to the parent. More...
void | elm_bg_color_set (Evas_Object *obj, int r, int g, int b)
| Sets the color on a given background widget. More...
void | elm_bg_color_get (const Evas_Object *obj, int *r, int *g, int *b)
| Gets the color set on a given background widget. More...
Eina_Bool | elm_bg_file_set (Eo *obj, const char *file, const char *group)
| Sets the file (image or edje collection) to give life for the background. More...
void | elm_bg_file_get (const Eo *obj, const char **file, const char **group)
| Gets the file (image or edje collection) set on a given background widget. More...
void | elm_bg_option_set (Evas_Object *obj, Elm_Bg_Option option)
| Sets the mode of display for a given background widget's image. More...
Elm_Bg_Option | elm_bg_option_get (const Evas_Object *obj)
| Gets the mode of display of a given background widget's image. More...
void | elm_bg_load_size_set (Evas_Object *obj, int w, int h)
| Sets the size of the pixmap representation of the image set on a given background widget. More...
EINA_DEPRECATED void | elm_bg_overlay_set (Evas_Object *obj, Evas_Object *overlay)
| Set the overlay object used for the background object. More...
EINA_DEPRECATED Evas_Object * | elm_bg_overlay_get (const Evas_Object *obj)
| Get the overlay object used for the background object. More...
EINA_DEPRECATED Evas_Object * | elm_bg_overlay_unset (Evas_Object *obj)
| Get the overlay object used for the background object. More...

## Detailed Description

Background object, used for setting a solid color, image or Edje group as a background to a window or any container object.

The bg (background) widget is used for setting (solid) background decorations to a window (unless it has transparency enabled) or to any container object. It works just like an image, but has some properties useful to a background, like setting it to tiled, centered, scaled or stretched.

This widget inherits from the Layout one, so that all the functions acting on it also work for background objects.

Default content parts of the bg widget that you can use for are:

- `"overlay"` - overlay of the bg

Here is some sample code using it:

- elm_bg - Plain color background.
- elm_bg - Image background.
- elm_bg - Background properties.

## Enumeration Type Documentation

## ◆ Elm_Bg_Option

enum Elm_Bg_Option

Identifiers on how a background widget is to display its image.

– if it was set to use an image file.

Enumerator
ELM_BG_OPTION_CENTER | Center the background image.
ELM_BG_OPTION_SCALE | Scale the background image, retaining aspect ratio (default).
ELM_BG_OPTION_STRETCH | Stretch the background image to fill the widget's area.
ELM_BG_OPTION_TILE | Tile background image at its original size.
ELM_BG_OPTION_LAST | Sentinel value to indicate last enum field during iteration. Also used to indicate errors

## Function Documentation

## ◆ elm_bg_add()

Evas_Object* elm_bg_add | ( | Evas_Object * | parent | ) |

Adds a new background to the parent.

Parameters

  parent | The parent object

Returns
  The new object or `NULL` if it cannot be created

References EINA_SAFETY_ON_NULL_RETURN_VAL.

Referenced by elm_quicklaunch_seed().

## ◆ elm_bg_color_set()

void elm_bg_color_set | ( | Evas_Object * | obj,
|  | int | r,
|  | int | g,
|  | int | b
| ) |  |

Sets the color on a given background widget.

Parameters

  obj | The background object handle
  r | The red color component's value
  g | The green color component's value
  b | The blue color component's value

This sets the color used for the background rectangle, in RGB format. Each color component's range is from 0 to 255.

Note
  You probably only want to use this function if you haven't previously called elm_bg_file_set(), so that you just want a solid color background.
  You can reset the color by setting `r`, `g`, `b` as -1, -1, -1.

See also
  elm_bg_color_get()

## ◆ elm_bg_color_get()

void elm_bg_color_get | ( | const Evas_Object * | obj,
|  | int * | r,
|  | int * | g,
|  | int * | b
| ) |  |

Gets the color set on a given background widget.

Parameters

  obj | The background object handle
  r | Where to store the red color component's value
  g | Where to store the green color component's value
  b | Where to store the blue color component's value

Note
  Use `NULL` pointers on the file components you're not interested in: they'll be ignored by the function.

See also
  elm_bg_color_get() for more details

## ◆ elm_bg_file_set()

Eina_Bool elm_bg_file_set | ( | Eo * | obj,
|  | const char * | file,
|  | const char * | group
| ) |  |

Sets the file (image or edje collection) to give life for the background.

Returns
  `EINA_TRUE` on success, `EINA_FALSE` otherwise

This sets the image file used in the background object. If the image comes from an Edje group, it will be stretched to completely fill the background object. If it comes from a traditional image file, it will by default be centered in this widget's area (thus retaining its aspect), what could lead to some parts being not visible. You may change the mode of exhibition for a real image file with elm_bg_option_set().

Note
  Once the image of `obj` is set, a previously set one will be deleted, even if `file` is `NULL`.
  This will only affect the contents of one of the background's swallow spots, namely `"elm.swallow.background"`. If you want to achieve the `Layout's` file setting behavior, you'll have to call that method on this object.

Parameters

  [in] | obj | The background object handle
  [in] | file | The file path
  [in] | group | Optional key (group in Edje) within the file

References EINA_FALSE, EINA_TRUE, and elm_image_preload_disabled_set().

## ◆ elm_bg_file_get()

void elm_bg_file_get | ( | const Eo * | obj,
|  | const char ** | file,
|  | const char ** | group
| ) |  |

Gets the file (image or edje collection) set on a given background widget.

Note
  Use `NULL` pointers on the file components you're not interested in: they'll be ignored by the function.

Parameters

  [in] | obj | The background object handle
  [out] | file | The file path
  [out] | group | Optional key (group in Edje) within the file

## ◆ elm_bg_option_set()

void elm_bg_option_set | ( | Evas_Object * | obj,
|  | Elm_Bg_Option | option
| ) |  |

Sets 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 elm_bg_file_set() was previously called with an image file on $obj. The image can be display tiled, scaled, centered or stretched. ELM_BG_OPTION_SCALE by default.

Parameters

  [in] | option | The desired background option(See Elm.Bg.Option).

See also
  elm_bg_option_get()

References ELM_BG_OPTION_CENTER, ELM_BG_OPTION_LAST, ELM_BG_OPTION_SCALE, ELM_BG_OPTION_STRETCH, and ELM_BG_OPTION_TILE.

## ◆ elm_bg_option_get()

Elm_Bg_Option elm_bg_option_get | ( | const Evas_Object * | obj | ) |

Gets the mode of display of a given background widget's image.

Returns
  The background option Elm.Bg.Option Default is ELM_BG_OPTION_SCALE.

See also
  elm_bg_option_set()

References ELM_BG_OPTION_CENTER, ELM_BG_OPTION_LAST, ELM_BG_OPTION_SCALE, ELM_BG_OPTION_STRETCH, ELM_BG_OPTION_TILE, and ERR.

## ◆ elm_bg_load_size_set()

void elm_bg_load_size_set | ( | Evas_Object * | obj,
|  | int | w,
|  | int | h
| ) |  |

Sets the size of the pixmap representation of the image set on a given background widget.

Warning
  : This function just makes sense if an image file was set on `obj`, with elm_bg_file_set().

This function sets a new size for pixmap representation of the given bg image. It allows for the image to be loaded already in the specified size, reducing the memory usage and load time (for example, when loading a big image file with its load size set to a smaller size)

Note
  : 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.

Parameters

  [in] | w | The new width of the image pixmap representation
  [in] | h | The new height of the image pixmap representation

References EINA_SIZE2D.

## ◆ elm_bg_overlay_set()

EINA_DEPRECATED void elm_bg_overlay_set | ( | Evas_Object * | obj,
|  | Evas_Object * | overlay
| ) |  |

Set the overlay object used for the background object.

Parameters

  obj | The bg object
  overlay | The overlay object

This provides a way for elm_bg to have an 'overlay' that will be on top of the bg. Once the over object is set, a previously set one will be deleted, even if you set the new one to NULL. If you want to keep that old content object, use the elm_bg_overlay_unset() function.

Deprecated:
  use elm_object_part_content_set() instead

## ◆ elm_bg_overlay_get()

EINA_DEPRECATED Evas_Object* elm_bg_overlay_get | ( | const Evas_Object * | obj | ) |

Get the overlay object used for the background object.

Parameters

  obj | The bg object

Returns
  The content that is being used

Return the content object which is set for this widget

Deprecated:
  use elm_object_part_content_get() instead

## ◆ elm_bg_overlay_unset()

EINA_DEPRECATED Evas_Object* elm_bg_overlay_unset | ( | Evas_Object * | obj | ) |

Get the overlay object used for the background object.

Parameters

  obj | The bg object

Returns
  The content that was being used

Unparent and return the overlay object which was set for this widget

Deprecated:
  use elm_object_part_content_unset() instead