Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
gdkpaintable.h
Go to the documentation of this file.
1/*
2 * Copyright © 2018 Benjamin Otte
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authors: Benjamin Otte <otte@gnome.org>
18 */
19
20#pragma once
21
22#if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
23#error "Only <gdk/gdk.h> can be included directly."
24#endif
25
26#include <gdk/gdktypes.h>
27
29
30#define GDK_TYPE_PAINTABLE (gdk_paintable_get_type ())
31
33G_DECLARE_INTERFACE (GdkPaintable, gdk_paintable, GDK, PAINTABLE, GObject)
34
35/**
36 * GdkPaintableFlags:
37 * @GDK_PAINTABLE_STATIC_SIZE: The size is immutable.
38 * The [signal@Gdk.Paintable::invalidate-size] signal will never be
39 * emitted.
40 * @GDK_PAINTABLE_STATIC_CONTENTS: The content is immutable.
41 * The [signal@Gdk.Paintable::invalidate-contents] signal will never be
42 * emitted.
43 *
44 * Flags about a paintable object.
45 *
46 * Implementations use these for optimizations such as caching.
47 */
52
53/**
54 * GdkPaintableInterface:
55 * @snapshot: Snapshot the paintable. The given @width and @height are
56 * guaranteed to be larger than 0.0. The resulting snapshot must modify
57 * only the area in the rectangle from (0,0) to (width, height).
58 * This is the only function that must be implemented for this interface.
59 * @get_current_image: return a `GdkPaintable` that does not change over
60 * time. This means the `GDK_PAINTABLE_STATIC_SIZE` and
61 * `GDK_PAINTABLE_STATIC_CONTENTS` flag are set.
62 * @get_flags: Get the flags for this instance. See [flags@Gdk.PaintableFlags]
63 * for details.
64 * @get_intrinsic_width: The preferred width for this object to be
65 * snapshot at or 0 if none. This is purely a hint. The object must still
66 * be able to render at any size.
67 * @get_intrinsic_height: The preferred height for this object to be
68 * snapshot at or 0 if none. This is purely a hint. The object must still
69 * be able to render at any size.
70 * @get_intrinsic_aspect_ratio: The preferred aspect ratio for this object
71 * or 0 if none. If both [vfunc@Gdk.Paintable.get_intrinsic_width]
72 * and [vfunc@Gdk.Paintable.get_intrinsic_height] return non-zero
73 * values, this function should return the aspect ratio computed from those.
74 *
75 * The list of functions that can be implemented for the `GdkPaintable`
76 * interface.
77 *
78 * Note that apart from the [vfunc@Gdk.Paintable.snapshot] function,
79 * no virtual function of this interface is mandatory to implement, though it
80 * is a good idea to implement [vfunc@Gdk.Paintable.get_current_image]
81 * for non-static paintables and [vfunc@Gdk.Paintable.get_flags] if the
82 * image is not dynamic as the default implementation returns no flags and
83 * that will make the implementation likely quite slow.
84 */
86{
87 /*< private >*/
89
90 /*< public >*/
91 /* draw to 0,0 with the given width and height */
92 void (* snapshot) (GdkPaintable *paintable,
94 double width,
95 double height);
96 /* get the current contents in an immutable form (optional) */
97 GdkPaintable * (* get_current_image) (GdkPaintable *paintable);
98
99 /* get flags for potential optimizations (optional) */
100 GdkPaintableFlags (* get_flags) (GdkPaintable *paintable);
101 /* preferred width of paintable or 0 if it has no width (optional) */
102 int (* get_intrinsic_width) (GdkPaintable *paintable);
103 /* preferred height of paintable or 0 if it has no height (optional) */
104 int (* get_intrinsic_height) (GdkPaintable *paintable);
105 /* aspect ratio (width / height) of paintable or 0 if it has no aspect ratio (optional) */
106 double (* get_intrinsic_aspect_ratio) (GdkPaintable *paintable);
107};
108
110void gdk_paintable_snapshot (GdkPaintable *paintable,
111 GdkSnapshot *snapshot,
112 double width,
113 double height);
115GdkPaintable * gdk_paintable_get_current_image (GdkPaintable *paintable);
116
119 gdk_paintable_get_flags (GdkPaintable *paintable);
121int gdk_paintable_get_intrinsic_width (GdkPaintable *paintable);
123int gdk_paintable_get_intrinsic_height (GdkPaintable *paintable);
125double gdk_paintable_get_intrinsic_aspect_ratio(GdkPaintable *paintable);
126
128void gdk_paintable_compute_concrete_size (GdkPaintable *paintable,
129 double specified_width,
130 double specified_height,
131 double default_width,
132 double default_height,
133 double *concrete_width,
134 double *concrete_height);
135/* for implementations only */
137void gdk_paintable_invalidate_contents (GdkPaintable *paintable);
139void gdk_paintable_invalidate_size (GdkPaintable *paintable);
141GdkPaintable * gdk_paintable_new_empty (int intrinsic_width,
142 int intrinsic_height);
143
144
146
#define GDK_AVAILABLE_IN_ALL
GDK_AVAILABLE_IN_ALL int gdk_paintable_get_intrinsic_width(GdkPaintable *paintable)
GDK_AVAILABLE_IN_ALL void gdk_paintable_invalidate_size(GdkPaintable *paintable)
GDK_AVAILABLE_IN_ALL void gdk_paintable_invalidate_contents(GdkPaintable *paintable)
GDK_AVAILABLE_IN_ALL GdkPaintable * gdk_paintable_new_empty(int intrinsic_width, int intrinsic_height)
GDK_AVAILABLE_IN_ALL GdkPaintable * gdk_paintable_get_current_image(GdkPaintable *paintable)
GDK_AVAILABLE_IN_ALL void gdk_paintable_compute_concrete_size(GdkPaintable *paintable, double specified_width, double specified_height, double default_width, double default_height, double *concrete_width, double *concrete_height)
GDK_AVAILABLE_IN_ALL GdkPaintableFlags gdk_paintable_get_flags(GdkPaintable *paintable)
GDK_AVAILABLE_IN_ALL int gdk_paintable_get_intrinsic_height(GdkPaintable *paintable)
GdkPaintableFlags
@ GDK_PAINTABLE_STATIC_CONTENTS
@ GDK_PAINTABLE_STATIC_SIZE
GDK_AVAILABLE_IN_ALL void gdk_paintable_snapshot(GdkPaintable *paintable, GdkSnapshot *snapshot, double width, double height)
GDK_AVAILABLE_IN_ALL double gdk_paintable_get_intrinsic_aspect_ratio(GdkPaintable *paintable)
struct _GdkSnapshot GdkSnapshot
Definition gdktypes.h:94
#define G_END_DECLS
Definition gmacros.h:910
#define G_BEGIN_DECLS
Definition gmacros.h:909
#define G_DECLARE_INTERFACE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, PrerequisiteName)
Definition gtype.h:1797
int(* get_intrinsic_width)(GdkPaintable *paintable)
int(* get_intrinsic_height)(GdkPaintable *paintable)
GTypeInterface g_iface
GdkPaintableFlags(* get_flags)(GdkPaintable *paintable)
double(* get_intrinsic_aspect_ratio)(GdkPaintable *paintable)
void(* snapshot)(GdkPaintable *paintable, GdkSnapshot *snapshot, double width, double height)