Class: Iup::Widget
- Inherits:
-
Object
- Object
- Iup::Widget
- Extended by:
- AttributeBuilders
- Includes:
- CallbackSetter, CommonAttributes
- Defined in:
- lib/wrapped/widget.rb
Overview
Parent class for controls in the library.
Direct Known Subclasses
BackgroundBox, Button, Canvas, ColorBar, ColourDialog, Dial, Dialog, Expander, FileDialog, Fill, FontDialog, Frame, GridBox, HBox, ImageWidget, Label, List, Matrix, Menu, MenuItem, MessageDialog, ProgressBar, ProgressDialog, Radio, Scintilla, ScrollBox, Separator, SplitBox, StretchBox, SubMenu, Tabs, Text, Toggle, Tree, VBox, Val, ZBox
Constant Summary collapse
- @@controlslib =
false
Instance Attribute Summary collapse
-
#handle ⇒ Object
readonly
Unique reference to widget.
Instance Method Summary collapse
-
#assign_handle(name) ⇒ Object
The C handle name for this widget.
-
#enterwindow_cb(callback) ⇒ Object
Action generated when the mouse enters the element.
-
#getfocus_cb(callback) ⇒ Object
Action generated when an element is given keyboard focus.
-
#help_cb(callback) ⇒ Object
Action generated when the user presses F1 at a control.
-
#k_any(callback) ⇒ Object
Action generated when a keyboard event occurs.
-
#killfocus_cb(callback) ⇒ Object
Action generated when an element loses keyboard focus.
-
#leavewindow_cb(callback) ⇒ Object
Action generated when the mouse leaves the element.
-
#map_cb(callback) ⇒ Object
Called right after an element is mapped and its layout updated.
-
#open_controls ⇒ Object
Ensure the controls library is opened.
-
#unmap_cb(callback) ⇒ Object
Called right before an element is unmapped.
Methods included from AttributeBuilders
define_attribute, define_id_attribute, define_id_readonly, define_id_writeonly, define_property_attribute, define_property_writeonly, define_readonly, define_writeonly
Methods included from CallbackSetter
Instance Attribute Details
#handle ⇒ Object (readonly)
Unique reference to widget.
11 12 13 |
# File 'lib/wrapped/widget.rb', line 11 def handle @handle end |
Instance Method Details
#assign_handle(name) ⇒ Object
The C handle name for this widget
14 15 16 |
# File 'lib/wrapped/widget.rb', line 14 def assign_handle name IupLib.IupSetHandle name, @handle end |
#enterwindow_cb(callback) ⇒ Object
Action generated when the mouse enters the element
75 76 77 78 79 80 81 82 83 |
# File 'lib/wrapped/widget.rb', line 75 def enterwindow_cb callback unless callback.arity.zero? raise ArgumentError, 'enterwindow_cb callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'ENTERWINDOW_CB', :plain end |
#getfocus_cb(callback) ⇒ Object
Action generated when an element is given keyboard focus
53 54 55 56 57 58 59 60 61 |
# File 'lib/wrapped/widget.rb', line 53 def getfocus_cb callback unless callback.arity.zero? raise ArgumentError, 'getfocus_cb callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'GETFOCUS_CB', :plain end |
#help_cb(callback) ⇒ Object
Action generated when the user presses F1 at a control
110 111 112 113 114 115 116 117 118 |
# File 'lib/wrapped/widget.rb', line 110 def help_cb callback unless callback.arity.zero? raise ArgumentError, 'help_cb callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'HELP_CB', :plain_v end |
#k_any(callback) ⇒ Object
Action generated when a keyboard event occurs. k_any takes a 1-argument callback, the argument being the character that is pressed.
99 100 101 102 103 104 105 106 107 |
# File 'lib/wrapped/widget.rb', line 99 def k_any callback unless callback.arity == 1 raise ArgumentError, 'k_any callback must take 1 argument, a character' end cb = Proc.new do |ih, c| callback.call c end define_callback cb, 'K_ANY', :i_i end |
#killfocus_cb(callback) ⇒ Object
Action generated when an element loses keyboard focus
64 65 66 67 68 69 70 71 72 |
# File 'lib/wrapped/widget.rb', line 64 def killfocus_cb callback unless callback.arity.zero? raise ArgumentError, 'killfocus_cb callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'KILLFOCUS_CB', :plain end |
#leavewindow_cb(callback) ⇒ Object
Action generated when the mouse leaves the element
86 87 88 89 90 91 92 93 94 |
# File 'lib/wrapped/widget.rb', line 86 def leavewindow_cb callback unless callback.arity.zero? raise ArgumentError, 'leavewindow_cb callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'LEAVEWINDOW_CB', :plain end |
#map_cb(callback) ⇒ Object
Called right after an element is mapped and its layout updated
31 32 33 34 35 36 37 38 39 |
# File 'lib/wrapped/widget.rb', line 31 def map_cb callback unless callback.arity.zero? raise ArgumentError, 'map_cb callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'MAP_CB', :plain end |
#open_controls ⇒ Object
Ensure the controls library is opened
21 22 23 24 25 26 |
# File 'lib/wrapped/widget.rb', line 21 def open_controls unless @@controlslib ControlsLib.IupControlsOpen @@controlslib = true end end |
#unmap_cb(callback) ⇒ Object
Called right before an element is unmapped
42 43 44 45 46 47 48 49 50 |
# File 'lib/wrapped/widget.rb', line 42 def unmap_cb callback unless callback.arity.zero? raise ArgumentError, 'unmap_cb callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'UNMAP_CB', :plain end |