Debian Codegraph @

gtk/src/cellrendererpixbuf.hg

raw
1 /* Copyright (C) 1998-2002 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include <gtkmm/cellrenderer.h>
18 #include <glibmm/value.h>
19 #include <giomm/icon.h>
20 _DEFS(gtkmm,gtk)
21 _PINCLUDE(gtkmm/private/cellrenderer_p.h)
22
23 extern "C"
24 {
25 GType cairo_gobject_surface_get_type();
26 }
27
28 namespace Glib
29 {
30 //TODO: If we decide to allow adding ABI to gtkmm-3, make this specialization
31 // more like the one in gtkmm-4, gdk/gdkmm/value_cairo.h.
32 /** Specialization of Glib::Value<> for Cairo::RefPtr<Cairo::Surface>.
33 * Needed for Gtk::CellRendererPixbuf::property_surface().
34 */
35 template <>
36 class GTKMM_API Value<::Cairo::RefPtr<::Cairo::Surface>> : public ValueBase_Boxed
37 {
38 public:
39 using T = ::Cairo::Surface;
40 using CppType = ::Cairo::RefPtr<T>;
41 using CType = T::cobject;
42
43 static GType value_type() { return cairo_gobject_surface_get_type(); }
44
45 void set(const CppType& data) { set_boxed(data->cobj()); }
46
47 CppType get() const
48 {
49 CType* CObj = static_cast<CType*>(get_boxed());
50 T* CppObj = new T(CObj, false); // false == take reference
51 return CppType(CppObj);
52 }
53 };
54
55 } // namespace Glib
56
57 namespace Gtk
58 {
59
60 /** Renders a pixbuf in a cell.
61 * A CellRendererPixbuf can be used to render an image in a cell. It allows you to render either a
62 * given Pixbuf (set via the pixbuf property) or a stock icon (set via the stock_id property).
63 *
64 * To support the tree view, CellRendererPixbuf also supports rendering two alternative pixbufs, when
65 * the is_expanded property is true. If the is_expanded property is true and the pixbuf_expander_open
66 * property is set to a pixbuf, it renders that pixbuf. If the is_expanded property is false and the *
67 * pixbuf_expander_closed property is set to a pixbuf, it renders that one.
68 *
69 * @ingroup TreeView
70 */
71 class GTKMM_API CellRendererPixbuf : public CellRenderer
72 {
73 _CLASS_GTKOBJECT(CellRendererPixbuf,GtkCellRendererPixbuf,GTK_CELL_RENDERER_PIXBUF,Gtk::CellRenderer,GtkCellRenderer,,,GTKMM_API)
74 public:
75
76 _CTOR_DEFAULT
77
78 _WRAP_PROPERTY("pixbuf", Glib::RefPtr<Gdk::Pixbuf>)
79 _WRAP_PROPERTY("pixbuf_expander_open", Glib::RefPtr<Gdk::Pixbuf>)
80 _WRAP_PROPERTY("pixbuf_expander_closed", Glib::RefPtr<Gdk::Pixbuf>)
81 _WRAP_PROPERTY("stock_id", Glib::ustring, deprecated "Use property_icon_name() instead.")
82 _WRAP_PROPERTY("stock_size", guint)
83 _WRAP_PROPERTY("stock_detail", Glib::ustring)
84 _WRAP_PROPERTY("icon-name", Glib::ustring)
85 _WRAP_PROPERTY("follow-state", bool, deprecated "Cell renderers always follow state.")
86 _WRAP_PROPERTY("gicon", Glib::RefPtr<Gio::Icon>)
87 _WRAP_PROPERTY("surface", ::Cairo::RefPtr< ::Cairo::Surface>)
88
89 Glib::PropertyProxy_Base _property_renderable() override;
90 };
91
92 } //namespace Gtk