Class: Tk::Spinbox
- Defined in:
- lib/ffi-tk/widget/spinbox.rb
Constant Summary
Constants included from Cget
Constants included from WM
Instance Attribute Summary
Attributes inherited from Widget
Class Method Summary collapse
Instance Method Summary collapse
-
#bbox(index) ⇒ Object
Returns a list of four numbers describing the bounding box of the character given by index.
-
#delete(first, last = None) ⇒ Object
Delete one or more elements of the spinbox.
-
#get ⇒ Object
Returns the spinbox’s string.
-
#icursor(index) ⇒ Object
Arrange for the insertion cursor to be displayed just before the character given by index.
-
#identify(x, y) ⇒ Object
Returns the name of the window element corresponding to coordinates x and y in the spinbox.
-
#index(index) ⇒ Object
Returns the numerical index corresponding to index.
-
#insert(index, string) ⇒ Object
Insert the characters of string just before the character indicated by index.
-
#invoke(element) ⇒ Object
Causes the specified element, either buttondown or buttonup, to be invoked, triggering the action associated with it.
-
#scan_dragto(x) ⇒ Object
This command computes the difference between its x argument and the x argument to the last scan mark command for the widget.
-
#scan_mark(x) ⇒ Object
Records x and the current view in the spinbox window; used in conjunction with later scan dragto commands.
-
#selection_adjust(index) ⇒ Object
Locate the end of the selection nearest to the character given by index, and adjust that end of the selection to be at index (i.e. including but not going beyond index).
-
#selection_clear ⇒ Object
Clear the selection if it is currently in this widget.
-
#selection_element(element = None) ⇒ Object
Sets or gets the currently selected element.
-
#selection_from(index) ⇒ Object
Set the selection anchor point to just before the character given by index.
-
#selection_present ⇒ Object
Returns 1 if there is are characters selected in the spinbox, 0 if nothing is selected.
-
#selection_range(from, to) ⇒ Object
Sets the selection to include the characters starting with the one indexed by start and ending with the one just before end.
-
#selection_to(index) ⇒ Object
If index is before the anchor point, set the selection to the characters from index up to but not including the anchor point.
-
#set(string = None) ⇒ Object
If string is specified, the spinbox will try and set it to this value, otherwise it just returns the spinbox’s string.
-
#validate ⇒ Object
This command is used to force an evaluation of the validateCommand independent of the conditions specified by the validate option.
-
#xview(index = None) ⇒ Object
Returns a list containing two elements.
-
#xview_moveto(fraction) ⇒ Object
Adjusts the view in the window so that the character fraction of the way through the text appears at the left edge of the window.
-
#xview_scroll(number, what) ⇒ Object
This command shifts the view in the window left or right according to number and what.
Methods included from Cget
#cget, option_hash_to_tcl, option_to_ruby, type_to_ruby
Methods included from Configure
Methods inherited from Widget
#execute, #execute_only, #focus, #focus_next, #focus_prev, #initialize, #lower, #raise, #to_tcl
Methods included from Pack
configure, forget, info, pack, #pack, #pack_configure, #pack_forget, #pack_info, #pack_propagate, #pack_slaves, propagate, slaves
Methods included from Destroy
Methods included from Bind
Methods included from Bindtags
Methods included from WM
aspect, attributes, client, colormapwindows, command, deiconify, focusmodel, forget, frame, geometry, grid, group, iconbitmap, iconbitmap_default, iconify, iconmask, iconname, iconphoto, iconphoto_default, iconposition, iconwindow, manage, maxsize, minsize, overrideredirect, positionfrom, protocol, resizable, sizefrom, stackorder, state, title, transient, withdraw, #wm_aspect, #wm_aspect=, #wm_attributes, #wm_client, #wm_client=, #wm_colormapwindows, #wm_colormapwindows=, #wm_command, #wm_command=, #wm_deiconify, #wm_focusmodel, #wm_focusmodel=, #wm_forget, #wm_frame, #wm_geometry, #wm_geometry=, #wm_grid, #wm_grid=, #wm_group, #wm_group=, #wm_iconbitmap, #wm_iconbitmap=, #wm_iconbitmap_default, #wm_iconbitmap_default=, #wm_iconify, #wm_iconmask, #wm_iconmask=, #wm_iconname, #wm_iconname=, #wm_iconphoto, #wm_iconphoto=, #wm_iconphoto_default, #wm_iconphoto_default=, #wm_iconposition, #wm_iconposition=, #wm_iconwindow, #wm_iconwindow=, #wm_manage, #wm_maxsize, #wm_minsize, #wm_overrideredirect, #wm_overrideredirect=, #wm_positionfrom, #wm_positionfrom=, #wm_protocol, #wm_resizable, #wm_sizefrom, #wm_sizefrom=, #wm_stackorder, #wm_state, #wm_state=, #wm_title, #wm_title=, #wm_transient, #wm_transient=, #wm_withdraw
Methods included from Winfo
atom, atomname, cells, children, class_name, colormapfull, containing, depth, exists, fpixels, geometry, height, id, interps, ismapped, manager, name, parent, pathname, pixels, pointerx, pointerxy, pointery, reqheight, reqwidth, rgb, rootx, rooty, screen, screencells, screendepth, screenheight, screenmmheight, screenmmwidth, screenvisual, screenwidth, server, toplevel, viewable, visual, visualid, visualsavailable, vrootheight, vrootwidth, vrootx, vrooty, width, #winfo_atom, #winfo_atomname, #winfo_cells, #winfo_children, #winfo_class, #winfo_colormapfull, #winfo_containing, #winfo_depth, #winfo_exists, #winfo_fpixels, #winfo_geometry, #winfo_height, #winfo_id, #winfo_interps, #winfo_ismapped, #winfo_manager, #winfo_name, #winfo_parent, #winfo_pathname, #winfo_pixels, #winfo_pointerx, #winfo_pointerxy, #winfo_pointery, #winfo_reqheight, #winfo_reqwidth, #winfo_rgb, #winfo_rootx, #winfo_rooty, #winfo_screen, #winfo_screencells, #winfo_screendepth, #winfo_screenheight, #winfo_screenmmheight, #winfo_screenmmwidth, #winfo_screenvisual, #winfo_screenwidth, #winfo_server, #winfo_toplevel, #winfo_viewable, #winfo_visual, #winfo_visualid, #winfo_visualsavailable, #winfo_vrootheight, #winfo_vrootwidth, #winfo_vrootx, #winfo_vrooty, #winfo_width, #winfo_x, #winfo_y, x, y
Methods included from Grid
anchor, bbox, columnconfigure, configure, forget, #grid_anchor, #grid_bbox, #grid_columnconfigure, #grid_configure, #grid_forget, #grid_info, #grid_location, #grid_propagate, #grid_remove, #grid_rowconfigure, #grid_size, #grid_slave, #grid_slaves, info, location, propagate, remove, rowconfigure, size, slave, slaves
Methods included from Clipboard
append, clear, #clipboard_append, #clipboard_clear, #clipboard_get, #clipboard_set, get
Methods included from Place
configure, forget, info, place, #place, #place_configure, #place_forget, #place_info, #place_slaves, slaves
Methods included from TkCmd
appname, caret, inactive, scaling, #tk_appname, #tk_appname=, #tk_caret, #tk_inactive, #tk_scaling, #tk_scaling=, #tk_useinputmethods, #tk_useinputmethods=, #tk_windowingsystem, useinputmethods, windowingsystem
Constructor Details
This class inherits a constructor from Tk::Widget
Class Method Details
.tk_command ⇒ Object
5 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 5 def self.tk_command; 'spinbox'; end |
Instance Method Details
#bbox(index) ⇒ Object
Returns a list of four numbers describing the bounding box of the character given by index. The first two elements of the list give the x and y coordinates of the upper-left corner of the screen area covered by the character (in pixels relative to the widget) and the last two elements give the width and height of the character, in pixels. The bounding box may refer to a region outside the visible area of the window.
15 16 17 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 15 def bbox(index) execute(:bbox, index).to_a(&:to_i) end |
#delete(first, last = None) ⇒ Object
Delete one or more elements of the spinbox. First is the index of the first character to delete, and last is the index of the character just after the last one to delete. If last is not specified it defaults to first+1, i.e. a single character is deleted. This command returns an empty string.
25 26 27 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 25 def delete(first, last = None) execute_only(:delete, first, last) end |
#get ⇒ Object
Returns the spinbox’s string.
30 31 32 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 30 def get execute(:get) end |
#icursor(index) ⇒ Object
Arrange for the insertion cursor to be displayed just before the character given by index.
36 37 38 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 36 def icursor(index) execute_only(:icursor, index) end |
#identify(x, y) ⇒ Object
Returns the name of the window element corresponding to coordinates x and y in the spinbox. Return value is one of: none, buttondown, buttonup, entry.
43 44 45 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 43 def identify(x, y) execute(:identify, x, y).to_sym end |
#index(index) ⇒ Object
Returns the numerical index corresponding to index.
48 49 50 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 48 def index(index) execute(:index, index) end |
#insert(index, string) ⇒ Object
Insert the characters of string just before the character indicated by index. Returns an empty string.
54 55 56 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 54 def insert(index, string) execute_only(:insert, index, string) end |
#invoke(element) ⇒ Object
Causes the specified element, either buttondown or buttonup, to be invoked, triggering the action associated with it.
60 61 62 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 60 def invoke(element) execute(:invoke, element) end |
#scan_dragto(x) ⇒ Object
This command computes the difference between its x argument and the x argument to the last scan mark command for the widget. It then adjusts the view left or right by 10 times the difference in x-coordinates. This command is typically associated with mouse motion events in the widget, to produce the effect of dragging the spinbox at high speed through the window.
78 79 80 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 78 def scan_dragto(x) execute_only(:scan, :dragto, x) end |
#scan_mark(x) ⇒ Object
Records x and the current view in the spinbox window; used in conjunction with later scan dragto commands. Typically this command is associated with a mouse button press in the widget.
68 69 70 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 68 def scan_mark(x) execute_only(:scan, :mark, x) end |
#selection_adjust(index) ⇒ Object
Locate the end of the selection nearest to the character given by index, and adjust that end of the selection to be at index (i.e. including but not going beyond index). The other end of the selection is made the anchor point for future select to commands. If the selection is not currently in the spinbox, then a new selection is created to include the characters between index and the most recent selection anchor point, inclusive.
90 91 92 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 90 def selection_adjust(index) execute_only(:selection, :adjust, index) end |
#selection_clear ⇒ Object
Clear the selection if it is currently in this widget. If the selection is not in this widget then the command has no effect.
96 97 98 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 96 def selection_clear execute_only(:selection, :clear) end |
#selection_element(element = None) ⇒ Object
Sets or gets the currently selected element. If a spinbutton element is specified, it will be displayed depressed.
102 103 104 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 102 def selection_element(element = None) execute(:selection, :element, element) end |
#selection_from(index) ⇒ Object
Set the selection anchor point to just before the character given by index. Does not change the selection.
108 109 110 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 108 def selection_from(index) execute_only(:selection, :from, index) end |
#selection_present ⇒ Object
Returns 1 if there is are characters selected in the spinbox, 0 if nothing is selected.
114 115 116 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 114 def selection_present execute(:selection, :present).to_boolean end |
#selection_range(from, to) ⇒ Object
Sets the selection to include the characters starting with the one indexed by start and ending with the one just before end. If end refers to the same character as start or an earlier one, then the spinbox’s selection is cleared.
122 123 124 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 122 def selection_range(from, to) execute(:selection, :range, from, to) end |
#selection_to(index) ⇒ Object
If index is before the anchor point, set the selection to the characters from index up to but not including the anchor point. If index is the same as the anchor point, do nothing. If index is after the anchor point, set the selection to the characters from the anchor point up to but not including index. The anchor point is determined by the most recent select from or select adjust command in this widget. If the selection is not in this widget then a new selection is created using the most recent anchor point specified for the widget. Returns an empty string.
136 137 138 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 136 def selection_to(index) execute(:selection, :to, index) end |
#set(string = None) ⇒ Object
If string is specified, the spinbox will try and set it to this value, otherwise it just returns the spinbox’s string. If validation is on, it will occur when setting the string.
143 144 145 146 147 148 149 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 143 def set(string = None) if None == string execute(:set) else execute_only(:set, string) end end |
#validate ⇒ Object
This command is used to force an evaluation of the validateCommand independent of the conditions specified by the validate option. This is done by temporarily setting the validate option to all. It returns 0 or 1.
155 156 157 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 155 def validate execute(:validate).to_boolean end |
#xview(index = None) ⇒ Object
Returns a list containing two elements. Each element is a real fraction between 0 and 1; together they describe the horizontal span that is visible in the window. For example, if the first element is .2 and the second element is .6, 20% of the spinbox’s text is off-screen to the left, the middle 40% is visible in the window, and 40% of the text is off-screen to the right. These are the same values passed to scrollbars via the -xscrollcommand option.
Adjusts the view in the window so that the character given by index is displayed at the left edge of the window.
170 171 172 173 174 175 176 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 170 def xview(index = None) if None == index execute(:xview) else execute_only(:xview, index) end end |
#xview_moveto(fraction) ⇒ Object
Adjusts the view in the window so that the character fraction of the way through the text appears at the left edge of the window. Fraction must be a fraction between 0 and 1.
181 182 183 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 181 def xview_moveto(fraction) execute(:xview, :moveto, fraction) end |
#xview_scroll(number, what) ⇒ Object
This command shifts the view in the window left or right according to number and what. Number must be an integer. What must be either units or pages or an abbreviation of one of these. If what is units, the view adjusts left or right by number average-width characters on the display; if it is pages then the view adjusts by number screenfuls. If number is negative then characters farther to the left become visible; if it is positive then characters farther to the right become visible.
194 195 196 |
# File 'lib/ffi-tk/widget/spinbox.rb', line 194 def xview_scroll(number, what) execute(:xview, :scroll, number, what) end |