Module: Iup

Extended by:
Iup
Included in:
Iup
Defined in:
lib/wrapped/constants.rb,
lib/wrapped/val.rb,
lib/wrapped/dial.rb,
lib/wrapped/fill.rb,
lib/wrapped/hbox.rb,
lib/wrapped/link.rb,
lib/wrapped/list.rb,
lib/wrapped/menu.rb,
lib/wrapped/tabs.rb,
lib/wrapped/text.rb,
lib/wrapped/tree.rb,
lib/wrapped/vbox.rb,
lib/wrapped/zbox.rb,
lib/wrapped/frame.rb,
lib/wrapped/image.rb,
lib/wrapped/label.rb,
lib/wrapped/radio.rb,
lib/wrapped/timer.rb,
lib/wrapped/button.rb,
lib/wrapped/canvas.rb,
lib/wrapped/dialog.rb,
lib/wrapped/matrix.rb,
lib/wrapped/toggle.rb,
lib/wrapped/widget.rb,
lib/wrapped/dialogs.rb,
lib/wrapped/gridbox.rb,
lib/wrapped/submenu.rb,
lib/wrapped/expander.rb,
lib/wrapped/menuitem.rb,
lib/wrapped/splitbox.rb,
lib/wrapped/colourbar.rb,
lib/wrapped/scintilla.rb,
lib/wrapped/scrollbox.rb,
lib/wrapped/separator.rb,
lib/wrapped/filedialog.rb,
lib/wrapped/fontdialog.rb,
lib/wrapped/iup-global.rb,
lib/wrapped/stretchbox.rb,
lib/wrapped/progressbar.rb,
lib/wrapped/colourdialog.rb,
lib/wrapped/messagedialog.rb,
lib/wrapped/background-box.rb,
lib/wrapped/progressdialog.rb,
lib/wrapped/callback-setter.rb,
lib/wrapped/image-attributes.rb,
lib/wrapped/common-attributes.rb,
lib/wrapped/attribute-builders.rb,
lib/wrapped/attribute-reference.rb,
lib/wrapped/drag-drop-attributes.rb,
lib/wrapped/dynamic-fill-methods.rb,
lib/wrapped/scrollbar-attributes.rb,
lib/wrapped/internal-drag-drop-attributes.rb

Overview

Iup is the main module, in which all controls and widgets are named.

The module also provides constants and supporting methods.

Constants

– TODO: Check if constants are used in single or multiple places. If single (e.g. canvas / scrollbars), they can be moved to those files. ++

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

Defined Under Namespace

Modules: AttributeBuilders, AttributeReference, ButtonCallback, CallbackSetter, CommonAttributes, DragDropAttributes, DynamicFillMethods, ImageAttributes, InternalDragDropAttributes, ScrollBarAttributes Classes: BackgroundBox, Button, Canvas, ColorBar, ColourDialog, Dial, Dialog, Expander, FileDialog, Fill, FontDialog, Frame, GridBox, HBox, Image, ImageRGB, ImageRGBA, ImageWidget, Label, Link, List, Matrix, Menu, MenuItem, MessageDialog, ProgressBar, ProgressDialog, Radio, Scintilla, ScrollBox, Separator, SplitBox, StretchBox, SubMenu, Tabs, Text, Timer, Toggle, Tree, VBox, Val, Widget, ZBox

Constant Summary collapse

ColourBar =
ColorBar
ERROR =

Common Flags and Return Values

1
NOERROR =
0
OPENED =
-1
INVALID =
-1
INVALID_ID =
-10
IGNORE =

Callback Return Values

-1
DEFAULT =
-2
CLOSE =
-3
CONTINUE =
-4
CENTER =

IupPopup and IupShowXY Parameter Values

0xFFFF
LEFT =

65535

0xFFFE
RIGHT =

65534

0xFFFD
MOUSEPOS =

65533

0xFFFC
CURRENT =

65532

0xFFFB
CENTERPARENT =

65531

0xFFFA
TOP =

65530

LEFT
BOTTOM =
RIGHT
BUTTON1 =

Mouse Button Values and Macros

'1'
BUTTON2 =
'2'
BUTTON3 =
'3'
BUTTON4 =
'4'
BUTTON5 =
'5'
MASK_FLOAT =

Pre-Defined Masks

"[+/-]?(/d+/.?/d*|/./d+)"
MASK_UFLOAT =
"(/d+/.?/d*|/./d+)"
MASK_EFLOAT =
"[+/-]?(/d+/.?/d*|/./d+)([eE][+/-]?/d+)?"
MASK_INT =
"[+/-]?/d+"
MASK_UINT =
"/d+"
GETPARAM_OK =

IupGetParam Callback situations

-1
GETPARAM_INIT =
-2
GETPARAM_CANCEL =
-3
GETPARAM_HELP =
-4
K_SP =

from 32 to 126, all character sets are equal, the key code is the same as the ASCii character code.

' '.ord
K_exclam =
'!'.ord
K_quotedbl =
"\"".ord
K_numbersign =
'#'.ord
K_dollar =
'$'.ord
K_percent =
'%'.ord
K_ampersand =
'&'.ord
K_apostrophe =
"\'".ord
K_parentleft =
'('.ord
K_parentright =
')'.ord
K_asterisk =
'*'.ord
K_plus =
'+'.ord
K_comma =
','.ord
K_minus =
'-'.ord
K_period =
'.'.ord
K_slash =
'/'.ord
K_0 =
'0'.ord
K_1 =
'1'.ord
K_2 =
'2'.ord
K_3 =
'3'.ord
K_4 =
'4'.ord
K_5 =
'5'.ord
K_6 =
'6'.ord
K_7 =
'7'.ord
K_8 =
'8'.ord
K_9 =
'9'.ord
K_colon =
':'.ord
K_semicolon =
';'.ord
K_less =
'<'.ord
K_equal =
'='.ord
K_greater =
'>'.ord
K_question =
'?'.ord
K_at =
'@'.ord
K_A =
'A'.ord
K_B =
'B'.ord
K_C =
'C'.ord
K_D =
'D'.ord
K_E =
'E'.ord
K_F =
'F'.ord
K_G =
'G'.ord
K_H =
'H'.ord
K_I =
'I'.ord
K_J =
'J'.ord
K_K =
'K'.ord
K_L =
'L'.ord
K_M =
'M'.ord
K_N =
'N'.ord
K_O =
'O'.ord
K_P =
'P'.ord
K_Q =
'Q'.ord
K_R =
'R'.ord
K_S =
'S'.ord
K_T =
'T'.ord
K_U =
'U'.ord
K_V =
'V'.ord
K_W =
'W'.ord
K_X =
'X'.ord
K_Y =
'Y'.ord
K_Z =
'Z'.ord
K_bracketleft =
'['.ord
K_backslash =
"\\".ord
K_bracketright =
']'.ord
K_circum =
'^'.ord
K_underscore =
'_'.ord
K_grave =
'`'.ord
K_a =
'a'.ord
K_b =
'b'.ord
K_c =
'c'.ord
K_d =
'd'.ord
K_e =
'e'.ord
K_f =
'f'.ord
K_g =
'g'.ord
K_h =
'h'.ord
K_i =
'i'.ord
K_j =
'j'.ord
K_k =
'k'.ord
K_l =
'l'.ord
K_m =
'm'.ord
K_n =
'n'.ord
K_o =
'o'.ord
K_p =
'p'.ord
K_q =
'q'.ord
K_r =
'r'.ord
K_s =
's'.ord
K_t =
't'.ord
K_u =
'u'.ord
K_v =
'v'.ord
K_w =
'w'.ord
K_x =
'x'.ord
K_y =
'y'.ord
K_z =
'z'.ord
K_braceleft =
'{'.ord
K_bar =
'|'.ord
K_braceright =
'}'.ord
K_tilde =
'~'.ord
K_BS =

also define the escape sequences that have keys associated

"\b".ord
K_TAB =
"\t".ord
K_LF =
"\n".ord
K_CR =
"\r".ord
K_PAUSE =

These use the same definition as X11 and GDK.

This also means that any X11 or GDK definition can also be used.
0xFF13
K_ESC =
0xFF1B
K_HOME =
0xFF50
K_LEFT =
0xFF51
K_UP =
0xFF52
K_RIGHT =
0xFF53
K_DOWN =
0xFF54
K_PGUP =
0xFF55
K_PGDN =
0xFF56
K_END =
0xFF57
K_MIDDLE =
0xFF0B
K_Print =
0xFF61
K_INS =
0xFF63
K_Menu =
0xFF67
K_DEL =
0xFFFF
K_F1 =
0xFFBE
K_F2 =
0xFFBF
K_F3 =
0xFFC0
K_F4 =
0xFFC1
K_F5 =
0xFFC2
K_F6 =
0xFFC3
K_F7 =
0xFFC4
K_F8 =
0xFFC5
K_F9 =
0xFFC6
K_F10 =
0xFFC7
K_F11 =
0xFFC8
K_F12 =
0xFFC9
K_LSHIFT =

no Shift/Ctrl/Alt */

0xFFE1
K_RSHIFT =
0xFFE2
K_LCTRL =
0xFFE3
K_RCTRL =
0xFFE4
K_LALT =
0xFFE9
K_RALT =
0xFFEA
K_NUM =
0xFF7F
K_SCROLL =
0xFF14
K_CAPS =
0xFFE5
K_ccedilla =

Also, these are the same as the Latin-1 definition */

0x00E7
K_Ccedilla =
0x00C7
K_acute =

no Shift/Ctrl/Alt */

0x00B4
K_diaeresis =
0x00A8
CD_QUERY =

– from CD library

-1             # query value
CD_RGB =

bitmap type these definitions are compatibility with the IM library

0
CD_MAP =
1
CD_RGBA =
0x100
CD_IRED =

bitmap data

0
CD_IGREEN =
1
CD_IBLUE =
2
CD_IALPHA =
3
CD_INDEX =
4
CD_COLORS =
5
CD_ERROR =

status report

-1
CD_OK =
0
CD_CLIPOFF =

clip mode

0
CD_CLIPAREA =
1
CD_CLIPPOLYGON =
2
CD_CLIPREGION =
3
CD_UNION =

region combine mode

0
CD_INTERSECT =
1
CD_DIFFERENCE =
2
CD_NOTINTERSECT =
3
CD_FILL =

:nodoc: polygon mode (begin…end)

0
CD_OPEN_LINES =
1
CD_CLOSED_LINES =
2
CD_CLIP =
3
CD_BEZIER =
4
CD_REGION =
5
CD_PATH =
6
CD_POLYCUSTOM =
10
CD_PATH_NEW =

path actions

0
CD_PATH_MOVETO =
1
CD_PATH_LINETO =
2
CD_PATH_ARC =
3
CD_PATH_CURVETO =
4
CD_PATH_CLOSE =
5
CD_PATH_FILL =
6
CD_PATH_STROKE =
7
CD_PATH_FILLSTROKE =
7
CD_PATH_CLIP =
8
CD_EVENODD =

fill mode

0
CD_WINDING =
1
CD_MITER =

line join

0
CD_BEVEL =
1
CD_ROUND =
2
CD_CAPFLAT =

line cap

0
CD_CAPSQUARE =
1
CD_CAPROUND =
2
CD_OPAQUE =

background opacity mode

0
CD_TRANSPARENT =
1
CD_REPLACE =

write mode

0
CD_XOR =
1
CD_NOT_XOR =
2
CD_POLITE =

:doc: color allocation mode (palette)

0
CD_FORCE =
1
CD_CONTINUOUS =

:nodoc: line style

0
CD_DASHED =
1
CD_DOTTED =
2
CD_DASH_DOT =
3
CD_DASH_DOT_DOT =
4
CD_CUSTOM =
5
CD_PLUS =

marker type

0
CD_STAR =
1
CD_CIRCLE =
2
CD_X =
3
CD_BOX =
4
CD_DIAMOND =
5
CD_HOLLOW_CIRCLE =
6
CD_HOLLOW_BOX =
7
CD_HOLLOW_DIAMOND =
8
CD_HORIZONTAL =

hatch type

0
CD_VERTICAL =
1
CD_FDIAGONAL =
2
CD_BDIAGONAL =
3
CD_CROSS =
4
CD_DIAGCROSS =
5
CD_SOLID =

interior style

0
CD_HATCH =
1
CD_STIPPLE =
2
CD_PATTERN =
3
CD_HOLLOW =
4
CD_NORTH =

text alignment

0
CD_SOUTH =
1
CD_EAST =
2
CD_WEST =
3
CD_NORTH_EAST =
4
CD_NORTH_WEST =
5
CD_SOUTH_EAST =
6
CD_SOUTH_WEST =
7
CD_CENTER =
8
CD_BASE_LEFT =
9
CD_BASE_CENTER =
10
CD_BASE_RIGHT =
11
CD_PLAIN =

style

0
CD_BOLD =
1
CD_ITALIC =
2
CD_UNDERLINE =
4
CD_STRIKEOUT =
8
CD_BOLD_ITALIC =

compatibility name

(CD_BOLD|CD_ITALIC)
CD_SMALL =

some font sizes

8
CD_STANDARD =
12
CD_LARGE =
18
CD_CAP_NONE =

context capabilities

0x00000000
CD_CAP_FLUSH =
0x00000001
CD_CAP_CLEAR =
0x00000002
CD_CAP_PLAY =
0x00000004
CD_CAP_YAXIS =
0x00000008
CD_CAP_CLIPAREA =
0x00000010
CD_CAP_CLIPPOLY =
0x00000020
CD_CAP_REGION =
0x00000040
CD_CAP_RECT =
0x00000080
CD_CAP_CHORD =
0x00000100
CD_CAP_IMAGERGB =
0x00000200
CD_CAP_IMAGERGBA =
0x00000400
CD_CAP_IMAGEMAP =
0x00000800
CD_CAP_GETIMAGERGB =
0x00001000
CD_CAP_IMAGESRV =
0x00002000
CD_CAP_BACKGROUND =
0x00004000
CD_CAP_BACKOPACITY =
0x00008000
CD_CAP_WRITEMODE =
0x00010000
CD_CAP_LINESTYLE =
0x00020000
CD_CAP_LINEWITH =
0x00040000
CD_CAP_FPRIMTIVES =
0x00080000
CD_CAP_HATCH =
0x00100000
CD_CAP_STIPPLE =
0x00200000
CD_CAP_PATTERN =
0x00400000
CD_CAP_FONT =
0x00800000
CD_CAP_FONTDIM =
0x01000000
CD_CAP_TEXTSIZE =
0x02000000
CD_CAP_TEXTORIENTATION =
0x04000000
CD_CAP_PALETTE =
0x08000000
CD_CAP_LINECAP =
0x10000000
CD_CAP_LINEJOIN =
0x20000000
CD_CAP_PATH =
0x40000000
CD_CAP_BEZIER =
0x80000000
CD_CAP_ALL =
0xFFFFFFFF
CD_SIM_NONE =

simulation flags

0x0000
CD_SIM_LINE =
0x0001
CD_SIM_RECT =
0x0002
CD_SIM_BOX =
0x0004
CD_SIM_ARC =
0x0008
CD_SIM_SECTOR =
0x0010
CD_SIM_CHORD =
0x0020
CD_SIM_POLYLINE =
0x0040
CD_SIM_POLYGON =
0x0080
CD_SIM_TEXT =
0x0100
CD_SIM_ALL =
0xFFFF
CD_SIM_LINES =
(CD_SIM_LINE | CD_SIM_RECT | CD_SIM_ARC | CD_SIM_POLYLINE)
CD_SIM_FILLS =
(CD_SIM_BOX | CD_SIM_SECTOR | CD_SIM_CHORD | CD_SIM_POLYGON)
CD_RED =

:nodoc: some predefined colors for convenience

0xFF0000
CD_DARK_RED =

255, 0, 0

0x800000
CD_GREEN =

128, 0, 0

0x00FF00
CD_DARK_GREEN =

0,255, 0

0x008000
CD_BLUE =

0,128, 0

0x0000FF
CD_DARK_BLUE =

0, 0,255

0x000080
CD_YELLOW =

0, 0,128

0xFFFF00
CD_DARK_YELLOW =

255,255, 0

0x808000
CD_MAGENTA =

128,128, 0

0xFF00FF
CD_DARK_MAGENTA =

255, 0,255

0x800080
CD_CYAN =

128, 0,128

0x00FFFF
CD_DARK_CYAN =

0,255,255

0x008080
CD_WHITE =

0,128,128

0xFFFFFF
CD_BLACK =

255,255,255

0x000000
CD_DARK_GRAY =

0, 0, 0

0x808080
CD_GRAY =

128,128,128

0xC0C0C0
CD_MM2PT =

:doc: some useful conversion factors

2.834645669
CD_RAD2DEG =

milimeters to points (pt = CD_MM2PT * mm)

57.295779513
CD_DEG2RAD =

radians to degrees (deg = CD_RAD2DEG * rad)

0.01745329252
IUP_SHOW =

SHOW_CB Callback Values

0
IUP_RESTORE =
1
IUP_MINIMIZE =
2
IUP_MAXIMIZE =
3
IUP_HIDE =
4
IUP_SBUP =

SCROLL_CB Callback Values – actions on vertical scrollbar

0
IUP_SBDN =
1
IUP_SBPGUP =
2
IUP_SBPGDN =
3
IUP_SBPOSV =
4
IUP_SBDRAGV =
5
IUP_SBLEFT =

– actions on horizontal scrollbar

6
IUP_SBRIGHT =
7
IUP_SBPGLEFT =
8
IUP_SBPGRIGHT =
9
IUP_SBPOSH =
10
IUP_SBDRAGH =
11
IUP_PRIMARY =

used by ColourBar

-1
IUP_SECONDARY =
-2

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.LoadImage(filename) ⇒ Object

Loads an image from file and returns an appropriate ruby class



4
5
6
7
8
9
10
11
# 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

Instance Method Details

#alarm(title, msg, button1, button2 = nil, button3 = nil) ⇒ Object

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



23
24
25
# File 'lib/wrapped/dialogs.rb', line 23

def alarm title, msg, button1, button2=nil, button3=nil
  IupLib.IupAlarm title, msg, button1, button2, button3
end

#get_colour(x = 0, y = 0) ⇒ Object

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


33
34
35
36
37
38
39
40
41
42
43
# 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

#get_file(filter = '') ⇒ Object

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'


53
54
55
56
57
58
59
60
61
62
63
# 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

#global(name, val = nil) ⇒ Object

Accesses the global variable ‘name’. Provide a value for ‘val’ to set the variable, or leave as nil to get the variable.



30
31
32
33
34
35
36
# 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

#idle(callback) ⇒ Object

Sets the idle_action



39
40
41
42
43
44
# 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

#listdialog(title, items) ⇒ Object

show a list dialog. returns selected item, or nil if cancel clicked. – TODO: Include multiple selection, change to cols/lines



84
85
86
87
88
89
90
91
92
93
94
95
96
# 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

#mainloopObject

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


16
17
18
19
20
21
22
23
24
25
# 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

#message(title, msg) ⇒ Object

Create a MessageDialog with given title and displayed message.

message "title of dialog", "text of message"


102
103
104
# File 'lib/wrapped/dialogs.rb', line 102

def message title, msg
  IupLib.IupMessage title, msg
end