/src/wrappers/gtk/library/gtk_font_selection.e

http://github.com/tybor/Liberty · Specman e · 118 lines · 59 code · 21 blank · 38 comment · 4 complexity · f485964656cf841b21206e0e63de39e1 MD5 · raw file

  1. indexing
  2. description: "GtkFontSelection: A widget for selecting fonts."
  3. copyright: "[
  4. Copyright (C) 2007 Paolo Redaelli, GTK+ team
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hopeOA that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. wrapped_version: "2.10.6"
  19. class GTK_FONT_SELECTION
  20. -- The GtkFontSelection widget lists the available fonts, styles
  21. -- and sizes, allowing the user to select a font. It is used in the
  22. -- GtkFontSelectionDialog widget to provide a dialog box for
  23. -- selecting fonts.
  24. -- To set the font which is initially selected, use
  25. -- `set_font_name'.
  26. -- To get the selected font use `font_name'.
  27. -- To change the text which is shown in the preview area, use
  28. -- `set_preview_text'.
  29. inherit
  30. GTK_VBOX
  31. rename
  32. make as make_vbox
  33. undefine
  34. struct_size
  35. end
  36. -- GtkFontSelection implements AtkImplementorIface.
  37. insert GTK_FONT_SELECTION_EXTERNALS
  38. creation make, from_external_pointer
  39. feature {} -- Creation
  40. make is
  41. -- Creates a new GtkFontSelection.
  42. do
  43. from_external_pointer(gtk_font_selection_new)
  44. end
  45. feature
  46. font_name: STRING is
  47. -- The currently-selected font name. Note that this can be a
  48. -- different string than what you set with `set_font_name',
  49. -- as the font selection widget may normalize font names and
  50. -- thus return a string with a different structure. For
  51. -- example, "Helvetica Italic Bold 12" could be normalized to
  52. -- "Helvetica Bold Italic 12". Use (TODO)
  53. -- pango_font_description_equal() if you want to compare two
  54. -- font
  55. local ptr: POINTER
  56. do
  57. ptr:=gtk_font_selection_get_font_name(handle)
  58. if ptr.is_not_null then
  59. create Result.from_external(ptr)
  60. -- Note: C documentation saya that
  61. -- gtk_font_selection_get_font_name "returns a string with
  62. -- the name of the current font, or NULL if no font is
  63. -- selected. You must free this string with g_free()". We
  64. -- isntead pass it under the Garbage Collector.
  65. end
  66. end
  67. successfully_set: BOOLEAN
  68. -- Has the last call to `set_font_name' been successful?
  69. set_font_name (a_font_name: STRING) is
  70. -- Sets the currently-selected font. Note that the font
  71. -- selection widget needs to know the screen in which it will
  72. -- appear for this to work; this can be guaranteed by simply
  73. -- making sure that the widget is inserted in a toplevel
  74. -- window before you call this function.
  75. -- `a_fontname': a font name like "Helvetica 12" or "Times
  76. -- Bold 18"
  77. -- `successfully_set' will be True if the font could be set
  78. -- successfully; False if no such font exists or if the
  79. -- fontsel doesn't belong to a particular screen yet.
  80. require name_not_void: a_font_name /= Void
  81. do
  82. successfully_set:=(gtk_font_selection_set_font_name
  83. (handle, a_font_name.to_external).to_boolean)
  84. end
  85. preview_text: CONST_STRING is
  86. -- the text displayed in the preview area.
  87. do
  88. create Result.from_external(gtk_font_selection_get_preview_text(handle))
  89. end
  90. set_preview_text (a_text: STRING) is
  91. -- Sets the text displayed in the preview area.
  92. require text_not_void: a_text /= Void
  93. do
  94. gtk_font_selection_set_preview_text(handle, a_text.to_external)
  95. end
  96. -- GtkFontSelectionDialog a dialog box which uses GtkFontSelection.
  97. end -- class GTK_FONT_SELECTION