use CellAreaContext;
use CellEditable;
use CellLayout;
use CellRenderer;
use CellRendererState;
use DirectionType;
use Orientation;
use SizeRequestMode;
use TreeIter;
use TreeModel;
use Widget;
use cairo;
use ffi;
use gdk;
use glib::object::IsA;
use glib::translate::*;
use std::mem;
glib_wrapper! {
pub struct CellArea(Object<ffi::GtkCellArea>): CellLayout;
match fn {
get_type => || ffi::gtk_cell_area_get_type(),
}
}
pub trait CellAreaExt {
fn activate<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T, cell_area: &gdk::Rectangle, flags: CellRendererState, edit_only: bool) -> bool;
fn activate_cell<T: IsA<Widget>, U: IsA<CellRenderer>>(&self, widget: &T, renderer: &U, event: &gdk::Event, cell_area: &gdk::Rectangle, flags: CellRendererState) -> bool;
fn add<T: IsA<CellRenderer>>(&self, renderer: &T);
fn add_focus_sibling<T: IsA<CellRenderer>, U: IsA<CellRenderer>>(&self, renderer: &T, sibling: &U);
fn apply_attributes<T: IsA<TreeModel>>(&self, tree_model: &T, iter: &TreeIter, is_expander: bool, is_expanded: bool);
fn attribute_connect<T: IsA<CellRenderer>>(&self, renderer: &T, attribute: &str, column: i32);
fn attribute_disconnect<T: IsA<CellRenderer>>(&self, renderer: &T, attribute: &str);
#[cfg(feature = "v3_14")]
fn attribute_get_column<T: IsA<CellRenderer>>(&self, renderer: &T, attribute: &str) -> i32;
fn copy_context(&self, context: &CellAreaContext) -> Option<CellAreaContext>;
fn create_context(&self) -> Option<CellAreaContext>;
fn event<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T, event: &gdk::Event, cell_area: &gdk::Rectangle, flags: CellRendererState) -> i32;
fn focus(&self, direction: DirectionType) -> bool;
fn get_cell_allocation<T: IsA<Widget>, U: IsA<CellRenderer>>(&self, context: &CellAreaContext, widget: &T, renderer: &U, cell_area: &gdk::Rectangle) -> gdk::Rectangle;
fn get_cell_at_position<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T, cell_area: &gdk::Rectangle, x: i32, y: i32) -> (CellRenderer, gdk::Rectangle);
fn get_current_path_string(&self) -> Option<String>;
fn get_edit_widget(&self) -> Option<CellEditable>;
fn get_edited_cell(&self) -> Option<CellRenderer>;
fn get_focus_cell(&self) -> Option<CellRenderer>;
fn get_focus_from_sibling<T: IsA<CellRenderer>>(&self, renderer: &T) -> Option<CellRenderer>;
fn get_focus_siblings<T: IsA<CellRenderer>>(&self, renderer: &T) -> Vec<CellRenderer>;
fn get_preferred_height<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T) -> (i32, i32);
fn get_preferred_height_for_width<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T, width: i32) -> (i32, i32);
fn get_preferred_width<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T) -> (i32, i32);
fn get_preferred_width_for_height<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T, height: i32) -> (i32, i32);
fn get_request_mode(&self) -> SizeRequestMode;
fn has_renderer<T: IsA<CellRenderer>>(&self, renderer: &T) -> bool;
fn inner_cell_area<T: IsA<Widget>>(&self, widget: &T, cell_area: &gdk::Rectangle) -> gdk::Rectangle;
fn is_activatable(&self) -> bool;
fn is_focus_sibling<T: IsA<CellRenderer>, U: IsA<CellRenderer>>(&self, renderer: &T, sibling: &U) -> bool;
fn remove<T: IsA<CellRenderer>>(&self, renderer: &T);
fn remove_focus_sibling<T: IsA<CellRenderer>, U: IsA<CellRenderer>>(&self, renderer: &T, sibling: &U);
fn render<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T, cr: &cairo::Context, background_area: &gdk::Rectangle, cell_area: &gdk::Rectangle, flags: CellRendererState, paint_focus: bool);
fn request_renderer<T: IsA<CellRenderer>, U: IsA<Widget>>(&self, renderer: &T, orientation: Orientation, widget: &U, for_size: i32) -> (i32, i32);
fn set_focus_cell<T: IsA<CellRenderer>>(&self, renderer: &T);
fn stop_editing(&self, canceled: bool);
}
impl<O: IsA<CellArea>> CellAreaExt for O {
fn activate<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T, cell_area: &gdk::Rectangle, flags: CellRendererState, edit_only: bool) -> bool {
unsafe {
from_glib(ffi::gtk_cell_area_activate(self.to_glib_none().0, context.to_glib_none().0, widget.to_glib_none().0, cell_area.to_glib_none().0, flags.to_glib(), edit_only.to_glib()))
}
}
fn activate_cell<T: IsA<Widget>, U: IsA<CellRenderer>>(&self, widget: &T, renderer: &U, event: &gdk::Event, cell_area: &gdk::Rectangle, flags: CellRendererState) -> bool {
unsafe {
from_glib(ffi::gtk_cell_area_activate_cell(self.to_glib_none().0, widget.to_glib_none().0, renderer.to_glib_none().0, mut_override(event.to_glib_none().0), cell_area.to_glib_none().0, flags.to_glib()))
}
}
fn add<T: IsA<CellRenderer>>(&self, renderer: &T) {
unsafe {
ffi::gtk_cell_area_add(self.to_glib_none().0, renderer.to_glib_none().0);
}
}
fn add_focus_sibling<T: IsA<CellRenderer>, U: IsA<CellRenderer>>(&self, renderer: &T, sibling: &U) {
unsafe {
ffi::gtk_cell_area_add_focus_sibling(self.to_glib_none().0, renderer.to_glib_none().0, sibling.to_glib_none().0);
}
}
fn apply_attributes<T: IsA<TreeModel>>(&self, tree_model: &T, iter: &TreeIter, is_expander: bool, is_expanded: bool) {
unsafe {
ffi::gtk_cell_area_apply_attributes(self.to_glib_none().0, tree_model.to_glib_none().0, mut_override(iter.to_glib_none().0), is_expander.to_glib(), is_expanded.to_glib());
}
}
fn attribute_connect<T: IsA<CellRenderer>>(&self, renderer: &T, attribute: &str, column: i32) {
unsafe {
ffi::gtk_cell_area_attribute_connect(self.to_glib_none().0, renderer.to_glib_none().0, attribute.to_glib_none().0, column);
}
}
fn attribute_disconnect<T: IsA<CellRenderer>>(&self, renderer: &T, attribute: &str) {
unsafe {
ffi::gtk_cell_area_attribute_disconnect(self.to_glib_none().0, renderer.to_glib_none().0, attribute.to_glib_none().0);
}
}
#[cfg(feature = "v3_14")]
fn attribute_get_column<T: IsA<CellRenderer>>(&self, renderer: &T, attribute: &str) -> i32 {
unsafe {
ffi::gtk_cell_area_attribute_get_column(self.to_glib_none().0, renderer.to_glib_none().0, attribute.to_glib_none().0)
}
}
fn copy_context(&self, context: &CellAreaContext) -> Option<CellAreaContext> {
unsafe {
from_glib_full(ffi::gtk_cell_area_copy_context(self.to_glib_none().0, context.to_glib_none().0))
}
}
fn create_context(&self) -> Option<CellAreaContext> {
unsafe {
from_glib_full(ffi::gtk_cell_area_create_context(self.to_glib_none().0))
}
}
fn event<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T, event: &gdk::Event, cell_area: &gdk::Rectangle, flags: CellRendererState) -> i32 {
unsafe {
ffi::gtk_cell_area_event(self.to_glib_none().0, context.to_glib_none().0, widget.to_glib_none().0, mut_override(event.to_glib_none().0), cell_area.to_glib_none().0, flags.to_glib())
}
}
fn focus(&self, direction: DirectionType) -> bool {
unsafe {
from_glib(ffi::gtk_cell_area_focus(self.to_glib_none().0, direction.to_glib()))
}
}
fn get_cell_allocation<T: IsA<Widget>, U: IsA<CellRenderer>>(&self, context: &CellAreaContext, widget: &T, renderer: &U, cell_area: &gdk::Rectangle) -> gdk::Rectangle {
unsafe {
let mut allocation = gdk::Rectangle::uninitialized();
ffi::gtk_cell_area_get_cell_allocation(self.to_glib_none().0, context.to_glib_none().0, widget.to_glib_none().0, renderer.to_glib_none().0, cell_area.to_glib_none().0, allocation.to_glib_none_mut().0);
allocation
}
}
fn get_cell_at_position<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T, cell_area: &gdk::Rectangle, x: i32, y: i32) -> (CellRenderer, gdk::Rectangle) {
unsafe {
let mut alloc_area = gdk::Rectangle::uninitialized();
let ret = from_glib_none(ffi::gtk_cell_area_get_cell_at_position(self.to_glib_none().0, context.to_glib_none().0, widget.to_glib_none().0, cell_area.to_glib_none().0, x, y, alloc_area.to_glib_none_mut().0));
(ret, alloc_area)
}
}
fn get_current_path_string(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::gtk_cell_area_get_current_path_string(self.to_glib_none().0))
}
}
fn get_edit_widget(&self) -> Option<CellEditable> {
unsafe {
from_glib_none(ffi::gtk_cell_area_get_edit_widget(self.to_glib_none().0))
}
}
fn get_edited_cell(&self) -> Option<CellRenderer> {
unsafe {
from_glib_none(ffi::gtk_cell_area_get_edited_cell(self.to_glib_none().0))
}
}
fn get_focus_cell(&self) -> Option<CellRenderer> {
unsafe {
from_glib_none(ffi::gtk_cell_area_get_focus_cell(self.to_glib_none().0))
}
}
fn get_focus_from_sibling<T: IsA<CellRenderer>>(&self, renderer: &T) -> Option<CellRenderer> {
unsafe {
from_glib_none(ffi::gtk_cell_area_get_focus_from_sibling(self.to_glib_none().0, renderer.to_glib_none().0))
}
}
fn get_focus_siblings<T: IsA<CellRenderer>>(&self, renderer: &T) -> Vec<CellRenderer> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::gtk_cell_area_get_focus_siblings(self.to_glib_none().0, renderer.to_glib_none().0))
}
}
fn get_preferred_height<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T) -> (i32, i32) {
unsafe {
let mut minimum_height = mem::uninitialized();
let mut natural_height = mem::uninitialized();
ffi::gtk_cell_area_get_preferred_height(self.to_glib_none().0, context.to_glib_none().0, widget.to_glib_none().0, &mut minimum_height, &mut natural_height);
(minimum_height, natural_height)
}
}
fn get_preferred_height_for_width<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T, width: i32) -> (i32, i32) {
unsafe {
let mut minimum_height = mem::uninitialized();
let mut natural_height = mem::uninitialized();
ffi::gtk_cell_area_get_preferred_height_for_width(self.to_glib_none().0, context.to_glib_none().0, widget.to_glib_none().0, width, &mut minimum_height, &mut natural_height);
(minimum_height, natural_height)
}
}
fn get_preferred_width<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T) -> (i32, i32) {
unsafe {
let mut minimum_width = mem::uninitialized();
let mut natural_width = mem::uninitialized();
ffi::gtk_cell_area_get_preferred_width(self.to_glib_none().0, context.to_glib_none().0, widget.to_glib_none().0, &mut minimum_width, &mut natural_width);
(minimum_width, natural_width)
}
}
fn get_preferred_width_for_height<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T, height: i32) -> (i32, i32) {
unsafe {
let mut minimum_width = mem::uninitialized();
let mut natural_width = mem::uninitialized();
ffi::gtk_cell_area_get_preferred_width_for_height(self.to_glib_none().0, context.to_glib_none().0, widget.to_glib_none().0, height, &mut minimum_width, &mut natural_width);
(minimum_width, natural_width)
}
}
fn get_request_mode(&self) -> SizeRequestMode {
unsafe {
from_glib(ffi::gtk_cell_area_get_request_mode(self.to_glib_none().0))
}
}
fn has_renderer<T: IsA<CellRenderer>>(&self, renderer: &T) -> bool {
unsafe {
from_glib(ffi::gtk_cell_area_has_renderer(self.to_glib_none().0, renderer.to_glib_none().0))
}
}
fn inner_cell_area<T: IsA<Widget>>(&self, widget: &T, cell_area: &gdk::Rectangle) -> gdk::Rectangle {
unsafe {
let mut inner_area = gdk::Rectangle::uninitialized();
ffi::gtk_cell_area_inner_cell_area(self.to_glib_none().0, widget.to_glib_none().0, cell_area.to_glib_none().0, inner_area.to_glib_none_mut().0);
inner_area
}
}
fn is_activatable(&self) -> bool {
unsafe {
from_glib(ffi::gtk_cell_area_is_activatable(self.to_glib_none().0))
}
}
fn is_focus_sibling<T: IsA<CellRenderer>, U: IsA<CellRenderer>>(&self, renderer: &T, sibling: &U) -> bool {
unsafe {
from_glib(ffi::gtk_cell_area_is_focus_sibling(self.to_glib_none().0, renderer.to_glib_none().0, sibling.to_glib_none().0))
}
}
fn remove<T: IsA<CellRenderer>>(&self, renderer: &T) {
unsafe {
ffi::gtk_cell_area_remove(self.to_glib_none().0, renderer.to_glib_none().0);
}
}
fn remove_focus_sibling<T: IsA<CellRenderer>, U: IsA<CellRenderer>>(&self, renderer: &T, sibling: &U) {
unsafe {
ffi::gtk_cell_area_remove_focus_sibling(self.to_glib_none().0, renderer.to_glib_none().0, sibling.to_glib_none().0);
}
}
fn render<T: IsA<Widget>>(&self, context: &CellAreaContext, widget: &T, cr: &cairo::Context, background_area: &gdk::Rectangle, cell_area: &gdk::Rectangle, flags: CellRendererState, paint_focus: bool) {
unsafe {
ffi::gtk_cell_area_render(self.to_glib_none().0, context.to_glib_none().0, widget.to_glib_none().0, mut_override(cr.to_glib_none().0), background_area.to_glib_none().0, cell_area.to_glib_none().0, flags.to_glib(), paint_focus.to_glib());
}
}
fn request_renderer<T: IsA<CellRenderer>, U: IsA<Widget>>(&self, renderer: &T, orientation: Orientation, widget: &U, for_size: i32) -> (i32, i32) {
unsafe {
let mut minimum_size = mem::uninitialized();
let mut natural_size = mem::uninitialized();
ffi::gtk_cell_area_request_renderer(self.to_glib_none().0, renderer.to_glib_none().0, orientation.to_glib(), widget.to_glib_none().0, for_size, &mut minimum_size, &mut natural_size);
(minimum_size, natural_size)
}
}
fn set_focus_cell<T: IsA<CellRenderer>>(&self, renderer: &T) {
unsafe {
ffi::gtk_cell_area_set_focus_cell(self.to_glib_none().0, renderer.to_glib_none().0);
}
}
fn stop_editing(&self, canceled: bool) {
unsafe {
ffi::gtk_cell_area_stop_editing(self.to_glib_none().0, canceled.to_glib());
}
}
}