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