/src/wrappers/gtk/library/gtk_range.e

http://github.com/tybor/Liberty · Specman e · 349 lines · 143 code · 68 blank · 138 comment · 2 complexity · a2c9b688e18d4e07ac55bb73eeb50e11 MD5 · raw file

  1. indexing
  2. description: "GtkRange -- Base class for widgets which visualize an adjustment."
  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. deferred class GTK_RANGE
  21. inherit
  22. GTK_WIDGET
  23. GTK_RANGE_EXTERNALS
  24. feature -- The adjustment
  25. adjustment: GTK_ADJUSTMENT is
  26. -- the GtkAdjustment which is the "model" object for
  27. -- GtkRange. It contains the current value of this range
  28. -- object.
  29. local
  30. factory: G_OBJECT_EXPANDED_FACTORY [GTK_ADJUSTMENT]
  31. do
  32. Result := factory.unreffed_wrapper_or_void (gtk_range_get_adjustment (handle))
  33. -- GTK documentation says "See gtk_range_set_adjustment() for
  34. -- details. The return value does not have a reference added,
  35. -- so should not be unreferenced." Instead we just add a
  36. -- reference to the adjustment, because there will be an
  37. -- effective refence on the Eiffel side
  38. -- Result.ref
  39. ensure
  40. valid_adjustment: Result /= Void
  41. end
  42. set_adjustment (an_adjustment: GTK_ADJUSTMENT) is
  43. -- Sets the adjustment to be used as the "model" object for
  44. -- this range widget. The adjustment indicates the current
  45. -- range value, the minimum and maximum range values, the
  46. -- step/page increments used for keybindings and scrolling,
  47. -- and the page size. The page size is normally 0 for
  48. -- GtkScale and nonzero for GtkScrollbar, and indicates the
  49. -- size of the visible area of the widget being scrolled. The
  50. -- page size affects the size of the scrollbar slider.
  51. require valid_adjustment: an_adjustment /= Void
  52. do
  53. gtk_range_set_adjustment (handle, an_adjustment.handle)
  54. end
  55. feature -- update policy
  56. set_continous_update_policy is
  57. -- Sets the update policy for the range. GTK_UPDATE_CONTINUOUS
  58. -- means that anytime the range slider is moved, the range value
  59. -- will change and the value_changed signal will be
  60. -- emitted.
  61. do
  62. gtk_range_set_update_policy (handle, gtk_update_continuous)
  63. ensure is_update_policy_continous
  64. end
  65. is_update_policy_continous: BOOLEAN is
  66. -- Sets the update policy for the range. GTK_UPDATE_CONTINUOUS
  67. -- means that anytime the range slider is moved, the range value
  68. -- will change and the value_changed signal will be
  69. -- emitted.
  70. do
  71. Result := (gtk_range_get_update_policy (handle) = gtk_update_continuous)
  72. end
  73. set_discontinous_update_policy is
  74. -- Sets the update policy for the range. GTK_UPDATE_DELAYED
  75. -- means that the value will be updated after a brief timeout
  76. -- where no slider motion occurs, so updates are spaced by a
  77. -- short time rather than continuous.
  78. do
  79. gtk_range_set_update_policy (handle, gtk_update_discontinuous)
  80. ensure is_update_policy_discontinous
  81. end
  82. is_update_policy_discontinous: BOOLEAN is
  83. -- Sets the update policy for the range. GTK_UPDATE_DELAYED
  84. -- means that the value will be updated after a brief timeout
  85. -- where no slider motion occurs, so updates are spaced by a
  86. -- short time rather than continuous.
  87. do
  88. Result := (gtk_range_get_update_policy (handle) = gtk_update_discontinuous)
  89. end
  90. set_delayed_update_policy is
  91. -- Sets the update policy for the
  92. -- range. GTK_UPDATE_DISCONTINUOUS means that the value will
  93. -- only be updated when the user releases the button and ends
  94. -- the slider drag operation.
  95. do
  96. gtk_range_set_update_policy (handle, gtk_update_delayed)
  97. ensure is_update_policy_delayed
  98. end
  99. is_update_policy_delayed: BOOLEAN is
  100. -- Sets the update policy for the
  101. -- range. GTK_UPDATE_DISCONTINUOUS means that the value will
  102. -- only be updated when the user releases the button and ends
  103. -- the slider drag operation.
  104. do
  105. Result := (gtk_range_get_update_policy (handle) = gtk_update_delayed)
  106. end
  107. feature -- Inverted-ness
  108. is_inverted: BOOLEAN is
  109. -- Is the range inverted? An inverted direction slider moves
  110. -- to increase range value.
  111. do
  112. Result := (gtk_range_get_inverted (handle)).to_boolean
  113. end
  114. set_inverted is
  115. -- Ranges normally move from lower to higher values as the
  116. -- slider moves from top to bottom or left to right. Inverted
  117. -- ranges have higher values at the top or on the right
  118. -- rather than on the bottom or left.
  119. do
  120. gtk_range_set_inverted (handle,1)
  121. ensure is_inverted
  122. end
  123. set_normal is
  124. -- Ranges normally move from lower to higher values as the
  125. -- slider moves from top to bottom or left to right. Inverted
  126. -- ranges have higher values at the top or on the right
  127. -- rather than on the bottom or left.
  128. do
  129. gtk_range_set_inverted (handle,0)
  130. ensure not is_inverted
  131. end
  132. feature -- value
  133. value: REAL_64 is
  134. -- the current value of the range.
  135. do
  136. Result := gtk_range_get_value (handle)
  137. end
  138. set_value (a_value: REAL_64) is
  139. -- Sets the current value of the range; if `a_value' is
  140. -- outside the minimum or maximum range values, it will be
  141. -- clamped to fit inside them. The range emits the
  142. -- "value_changed" signal if the value changes.
  143. do
  144. gtk_range_set_value (handle, a_value)
  145. end
  146. feature -- increments
  147. set_increments (a_step, a_page: REAL) is
  148. -- Sets the step and page sizes for the range. The step size
  149. -- is used when the user clicks the GtkScrollbar arrows or
  150. -- moves GtkScale via arrow keys. The page size is used for
  151. -- example when moving via Page Up or Page Down keys.
  152. do
  153. gtk_range_set_increments (handle, a_step, a_page)
  154. end
  155. feature -- range
  156. set_range (a_min,a_max: REAL_64) is
  157. -- Sets the allowable values in the GtkRange, and clamps the
  158. -- range value to be between min and max. (If the range has a
  159. -- non-zero page size, it is clamped between min and max -
  160. -- page-size.) -- `a_min': minimum range value; `a_max':
  161. -- maximum range value
  162. do
  163. gtk_range_set_range (handle, a_min, a_max)
  164. end
  165. -- Note: The "adjustment", "inverted" property
  166. feature -- TODO: The "update-policy" property
  167. -- "update-policy" GtkUpdateType : Read / Write
  168. -- How the range should be updated on the screen.
  169. -- Default value: GTK_UPDATE_CONTINUOUS
  170. -- Style Property Details
  171. feature -- TODO: The "arrow-displacement-x" style property
  172. -- "arrow-displacement-x" gint : Read
  173. -- How far in the x direction to move the arrow when the button is depressed.
  174. -- Default value: 0
  175. feature -- TODO: The "arrow-displacement-y" style property
  176. -- "arrow-displacement-y" gint : Read
  177. -- How far in the y direction to move the arrow when the button is depressed.
  178. -- Default value: 0
  179. feature -- TODO: The "slider-width" style property
  180. -- "slider-width" gint : Read
  181. -- Width of scrollbar or scale thumb.
  182. -- Allowed values: >= 0
  183. -- Default value: 14
  184. feature -- TODO: The "stepper-size" style property
  185. -- "stepper-size" gint : Read
  186. -- Length of step buttons at ends.
  187. -- Allowed values: >= 0
  188. -- Default value: 14
  189. feature -- TODO: The "stepper-spacing" style property
  190. -- "stepper-spacing" gint : Read
  191. -- Spacing between step buttons and thumb.
  192. -- Allowed values: >= 0
  193. -- Default value: 0
  194. feature -- TODO: The "trough-border" style property
  195. -- "trough-border" gint : Read
  196. -- Spacing between thumb/steppers and outer trough bevel.
  197. -- Allowed values: >= 0
  198. -- Default value: 1
  199. feature -- TODO: Signal Details
  200. -- The "adjust-bounds" signal
  201. -- void user_function (GtkRange *range,
  202. -- gdouble arg1,
  203. -- gpointer user_data);
  204. -- range : the object which received the signal.
  205. -- arg1 :
  206. -- user_data : user data set when the signal handler was connected.
  207. feature -- The "change-value" signal
  208. -- Since 2.6
  209. -- The `change-value' signal is emitted when a scroll action is
  210. -- performed on a range. It allows an application to determine the type of
  211. -- scroll event that occurred and the resultant new value. The application
  212. -- can handle the event itself and return True to prevent further
  213. -- processing. Or, by returning False, it can pass the event to other
  214. -- handlers until the default GTK+ handler is reached.
  215. -- The value parameter is unrounded. An application that overrides the
  216. -- `change-value' signal is responsible for clamping the value to the
  217. -- desired number of decimal digits; the default GTK+ handler clamps the
  218. -- value based on range->round_digits.
  219. -- It is not possible to use delayed update policies in an overridden
  220. -- `change-value' handler.
  221. change_value_signal_name: STRING is "change-value"
  222. -- gboolean user_function (GtkRange *range,
  223. -- GtkScrollType scroll,
  224. -- gdouble value,
  225. -- gpointer user_data);
  226. enable_on_change_value is
  227. -- Connects "change-value" signal to `on_change_value' feature.
  228. do
  229. connect (Current, change_value_signal_name, $on_change_value)
  230. end
  231. on_change_value: INTEGER is
  232. -- Built-in change-value signal handler; empty by design; redefine it.
  233. do
  234. end
  235. connect_agent_to_change_value_signal (a_function: FUNCTION[ANY, TUPLE [REAL, INTEGER, GTK_RANGE], BOOLEAN]) is
  236. -- range : the range that received the signal.
  237. -- scroll: the type of scroll action that was performed.
  238. -- value : the new value resulting from the scroll action.
  239. -- returns: True to prevent other handlers from being invoked for the signal.
  240. -- False to propagate the signal further.
  241. require
  242. valid_function: a_function /= Void
  243. wrapper_is_stored: is_eiffel_wrapper_stored
  244. local
  245. change_value_callback: CHANGE_VALUE_CALLBACK
  246. do
  247. create change_value_callback.make
  248. change_value_callback.connect (Current, a_function)
  249. end
  250. -- The "move-slider" signal
  251. -- void user_function (GtkRange *range,
  252. -- GtkScrollType arg1,
  253. -- gpointer user_data);
  254. -- Virtual function that moves the slider. Used for keybindings.
  255. -- range : the GtkRange
  256. -- arg1 :
  257. -- user_data : user data set when the signal handler was connected.
  258. feature -- The "value-changed" signal
  259. -- void user_function (GtkRange *range,
  260. -- gpointer user_data);
  261. -- Emitted when the range value changes.
  262. -- range : the GtkRange
  263. -- user_data : user data set when the signal handler was connected.
  264. value_changed_signal_name: STRING is "value-changed"
  265. on_value_changed is
  266. -- Built-in value_changed signal handler; empty by design; redefine it.
  267. do
  268. end
  269. enable_on_value_changed is
  270. -- Connects "value_changed" signal to `on_value_changed' feature.
  271. do
  272. connect (Current, value_changed_signal_name, $on_value_changed)
  273. end
  274. connect_agent_to_value_changed_signal (a_procedure: PROCEDURE [ANY, TUPLE[GTK_RANGE]]) is
  275. require valid_procedure: a_procedure /= Void
  276. local value_changed_callback: VALUE_CHANGED_CALLBACK
  277. do
  278. create value_changed_callback.make
  279. value_changed_callback.connect (Current, a_procedure)
  280. end
  281. end