module Iup
Iup
is the main module, in which all controls and widgets are named.
The module also provides constants and supporting methods.
Constants¶ ↑
predefined colours¶ ↑
-
CD_RED
-
CD_DARK_RED
-
CD_GREEN
-
CD_DARK_GREEN
-
CD_BLUE
-
CD_DARK_BLUE
-
CD_YELLOW
-
CD_DARK_YELLOW
-
CD_MAGENTA
-
CD_DARK_MAGENTA
-
CD_CYAN
-
CD_DARK_CYAN
-
CD_WHITE
-
CD_BLACK
-
CD_DARK_GRAY
-
CD_GRAY
operations on vertical scrollbar (ScrollBarAttributes#scroll_cb
)¶ ↑
-
IUP_SBUP : line up
-
IUP_SBDN : line down
-
IUP_SBPGUP : page up
-
IUP_SBPGDN : page down
-
IUP_SBPOSV : vertical positioning
-
IUP_SBDRAGV : vertical drag
operations on horizontal scrollbar (ScrollBarAttributes#scroll_cb
)¶ ↑
-
IUP_SBLEFT : column left
-
IUP_SBRIGHT : column right
-
IUP_SBPGLEFT : page left
-
IUP_SBPGRIGHT : page right
-
IUP_SBPOSH : horizontal positioning
-
IUP_SBDRAGH : horizontal drag
line style ¶ ↑
-
CD_CONTINUOUS
-
CD_DASHED
-
CD_DOTTED
-
CD_DASH_DOT
-
CD_DASH_DOT_DOT
-
CD_CUSTOM
line join¶ ↑
-
CD_MITER
-
CD_BEVEL
-
CD_ROUND
line cap ¶ ↑
-
CD_CAPFLAT
-
CD_CAPSQUARE
-
CD_CAPROUND
mark type ¶ ↑
-
CD_PLUS
-
CD_STAR
-
CD_CIRCLE
-
CD_X
-
CD_BOX
-
CD_DIAMOND
-
CD_HOLLOW_CIRCLE
-
CD_HOLLOW_BOX
-
CD_HOLLOW_DIAMOND
background opacity mode ¶ ↑
-
CD_OPAQUE
-
CD_TRANSPARENT
fill mode¶ ↑
-
CD_EVENODD
-
CD_WINDING
hatch type¶ ↑
-
CD_HORIZONTAL
-
CD_VERTICAL
-
CD_FDIAGONAL
-
CD_BDIAGONAL
-
CD_CROSS
-
CD_DIAGCROSS
interior style¶ ↑
-
CD_SOLID
-
CD_HATCH
-
CD_STIPPLE
-
CD_PATTERN
-
CD_HOLLOW
path actions¶ ↑
-
CD_PATH_NEW
-
CD_PATH_MOVETO
-
CD_PATH_LINETO
-
CD_PATH_ARC
-
CD_PATH_CURVETO
-
CD_PATH_CLOSE
-
CD_PATH_FILL
-
CD_PATH_STROKE
-
CD_PATH_FILLSTROKE
-
CD_PATH_CLIP
polygon mode (begin…end)¶ ↑
-
CD_FILL
-
CD_OPEN_LINES
-
CD_CLOSED_LINES
-
CD_CLIP
-
CD_BEZIER
-
CD_REGION
-
CD_PATH
-
CD_POLYCUSTOM
write mode ¶ ↑
-
CD_REPLACE
-
CD_XOR
-
CD_NOT_XOR
text alignment ¶ ↑
-
CD_NORTH
-
CD_SOUTH
-
CD_EAST
-
CD_WEST
-
CD_NORTH_EAST
-
CD_NORTH_WEST
-
CD_SOUTH_EAST
-
CD_SOUTH_WEST
-
CD_CENTER
-
CD_BASE_LEFT
-
CD_BASE_CENTER
-
CD_BASE_RIGHT
text styles¶ ↑
-
CD_PLAIN : plain text
-
CD_BOLD : bold text
-
CD_ITALIC : italic text
-
CD_UNDERLINE : underline text (only windows and pdf)
-
CD_STRIKEOUT : strikeout text (only windows and pdf)
-
CD_BOLD_ITALIC : bold and italic text
Constants
- BOTTOM
- BUTTON1
Mouse
Button
Values and Macros- BUTTON2
- BUTTON3
- BUTTON4
- BUTTON5
- CD_CLIPAREA
- CD_CLIPOFF
clip mode
- CD_CLIPPOLYGON
- CD_CLIPREGION
- CD_COLORS
- CD_DEG2RAD
- CD_DIFFERENCE
- CD_ERROR
status report
- CD_FORCE
- CD_IALPHA
- CD_IBLUE
- CD_IGREEN
- CD_INDEX
- CD_INTERSECT
- CD_IRED
bitmap data
- CD_MAP
- CD_MM2PT
some useful conversion factors
- CD_NOTINTERSECT
- CD_OK
- CD_POLITE
color allocation mode (palette)
- CD_QUERY
– from CD library
- CD_RAD2DEG
- CD_RGB
bitmap type these definitions are compatibility with the IM library
- CD_RGBA
- CD_UNION
region combine mode
- CENTER
IupPopup and IupShowXY Parameter Values
- CENTERPARENT
- CLOSE
- CONTINUE
- CURRENT
- ColourBar
Colour bar
- DEFAULT
- ERROR
Common Flags and Return Values
- GETPARAM_CANCEL
- GETPARAM_HELP
- GETPARAM_INIT
- GETPARAM_OK
IupGetParam Callback situations
- IGNORE
Callback Return Values
- INVALID
- INVALID_ID
- IUP_HIDE
- IUP_MAXIMIZE
- IUP_MINIMIZE
- IUP_PRIMARY
used by
ColourBar
- IUP_RESTORE
- IUP_SECONDARY
- IUP_SHOW
SHOW_CB Callback Values
- 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
also define the escape sequences that have keys associated
- K_C
- K_CAPS
- K_CR
- K_Ccedilla
- 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
no Shift/Ctrl/Alt */
- K_M
- K_MIDDLE
- K_Menu
- K_N
- K_NUM
- K_O
- K_P
- K_PAUSE
These use the same definition as X11 and GDK.
This also means that any X11 or GDK definition can also be used.
- K_PGDN
- K_PGUP
- K_Print
- K_Q
- K_R
- K_RALT
- K_RCTRL
- K_RIGHT
- K_RSHIFT
- K_S
- K_SCROLL
- K_SP
from 32 to 126, all character sets are equal, the key code is the same as the ASCii character code.
- K_T
- K_TAB
- K_U
- K_UP
- K_V
- K_W
- K_X
- K_Y
- K_Z
- K_a
- K_acute
- K_ampersand
- K_apostrophe
- K_asterisk
- K_at
- K_b
- K_backslash
- K_bar
- K_braceleft
- K_braceright
- K_bracketleft
- K_bracketright
- K_c
- K_ccedilla
Also, these are the same as the Latin-1 definition */
- K_circum
- K_colon
- K_comma
- K_d
- K_diaeresis
- 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
- LEFT
- MASK_EFLOAT
- MASK_FLOAT
Pre-Defined Masks
- MASK_INT
- MASK_UFLOAT
- MASK_UINT
- MOUSEPOS
- NOERROR
- OPENED
- RIGHT
- TOP
Public Class Methods
Loads an image from file and returns an appropriate ruby class
# File lib/wrapped/image.rb, line 4 def Iup.LoadImage filename handle = ImLib.IupLoadImage filename image = ImageWidget.new image.instance_eval do @handle = handle end return image end
Public Instance Methods
Creates and shows an AlarmDialog, returning the number of the button clicked.
mainloop do case alarm 'IupAlarm Example', 'File not saved! Save it now?', 'Yes', 'No', 'Cancel' when 1 message 'Save file', 'File saved successfully - leaving program' when 2 message 'Save file', 'File not saved - leaving program anyway' when 3 message 'Save file', 'Operation cancelled' end exit # needed, as we don't have a persistent dialog, so don't wish to run the mainloop end
- 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
# File lib/wrapped/dialogs.rb, line 23 def alarm title, msg, button1, button2=nil, button3=nil IupLib.IupAlarm title, msg, button1, button2, button3 end
Shows a modal dialog allowing user to select a colour.
As input, provide the x,y coordinates to show dialog.
Returns r/g/b triple of selected colour, or nil if “cancel” clicked.
r, g, b = get_colour 150, 150
# File lib/wrapped/dialogs.rb, line 33 def get_colour 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, nil, nil else return r.read_int, g.read_int, b.read_int end end
Convenience function to show a modal dialog to select a filename. As input, accepts a path and filter for the file.
Returns the status code and selected filename.
Example, selecting a filename ending in “.txt” from current directory.
code, file = get_file './*.txt'
# File lib/wrapped/dialogs.rb, line 53 def 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
Accesses the global variable 'name'. Provide a value for 'val' to set the variable, or leave as nil to get the variable.
# File lib/wrapped/iup-global.rb, line 30 def global name, val=nil if val.nil? IupLib.IupGetGlobal(name).first else IupLib.IupSetGlobal name, val end end
Sets the idle_action
# File lib/wrapped/iup-global.rb, line 39 def 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
show a list dialog. returns selected item, or nil if cancel clicked.
# File lib/wrapped/dialogs.rb, line 84 def 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
All IUP GUI code must be called via a block passed to this method, as in this minimal example.
mainloop do label = Label.new("Hello World!") Dialog.new label do title ' ... from IUP' size '150x50' end.show end
# File lib/wrapped/iup-global.rb, line 16 def mainloop begin IupLib.IupOpen 0, nil ImgLib::IupImageLibOpen() yield IupLib.IupMainLoop ensure IupLib.IupClose end end
Create a MessageDialog
with given title and displayed message.
message "title of dialog", "text of message"
# File lib/wrapped/dialogs.rb, line 102 def message title, msg IupLib.IupMessage title, msg end