/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

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