# Module: `wibox.widget`

Utility function for working with widgets.

### Info:

- Copyright: 2010 Uli Schlachter
- Originally authored by: Uli Schlachter
  (Full contributors list available on our github project)

## Static module functions

wibox.widget.draw_to_cairo_context (wdg, cr, width, height, context) | Draw a widget directly to a given cairo context. |
wibox.widget.draw_to_svg_file (wdg, path, width, height, context) | Create an SVG file showing this widget. |
wibox.widget.draw_to_image_surface (wdg, width, height, format, context) -> () | Create a cairo image surface showing this widget. |

## Static module functions

🔗 wibox.widget.draw_to_cairo_context (wdg, cr, width, height, context)
  Draw a widget directly to a given cairo context. This function creates a temporary wibox.hierarchy instance and uses that to draw the given widget once to the given cairo context.

  ### Parameters:

  Name |  | Type(s) | Description | Default value
  --- | --- | --- | --- | ---
  wdg |  | widget | A widget to draw | Not applicable
  cr |  | cairo_context | The cairo context to draw the widget on | Not applicable
  width |  | number | The width of the widget | Not applicable
  height |  | number | The height of the widget | Not applicable
  context | Optional | table | The context information to give to the widget. | `{dpi=96}`

🔗 wibox.widget.draw_to_svg_file (wdg, path, width, height, context)
  Create an SVG file showing this widget.

  ### Parameters:

  Name |  | Type(s) | Description | Default value
  --- | --- | --- | --- | ---
  wdg |  | widget | A widget | Not applicable
  path |  | string | The output file path | Not applicable
  width |  | number | The surface width | Not applicable
  height |  | number | The surface height | Not applicable
  context | Optional | table | The context information to give to the widget. | `{dpi=96}`

🔗 wibox.widget.draw_to_image_surface (wdg, width, height, format, context) -> ()
  Create a cairo image surface showing this widget.

  ### Parameters:

  Name |  | Type(s) | Description | Default value
  --- | --- | --- | --- | ---
  wdg |  | widget | A widget | Not applicable
  width |  | number | The surface width | Not applicable
  height |  | number | The surface height | Not applicable
  format | Optional |  | The surface format | `cairo.Format.ARGB32`
  context | Optional | table | The context information to give to the widget. | `{dpi=96}`

  ### Returns:

  The cairo surface

generated by LDoc 1.5.0