/src/wrappers/gtk/library/gtk_adjustment.e

http://github.com/tybor/Liberty · Specman e · 220 lines · 102 code · 36 blank · 82 comment · 2 complexity · 9cc534340dfba8ac47334d65e8ad6a1e MD5 · raw file

  1. indexing
  2. description: "GtkAdjustment -- A GtkObject representing an adjustable bounded value."
  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_ADJUSTMENT
  21. -- The GtkAdjustment object represents a value which has an
  22. -- associated lower and upper bound, together with step and page
  23. -- increments, and a page size. It is used within several GTK+
  24. -- widgets, including GtkSpinButton, GtkViewport, and GtkRange
  25. -- (which is a base class for GtkHScrollbar, GtkVScrollbar,
  26. -- GtkHScale, and GtkVScale).
  27. -- The GtkAdjustment object does not update the value
  28. -- itself. Instead it is left up to the owner of the GtkAdjustment
  29. -- to control the value.
  30. -- The owner of the GtkAdjustment typically calls the
  31. -- `value_changed' and `changed' features after changing the value
  32. -- and its bounds. This results in the emission of the
  33. -- "value_changed" or "changed" signal respectively.
  34. inherit GTK_OBJECT
  35. insert
  36. GTK_ADJUSTMENT_EXTERNALS
  37. EXCEPTIONS
  38. export {} all
  39. undefine copy, is_equal
  40. end
  41. creation make, from_external_pointer
  42. feature
  43. struct_size: INTEGER is
  44. external "C inline use <gtk/gtk.h>"
  45. alias "sizeof(GtkAdjustment)"
  46. end
  47. feature {} -- Creation
  48. make (a_value, a_lower, an_upper, a_step_increment, a_page_increment, a_page_size: REAL_64) is
  49. -- Creates a new GtkAdjustment.
  50. -- a_value : the initial value.
  51. -- a_lower : the minimum value.
  52. -- an_upper : the maximum value.
  53. -- a_step_increment : the step increment.
  54. -- a_page_increment : the page increment.
  55. -- a_page_size : the page size.
  56. do
  57. from_external_pointer(gtk_adjustment_new (a_value, a_lower, an_upper,
  58. a_step_increment, a_page_increment, a_page_size))
  59. end
  60. feature -- Access
  61. value: REAL_64 is
  62. -- the current value of the adjustment.
  63. do
  64. Result := gtk_adjustment_get_value (handle)
  65. end
  66. lower: REAL_64 is
  67. -- Retrieves the lowest possible value for this adjustment
  68. do
  69. Result := gtk_adjustment_get_lower (handle)
  70. end
  71. upper: REAL_64 is
  72. -- The maximum value of the adjustment. Note that values will be
  73. -- restricted by upper - page-size if the page-size property is nonzero.
  74. do
  75. Result := gtk_adjustment_get_upper (handle)
  76. end
  77. page_increment: REAL_64 is
  78. -- Retrieves the page increment for this adjustment. In a GtkScrollbar this
  79. -- increment is used when the mouse is clicked in the trough, to scroll by a
  80. -- large amount.
  81. do
  82. Result := gtk_adjustment_get_page_increment (handle)
  83. end
  84. page_size: REAL_64 is
  85. -- Retrieves page size of the adjustment.
  86. -- In a GtkScrollbar this is the size of the area which is currently visible.
  87. -- Irrelevant and should be set to zero if the adjustment is used for a
  88. -- simple scalar value, e.g. in a GtkSpinButton.
  89. do
  90. Result := gtk_adjustment_get_page_size (handle)
  91. end
  92. step_increment: REAL_64 is
  93. -- Retrieves the increment to use to make minor changes to the value.
  94. -- In a GtkScrollbar this increment is used when the mouse is clicked on
  95. -- the arrows at the top and bottom of the scrollbar, to scroll by a
  96. -- small amount.
  97. do
  98. Result := gtk_adjustment_get_step_increment (handle)
  99. end
  100. feature -- Operations
  101. set_value (a_value: REAL_64) is
  102. -- Sets the GtkAdjustment value. The value is clamped to lie
  103. -- between adjustment->lower and adjustment->upper.
  104. -- Note that for adjustments which are used in a
  105. -- GtkScrollbar, the effective range of allowed values goes
  106. -- from adjustment->lower to adjustment->upper -
  107. -- adjustment->page_size.
  108. do
  109. gtk_adjustment_set_value (handle, a_value)
  110. end
  111. set_lower (a_lower: REAL_64) is
  112. -- Sets the lowest possible value for this adjustment
  113. do
  114. gtk_adjustment_set_lower (handle, a_lower)
  115. end
  116. set_upper (an_upper: REAL_64) is
  117. -- Sets the maximum value of the adjustment. Note that values will be
  118. -- restricted by upper - page-size if the page-size property is nonzero.
  119. do
  120. gtk_adjustment_set_upper (handle, an_upper)
  121. end
  122. set_page_increment (a_page_increment: REAL_64) is
  123. -- Sets the page increment for this adjustment. In a GtkScrollbar this
  124. -- increment is used when the mouse is clicked in the trough, to scroll by a
  125. -- large amount.
  126. do
  127. gtk_adjustment_set_page_increment (handle, a_page_increment)
  128. end
  129. set_page_size (a_page_size: REAL_64) is
  130. -- Sets the page size of the adjustment.
  131. -- In a GtkScrollbar this is the size of the area which is currently visible.
  132. -- Irrelevant and should be set to zero if the adjustment is used for a
  133. -- simple scalar value, e.g. in a GtkSpinButton.
  134. do
  135. gtk_adjustment_set_page_size (handle, a_page_size)
  136. end
  137. set_step_increment (a_step_increment: REAL_64) is
  138. -- Sets the increment to use to make minor changes to the value.
  139. -- In a GtkScrollbar this increment is used when the mouse is clicked on
  140. -- the arrows at the top and bottom of the scrollbar, to scroll by a
  141. -- small amount.
  142. do
  143. gtk_adjustment_set_step_increment (handle, a_step_increment)
  144. end
  145. clamp_page (a_lower, an_upper: REAL_64) is
  146. -- Updates the GtkAdjustment value to ensure that the range
  147. -- between lower and upper is in the current page
  148. -- (i.e. between value and value + page_size). If the range
  149. -- is larger than the page size, then only the start of it
  150. -- will be in the current page. A "changed" signal will be
  151. -- emitted if the value is changed.
  152. do
  153. gtk_adjustment_clamp_page (handle, a_lower, an_upper)
  154. end
  155. changed is
  156. -- Emits a "changed" signal from the GtkAdjustment. This is
  157. -- typically called by the owner of the GtkAdjustment after
  158. -- it has changed any of the GtkAdjustment fields other than
  159. -- the value.
  160. do
  161. gtk_adjustment_changed (handle)
  162. end
  163. value_changed is
  164. -- Emits a "value_changed" signal from the
  165. -- GtkAdjustment. This is typically called by the owner of
  166. -- the GtkAdjustment after it has changed the GtkAdjustment
  167. -- value field.
  168. do
  169. gtk_adjustment_value_changed (handle)
  170. end
  171. -- TODO: The "value" property
  172. -- NOTE (achuni): the 'value' feature should be used instead of this, I think
  173. -- Signal Details
  174. -- The "changed" signal
  175. -- void user_function (GtkAdjustment *adjustment, gpointer user_data);
  176. -- Emitted when one or more of the GtkAdjustment fields have been changed, other than the value field.
  177. -- adjustment : the object which received the signal.
  178. -- user_data : user data set when the signal handler was connected.
  179. -- The "value-changed" signal
  180. -- void user_function (GtkAdjustment *adjustment, gpointer user_data);
  181. -- Emitted when the GtkAdjustment value field has been changed.
  182. -- adjustment : the object which received the signal.
  183. -- user_data : user data set when the signal handler was connected.
  184. end