PageRenderTime 22ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/src/wrappers/gtk/library/gtk_font_selection_dialog.e

http://github.com/tybor/Liberty
Specman e | 151 lines | 89 code | 31 blank | 31 comment | 4 complexity | e016b1dda324e7211e3285c2058a4d4c MD5 | raw file
  1indexing
  2	description: "GtkFontSelectionDialog รข€” A dialog box for selecting fonts."
  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_FONT_SELECTION_DIALOG
 25	-- The GtkFontSelectionDialog widget is a dialog box for selecting
 26	-- a font.
 27			
 28	-- To set the font which is initially selected, use
 29	-- `set_font_name'.
 30			
 31	-- To get the selected font use `font_name'.
 32
 33	-- To change the text which is shown in the preview area, use
 34	-- `set_preview_text'.
 35
 36
 37inherit GTK_DIALOG
 38	-- GtkFontSelectionDialog implements AtkImplementorIface.
 39	rename make as dialog_make
 40	redefine struct_size
 41	end
 42
 43insert
 44	GTK_FONT_SELECTION_DIALOG_EXTERNALS
 45
 46creation make, from_external_pointer
 47
 48-- feature {} -- Creation
 49
 50
 51creation make
 52
 53feature -- Creation
 54	make (a_title: STRING) is
 55			-- Creates a new GtkFontSelectionDialog.
 56		require
 57			gtk_initialized: gtk.is_initialized
 58			title_not_void: a_title /= Void
 59		do
 60			from_external_pointer (gtk_font_selection_dialog_new (a_title.to_external))
 61		end
 62
 63feature
 64
 65	font_name: STRING is
 66			-- Gets the currently-selected font name. Note that this can be a
 67			-- different string than what you set with `set_font_name', as the
 68			-- font selection widget may normalize font names and thus return
 69			-- a string with a different structure.
 70			-- For example, "Helvetica Italic Bold 12" could be normalized
 71			-- to "Helvetica Bold Italic 12". Use pango_font_description_equal()
 72			-- if you want to compare two font descriptions.
 73			-- Returns Void if no font was selected.
 74		local
 75			c_string: POINTER
 76		do
 77			c_string := gtk_font_selection_dialog_get_font_name (handle)
 78			if c_string.is_not_null then
 79				create Result.from_external (c_string)
 80			end
 81		end
 82
 83	set_preview_text (text: STRING) is
 84			-- Sets the text displayed in the preview area
 85		do
 86			gtk_font_selection_dialog_set_preview_text (handle, text.to_external)
 87		end
 88
 89	set_font_name (fontname: STRING): BOOLEAN is
 90			-- Sets the currently-selected font.
 91			-- Returns : True if the font was found.
 92		do
 93			Result := gtk_font_selection_dialog_set_font_name (handle, fontname.to_external).to_boolean
 94		end
 95
 96	preview_text: STRING is
 97			-- the text displayed in the preview area.
 98		do
 99			create Result.from_external_copy (gtk_font_selection_dialog_get_preview_text (handle))
100		end
101
102	ok_button: GTK_WIDGET is
103			--	The OK button of the dialog
104		local factory: G_OBJECT_EXPANDED_FACTORY [GTK_WIDGET]
105		do
106			Result := factory.wrapper (get_ok_button(handle))
107		end
108
109	apply_button: GTK_WIDGET is
110			-- The Apply button of the dialog. This button is hidden by default
111			-- but you can show/hide it
112		local factory: G_OBJECT_EXPANDED_FACTORY [GTK_WIDGET]
113		do
114			Result := factory.wrapper (get_apply_button(handle))
115		end
116	
117	cancel_button: GTK_WIDGET is
118			-- The Cancel button of the dialog
119		local factory: G_OBJECT_EXPANDED_FACTORY [GTK_WIDGET]
120		do
121			Result := factory.wrapper (get_cancel_button(handle))
122		end
123	
124feature {} -- GtkFontSelectionDialog struct
125
126-- typedef struct {
127--   GtkWidget *ok_button;
128--   GtkWidget *apply_button;
129--   GtkWidget *cancel_button;
130-- } GtkFontSelectionDialog;
131
132	get_ok_button (a_struct: POINTER): POINTER is
133		external "C struct GtkFontSelectionDialog get ok_button use <gtk/gtk.h>"
134		end
135	
136	get_apply_button (a_struct: POINTER): POINTER is
137		external "C struct GtkFontSelectionDialog get apply_button use <gtk/gtk.h>"
138		end
139	
140	get_cancel_button (a_struct: POINTER): POINTER is
141		external "C struct GtkFontSelectionDialog get cancel_button use <gtk/gtk.h>"
142		end
143
144feature -- size
145
146	struct_size: INTEGER is
147		external "C inline use <gtk/gtk.h>"
148		alias "sizeof (GtkFontSelectionDialog)"
149		end
150
151end -- class GTK_FONT_SELECTION_DIALOG