1Gtk2::CellLayout(3) User Contributed Perl Documentation Gtk2::CellLayout(3)
2
3
4
6 Gtk2::CellLayout
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
46 is the column of the model from which to get a value, and the
47 $attribute is the property of $cell to be set from the value. So,
48 for example, if column 2 of the model contains strings, you could
49 have the "text" attribute of a Gtk2::CellRendererText get its
50 values from column 2.
51
52 $cell_layout->set_attributes ($cell, ...)
53 · $cell (Gtk2::CellRenderer)
54
55 · ... (list) list of property name and column number pairs.
56
57 Sets the pairs in the ... list as the attributes of $cell_layout,
58 as with repeated calls to "add_attribute". All existing attributes
59 are removed, and replaced with the new attributes.
60
61 $cell_layout->set_cell_data_func ($cell, $func, $func_data=undef)
62 · $cell (Gtk2::CellRenderer)
63
64 · $func (scalar)
65
66 · $func_data (scalar)
67
68 Sets up $cell_layout to call $func to set up attributes of $cell,
69 instead of the standard attribute mapping. $func may be undef to
70 remove an older callback. $func will receive these parameters:
71
72 $cell_layout The cell layout instance
73 $cell The cell renderer to set up
74 $model The tree model
75 $iter TreeIter of the row for which to set the values
76 $data The $func_data passed to "set_cell_data_func"
77
78 list = $cell_layout->get_cells
79 Fetch all of the cell renderers which have been added to
80 $cell_layout.
81
82 Since: gtk+ 2.12
83
84 $cell_layout->clear
85 Unsets all the mappings on all renderers on $cell_layout and
86 removes all renderers attached to it.
87
88 $cell_layout->clear_attributes ($cell)
89 · $cell (Gtk2::CellRenderer)
90
91 Clears all existing attributes previously set with for $cell with
92 "add_attribute" or "set_attributes".
93
94 $cell_layout->pack_end ($cell, $expand)
95 · $cell (Gtk2::CellRenderer)
96
97 · $expand (boolean)
98
99 Like "pack_start", but adds from the end of the layout instead of
100 the beginning.
101
102 $cell_layout->pack_start ($cell, $expand)
103 · $cell (Gtk2::CellRenderer)
104
105 · $expand (boolean)
106
107 Packs $cell into the beginning of $cell_layout. If $expand is
108 false, then $cell is allocated no more space than it needs. Any
109 unused space is divided evenly between cells for which $expand is
110 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-2008 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.12.0 2010-05-02 Gtk2::CellLayout(3)