PageRenderTime 17ms CodeModel.GetById 9ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/src/wrappers/gtk/library/gtk_cell_view.e

http://github.com/tybor/Liberty
Specman e | 218 lines | 134 code | 39 blank | 45 comment | 3 complexity | f82b57f523d6cad4daad79b05263a1a9 MD5 | raw file
  1indexing
  2	description: "GtkCellView, a widget displaying a single row of a GtkTreeModel."
  3	copyright: "[
  4					Copyright (C) 2006 eiffel-libraries team, GTK+ team
  5					
  6					This library is free software; you can redistribute it and/or
  7					modify it under the terms of the GNU Lesser General Public License
  8					as published by the Free Software Foundation; either version 2.1 of
  9					the License, or (at your option) any later version.
 10					
 11					This library is distributed in the hope that it will be useful, but
 12					WITHOUT ANY WARRANTY; without even the implied warranty of
 13					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14					Lesser General Public License for more details.
 15
 16					You should have received a copy of the GNU Lesser General Public
 17					License along with this library; if not, write to the Free Software
 18					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 19					02110-1301 USA
 20					]"					
 21
 22class GTK_CELL_VIEW
 23	-- A GtkCellView displays a single row of a GtkTreeModel, using
 24	-- cell renderers just like GtkTreeView. GtkCellView doesn't
 25	-- support some of the more complex features of GtkTreeView, like
 26	-- cell editing and drag and drop.
 27	
 28inherit
 29	GTK_WIDGET
 30	GTK_CELL_LAYOUT
 31		undefine
 32			store_eiffel_wrapper
 33		end
 34		-- GtkCellView also implements AtkImplementorIface.
 35		
 36creation make, from_external_pointer
 37
 38feature {} -- Creation
 39
 40	make is 
 41			-- Creates a new GtkCellView widget.
 42		do
 43			from_external_pointer (gtk_cell_view_new)
 44		end
 45
 46	make_with_text (a_text: STRING) is
 47			-- Creates a new GtkCellView widget, adds a
 48			-- GtkCellRendererText to it, and makes its show `a_text'.
 49		require valide_text: a_text /= Void
 50		do
 51			handle:=gtk_cell_view_new_with_text (a_text.to_external)
 52			store_eiffel_wrapper
 53		end
 54	
 55	new_with_markup (a_markup: STRING) is
 56			-- Creates a new GtkCellView widget, adds a
 57			-- GtkCellRendererText to it, and makes its show
 58			-- `a_markup'. The text can be marked up with the Pango text
 59			-- markup language.
 60		require valid_text: a_markup /= Void
 61		do
 62			from_external_pointer (gtk_cell_view_new_with_markup (a_markup.to_external))
 63		end
 64
 65	make_with_pixbuf (a_pixbuf: GDK_PIXBUF) is
 66		-- Creates a new GtkCellView widget, adds a
 67		-- GtkCellRendererPixbuf to it, and makes its show `a_pixbuf'.
 68		do
 69			handle:=gtk_cell_view_new_with_pixbuf (a_pixbuf.handle)
 70			store_eiffel_wrapper
 71		end
 72
 73feature
 74	set_model (a_model: GTK_TREE_MODEL) is
 75			-- Sets the model for cell_view. If Current already has a
 76			-- model set, it will remove it before setting the new model.
 77		require valid_model: a_model /= Void
 78		do
 79			gtk_cell_view_set_model (handle, a_model.handle)
 80		end
 81
 82	unset_model is
 83			-- Unset the old model.
 84		do
 85			gtk_cell_view_set_model (handle, default_pointer)
 86		end
 87
 88	set_displayed_row (a_path: GTK_TREE_PATH) is
 89			-- Sets the row of the model that is currently displayed by
 90			-- the GtkCellView. If the `a_path' is unset, then the
 91			-- contents of the cellview "stick" at their last value; this
 92			-- is not normally a desired result, but may be a needed
 93			-- intermediate state if say, the model for the GtkCellView
 94			-- becomes temporarily empty.
 95		require valid_path: a_path /= Void
 96		do
 97			gtk_cell_view_set_displayed_row (handle, a_path.handle)
 98		end
 99
100	unset_displayed_row is
101			-- Unset the displayed row; it is not normally a desired
102			-- result, but may be a needed intermediate state if say, the
103			-- model for the GtkCellView becomes temporarily empty.
104		do
105			gtk_cell_view_set_displayed_row (handle, default_pointer)
106		end
107
108	displayed_row: GTK_TREE_PATH is
109			-- A GtkTreePath referring to the currently displayed row. It
110			-- is Void ff no row is currently displayed.
111		local
112			ptr: POINTER
113		do
114			ptr := gtk_cell_view_get_displayed_row (handle)
115			if ptr.is_not_null then create Result.from_external_pointer (ptr) end
116		end
117
118	size_of_row (a_path: GTK_TREE_PATH): GTK_REQUISITION is
119			-- the size needed by Current to display the model row pointed to by `a_path'.
120		require valid_path: a_path /= Void
121		local shall_be_true: INTEGER
122		do
123			create Result.make
124			shall_be_true:=gtk_cell_view_get_size_of_row (handle, a_path.handle,
125																		 Result.handle)
126		end
127
128	set_background_color (a_color: GDK_COLOR) is
129			-- Sets the background color of view.
130		do
131			gtk_cell_view_set_background_color (handle, a_color.handle)
132		end
133
134	cell_renderers: G_LIST [GTK_CELL_RENDERER] is
135			-- the cell renderers which have been added to Current
136			-- cell_view.
137		do
138			create {G_OBJECT_LIST[GTK_CELL_RENDERER]}
139			Result.from_external_pointer (gtk_cell_view_get_cell_renderers (handle))
140			debug print (once "Warning! Possible memory problems in GTK_CELL_VIEW.cell_renderers%N") end
141			-- TODO: The returned list, but not the renderers has been newly
142			-- allocated and should be freed with g_list_free() when no
143			-- longer needed.
144		end
145
146feature 	-- The "background" property
147	set_backgroud_color_name (a_color_name: STRING) is
148		do
149			set_string_property (background_property_name, a_color_name)
150		end
151	
152	--   "background"           gchararray            : Write
153	
154	-- Background color as a string.
155
156	-- Default value: NULL
157	-- The "background-gdk" property
158
159	--   "background-gdk"       GdkColor              : Read / Write
160
161	-- Background color as a GdkColor.
162	-- The "background-set" property
163
164	--   "background-set"       gboolean              : Read / Write
165
166	-- Whether this tag affects the background color.
167
168	-- Default value: FALSE
169
170feature -- size
171	struct_size: INTEGER is
172		external "C inline use <gtk/gtk.h>"
173		alias "sizeof(GtkCellView)"
174		end
175
176feature {} -- Properties string-names
177		background_property_name: STRING is "background"
178
179feature {} -- External calls
180	gtk_cell_view_new: POINTER  is
181		external "C use <gtk/gtk.h>"
182		end
183
184	gtk_cell_view_new_with_text (a_text: POINTER): POINTER is
185		external "C use <gtk/gtk.h>"
186		end
187
188	gtk_cell_view_new_with_markup (a_markup: POINTER): POINTER is
189		external "C use <gtk/gtk.h>"
190		end
191
192	gtk_cell_view_new_with_pixbuf (a_pixbuf: POINTER): POINTER is
193		external "C use <gtk/gtk.h>"
194		end
195
196	gtk_cell_view_set_model (a_cell_view, a_model: POINTER) is
197		external "C use <gtk/gtk.h>"
198		end
199	
200	gtk_cell_view_set_displayed_row (a_cell_view, a_path: POINTER) is
201		external "C use <gtk/gtk.h>"
202		end
203
204	gtk_cell_view_get_displayed_row (a_cell_view: POINTER): POINTER is
205		external "C use <gtk/gtk.h>"
206		end
207	gtk_cell_view_get_size_of_row (a_cell_view, a_path, a_gtk_requisiton: POINTER): INTEGER is -- gboolean
208		external "C use <gtk/gtk.h>"
209		end
210
211	gtk_cell_view_set_background_color (a_cell_view a_gdk_color: POINTER) is
212		external "C use <gtk/gtk.h>"
213		end
214	
215	gtk_cell_view_get_cell_renderers (a_cell_view: POINTER): POINTER is -- GList*
216		external "C use <gtk/gtk.h>"
217		end
218end