Preface
This is the reference manual of YAAA.app (Y3A pronounced Y triple A), a GUI scripting interface that leverages Lua, Python, C# and Microsoft Excel via the Fast Light Toolkit (FLTK).
This reference manual provides comprehensive documentation on utilizing the available API to:
- Setup your app’s structure.
- Exchange data between supported languages.
- Interface with FLTK widgets.
- Access system APIs.
- Handle events and callbacks.
- Integrate with external applications.
It is assumed that the reader is familiar with basic computer programming concepts.
For convenience of reference, this document contains external (deep) links to the Lua Reference Manual and the FLTK Programming Manual.
Installation
Latest version of the app can be download from the Download page.
It ships in a fully portable package and does not require elevated user privileges for installation or operation. This makes it easy to use on any compatible Windows system without administrative rights.
To install, run the downloaded installation file, select the desired location in which you want the application files to be stored and click on Install. Please note that installing the app in system directories such as C:\Program Files would require admin rights.
Once the installation is complete, you can create a desktop shortcut or pin the exe file in application directory to the taskbar for quick access.
Writing Your First App
Y3A’s programming interface provides simple controls to create application structure.
To create a new app simply click on the Add app button on the toolbar (Button 1). You will be presented with a dialogue to set the following app’s parameters.
- Name: Unique app’s name which appear on the user’s Desktop as well as on app tree browser within the programming interface. We will set this as TestApp.
- Callback: A global Lua variable which is of type app dialogue. This is the app’s entry dialogue which is shown when the app’s icon on the desktop is clicked.
- Tooltip: Contents of the dialogue shown when users hover mouse over the Desktop icon.
- Icon: SVG code of the Desktop icon. SVG Repo contains a large range of icons which can be easily copied and used as app’s icon. Simply go to the icon’s page, click on Edit Vector and then COPY SVG.
NOTE | Y3A’s SVG images/icons do not support text. |
<svg ...>
</svg>
XMLOnce all above fields are set, click on Save on the toolbar (Button 6) to save the changes. Upon completion a new app icon will appear on the Desktop with given parameters.
Next we need to define the body of the app. Y3A uses Lua as its primary programming interface due to it’s simplicity and robustness. The graphical user interface (GUI) of all apps can only be defined in Lua. In addition to Lua, other available scripting languages can be used to implement the logic of the apps.
To create a new Lua, Python or C# script, simply click on the Add Lua script, Add Python script and Add C# script on the toolbar respectively (Buttons 2-4). In the name field, write in your preferred name for the script. To save the script as a child of TestApp, name of the script needs to start with TestApp/ i.e. TestApp/TestScript.
Y3A provides a simple way to integrate Python, C# and MS Excel logics in Lua scripts. Python and C# global functions and class static functions can simply be called with PY.call and CS.call functions.
-- output is the return value from the Python function
-- func is the Python function name
-- arg1, arg2, ... are the arguments passed to the Python function
output = PY.call('func', arg1, arg2, ...)
output = PY.call('className.func', arg1, arg2, ...)
Lua-- output is the return value from the C# function
-- func is the C# function name
-- arg1, arg2, ... are the arguments passed to the C# function
output = CS.call('func', arg1, arg2, ...)
output = CS.call('className.func', arg1, arg2, ...)
LuaUse PY.create and CS.create functions to create instances of Python and C# classes.
pyClassInstance = PY.create('className', arg1, arg2, ...)
pyClassInstance:MyMethod(arg1, arg2, ...) -- Call class method MyMethod
LuaExcel spreadsheet can also be used to implement the calculation logic of the apps. This method is particularly useful since most engineers are comfortable with writing Excel calculations, making it easy to distribute the development workload among team members. Refer to Sample Beam Calculator blog post to check how you can incorporate Excel calculations in your apps.
TestApp will include 3 Lua scripts to implement utility functions, callback functions and GUI layout. To create the Lua scripts click on the Add Lua script icon on the toolbar (Button 2). We will call the first Lua script Utilities and save it under TestApp by specifying the name as TestApp/Utilities.
function file_chooser_cb(udata)
input, ext = table.unpack(udata)
chooser = gui.native_file_chooser()
chooser:filter(ext)
chooser:show()
path = chooser:filenames(1)
if path == nil then do return end end
input:value(path)
input:activate()
end
function FileExists(path)
local f = io.open(path, 'r')
if f then
f:close()
end
return f ~= nil
end
Lua-- EPDD CB
TestApp = {
cb = {},
data = {}
}
local outputWB = Workbook('EPDD/xls')
outputWB:open()
local lookupWS = outputWB:worksheet('Lookup')
local reportWS = outputWB:worksheet('Report')
local inputTabs = {}
local pierDefinitionCount = nil
local rawPierDefinitions = {}
----------------------------------------------
EPDD.InitParameters = function()
for k, v in pairs(EPDD.layout.parameterTab.widgets) do
v:do_callback()
end
end
----------------------------------------------
local function cb_ImportData(input)
local type = input:label()
local path = input:value()
if (not (FileExists(path))) then
msg.error('Select the ' .. type .. ' input file')
do
return
end
end
local inputWB = Workbook(path)
inputWB:open()
local worksheets = Decode(inputWB:worksheets())
local inputWS = inputWB:worksheet(worksheets[1])
local outputWS = outputWB:worksheet(type)
outputWS:copy(inputWS)
inputWB:close()
input:deactivate()
end
EPDD.cb.ImportData = cb_ImportData
local function cb_Reset()
outputWB:close()
EPDD.layout.reset:deactivate()
end
EPDD.cb.Reset = cb_Reset
----------------------------------------------
local function cb_Input(udata)
local w, name = table.unpack(udata)
if (w:value() == '') then
local v = outputWB[name]:value()
w:value(Decode(v)[1])
else
outputWB[name]:cell(0, 0):value(w:value())
end
end
EPDD.cb.Input = cb_Input
----------------------------------------------
local function cb_NumberInput(udata)
local w, name = table.unpack(udata)
if (w:value() == '') then
local v = outputWB[name]:value()
w:value(Decode(v)[1])
else
outputWB[name]:cell(0, 0):value(tonumber(w:value()))
end
end
EPDD.cb.NumberInput = cb_NumberInput
----------------------------------------------
local function cb_Output(udata)
local w, name = table.unpack(udata)
local v = outputWB[name]:value()
w:value(Decode(v)[1])
end
EPDD.cb.Output = cb_Output
----------------------------------------------
function cb_Close(window)
if IsOpen(source:value()) then
PY.call('Close', source:value())
end
if IsOpen(target:value()) then
PY.call('Close', target:value())
end
source:activate()
target:activate()
source:value('')
target:value('')
materialList:clear()
sourceCase:clear()
targetCase:clear()
swTargetCase:clear()
if window~=nil then
window:hide()
end
end
Lua-- EPDD Layout
TestApp.layout = {
tab1 = {
widgets = {}},
tab2 = {
widgets = {}},
tab3 = {
widgets = {}}
}
TestApp_win = gui.app(100, 100, 700, 295, 'My first app')
TestApp_win:callback(cb_Close, TestApp_win)
local t = gui.tabs(0, 0, 700, 255)
----------------------------------------------
local g = gui.group(0, 30, 700, 255, 'Tab 1')
TestApp.layout.tab1.group = g
local function AddImportWidgets(y, label)
local i = gui.input(70, y, 500, 30, label)
local o = gui.button(580, y, 50, 30, 'Select')
o:callback(file_chooser_cb, {i, 'Excel Files\t*.xlsx'})
o = gui.button(640, y, 50, 30, 'Import')
o:callback(TestApp.cb.ImportData, i)
table.insert(TestApp.layout.tab1.widgets, i)
table.insert(TestApp.layout.tab1.widgets, o)
end
AddImportWidgets(40, 'Reaction')
AddImportWidgets(75, 'Force')
g:done()
----------------------------------------------
g = gui.group(0, 30, 700, 255, 'Tab 2')
TestApp.layout.tab2.group = g
local function AddParameter(x, y, w, h, label, cb_name, tooltip, isNumber)
tooltip = tooltip or ''
isNumber = isNumber or false
local o = nil
if isNumber then
o = gui.float_input(x, y, w, h, label)
o:callback(EPDD.cb.NumberInput, {o, cb_name})
else
o = gui.input(x, y, w, h, label)
o:callback(EPDD.cb.Input, {o, cb_name})
end
o:tooltip(tooltip)
table.insert(EPDD.layout.parameterTab.widgets, o)
return o
end
AddParameter(70, 40, 60, 30, 'µ/Sp', 'Setting.muOnSp', '', true)
AddParameter(70, 75, 60, 30, 'Top µ', 'Setting.frictionMu.Top',
[[Coefficient of friction to reduce shear force in dowels (max. 0.6)
Note that the plastic membrane is placed over the wall prior slab pour]], true)
g:done()
----------------------------------------------
g = gui.group(0, 30, 700, 255, 'Tab 3')
TestApp.layout.tab3.group = g
local o = gui.text_editor(10, 55, 240, 190, 'Tab 3')
local buffer = gui.text_buffer()
o:buffer(buffer)
o:tooltip('INPUT FORMAT\nTag Thickness Grade VerticalReo HorizontalReo')
o:callback(EPDD.cb.AddPierDefinitions, o)
o:when('never')
buffer:text([[
P180A 180 40 N12-300 N12-300
P180B 180 40 N12-200 N12-150
P200A 200 40 N12-350 N12-350
P200B 200 40 N12-250 N12-350
P200C 200 50 N12-150 N12-150
P200D 200 40 N16-225 N12-150
P250A 250 50 N12-250 N12-350]])
table.insert(EPDD.layout.definitionTab.widgets, o)
o = gui.box(260, 55, 60, 120, 'Dowel\nsize/s')
o = gui.browser(310, 55, 60, 120, 'Bottom')
o:type('multi')
o:align(ALIGN_TOP)
o:tooltip('Select the bottom dowels to be used in the design')
o:callback(EPDD.cb.DowelSize, o)
o:when('never')
table.insert(EPDD.layout.definitionTab.widgets, o)
o:add('20')
o:add('24')
o:add('28')
o:add('32')
o:add('36')
o:add('40')
o:select(3)
o:select(4)
AddParameter(310, 180, 60, 30, 'Min.\nEdge', 'Dowel.minEdgeDistance.Bottom',
'Min bottom dowel edge distance to panel ends', true)
AddParameter(310, 215, 60, 30, 'Min.\nSpacing', 'Dowel.minSpacing.Bottom', 'Min bottom dowel spacing', true)
o = gui.browser(380, 55, 60, 120, 'Top')
o:type('multi')
o:align(ALIGN_TOP)
o:tooltip('Select the top dowels to be used in the design')
o:callback(EPDD.cb.DowelSize, o)
o:when('never')
table.insert(EPDD.layout.definitionTab.widgets, o)
o:add('12')
o:add('16')
o:add('20')
o:add('24')
o:add('28')
o:add('32')
o:select(2)
o:select(3)
AddParameter(380, 180, 60, 30, '', 'Dowel.minEdgeDistance.Top', 'Min top dowel edge distance to panel ends', true)
AddParameter(380, 215, 60, 30, '', 'Dowel.minSpacing.Top', 'Min top dowel spacing', true)
g:done()
----------------------------------------------
g = gui.group(0, 30, 700, 255, 'Lookup')
EPDD.layout.lookupTab.group = g
local story = gui.choice(70, 40, 60, 30, 'Story:')
story:callback(EPDD.cb.StoryLookup)
EPDD.layout.lookupTab.story = story
local pier = gui.choice(70, 75, 60, 30, 'Pier:')
pier:callback(EPDD.cb.PierLookup)
EPDD.layout.lookupTab.pier = pier
local function AddOutput(x, y, w, h, label, cb_name)
o = gui.output(x, y, w, h, label)
o:callback(EPDD.cb.Output, {o, cb_name})
o:when('never')
o:clear_visible_focus()
table.insert(EPDD.layout.lookupTab.widgets, o)
end
AddOutput(180, 40, 60, 30, 'G:', 'G')
AddOutput(180, 75, 60, 30, 'Q:', 'Q')
local location = gui.choice(480, 40, 60, 30, 'Location:')
location:callback(EPDD.cb.LocationLookup)
location:add('Bottom')
location:add('Top')
EPDD.layout.lookupTab.location = location
g:done()
g:deactivate()
----------------------------------------------
t:done()
o = gui.button(380, 260, 70, 30, 'Compute')
o:callback(EPDD.cb.Calculate)
EPDD.layout.calculate = o
o = gui.button(460, 260, 70, 30, 'Export')
o:callback(EPDD.cb.Export)
o:deactivate()
EPDD.layout.export = o
o = gui.button(540, 260, 70, 30, 'Save')
o:callback(EPDD.cb.Save)
o:deactivate()
EPDD.layout.save = o
o = gui.button(620, 260, 70, 30, 'Reset')
o:callback(EPDD.cb.Reset)
o:deactivate()
EPDD.layout.reset = o
EPDD_window:done()
EPDD.InitParameters()
LuaIt is highly recommended to define variables as local in your scripts to maintain the global states as clean as possible and avoid conflicting variable names in global scope from different apps (Similar to how they are defined above).
We will include a Python and C# script to implement part of our app’s logic in these languages. In a real scenario, these languages are used to make external API calls to external applications such as Etabs and RAM Concept.
import pandas as pd
def PyFunc():
data = {'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 30, 22], 'City': ['New York', 'San Francisco', 'Los Angeles']}
return pd.DataFrame(data)
Pythonpublic class ScriptTest
{
public string Message { get; set; } = "Hello wonderful World!!!";
public string Name { get; set; }
public int Id { get; set; }
}
C#NOTE | Being an scripting interface, Y3A processes the scripts in the order shown in the project browser. To ensure that function calls do not fail, ensure that the scripts are compiled prior to accessing their variables/functions. i.e. place callbacks above the layout in the tree browser as callback functions must be defined prior to assigning them to the gui elements. |
Examples
Examples can be found in the programming interface of the app.
API Introduction
Y3A exposes FLTK functions and static methods as Lua functions contained in the gui table. For example, gui.draw( ) exposes fl_draw( ), gui.run( ) exposes Fl::run( ), and so on.
FLTK classes are exposed as Lua objects, that is, table with methods. For each (concrete) class there is a constructor function in the gui table that instantiates an object of that class, bounds it to a Lua table and returns the latter.
win = gui.double_window(0, 0, 600, 400) -- creates a Fl_Double_Window
win:label('My Window') -- a method
LuaY3A’s GUI objects preserve the FLTK class hierarchy: the win object in the above example is not only a double_window, but also a window, a group, and a widget. This means that it inherits their methods and it can be used wherever a window, a group, or a widget is expected.
Exposed functions, classes, and their methods are listed in the following sections. For most of them, their functionalities and usages are not described in this manual (please refer to the FLTK Programming Manual instead).
Classes
Widgets
widget
Rfr: Fl_Widget
No Constructor (abstract class)
- :activate( )
- boolean = :active( )
- boolean = :active_r( )
- :align(alignment)
alignment = :align( ) - :argument(arg)
arg = :argument( )
arg : any Lua value. - :box(boxtype)
boxtype = :box( ) - :callback(func [, arg])
func = :callback( )
The func callback (a Lua function) is executed as func(arg).
The optional argument arg may be any Lua value. - boolean = :changed( )
- :clear_active( )
:clear_changed( )
:clear_damage(damagebits)
:clear_output( )
:clear_visible( )
:clear_visible_focus( ) - :color(bgcolor [, selcolor])
bgcolor = :color( ) - boolean = :contains(widget)
- :damage(damagebits) :damage(x, y, w, h, damagebits)
damagebits = :damage( ) - :deactivate( )
- :deimage(image)
image = :deimage( ) - :do_callback([arg])
The optional argument arg may be any Lua value.
If arg is not passed, the current user_data is used.
If arg = nil, the callback receives nil as argument. - :draw( )
- :draw_label( )
:draw_label(x, y, w, h [, alignment]) - boolean = :handle(event)
- :hide( )
- :image(image)
image = :image( ) - boolean = :inside(widget)
- :label(label)
label = :label( ) - :labelcolor(color)
color = :labelcolor( ) - :labelfont(font)
font = :labelfont( ) - :labelsize(fontsize)
fontsize = :labelsize( ) - :labeltype(labeltype)
labeltype = :labeltype( ) - width, height = :measure_label( )
- boolean = :output( )
- group = :parent( )
- :position(x, y)
- :redraw( )
:redraw_label( ) - :resize(x, y, w, h)
- :selection_color(color)
color = :selection_color( ) - :set_active( )
- set_changed( )
- :set_output( )
- :set_visible( )
- :set_visible_focus( )
- :show( )
- :size(w, h)
- boolean = :take_focus( )
- boolean = :takesevents( )
- :tooltip(text)
text = :tooltip( ) - window = :top_window( )
- xoffset, yoffset = :top_window_offset( )
- :type(rtti)
rtti = :type( ) - :userdata: alias for :argument
- boolean = :visible( )
- :visible_focus(boolean)
boolean = :visible_focus( ) - boolean = :visible_r( )
- :when(whenflags)
whenflags = :when() - window = :window( )
- x, y, w, h = :xywh( )
x = :x()
y = :y( )
w = :w( )
h = :h( )
Protected methods, exposed for subclassing:
box
Rfr: Fl_Box
Inherits from: widget
- box = gui.box(x, y, w, h [, label])
box = gui.box(boxtype, x, y, w, h [, label])
light_button
Rfr: Fl_Light_Button
Inherits from: button
- light_button = gui.light_button(x, y, w, h [, label])
check_button
Rfr: Fl_Check_Button
Inherits from: light_button
- check_button = gui.check_button(x, y, w, h [, label])
radio_light_button
Rfr: Fl_Radio_Light_Button
Inherits from: light_button
- radio_light_button = gui.radio_light_button(x, y, w, h [, label])
round_button
Rfr: Fl_Round_Button
Inherits from: light_button
- round_button = gui.round_button(x, y, w, h [, label])
radio_round_button
Rfr: Fl_Radio_Round_Button
Inherits from: round_button
- radio_round_button = gui.radio_round_button(x, y, w, h [, label])
radio_button
Rfr: Fl_Radio_Button
Inherits from: button
- radio_button = gui.radio_button(x, y, w, h [, label])
repeat_button
Rfr: Fl_Repeat_Button
Inherits from: button
- repeat_button = gui.repeat_button(x, y, w, h [, label])
- :deactivate( )
return_button
Rfr: Fl_Return_Button
Inherits from: button
- return_button = gui.return_button(x, y, w, h [, label])
toggle_button
Rfr: Fl_Toggle_Button
Inherits from: button
- toggle_button = gui.toggle_button(x, y, w, h [, label])
chart
Rfr: Fl_Chart
Inherits from: widget
RTTI: bar, horbar, line, fill, spike, pie, specialpie
- chart = gui.chart(x, y, w, h [, label])
- :add(value [, label] [, color])
- :autosize(boolean)
boolean = :autosize( ) - :bounds(lower, upper)
lower, upper = :bounds( ) - :clear( )
- :insert(pos, value [, label] [, color])
- :maxsize(n)
n = :maxsize( ) - :replace(pos, value [, label] [, color])
- :size(w, h)
n = :size( ) - :textcolor(color)
color = :textcolor( ) - :textfont(font)
font = :textfont( ) - :textsize(fontsize)
fontsize = :textsize( )
clock_output
Rfr: Fl_Clock_Output
Inherits from: widget
- clock_output = gui.clock_output(x, y, w, h [, label])
- hour = :hour( )
- minute = :minute( )
- second = :second( )
- :value(H, m, s)
sec_since_UNIX_epoch (1 Jan 1970) = :value( )
round_clock
Rfr: Fl_Round_Clock
Inherits from: clock
- round_clock = gui.round_clock(x, y, w, h [, label])
group
Rfr: Fl_Group
Inherits from: widget
- group = gui.group(x, y, w, h [, label])
- :add(widget)
- :add_resizable(widget)
- :begin( )
- widget = :child(n)
- nchildren = :children( )
NOTE: Children are indexed from 1 to :children() inclusive. - :clear( )
- :clip_children(boolean)
boolean = :clip_children( ) - :done( )
:end is replaced by :done (end is a reserved keyword in Lua). - n = :find(widget)
Returns :children()+1 if widget is nil or not found. - :init_sizes( )
- :insert(widget, n)
:insert(widget, beforewidget) - :remove(widget)
- :resizable(widget)
widget = :resizable( )
If widget is nil, then all widget remain a fixed size and distance from the top-left corner.
NOTE: :resizable() differs from :resizable(nil): the former is a getter, while the latter is a setter function.
The following are (un)protected methods to be used only when subclassing.
browser_
Rfr: Fl_Browser_
Inherits from: group
RTTI: normal, select, hold, multi
No constructor (abstract class).
- boolean = :deselect( )
- :has_scrollbars(scrollbarsmode)
scrollbarsmode = :has_scrollbars( ) - :hposition(pos)
pos = :hposition( ) - :position(pos)
pos = :position( ) - :scrollbar_left( )
:scrollbar_right( ) - :scrollbar_size(size)
size = :scrollbar_size( ) - :sort(order)
order : “ascending” or “descending” - :textcolor(color)
color = :textcolor( ) - :textfont(font)
font = :textfont( ) - :textsize(fontsize)
fontsize = :textsize( )
browser
Rfr: Fl_Browser
Inherits from: browser_
- browser = gui.browser(x, y, w, h [, label])
- :add([text] [, data])
- :bottomline(line)
- :clear( )
- :column_char(c)
c = :column_char( )
c : ASCII character. - :column_widths(w1, w2, …, wN)
w1, w2, …, wN = :column_widths( ) - :data(line, data)
data = :data(line)
data : an integer value to associate with the item (defaults to 0).
This value may be used as index in a Lua table containing more complex data associated with the item. - boolean = :displayed(line)
- :format_char(c)
c = :format_char( )
c : ASCII character. - :hide(line)
:hide( ) - :icon(line, image)
image = :icon(line) - :insert(line [, text] [, data])
- :lineposition(line, linepos)
- ok, err = :load(filename)
Returns true or false and an error string. - :make_visible(line)
- :middleline(line)
- :move(to, from)
- :remove(line)
- :remove_icon(line)
- boolean = :select(line [, boolean])
- boolean = :selected(line)
- :show(line)
:show( ) - :size(w, h)
nlines = :size( ) - :swap(line1, line2)
- :text(line [, text])
text = :text(line) - :topline(line)
line = :topline( ) - :value(line)
line = :value( ) - boolean = :visible(line)
file_browser
Rfr: Fl_File_Browser
Inherits from: browser
hold_browser
Rfr: Fl_Hold_Browser
Inherits from: browser
- hold_browser = gui.hold_browser(x, y, w, h [, label])
multi_browser
Rfr: Fl_Multi_Browser
Inherits from: browser
- multi_browser = gui.multi_browser(x, y, w, h [, label])
select_browser
Rfr: Fl_Select_Browser
Inherits from: browser
- select_browser = gui.select_browser(x, y, w, h [, label])
check_browser
Rfr: Fl_Check_Browser
Inherits from: browser_
- check_browser = gui.check_browser(x, y, w, h [, label])
- index = :add([text] [, boolean])
NOTE: index is an integer in the range 1 to :nitems() inclusive. - :check_all( )
- :check_none( )
- :checked(index, boolean)
boolean = :checked(index) - :clear( )
- n = :nchecked( )
- n = :nitems( )
- n = :remove(index)
- :set_checked(index)
- text = :text(index)
- index = :value( )
color_chooser
Rfr: Fl_Color_Chooser
Inherits from: group
- color_chooser = gui.color_chooser(x, y, w, h [, label])
- boolean = :hsv(rh, sg, vb)
boolean = :rgb(r, g, b) - hue = :hue( )
- :mode(colorchoosermode)
colorchoosermode = :mode( ) - r = :r( )
g = :g( )
b = :b( ) - saturation = :saturation( )
- brightness = :value( )
help_view
Rfr: Fl_Help_View
Inherits from: group
- help_view = gui.help_view(x, y, w, h [, label])
- :clear_selection( )
- dirname = :directory( )
- filename = :filename( )
- line = :find(string [, pos])
Returns nil if string is not found. - :leftline(p)
p = :leftline( ) - :link(func)
The func callback (a function) is executed as func(uri) where uri is an URI or a pathname. It must return a pahname that can be opened as a local file, or nil (see Fl_Help_View::link() in the FLTK manual for more details). - :load(filename)
- :resize(x, y, w, h)
- :scrollbar_size(pixels)
pixels = :scrollbar_size( )
NOTE: Do not use this function, use gui.scrollbar_size( ) instead. - :select_all( )
- :size(w, h)
size = :size( ) - :textcolor(color)
color = :textcolor( ) - :textfont(font)
font = :textfont( ) - :textsize(fontsize)
fontsize = :textsize( ) - title = :title( )
- :topline(line)
:topline(name)
line = :topline( ) - :value(text)
text = :value( )
input_choice
Rfr: Fl_Input_Choice
Inherits from: group
- input_choice = gui.input_choice(x, y, w, h [, label])
- :add(item)
item : a string. - boolean = :changed( )
- :clear( )
- :clear_changed( )
- :down_box(boxtype)
boxtype = :down_box( ) - input = :input( )
- menu_button = :menubutton( )
- :set_changed( )
- :textcolor(color)
color = :textcolor( ) - :textfont(font)
font = :textfont( ) - :textsize(fontsize)
fontsize = :textsize( ) - :value(index)
:value(item)
item = :value( )
pack
Rfr: Fl_Pack
Inherits from: group
RTTI: horizontal, vertical
- pack = gui.pack(x, y, w, h [, label])
- :spacing(pixels)
pixels = :spacing( )
scroll
Rfr: Fl_Scroll
Inherits from: group
RTTI: no scrollbar, horizontal, vertical, both, always on, horizontal always, vertical always, both always
- scroll = gui.scroll(x, y, w, h [, label])
- :clear( )
- scrollbar = :hscrollbar( )
Returns a reference to the horizontal scrollbar widget. - scrollbar = :scrollbar( )
Returns a reference to the vertical scrollbar widget. - :scrollbar_size(pixels)
pixels = :scrollbar_size( ) - :scroll_to(x, y)
- x :xposition( )
y :yposition( )
spinner
Rfr: Fl_Spinner
Inherits from: group
RTTI: float, int
- spinner = gui.spinner(x, y, w, h [, label])
- :color(color)
color = :color( ) - :format(fmt)
fmt = :format( ) - :maximum(number)
number = :maximum( ) - :minimum(number)
number = :minimum( ) - :range(min, max)
- :selection_color(color)
color = :selection_color( ) - :step(number)
number = :step( ) - :textcolor(color)
color = :textcolor( ) - :textfont(font)
font = :textfont( ) - :textsize(fontsize)
fontsize = :textsize( ) - :value(number)
number = :value( )
table
Rfr: Fl_Table
Inherits from: group
- table = gui.table(x, y, w, h [, label])
NOTE: Row and column numbers, as well as children indices, are 1-based (Lua-style). - tablecontext = :callback_context( )
- col = :callback_col( )
- row = :callback_row( )
- :col_header(boolean)
boolean = :col_header( ) - :col_header_color(color)
color = :col_header_color( ) - :col_header_height(h)
h = :col_header_height( ) - :col_position(col)
col = :col_position( ) - :col_resize(boolean)
boolean = :col_resize( ) - :col_resize_min(val)
val = :col_resize_min( ) - :col_width(col, w)
w = :col_width(col) - :col_width_all(w)
- ncols = :cols( )
- :draw_cell(tablecontext, r, c, x, y, w, h)
- x, y, w, h = :find_cell(tablecontext, row, col)
- row_top, col_left, row_bottom, col_right = :get_selection( )
- boolean = :is_interactive_resize( )
- boolean = :is_selected(row, col)
- boolean = :move_cursor(deltarow, deltacol [, shiftselect])
- row = :current_row( )
col = :current_col( )
Return nil if none is selected. - :row_header(boolean)
boolean = :row_header( ) - :row_header_color(color)
color = :row_header_color( ) - :row_header_width(w)
w = :row_header_width( ) - :row_height(row, h)
h = :row_height(row) - :row_height_all(h)
- :row_position(row)
row = :row_position( ) - :row_resize(boolean)
boolean = :row_resize( ) - :row_resize_min(val)
val = :row_resize_min( ) - nrows = :rows( )
- :scrollbar_size(val)
val = :scrollbar_size( ) - :set_selection(row_top, col_left, row_bottom, col_right)
- :table_box(boxtype)
boxtype = :table_box( ) - :tab_cell_nav(boolean)
boolean = :tab_cell_nav( ) - row1, row2, col1, col2 = :visible_cells( )
table_row
Rfr: Fl_Table_Row
Inherits from: table
RTTI: none, single, multi
- table_row = gui.table_row(x, y, w, h [, label])
NOTE: Row and column numbers, as well as children indices, are 1-based (Lua-style).
- boolean = :row_selected(row)
Returns nil, errmsg if row is out of range. - :rows(nrows)
nrows = :rows( ) - :select_all_rows([option])
option : deselect, select (default), toggle - boolean = :select_row(row [, option])
option : deselect, select (default), toggle
Returns nil, errmsg if row is out of range.
tabs
text_display
Rfr: Fl_Text_Display
Inherits from: group
IMPORTANT: See text_buffer indexing.
- text_display = gui.text_display(x, y, w, h [, label])
- :buffer(text_buffer)
text_buffer = :buffer( ) - nlines = :count_lines(start [, end] [, islinestart])
- :cursor_color(color)
color = :cursor_color( ) - :cursor_style(cursorstyle)
- :hide_cursor( )
- :highlight_data(stylebuffer, styletable [, unfinishedstyle, func])
stylebuffer : a text_buffer.
styletable : an array (integer-indexed table) of style-describing arrays, each of which in the form: { color, font, fontsize, fontattr }
fontattr is optional and defaults to 0.
Characters in the stylebuffer indicate styles in the styletable : ‘A’, denotes the first style, ‘B’ the second, and so on (up to ‘~’).
unfinishedstyle : (optional) character denoting the unfinished style that triggers the callback below.
func : (optional) callback triggered by unfinishedstyle. The callback is executed as func(pos). - boolean = :in_selection(x, y)
- :insert(text)
- :insert_position(pos)
pos = :insert_position( ) - pos = :line_end(pos [, islinestart])
- pos = :line_start(pos)
- :linenumber_align(alignment)
alignment = :linenumber_align( ) - :linenumber_bgcolor(color)
color = :linenumber_bgcolor( ) - :linenumber_fgcolor(color)
color = :linenumber_fgcolor( ) - :linenumber_font(font)
font = :linenumber_font( ) - :linenumber_format(fmt)
fmt = :linenumber_format( ) - :linenumber_size(fontsize)
fontsize = :linenumber_size( ) - :linenumber_width(w)
w = :linenumber_width( ) - boolean = :move_down( )
boolean = :move_left( )
boolean = :move_right( )
boolean = :move_up( ) - :next_word( )
- :overstrike( )
- x, y = :position_to_xy(pos)
Returns nil if character is vertically out of view. - :previous_word( )
- :redisplay_range(start, end)
- pos = :rewind_lines(start, nlines)
- :scrollbar_align(alignment)
alignment = :scrollbar_align( ) - :scrollbar_width(w)
w = :scrollbar_width( ) - :shortcut(shortcut)
shortcut = :shortcut( ) - :show_cursor(boolean)
- :show_insert_position( )
- pos = :skip_lines(start, nlines [, islinestart])
- :textcolor(color)
color = :textcolor( ) - :textfont(font)
font = :textfont( ) - :textsize(fontsize)
fontsize = :textsize( ) - start = :word_start(pos)
- end + 1 = :word_end(pos)
- :wrap_mode(wrapmode, margin)
text_editor
Rfr: Fl_Text_Editor
Inherits from: text_display
- text_editor = gui.text_editor(x, y, w, h [, label])
- :insert_mode(boolean)
boolean = :insert_mode( ) - :key_callback(func)
Registers func as the callback for key bindings. A text_editor may have only one key callback, and this will handle all the (key, modifiers) combinations bound with the key_bind( ) method. The callback is executed as func(editor, key, modifiers) and must return a boolean (the modifiers argument is passed as integer code). - :key_bind(key, modifiers)
Binds (key, modifiers) to the key callback. - :key_unbind(key, modifiers)
Unbinds (key, modifiers). This method can be used also to unbind default key bindings, not only for keys bound to the key callback. - :remove_all_key_bindings( )
Built-in key handling functions are available as members of the gui table and may be used in the key callback:
- boolean = gui.kf_default(key, text_editor)
boolean = gui.kf_ignore(key, text_editor)
boolean = gui.kf_backspace(key, text_editor)
boolean = gui.kf_enter(key, text_editor)
boolean = gui.kf_move(key, text_editor)
boolean = gui.kf_shift_move(key, text_editor)
boolean = gui.kf_ctrl_move(key, text_editor)
boolean = gui.kf_c_s_move(key, text_editor)
boolean = gui.kf_meta_move(key, text_editor)
boolean = gui.kf_m_s_move(key, text_editor)
boolean = gui.kf_home(key, text_editor)
boolean = gui.kf_end(key, text_editor)
boolean = gui.kf_left(key, text_editor)
boolean = gui.kf_up(key, text_editor)
boolean = gui.kf_right(key, text_editor)
boolean = gui.kf_down(key, text_editor)
boolean = gui.kf_page_up(key, text_editor)
boolean = gui.kf_page_down(key, text_editor)
boolean = gui.kf_insert(key, text_editor)
boolean = gui.kf_delete(key, text_editor)
boolean = gui.kf_copy(key, text_editor)
boolean = gui.kf_cut(key, text_editor)
boolean = gui.kf_paste(key, text_editor)
boolean = gui.kf_select_all(key, text_editor)
boolean = gui.kf_undo(key, text_editor)
tile
Rfr: Fl_Tile
Inherits from: group
- tile = gui.tile(x, y, w, h [, label])
- :move_intersection(oldx, oldy, newx, newy)
tree
Rfr: Fl_Tree
Inherits from: group
RTTI: see treeselect
NOTE: In Y3A, tree items are identified by their pathname and the tree they belong to (orphaned items are not supported). The Fl_Tree_Item class in not directly exposed, while its methods are exposed as methods of the gui.tree object (renamed with a leading item_ prefix, and accepting the item’s pathname as first argument). Children items’ indices are 1-based.
- tree = gui.tree(x, y, w, h [, label])
- :add(pathname)
- :argument(arg)
arg + = :argument( )
arg : any Lua value. - :callback(func [, arg])
func + = :callback( )
The func callback (a Lua function) is executed as func(tree, pathname, reason, arg), where pathname is the affected item and reason is the reason for calling back (see treereason). The optional argument arg may be any Lua value. - :clear([pathname])
If pathname is passed, clears the item’s subtree, otherwise clears the whole tree. - :closeicon(image)
image = :closeicon( ) - :connectorcolor(color)
color = :connectorcolor( ) - :connectorstyle(treeconnector)
treeconnector = :connectorstyle( ) - :connectorwidth(pixels)
pixels = :connectorwidth( ) - :extend_selection_up(from, to [, op] [, visible])
n = :extend_selection_down(from, to [, op] [, visible])
from, to : items pathnames.
op : select (default), deselect, toggle
visible : boolean (default=false). - pathname = :first( )
pathname = :first_selected_item( )
pathname = :first_visible_item( ) - pathname = :get_item_focus( )
- :hposition(h)
h = :hposition( ) - pathname = :insert_above(above, name)
above : pathname of the item above which the new item has to be inserted.
name : name of the new item.
Returns the pathname of the newly inserted item. - pathname = :insert(parent, name, index)
parent : pathname of the parent item.
name : name of the new item.
Returns the pathname of the newly inserted item. - boolean = :is_hscroll_visible( )
boolean = :is_vscroll_visible( ) - :labelmarginleft(pixels)
- pixels = :labelmarginleft( )
- pathname = :last( )
pathname = :last_selected_item( )
pathname = :last_visible_item( ) - :linespacing(pixels)
pixels = :linespacing( ) - :marginleft(pixels)
pixels = :marginleft( ) - :margintop(pixels)
pixels = :margintop( ) - pathname = :next(pathname)
pathname = :next_selected_item(pathname)
pathname = :next_visible_item(pathname) - :openicon(image)
image = :openicon( ) - :openchild_marginbottom(pixels)
pixels = :openchild_marginbottom( ) - pathname = :prev(pathname)
pathname = :prev_selected_item(pathname)
pathname = :prev_visible_item(pathname) - :remove(pathname)
- :root_label(name)
- name = :root( )
- :scrollbar_size(pixels)
pixels = :scrollbar_size( ) - :show_item([pathname] [, yoffset])
- :show_item_bottom([pathname])
:show_item_middle([pathname])
:show_item_top([pathname]) - :selectbox(boxtype)
boxtype = :selectbox( ) - :selectmode(treeselect)
treeselect = :selectmode( ) - :set_item_focus([pathname])
- :showcollapse(boolean)
boolean = :showcollapse( ) - :showroot(boolean)
boolean = :showroot( ) - :show_self( )
- :sortorder(treesort)
treesort = :sortorder( ) - :usericon(image)
image = :usericon( ) - :usericon_marginleft(pixels)
pixels = :usericon_marginleft( ) - :vposition(v)
v = :vposition( ) - :item_activate(pathname)
- pathname = :item_child(pathname, index)
- n = :item_children(pathname)
- boolean = :item_close(pathname [, docallback])
- :item_deactivate(pathname)
- n = :item_depth(pathname)
- boolean = :item_deselect([pathname] [, docallback])
boolean = :item_deselect_all([pathname] [, docallback]) - :item_display([pathname])
- boolean = :item_displayed([pathname])
- index = :item_find_child(pathname, name)
Returns nil if the item pathname has no child named name, otherwise returns its index (1-based). - h = :item_h(pathname)
- boolean = :item_has_children(pathname)
boolean = :item_is_active(pathname)
boolean = :item_is_activated(pathname)
boolean = :item_is_close(pathname)
boolean = :item_is_open(pathname)
boolean = :item_is_root(pathname)
boolean = :item_is_selected(pathname)
boolean = :item_is_visible(pathname) - :item_label(pathname, label)
label = :item_label(pathname) - x = :item_label_x(pathname)
y = :item_label_y(pathname)
w = :item_label_w(pathname)
h = :item_label_h(pathname) - :item_labelbgcolor([pathname], color)
color = :item_labelbgcolor([pathname])
pathname=nil to set/get the default color. - :item_labelfgcolor([pathname], color)
color = :item_labelfgcolor([pathname])
pathname=nil to set/get the default color. - :item_labelcolor: alias for :item_labelfgcolor.
- :item_labelfont([pathname], font)
font = :item_labelfont([pathname])
pathname=nil to set/get the default font. - :item_labelsize([pathname], fontsize)
fontsize = :item_labelsize([pathname])
pathname=nil to set/get the default font size. - boolean = :item_open(pathname [, docallback])
- boolean = :item_open_toggle(pathname [, docallback])
- pathname = :item_parent(pathname)
- :item_show_self(pathname [, indent])
- boolean = :item_select([pathname] [, docallback])
boolean = :item_select_all([pathname] [, docallback])
boolean = :item_select_only([pathname] [, docallback])
boolean = :item_select_toggle([pathname] [, docallback]) - :item_swap_children(pathname, name1, name2)
- :item_user_data(pathname, val)
val = :item_user_data(pathname)
val: integer value to associate with the item (may be used to index a Lua table containing more complex data). - :item_usericon(pathname, image)
image = :item_usericon(pathname) - :item_visible(pathname)
boolean = :item_visible_r(pathname) - w = :item_w(pathname)
- :item_widget(pathname, widget)
widget = :item_widget(pathname) - x = :item_x(pathname)
y = :item_y(pathname)
window
Rfr: Fl_Window
Inherits from: group
- window = gui.window(x, y, w, h [, label])
window = gui.window(w, h [, label]) - :border(boolean)
boolean = :border( ) - :clear_border( )
- :clear_modal_states( )
- :cursor(cursortype)
:cursor(image, hotx, hoty) - height = :decorated_h( )
width = :decorated_w( ) - :default_cursor(cursortype)
- :fullscreen( )
- boolean = :fullscreen_active( )
- :fullscreen_off( )
:fullscreen_off(x, y, w, h) - :fullscreen_screens(top, bottom, left, right)
- :hotspot(widget [, offscreen])
:hotspot(x, y [, offscreen]) - :icon(image)
- :iconize( )
- :iconlabel(label)
label = :iconlabel( ) - :label(label)
label = :label( ) - :make_current( )
- boolean = :menu_window( )
boolean = :modal( )
boolean = :non_modal( )
boolean = :override( ) - :set_menu_window( )
:set_modal( )
:set_non_modal( )
:set_override( ) - :set_tooltip_window( )
- :shape(image)
- :show( )
- boolean = :shown( )
- :size_range(minw, minh [, maxw, maxh, dw, dh, aspect])
- boolean = :tooltip_window( )
- :wait_for_expose( )
- x = :x_root( )
y = :y_root( ) - xclass = :xclass( )
double_window
Rfr: Fl_Double_Window
Inherits from: window
- double_window = gui.double_window(x, y, w, h [, label])
double_window = gui.double_window(w, h [, label]) - :flush( )
overlay_window
Rfr: Fl_Overlay_Window
Inherits from: double_window
No constructor (abstract class).
- boolean = :can_do_overlay( )
- :draw_overlay( )
:redraw_overlay( )
gl_window
Rfr: Fl_Gl_Window
Inherits from: window
No constructor (abstract class).
single_window
Rfr: Fl_Single_Window
Inherits from: window
- single_window = gui.single_window(x, y, w, h [, label])
single_window = gui.single_window(w, h [, label])
menu_window
Rfr: Fl_Menu_Window
Inherits from: window
- menu_window = gui.menu_window(x, y, w, h [, label])
menu_window = gui.menu_window(w, h [, label])
wizard
input_
Rfr: Fl_Input_
Inherits from: widget
RTTI: normal, float, int, hidden, multiline, secret
No constructor (abstract class).
- boolean = :copy(clipboard)
clipboard : 0 for current text selection, 1 for cut&paste clipboard. - boolean = :copy_cuts( )
- :cursor_color(color)
color = :cursor_color( ) - boolean = :cut( )
boolean = :cut(n)
boolean = :cut(n1, n2) - ucs4 = :index(n)
- :input_type(rtti)
rtti = :input_type( ) - boolean = :insert(text)
- boolean = :mark(m)
m = :mark( ) - :maximum_size(nchars)
nchars = :maximum_size( ) - :position(pos)
boolean = :position(pos, m)
pos = :position( ) - :readonly(boolean)
boolean = :readonly( ) - boolean = :replace(begin, end, text)
- :shortcut(shortcut)
shortcut = :shortcut( ) - :size(w, h)
nbytes = :size( ) - :tab_nav(boolean)
boolean = :tab_nav( ) - :textcolor(color)
color = :textcolor( ) - :textfont(font)
font = :textfont( ) - :textsize(fontsize)
fontsize = :textsize( ) - boolean = :undo( )
- boolean = :value(text)
text = :value( ) - :wrap(boolean)
boolean = :wrap( )
file_input
Rfr: Fl_File_Input
Inherits from: input
float_input
Rfr: Fl_Float_Input
Inherits from: input
- float_input = gui.float_input(x, y, w, h [, label])
multiline_input
Rfr: Fl_Multiline_Input
Inherits from: input
- multiline_input = gui.multiline_input(x, y, w, h [, label])
multiline_output
Rfr: Fl_Multiline_Output
Inherits from: output
- multiline_output = gui.multiline_output(x, y, w, h [, label])
secret_input
Rfr: Fl_Secret_Input
Inherits from: input
- secret_input = gui.secret_input(x, y, w, h [, label])
menu_item
Rfr: Fl_Menu_Item
- :activate()
- boolean = :active( )
- boolean = :activevisible( )
- :argument(argument)
argument = :argument( ) - :callback(func)
func = :callback( ) - boolean = :checkbox( )
- :clear( )
- :deactivate( )
- menuitemflags = :flags( )
- :hide( )
- :image(image)
- :label(label)
:label(labeltype, label)
label = :label( ) - :labelcolor(color)
color = :labelcolor( ) - :labelfont(font)
font = :labelfont( ) - :labelsize(fontsize)
fontsize = :labelsize( ) - :labeltype(labeltype)
labeltype = :labeltype( ) - boolean = :radio( )
- :set( )
- :setonly( )
- :shortcut(shortcut)
shortcut = :shortcut( ) - :show( )
- nitems = :size( )
Returns the no. of items from this one to the end. - boolean = :submenu( )
- boolean = :value( )
- boolean = :visible( )
menu_
Rfr: Fl_Menu_
Inherits from: widget.
No constructor (abstract class).
- index = :add(pathname [, shortcut] [, func] [, argument] [, menuitemflags])
The func callback, if any, is executed as func(menu, pathname, argument).
The argument may be any valid Lua value. - :clear( )
- :clear_submenu(pathname)
- :down_box(boxtype)
boxtype = :down_box( ) - :global( )
- :mode(pathname, menuitemflags)
menuitemflags = :mode(pathname) - pathname = :mvalue( )
- :remove(pathname)
- :replace(pathname, newlabel)
- :shortcut(pathname, shortcut)
shortcut = :shortcut(pathname) - :size(w, h)
nitems = :size( ) - pathname = :test_shortcut( )
- label = :text([pathname])
If pathname is not passed, the label of the last picked item is returned (i.e. pathname defaults to :mvalue()). - :textcolor(color)
color = :textcolor( ) - :textfont(font)
font = :textfont( ) - :textsize(fontsize)
fontsize = :textsize( ) - changed = :value(pathname)
- pathname = :value( )
choice
Rfr: Fl_Choice
Inherits from: menu_
- choice = gui.choice(x, y, w, h [, label])
- changed = :value(pathname)
pathname = :value( )
menu_button
Rfr: Fl_Menu_Button
Inherits from: menu_
RTTI: popup1, popup2, popup12, popup3, popup13, popup23, popup123.
- menu_button = gui.menu_button(x, y, w, h [, label])
- pathname = :popup( )
progress
Rfr: Fl_Progress
Inherits from: widget
- progress = gui.progress(x, y, w, h [, label])
- :maximum(number)
number = :maximum( ) - :minimum(number)
number = :minimum( ) - :value(number)
number = :value( )
valuator
Rfr: Fl_Valuator
Inherits from: widget
No constructor (abstract class).
- :bounds(min, max)
- number = :clamp(number)
- string = :format( )
- number = :increment(step, n)
- :maximum(number)
number = :maximum( ) - :minimum(number)
number = :minimum( ) - :precision(ndigits)
- :range(min, max)
- number = :round(number)
- :step(number)
:step(a, n) - number = :step( )
- changed = :value(number)
number = :value( )
adjuster
Rfr: Fl_Adjuster
Inherits from: valuator
- adjuster = gui.adjuster(x, y, w, h [, label])
- :soft(boolean)
boolean = :soft( )
counter
Rfr: Fl_Counter
Inherits from: valuator
RTTI: normal, simple
simple_counter
Rfr: Fl_Simple_Counter
Inherits from: counter
- simple_counter = gui.simple_counter(x, y, w, h [, label])
dial
Rfr: Fl_Dial
Inherits from: valuator
RTTI: normal, line, fill
- dial = gui.dial(x, y, w, h [, label])
- :angle1(deg)
deg = :angle1( ) - :angle2(deg)
deg = :angle2( ) - :angles(deg1, deg2)
roller
Rfr: Fl_Roller
Inherits from: valuator
RTTI: vertical, horizontal
- roller = gui.roller(x, y, w, h [, label])
slider
Rfr: Fl_Slider
Inherits from: valuator
RTTI: vertical, horizontal, vertical fill, horizontal fill, vertical nice, horizontal nice
fill_slider
Rfr: Fl_Fill_Slider
Inherits from: slider
- fill_slider = gui.fill_slider(x, y, w, h [, label])
hor_fill_slider
Rfr: Fl_Hor_Fill_Slider
Inherits from: slider
- hor_fill_slider = gui.hor_fill_slider(x, y, w, h [, label])
hor_nice_slider
Rfr: Fl_Hor_Nice_Slider
Inherits from: slider
- hor_nice_slider = gui.hor_nice_slider(x, y, w, h [, label])
hor_slider
Rfr: Fl_Hor_Slider
Inherits from: slider
- hor_slider = gui.hor_slider(x, y, w, h [, label])
nice_slider
Rfr: Fl_Nice_Slider
Inherits from: slider
- nice_slider = gui.nice_slider(x, y, w, h [, label])
scrollbar
Rfr: Fl_Scrollbar
Inherits from: slider
RTTI: vertical, horizontal
- scrollbar = gui.scrollbar(x, y, w, h [, label])
- :linesize(step)
step = :linesize( ) - boolean = :value(pos)
boolean = :value(pos, winsize, first, total)
pos = :value( )
value_slider
Rfr: Fl_Value_Slider
Inherits from: slider
hor_value_slider
Rfr: Fl_Hor_Value_Slider
Inherits from: value_slider
- hor_value_slider = gui.hor_value_slider(x, y, w, h [, label])
value_input
Rfr: Fl_Value_Input
Inherits from: valuator
value_output
Rfr: Fl_Value_Output
Inherits from: valuator
image
Rfr: Fl_Image
- image = gui.image(name, data [, w, h])
- gui.rgb_scaling(rgbscaling)
rgbscaling = gui.rgb_scaling( ) - gui.rgb_max_size(size)
size = gui.rgb_max_size( ) - :color_average(color, amount)
amount: 0.0 to 1.0. - image = :copy([w, h])
- count = :count( )
- depth = :d( )
height = :h( )
width = :w( ) - :desaturate( )
- :draw(x, y [, w, h] [, cx, cy])
- :inactive( )
- :label(widget)
:label(menu, pathname)
The couple (menu, pathname) identifies a menu item. - size = :ld( )
- :uncache( )
help_dialog
Rfr: Fl_Help_Dialog
- help_dialog = gui.help_dialog( )
- :hide( )
- :load(filename)
- :position(x, y)
- :resize(x, y, w, h)
- :show( )
- :textsize(fontsize)
fontsize = :textsize( ) - :topline(name)
:topline(n) - :value(text)
text = :value( ) - boolean = :visible( )
- x = :x( )
y = :y( )
w = :w( )
h = :h( )
native_file_chooser
Rfr: Fl_Native_File_Chooser
RTTI: file (default), directory, multi file, multi directory, save file, save directory
- native_file_chooser = gui.native_file_chooser([rtti])
- nitems = :count( )
- :directory(dirname)
dirname = :directory( ) - errmsg = :errmsg( )
- filename = :filenames([i = 1])
The optional i argument must be in the range 1 .. count(). - filename1, …, filenameN = :filenames()
Returns the names of all the selected items (N=count()). - :filter(filter)
filter = :filter( ) - :filter_value(i)
i = :filter_value( )
The i argument must be in the range 1 .. filters(). - nfilters = :filters( )
- :options(nativefilechooseroptions)
nativefilechooseroptions= :options( ) - :preset_file(filename)
filename = :preset_file( ) - retval = :show( )
retval : ok, cancel or error message (same as errmsg()). - :title(title)
title = :title( ) - :type(rtti)
rtti = :type( )
text_buffer
Rfr: Fl_Text_Buffer
NOTE: All indices in text buffers are 1-based (Lua-style). Indices denoting a range – usually named start and end – are inclusive (when end is optional it defaults to the buffer’s length). The indices start and end = start – 1 denote a zero length range right before start.
buf = gui.text_buffer()
buf:text("hello") -- position: 1 .. 9
print(buf:text()) --> hello
print(buf:text_range(1,1)) --> h
print(buf:text_range(1,2)) --> he
print(buf:text_range(1)) --> hello
buf:replace(1,0,"xxx") -- replaces an empty range (i.e. inserts) before pos=1
print(buf:text()) --> xxxhello
Lua- text_buffer = gui.text_buffer([reqsize] [, prefgapsize]])
- :append(text)
- ok, errmsg = :appendfile(filename [, buflen])
- byte = :byte_at(pos)
Returns the raw byte found at pos. - :can_undo(boolean)
- char, codepoint = :char_at(pos)
Returns the UTF-8 encoded character containing the byte at pos, and its codepoint. The pos argument need not be at a character boundary (the method takes care of aligning it). - :copy(from, start, end, pos)
from is the source text_buffer, (start, end) is the range to be copied and pos is the destination position. - nchars = :count_displayed_characters(linestartpos, targetpos)
- nlines = :count_lines(startpos, endpos)
NOTE: nlines is the number of newlines (‘\n’). Total number of lines is count_lines(1) + 1. - :findchar_backward(start, char)
pos = :findchar_forward(start, char)
char : UTF8 encoded character. Returns nil if char is not found. - :highlight(start [, end])
boolean = :highlight( ) - start, end = :highlight_position( )
- text = :highlight_text( )
- boolean = :input_file_was_transcoded( )
- :insert(pos, text)
- ok, errmsg = :insertfile(filename, pos [, buflen])
- nbytes = :length( )
- end = :line_end(pos)
- start = :line_start(pos)
- text = :line_text(pos)
- ok, errmsg = :loadfile(filename [, buflen])
- start, end = :next_char([pos])
Returns the boundaries of the character following the one containing the byte at pos, or nil if there are none. If pos is none or nil, returns the boundaries of the first character (i.e. start = 1, end = whatever). - ok, errmsg = :outputfile(filename, start [, end] [, buflen])
- start, end = :prev_char(pos)
Returns the boundaries of the character preceding the one containing the byte at pos, or nil if there are none. If pos is none or nil, returns the boundaries of the last character (i.e. start = whatever, end = length()). - :remove(start [, end])
:remove_secondary_selection( )
:remove_selection( ) - :replace(start, end, text)
:replace_secondary_selection(text)
:replace_selection(text) - pos = :rewind_lines(start, nlines)
- ok, errmsg = :savefile(filename [, buflen])
- pos = :search_backward(start, text [, matchcase])
pos = :search_forward(start, text [, matchcase])
Returns nil if text is not found. - :secondary_select(start [, end])
- boolean = :secondary_selected( )
- start, end = :secondary_selection_position( )
- text = :secondary_selection_text( )
- :secondary_unselect( )
- :select(start [, end])
- boolean = :selected( )
- start, end = :selection_position( )
- text = :selection_text( )
- offset = :skip_displayed_characters(linestart, nchars)
- pos = :skip_lines(start, nlines)
- :tabs_distance(n)
n = :tabs_distance( ) - :text(text)
text = :text( ) - text = :text_range(start [, end])
Returns the text between start and end. Raises an error if start is greater than end or than the buffer’s length. - pos = :undo( )
- :unhighlight( )
- :unselect( )
- pos = :utf8_align(pos)
- start, end = :word(pos)
- text = :word_at(pos)
Returns the UTF-8 encoded word containing the byte at pos.
- :call_modify_callback( )
- :call_predelete_callback( )
- :modify_callback(func [, argument])
If func = nil, unregisters the current callback and argument, otherwise registers func (a function) as the modify callback for this text_buffer. The optional argument may be any valid Lua type.
The callback is executed as func(buf, pos, nins, ndel, nrest, deltext, argument), where buf is this text_buffer, and the other parameters have the same meaning as in the Fl_Text_Modify_Cb type. - :predelete_callback(func [, argument])
If func = nil, unregisters the current callback and argument, otherwise registers func (a function) as the predelete callback for this text_buffer. The optional argument may be any valid Lua type.
The callback is executed as func(buf, pos, ndel, argument), where buf is this text_buffer, and the other parameters have the same meaning as in the Fl_Text_Predelete_Cb type.
Subclassing
Rfr: Adding and Extending Widgets.
In order to extend widgets, and to use widgets such as gl_window that require subclassing, Y3A provides subclass objects. These are Lua userdata bound to instances of subclasses of FLTK widgets, and provided with means to override a few methods of their superclass (draw( ), handle( ), etc.), and to invoke those of the superclass.
fl = require("YAAA.app")
-- Subclass 'constructor':
function MyWindow(w, h, label)
-- Create a 'window sub' object:
local win = gui.window_sub(w, h, label)
print("created window", win)
-- Override the basic window methods:
win:override_draw(mydraw)
win:override_handle(myhandle)
win:override_hide(myhide)
win:override_resize(myresize)
return win
end
function mydraw(win)
assert(win == mywin)
print("draw()")
win:super_draw() -- this executes window:draw()
end
function myhandle(win, event)
assert(win == mywin)
print("handle('" .. event .. "')")
-- this must return true or false (see Fl_Widget::handle())
return win:super_handle(event)
end
function myhide(win)
assert(win == mywin)
print("hide()")
win:super_hide()
end
function myresize(win, x, y, w, h)
assert(win == win)
print(string.format("resize(%d, %d, %d, %d)", x, y, w, h))
win:super_resize(x, y, w, h)
end
mywin = MyWindow(340, 180, arg[0])
mywin:resizable(mywin) -- so that we can try myresize()
mywin:done()
mywin:show()
return gui.run()
LuaA subclass object is instantiated by means of the subclass constructor function (gui.window_sub ( ) in the above example). This function accepts the same parameters as the constructor of the super-class (gui.window ( ), in the example), and has the same name but with a trailing ‘_sub‘.
The object inherits all the methods of the superclass (except for the overridable ones), plus those listed hereafter.
Methods available to all subclasses:
- subwidget:override_draw (func)
Overrides the draw( ) method with the func callback, which will be executed as func(subwidget). - subwidget:override_handle (func)
Overrides the handle( ) method with the func callback, which will be executed as func(subwidget, event) and must return a boolean indicating whether the event has been consumed or not. - subwidget:override_hide (func)
Overrides the hide( ) method with the func callback, which will be executed as func(subwidget). - subwidget:override_resize (func)
Overrides the resize( ) method with the func callback, which will be executed as func(subwidget, x, y, w, h). - subwidget:override_show (func)
Overrides the show( ) method with the func callback, which will be executed as func(subwidget). - subwidget:super_draw ( )
Executes the draw( ) method of the superclass. - subwidget:super_handle (event)
→ boolean
Executes the handle( ) method of the superclass. - subwidget:super_hide ( )
Executes the hide( ) method of the superclass. - subwidget:super_resize (x, y, w, h)
Executes the resize( ) method of the superclass. - subwidget:super_show ( )
Executes the show( ) method of the superclass.
Methods available only to overlay_window_sub:
- subwidget:override_draw_overlay (func)
Overrides the draw_overlay( ) method with the func callback, which will be executed as func(subwidget).
Methods available only to table_sub and table_row_sub:
Functions
Main loop
Rfr: Fl
- gui.args(progname [, args])
gui.args(args)
progname: string,
args: {string}. - boolean = gui.check( )
- boolean = gui.damage( )
- gui.display(string)
- gui.flush( )
- boolean = gui.gl_visual(mode)
- boolean = gui.is_scheme(name)
- gui.option(option, boolean)
boolean = gui.option(option)
- boolean = gui.ready( )
- gui.redraw( )
- gui.reload_scheme( )
- gui.scheme(name)
name = gui.scheme( ) - boolean = gui.run( )
- number = gui.version( )
- gui.visible_focus(boolean)
boolean = gui.visible_focus( ) - boolean = gui.visual(mode)
- gui.wait([seconds])
boolean = gui.wait( )
Returns nil if an error occurred.
Windows handling
Events handling
Rfr: Events handling functions
- gui.belowmouse(widget)
widget = gui.belowmouse( ) - gui.disable_im( )
- gui.enable_im( )
- event = gui.event( )
- boolean = gui.event_alt( )
- button = gui.event_button( )
button: ‘left‘, ‘middle‘, ‘right‘ (or nil). - boolean = gui.event_button1( )
boolean = gui.event_button2( )
boolean = gui.event_button3( ) - left, middle, right = gui.event_buttons( )
left, middle, right: booleans. - gui.event_clicks(nclicks)
nclicks = gui.event_clicks( ) - image = gui.event_clipboard( )
Returns nil if the pasted data is not an image. - clipboardtype = gui.event_clipboard_type( )
- boolean = gui.event_command( )
- boolean = gui.event_ctrl( )
- n = gui.event_dx( )
n = gui.event_dy( ) - gui.event_inside(x, y, w, h)
boolean = gui.event_inside(widget) - gui.event_is_click(boolean)
boolean = gui.event_is_click( ) - gui.event_key(key)
key = gui.event_key( ) - n = gui.event_lenght( )
- boolean = gui.event_shift( )
- modifiers = gui.event_state( )
- boolean = gui.event_state(modifiers)
- text = gui.event_text( )
- pos = gui.event_x( )
pos = gui.event_x_root( )
pos = gui.event_y( )
pos = gui.event_y_root( ) - gui.focus(widget)
widget = gui.focus( ) - boolean = gui.get_key(key)
- x, y = gui.get_mouse( )
Selection & Clipboard
Rfr: Selection & Clipboard functions
- gui.add_clipboard_notify([func])
Registers func as ‘clipboard notify callback’. If func is none or nil, unregisters the current callback.
The callback is executed as func(source) where source (a string) may be either ‘selection buffer‘ or ‘clipboard‘. - boolean = gui.clipboard_contains(clipboardtype)
- gui.copy(text [, destination])
destination: ‘selection buffer‘ or ‘clipboard‘. - gui.dnd( )
- gui.dnd_text_ops(boolean)
boolean = gui.dnd_text_ops( ) - gui.paste(receiver, source [, clipboardtype])
receiver: a widget.
destination: ‘selection buffer‘ or ‘clipboard‘. - gui.remove_clipboard_notify( )
Unregisters the current ‘clipboard notify callback’, if any. - gui.selection(owner, text)
owner: a widget.
Screen
Rfr: Screen functions
NOTE | Screens are numbered from 1 to gui.screen_count( ) inclusive. |
- nscreens = gui.screen_count( )
- h, v = gui.screen_dpi([screen = 1])
- screen = gui.screen_num(x, y [,w, h])
- x, y, w, h = gui.screen_work_area(mx, my)
x, y, w, h = gui.screen_work_area(screen)
x, y, w, h = gui.screen_work_area( ) - x, y, w, h = gui.screen_xywh( )
x, y, w, h = gui.screen_xywh(mx, my)
x, y, w, h = gui.screen_xywh(screen)
x, y, w, h = gui.screen_xywh(mx, my, mw, mh) - x = gui.x( )
y = gui.y( )
w = gui.w( )
h = gui.h( ) - x, y, w, h = gui.xywh( )
Colors
Rfr: Color & Font functions – Fl.
- gui.background(r, g, b)
gui.background2(r, g, b) - gui.color(color)
gui.color(r, g, b)
color = gui.color( ) - color = gui.color_average(color1, color2, weight)
- color = gui.color_cube(r, g, b)
r, g, b: 0 .. gui.NUM_RED/GREEN/BLUE – 1. See FL/Enumerations.H. - color = gui.contrast(fgcolor, bgcolor)
- color = gui.darker(color)
- gui.free_color(index [, overlay]
- gui.foreground(r, g, b)
- color, r, g, b = gui.get_color(index)
- gui.get_system_colors( )
- color = gui.gray_ramp(n)
n: 0 .. gui.NUM_GRAY – 1. See FL/Enumerations.H. - r, g, b = gui.hsv2rgb(h, s, v)
Binding to Fl_Color_Chooser::hsv2rgb(). - color = gui.inactive(color)
- color = gui.lighter(color)
- gui.own_colormap( )
- color = gui.rgb_color(r, g, b)
color = gui.rgb_color(n)
Returns the color value closer to (r,g,b), or to n (grayscale). See FL/Enumerations.H. - h, s, v = gui.rgb2hsv(r, g, b)
Binding to Fl_Color_Chooser::rgb2hsv(). - gui.set_color(index, fromindex)
gui.set_color(r, g, b) - color = gui.show_colormap(oldcolor)
- xpixel = gui.xpixel(index)
xpixel = gui.xpixel(r, g, b)
Fonts
Rfr: Color & Font functions and Fl
- d = gui.descent( )
- gui.font(font [, fontsize])
font = gui.font( ) - height = gui.height( )
height = gui.height(font, fontsize) - descr = gui.get_font(font)
- fontname, fontattr = gui.get_font_name(font)
- size1, …, sizeN = gui.get_font_sizes(font)
Returns nil if font is scalable. - gui.latin1_to_local(text [, n])
text = gui.local_to_latin1(text [, n]) - nfonts = gui.nfonts( )
Returns the number of available fonts (i.e. the first free font index). - gui.set_font(index, fromindex)
gui.set_font(index, name) - nfonts = gui.setfonts([xstarname])
- dx, dy, w, h = gui.text_extents(text)
- fontsize = gui.size( )
- width = gui.width(text)
Multithreading
Rfr: Multithreading support functions
Y3A can be used in conjunction with multithreading libraries such as LuaLanes (thanks to Oliver).
Any other thread (‘background thread‘) is only allowed to require the “gui.background” module, which is a limited version of Y3A containing only the gui.awake( ) function described below and a few other thread-safe utilities (currently, those listed in the sections ‘File names and URI’, and ‘Unicode and UTF-8’).
- boolean = gui.awake([message])
Only available in background threads.
Awakes the main thread, optionally queueing a string message.
Returns true if the message was successfully queued or no message was given. - message = gui.thread_message( )
Removes and returns the next message (string) queued with gui.awake( ), or nil if the queue is empty.
Unicode and UTF-8
Rfr: Unicode and UTF-8 functions
See also Lua’s native UTF-8 Support.
- string = gui.utf_tolower(string)
string = gui.utf_toupper(string) - -1|0|+1 = gui.utf_strcasecmp(string1, string2)
Common Dialogs
Rfr: Common Dialogs classes functions
- gui.alert(message)
- gui.beep(beep)
- gui.choice_dialog(message, opt1 [, opt2] [, opt3])
- gui.color_chooser_b(label, r, g, b [, colorchoosermode])
r, g, b = gui.color_chooser_f(label, r, g, b [, colorchoosermode])
Returns nil if the user cancelled the dialog.
The ‘_b’ version works with byte components (0 .. 255), while the ‘_f’ version works with floating point components (0.0 .. 1.0). - dirname = gui.dir_chooser(message, dirname [, relative])
Returns nil if the user cancelled the dialog.
relative: a boolean (true for relative path return, false for absolute path). - filename = gui.file_chooser(message, pattern, filename [, relative])
Returns nil if the user cancelled the dialog.
relative: a boolean (true for relative path return, false for absolute path). - gui.file_chooser_callback([func])
If func is nil or none, unregisters the current file chooser callback (if any).
The func callback is executed as func(filename). - gui.file_chooser_ok_label(label)
- gui.message(message)
gui.message_hotspot(boolean)
boolean = gui.message_hotspot( ) - gui.message_title(title)
- gui.message_title_default(title)
- text = gui.password(message [, default])
Returns nil if the user cancelled the dialog.
File names and URI
Rfr: File names and URI utility functions
- uri = gui.decode_uri(uri)
- filename = gui.filename_absolute(filename)
- filename = gui.filename_expand(filename)
- extension = gui.filename_ext(filename)
Returns nil if filename has no extension. - boolean = gui.filename_isdir(filename)
- filename1, …, filenameN = gui.filename_list(dirname [, filesort])
- boolean = gui.filename_match(string, pattern)
- filename = gui.filename_name(pathname)
- filename = gui.filename_relative(filename)
- extension = gui.filename_setext(filename, extension)
- boolean, msg = gui.open_uri(uri)
Tooltips
Rfr: Fl_Tooltip
- gui.tooltip_color(color)
color = gui.tooltip_color( ) - gui.tooltip_current(widget)
widget = gui.tooltip_current( ) - gui.tooltip_delay(seconds)
seconds = gui.tooltip_delay( ) - gui.tooltip_disable( )
- gui.tooltip_enable([boolean])
- boolean = gui.tooltip_enabled( )
- gui.tooltip_font(font)
font = gui.tooltip_font( ) - gui.tooltip_hoverdelay(seconds)
seconds = gui.tooltip_hoverdelay( ) - gui.tooltip_margin_height(pixels)
pixels = gui.tooltip_margin_height( ) - gui.tooltip_margin_width(pixels)
pixels = gui.tooltip_margin_width( ) - gui.tooltip_size(fontsize)
fontsize = gui.tooltip_size( ) - gui.tooltip_textcolor(color)
color = gui.tooltip_textcolor( ) - gui.tooltip_wrap_width(pixels)
pixels = gui.tooltip_wrap_width( )
Handlers
Rfr: Fl
Check handler
- boolean = gui.has_check( )
Returns true if the check handler is set and has not yet been called, false otherwise. - gui.set_check(func)
Sets func (a function) as the check handler. It will be executed as func() (i.e. passing it no arguments). If called with no arguments, removes the handler.
NOTE | There is a single check handler in Y3A. If multiple handlers are needed, multiplex it in Lua. |
File descriptors handler
- boolean = gui.has_fd_handler( )
Returns true if the fd handler is set, false otherwise. - gui.set_fd_handler(func)
Sets func (a function) as the fd handler. It will be executed as func(fd) where fd is the affected file handler. If called with no arguments, removes the handler.
NOTE | There is a single fd handler in Y3A to handle all file descriptors registered with gui.add_fd( ). The file descriptor for a Lua io library file handle can be obtained with the gui.fileno( ) function. |
- gui.add_fd(fd, whenfd)
Monitor the file descriptor fd. When the file descriptor is ready (depending on the whenfd argument) the fd handler is executed. - gui.remove_fd(fd)
Stop monitoring the file descriptor fd.
Idle handler
- boolean = gui.has_idle( )
Returns true if the idle handler is set, false otherwise. - gui.set_idle(func)
Sets func (a function) as the idle handler. It will be executed as func() (i.e. passing it no arguments). If called with no arguments, removes the handler.
NOTE | There is a single idle handler in Y3A. If multiple handlers are needed, multiplex it in Lua. |
Timeout handler
- boolean = gui.has_timeout( )
Returns true if the timeout handler is set, false otherwise. - gui.set_timeout(seconds, repeat, func)
Sets the timer so to expire after seconds. At the timer expiration, the func callback will be executed as func() (passing it no arguments). If repeat is true, the timer is automatically restarted at its expiration. If called with no arguments, this function stops the timer and unregisters the callback.
NOTE | There is a single timeout handler in Y3A. If multiple concurrent timers are needed, the timer module can be multiplexed in Lua. |
timer
timer uses the single timeout handler to implement a timer heap. The following example shows how to use it.
fl = require("YAAA.app")
timer = require("YAAA.app.timer")
-- Init the timer module
timer.init()
tname = {} -- tname[tid] = timer name
tstart = {} -- tstart[tid] = starting time
-- Callback for timers' expiration:
function texpired(tid)
local now = gui.gettime()
print(string.format("timer %s expired (elapsed time: %g seconds)",
tname[tid], now - tstart[tid]))
-- restart timer:
tstart[tid] = timer.start(tid)
end
-- Create a few timers:
t1 = timer.create(2, texpired)
tname[t1] = "T1"
t2 = timer.create(3.1, texpired)
tname[t2] = "T2"
-- Start them:
tstart[t1], errmsg = timer.start(t1)
tstart[t2], errmsg = timer.start(t2)
-- Enter the FLTK main loop:
while true do
gui.wait(0)
end
LuaThe timer module provides the functions described below. Time values are obtained with the gui.gettime( ) function. On error, all these functions return nil followed by an error message.
- timer.init( )
Inits the module. - tid = timer.create(timeout, func)
Creates a new timer and returns a unique timer identifier (tid) for subsequent operations. The timeout argument is the default timeout in seconds, which will be used to compute the expiration time if it is not specified when the timer is started. The func argument (a function) is the callback that will be executed as func(tid) at timer expiration. - timer.delete(tid)
Deletes the timer identified by tid. - timer.deleteall( )
Deletes all the timers. - startime = timer.start(tid [, exptime])
Starts the timer identified by tid so to expire at the time exptime. - timer.stop(tid)
Stops the timer identified by tid. - timeut = timer.timeout(tid [, timeout])
Gets/sets the default timeout (in seconds) for the timer identified by tid. - func = timer.callback(tid [, func])
Gets/sets the callback for the timer identified by tid. - boolean, exptime = timer.isrunning(tid)
If the timer is running, returns true and the expiration time, otherwise returns false.
Additional utilities
- code = gui.alignment(s1, …, sN)
s1, …, sN = gui.alignment(code)
Encodes/decodes the FLTK alignment code from/to the string values s1, …, sN. - code = gui.damagebits(s1, …, sN)
s1, …, sN = gui.damagebits(code)
Encodes/decodes the FLTK damagebits code from/to the string values s1, …, sN. - fd = gui.fileno(file)
Returns the file descriptor for the Lua io library file handle. - seconds = gui.gettime( )
Returns the current time since UNIX epoch (Thu Jan 1 00:00:00 1970) in seconds. - code = gui.key(s)
s = gui.key(code)
Translates the FLTK key code to/from the corresponding string value s. - code = gui.linestyle(s1, …, sN)
s1, …, sN = gui.linestyle(code)
Encodes/decodes the FLTK linestyle code from/to the string values s1, …, sN. - code = gui.menuitemflags(s1, …, sN)
s1, …, sN = gui.menuitemflags(code)
Encodes/decodes the FLTK menuitemflags code from/to the string values s1, …, sN. - code = gui.mode(s1, …, sN)
s1, …, sN = gui.mode(code)
Encodes/decodes the FLTK mode code from/to the string values s1, …, sN. - code = gui.modifiers(s1, …, sN)
s1, …, sN = gui.modifiers(code)
Encodes/decodes the FLTK modifiers code from/to the string values s1, …, sN. - uuid = gui.new_uuid( )
Binding to Fl_Preferences::newUUID( ), returns an universally unique identifier. - trace_object(boolean)
Enables/disables tracing on stdout of objects creation and deletion (default is disabled). - code = gui.shortcut(s1, …, sN)
Encodes an FLTK shortcut code by combining the string values s1, …, sN, which must comprise one (and only one) key and zero or more modifiers. For example, this produces the code for the ‘Ctrl+S’ shortcut: code = gui.shortcut(‘Ctrl’, ‘s’). Beware that the ‘Shift‘ modifier is implicit in upper-case keys, so passing ‘S‘ instead of ‘s‘ would produce the code for the shortcut ‘Ctrl+Shift+S’. - s1, …, sN = gui.shortcut(code)
Decodes an FLTK shortcut. - gui.sleep(seconds)
Sleep for seconds. This function should not be used, it has been added only to emulate work in progress in the examples. - code = gui.whenflags(s1, …, sN)
s1, …, sN = gui.whenflags(code)
Encodes/decodes the FLTK whenflags code from/to the string values s1, …, sN.
Enumerations, bitfields, etc.
An enumeration is a string (a literal) from a well defined set of values.
A bitfield, when used as a function argument it may be passed either as an integer code, or as a sequence of strings from a well defined set of values. When it is not the last argument of the function, it may be passed only as an integer code. Functions returning a bitfield return the integer code only (utilities are provided to encode/decode bitfields, if needed).
NOTE: String values need to be enclosed in quotes i.e. default becomes ‘default’
alignment
Type: bitfield
Values: a combination of gui.ALIGN_XXX
values (corresponding to FL_ALIGN_XXX
defines).
Strings: default, center, top, bottom, left, right, inside, outside, text over image, image over text, image next to text, text next to image, image backdrop, clip, no clip, wrap, no wrap
beep
Type: enumeration
Strings: default, message, error, question, password, notification
boxtype
Type: enumeration or 0-255 integer code (Rfr: Fl_Boxtype)
Strings: no box, flat box, up box, down box, up frame, down frame, thin up box, thin down box, thin up frame, thin down frame, engraved box, embossed box, engraved frame, embossed frame, border box, shadow box, border frame, shadow frame, rounded box, rshadow box, rounded frame, rflat box, round up box, round down box, diamond up box, diamond down box, oval box, oshadow box, oval frame, oflat box, plastic up box, plastic down box, plastic up frame, plastic down frame, plastic thin up box, plastic thin down box, plastic round up box, plastic round down box, gtk up box, gtk down box, gtk up frame, gtk down frame, gtk thin up box, gtk thin down box, gtk thin up frame, gtk thin down frame, gtk round up box, gtk round down box, gleam up box, gleam down box, gleam up frame, gleam down frame, gleam thin up box, gleam thin down box, gleam round up box, gleam round down box, free boxtype
clipboardtype
Type: enumeration
Strings: text/plain, image
color
Type: RGBI integer code
Values: FLTK defines for colors are available as fields of the gui
table (e.g., gui.FOREGROUND_COLOR
for FL_FOREGROUND_COLOR
, gui.RED
for FL_RED
, etc.)
colorchoosermode
Type: enumeration
Strings: default, rgb, byte, hex, hsv
cursorstyle
Type: enumeration
Strings: normal, caret, dim, block, heavy, simple
cursortype
Type: enumeration
Strings: default, arrow, cross, wait, insert, hand, help, move, ns, we, nwse, nesw, n, ne, e, se, s, sw, w, nw, none
damagebits
Type: bitfield
Values: a combination of gui.DAMAGE_XXX
values (corresponding to FL_DAMAGE_XXX
defines)
Strings: nothing, child, expose, scroll, overlay, user1, user2, all
event
Type: enumeration
Strings: no event, push, release, enter, leave, drag, focus, unfocus, keydown, keyup, close, move, shortcut, deactivate, activate, hide, show, paste, selectionclear, mousewheel, dnd enter, dnd drag, dnd leave, dnd release, screen configuration changed, fullscreen
filesort
Type: enumeration
Strings: alphasort, casealphasort, numericsort, casenumericsort
filetype
Type: enumeration
Strings: files, directories
font
Type: integer code encoding the font index and attributes
Value: Available as fields of the fl
table (e.g., gui.HELVETICA
for FL_HELVETICA
, gui.ITALIC
for FL_ITALIC
, etc.)
key
Type: enumeration
Strings: button1 .. button8, backspace, tab, iso key, enter, pause, scroll lock, escape, kana, eisu, yen, jis underscore, home, left, up, right, down, page up, page down, end, print, insert, menu, help, num lock, kp 0 .. kp 9, kp +, kp –, kp *, kp /, kp ., kp =, kp enter, kp middle, f1 .. f20, shift l, shift r, control l, control r, caps lock, meta l, meta r, alt l, alt r, alt gr, delete, volume down, volume mute, volume up, media play, media stop, media prev, media next, home page, mail, search, back, forward, stop, refresh, sleep, favorites, and any printable UTF-8 character in the code-point range 0..255 (see Fl::event_key()).
labeltype
Type: enumeration
Strings: none, normal, shadow, engraved, embossed
lineposition
Type: enumeration
Strings: top, middle, bottom
linestyle
Type: bitfield
Values: a combination of gui.XXX
values (corresponding to FL_XXX
defines for line styles)
Strings: solid, dash, dot, dashdot, dashdotdot, cap flat, cap round, cap square, join miter, join round, join bevel
menuitemflags
Type: bitfield
Values: a combination of gui.MENU_XXX
values (corresponding to FL_MENU_XXX
defines)
Strings: inactive, toggle, value, radio, invisible, submenu, divider, horizontal
mode
Type: bitfield
Values: a combination of gui.XXX
values (corresponding to FL_XXX
defines for mode)
Strings: rgb, index, single, double, accum, alpha, depth, stencil, rgb8, multisample, stereo, fake single
modifiers
Type: bitfield
Values: a combination of gui.XXX
values (corresponding to FL_XXX
defines for modifiers)
Strings: Shift, Caps Lock, Ctrl, Alt, Num Lock, Meta, Scroll Lock, Button1 .. Button8
mousebutton
Type: enumeration
Strings: left, middle, right
nativefilechooseroption
Type: sequence of strings
Strings: no options, saveas confirm, new folder, preview, use filter ext
option
Type: enumeration
Strings: arrow focus, visible focus, dnd text, show tooltips, uses gtk
rgbscaling
Type: enumeration
Strings: nearest, bilinear
rtti
Type: integer code or enumeration
Strings: FLTK ‘RTTI’ integer code for the Fl_Widget:type()
method, or applicable string values for specific classes.
NOTE: rtti values should be enclosed in quotes.
scrollbarmode
Type: enumeration
Strings: none, horizontal, vertical, both, always on, horizontal always, vertical always, both always
shortcut
Type: FLTK shortcut integer code
Utility: May be produced with the gui.shortcut()
utility
tablecontext
Type: enumeration
Strings: none, startpage, endpage, row header, col header, cell, table, rc resize
treeconnector
Type: enumeration
Strings: none, dotted, solid
treereason
Type: enumeration
Strings: none, startpage, endpage, row header, col header, cell, table, rc resize
treeselect
Type: enumeration
Strings: none, single, multi, single draggable
treesort
Type: enumeration
Strings: none, ascending, descending
whenfd
Type: bitfield
Values: a combination of gui.READ
, gui.WRITE
and gui.EXCEPT
values
Strings: read, write, except
whenflags
Type: bitfield
Values: a combination of gui.WHEN_XXX
values (corresponding to FL_WHEN_XXX
defines)
Strings: never, changed, not changed, release, enter key
wrapmode
Type: enumeration
Strings: none, at column, at pixel, at bounds
Unreferencing objects
Usually you need not care about deletion of Y3A objects (widgets, images, etc) because they are automatically garbage collected when the process exits, provided it exits cleanly closing the Lua state.
There may be, however, situations when you want objects to be collected before than that. For example if you dynamically create lots of them for temporary use only.
To force garbage collection of an object, you need to remove all the references to it and let the Lua garbage collector do its job, like you would do with any other Lua value you want to be collected.
Besides the variables holding the object, there are other references to remove. One is the anchor to the Lua registry (all Y3A objects are anchored to the Lua registry when they are created): this counts as a reference, that you can remove with the gui.unreference( ) function. Other references are the callbacks’ arguments: if you use the object as argument for some callback (e.g. if you pass it as arg to the widget:callback( ) method), this also creates a reference that you need to remove; you can do this by unregistering the callback, or by changing its argument to something different than the object you want to delete.
Implementation notes
The following FLTK (1.4) features are not yet implemented in Y3A:
- Most Unicode and UTF-8 functions (notice however that Lua already provides basic UTF-8 Support).
- Safe widget deletion support functions.
- Cairo support functions and classes.
- Mac OS X-specific stuff.
- GLUT compatibility.
- Forms compatibility and most forms classes.
- The Fl_Preferences class (Lua itself is good at handling configuration files).
- The following classes: Fl_File_Icon, Fl_File_Chooser, Fl_Device and descendants.
- The following functionalities of the Fl class: the Fl::readqueue( ) callback mechanism, Fl::set/get_labeltype(), system handlers (Fl::add_system_handler( )), Fl::default_at_close( ), Fl::warning/error/fatal( ).
- Fl_Tooltip::enter_area( ).
- A few other things here and there (that is, this list is not exhaustive).
- Preface
- API Introduction
- Classes
- Widgets
- widget
- box
- button
- light_button
- check_button
- radio_light_button
- round_button
- radio_round_button
- radio_button
- repeat_button
- return_button
- toggle_button
- chart
- clock_output
- clock
- round_clock
- group
- browser_
- browser
- file_browser
- hold_browser
- multi_browser
- select_browser
- check_browser
- color_chooser
- help_view
- input_choice
- pack
- scroll
- spinner
- table
- table_row
- tabs
- text_display
- text_editor
- tile
- tree
- window
- double_window
- app
- overlay_window
- gl_window
- single_window
- menu_window
- wizard
- input_
- input
- file_input
- float_input
- int_input
- multiline_input
- output
- multiline_output
- secret_input
- menu_item
- menu_
- choice
- menu_bar
- menu_button
- progress
- valuator
- adjuster
- counter
- simple_counter
- dial
- fill_dial
- line_dial
- roller
- slider
- fill_slider
- hor_fill_slider
- hor_nice_slider
- hor_slider
- nice_slider
- scrollbar
- value_slider
- hor_value_slider
- value_input
- value_output
- image
- help_dialog
- native_file_chooser
- text_buffer
- Subclassing
- Widgets
- Functions
- Enumerations, bitfields, etc.
- alignment
- beep
- boxtype
- clipboardtype
- color
- colorchoosermode
- cursorstyle
- cursortype
- damagebits
- event
- filesort
- filetype
- font
- key
- labeltype
- lineposition
- linestyle
- menuitemflags
- mode
- modifiers
- mousebutton
- nativefilechooseroption
- option
- rgbscaling
- rtti
- scrollbarmode
- shortcut
- tablecontext
- treeconnector
- treereason
- treeselect
- treesort
- whenfd
- whenflags
- wrapmode
- Unreferencing objects
- Implementation notes