class Iup::ScrollBox
A container holding a single child widget, enabling that child widget to be scrolled.
Attributes¶ ↑
- border
-
Set to show a border around the scrollbox. Values 'yes' / 'no'.
- canfocus
-
Always 'no' - control cannot gain focus.
- clientoffset
-
read-only, returns current offset of box in its client as “widthxheight”.
- clientsize
-
read-only, returns current size of box as “widthxheight”.
- cursor
-
Name of the mouse shape / cursor for the scrollbox.
- drawsize
-
Size of drawing area in pixels, as “widthxheight”.
- expand
-
Allows container to fill available space in indicated direction. Values 'no' / 'horizontal' / 'vertical' / 'yes'.
- padding
-
Margin in x and y directions in pixels, value as “mxn”.
- position
-
read-only returns position in pixels within client window as “x,y”.
- rastersize
-
Size of the container, in pixels, value as “widthxheight”.
- screenposition
-
read-only returns position in pixels on screen as “x,y”.
- scrollbar
-
Selects 'no' / 'horizontal' / 'vertical' / 'yes' (for both) scrollbars.
- tip
-
Tooltip string.
Public Class Methods
Creates a new instance of the container.
- child
-
a child widget
- block
-
optional block to set up attributes
# File lib/wrapped/scrollbox.rb, line 33 def initialize child, &block @handle = IupLib.IupScrollBox child.handle # run any provided block on instance, to set up further attributes self.instance_eval &block if block_given? end
Public Instance Methods
Action generated when the scrollbar needs to be redrawn. action takes a callback which accepts 2 arguments (posx, posy). posx, posy are the position of the horizontal and vertical thumbs of the scrollbar.
# File lib/wrapped/scrollbox.rb, line 60 def action callback unless callback.arity == 2 raise ArgumentError, 'action must take 2 arguments: (posx, posy)' end cb = Proc.new do |ih, posx, posy| callback.call posx, posy end define_callback cb, 'ACTION', :ff_i end
Called when the scrollbar gets or loses the keyboard focus. Callback takes a single parameter: (focus)
- focus
-
non-zero if canvas gaining focus, else zero.
# File lib/wrapped/scrollbox.rb, line 75 def focus_cb callback unless callback.arity == 1 raise ArgumentError, 'focus_cb callback must take 1 argument, the focus' end cb = Proc.new do |ih, focus| callback.call focus end define_callback cb, 'FOCUS_CB', :i_i end
Action generated when a key is pressed or released. keypress_cb
takes a 2-argument callback: (character, pressed). pressed == 1 if key is pressed, pressed == 0 if key is released.
# File lib/wrapped/scrollbox.rb, line 89 def keypress_cb callback unless callback.arity == 2 raise ArgumentError, 'keypress_cb callback must take 2 arguments: (char, press)' end cb = Proc.new do |ih, char, press| callback.call char, press end define_callback cb, 'KEYPRESS_CB', :ii_i end
Action generated when the mouse is moved. Callback takes 3 arguments: (x, y, state)
- x
-
x position of mouse
- y
-
y position of mouse
- state
-
status of mouse buttons and certain keyboard keys at the moment the event was generated.
# File lib/wrapped/scrollbox.rb, line 107 def motion_cb callback unless callback.arity == 3 raise ArgumentError, 'motion_cb callback must take 3 arguments: (x, y, state)' end cb = Proc.new do |ih, x, y, state| callback.call x, y, state end define_callback cb, 'MOTION_CB', :iis_i end
Action generated when the scrollbar size is changed. resize_cb
a 2-argument callback: (width, height).
- width
-
internal width of canvas (client width)
- height
-
internal height of canvas (client height)
# File lib/wrapped/scrollbox.rb, line 121 def resize_cb callback unless callback.arity == 2 raise ArgumentError, 'resize_cb callback must take 2 arguments: (width, height)' end cb = Proc.new do |ih, width, height| callback.call width, height end define_callback cb, 'RESIZE_CB', :ii_i end
Action generated when the mouse wheel is rotated. wheel_cb
a 4-argument callback: (delta, x, y, status).
- delta
-
the amount the wheel was rotated in notches.
- x, y
-
position in the canvas where the event has occurred, in pixels.
- status
-
status of mouse buttons and certain keyboard keys at the moment the event was generated.
# File lib/wrapped/scrollbox.rb, line 136 def wheel_cb callback unless callback.arity == 4 raise ArgumentError, 'wheel_cb callback must take 4 arguments: (delta, x, y, status)' end cb = Proc.new do |ih, delta, x, y, status_ptr| status = FFI::Pointer.new(status_ptr).read_string callback.call delta, x, y, status end define_callback cb, 'WHEEL_CB', :fiis_i end