gtk4/auto/
cell_area_context.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4#![allow(deprecated)]
5
6use crate::{ffi, CellArea};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// This object will be removed in GTK 5
16    /// Stores geometrical information for a series of rows in a GtkCellArea
17    ///
18    /// The [`CellAreaContext`][crate::CellAreaContext] object is created by a given [`CellArea`][crate::CellArea]
19    /// implementation via its `GtkCellAreaClass.create_context()` virtual
20    /// method and is used to store cell sizes and alignments for a series of
21    /// [`TreeModel`][crate::TreeModel] rows that are requested and rendered in the same context.
22    ///
23    /// [`CellLayout`][crate::CellLayout] widgets can create any number of contexts in which to
24    /// request and render groups of data rows. However, it’s important that the
25    /// same context which was used to request sizes for a given [`TreeModel`][crate::TreeModel]
26    /// row also be used for the same row when calling other [`CellArea`][crate::CellArea] APIs
27    /// such as gtk_cell_area_render() and gtk_cell_area_event().
28    ///
29    /// ## Properties
30    ///
31    ///
32    /// #### `area`
33    ///  The [`CellArea`][crate::CellArea] this context was created by
34    ///
35    /// Readable | Writeable | Construct Only
36    ///
37    ///
38    /// #### `minimum-height`
39    ///  The minimum height for the [`CellArea`][crate::CellArea] in this context
40    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
41    /// for using gtk_cell_area_get_preferred_height().
42    ///
43    /// Readable
44    ///
45    ///
46    /// #### `minimum-width`
47    ///  The minimum width for the [`CellArea`][crate::CellArea] in this context
48    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
49    /// for using gtk_cell_area_get_preferred_width().
50    ///
51    /// Readable
52    ///
53    ///
54    /// #### `natural-height`
55    ///  The natural height for the [`CellArea`][crate::CellArea] in this context
56    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
57    /// for using gtk_cell_area_get_preferred_height().
58    ///
59    /// Readable
60    ///
61    ///
62    /// #### `natural-width`
63    ///  The natural width for the [`CellArea`][crate::CellArea] in this context
64    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
65    /// for using gtk_cell_area_get_preferred_width().
66    ///
67    /// Readable
68    ///
69    /// # Implements
70    ///
71    /// [`CellAreaContextExt`][trait@crate::prelude::CellAreaContextExt], [`trait@glib::ObjectExt`]
72    #[doc(alias = "GtkCellAreaContext")]
73    pub struct CellAreaContext(Object<ffi::GtkCellAreaContext, ffi::GtkCellAreaContextClass>);
74
75    match fn {
76        type_ => || ffi::gtk_cell_area_context_get_type(),
77    }
78}
79
80impl CellAreaContext {
81    pub const NONE: Option<&'static CellAreaContext> = None;
82}
83
84mod sealed {
85    pub trait Sealed {}
86    impl<T: super::IsA<super::CellAreaContext>> Sealed for T {}
87}
88
89/// Trait containing all [`struct@CellAreaContext`] methods.
90///
91/// # Implementors
92///
93/// [`CellAreaContext`][struct@crate::CellAreaContext]
94pub trait CellAreaContextExt: IsA<CellAreaContext> + sealed::Sealed + 'static {
95    /// Allocates a width and/or a height for all rows which are to be
96    /// rendered with @self.
97    ///
98    /// Usually allocation is performed only horizontally or sometimes
99    /// vertically since a group of rows are usually rendered side by
100    /// side vertically or horizontally and share either the same width
101    /// or the same height. Sometimes they are allocated in both horizontal
102    /// and vertical orientations producing a homogeneous effect of the
103    /// rows. This is generally the case for [`TreeView`][crate::TreeView] when
104    /// `GtkTreeView:fixed-height-mode` is enabled.
105    ///
106    /// # Deprecated since 4.10
107    ///
108    /// This object will be removed in GTK 5
109    /// ## `width`
110    /// the allocated width for all [`TreeModel`][crate::TreeModel] rows rendered
111    ///   with @self, or -1
112    /// ## `height`
113    /// the allocated height for all [`TreeModel`][crate::TreeModel] rows rendered
114    ///   with @self, or -1
115    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
116    #[allow(deprecated)]
117    #[doc(alias = "gtk_cell_area_context_allocate")]
118    fn allocate(&self, width: i32, height: i32) {
119        unsafe {
120            ffi::gtk_cell_area_context_allocate(self.as_ref().to_glib_none().0, width, height);
121        }
122    }
123
124    /// Fetches the current allocation size for @self.
125    ///
126    /// If the context was not allocated in width or height, or if the
127    /// context was recently reset with gtk_cell_area_context_reset(),
128    /// the returned value will be -1.
129    ///
130    /// # Deprecated since 4.10
131    ///
132    /// This object will be removed in GTK 5
133    ///
134    /// # Returns
135    ///
136    ///
137    /// ## `width`
138    /// location to store the allocated width
139    ///
140    /// ## `height`
141    /// location to store the allocated height
142    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
143    #[allow(deprecated)]
144    #[doc(alias = "gtk_cell_area_context_get_allocation")]
145    #[doc(alias = "get_allocation")]
146    fn allocation(&self) -> (i32, i32) {
147        unsafe {
148            let mut width = std::mem::MaybeUninit::uninit();
149            let mut height = std::mem::MaybeUninit::uninit();
150            ffi::gtk_cell_area_context_get_allocation(
151                self.as_ref().to_glib_none().0,
152                width.as_mut_ptr(),
153                height.as_mut_ptr(),
154            );
155            (width.assume_init(), height.assume_init())
156        }
157    }
158
159    /// Fetches the [`CellArea`][crate::CellArea] this @self was created by.
160    ///
161    /// This is generally unneeded by layouting widgets; however,
162    /// it is important for the context implementation itself to
163    /// fetch information about the area it is being used for.
164    ///
165    /// For instance at `GtkCellAreaContextClass.allocate()` time
166    /// it’s important to know details about any cell spacing
167    /// that the [`CellArea`][crate::CellArea] is configured with in order to
168    /// compute a proper allocation.
169    ///
170    /// # Deprecated since 4.10
171    ///
172    /// This object will be removed in GTK 5
173    ///
174    /// # Returns
175    ///
176    /// the [`CellArea`][crate::CellArea] this context was created by.
177    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
178    #[allow(deprecated)]
179    #[doc(alias = "gtk_cell_area_context_get_area")]
180    #[doc(alias = "get_area")]
181    fn area(&self) -> CellArea {
182        unsafe {
183            from_glib_none(ffi::gtk_cell_area_context_get_area(
184                self.as_ref().to_glib_none().0,
185            ))
186        }
187    }
188
189    /// Gets the accumulative preferred height for all rows which have been
190    /// requested with this context.
191    ///
192    /// After gtk_cell_area_context_reset() is called and/or before ever
193    /// requesting the size of a [`CellArea`][crate::CellArea], the returned values are 0.
194    ///
195    /// # Deprecated since 4.10
196    ///
197    /// This object will be removed in GTK 5
198    ///
199    /// # Returns
200    ///
201    ///
202    /// ## `minimum_height`
203    /// location to store the minimum height
204    ///
205    /// ## `natural_height`
206    /// location to store the natural height
207    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
208    #[allow(deprecated)]
209    #[doc(alias = "gtk_cell_area_context_get_preferred_height")]
210    #[doc(alias = "get_preferred_height")]
211    fn preferred_height(&self) -> (i32, i32) {
212        unsafe {
213            let mut minimum_height = std::mem::MaybeUninit::uninit();
214            let mut natural_height = std::mem::MaybeUninit::uninit();
215            ffi::gtk_cell_area_context_get_preferred_height(
216                self.as_ref().to_glib_none().0,
217                minimum_height.as_mut_ptr(),
218                natural_height.as_mut_ptr(),
219            );
220            (minimum_height.assume_init(), natural_height.assume_init())
221        }
222    }
223
224    /// Gets the accumulative preferred height for @width for all rows
225    /// which have been requested for the same said @width with this context.
226    ///
227    /// After gtk_cell_area_context_reset() is called and/or before ever
228    /// requesting the size of a [`CellArea`][crate::CellArea], the returned values are -1.
229    ///
230    /// # Deprecated since 4.10
231    ///
232    /// This object will be removed in GTK 5
233    /// ## `width`
234    /// a proposed width for allocation
235    ///
236    /// # Returns
237    ///
238    ///
239    /// ## `minimum_height`
240    /// location to store the minimum height
241    ///
242    /// ## `natural_height`
243    /// location to store the natural height
244    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
245    #[allow(deprecated)]
246    #[doc(alias = "gtk_cell_area_context_get_preferred_height_for_width")]
247    #[doc(alias = "get_preferred_height_for_width")]
248    fn preferred_height_for_width(&self, width: i32) -> (i32, i32) {
249        unsafe {
250            let mut minimum_height = std::mem::MaybeUninit::uninit();
251            let mut natural_height = std::mem::MaybeUninit::uninit();
252            ffi::gtk_cell_area_context_get_preferred_height_for_width(
253                self.as_ref().to_glib_none().0,
254                width,
255                minimum_height.as_mut_ptr(),
256                natural_height.as_mut_ptr(),
257            );
258            (minimum_height.assume_init(), natural_height.assume_init())
259        }
260    }
261
262    /// Gets the accumulative preferred width for all rows which have been
263    /// requested with this context.
264    ///
265    /// After gtk_cell_area_context_reset() is called and/or before ever
266    /// requesting the size of a [`CellArea`][crate::CellArea], the returned values are 0.
267    ///
268    /// # Deprecated since 4.10
269    ///
270    /// This object will be removed in GTK 5
271    ///
272    /// # Returns
273    ///
274    ///
275    /// ## `minimum_width`
276    /// location to store the minimum width
277    ///
278    /// ## `natural_width`
279    /// location to store the natural width
280    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
281    #[allow(deprecated)]
282    #[doc(alias = "gtk_cell_area_context_get_preferred_width")]
283    #[doc(alias = "get_preferred_width")]
284    fn preferred_width(&self) -> (i32, i32) {
285        unsafe {
286            let mut minimum_width = std::mem::MaybeUninit::uninit();
287            let mut natural_width = std::mem::MaybeUninit::uninit();
288            ffi::gtk_cell_area_context_get_preferred_width(
289                self.as_ref().to_glib_none().0,
290                minimum_width.as_mut_ptr(),
291                natural_width.as_mut_ptr(),
292            );
293            (minimum_width.assume_init(), natural_width.assume_init())
294        }
295    }
296
297    /// Gets the accumulative preferred width for @height for all rows which
298    /// have been requested for the same said @height with this context.
299    ///
300    /// After gtk_cell_area_context_reset() is called and/or before ever
301    /// requesting the size of a [`CellArea`][crate::CellArea], the returned values are -1.
302    ///
303    /// # Deprecated since 4.10
304    ///
305    /// This object will be removed in GTK 5
306    /// ## `height`
307    /// a proposed height for allocation
308    ///
309    /// # Returns
310    ///
311    ///
312    /// ## `minimum_width`
313    /// location to store the minimum width
314    ///
315    /// ## `natural_width`
316    /// location to store the natural width
317    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
318    #[allow(deprecated)]
319    #[doc(alias = "gtk_cell_area_context_get_preferred_width_for_height")]
320    #[doc(alias = "get_preferred_width_for_height")]
321    fn preferred_width_for_height(&self, height: i32) -> (i32, i32) {
322        unsafe {
323            let mut minimum_width = std::mem::MaybeUninit::uninit();
324            let mut natural_width = std::mem::MaybeUninit::uninit();
325            ffi::gtk_cell_area_context_get_preferred_width_for_height(
326                self.as_ref().to_glib_none().0,
327                height,
328                minimum_width.as_mut_ptr(),
329                natural_width.as_mut_ptr(),
330            );
331            (minimum_width.assume_init(), natural_width.assume_init())
332        }
333    }
334
335    /// Causes the minimum and/or natural height to grow if the new
336    /// proposed sizes exceed the current minimum and natural height.
337    ///
338    /// This is used by [`CellAreaContext`][crate::CellAreaContext] implementations during
339    /// the request process over a series of [`TreeModel`][crate::TreeModel] rows to
340    /// progressively push the requested height over a series of
341    /// gtk_cell_area_get_preferred_height() requests.
342    ///
343    /// # Deprecated since 4.10
344    ///
345    /// This object will be removed in GTK 5
346    /// ## `minimum_height`
347    /// the proposed new minimum height for @self
348    /// ## `natural_height`
349    /// the proposed new natural height for @self
350    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
351    #[allow(deprecated)]
352    #[doc(alias = "gtk_cell_area_context_push_preferred_height")]
353    fn push_preferred_height(&self, minimum_height: i32, natural_height: i32) {
354        unsafe {
355            ffi::gtk_cell_area_context_push_preferred_height(
356                self.as_ref().to_glib_none().0,
357                minimum_height,
358                natural_height,
359            );
360        }
361    }
362
363    /// Causes the minimum and/or natural width to grow if the new
364    /// proposed sizes exceed the current minimum and natural width.
365    ///
366    /// This is used by [`CellAreaContext`][crate::CellAreaContext] implementations during
367    /// the request process over a series of [`TreeModel`][crate::TreeModel] rows to
368    /// progressively push the requested width over a series of
369    /// gtk_cell_area_get_preferred_width() requests.
370    ///
371    /// # Deprecated since 4.10
372    ///
373    /// This object will be removed in GTK 5
374    /// ## `minimum_width`
375    /// the proposed new minimum width for @self
376    /// ## `natural_width`
377    /// the proposed new natural width for @self
378    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
379    #[allow(deprecated)]
380    #[doc(alias = "gtk_cell_area_context_push_preferred_width")]
381    fn push_preferred_width(&self, minimum_width: i32, natural_width: i32) {
382        unsafe {
383            ffi::gtk_cell_area_context_push_preferred_width(
384                self.as_ref().to_glib_none().0,
385                minimum_width,
386                natural_width,
387            );
388        }
389    }
390
391    /// Resets any previously cached request and allocation
392    /// data.
393    ///
394    /// When underlying [`TreeModel`][crate::TreeModel] data changes its
395    /// important to reset the context if the content
396    /// size is allowed to shrink. If the content size
397    /// is only allowed to grow (this is usually an option
398    /// for views rendering large data stores as a measure
399    /// of optimization), then only the row that changed
400    /// or was inserted needs to be (re)requested with
401    /// gtk_cell_area_get_preferred_width().
402    ///
403    /// When the new overall size of the context requires
404    /// that the allocated size changes (or whenever this
405    /// allocation changes at all), the variable row
406    /// sizes need to be re-requested for every row.
407    ///
408    /// For instance, if the rows are displayed all with
409    /// the same width from top to bottom then a change
410    /// in the allocated width necessitates a recalculation
411    /// of all the displayed row heights using
412    /// gtk_cell_area_get_preferred_height_for_width().
413    ///
414    /// # Deprecated since 4.10
415    ///
416    /// This object will be removed in GTK 5
417    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
418    #[allow(deprecated)]
419    #[doc(alias = "gtk_cell_area_context_reset")]
420    fn reset(&self) {
421        unsafe {
422            ffi::gtk_cell_area_context_reset(self.as_ref().to_glib_none().0);
423        }
424    }
425
426    /// The minimum height for the [`CellArea`][crate::CellArea] in this context
427    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
428    /// for using gtk_cell_area_get_preferred_height().
429    ///
430    /// # Deprecated since 4.10
431    ///
432    /// This object will be removed in GTK 5
433    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
434    #[doc(alias = "minimum-height")]
435    fn minimum_height(&self) -> i32 {
436        ObjectExt::property(self.as_ref(), "minimum-height")
437    }
438
439    /// The minimum width for the [`CellArea`][crate::CellArea] in this context
440    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
441    /// for using gtk_cell_area_get_preferred_width().
442    ///
443    /// # Deprecated since 4.10
444    ///
445    /// This object will be removed in GTK 5
446    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
447    #[doc(alias = "minimum-width")]
448    fn minimum_width(&self) -> i32 {
449        ObjectExt::property(self.as_ref(), "minimum-width")
450    }
451
452    /// The natural height for the [`CellArea`][crate::CellArea] in this context
453    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
454    /// for using gtk_cell_area_get_preferred_height().
455    ///
456    /// # Deprecated since 4.10
457    ///
458    /// This object will be removed in GTK 5
459    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
460    #[doc(alias = "natural-height")]
461    fn natural_height(&self) -> i32 {
462        ObjectExt::property(self.as_ref(), "natural-height")
463    }
464
465    /// The natural width for the [`CellArea`][crate::CellArea] in this context
466    /// for all [`TreeModel`][crate::TreeModel] rows that this context was requested
467    /// for using gtk_cell_area_get_preferred_width().
468    ///
469    /// # Deprecated since 4.10
470    ///
471    /// This object will be removed in GTK 5
472    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
473    #[doc(alias = "natural-width")]
474    fn natural_width(&self) -> i32 {
475        ObjectExt::property(self.as_ref(), "natural-width")
476    }
477
478    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
479    #[doc(alias = "minimum-height")]
480    fn connect_minimum_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
481        unsafe extern "C" fn notify_minimum_height_trampoline<
482            P: IsA<CellAreaContext>,
483            F: Fn(&P) + 'static,
484        >(
485            this: *mut ffi::GtkCellAreaContext,
486            _param_spec: glib::ffi::gpointer,
487            f: glib::ffi::gpointer,
488        ) {
489            let f: &F = &*(f as *const F);
490            f(CellAreaContext::from_glib_borrow(this).unsafe_cast_ref())
491        }
492        unsafe {
493            let f: Box_<F> = Box_::new(f);
494            connect_raw(
495                self.as_ptr() as *mut _,
496                b"notify::minimum-height\0".as_ptr() as *const _,
497                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
498                    notify_minimum_height_trampoline::<Self, F> as *const (),
499                )),
500                Box_::into_raw(f),
501            )
502        }
503    }
504
505    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
506    #[doc(alias = "minimum-width")]
507    fn connect_minimum_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
508        unsafe extern "C" fn notify_minimum_width_trampoline<
509            P: IsA<CellAreaContext>,
510            F: Fn(&P) + 'static,
511        >(
512            this: *mut ffi::GtkCellAreaContext,
513            _param_spec: glib::ffi::gpointer,
514            f: glib::ffi::gpointer,
515        ) {
516            let f: &F = &*(f as *const F);
517            f(CellAreaContext::from_glib_borrow(this).unsafe_cast_ref())
518        }
519        unsafe {
520            let f: Box_<F> = Box_::new(f);
521            connect_raw(
522                self.as_ptr() as *mut _,
523                b"notify::minimum-width\0".as_ptr() as *const _,
524                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
525                    notify_minimum_width_trampoline::<Self, F> as *const (),
526                )),
527                Box_::into_raw(f),
528            )
529        }
530    }
531
532    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
533    #[doc(alias = "natural-height")]
534    fn connect_natural_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
535        unsafe extern "C" fn notify_natural_height_trampoline<
536            P: IsA<CellAreaContext>,
537            F: Fn(&P) + 'static,
538        >(
539            this: *mut ffi::GtkCellAreaContext,
540            _param_spec: glib::ffi::gpointer,
541            f: glib::ffi::gpointer,
542        ) {
543            let f: &F = &*(f as *const F);
544            f(CellAreaContext::from_glib_borrow(this).unsafe_cast_ref())
545        }
546        unsafe {
547            let f: Box_<F> = Box_::new(f);
548            connect_raw(
549                self.as_ptr() as *mut _,
550                b"notify::natural-height\0".as_ptr() as *const _,
551                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
552                    notify_natural_height_trampoline::<Self, F> as *const (),
553                )),
554                Box_::into_raw(f),
555            )
556        }
557    }
558
559    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
560    #[doc(alias = "natural-width")]
561    fn connect_natural_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
562        unsafe extern "C" fn notify_natural_width_trampoline<
563            P: IsA<CellAreaContext>,
564            F: Fn(&P) + 'static,
565        >(
566            this: *mut ffi::GtkCellAreaContext,
567            _param_spec: glib::ffi::gpointer,
568            f: glib::ffi::gpointer,
569        ) {
570            let f: &F = &*(f as *const F);
571            f(CellAreaContext::from_glib_borrow(this).unsafe_cast_ref())
572        }
573        unsafe {
574            let f: Box_<F> = Box_::new(f);
575            connect_raw(
576                self.as_ptr() as *mut _,
577                b"notify::natural-width\0".as_ptr() as *const _,
578                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
579                    notify_natural_width_trampoline::<Self, F> as *const (),
580                )),
581                Box_::into_raw(f),
582            )
583        }
584    }
585}
586
587impl<O: IsA<CellAreaContext>> CellAreaContextExt for O {}