module Iup
Iup is the main module, in which all controls and widgets are named.
The module also provides constants and supporting methods.
Public Class Methods
Source
# File lib/wrapped/messagedialog.rb, line 17 def self.alarm title, msg, button1, button2=nil, button3=nil IupLib.IupAlarm(title, msg, button1, button2, button3) end
Creates and shows an AlarmDialog, returning the number of the button clicked.
-
title- the title of the dialog window -
msg- the text to display within the dialog -
button1- label for the first button -
button2- label for the optional second button -
button3- label for the optional third button
Returns index of clicked button (1, 2 or 3).
result = Iup.alarm("Vegetable time", "Pick a vegetable", "cabbage", "carrots", "peas")
Also see: MessageDialog
Source
# File lib/wrapped/colordialog.rb, line 13 def self.get_color x=0, y=0 r = FFI::MemoryPointer.new(:int, 1, 0) g = FFI::MemoryPointer.new(:int, 1, 0) b = FFI::MemoryPointer.new(:int, 1, 0) code = IupLib.IupGetColor x, y, r, g, b if code == 0 return nil else return r.read_int, g.read_int, b.read_int end end
Shows a modal dialog to select a color.
-
x,y- optional coordinates to place the dialog
Returns r/g/b triple of selected color, or nil if “cancel” clicked.
r, g, b = Iup.get_color(150, 150)
Also see: ColorDialog
Source
# File lib/wrapped/filedialog.rb, line 17 def self.get_file filter='' file = ' '*(256-filter.size) + filter code = IupLib.IupGetFile(file) case code when 0, 1 filename = file[0...file.index("\0")] return code, filename else return code, '' end end
Convenience function to show a modal dialog to select a filename.
-
filter- path + filter for files to show
Returns the status code and selected filename: status is an integer, 1 for new file, 0 for existing file/directory, or -1 for cancelled.
Also see: FileDialog
For example, select a filename ending in “.txt” from current directory.
code, file = Iup.get_file('./*.txt')
Source
# File lib/wrapped/iup-global.rb, line 31 def self.global(name, val=nil) if val.nil? IupLib.IupGetGlobal(name).first else IupLib.IupSetGlobal(name, val) end end
Accesses the global variable ‘name’. Provide a value for ‘val’ to set the variable, or leave as nil to get the variable.
Source
# File lib/wrapped/iup-global.rb, line 40 def self.idle callback unless callback.nil? or callback.arity.zero? raise ArgumentError 'callback to idle must take no arguments' end IupLib.IupSetFunction('IDLE_ACTION', callback) end
Sets the idle_action
Source
# File lib/wrapped/list.rb, line 15 def self.listdialog(title, items) strptrs = [] strptrs << nil items_ptr = FFI::MemoryPointer.new(:pointer, items.length) items.each_with_index do |item, i| items_ptr[i].put_pointer(0, FFI::MemoryPointer.from_string(item)) end code = IupLib.IupListDialog(1, title, items.length, items_ptr, 1, 1, 10, nil) return (code == -1 ? nil : items[code]) end
Convenience function to show a modal dialog to select an item from a list.
-
title- title for dialog -
items- list of items (strings) to display
Returns selected item, or nil if cancel clicked.
selection = Iup.listdialog('select one', ['C', 'Java', 'Ruby', 'Scheme']) puts "Return #{selection}"
Also see: List
Source
# File lib/wrapped/image.rb, line 6 def self.load_image filename if File.exist?(filename) handle = ImLib.IupLoadImage(filename) puts handle # TODO - broken? image = ImageWidget.new image.handle = handle return image else raise RuntimeError, "File does not exist", filename end end
Loads an image from file, returning an ImageWidget instance.
-
filename- name of image file
Raises RuntimeError if no file of given filename exists.
Source
# File lib/wrapped/iup-global.rb, line 16 def self.mainloop begin IupLib.IupOpen(0, nil) ImgLib.IupImageLibOpen() yield IupLib.IupMainLoop ensure IupLib.IupClose end end
All IUP GUI code must be called via a block passed to this method, as in this minimal example.
Iup.mainloop do label = Iup::Label.new("Hello World!") Iup::Dialog.new label do |d| d.title = ' ... from IUP' d.size = '150x50' end.show end
Source
# File lib/wrapped/messagedialog.rb, line 33 def self.message(title, value) IupLib.IupMessage(title, value) end
Convenience function to show a MessageDialog with given title and displayed message value. This is an “information” dialog, with a single button labelled “ok”.
Iup.message("About", <<MSG) My Ruby Application Date: January 2026 MSG
Also see: MessageDialog
Button values
Constants
- BUTTON1
-
Left mouse button
- BUTTON2
-
Middle mouse button
- BUTTON3
-
Right mouse button
- BUTTON4
-
Extra button
- BUTTON5
-
Extra button
CD background opacity mode
Constants
- CD_OPAQUE
- CD_TRANSPARENT
CD bitmap data
Constants
- CD_COLORS
- CD_IALPHA
- CD_IBLUE
- CD_IGREEN
- CD_INDEX
- CD_IRED
CD bitmap type
Constants
- CD_MAP
- CD_RGB
- CD_RGBA
CD clip mode
Constants
- CD_CLIPAREA
- CD_CLIPOFF
- CD_CLIPPOLYGON
- CD_CLIPREGION
CD color allocation mode (palette)
Constants
- CD_FORCE
- CD_POLITE
CD colors
Constants
- CD_BLACK
- CD_BLUE
- CD_CYAN
- CD_DARK_BLUE
- CD_DARK_CYAN
- CD_DARK_GRAY
- CD_DARK_GREEN
- CD_DARK_MAGENTA
- CD_DARK_RED
- CD_DARK_YELLOW
- CD_GRAY
- CD_GREEN
- CD_MAGENTA
- CD_RED
- CD_WHITE
- CD_YELLOW
CD context capabilities
Constants
- CD_CAP_ALL
- CD_CAP_BACKGROUND
- CD_CAP_BACKOPACITY
- CD_CAP_BEZIER
- CD_CAP_CHORD
- CD_CAP_CLEAR
- CD_CAP_CLIPAREA
- CD_CAP_CLIPPOLY
- CD_CAP_FLUSH
- CD_CAP_FONT
- CD_CAP_FONTDIM
- CD_CAP_FPRIMTIVES
- CD_CAP_GETIMAGERGB
- CD_CAP_HATCH
- CD_CAP_IMAGEMAP
- CD_CAP_IMAGERGB
- CD_CAP_IMAGERGBA
- CD_CAP_IMAGESRV
- CD_CAP_LINECAP
- CD_CAP_LINEJOIN
- CD_CAP_LINESTYLE
- CD_CAP_LINEWITH
- CD_CAP_NONE
- CD_CAP_PALETTE
- CD_CAP_PATH
- CD_CAP_PATTERN
- CD_CAP_PLAY
- CD_CAP_RECT
- CD_CAP_REGION
- CD_CAP_STIPPLE
- CD_CAP_TEXTORIENTATION
- CD_CAP_TEXTSIZE
- CD_CAP_WRITEMODE
- CD_CAP_YAXIS
CD conversion factors
Constants
- CD_DEG2RAD
-
degrees to radians (rad =
CD_DEG2RAD* deg) - CD_MM2PT
-
milimeters to points (pt =
CD_MM2PT* mm) - CD_RAD2DEG
-
radians to degrees (deg =
CD_RAD2DEG* rad)
CD fill mode
Constants
- CD_EVENODD
- CD_WINDING
CD font sizes
Constants
- CD_LARGE
- CD_SMALL
- CD_STANDARD
CD hatch type
Constants
- CD_BDIAGONAL
- CD_CROSS
- CD_DIAGCROSS
- CD_FDIAGONAL
- CD_HORIZONTAL
- CD_VERTICAL
CD interior style
Constants
- CD_HATCH
- CD_HOLLOW
- CD_PATTERN
- CD_SOLID
- CD_STIPPLE
CD library
Constants
- CD_QUERY
CD line cap
Constants
- CD_CAPFLAT
- CD_CAPROUND
- CD_CAPSQUARE
CD line join
Constants
- CD_BEVEL
- CD_MITER
- CD_ROUND
CD line style
Constants
- CD_CONTINUOUS
- CD_CUSTOM
- CD_DASHED
- CD_DASH_DOT
- CD_DASH_DOT_DOT
- CD_DOTTED
CD mark type
Constants
- CD_BOX
- CD_CIRCLE
- CD_DIAMOND
- CD_HOLLOW_BOX
- CD_HOLLOW_CIRCLE
- CD_HOLLOW_DIAMOND
- CD_PLUS
- CD_STAR
- CD_X
CD path action
Constants
- CD_PATH_ARC
- CD_PATH_CLIP
- CD_PATH_CLOSE
- CD_PATH_CURVETO
- CD_PATH_FILL
- CD_PATH_FILLSTROKE
- CD_PATH_LINETO
- CD_PATH_MOVETO
- CD_PATH_NEW
- CD_PATH_STROKE
CD polygon mode
Constants
- CD_BEZIER
- CD_CLIP
- CD_CLOSED_LINES
- CD_FILL
- CD_OPEN_LINES
- CD_PATH
- CD_POLYCUSTOM
- CD_REGION
CD region combine mode
Constants
- CD_DIFFERENCE
- CD_INTERSECT
- CD_NOTINTERSECT
- CD_UNION
CD simulation flags
Constants
- CD_SIM_ALL
- CD_SIM_ARC
- CD_SIM_BOX
- CD_SIM_CHORD
- CD_SIM_FILLS
- CD_SIM_LINE
- CD_SIM_LINES
- CD_SIM_NONE
- CD_SIM_POLYGON
- CD_SIM_POLYLINE
- CD_SIM_RECT
- CD_SIM_SECTOR
- CD_SIM_TEXT
CD status report
Constants
- CD_ERROR
- CD_OK
CD text alignment
Constants
- CD_BASE_CENTER
- CD_BASE_LEFT
- CD_BASE_RIGHT
- CD_CENTER
- CD_EAST
- CD_NORTH
- CD_NORTH_EAST
- CD_NORTH_WEST
- CD_SOUTH
- CD_SOUTH_EAST
- CD_SOUTH_WEST
- CD_WEST
CD text style
Constants
- CD_BOLD
- CD_BOLD_ITALIC
-
compatibility name
- CD_ITALIC
- CD_PLAIN
- CD_STRIKEOUT
- CD_UNDERLINE
CD write mode
Constants
- CD_NOT_XOR
- CD_REPLACE
- CD_XOR
Callback return values
Constants
- CLOSE
-
Calls
IupExitLoopon returning; in most cases, this closes the application. - CONTINUE
-
Used by some action to pass control to parent.
- DEFAULT
-
Continues with user interaction: this is the return value to use, if in doubt.
- IGNORE
-
Used by some actions so that callback is ignored.
ColorBar select_cb type
Constants
- IUP_PRIMARY
-
Identifies color type as the primary color.
- IUP_SECONDARY
-
Identifies color type as the secondary color.
Dialog show position
Constants
- BOTTOM
-
To place at bottom border of screen.
- CENTER
-
To place at center of screen.
- CENTERPARENT
-
To center on the parent dialog.
- CURRENT
-
To center on the current dialog’s position.
- LEFT
-
To place at left border of screen.
- MOUSEPOS
-
To center on the mouse cursor.
- RIGHT
-
To place at right border of screen.
- TOP
-
To place at top border of screen.
Dialog show_cb state
Constants
- IUP_HIDE
-
When hidden
- IUP_MAXIMIZE
-
When maximized
- IUP_MINIMIZE
-
When minimized
- IUP_RESTORE
-
When restored
- IUP_SHOW
-
When shown
Key definitions
Constants
- K_0
- K_1
- K_2
- K_3
- K_4
- K_5
- K_6
- K_7
- K_8
- K_9
- K_A
- K_B
- K_BS
- K_C
- K_CAPS
- K_CR
- K_D
- K_DEL
- K_DOWN
- K_E
- K_END
- K_ESC
- K_F
- K_F1
- K_F10
- K_F11
- K_F12
- K_F2
- K_F3
- K_F4
- K_F5
- K_F6
- K_F7
- K_F8
- K_F9
- K_G
- K_H
- K_HOME
- K_I
- K_INS
- K_J
- K_K
- K_L
- K_LALT
- K_LCTRL
- K_LEFT
- K_LF
- K_LSHIFT
- K_M
- K_MIDDLE
- K_Menu
- K_N
- K_NUM
- K_O
- K_P
- K_PAUSE
- K_PGDN
- K_PGUP
- K_Print
- K_Q
- K_R
- K_RALT
- K_RCTRL
- K_RIGHT
- K_RSHIFT
- K_S
- K_SCROLL
- K_SP
- K_T
- K_TAB
- K_U
- K_UP
- K_V
- K_W
- K_X
- K_Y
- K_Z
- K_a
- K_ampersand
- K_apostrophe
- K_at
- K_b
- K_backslash
- K_bar
- K_braceleft
- K_braceright
- K_bracketleft
- K_bracketright
- K_c
- K_circum
- K_colon
- K_comma
- K_d
- K_dollar
- K_e
- K_equal
- K_exclam
- K_f
- K_g
- K_grave
- K_greater
- K_h
- K_i
- K_j
- K_k
- K_l
- K_less
- K_m
- K_minus
- K_n
- K_numbersign
- K_o
- K_p
- K_parentleft
- K_parentright
- K_percent
- K_period
- K_plus
- K_q
- K_question
- K_quotedbl
- K_r
- K_s
- K_semicolon
- K_slash
- K_t
- K_tilde
- K_u
- K_underscore
- K_v
- K_w
- K_x
- K_y
- K_z
Masks
Constants
- MASK_EFLOAT
- MASK_FLOAT
- MASK_FLOATCOMMA
- MASK_INT
- MASK_UFLOAT
- MASK_UFLOATCOMMA
- MASK_UINT
Scrollbar operations
Constants
- IUP_SBDN
-
Operation on vertical scrollbar - used in scroll_cb callback.
- IUP_SBDRAGH
-
Operation on horizontal scrollbar - used in scroll_cb callback.
- IUP_SBDRAGV
-
Operation on vertical scrollbar - used in scroll_cb callback.
- IUP_SBLEFT
-
Operation on horizontal scrollbar - used in scroll_cb callback.
- IUP_SBPGDN
-
Operation on vertical scrollbar - used in scroll_cb callback.
- IUP_SBPGLEFT
-
Operation on horizontal scrollbar - used in scroll_cb callback.
- IUP_SBPGRIGHT
-
Operation on horizontal scrollbar - used in scroll_cb callback.
- IUP_SBPGUP
-
Operation on vertical scrollbar - used in scroll_cb callback.
- IUP_SBPOSH
-
Operation on horizontal scrollbar - used in scroll_cb callback.
- IUP_SBPOSV
-
Operation on vertical scrollbar - used in scroll_cb callback.
- IUP_SBRIGHT
-
Operation on horizontal scrollbar - used in scroll_cb callback.
- IUP_SBUP
-
Operation on vertical scrollbar - used in scroll_cb callback.