/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

  1. indexing
  2. description: "GtkFontSelectionDialog — A dialog box for selecting fonts."
  3. copyright: "[
  4. Copyright (C) 2006 eiffel-libraries team, 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 hope 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. date: "$Date:$"
  19. revision: "$Revision:$"
  20. class GTK_FONT_SELECTION_DIALOG
  21. -- The GtkFontSelectionDialog widget is a dialog box for selecting
  22. -- a font.
  23. -- To set the font which is initially selected, use
  24. -- `set_font_name'.
  25. -- To get the selected font use `font_name'.
  26. -- To change the text which is shown in the preview area, use
  27. -- `set_preview_text'.
  28. inherit GTK_DIALOG
  29. -- GtkFontSelectionDialog implements AtkImplementorIface.
  30. rename make as dialog_make
  31. redefine struct_size
  32. end
  33. insert
  34. GTK_FONT_SELECTION_DIALOG_EXTERNALS
  35. creation make, from_external_pointer
  36. -- feature {} -- Creation
  37. creation make
  38. feature -- Creation
  39. make (a_title: STRING) is
  40. -- Creates a new GtkFontSelectionDialog.
  41. require
  42. gtk_initialized: gtk.is_initialized
  43. title_not_void: a_title /= Void
  44. do
  45. from_external_pointer (gtk_font_selection_dialog_new (a_title.to_external))
  46. end
  47. feature
  48. font_name: STRING is
  49. -- Gets the currently-selected font name. Note that this can be a
  50. -- different string than what you set with `set_font_name', as the
  51. -- font selection widget may normalize font names and thus return
  52. -- a string with a different structure.
  53. -- For example, "Helvetica Italic Bold 12" could be normalized
  54. -- to "Helvetica Bold Italic 12". Use pango_font_description_equal()
  55. -- if you want to compare two font descriptions.
  56. -- Returns Void if no font was selected.
  57. local
  58. c_string: POINTER
  59. do
  60. c_string := gtk_font_selection_dialog_get_font_name (handle)
  61. if c_string.is_not_null then
  62. create Result.from_external (c_string)
  63. end
  64. end
  65. set_preview_text (text: STRING) is
  66. -- Sets the text displayed in the preview area
  67. do
  68. gtk_font_selection_dialog_set_preview_text (handle, text.to_external)
  69. end
  70. set_font_name (fontname: STRING): BOOLEAN is
  71. -- Sets the currently-selected font.
  72. -- Returns : True if the font was found.
  73. do
  74. Result := gtk_font_selection_dialog_set_font_name (handle, fontname.to_external).to_boolean
  75. end
  76. preview_text: STRING is
  77. -- the text displayed in the preview area.
  78. do
  79. create Result.from_external_copy (gtk_font_selection_dialog_get_preview_text (handle))
  80. end
  81. ok_button: GTK_WIDGET is
  82. -- The OK button of the dialog
  83. local factory: G_OBJECT_EXPANDED_FACTORY [GTK_WIDGET]
  84. do
  85. Result := factory.wrapper (get_ok_button(handle))
  86. end
  87. apply_button: GTK_WIDGET is
  88. -- The Apply button of the dialog. This button is hidden by default
  89. -- but you can show/hide it
  90. local factory: G_OBJECT_EXPANDED_FACTORY [GTK_WIDGET]
  91. do
  92. Result := factory.wrapper (get_apply_button(handle))
  93. end
  94. cancel_button: GTK_WIDGET is
  95. -- The Cancel button of the dialog
  96. local factory: G_OBJECT_EXPANDED_FACTORY [GTK_WIDGET]
  97. do
  98. Result := factory.wrapper (get_cancel_button(handle))
  99. end
  100. feature {} -- GtkFontSelectionDialog struct
  101. -- typedef struct {
  102. -- GtkWidget *ok_button;
  103. -- GtkWidget *apply_button;
  104. -- GtkWidget *cancel_button;
  105. -- } GtkFontSelectionDialog;
  106. get_ok_button (a_struct: POINTER): POINTER is
  107. external "C struct GtkFontSelectionDialog get ok_button use <gtk/gtk.h>"
  108. end
  109. get_apply_button (a_struct: POINTER): POINTER is
  110. external "C struct GtkFontSelectionDialog get apply_button use <gtk/gtk.h>"
  111. end
  112. get_cancel_button (a_struct: POINTER): POINTER is
  113. external "C struct GtkFontSelectionDialog get cancel_button use <gtk/gtk.h>"
  114. end
  115. feature -- size
  116. struct_size: INTEGER is
  117. external "C inline use <gtk/gtk.h>"
  118. alias "sizeof (GtkFontSelectionDialog)"
  119. end
  120. end -- class GTK_FONT_SELECTION_DIALOG