PageRenderTime 23ms CodeModel.GetById 12ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/gtk/library/gtk_expander.e

http://github.com/tybor/Liberty
Specman e | 365 lines | 167 code | 92 blank | 106 comment | 3 complexity | 56af825173728e72ebe3f3847af4b23a MD5 | raw file
  1indexing
  2	description: "GtkExpander -- A container which can hide its child."
  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	date: "$Date:$"
 22	revision: "$Revision:$"
 23
 24class GTK_EXPANDER
 25	-- A GtkExpander allows the user to hide or show its child by clicking on an
 26	-- expander triangle similar to the triangles used in a GtkTreeView.
 27
 28	-- Normally you use an expander as you would use any other descendant of
 29	-- GtkBin; you create the child widget and use gtk_container_add() to add it
 30	-- to the expander. When the expander is toggled, it will take care of
 31	-- showing and hiding the child automatically.
 32
 33	-- Special Usage: There are situations in which you may prefer to show and
 34	-- hide the expanded widget yourself, such as when you want to actually
 35	-- create the widget at expansion time. In this case, create a GtkExpander
 36	-- but do not add a child to it. The expander widget has an expanded property
 37	-- which can be used to monitor its expansion state. You should watch this
 38	-- property with a signal connection as follows:
 39
 40	--  expander = gtk_expander_new_with_mnemonic ("_More Options");
 41	--  g_signal_connect (expander, "notify::expanded", G_CALLBACK
 42	--  (expander_callback), NULL);
 43
 44	--  ...
 45	
 46	-- static void -- expander_callback (GObject *object, GParamSpec *param_spec,
 47	-- gpointer user_data) -- { -- GtkExpander *expander;
 48	
 49	-- expander = GTK_EXPANDER (object);
 50
 51	-- if (gtk_expander_get_expanded (expander)) { /* Show or create widgets */ }
 52	-- else { /* Hide or destroy widgets */ } -- }
 53
 54inherit
 55	GTK_BIN -- rename make as make_bin end
 56
 57		-- Implemented Interfaces: GtkExpander implements AtkImplementorIface.
 58	
 59insert G_OBJECT_FACTORY [GTK_WIDGET]	
 60
 61creation make, make_with_mnemonic, from_external_pointer
 62
 63feature {} -- Creation
 64
 65	make (a_label: STRING) is
 66			-- Creates a new expander using 'a_label' as the text of the
 67			-- label.
 68		
 69			-- Note: better make as in Eiffel tradition or new as in GTK
 70			-- API? Paolo 2006-04-27
 71		require valid_label: a_label /= Void
 72		do
 73			from_external_pointer(gtk_expander_new(a_label.to_external))
 74		end
 75
 76	make_with_mnemonic (a_label: STRING) is
 77			-- Creates a new expander using label as the text of the
 78			-- label. If characters in label are preceded by an
 79			-- underscore, they are underlined.  If you need a literal
 80			-- underscore character in a label, use '__' (two
 81			-- underscores). The first underlined character represents a
 82			-- keyboard accelerator called a mnemonic. Pressing Alt and
 83			-- that key activates the button.
 84
 85		
 86			-- Note: better make_with_mnemonic as in Eiffel tradition or
 87			-- new_with_mnemonic as in GTK API? Paolo 2006-04-27
 88		require valid_label: a_label /= Void
 89		do
 90			from_external_pointer(gtk_expander_new_with_mnemonic(a_label.to_external))
 91		end
 92
 93feature 
 94	set_expanded is
 95			-- Reveales the child widget to be revealed
 96		do
 97			gtk_expander_set_expanded (handle, 1)
 98			ensure is_expanded: is_expanded
 99		end
100
101	unset_expanded is
102			-- Hides the child widget.
103		do
104			gtk_expander_set_expanded (handle, 0)
105		ensure unexpanded: not is_expanded
106		end
107
108	is_expanded: BOOLEAN is
109			-- IS the child widget shown to the user?
110		do
111			Result:=gtk_expander_get_expanded(handle).to_boolean
112		end
113
114	set_spacing (a_spacing: INTEGER) is 
115			-- Sets the spacing field of expander, wbhich is the number of
116			-- pixels to place between expander and the child.
117		do 
118			gtk_expander_set_spacing (handle, a_spacing)
119		end
120
121	spacing: INTEGER is
122			-- the spacing field of expander, wbhich is the number of
123			-- pixels to place between expander and the child.
124		do
125			Result:=gtk_expander_get_spacing(handle)
126		end
127
128	set_label (a_label: STRING) is
129			-- Sets the text of the label of the expander to `a_label'.
130			-- This will also clear any previously set labels.
131		require valid_label: a_label /= Void
132		do
133			gtk_expander_set_label (handle, a_label.to_external)
134		end
135
136	label: STRING is
137			-- The text from the label of the expander, as set by --
138			-- `set_label'. If the label text has not been set the return
139			-- value will be Void. This will be the case if you create an
140			-- empty button with make to use as a container.
141		local ptr: POINTER
142		do
143			ptr:=gtk_expander_get_label(handle)
144			-- Note: gtk_expander_get_label returns a pointer owned by
145			-- the widget and must not be modified or freed.
146			if ptr.is_not_null then 
147				create Result.from_external_copy (ptr)
148			end
149		end
150
151	set_use_underline is
152			-- Put an underline in the text of the expander label
153			-- indicating the character used for the mnemonic accelerator
154			-- key.
155		do
156			gtk_expander_set_use_underline (handle, 1)
157		ensure set: is_underline_used
158		end
159
160	unset_use_underline is
161			-- Remove the underline under the mnemonic accelerator key
162		do
163			gtk_expander_set_use_underline (handle, 0)
164		ensure unset: not is_underline_used
165		end
166
167	is_underline_used: BOOLEAN is
168			-- Does an embedded underline in the expander label indicates
169			-- a mnemonic? See `set_use_underline'.
170		do
171			Result:=gtk_expander_get_use_underline(handle).to_boolean
172		end
173
174
175	set_use_markup is
176			-- Sets whether the text of the label contains markup in
177			-- Pango's text markup language. See `set_markup'.
178		do
179			gtk_expander_set_use_markup (handle, 1)
180		ensure set: is_markup_used
181		end
182
183	unset_use_markup is
184			-- Do not use Pango markups in the label
185		do
186			gtk_expander_set_use_markup (handle, 0)
187		ensure unset: not is_markup_used
188		end
189
190	is_markup_used: BOOLEAN is
191			-- Is the label's text interpreted as marked up with the
192			-- Pango text markup language? See `set_use_markup'.
193		do
194			Result:=(gtk_expander_get_use_markup(handle).to_boolean)
195		end
196
197	set_label_widget (a_widget: GTK_WIDGET) is
198			-- Set the label widget for the expander. This is the widget
199			-- that will appear emCbedded alongside the expander arrow.
200		require valid_widget: a_widget /= Void
201		do
202			gtk_expander_set_label_widget (handle, a_widget.handle)
203		end
204
205	label_widget: GTK_WIDGET is
206			-- The label widget for the frame. 'set_label_widget'. Can 
207			-- be Void
208		do
209			Result := wrapper (gtk_expander_get_label_widget (handle))
210		end
211
212
213--    Since 2.4
214
215feature -- Properties
216	
217--    "expanded"             gboolean              : Read / Write / Construct
218--    "label"                gchararray            : Read / Write / Construct
219--    "label-widget"         GtkWidget             : Read / Write
220--    "spacing"              gint                  : Read / Write
221--    "use-markup"           gboolean              : Read / Write / Construct
222--    "use-underline"        gboolean              : Read / Write / Construct
223
224-- Style Properties
225
226
227--    "expander-size"        gint                  : Read
228  --    "expander-spacing"     gint                  : Read
229
230
231
232--  "activate"  void        user_function      (GtkExpander *expander,
233--                                              gpointer     user_data)      : Run last / Action
234
235--   The "spacing" property
236
237--    "spacing"              gint                  : Read / Write
238
239--    Space to put between the label and the child.
240
241--    Allowed values: >= 0
242
243--    Default value: 0
244
245--    -----------------------------------------------------------------------
246
247--   The "use-markup" property
248
249--    "use-markup"           gboolean              : Read / Write / Construct
250
251--    The text of the label includes XML markup. See pango_parse_markup().
252
253--    Default value: FALSE
254
255--    -----------------------------------------------------------------------
256
257--   The "use-underline" property
258
259--    "use-underline"        gboolean              : Read / Write / Construct
260
261--    If set, an underline in the text indicates the next character should be
262--    used for the mnemonic accelerator key.
263
264--    Default value: FALSE
265
266-- Style Property Details
267
268--   The "expander-size" style property
269
270--    "expander-size"        gint                  : Read
271
272--    Size of the expander arrow.
273
274--    Allowed values: >= 0
275
276--    Default value: 10
277
278--    -----------------------------------------------------------------------
279
280--   The "expander-spacing" style property
281
282--    "expander-spacing"     gint                  : Read
283
284--    Spacing around expander arrow.
285
286--    Allowed values: >= 0
287
288--    Default value: 2
289
290feature  --   The "activate" signal
291	activate_signal_name: STRING is "activate"
292
293	on_activate is
294		do
295			-- Empty by default
296		end
297
298	enable_on_activate is
299		do
300			connect (Current, activate_signal_name, $on_activate)
301		end
302
303feature {} -- size
304	struct_size: INTEGER is
305		external "C inline use <gtk/gtk.h>"
306		alias "sizeof(GtkExpander)"
307		end
308
309feature {} -- External calls 
310	gtk_expander_new (a_label: POINTER): POINTER is -- GtkWidget*
311		external "C use <gtk/gtk.h>"
312		end
313	
314	gtk_expander_new_with_mnemonic (a_label: POINTER): POINTER is -- GtkWidget*
315		external "C use <gtk/gtk.h>"
316		end
317
318	gtk_expander_set_expanded (an_expander: POINTER; an_expanded: INTEGER) is
319		external "C use <gtk/gtk.h>"
320		end
321
322	gtk_expander_get_expanded (an_expander: POINTER): INTEGER is
323		external "C use <gtk/gtk.h>"
324		end
325
326	gtk_expander_set_spacing (an_expander: POINTER; a_spacing: INTEGER) is
327		external "C use <gtk/gtk.h>"
328		end
329
330	gtk_expander_get_spacing (an_expander: POINTER): INTEGER is
331		external "C use <gtk/gtk.h>"
332		end
333
334	gtk_expander_set_label (an_expander, a_label: POINTER) is
335		external "C use <gtk/gtk.h>"
336		end
337
338	gtk_expander_get_label (an_expander: POINTER): POINTER is -- const gchar*
339		external "C use <gtk/gtk.h>"
340		end
341
342	gtk_expander_set_use_underline (an_expander: POINTER; a_use_underline: INTEGER) is
343		external "C use <gtk/gtk.h>"
344		end
345
346	gtk_expander_get_use_underline (an_expander: POINTER): INTEGER is
347		external "C use <gtk/gtk.h>"
348		end
349
350	gtk_expander_set_use_markup (an_expander: POINTER; a_use_markup: INTEGER) is
351		external "C use <gtk/gtk.h>"
352		end
353
354	gtk_expander_get_use_markup (an_expander: POINTER): INTEGER is
355		external "C use <gtk/gtk.h>"
356		end
357	
358	gtk_expander_set_label_widget (an_expander, a_label_widget: POINTER) is
359		external "C use <gtk/gtk.h>"
360		end
361	
362	gtk_expander_get_label_widget (an_expander: POINTER): POINTER is -- GtkWidget*
363		external "C use <gtk/gtk.h>"
364		end
365end