// GENERATED — DO NOT EDIT

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/class.Layout.html).
pub type Layout

///|
pub(open) trait ILayout {
  fn as_layout(Self) -> Layout
  fn context_changed(Self) -> Unit = _
  fn copy(Self) -> Layout = _
  fn get_alignment(Self) -> Alignment = _
  fn get_attributes(Self) -> AttrList? = _
  fn get_auto_dir(Self) -> Bool = _
  fn get_baseline(Self) -> Int = _
  fn get_caret_pos(Self, Int) -> (Rectangle, Rectangle) = _
  fn get_character_count(Self) -> Int = _
  fn get_context(Self) -> Context = _
  fn get_cursor_pos(Self, Int) -> (Rectangle, Rectangle) = _
  fn get_direction(Self, Int) -> Direction = _
  fn get_ellipsize(Self) -> EllipsizeMode = _
  fn get_extents(Self) -> (Rectangle, Rectangle) = _
  fn get_font_description(Self) -> FontDescription? = _
  fn get_height(Self) -> Int = _
  fn get_indent(Self) -> Int = _
  fn get_iter(Self) -> LayoutIter = _
  fn get_justify(Self) -> Bool = _
  fn get_justify_last_line(Self) -> Bool = _
  fn get_line(Self, Int) -> LayoutLine? = _
  fn get_line_count(Self) -> Int = _
  fn get_line_readonly(Self, Int) -> LayoutLine? = _
  fn get_line_spacing(Self) -> Float = _
  fn get_lines(Self) -> Array[LayoutLine] = _
  fn get_lines_readonly(Self) -> Array[LayoutLine] = _
  fn get_log_attrs(Self) -> Array[LogAttr] = _
  fn get_log_attrs_readonly(Self) -> Array[LogAttr] = _
  fn get_pixel_extents(Self) -> (Rectangle, Rectangle) = _
  fn get_pixel_size(Self) -> (Int, Int) = _
  fn get_serial(Self) -> UInt = _
  fn get_single_paragraph_mode(Self) -> Bool = _
  fn get_size(Self) -> (Int, Int) = _
  fn get_spacing(Self) -> Int = _
  fn get_tabs(Self) -> TabArray? = _
  fn get_text(Self) -> String = _
  fn get_unknown_glyphs_count(Self) -> Int = _
  fn get_width(Self) -> Int = _
  fn get_wrap(Self) -> WrapMode = _
  fn index_to_line_x(Self, Int, Bool) -> (Int, Int) = _
  fn index_to_pos(Self, Int) -> Rectangle = _
  fn is_ellipsized(Self) -> Bool = _
  fn is_wrapped(Self) -> Bool = _
  fn move_cursor_visually(Self, Bool, Int, Int, Int) -> (Int, Int) = _
  fn serialize(Self, LayoutSerializeFlags) -> Bytes = _
  fn set_alignment(Self, Alignment) -> Unit = _
  fn set_attributes(Self, AttrList?) -> Unit = _
  fn set_auto_dir(Self, Bool) -> Unit = _
  fn set_ellipsize(Self, EllipsizeMode) -> Unit = _
  fn set_font_description(Self, FontDescription?) -> Unit = _
  fn set_height(Self, Int) -> Unit = _
  fn set_indent(Self, Int) -> Unit = _
  fn set_justify(Self, Bool) -> Unit = _
  fn set_justify_last_line(Self, Bool) -> Unit = _
  fn set_line_spacing(Self, Float) -> Unit = _
  fn set_markup(Self, String, Int) -> Unit = _
  fn set_markup_with_accel(Self, String, Int, UInt) -> UInt = _
  fn set_single_paragraph_mode(Self, Bool) -> Unit = _
  fn set_spacing(Self, Int) -> Unit = _
  fn set_tabs(Self, TabArray?) -> Unit = _
  fn set_text(Self, String, Int) -> Unit = _
  fn set_width(Self, Int) -> Unit = _
  fn set_wrap(Self, WrapMode) -> Unit = _
  fn write_to_file(Self, LayoutSerializeFlags, String) -> Bool raise @glib.Error_ = _
  fn xy_to_index(Self, Int, Int) -> (Bool, Int, Int) = _
}

///|
pub impl ILayout for Layout with fn as_layout(self) {
  self
}

///|
#borrow(context)
extern "c" fn moonbit_pango_layout_new(context : Context) -> Layout = "moonbit_pango_layout_new"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/ctor.Layout.new.html).
pub fn Layout::new(context : &IContext) -> Layout {
  moonbit_pango_layout_new(context.as_context())
}

///|
#borrow(context, bytes, error)
extern "c" fn moonbit_pango_layout_deserialize(
  context : Context,
  bytes : Bytes,
  flags : Int,
  error : Ref[@glib.Nullable[@glib.Error_]],
) -> @glib.Nullable[Layout] = "moonbit_pango_layout_deserialize"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/type_func.Layout.deserialize.html).
pub fn Layout::deserialize(
  context : &IContext,
  bytes : Bytes,
  flags : LayoutDeserializeFlags,
) -> Layout? raise @glib.Error_ {
  let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
  let raw_result = moonbit_pango_layout_deserialize(
    context.as_context(),
    bytes,
    flags.to_int(),
    error_,
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  raw_result.to_option()
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.context_changed.html).
#borrow(self)
pub extern "c" fn Layout::context_changed(self : Layout) = "moonbit_pango_layout_context_changed"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.copy.html).
#borrow(self)
pub extern "c" fn Layout::copy(self : Layout) -> Layout = "moonbit_pango_layout_copy"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_alignment.html).
#borrow(self)
pub extern "c" fn Layout::get_alignment(self : Layout) -> Alignment = "moonbit_pango_layout_get_alignment"

///|
#borrow(self_)
extern "c" fn moonbit_pango_layout_get_attributes(
  self_ : Layout,
) -> @glib.Nullable[AttrList] = "moonbit_pango_layout_get_attributes"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_attributes.html).
pub fn Layout::get_attributes(self : Layout) -> AttrList? {
  let raw_result = moonbit_pango_layout_get_attributes(self)
  raw_result.to_option()
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_auto_dir.html).
#borrow(self)
pub extern "c" fn Layout::get_auto_dir(self : Layout) -> Bool = "moonbit_pango_layout_get_auto_dir"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_baseline.html).
#borrow(self)
pub extern "c" fn Layout::get_baseline(self : Layout) -> Int = "moonbit_pango_layout_get_baseline"

///|
#borrow(self_, __out_weak_pos)
extern "c" fn moonbit_pango_layout_get_caret_pos(
  self_ : Layout,
  index_ : Int,
  __out_weak_pos : Ref[Rectangle],
) -> Rectangle = "moonbit_pango_layout_get_caret_pos"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_caret_pos.html).
pub fn Layout::get_caret_pos(
  self : Layout,
  index_ : Int,
) -> (Rectangle, Rectangle) {
  let __out_weak_pos = Ref(Rectangle::_zero())
  let __result = moonbit_pango_layout_get_caret_pos(
    self, index_, __out_weak_pos,
  )
  (__result, __out_weak_pos.val)
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_character_count.html).
#borrow(self)
pub extern "c" fn Layout::get_character_count(self : Layout) -> Int = "moonbit_pango_layout_get_character_count"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_context.html).
#borrow(self)
pub extern "c" fn Layout::get_context(self : Layout) -> Context = "moonbit_pango_layout_get_context"

///|
#borrow(self_, __out_weak_pos)
extern "c" fn moonbit_pango_layout_get_cursor_pos(
  self_ : Layout,
  index_ : Int,
  __out_weak_pos : Ref[Rectangle],
) -> Rectangle = "moonbit_pango_layout_get_cursor_pos"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_cursor_pos.html).
pub fn Layout::get_cursor_pos(
  self : Layout,
  index_ : Int,
) -> (Rectangle, Rectangle) {
  let __out_weak_pos = Ref(Rectangle::_zero())
  let __result = moonbit_pango_layout_get_cursor_pos(
    self, index_, __out_weak_pos,
  )
  (__result, __out_weak_pos.val)
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_direction.html).
#borrow(self)
pub extern "c" fn Layout::get_direction(
  self : Layout,
  index : Int,
) -> Direction = "moonbit_pango_layout_get_direction"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_ellipsize.html).
#borrow(self)
pub extern "c" fn Layout::get_ellipsize(self : Layout) -> EllipsizeMode = "moonbit_pango_layout_get_ellipsize"

///|
#borrow(self_, __out_logical_rect)
extern "c" fn moonbit_pango_layout_get_extents(
  self_ : Layout,
  __out_logical_rect : Ref[Rectangle],
) -> Rectangle = "moonbit_pango_layout_get_extents"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_extents.html).
pub fn Layout::get_extents(self : Layout) -> (Rectangle, Rectangle) {
  let __out_logical_rect = Ref(Rectangle::_zero())
  let __result = moonbit_pango_layout_get_extents(self, __out_logical_rect)
  (__result, __out_logical_rect.val)
}

///|
#borrow(self_)
extern "c" fn moonbit_pango_layout_get_font_description(
  self_ : Layout,
) -> @glib.Nullable[FontDescription] = "moonbit_pango_layout_get_font_description"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_font_description.html).
pub fn Layout::get_font_description(self : Layout) -> FontDescription? {
  let raw_result = moonbit_pango_layout_get_font_description(self)
  raw_result.to_option()
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_height.html).
#borrow(self)
pub extern "c" fn Layout::get_height(self : Layout) -> Int = "moonbit_pango_layout_get_height"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_indent.html).
#borrow(self)
pub extern "c" fn Layout::get_indent(self : Layout) -> Int = "moonbit_pango_layout_get_indent"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_iter.html).
#borrow(self)
pub extern "c" fn Layout::get_iter(self : Layout) -> LayoutIter = "moonbit_pango_layout_get_iter"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_justify.html).
#borrow(self)
pub extern "c" fn Layout::get_justify(self : Layout) -> Bool = "moonbit_pango_layout_get_justify"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_justify_last_line.html).
#borrow(self)
pub extern "c" fn Layout::get_justify_last_line(self : Layout) -> Bool = "moonbit_pango_layout_get_justify_last_line"

///|
#borrow(self_)
extern "c" fn moonbit_pango_layout_get_line(
  self_ : Layout,
  line : Int,
) -> @glib.Nullable[LayoutLine] = "moonbit_pango_layout_get_line"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_line.html).
pub fn Layout::get_line(self : Layout, line : Int) -> LayoutLine? {
  let raw_result = moonbit_pango_layout_get_line(self, line)
  raw_result.to_option()
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_line_count.html).
#borrow(self)
pub extern "c" fn Layout::get_line_count(self : Layout) -> Int = "moonbit_pango_layout_get_line_count"

///|
#borrow(self_)
extern "c" fn moonbit_pango_layout_get_line_readonly(
  self_ : Layout,
  line : Int,
) -> @glib.Nullable[LayoutLine] = "moonbit_pango_layout_get_line_readonly"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_line_readonly.html).
pub fn Layout::get_line_readonly(self : Layout, line : Int) -> LayoutLine? {
  let raw_result = moonbit_pango_layout_get_line_readonly(self, line)
  raw_result.to_option()
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_line_spacing.html).
#borrow(self)
pub extern "c" fn Layout::get_line_spacing(self : Layout) -> Float = "moonbit_pango_layout_get_line_spacing"

///|
#borrow(self_, result)
extern "c" fn moonbit_pango_layout_get_lines(
  self_ : Layout,
  result : Ref[FixedArray[LayoutLine]],
) = "moonbit_pango_layout_get_lines"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_lines.html).
pub fn Layout::get_lines(self : Layout) -> Array[LayoutLine] {
  let result_ref : Ref[FixedArray[LayoutLine]] = Ref([])
  moonbit_pango_layout_get_lines(self, result_ref)
  let values : Array[LayoutLine] = Array::new(capacity=result_ref.val.length())
  for value in result_ref.val {
    values.push(value)
  }
  values
}

///|
#borrow(self_, result)
extern "c" fn moonbit_pango_layout_get_lines_readonly(
  self_ : Layout,
  result : Ref[FixedArray[LayoutLine]],
) = "moonbit_pango_layout_get_lines_readonly"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_lines_readonly.html).
pub fn Layout::get_lines_readonly(self : Layout) -> Array[LayoutLine] {
  let result_ref : Ref[FixedArray[LayoutLine]] = Ref([])
  moonbit_pango_layout_get_lines_readonly(self, result_ref)
  let values : Array[LayoutLine] = Array::new(capacity=result_ref.val.length())
  for value in result_ref.val {
    values.push(value)
  }
  values
}

///|
#borrow(self_, attrs)
extern "c" fn moonbit_pango_layout_get_log_attrs(
  self_ : Layout,
  attrs : Ref[FixedArray[LogAttr]],
) = "moonbit_pango_layout_get_log_attrs"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_log_attrs.html).
pub fn Layout::get_log_attrs(self : Layout) -> Array[LogAttr] {
  let attrs : Ref[FixedArray[LogAttr]] = Ref([])
  moonbit_pango_layout_get_log_attrs(self, attrs)
  let result : Array[LogAttr] = Array::new(capacity=attrs.val.length())
  for i in 0.. Array[LogAttr] {
  let result_ref : Ref[FixedArray[LogAttr]] = Ref([])
  moonbit_pango_layout_get_log_attrs_readonly(self, result_ref)
  let values : Array[LogAttr] = Array::new(capacity=result_ref.val.length())
  for i in 0.. Rectangle = "moonbit_pango_layout_get_pixel_extents"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_pixel_extents.html).
pub fn Layout::get_pixel_extents(self : Layout) -> (Rectangle, Rectangle) {
  let __out_logical_rect = Ref(Rectangle::_zero())
  let __result = moonbit_pango_layout_get_pixel_extents(
    self, __out_logical_rect,
  )
  (__result, __out_logical_rect.val)
}

///|
#borrow(self_, width, height)
extern "c" fn moonbit_pango_layout_get_pixel_size(
  self_ : Layout,
  width : Ref[Int],
  height : Ref[Int],
) = "moonbit_pango_layout_get_pixel_size"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_pixel_size.html).
pub fn Layout::get_pixel_size(self : Layout) -> (Int, Int) {
  let width = Ref(0)
  let height = Ref(0)
  moonbit_pango_layout_get_pixel_size(self, width, height)
  (width.val, height.val)
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_serial.html).
#borrow(self)
pub extern "c" fn Layout::get_serial(self : Layout) -> UInt = "moonbit_pango_layout_get_serial"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_single_paragraph_mode.html).
#borrow(self)
pub extern "c" fn Layout::get_single_paragraph_mode(self : Layout) -> Bool = "moonbit_pango_layout_get_single_paragraph_mode"

///|
#borrow(self_, width, height)
extern "c" fn moonbit_pango_layout_get_size(
  self_ : Layout,
  width : Ref[Int],
  height : Ref[Int],
) = "moonbit_pango_layout_get_size"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_size.html).
pub fn Layout::get_size(self : Layout) -> (Int, Int) {
  let width = Ref(0)
  let height = Ref(0)
  moonbit_pango_layout_get_size(self, width, height)
  (width.val, height.val)
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_spacing.html).
#borrow(self)
pub extern "c" fn Layout::get_spacing(self : Layout) -> Int = "moonbit_pango_layout_get_spacing"

///|
#borrow(self_)
extern "c" fn moonbit_pango_layout_get_tabs(
  self_ : Layout,
) -> @glib.Nullable[TabArray] = "moonbit_pango_layout_get_tabs"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_tabs.html).
pub fn Layout::get_tabs(self : Layout) -> TabArray? {
  let raw_result = moonbit_pango_layout_get_tabs(self)
  raw_result.to_option()
}

///|
#borrow(self_)
extern "c" fn moonbit_pango_layout_get_text(self_ : Layout) -> Bytes = "moonbit_pango_layout_get_text"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_text.html).
pub fn Layout::get_text(self : Layout) -> String {
  @encoding/utf8.decode_lossy(moonbit_pango_layout_get_text(self))
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_unknown_glyphs_count.html).
#borrow(self)
pub extern "c" fn Layout::get_unknown_glyphs_count(self : Layout) -> Int = "moonbit_pango_layout_get_unknown_glyphs_count"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_width.html).
#borrow(self)
pub extern "c" fn Layout::get_width(self : Layout) -> Int = "moonbit_pango_layout_get_width"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.get_wrap.html).
#borrow(self)
pub extern "c" fn Layout::get_wrap(self : Layout) -> WrapMode = "moonbit_pango_layout_get_wrap"

///|
#borrow(self_, line, x_pos)
extern "c" fn moonbit_pango_layout_index_to_line_x(
  self_ : Layout,
  index_ : Int,
  trailing : Bool,
  line : Ref[Int],
  x_pos : Ref[Int],
) = "moonbit_pango_layout_index_to_line_x"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.index_to_line_x.html).
pub fn Layout::index_to_line_x(
  self : Layout,
  index_ : Int,
  trailing : Bool,
) -> (Int, Int) {
  let line = Ref(0)
  let x_pos = Ref(0)
  moonbit_pango_layout_index_to_line_x(self, index_, trailing, line, x_pos)
  (line.val, x_pos.val)
}

///|
#borrow(self_)
extern "c" fn moonbit_pango_layout_index_to_pos(
  self_ : Layout,
  index_ : Int,
) -> Rectangle = "moonbit_pango_layout_index_to_pos"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.index_to_pos.html).
pub fn Layout::index_to_pos(self : Layout, index_ : Int) -> Rectangle {
  let __result = moonbit_pango_layout_index_to_pos(self, index_)
  __result
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.is_ellipsized.html).
#borrow(self)
pub extern "c" fn Layout::is_ellipsized(self : Layout) -> Bool = "moonbit_pango_layout_is_ellipsized"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.is_wrapped.html).
#borrow(self)
pub extern "c" fn Layout::is_wrapped(self : Layout) -> Bool = "moonbit_pango_layout_is_wrapped"

///|
#borrow(self_, new_index, new_trailing)
extern "c" fn moonbit_pango_layout_move_cursor_visually(
  self_ : Layout,
  strong : Bool,
  old_index : Int,
  old_trailing : Int,
  direction : Int,
  new_index : Ref[Int],
  new_trailing : Ref[Int],
) = "moonbit_pango_layout_move_cursor_visually"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.move_cursor_visually.html).
pub fn Layout::move_cursor_visually(
  self : Layout,
  strong : Bool,
  old_index : Int,
  old_trailing : Int,
  direction : Int,
) -> (Int, Int) {
  let new_index = Ref(0)
  let new_trailing = Ref(0)
  moonbit_pango_layout_move_cursor_visually(
    self, strong, old_index, old_trailing, direction, new_index, new_trailing,
  )
  (new_index.val, new_trailing.val)
}

///|
#borrow(self_)
extern "c" fn moonbit_pango_layout_serialize(
  self_ : Layout,
  flags : Int,
) -> Bytes = "moonbit_pango_layout_serialize"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.serialize.html).
pub fn Layout::serialize(self : Layout, flags : LayoutSerializeFlags) -> Bytes {
  moonbit_pango_layout_serialize(self, flags.to_int())
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_alignment.html).
#borrow(self)
pub extern "c" fn Layout::set_alignment(self : Layout, alignment : Alignment) = "moonbit_pango_layout_set_alignment"

///|
#borrow(self_, attrs)
extern "c" fn moonbit_pango_layout_set_attributes(
  self_ : Layout,
  attrs : @glib.Nullable[AttrList],
) = "moonbit_pango_layout_set_attributes"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_attributes.html).
pub fn Layout::set_attributes(self : Layout, attrs : AttrList?) -> Unit {
  moonbit_pango_layout_set_attributes(
    self,
    match attrs {
      Some(v) => @glib.Nullable::some(v)
      None => @glib.Nullable::null()
    },
  )
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_auto_dir.html).
#borrow(self)
pub extern "c" fn Layout::set_auto_dir(self : Layout, auto_dir : Bool) = "moonbit_pango_layout_set_auto_dir"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_ellipsize.html).
#borrow(self)
pub extern "c" fn Layout::set_ellipsize(
  self : Layout,
  ellipsize : EllipsizeMode,
) = "moonbit_pango_layout_set_ellipsize"

///|
#borrow(self_, desc)
extern "c" fn moonbit_pango_layout_set_font_description(
  self_ : Layout,
  desc : @glib.Nullable[FontDescription],
) = "moonbit_pango_layout_set_font_description"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_font_description.html).
pub fn Layout::set_font_description(
  self : Layout,
  desc : FontDescription?,
) -> Unit {
  moonbit_pango_layout_set_font_description(
    self,
    match desc {
      Some(v) => @glib.Nullable::some(v)
      None => @glib.Nullable::null()
    },
  )
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_height.html).
#borrow(self)
pub extern "c" fn Layout::set_height(self : Layout, height : Int) = "moonbit_pango_layout_set_height"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_indent.html).
#borrow(self)
pub extern "c" fn Layout::set_indent(self : Layout, indent : Int) = "moonbit_pango_layout_set_indent"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_justify.html).
#borrow(self)
pub extern "c" fn Layout::set_justify(self : Layout, justify : Bool) = "moonbit_pango_layout_set_justify"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_justify_last_line.html).
#borrow(self)
pub extern "c" fn Layout::set_justify_last_line(self : Layout, justify : Bool) = "moonbit_pango_layout_set_justify_last_line"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_line_spacing.html).
#borrow(self)
pub extern "c" fn Layout::set_line_spacing(self : Layout, factor : Float) = "moonbit_pango_layout_set_line_spacing"

///|
#borrow(self_, markup)
extern "c" fn moonbit_pango_layout_set_markup(
  self_ : Layout,
  markup : Bytes,
  length : Int,
) = "moonbit_pango_layout_set_markup"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_markup.html).
pub fn Layout::set_markup(self : Layout, markup : String, length : Int) -> Unit {
  moonbit_pango_layout_set_markup(self, @encoding/utf8.encode(markup), length)
}

///|
#borrow(self_, markup, accel_char)
extern "c" fn moonbit_pango_layout_set_markup_with_accel(
  self_ : Layout,
  markup : Bytes,
  length : Int,
  accel_marker : UInt,
  accel_char : Ref[UInt],
) = "moonbit_pango_layout_set_markup_with_accel"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_markup_with_accel.html).
pub fn Layout::set_markup_with_accel(
  self : Layout,
  markup : String,
  length : Int,
  accel_marker : UInt,
) -> UInt {
  let accel_char = Ref(0U)
  moonbit_pango_layout_set_markup_with_accel(
    self,
    @encoding/utf8.encode(markup),
    length,
    accel_marker,
    accel_char,
  )
  accel_char.val
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_single_paragraph_mode.html).
#borrow(self)
pub extern "c" fn Layout::set_single_paragraph_mode(
  self : Layout,
  setting : Bool,
) = "moonbit_pango_layout_set_single_paragraph_mode"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_spacing.html).
#borrow(self)
pub extern "c" fn Layout::set_spacing(self : Layout, spacing : Int) = "moonbit_pango_layout_set_spacing"

///|
#borrow(self_, tabs)
extern "c" fn moonbit_pango_layout_set_tabs(
  self_ : Layout,
  tabs : @glib.Nullable[TabArray],
) = "moonbit_pango_layout_set_tabs"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_tabs.html).
pub fn Layout::set_tabs(self : Layout, tabs : TabArray?) -> Unit {
  moonbit_pango_layout_set_tabs(
    self,
    match tabs {
      Some(v) => @glib.Nullable::some(v)
      None => @glib.Nullable::null()
    },
  )
}

///|
#borrow(self_, text)
extern "c" fn moonbit_pango_layout_set_text(
  self_ : Layout,
  text : Bytes,
  length : Int,
) = "moonbit_pango_layout_set_text"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_text.html).
pub fn Layout::set_text(self : Layout, text : String, length : Int) -> Unit {
  moonbit_pango_layout_set_text(self, @encoding/utf8.encode(text), length)
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_width.html).
#borrow(self)
pub extern "c" fn Layout::set_width(self : Layout, width : Int) = "moonbit_pango_layout_set_width"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.set_wrap.html).
#borrow(self)
pub extern "c" fn Layout::set_wrap(self : Layout, wrap : WrapMode) = "moonbit_pango_layout_set_wrap"

///|
#borrow(self_, filename, error)
extern "c" fn moonbit_pango_layout_write_to_file(
  self_ : Layout,
  flags : Int,
  filename : Bytes,
  error : Ref[@glib.Nullable[@glib.Error_]],
) -> Bool = "moonbit_pango_layout_write_to_file"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.write_to_file.html).
pub fn Layout::write_to_file(
  self : Layout,
  flags : LayoutSerializeFlags,
  filename : String,
) -> Bool raise @glib.Error_ {
  let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
  let result = moonbit_pango_layout_write_to_file(
    self,
    flags.to_int(),
    @encoding/utf8.encode(filename),
    error_,
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  result
}

///|
#borrow(self_, index_, trailing)
extern "c" fn moonbit_pango_layout_xy_to_index(
  self_ : Layout,
  x : Int,
  y : Int,
  index_ : Ref[Int],
  trailing : Ref[Int],
) -> Bool = "moonbit_pango_layout_xy_to_index"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Layout.xy_to_index.html).
pub fn Layout::xy_to_index(self : Layout, x : Int, y : Int) -> (Bool, Int, Int) {
  let index_ = Ref(0)
  let trailing = Ref(0)
  let result = moonbit_pango_layout_xy_to_index(self, x, y, index_, trailing)
  (result, index_.val, trailing.val)
}

///|
impl ILayout with fn context_changed(self) -> Unit {
  self.as_layout().context_changed()
}

///|
impl ILayout with fn copy(self) -> Layout {
  self.as_layout().copy()
}

///|
impl ILayout with fn get_alignment(self) -> Alignment {
  self.as_layout().get_alignment()
}

///|
impl ILayout with fn get_attributes(self) -> AttrList? {
  self.as_layout().get_attributes()
}

///|
impl ILayout with fn get_auto_dir(self) -> Bool {
  self.as_layout().get_auto_dir()
}

///|
impl ILayout with fn get_baseline(self) -> Int {
  self.as_layout().get_baseline()
}

///|
impl ILayout with fn get_caret_pos(self, index_) -> (Rectangle, Rectangle) {
  self.as_layout().get_caret_pos(index_)
}

///|
impl ILayout with fn get_character_count(self) -> Int {
  self.as_layout().get_character_count()
}

///|
impl ILayout with fn get_context(self) -> Context {
  self.as_layout().get_context()
}

///|
impl ILayout with fn get_cursor_pos(self, index_) -> (Rectangle, Rectangle) {
  self.as_layout().get_cursor_pos(index_)
}

///|
impl ILayout with fn get_direction(self, index) -> Direction {
  self.as_layout().get_direction(index)
}

///|
impl ILayout with fn get_ellipsize(self) -> EllipsizeMode {
  self.as_layout().get_ellipsize()
}

///|
impl ILayout with fn get_extents(self) -> (Rectangle, Rectangle) {
  self.as_layout().get_extents()
}

///|
impl ILayout with fn get_font_description(self) -> FontDescription? {
  self.as_layout().get_font_description()
}

///|
impl ILayout with fn get_height(self) -> Int {
  self.as_layout().get_height()
}

///|
impl ILayout with fn get_indent(self) -> Int {
  self.as_layout().get_indent()
}

///|
impl ILayout with fn get_iter(self) -> LayoutIter {
  self.as_layout().get_iter()
}

///|
impl ILayout with fn get_justify(self) -> Bool {
  self.as_layout().get_justify()
}

///|
impl ILayout with fn get_justify_last_line(self) -> Bool {
  self.as_layout().get_justify_last_line()
}

///|
impl ILayout with fn get_line(self, line) -> LayoutLine? {
  self.as_layout().get_line(line)
}

///|
impl ILayout with fn get_line_count(self) -> Int {
  self.as_layout().get_line_count()
}

///|
impl ILayout with fn get_line_readonly(self, line) -> LayoutLine? {
  self.as_layout().get_line_readonly(line)
}

///|
impl ILayout with fn get_line_spacing(self) -> Float {
  self.as_layout().get_line_spacing()
}

///|
impl ILayout with fn get_lines(self) -> Array[LayoutLine] {
  self.as_layout().get_lines()
}

///|
impl ILayout with fn get_lines_readonly(self) -> Array[LayoutLine] {
  self.as_layout().get_lines_readonly()
}

///|
impl ILayout with fn get_log_attrs(self) -> Array[LogAttr] {
  self.as_layout().get_log_attrs()
}

///|
impl ILayout with fn get_log_attrs_readonly(self) -> Array[LogAttr] {
  self.as_layout().get_log_attrs_readonly()
}

///|
impl ILayout with fn get_pixel_extents(self) -> (Rectangle, Rectangle) {
  self.as_layout().get_pixel_extents()
}

///|
impl ILayout with fn get_pixel_size(self) -> (Int, Int) {
  self.as_layout().get_pixel_size()
}

///|
impl ILayout with fn get_serial(self) -> UInt {
  self.as_layout().get_serial()
}

///|
impl ILayout with fn get_single_paragraph_mode(self) -> Bool {
  self.as_layout().get_single_paragraph_mode()
}

///|
impl ILayout with fn get_size(self) -> (Int, Int) {
  self.as_layout().get_size()
}

///|
impl ILayout with fn get_spacing(self) -> Int {
  self.as_layout().get_spacing()
}

///|
impl ILayout with fn get_tabs(self) -> TabArray? {
  self.as_layout().get_tabs()
}

///|
impl ILayout with fn get_text(self) -> String {
  self.as_layout().get_text()
}

///|
impl ILayout with fn get_unknown_glyphs_count(self) -> Int {
  self.as_layout().get_unknown_glyphs_count()
}

///|
impl ILayout with fn get_width(self) -> Int {
  self.as_layout().get_width()
}

///|
impl ILayout with fn get_wrap(self) -> WrapMode {
  self.as_layout().get_wrap()
}

///|
impl ILayout with fn index_to_line_x(self, index_, trailing) -> (Int, Int) {
  self.as_layout().index_to_line_x(index_, trailing)
}

///|
impl ILayout with fn index_to_pos(self, index_) -> Rectangle {
  self.as_layout().index_to_pos(index_)
}

///|
impl ILayout with fn is_ellipsized(self) -> Bool {
  self.as_layout().is_ellipsized()
}

///|
impl ILayout with fn is_wrapped(self) -> Bool {
  self.as_layout().is_wrapped()
}

///|
impl ILayout with fn move_cursor_visually(
  self,
  strong,
  old_index,
  old_trailing,
  direction,
) -> (Int, Int) {
  self
  .as_layout()
  .move_cursor_visually(strong, old_index, old_trailing, direction)
}

///|
impl ILayout with fn serialize(self, flags) -> Bytes {
  self.as_layout().serialize(flags)
}

///|
impl ILayout with fn set_alignment(self, alignment) -> Unit {
  self.as_layout().set_alignment(alignment)
}

///|
impl ILayout with fn set_attributes(self, attrs) -> Unit {
  self.as_layout().set_attributes(attrs)
}

///|
impl ILayout with fn set_auto_dir(self, auto_dir) -> Unit {
  self.as_layout().set_auto_dir(auto_dir)
}

///|
impl ILayout with fn set_ellipsize(self, ellipsize) -> Unit {
  self.as_layout().set_ellipsize(ellipsize)
}

///|
impl ILayout with fn set_font_description(self, desc) -> Unit {
  self.as_layout().set_font_description(desc)
}

///|
impl ILayout with fn set_height(self, height) -> Unit {
  self.as_layout().set_height(height)
}

///|
impl ILayout with fn set_indent(self, indent) -> Unit {
  self.as_layout().set_indent(indent)
}

///|
impl ILayout with fn set_justify(self, justify) -> Unit {
  self.as_layout().set_justify(justify)
}

///|
impl ILayout with fn set_justify_last_line(self, justify) -> Unit {
  self.as_layout().set_justify_last_line(justify)
}

///|
impl ILayout with fn set_line_spacing(self, factor) -> Unit {
  self.as_layout().set_line_spacing(factor)
}

///|
impl ILayout with fn set_markup(self, markup, length) -> Unit {
  self.as_layout().set_markup(markup, length)
}

///|
impl ILayout with fn set_markup_with_accel(self, markup, length, accel_marker) -> UInt {
  self.as_layout().set_markup_with_accel(markup, length, accel_marker)
}

///|
impl ILayout with fn set_single_paragraph_mode(self, setting) -> Unit {
  self.as_layout().set_single_paragraph_mode(setting)
}

///|
impl ILayout with fn set_spacing(self, spacing) -> Unit {
  self.as_layout().set_spacing(spacing)
}

///|
impl ILayout with fn set_tabs(self, tabs) -> Unit {
  self.as_layout().set_tabs(tabs)
}

///|
impl ILayout with fn set_text(self, text, length) -> Unit {
  self.as_layout().set_text(text, length)
}

///|
impl ILayout with fn set_width(self, width) -> Unit {
  self.as_layout().set_width(width)
}

///|
impl ILayout with fn set_wrap(self, wrap) -> Unit {
  self.as_layout().set_wrap(wrap)
}

///|
impl ILayout with fn write_to_file(self, flags, filename) -> Bool raise @glib.Error_ {
  self.as_layout().write_to_file(flags, filename)
}

///|
impl ILayout with fn xy_to_index(self, x, y) -> (Bool, Int, Int) {
  self.as_layout().xy_to_index(x, y)
}

///|
pub fn Layout::as_gobject_object(self : Layout) -> @gobject.Object = "%identity"

///|
pub impl @gobject.IObject for Layout with fn as_object(self) {
  self.as_gobject_object()
}