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