PageRenderTime 24ms CodeModel.GetById 12ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

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