/src/wrappers/gtk/library/gtk_range.e
Specman e | 349 lines | 143 code | 68 blank | 138 comment | 2 complexity | a2c9b688e18d4e07ac55bb73eeb50e11 MD5 | raw file
1indexing 2 description: "GtkRange -- Base class for widgets which visualize an adjustment." 3 copyright: "[ 4 Copyright (C) 2006 eiffel-libraries team, GTK+ team 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public License 8 as published by the Free Software Foundation; either version 2.1 of 9 the License, or (at your option) any later version. 10 11 This library is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Lesser General Public License for more details. 15 16 You should have received a copy of the GNU Lesser General Public 17 License along with this library; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 02110-1301 USA 20 ]" 21 date: "$Date:$" 22 revision: "$Revision:$" 23 24deferred class GTK_RANGE 25 26inherit 27 GTK_WIDGET 28 GTK_RANGE_EXTERNALS 29 30feature -- The adjustment 31 32 adjustment: GTK_ADJUSTMENT is 33 -- the GtkAdjustment which is the "model" object for 34 -- GtkRange. It contains the current value of this range 35 -- object. 36 local 37 factory: G_OBJECT_EXPANDED_FACTORY [GTK_ADJUSTMENT] 38 do 39 Result := factory.unreffed_wrapper_or_void (gtk_range_get_adjustment (handle)) 40 -- GTK documentation says "See gtk_range_set_adjustment() for 41 -- details. The return value does not have a reference added, 42 -- so should not be unreferenced." Instead we just add a 43 -- reference to the adjustment, because there will be an 44 -- effective refence on the Eiffel side 45 -- Result.ref 46 ensure 47 valid_adjustment: Result /= Void 48 end 49 50 set_adjustment (an_adjustment: GTK_ADJUSTMENT) is 51 -- Sets the adjustment to be used as the "model" object for 52 -- this range widget. The adjustment indicates the current 53 -- range value, the minimum and maximum range values, the 54 -- step/page increments used for keybindings and scrolling, 55 -- and the page size. The page size is normally 0 for 56 -- GtkScale and nonzero for GtkScrollbar, and indicates the 57 -- size of the visible area of the widget being scrolled. The 58 -- page size affects the size of the scrollbar slider. 59 require valid_adjustment: an_adjustment /= Void 60 do 61 gtk_range_set_adjustment (handle, an_adjustment.handle) 62 end 63 64feature -- update policy 65 set_continous_update_policy 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 gtk_range_set_update_policy (handle, gtk_update_continuous) 72 ensure is_update_policy_continous 73 end 74 75 is_update_policy_continous: BOOLEAN is 76 -- Sets the update policy for the range. GTK_UPDATE_CONTINUOUS 77 -- means that anytime the range slider is moved, the range value 78 -- will change and the value_changed signal will be 79 -- emitted. 80 do 81 Result := (gtk_range_get_update_policy (handle) = gtk_update_continuous) 82 end 83 84 set_discontinous_update_policy is 85 -- Sets the update policy for the range. GTK_UPDATE_DELAYED 86 -- means that the value will be updated after a brief timeout 87 -- where no slider motion occurs, so updates are spaced by a 88 -- short time rather than continuous. 89 do 90 gtk_range_set_update_policy (handle, gtk_update_discontinuous) 91 ensure is_update_policy_discontinous 92 end 93 94 is_update_policy_discontinous: BOOLEAN is 95 -- Sets the update policy for the range. GTK_UPDATE_DELAYED 96 -- means that the value will be updated after a brief timeout 97 -- where no slider motion occurs, so updates are spaced by a 98 -- short time rather than continuous. 99 do 100 Result := (gtk_range_get_update_policy (handle) = gtk_update_discontinuous) 101 end 102 103 set_delayed_update_policy is 104 -- Sets the update policy for the 105 -- range. GTK_UPDATE_DISCONTINUOUS means that the value will 106 -- only be updated when the user releases the button and ends 107 -- the slider drag operation. 108 do 109 gtk_range_set_update_policy (handle, gtk_update_delayed) 110 ensure is_update_policy_delayed 111 end 112 113 is_update_policy_delayed: BOOLEAN is 114 -- Sets the update policy for the 115 -- range. GTK_UPDATE_DISCONTINUOUS means that the value will 116 -- only be updated when the user releases the button and ends 117 -- the slider drag operation. 118 do 119 Result := (gtk_range_get_update_policy (handle) = gtk_update_delayed) 120 end 121 122feature -- Inverted-ness 123 124 is_inverted: BOOLEAN is 125 -- Is the range inverted? An inverted direction slider moves 126 -- to increase range value. 127 do 128 Result := (gtk_range_get_inverted (handle)).to_boolean 129 end 130 131 set_inverted is 132 -- Ranges normally move from lower to higher values as the 133 -- slider moves from top to bottom or left to right. Inverted 134 -- ranges have higher values at the top or on the right 135 -- rather than on the bottom or left. 136 do 137 gtk_range_set_inverted (handle,1) 138 ensure is_inverted 139 end 140 141 set_normal is 142 -- Ranges normally move from lower to higher values as the 143 -- slider moves from top to bottom or left to right. Inverted 144 -- ranges have higher values at the top or on the right 145 -- rather than on the bottom or left. 146 do 147 gtk_range_set_inverted (handle,0) 148 ensure not is_inverted 149 end 150 151feature -- value 152 153 value: REAL_64 is 154 -- the current value of the range. 155 do 156 Result := gtk_range_get_value (handle) 157 end 158 159 set_value (a_value: REAL_64) is 160 -- Sets the current value of the range; if `a_value' is 161 -- outside the minimum or maximum range values, it will be 162 -- clamped to fit inside them. The range emits the 163 -- "value_changed" signal if the value changes. 164 do 165 gtk_range_set_value (handle, a_value) 166 end 167 168feature -- increments 169 set_increments (a_step, a_page: REAL) is 170 -- Sets the step and page sizes for the range. The step size 171 -- is used when the user clicks the GtkScrollbar arrows or 172 -- moves GtkScale via arrow keys. The page size is used for 173 -- example when moving via Page Up or Page Down keys. 174 do 175 gtk_range_set_increments (handle, a_step, a_page) 176 end 177 178feature -- range 179 180 set_range (a_min,a_max: REAL_64) is 181 -- Sets the allowable values in the GtkRange, and clamps the 182 -- range value to be between min and max. (If the range has a 183 -- non-zero page size, it is clamped between min and max - 184 -- page-size.) -- `a_min': minimum range value; `a_max': 185 -- maximum range value 186 do 187 gtk_range_set_range (handle, a_min, a_max) 188 end 189 190 191 -- Note: The "adjustment", "inverted" property 192 193feature -- TODO: The "update-policy" property 194 -- "update-policy" GtkUpdateType : Read / Write 195 196 -- How the range should be updated on the screen. 197 198 -- Default value: GTK_UPDATE_CONTINUOUS 199 -- Style Property Details 200 201feature -- TODO: The "arrow-displacement-x" style property 202-- "arrow-displacement-x" gint : Read 203 204-- How far in the x direction to move the arrow when the button is depressed. 205 206-- Default value: 0 207feature -- TODO: The "arrow-displacement-y" style property 208-- "arrow-displacement-y" gint : Read 209 210-- How far in the y direction to move the arrow when the button is depressed. 211 212-- Default value: 0 213feature -- TODO: The "slider-width" style property 214-- "slider-width" gint : Read 215 216-- Width of scrollbar or scale thumb. 217 218-- Allowed values: >= 0 219 220-- Default value: 14 221feature -- TODO: The "stepper-size" style property 222-- "stepper-size" gint : Read 223 224-- Length of step buttons at ends. 225 226-- Allowed values: >= 0 227 228-- Default value: 14 229feature -- TODO: The "stepper-spacing" style property 230-- "stepper-spacing" gint : Read 231 232-- Spacing between step buttons and thumb. 233 234-- Allowed values: >= 0 235 236-- Default value: 0 237feature -- TODO: The "trough-border" style property 238-- "trough-border" gint : Read 239 240-- Spacing between thumb/steppers and outer trough bevel. 241 242-- Allowed values: >= 0 243 244-- Default value: 1 245 246feature -- TODO: Signal Details 247 248-- The "adjust-bounds" signal 249 250-- void user_function (GtkRange *range, 251-- gdouble arg1, 252-- gpointer user_data); 253 254-- range : the object which received the signal. 255-- arg1 : 256-- user_data : user data set when the signal handler was connected. 257 258feature -- The "change-value" signal 259 260 -- Since 2.6 261 -- The `change-value' signal is emitted when a scroll action is 262 -- performed on a range. It allows an application to determine the type of 263 -- scroll event that occurred and the resultant new value. The application 264 -- can handle the event itself and return True to prevent further 265 -- processing. Or, by returning False, it can pass the event to other 266 -- handlers until the default GTK+ handler is reached. 267 268 -- The value parameter is unrounded. An application that overrides the 269 -- `change-value' signal is responsible for clamping the value to the 270 -- desired number of decimal digits; the default GTK+ handler clamps the 271 -- value based on range->round_digits. 272 273 -- It is not possible to use delayed update policies in an overridden 274 -- `change-value' handler. 275 276 change_value_signal_name: STRING is "change-value" 277 -- gboolean user_function (GtkRange *range, 278 -- GtkScrollType scroll, 279 -- gdouble value, 280 -- gpointer user_data); 281 282 enable_on_change_value is 283 -- Connects "change-value" signal to `on_change_value' feature. 284 do 285 connect (Current, change_value_signal_name, $on_change_value) 286 end 287 288 on_change_value: INTEGER is 289 -- Built-in change-value signal handler; empty by design; redefine it. 290 do 291 end 292 293 connect_agent_to_change_value_signal (a_function: FUNCTION[ANY, TUPLE [REAL, INTEGER, GTK_RANGE], BOOLEAN]) is 294 -- range : the range that received the signal. 295 -- scroll: the type of scroll action that was performed. 296 -- value : the new value resulting from the scroll action. 297 -- returns: True to prevent other handlers from being invoked for the signal. 298 -- False to propagate the signal further. 299 require 300 valid_function: a_function /= Void 301 wrapper_is_stored: is_eiffel_wrapper_stored 302 local 303 change_value_callback: CHANGE_VALUE_CALLBACK 304 do 305 create change_value_callback.make 306 change_value_callback.connect (Current, a_function) 307 end 308 309-- The "move-slider" signal 310 311-- void user_function (GtkRange *range, 312-- GtkScrollType arg1, 313-- gpointer user_data); 314 315-- Virtual function that moves the slider. Used for keybindings. 316-- range : the GtkRange 317-- arg1 : 318-- user_data : user data set when the signal handler was connected. 319 320feature -- The "value-changed" signal 321-- void user_function (GtkRange *range, 322-- gpointer user_data); 323 324-- Emitted when the range value changes. 325-- range : the GtkRange 326-- user_data : user data set when the signal handler was connected. 327 328 value_changed_signal_name: STRING is "value-changed" 329 330 on_value_changed is 331 -- Built-in value_changed signal handler; empty by design; redefine it. 332 do 333 end 334 335 enable_on_value_changed is 336 -- Connects "value_changed" signal to `on_value_changed' feature. 337 do 338 connect (Current, value_changed_signal_name, $on_value_changed) 339 end 340 341 connect_agent_to_value_changed_signal (a_procedure: PROCEDURE [ANY, TUPLE[GTK_RANGE]]) is 342 require valid_procedure: a_procedure /= Void 343 local value_changed_callback: VALUE_CHANGED_CALLBACK 344 do 345 create value_changed_callback.make 346 value_changed_callback.connect (Current, a_procedure) 347 end 348 349end