1Gtk2::CellLayout(3) User Contributed Perl Documentation Gtk2::CellLayout(3)
2
3
4
6 Gtk2::CellLayout - wrapper for GtkCellLayout
7
9 # This is an abstract interface; the CellLayout interface is
10 # implemented by concrete classes like ComboBox and TreeViewColumn.
11 # See the discussion for details on creating your own CellLayout.
12 # This synopsis assumes you already have an instance in $cell_layout.
13
14 # Add a cell renderer that shows the pixbuf in column 2 of the
15 # associated TreeModel. It will take up only the necessary space
16 # ("expand" => FALSE).
17 my $cell = Gtk2::CellRendererPixbuf->new ();
18 $cell_layout->pack_start ($cell, FALSE);
19 $cell_layout->add_attribute ($cell, pixbuf => 2);
20
21 # Add another cell renderer that gets the "text" property from
22 # column 3 of the associated TreeModel, and takes up all remaining
23 # horizontal space ("expand" => TRUE).
24 my $cell = Gtk2::CellRendererText->new ();
25 $cell_layout->pack_start ($cell, TRUE);
26 $cell_layout->add_attribute ($cell, text => 3);
27
29 Gtk2::CellLayout is an interface to be implemented by all objects which
30 want to provide a Gtk2::TreeViewColumn-like API for packing cells,
31 setting attributes and data funcs.
32
34 Glib::Interface
35 +----Gtk2::CellLayout
36
38 $cell_layout->add_attribute ($cell, $attribute, $column)
39 • $cell (Gtk2::CellRenderer)
40
41 • $attribute (string)
42
43 • $column (integer)
44
45 Adds an attribute mapping to the list in $cell_layout. The $column is
46 the column of the model from which to get a value, and the $attribute
47 is the property of $cell to be set from the value. So, for example, if
48 column 2 of the model contains strings, you could have the "text"
49 attribute of a Gtk2::CellRendererText get its values from column 2.
50
51 $cell_layout->set_attributes ($cell, ...)
52 • $cell (Gtk2::CellRenderer)
53
54 • ... (list) list of property name and column number pairs.
55
56 Sets the pairs in the ... list as the attributes of $cell_layout, as
57 with repeated calls to "add_attribute". All existing attributes are
58 removed, and replaced with the new attributes.
59
60 $cell_layout->set_cell_data_func ($cell, $func, $func_data=undef)
61 • $cell (Gtk2::CellRenderer)
62
63 • $func (scalar)
64
65 • $func_data (scalar)
66
67 Sets up $cell_layout to call $func to set up attributes of $cell,
68 instead of the standard attribute mapping. $func may be undef to
69 remove an older callback. $func will receive these parameters:
70
71 $cell_layout The cell layout instance
72 $cell The cell renderer to set up
73 $model The tree model
74 $iter TreeIter of the row for which to set the values
75 $data The $func_data passed to "set_cell_data_func"
76
77 list = $cell_layout->get_cells
78 Fetch all of the cell renderers which have been added to $cell_layout.
79
80 Note that if there are no cells this functions returns 'undef' instead
81 of an empty list.
82
83 Since: gtk+ 2.12
84
85 $cell_layout->clear
86 Unsets all the mappings on all renderers on $cell_layout and removes
87 all renderers attached to it.
88
89 $cell_layout->clear_attributes ($cell)
90 • $cell (Gtk2::CellRenderer)
91
92 Clears all existing attributes previously set with for $cell with
93 "add_attribute" or "set_attributes".
94
95 $cell_layout->pack_end ($cell, $expand)
96 • $cell (Gtk2::CellRenderer)
97
98 • $expand (boolean)
99
100 Like "pack_start", but adds from the end of the layout instead of the
101 beginning.
102
103 $cell_layout->pack_start ($cell, $expand)
104 • $cell (Gtk2::CellRenderer)
105
106 • $expand (boolean)
107
108 Packs $cell into the beginning of $cell_layout. If $expand is false,
109 then $cell is allocated no more space than it needs. Any unused space
110 is divided evenly between cells for which $expand is true.
111
112 $cell_layout->reorder ($cell, $position)
113 • $cell (Gtk2::CellRenderer)
114
115 • $position (integer)
116
117 Re-insert $cell at $position. $cell must already be packed into
118 $cell_layout.
119
121 GTK+ provides several CellLayout implementations, such as
122 Gtk2::TreeViewColumn and Gtk2::ComboBox. To create your own object
123 that implements the CellLayout interface and therefore can be used to
124 display CellRenderers, you need to add Gtk2::CellLayout to your class's
125 "interfaces" list, like this:
126
127 package MyLayout;
128 use Gtk2;
129 use Glib::Object::Subclass
130 Gtk2::Widget::,
131 interfaces => [ Gtk2::CellLayout:: ],
132 ;
133
134 This will cause perl to call several virtual methods with
135 ALL_CAPS_NAMES when GTK+ attempts to perform certain actions. You
136 simply provide (or override) those methods with perl code. The methods
137 map rather directly to the object interface, so it should be easy to
138 figure out what they should do. Those methods are:
139
140 PACK_START ($cell_layout, $cell, $expand)
141 PACK_END ($cell_layout, $cell, $expand)
142 CLEAR ($cell_layout)
143 ADD_ATTRIBUTE ($cell_layout, $cell, $attribute, $column)
144 SET_CELL_DATA_FUNC ($cell_layout, $cell, $func, $data)
145 CLEAR_ATTRIBUTES ($cell_layout, $cell)
146 REORDER ($cell_layout, $cell, $position)
147 list = GET_CELLS ($cell_layout)
148
150 Gtk2, Glib::Interface
151
153 Copyright (C) 2003-2011 by the gtk2-perl team.
154
155 This software is licensed under the LGPL. See Gtk2 for a full notice.
156
157
158
159perl v5.34.0 2022-01-21 Gtk2::CellLayout(3)