PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/src/wrappers/gtk/library/gtk_font_button.e

http://github.com/tybor/Liberty
Specman e | 215 lines | 110 code | 33 blank | 72 comment | 2 complexity | ce5b76710aa3ce9d29e7ae12637f2fec MD5 | raw file
  1indexing
  2	description: "GtkFontButton: A button to launch a font selection dialog."
  3	copyright: "[
  4					Copyright (C) 2007 Paolo Redaelli, 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 hopeOA 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
 22	wrapped_version: "2.10.6"
 23
 24class GTK_FONT_BUTTON
 25	-- The GtkFontButton is a button which displays the currently
 26	-- selected font an allows to open a font selection dialog to
 27	-- change the font. It is suitable widget for selecting a font in a
 28	-- preference dialog.
 29
 30inherit
 31	GTK_BUTTON
 32		undefine
 33			struct_size
 34		redefine
 35			make
 36		end
 37
 38insert GTK_FONT_BUTTON_EXTERNALS
 39
 40creation make, from_external_pointer
 41
 42feature {} -- Creation
 43	make is
 44			-- Creates a new font picker widget.
 45		do
 46			from_external_pointer(gtk_font_button_new)
 47		end
 48
 49	with_font (a_font_name: STRING) is
 50			-- Creates a new font picker widget. `a_font_name' is the
 51			-- name of font to display in font selection dialog
 52		require
 53            name_not_void: a_font_name /= Void
 54		do
 55			from_external_pointer(gtk_font_button_new_with_font(a_font_name.to_external))
 56		end
 57
 58feature
 59
 60	set_font_name (a_font_name: STRING) is
 61			-- Sets or updates the currently-displayed font in font
 62			-- picker dialog.
 63
 64			-- `a_font_name': Name of font to display in font selection
 65			-- dialog.
 66
 67			-- `font_exists' is set to True if the selection dialog and
 68			-- the font exists.
 69		require name_not_void: a_font_name /= Void
 70		do
 71			font_exists := (gtk_font_button_set_font_name 
 72								 (handle, a_font_name.to_external).to_boolean)
 73			--   Returns : Return value of
 74			--   gtk_font_selection_dialog_set_font_name() if the font
 75			--   selection dialog exists, otherwise FALSE.
 76		end
 77
 78	font_exists: BOOLEAN 
 79			-- Has the last call to `set_font' successful?
 80
 81	font_name: STRING is
 82			-- The name of the currently selected font. 
 83			-- Default value: "Sans 12"
 84		do
 85			create Result.from_external_copy (gtk_font_button_get_font_name(handle))
 86		end
 87
 88	set_show_style (a_setting: BOOLEAN) is
 89			-- If `a_setting' is True, the font style will be displayed
 90			-- along with name of the selected font.
 91		
 92			-- If this property is set to TRUE, the name of the selected
 93			-- font style will be shown in the label. For a more WYSIWYG
 94			-- way to show the selected style, see the ::use-font
 95			-- property.
 96		do
 97			gtk_font_button_set_show_style  (handle,a_setting.to_integer)
 98		ensure set: a_setting = is_style_shown
 99		end
100
101	is_style_shown: BOOLEAN is
102			-- Will the font style be shown in the label?
103		do
104			Result:=gtk_font_button_get_show_style(handle).to_boolean
105		end
106	
107	set_show_size (a_setting: BOOLEAN) is
108			-- If `a_setting' is True, the font size will be displayed
109			-- along with the name of the selected font.
110		do
111			gtk_font_button_set_show_size(handle, a_setting.to_integer)
112		ensure set: a_setting = is_size_shown
113		end	
114
115	is_size_shown: BOOLEAN is
116			-- Will the font size be shown in the label?
117
118			-- If this property is set to True, the selected font size
119			-- will be shown in the label. For a more WYSIWYG way to show
120			-- the selected size, see the ::use-size property.
121		do
122			Result:=gtk_font_button_get_show_size(handle).to_boolean
123		end
124
125	set_use_font (a_setting: BOOLEAN) is
126			-- If `a_setting' is True, the font name will be written
127			-- using the selected font.
128		do
129			gtk_font_button_set_use_font(handle,a_setting.to_integer)
130		ensure set: a_setting = is_font_used
131		end
132	
133	is_font_used: BOOLEAN is
134			-- Is the selected font used in the label?
135		do
136			Result:=gtk_font_button_get_use_font(handle).to_boolean
137		end
138
139	set_use_size (a_setting: BOOLEAN) is
140			-- If `a_setting' is TRUE, the font name will be written
141			-- using the selected size.
142		do
143			gtk_font_button_set_use_size(handle,a_setting.to_integer)
144		ensure set: a_setting = is_size_used
145		end
146
147	is_size_used: BOOLEAN is
148			-- Is the selected size used in the label?
149		do
150			Result:=gtk_font_button_get_use_size(handle) /= 0
151		end
152
153	set_title (a_title: STRING) is
154			-- Sets the title for the font selection dialog.
155		require title_not_void: a_title /= Void
156		do
157			gtk_font_button_set_title(handle, a_title.to_external)
158		ensure set: a_title.is_equal(title)
159		end
160
161	title: CONST_STRING is
162			-- the title of the font selection dialog.
163		do
164			create Result.from_external(gtk_font_button_get_title(handle))
165		ensure
166            not_void: Result /= Void
167		end
168	
169	-- Note: "font-name", "show-size", "show-style", "title",
170	-- "use-font", "use-size" properties already have strongly-typed
171	-- setter/getter features
172
173		--
174	--   Default value: FALSE
175	--
176	--   Since 2.4
177	--
178	--   --------------------------------------------------------------------------
179	--
180	--  The "use-size" property
181	--
182	--   "use-size"             gboolean              : Read / Write
183	--
184	--   If this property is set to TRUE, the label will be drawn with the selected
185	--   font size.
186	--
187	--   Default value: FALSE
188	--
189	--   Since 2.4
190	--
191
192feature -- The "font-set" signal
193
194	connect_agent_to_font_set_signal (a_procedure: PROCEDURE [ANY, TUPLE[GTK_FONT_BUTTON]]) is
195			--   The ::font-set signal is emitted when the user selects a font. When
196			--   handling this signal, use `font_name()' to find out
197			--   which font was just selected.
198			--
199			--   Note that this signal is only emitted when the user changes the font. If
200			--   you need to react to programmatic font changes as well, use the
201			--   notify::font-name signal.
202			--
203			--   widget :    the object which received the signal.
204			--
205			--   Since 2.4
206		require
207			valid_procedure: a_procedure /= Void
208		local
209			font_set_callback: FONT_SET_CALLBACK
210		do
211			create font_set_callback.make
212			font_set_callback.connect (Current, a_procedure)
213		end
214
215end -- class GTK_FONT_BUTTON_EXTERNALS