├── CVSROOT ├── checkoutlist ├── commitinfo ├── config ├── cvswrappers ├── loginfo ├── modules ├── notify ├── rcsinfo ├── taginfo └── verifymsg └── tekui ├── COPYRIGHT ├── Makefile ├── README ├── TODO ├── bin ├── alignment.lua ├── bashing.lua ├── buttonclass.lua ├── demo.lua ├── demos │ ├── anims.lua │ ├── layout.lua │ ├── notifications.lua │ └── slider.lua ├── dynamic.lua ├── filereq.lua ├── floattext.lua ├── gendoc.lua ├── helloworld.lua ├── multilist.lua ├── plasma.lua ├── popups.lua ├── tek │ └── ui │ │ └── class │ │ ├── boing.lua │ │ ├── plasma.lua │ │ └── tunnel.lua └── vgroup.lua ├── config ├── doc ├── copyright.html ├── index.html ├── manual.css ├── manual.html └── todo.html ├── include └── tek │ ├── config.h │ ├── config │ └── posix.h │ ├── debug.h │ ├── exec.h │ ├── inline │ ├── exec.h │ └── time.h │ ├── lib │ └── init.h │ ├── mod │ ├── exec.h │ ├── hal.h │ ├── io.h │ ├── ioext.h │ ├── posix │ │ └── hal.h │ ├── time.h │ └── visual.h │ ├── proto │ ├── display.h │ ├── exec.h │ ├── hal.h │ ├── io.h │ ├── time.h │ └── visual.h │ ├── stdcall │ ├── display.h │ ├── exec.h │ ├── hal.h │ ├── io.h │ ├── time.h │ └── visual.h │ ├── teklib.h │ └── type.h ├── src ├── Makefile ├── display_dfb │ ├── Makefile │ ├── display_dfb_api.c │ ├── display_dfb_font.c │ ├── display_dfb_mod.c │ ├── display_dfb_mod.h │ └── display_dfb_utf8.c ├── display_x11 │ ├── Makefile │ ├── display_x11_api.c │ ├── display_x11_font.c │ ├── display_x11_inst.c │ ├── display_x11_mod.c │ ├── display_x11_mod.h │ └── display_x11_utf8.c ├── exec │ ├── Makefile │ ├── exec_api.c │ ├── exec_doexec.c │ ├── exec_memory.c │ ├── exec_mod.c │ └── exec_mod.h ├── hal │ ├── Makefile │ ├── hal_mod.c │ ├── hal_mod.h │ └── posix │ │ └── hal.c ├── teklib │ ├── Makefile │ ├── debug.c │ ├── init.c │ ├── posix │ │ └── host.c │ └── teklib.c ├── time │ ├── Makefile │ └── time_mod.c └── visual │ ├── Makefile │ ├── visual_api.c │ ├── visual_hash.c │ ├── visual_mod.c │ └── visual_mod.h └── tek ├── Makefile ├── class.lua ├── class ├── example.c ├── list.lua ├── markup.lua ├── object.lua └── utf8string.lua ├── lib ├── Makefile ├── args.lua ├── debug.lua ├── display │ ├── dfb_lua.c │ └── x11_lua.c ├── exec_lua.c ├── region.c ├── visual_api.c ├── visual_lua.c └── visual_lua.h ├── ui.lua └── ui ├── Makefile ├── border ├── blank.lua ├── button.lua ├── cursor.lua ├── group.lua ├── recess.lua ├── socket.lua └── tab.lua ├── class ├── application.lua ├── area.lua ├── border.lua ├── canvas.lua ├── checkmark.lua ├── dirlist.lua ├── display.lua ├── drawable.lua ├── element.lua ├── family.lua ├── floattext.lua ├── frame.lua ├── gadget.lua ├── gauge.lua ├── group.lua ├── handle.lua ├── image.lua ├── listgadget.lua ├── listview.lua ├── menuitem.lua ├── numeric.lua ├── pagegroup.lua ├── popitem.lua ├── poplist.lua ├── popupwindow.lua ├── radiobutton.lua ├── scrollbar.lua ├── scrollgroup.lua ├── slider.lua ├── spacer.lua ├── text.lua ├── textinput.lua ├── theme.lua ├── vectorimage.lua └── window.lua ├── cursor └── cursor-green.png ├── font ├── COPYRIGHT.TXT ├── Vera.ttf └── VeraMono.ttf └── layout └── default.c /CVSROOT/checkoutlist: -------------------------------------------------------------------------------- 1 | # The "checkoutlist" file is used to support additional version controlled 2 | # administrative files in $CVSROOT/CVSROOT, such as template files. 3 | # 4 | # The first entry on a line is a filename which will be checked out from 5 | # the corresponding RCS file in the $CVSROOT/CVSROOT directory. 6 | # The remainder of the line is an error message to use if the file cannot 7 | # be checked out. 8 | # 9 | # File format: 10 | # 11 | # [][] 12 | # 13 | # comment lines begin with '#' 14 | -------------------------------------------------------------------------------- /CVSROOT/commitinfo: -------------------------------------------------------------------------------- 1 | # The "commitinfo" file is used to control pre-commit checks. 2 | # The filter on the right is invoked with the repository and a list 3 | # of files to check. A non-zero exit of the filter program will 4 | # cause the commit to be aborted. 5 | # 6 | # The first entry on a line is a regular expression which is tested 7 | # against the directory that the change is being committed to, relative 8 | # to the $CVSROOT. For the first match that is found, then the remainder 9 | # of the line is the name of the filter to run. 10 | # 11 | # Format strings present in the filter will be replaced as follows: 12 | # %p = path relative to repository 13 | # %r = repository (path portion of $CVSROOT) 14 | # %{s} = file name, file name, ... 15 | # 16 | # If no format strings are present in the filter string, a default of 17 | # " %r %s" will be appended to the filter string, but this usage is 18 | # deprecated. 19 | # 20 | # If the repository name does not match any of the regular expressions in this 21 | # file, the "DEFAULT" line is used, if it is specified. 22 | # 23 | # If the name "ALL" appears as a regular expression it is always used 24 | # in addition to the first matching regex or "DEFAULT". 25 | -------------------------------------------------------------------------------- /CVSROOT/config: -------------------------------------------------------------------------------- 1 | # Set this to "no" if pserver shouldn't check system users/passwords 2 | #SystemAuth=no 3 | 4 | # Put CVS lock files in this directory rather than directly in the repository. 5 | #LockDir=/var/lock/cvs 6 | 7 | # Set `TopLevelAdmin' to `yes' to create a CVS directory at the top 8 | # level of the new working directory when using the `cvs checkout' 9 | # command. 10 | #TopLevelAdmin=no 11 | 12 | # Set `LogHistory' to `all' or `TOEFWUPCGMAR' to log all transactions to the 13 | # history file, or a subset as needed (ie `TMAR' logs all write operations) 14 | #LogHistory=TOEFWUPCGMAR 15 | 16 | # Set `RereadLogAfterVerify' to `always' (the default) to allow the verifymsg 17 | # script to change the log message. Set it to `stat' to force CVS to verify 18 | # that the file has changed before reading it (this can take up to an extra 19 | # second per directory being committed, so it is not recommended for large 20 | # repositories. Set it to `never' (the previous CVS behavior) to prevent 21 | # verifymsg scripts from changing the log message. 22 | #RereadLogAfterVerify=always 23 | 24 | # Set `UserAdminOptions' to the list of `cvs admin' commands (options) 25 | # that users not in the `cvsadmin' group are allowed to run. This 26 | # defaults to `k', or only allowing the changing of the default 27 | # keyword expansion mode for files for users not in the `cvsadmin' group. 28 | # This value is ignored if the `cvsadmin' group does not exist. 29 | # 30 | # The following string would enable all `cvs admin' commands for all 31 | # users: 32 | #UserAdminOptions=aAbceIklLmnNostuU 33 | 34 | # Set `UseNewInfoFmtStrings' to `no' if you must support a legacy system by 35 | # enabling the deprecated old style info file command line format strings. 36 | # Be warned that these strings could be disabled in any new version of CVS. 37 | UseNewInfoFmtStrings=yes 38 | -------------------------------------------------------------------------------- /CVSROOT/cvswrappers: -------------------------------------------------------------------------------- 1 | # This file affects handling of files based on their names. 2 | # 3 | # The -m option specifies whether CVS attempts to merge files. 4 | # 5 | # The -k option specifies keyword expansion (e.g. -kb for binary). 6 | # 7 | # Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers) 8 | # 9 | # wildcard [option value][option value]... 10 | # 11 | # where option is one of 12 | # -f from cvs filter value: path to filter 13 | # -t to cvs filter value: path to filter 14 | # -m update methodology value: MERGE or COPY 15 | # -k expansion mode value: b, o, kkv, &c 16 | # 17 | # and value is a single-quote delimited value. 18 | # For example: 19 | #*.gif -k 'b' 20 | -------------------------------------------------------------------------------- /CVSROOT/loginfo: -------------------------------------------------------------------------------- 1 | # The "loginfo" file controls where "cvs commit" log information 2 | # is sent. The first entry on a line is a regular expression which must match 3 | # the directory that the change is being made to, relative to the 4 | # $CVSROOT. If a match is found, then the remainder of the line is a filter 5 | # program that should expect log information on its standard input. 6 | # 7 | # If the repository name does not match any of the regular expressions in this 8 | # file, the "DEFAULT" line is used, if it is specified. 9 | # 10 | # If the name ALL appears as a regular expression it is always used 11 | # in addition to the first matching regex or DEFAULT. 12 | # 13 | # If any format strings are present in the filter, they will be replaced as follows: 14 | # %p = path relative to repository 15 | # %r = repository (path portion of $CVSROOT) 16 | # %{sVv} = attribute list = file name, old version number (pre-checkin), 17 | # new version number (post-checkin). When either old or new revision is 18 | # unknown, doesn't exist, or isn't applicable, the string "NONE" will be 19 | # placed on the command line instead. 20 | # 21 | # Note that %{sVv} is a list operator and not all elements are necessary. Thus %{sv} is 22 | # a legal format string, but will only be replaced with file name and new revision. 23 | # it also generates multiple arguments for each file being operated upon. i.e. if two 24 | # files, file1 & file2, are being commited from 1.1 to version 1.1.2.1 and from 1.1.2.2 25 | # to 1.1.2.3, respectively, %{sVv} will generate the following six arguments in this 26 | # order: file1, 1.1, 1.1.2.1, file2, 1.1.2.2, 1.1.2.3. 27 | # 28 | # For example: 29 | #DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog 30 | # or 31 | #DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog 32 | -------------------------------------------------------------------------------- /CVSROOT/modules: -------------------------------------------------------------------------------- 1 | # Three different line formats are valid: 2 | # key -a aliases... 3 | # key [options] directory 4 | # key [options] directory files... 5 | # 6 | # Where "options" are composed of: 7 | # -i prog Run "prog" on "cvs commit" from top-level of module. 8 | # -o prog Run "prog" on "cvs checkout" of module. 9 | # -e prog Run "prog" on "cvs export" of module. 10 | # -t prog Run "prog" on "cvs rtag" of module. 11 | # -u prog Run "prog" on "cvs update" of module. 12 | # -d dir Place module in directory "dir" instead of module name. 13 | # -l Top-level directory only -- do not recurse. 14 | # 15 | # NOTE: If you change any of the "Run" options above, you'll have to 16 | # release and re-checkout any working directories of these modules. 17 | # 18 | # And "directory" is a path to a directory relative to $CVSROOT. 19 | # 20 | # The "-a" option specifies an alias. An alias is interpreted as if 21 | # everything on the right of the "-a" had been typed on the command line. 22 | # 23 | # You can encode a module within a module by using the special '&' 24 | # character to interpose another module into the current module. This 25 | # can be useful for creating a module that consists of many directories 26 | # spread out over the entire source repository. 27 | -------------------------------------------------------------------------------- /CVSROOT/notify: -------------------------------------------------------------------------------- 1 | # The "notify" file controls where notifications from watches set by 2 | # "cvs watch add" or "cvs edit" are sent. The first entry on a line is 3 | # a regular expression which is tested against the directory that the 4 | # change is being made to, relative to the $CVSROOT. If it matches, 5 | # then the remainder of the line is a filter program that should contain 6 | # one occurrence of %s for the user to notify, and information on its 7 | # standard input. 8 | # 9 | # "ALL" or "DEFAULT" can be used in place of the regular expression. 10 | # 11 | # format strings are replaceed as follows: 12 | # %p = path relative to repository 13 | # %r = repository (path portion of $CVSROOT) 14 | # %s = user to notify 15 | # 16 | # For example: 17 | #ALL (echo Committed to %r/%p; cat) |mail %s -s "CVS notification" 18 | -------------------------------------------------------------------------------- /CVSROOT/rcsinfo: -------------------------------------------------------------------------------- 1 | # The "rcsinfo" file is used to control templates with which the editor 2 | # is invoked on commit and import. 3 | # 4 | # The first entry on a line is a regular expression which is tested 5 | # against the directory that the change is being made to, relative to the 6 | # $CVSROOT. For the first match that is found, then the remainder of the 7 | # line is the name of the file that contains the template. 8 | # 9 | # If the repository name does not match any of the regular expressions in this 10 | # file, the "DEFAULT" line is used, if it is specified. 11 | # 12 | # If the name "ALL" appears as a regular expression it is always used 13 | # in addition to the first matching regex or "DEFAULT". 14 | -------------------------------------------------------------------------------- /CVSROOT/taginfo: -------------------------------------------------------------------------------- 1 | # The "taginfo" file is used to control pre-tag checks. 2 | # The filter on the right is invoked with the following arguments if no format strings are present: 3 | # 4 | # $1 -- tagname 5 | # $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d 6 | # $3 -- tagtype "?" on delete, "T" for branch, "N" for static 7 | # $4 -- repository 8 | # $5-> file revision [file revision ...] 9 | # 10 | # If any format strings are present in the filter, they will be replaced as follows: 11 | # %b = branch mode = "?" (delete ops - unknown) | "T" (branch) | "N" (not branch) 12 | # %o = operation = "add" | "mov" | "del" 13 | # %p = path relative to repository 14 | # %r = repository (path portion of $CVSROOT) 15 | # %t = tagname 16 | # %{sVv} = attribute list = file name, old version tag will be deleted from, 17 | # new version tag will be added to (or deleted from, but this feature is 18 | # deprecated. When either old or new revision is unknown, doesn't exist, 19 | # or isn't applicable, the string "NONE" will be placed on the command 20 | # line. 21 | # 22 | # Note that %{sVv} is a list operator and not all elements are necessary. Thus %{sV} is 23 | # a legal format string, but will only be replaced with file name and old revision. 24 | # it also generates multiple arguments for each file being operated upon. i.e. if two 25 | # files, file1 & file2, are having a tag moved from version 1.1 to versoin 1.1.2.9, %{sVv} 26 | # will generate the following six arguments in this order: file1, 1.1, 1.1.2.9, file2, 1.1, 27 | # 1.1.2.9. 28 | # 29 | # A non-zero exit of the filter program will cause the tag to be aborted. 30 | # 31 | # The first entry on a line is a regular expression which is tested 32 | # against the directory that the change is being committed to, relative 33 | # to the $CVSROOT. For the first match that is found, then the remainder 34 | # of the line is the name of the filter to run. 35 | # 36 | # If the repository name does not match any of the regular expressions in this 37 | # file, the "DEFAULT" line is used, if it is specified. 38 | # 39 | # If the name "ALL" appears as a regular expression it is always used 40 | # in addition to the first matching regex or "DEFAULT". 41 | -------------------------------------------------------------------------------- /CVSROOT/verifymsg: -------------------------------------------------------------------------------- 1 | # The "verifymsg" file is used to allow verification of logging 2 | # information. It works best when a template (as specified in the 3 | # rcsinfo file) is provided for the logging procedure. Given a 4 | # template with locations for, a bug-id number, a list of people who 5 | # reviewed the code before it can be checked in, and an external 6 | # process to catalog the differences that were code reviewed, the 7 | # following test can be applied to the code: 8 | # 9 | # Making sure that the entered bug-id number is correct. 10 | # Validating that the code that was reviewed is indeed the code being 11 | # checked in (using the bug-id number or a seperate review 12 | # number to identify this particular code set.). 13 | # 14 | # If any of the above test failed, then the commit would be aborted. 15 | # 16 | # Format strings present in the filter will be replaced as follows: 17 | # %p = path relative to repository 18 | # %r = repository (path portion of $CVSROOT) 19 | # %l = name of log file to be verified. 20 | # 21 | # If no format strings are present in the filter, a default " %l" will 22 | # be appended to the filter, but this usage is deprecated. 23 | # 24 | # Actions such as mailing a copy of the report to each reviewer are 25 | # better handled by an entry in the loginfo file. 26 | # 27 | # One thing that should be noted is the the ALL keyword is not 28 | # supported. There can be only one entry that matches a given 29 | # repository. 30 | -------------------------------------------------------------------------------- /tekui/COPYRIGHT: -------------------------------------------------------------------------------- 1 | 2 | = License = 3 | 4 | tekUI is licensed under the terms of the MIT license reproduced 5 | below. It is free software: It can be used for both academic and 6 | commercial purposes at absolutely no cost, it qualifies as Open 7 | Source software and its license is compatible with GPL. 8 | 9 | --------------------------------------------------------------------- 10 | 11 | Copyright © 2008 by the authors: 12 | 13 | * Timm S. Müller 14 | * Franciska Schulze 15 | 16 | Permission is hereby granted, free of charge, to any person obtaining 17 | a copy of this software and associated documentation files (the 18 | "Software"), to deal in the Software without restriction, including 19 | without limitation the rights to use, copy, modify, merge, publish, 20 | distribute, sublicense, and/or sell copies of the Software, and to 21 | permit persons to whom the Software is furnished to do so, subject to 22 | the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be 25 | included in all copies or substantial portions of the Software. 26 | 27 | === Disclaimer === 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 30 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 31 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 32 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 33 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 34 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 35 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 36 | -------------------------------------------------------------------------------- /tekui/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include config 3 | 4 | .PHONY: all libs modules install clean help distclean docs release 5 | 6 | all: libs modules 7 | 8 | libs: 9 | cd src && $(MAKE) $@ 10 | 11 | modules: libs 12 | cd tek/lib && $(MAKE) $@ 13 | cd tek/ui && $(MAKE) $@ 14 | 15 | install: 16 | cd tek && $(MAKE) $@ 17 | cd tek/lib && $(MAKE) $@ 18 | cd tek/ui && $(MAKE) $@ 19 | 20 | clean: 21 | cd src && $(MAKE) $@ 22 | cd tek/lib && $(MAKE) $@ 23 | cd tek/ui && $(MAKE) $@ 24 | 25 | help: default-help 26 | @echo "Extra build targets for this Makefile:" 27 | @echo "-------------------------------------------------------------------------------" 28 | @echo "docs .................... (re-)generate documentation" 29 | @echo "distclean ............... remove all temporary files and directories" 30 | @echo "===============================================================================" 31 | 32 | distclean: clean 33 | -$(RMDIR) lib 34 | -find src tek -type d -name build | xargs $(RMDIR) 35 | 36 | docs: 37 | bin/gendoc.lua README -i 32 -n tekUI > doc/index.html 38 | bin/gendoc.lua COPYRIGHT -i 32 -n tekUI Copyright > doc/copyright.html 39 | bin/gendoc.lua TODO -i 32 -n tekUI TODO > doc/todo.html 40 | bin/gendoc.lua tek/ -n tekUI Reference manual > doc/manual.html 41 | 42 | kdiff: 43 | -(a=$$(mktemp -du) && hg clone $$PWD $$a && kdiff3 $$a $$PWD; rm -rf $$a) 44 | -------------------------------------------------------------------------------- /tekui/TODO: -------------------------------------------------------------------------------- 1 | 2 | = TODO = 3 | 4 | The scope of the current (alpha) release was determined by the 5 | smallest reasonable range of features needed for writing simple 6 | everyday applications. Chances are that the following issues need to 7 | be worked on: 8 | 9 | --------------------------------------------------------------------- 10 | 11 | === General === 12 | 13 | * Full internationalisation and localisation 14 | * Bitmap graphics 15 | * Individual style attributes 16 | * Clipboard support 17 | * Context menus 18 | * Bubble help 19 | * FloatText styling options 20 | * Confinement of popup elements to the visible screen 21 | * Eliminate occurences of float and double from the C library 22 | * The TextInput gadget is quite unsatisfactory 23 | 24 | === Known bugs === 25 | 26 | * potential memory leak in visual.drawimage 27 | * rare visual artifacts in lists 28 | * Antialiased fonts unsupported under X11 with Composite Extension 29 | * Doubleclick timeout is incorrectly handled when using an 30 | integer version of Lua 31 | -------------------------------------------------------------------------------- /tekui/bin/alignment.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local ui = require "tek.ui" 4 | 5 | ui.Application:new 6 | { 7 | Children = 8 | { 9 | ui.Window:new 10 | { 11 | Orientation = "vertical", 12 | Title = "Alignment Demo", 13 | Children = 14 | { 15 | ui.Group:new 16 | { 17 | Orientation = "vertical", 18 | Width = "free", 19 | Legend = "Align Horizontal", 20 | Children = 21 | { 22 | ui.Text:new { Text = "Begin", Width = "auto", Height = "free", HAlign = "left" }, 23 | ui.Text:new { Text = "Center", Width = "auto", Height = "free", HAlign = "center" }, 24 | ui.Group:new { Legend = "Group", Width = "auto", Height = "free", HAlign = "right", 25 | Children = 26 | { 27 | ui.Text:new { Text = "End", Width = "auto", Height = "free" } 28 | } 29 | }, 30 | }, 31 | }, 32 | ui.Group:new 33 | { 34 | Height = "free", 35 | Legend = "Align Vertical", 36 | Children = 37 | { 38 | ui.Text:new { Text = "Begin", Width = "free", VAlign = "top" }, 39 | ui.Text:new { Text = "Center", Width = "free", VAlign = "center" }, 40 | ui.Group:new 41 | { 42 | Legend = "Group", Width = "free", VAlign = "bottom", 43 | Children = 44 | { 45 | ui.Text:new { Text = "End", Width = "free" } 46 | } 47 | } 48 | }, 49 | }, 50 | }, 51 | }, 52 | }, 53 | }:run() 54 | -------------------------------------------------------------------------------- /tekui/bin/bashing.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local ui = require "tek.ui" 4 | 5 | ui.Application:new 6 | { 7 | Children = 8 | { 9 | ui.Window:new 10 | { 11 | GridWidth = 2, 12 | Children = 13 | { 14 | ui.Tunnel:new { MaxWidth = 400, MaxHeight = 200, VAlign = "bottom" }, 15 | ui.Tunnel:new { MaxWidth = 200, MaxHeight = 400 }, 16 | ui.Tunnel:new { MaxWidth = 200, MaxHeight = 400, HAlign = "right" }, 17 | ui.Tunnel:new { MaxWidth = 400, MaxHeight = 200 }, 18 | }, 19 | }, 20 | }, 21 | }:run() 22 | -------------------------------------------------------------------------------- /tekui/bin/buttonclass.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | ui = require "tek.ui" 4 | 5 | 6 | Button = ui.Text:newClass { _NAME = "_button" } 7 | 8 | function Button.init(self) 9 | self.Style = "button" 10 | self.Mode = self.Mode or "button" 11 | return ui.Text.init(self) 12 | end 13 | 14 | 15 | app = ui.Application:new() 16 | 17 | win = ui.Window:new { Title = "Hello" } 18 | 19 | button = Button:new { Text = "_Hello, World!" } 20 | 21 | button:addNotify("Pressed", false, { 22 | ui.NOTIFY_SELF, 23 | ui.NOTIFY_FUNCTION, 24 | function(self) 25 | print "Hello, World!" 26 | end 27 | }) 28 | 29 | app:addMember(win) 30 | 31 | win:addMember(button) 32 | 33 | app:run() 34 | -------------------------------------------------------------------------------- /tekui/bin/demos/anims.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local ui = require "tek.ui" 4 | 5 | local window = ui.Window:new 6 | { 7 | Orientation = "vertical", 8 | Width = 400, 9 | Height = 400, 10 | Id = "anims-window", 11 | Title = "Animations", 12 | Status = "hide", 13 | Notifications = 14 | { 15 | ["Status"] = 16 | { 17 | ["show"] = 18 | { 19 | { ui.NOTIFY_ID, "anims-window-button", "setValue", "Selected", true } 20 | }, 21 | ["hide"] = 22 | { 23 | { ui.NOTIFY_ID, "anims-window-button", "setValue", "Selected", false } 24 | }, 25 | }, 26 | }, 27 | Children = 28 | { 29 | ui.PageGroup:new 30 | { 31 | PageCaptions = { "_Tunnel", "_Boing", "_Plasma" }, 32 | Children = 33 | { 34 | ui.Group:new 35 | { 36 | Orientation = "vertical", 37 | Children = 38 | { 39 | ui.Tunnel:new { Id = "the-tunnel", HAlign = "center" }, 40 | ui.Group:new 41 | { 42 | Width = "fill", 43 | Height = "auto", 44 | Legend = "Parameters", 45 | GridWidth = 2, 46 | Children = 47 | { 48 | ui.text:new { Text = "Speed", Style = "caption", Width = "fill" }, 49 | ui.Slider:new { 50 | Width = "free", 51 | Min = 1, 52 | Max = 19, 53 | Value = 13, 54 | Range = 20, 55 | Step = 1, 56 | Notifications = { 57 | ["Value"] = { 58 | [ui.NOTIFY_CHANGE] = { 59 | { ui.NOTIFY_ID, "the-tunnel", "setSpeed", ui.NOTIFY_VALUE }, 60 | }, 61 | } 62 | }, 63 | }, 64 | ui.text:new { Text = "Focus", Style = "caption", Width = "fill" }, 65 | ui.Slider:new { 66 | Width = "free", 67 | Min = 0x10, 68 | Max = 0x1ff, 69 | Value = 0x50, 70 | Range = 0x200, 71 | Step = 20, 72 | Notifications = { 73 | ["Value"] = { 74 | [ui.NOTIFY_CHANGE] = { 75 | { ui.NOTIFY_ID, "the-tunnel", "setViewZ", ui.NOTIFY_VALUE }, 76 | }, 77 | } 78 | }, 79 | }, 80 | ui.text:new { Text = "Segments", Style = "caption", Width = "fill" }, 81 | ui.Slider:new { 82 | Width = "free", 83 | Min = 1, 84 | Max = 19, 85 | Value = 6, 86 | Range = 20, 87 | Step = 1, 88 | Notifications = { 89 | ["Value"] = { 90 | [ui.NOTIFY_CHANGE] = { 91 | { ui.NOTIFY_ID, "the-tunnel", "setNumSeg", ui.NOTIFY_VALUE }, 92 | }, 93 | } 94 | }, 95 | }, 96 | }, 97 | }, 98 | } 99 | }, 100 | ui.Group:new 101 | { 102 | Orientation = "vertical", 103 | Children = 104 | { 105 | ui.Boing:new { Id = "the-boing" }, 106 | ui.Group:new 107 | { 108 | Height = "auto", 109 | Children = 110 | { 111 | ui.text:new 112 | { 113 | Mode = "button", 114 | Style = "button", 115 | Text = "_Start", 116 | Notifications = 117 | { 118 | ["Pressed"] = 119 | { 120 | [false] = 121 | { 122 | { 123 | ui.NOTIFY_ID, "the-boing", "setValue", "Running", true 124 | } 125 | } 126 | } 127 | } 128 | }, 129 | ui.text:new 130 | { 131 | Mode = "button", 132 | Style = "button", 133 | Text = "Sto_p", 134 | Notifications = 135 | { 136 | ["Pressed"] = 137 | { 138 | [false] = 139 | { 140 | { 141 | ui.NOTIFY_ID, "the-boing", "setValue", "Running", false 142 | } 143 | } 144 | } 145 | } 146 | }, 147 | }, 148 | }, 149 | } 150 | }, 151 | ui.Plasma:new { }, 152 | }, 153 | } 154 | } 155 | } 156 | 157 | if ui.ProgName == "anims.lua" then 158 | local app = ui.Application:new() 159 | ui.Application.connect(window) 160 | app:addMember(window) 161 | window:setValue("Status", "show") 162 | app:run() 163 | else 164 | return 165 | { 166 | Window = window, 167 | Name = "Animations", 168 | Description = [[ 169 | This demo shows three different animated classes. 170 | 171 | The 'Boing' class registers its interval handler as soon as the window is opened, so when you switch away and back to its page, you will notice that the spot's position was udpated even while its page was invisible. 172 | 173 | The animation classes are not part of tekUI's system-wide installation; instead, they are loaded from the directory in which the application resides. 174 | 175 | ]] 176 | } 177 | end 178 | -------------------------------------------------------------------------------- /tekui/bin/demos/layout.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local ui = require "tek.ui" 4 | local db = require "tek.lib.debug" 5 | 6 | local window = ui.Window:new 7 | { 8 | Orientation = "vertical", 9 | Id = "layout-window", 10 | Title = "Layout", 11 | Status = "hide", 12 | MaxWidth = ui.HUGE, 13 | MaxHeight = ui.HUGE, 14 | Notifications = 15 | { 16 | ["Status"] = 17 | { 18 | ["show"] = 19 | { 20 | { ui.NOTIFY_ID, "layout-window-button", "setValue", "Selected", true } 21 | }, 22 | ["hide"] = 23 | { 24 | { ui.NOTIFY_ID, "layout-window-button", "setValue", "Selected", false } 25 | }, 26 | }, 27 | }, 28 | Children = 29 | { 30 | ui.Group:new 31 | { 32 | Legend = "Relative Sizes", 33 | Children = 34 | { 35 | ui.Text:new { Text = "1", MaxWidth = ui.HUGE }, 36 | ui.Spacer:new { }, 37 | ui.Text:new { Text = "12", MaxWidth = ui.HUGE }, 38 | ui.Spacer:new { }, 39 | ui.Text:new { Text = "123", MaxWidth = ui.HUGE }, 40 | ui.Spacer:new { }, 41 | ui.Text:new { Text = "1234", MaxWidth = ui.HUGE }, 42 | ui.Spacer:new { }, 43 | ui.Text:new { Text = "12345", MaxWidth = ui.HUGE }, 44 | }, 45 | }, 46 | ui.Group:new 47 | { 48 | SameSize = true, 49 | Legend = "Same Sizes", 50 | Children = 51 | { 52 | ui.Text:new { Text = "1", MaxWidth = ui.HUGE }, 53 | ui.Spacer:new { }, 54 | ui.Text:new { Text = "12", MaxWidth = ui.HUGE }, 55 | ui.Spacer:new { }, 56 | ui.Text:new { Text = "123", MaxWidth = ui.HUGE }, 57 | ui.Spacer:new { }, 58 | ui.Text:new { Text = "1234", MaxWidth = ui.HUGE }, 59 | ui.Spacer:new { }, 60 | ui.Text:new { Text = "12345", MaxWidth = ui.HUGE }, 61 | }, 62 | }, 63 | ui.Group:new 64 | { 65 | Legend = "Balancing Group", 66 | Children = 67 | { 68 | ui.Text:new { Id="1", Text = "free", Height = "fill" }, 69 | ui.Handle:new { Id="2" }, 70 | ui.Text:new { Id="3", Text = "free", Height = "fill" }, 71 | ui.Handle:new { Id="4" }, 72 | ui.Text:new { Id="5", Text = "free", Height = "fill" }, 73 | }, 74 | }, 75 | ui.Handle:new { }, 76 | ui.Group:new 77 | { 78 | Height = "free", 79 | Legend = "Grid", 80 | GridWidth = 3, 81 | SameSize = true, 82 | Children = 83 | { 84 | ui.Text:new { Text = "1", Height = "free" }, 85 | ui.Text:new { Text = "12", Height = "free" }, 86 | ui.Text:new { Text = "123", Height = "free" }, 87 | ui.Text:new { Text = "1234", Height = "free" }, 88 | ui.Text:new { Text = "12345", Height = "free" }, 89 | ui.Text:new { Text = "123456", Height = "free" }, 90 | }, 91 | }, 92 | ui.Group:new 93 | { 94 | Legend = "Fixed vs. Free", 95 | Children = 96 | { 97 | ui.Text:new { Text = "fix" }, 98 | ui.Text:new { Text = "25%", MaxWidth = ui.HUGE, Weight = 0x4000 }, 99 | ui.Text:new { Text = "fix" }, 100 | ui.Text:new { Text = "75%", MaxWidth = ui.HUGE, Weight = 0xc000 }, 101 | ui.Text:new { Text = "fix" }, 102 | }, 103 | }, 104 | ui.Group:new 105 | { 106 | MaxHeight = ui.HUGE, 107 | Legend = "Different Weights", 108 | Children = 109 | { 110 | ui.Text:new { Text = "25%", MaxWidth = ui.HUGE, MaxHeight = ui.HUGE, Weight = 0x4000 }, 111 | ui.Spacer:new { }, 112 | ui.Text:new { Text = "25%", MaxWidth = ui.HUGE, MaxHeight = ui.HUGE, Weight = 0x4000 }, 113 | ui.Spacer:new { }, 114 | ui.Text:new { Text = "50%", MaxWidth = ui.HUGE, MaxHeight = ui.HUGE, Weight = 0x8000 }, 115 | }, 116 | }, 117 | }, 118 | } 119 | 120 | if ui.ProgName == "layout.lua" then 121 | local app = ui.Application:new() 122 | ui.Application.connect(window) 123 | app:addMember(window) 124 | window:setValue("Status", "show") 125 | app:run() 126 | else 127 | return 128 | { 129 | Window = window, 130 | Name = "Layout", 131 | Description = "This demonstrates the various layouting options.", 132 | } 133 | end 134 | -------------------------------------------------------------------------------- /tekui/bin/demos/notifications.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local ui = require "tek.ui" 4 | 5 | local window = ui.Window:new 6 | { 7 | Orientation = "vertical", 8 | Id = "notifications-window", 9 | Title = "Notifications", 10 | Status = "hide", 11 | Notifications = 12 | { 13 | ["Status"] = 14 | { 15 | ["show"] = 16 | { 17 | { ui.NOTIFY_ID, "notifications-window-button", "setValue", "Selected", true } 18 | }, 19 | ["hide"] = 20 | { 21 | { ui.NOTIFY_ID, "notifications-window-button", "setValue", "Selected", false } 22 | }, 23 | }, 24 | }, 25 | Children = 26 | { 27 | ui.Group:new 28 | { 29 | Width = "free", 30 | Height = "free", 31 | Legend = "Connections", 32 | Children = 33 | { 34 | ui.Slider:new { Id = "slider-1", Orientation = "vertical", 35 | Notifications = 36 | { 37 | ["Value"] = 38 | { 39 | [ui.NOTIFY_ALWAYS] = 40 | { 41 | { ui.NOTIFY_ID, "slider-2", "setValue", "Value", ui.NOTIFY_VALUE }, 42 | } 43 | } 44 | } 45 | }, 46 | ui.Slider:new { Id = "slider-2", Orientation = "vertical", 47 | Notifications = 48 | { 49 | ["Value"] = 50 | { 51 | [ui.NOTIFY_ALWAYS] = 52 | { 53 | { ui.NOTIFY_ID, "slider-3", "setValue", "Value", ui.NOTIFY_VALUE }, 54 | } 55 | } 56 | } 57 | }, 58 | ui.Group:new 59 | { 60 | Orientation = "vertical", 61 | Height = "auto", 62 | VAlign = "center", 63 | Children = 64 | { 65 | ui.Slider:new { Id = "slider-7", 66 | Notifications = 67 | { 68 | ["Value"] = 69 | { 70 | [ui.NOTIFY_ALWAYS] = 71 | { 72 | { ui.NOTIFY_ID, "slider-1", "setValue", "Value", ui.NOTIFY_VALUE }, 73 | { ui.NOTIFY_ID, "slider-6", "setValue", "Value", ui.NOTIFY_VALUE }, 74 | } 75 | } 76 | } 77 | }, 78 | ui.Group:new 79 | { 80 | Width = "free", 81 | Children = 82 | { 83 | ui.Gauge:new { Id = "slider-3", Width = "free" }, 84 | ui.Gauge:new { Id = "slider-4", Width = "free" }, 85 | }, 86 | }, 87 | }, 88 | }, 89 | ui.Slider:new { Id = "slider-5", Orientation = "vertical", 90 | Notifications = 91 | { 92 | ["Value"] = 93 | { 94 | [ui.NOTIFY_ALWAYS] = 95 | { 96 | { ui.NOTIFY_ID, "slider-4", "setValue", "Value", ui.NOTIFY_VALUE }, 97 | } 98 | } 99 | } 100 | }, 101 | ui.Slider:new { Id = "slider-6", Orientation = "vertical", 102 | Notifications = 103 | { 104 | ["Value"] = 105 | { 106 | [ui.NOTIFY_ALWAYS] = 107 | { 108 | { ui.NOTIFY_ID, "slider-5", "setValue", "Value", ui.NOTIFY_VALUE }, 109 | } 110 | } 111 | } 112 | }, 113 | }, 114 | }, 115 | }, 116 | } 117 | 118 | if ui.ProgName == "notifications.lua" then 119 | local app = ui.Application:new() 120 | ui.Application.connect(window) 121 | app:addMember(window) 122 | window:setValue("Status", "show") 123 | app:run() 124 | else 125 | return 126 | { 127 | Window = window, 128 | Name = "Notifications", 129 | Description = [[ 130 | Elements can be interconnected with each other using notifications. 131 | ]] 132 | } 133 | end 134 | -------------------------------------------------------------------------------- /tekui/bin/demos/slider.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local ui = require "tek.ui" 4 | local db = require "tek.lib.debug" 5 | local window = ui.Window:new 6 | { 7 | Id = "slider-window", 8 | Title = "Slider", 9 | Status = "hide", 10 | MaxWidth = ui.HUGE, 11 | MaxHeight = ui.HUGE, 12 | Orientation = "vertical", 13 | Notifications = 14 | { 15 | ["Status"] = 16 | { 17 | ["show"] = 18 | { 19 | { ui.NOTIFY_ID, "slider-window-button", "setValue", "Selected", true } 20 | }, 21 | ["hide"] = 22 | { 23 | { ui.NOTIFY_ID, "slider-window-button", "setValue", "Selected", false } 24 | }, 25 | }, 26 | }, 27 | Children = 28 | { 29 | ui.Group:new 30 | { 31 | Legend = "Sliders", 32 | GridWidth = 3, 33 | Children = 34 | { 35 | ui.Text:new 36 | { 37 | Text = "Continuous", 38 | Width = "fill", 39 | }, 40 | ui.ScrollBar:new 41 | { 42 | Id = "slider-slider-1", 43 | Width = "free", 44 | Min = 0, 45 | Max = 10, 46 | Style = "number", 47 | Notifications = 48 | { 49 | ["Value"] = 50 | { 51 | [ui.NOTIFY_CHANGE] = 52 | { 53 | { ui.NOTIFY_ID, "slider-text-1", "setValue", "Text", ui.NOTIFY_FORMAT, "%2.2f" }, 54 | { ui.NOTIFY_ID, "slider-slider-2", "setValue", "Value", ui.NOTIFY_VALUE }, 55 | { ui.NOTIFY_ID, "slider-gauge-1", "setValue", "Value", ui.NOTIFY_VALUE } 56 | } 57 | } 58 | } 59 | }, 60 | ui.Text:new 61 | { 62 | Id = "slider-text-1", 63 | Width = "fill", 64 | Text = " 0.00 ", 65 | KeepMinWidth = true, 66 | }, 67 | 68 | ui.Text:new 69 | { 70 | Text = "Integer Step", 71 | Width = "fill", 72 | }, 73 | ui.ScrollBar:new 74 | { 75 | Id = "slider-slider-2", 76 | Width = "free", 77 | Min = 0, 78 | Max = 10, 79 | ForceInteger = true, 80 | Style = "number", 81 | Notifications = 82 | { 83 | ["Value"] = 84 | { 85 | [ui.NOTIFY_CHANGE] = 86 | { 87 | { ui.NOTIFY_ID, "slider-text-2", "setValue", "Text", ui.NOTIFY_FORMAT, "%d" }, 88 | { ui.NOTIFY_ID, "slider-slider-1", "setValue", "Value", ui.NOTIFY_VALUE }, 89 | { ui.NOTIFY_ID, "slider-gauge-1", "setValue", "Value", ui.NOTIFY_VALUE } 90 | } 91 | } 92 | } 93 | }, 94 | ui.Text:new 95 | { 96 | Id = "slider-text-2", 97 | Width = "fill", 98 | Text = " 0 ", 99 | KeepMinWidth = true, 100 | }, 101 | 102 | ui.Text:new 103 | { 104 | Text = "Range", 105 | Width = "fill", 106 | }, 107 | ui.ScrollBar:new 108 | { 109 | Id = "slider-slider-3", 110 | Width = "free", 111 | Min = 10, 112 | Max = 20, 113 | ForceInteger = true, 114 | Style = "number", 115 | Notifications = 116 | { 117 | ["Value"] = 118 | { 119 | [ui.NOTIFY_CHANGE] = 120 | { 121 | { ui.NOTIFY_ID, "slider-text-3", "setValue", "Text", ui.NOTIFY_FORMAT, "%d" }, 122 | { ui.NOTIFY_ID, "slider-slider-1", "setValue", "Range", ui.NOTIFY_VALUE }, 123 | { ui.NOTIFY_ID, "slider-slider-2", "setValue", "Range", ui.NOTIFY_VALUE }, 124 | } 125 | } 126 | } 127 | }, 128 | ui.Text:new 129 | { 130 | Id = "slider-text-3", 131 | Width = "fill", 132 | Text = " 0 ", 133 | KeepMinWidth = true, 134 | }, 135 | 136 | } 137 | }, 138 | ui.Group:new 139 | { 140 | Legend = "Gauges", 141 | Children = 142 | { 143 | ui.Gauge:new 144 | { 145 | Min = 0, 146 | Max = 10, 147 | Id = "slider-gauge-1", 148 | Width = "free", 149 | }, 150 | } 151 | }, 152 | } 153 | } 154 | 155 | if ui.ProgName == "slider.lua" then 156 | local app = ui.Application:new() 157 | ui.Application.connect(window) 158 | app:addMember(window) 159 | window:setValue("Status", "show") 160 | app:run() 161 | else 162 | return 163 | { 164 | Window = window, 165 | Name = "Slider", 166 | Description = "Slider", 167 | } 168 | end 169 | -------------------------------------------------------------------------------- /tekui/bin/dynamic.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | require "tek.lib.debug".level = 4 4 | local ui = require "tek.ui" 5 | -- ui.DEBUG = true 6 | 7 | ui.application:new 8 | { 9 | Children = 10 | { 11 | ui.window:new 12 | { 13 | Title = "Dynamic Weight 1", 14 | Children = 15 | { 16 | ui.group:new 17 | { 18 | Legend = "Dynamic Weight", 19 | Children = 20 | { 21 | ui.group:new 22 | { 23 | Title = "Hallo", 24 | Width = "free", 25 | Children = 26 | { 27 | ui.Slider:new 28 | { 29 | Min = 0, 30 | Max = 100000, 31 | Notifications = 32 | { 33 | ["Value"] = 34 | { 35 | [ui.NOTIFY_CHANGE] = { 36 | { ui.NOTIFY_ID, "weight-1", "setValue", "Text", ui.NOTIFY_FORMAT, "%d" }, 37 | }, 38 | }, 39 | }, 40 | }, 41 | ui.Text:new 42 | { 43 | FontSpec = "utopia:100", 44 | Id = "weight-1", 45 | Text = "0", 46 | Width = "auto" 47 | }, 48 | }, 49 | }, 50 | }, 51 | }, 52 | }, 53 | }, 54 | ui.window:new 55 | { 56 | Title = "Dynamic Weight 2", 57 | Legend = "Dynamic Weight", 58 | Orientation = "vertical", 59 | Children = 60 | { 61 | ui.group:new 62 | { 63 | Children = 64 | { 65 | ui.Slider:new 66 | { 67 | Knob = ui.Text:new 68 | { 69 | Id = "slider-knob", 70 | Style = "button", 71 | Text = "$08000", 72 | }, 73 | Id = "slider-2", 74 | Min = 0, 75 | Max = 0x10000, 76 | Width = "free", 77 | Default = 0x8000, 78 | Step = 0x400, 79 | Notifications = 80 | { 81 | ["Value"] = 82 | { 83 | [ui.NOTIFY_CHANGE] = 84 | { 85 | { ui.NOTIFY_ID, "slider-weight-1", "setValue", "Text", ui.NOTIFY_FORMAT, "$%05x" }, 86 | { ui.NOTIFY_ID, "slider-weight-1", "setValue", "Weight", ui.NOTIFY_VALUE }, 87 | { ui.NOTIFY_ID, "slider-knob", "setValue", "Text", ui.NOTIFY_FORMAT, "$%05x" }, 88 | }, 89 | }, 90 | }, 91 | }, 92 | ui.text:new 93 | { 94 | Mode = "button", 95 | Style = "button", 96 | Text = "Reset", 97 | Width = "auto", 98 | Notifications = 99 | { 100 | ["Pressed"] = 101 | { 102 | [false] = 103 | { 104 | { 105 | ui.NOTIFY_SELF, ui.NOTIFY_FUNCTION, function(self) 106 | local e = self.Application:getElementById("slider-weight-1") 107 | self.Application:getElementById("slider-2"):reset() 108 | e:setValue("Weight", false) 109 | end 110 | } 111 | } 112 | } 113 | } 114 | }, 115 | }, 116 | }, 117 | ui.group:new 118 | { 119 | Children = 120 | { 121 | ui.text:new { Id="slider-weight-1", Text = " $08000 ", FontSpec="utopia:60", KeepMinWidth = true }, 122 | ui.frame:new { Height = "fill" }, 123 | }, 124 | }, 125 | }, 126 | }, 127 | ui.window:new 128 | { 129 | Title = "Border Thickness", 130 | Legend = "Border Thickness", 131 | Children = 132 | { 133 | ui.text:new 134 | { 135 | Mode = "button", 136 | Style = "button", 137 | Width = "auto", 138 | Id = "border-button", 139 | Text = "Watch borders", 140 | }, 141 | ui.Slider:new 142 | { 143 | Width = "free", 144 | Min = 0, 145 | Max = 20, 146 | ForceInteger = true, 147 | Notifications = 148 | { 149 | ["Value"] = 150 | { 151 | [ui.NOTIFY_CHANGE] = 152 | { 153 | { 154 | ui.NOTIFY_SELF, ui.NOTIFY_FUNCTION, function(self, val) 155 | local e = self.Application:getElementById("border-button") 156 | e.Border = { val, val, val, val } 157 | e:rethinkLayout(true) 158 | self.Border = { val, val, val, val } 159 | self:rethinkLayout(true) 160 | end, ui.NOTIFY_VALUE 161 | } 162 | } 163 | } 164 | }, 165 | }, 166 | }, 167 | }, 168 | }, 169 | }:run() 170 | 171 | -------------------------------------------------------------------------------- /tekui/bin/filereq.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local ui = require "tek.ui" 4 | 5 | app = ui.Application:new 6 | { 7 | Children = 8 | { 9 | ui.Window:new 10 | { 11 | Title = "File Request", 12 | Orientation = "vertical", 13 | Children = 14 | { 15 | ui.Group:new 16 | { 17 | GridWidth = 2, 18 | SameHeight = true, 19 | Children = 20 | { 21 | ui.Text:new 22 | { 23 | Text = "_Path:", 24 | Width = "auto", 25 | Style = "caption", 26 | HAlign = "right", 27 | }, 28 | ui.TextInput:new 29 | { 30 | Id = "pathfield", 31 | Text = "/home", 32 | KeyCode = "p", 33 | }, 34 | ui.Text:new 35 | { 36 | Text = "Selected:", 37 | Width = "auto", 38 | Style = "caption", 39 | HAlign = "right", 40 | }, 41 | ui.TextInput:new 42 | { 43 | Id = "filefield", 44 | }, 45 | ui.Text:new 46 | { 47 | Text = "Status:", 48 | Width = "auto", 49 | Style = "caption", 50 | HAlign = "right", 51 | }, 52 | ui.Text:new 53 | { 54 | Id = "statusfield", 55 | TextHAlign = "left", 56 | }, 57 | ui.Text:new 58 | { 59 | Text = "_Multiselect:", 60 | Width = "auto", 61 | Style = "caption", 62 | HAlign = "right", 63 | }, 64 | ui.CheckMark:new 65 | { 66 | Id = "multiselect", 67 | KeyCode = "m", 68 | }, 69 | } 70 | }, 71 | ui.Text:new 72 | { 73 | Text = "_Choose File...", 74 | Style = "button", 75 | Mode = "button", 76 | Width = "auto", 77 | HAlign = "right", 78 | Notifications = 79 | { 80 | ["Pressed"] = 81 | { 82 | [false] = 83 | { 84 | { ui.NOTIFY_APPLICATION, ui.NOTIFY_COROUTINE, function(self) 85 | local pathfield = self:getElementById("pathfield") 86 | local filefield = self:getElementById("filefield") 87 | local statusfield = self:getElementById("statusfield") 88 | local status, path, select = self:requestFile 89 | { 90 | Path = pathfield.Text, 91 | SelectMode = self:getElementById("multiselect").Selected and "multi" or "single" 92 | } 93 | statusfield:setValue("Text", status) 94 | if status == "selected" then 95 | pathfield:setValue("Text", path) 96 | self:getElementById("filefield"):setValue("Text", table.concat(select, ", ")) 97 | end 98 | end } 99 | } 100 | } 101 | } 102 | } 103 | } 104 | } 105 | } 106 | }:run() 107 | -------------------------------------------------------------------------------- /tekui/bin/floattext.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local ui = require "tek.ui" 4 | 5 | ui.Application:new 6 | { 7 | Title = "FloatText Demo", 8 | Children = 9 | { 10 | ui.Window:new 11 | { 12 | Orientation = "vertical", 13 | Children = 14 | { 15 | ui.Text:new 16 | { 17 | Text = "Poems", 18 | FontSpec = "__huge", 19 | }, 20 | ui.Group:new 21 | { 22 | Children = 23 | { 24 | ui.Canvas:new 25 | { 26 | CanvasWidth = 500, 27 | CanvasHeight = 500, 28 | Child = ui.FloatText:new 29 | { 30 | BGPen = ui.PEN_SHINE, 31 | FGPen = ui.PEN_SHADOW, 32 | Text = [[ 33 | 34 | Ecce homo 35 | Friedrich Nietzsche (1844-1900) 36 | 37 | Ja! Ich weiß, woher ich stamme! 38 | Ungesättigt gleich der Flamme 39 | Glühe und verzehr' ich mich. 40 | Licht wird alles, was ich fasse, 41 | Kohle alles, was ich lasse: 42 | Flamme bin ich sicherlich 43 | ]] 44 | } 45 | }, 46 | ui.Handle:new { }, 47 | ui.ScrollGroup:new 48 | { 49 | HSliderMode = "off", 50 | VSliderMode = "on", 51 | Canvas = ui.Canvas:new 52 | { 53 | AutoWidth = true, 54 | Child = ui.FloatText:new 55 | { 56 | BGPen = ui.PEN_SHINE, 57 | FGPen = ui.PEN_SHADOW, 58 | Text = [[ 59 | 60 | Under der linden 61 | Walther von der Vogelweide (1170-1230) 62 | 63 | Under der linden 64 | an der heide, 65 | dâ unser zweier bette was, 66 | dâ mugent ir vinden 67 | schône beide 68 | gebrochen bluomen unde gras. 69 | vor dem walde in einem tal, 70 | tandaradei, 71 | schône sanc diu nahtegal. 72 | 73 | Ich kam gegangen 74 | zuo der ouwe: 75 | dô was mîn friedel komen ê. 76 | dâ wart ich enpfangen 77 | hêre frouwe, 78 | daz ich bin sælic iemer mê. 79 | kuster mich? wol tûsentstunt: 80 | tandaradei, 81 | seht wie rôt mir ist der munt. 82 | 83 | Dô hete er gemachet 84 | alsô rîche 85 | von bluomen eine bettestat. 86 | des wirt noch gelachet 87 | inneclîche, 88 | kumt iemen an daz selbe pfat. 89 | bî den rôsen er wol mac, 90 | tandaradei, 91 | merken wâ mirz houbet lac. 92 | 93 | Daz er bî mir læge, 94 | wesse ez iemen 95 | (nu enwelle got!), sô schamte ich mich. 96 | wes er mit mir pflæge, 97 | niemer niemen 98 | bevinde daz, wan er unt ich, 99 | und ein kleinez vogellîn: 100 | tandaradei, 101 | daz mac wol getriuwe sîn. 102 | ]] 103 | } 104 | } 105 | } 106 | } 107 | }, 108 | ui.Text:new 109 | { 110 | Text = "_Okay", 111 | Mode = "button", 112 | Style = "button", 113 | Notifications = 114 | { 115 | ["Pressed"] = 116 | { 117 | [false] = 118 | { 119 | { 120 | ui.NOTIFY_APPLICATION, "setValue", "Status", "quit" 121 | } 122 | } 123 | } 124 | } 125 | } 126 | } 127 | } 128 | } 129 | }:run() 130 | -------------------------------------------------------------------------------- /tekui/bin/helloworld.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | ui = require "tek.ui" 4 | 5 | ui.Application:new 6 | { 7 | Children = 8 | { 9 | ui.Window:new 10 | { 11 | Title = "Hello", 12 | Children = 13 | { 14 | ui.Text:new 15 | { 16 | Text = "_Hello, World!", 17 | Style = "button", 18 | Mode = "button", 19 | Notifications = 20 | { 21 | ["Pressed"] = 22 | { 23 | [false] = 24 | { 25 | { ui.NOTIFY_SELF, ui.NOTIFY_FUNCTION, 26 | function(self) 27 | print "Hello, World!" 28 | end 29 | }, 30 | }, 31 | }, 32 | }, 33 | }, 34 | }, 35 | }, 36 | }, 37 | }:run() 38 | -------------------------------------------------------------------------------- /tekui/bin/plasma.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local visual = require "tek.lib.visual" 4 | 5 | local COS = math.cos 6 | local SIN = math.sin 7 | local PI = math.pi 8 | local MIN = math.min 9 | local MAX = math.max 10 | local FLOOR = math.floor 11 | 12 | local WIDTH = 80 13 | local HEIGHT = 60 14 | local PIXWIDTH = 6 15 | local PIXHEIGHT = 6 16 | 17 | local WW = WIDTH * PIXWIDTH 18 | local WH = HEIGHT * PIXHEIGHT 19 | 20 | -- 21 | -- open window 22 | -- 23 | 24 | local v = visual.open { Title = "Plasma", Width = WW, Height = WH, 25 | MinWidth = WW, MinHeight = WH, MaxWidth = WW, MaxHeight = WH } 26 | 27 | v:setinput("close", "keydown", "interval") 28 | 29 | -- 30 | -- init 31 | -- 32 | 33 | local screen = { } 34 | local palette = { } 35 | local palindex = 0 36 | 37 | function addgradient(sr, sg, sb, dr, dg, db, num) 38 | dr = (dr - sr) / (num - 1) 39 | dg = (dg - sg) / (num - 1) 40 | db = (db - sb) / (num - 1) 41 | for i = 0, num - 1 do 42 | palette[palindex] = FLOOR(sr) * 65536 + FLOOR(sg) * 256 + FLOOR(sb) 43 | palindex = palindex + 1 44 | sr = sr + dr 45 | sg = sg + dg 46 | sb = sb + db 47 | end 48 | end 49 | 50 | addgradient(209,219,155, 79,33,57, 68) 51 | addgradient(79,33,57, 209,130,255, 60) 52 | 53 | local sintab = { } 54 | for i = 0, 1023 do 55 | sintab[i] = SIN(i / 1024 * PI * 2) 56 | end 57 | 58 | -- 59 | -- effect 60 | -- 61 | 62 | local xp1, xp2 = 0, 0 63 | local yp1, yp2, yp3 = 0, 0, 0 64 | 65 | function effect() 66 | 67 | local palettescale = #palette / 10 68 | local yc1, yc2, yc3 = yp1, yp2, yp3 69 | local i = 0 70 | 71 | for y = 0, HEIGHT - 1 do 72 | 73 | local xc1, xc2 = xp1, xp2 74 | local ysin = sintab[yc1] + sintab[yc2] + sintab[yc3] + 5 75 | 76 | for x = 0, WIDTH - 1 do 77 | 78 | local c = sintab[xc1] + sintab[xc2] + ysin 79 | screen[i] = palette[FLOOR(c * palettescale)] 80 | i = i + 1 81 | xc1 = (xc1 - 12) % 1024 82 | xc2 = (xc2 + 13) % 1024 83 | 84 | end 85 | 86 | yc1 = (yc1 + 8) % 1024 87 | yc2 = (yc2 + 11) % 1024 88 | yc3 = (yc3 - 18) % 1024 89 | 90 | end 91 | 92 | yp1 = (yp1 - 9) % 1024 93 | yp2 = (yp2 + 4) % 1024 94 | yp3 = (yp3 + 5) % 1024 95 | 96 | xp1 = (xp1 + 7) % 1024 97 | xp2 = (xp2 - 2) % 1024 98 | 99 | end 100 | 101 | -- 102 | -- main loop 103 | -- 104 | 105 | local abort, paint 106 | repeat 107 | v:wait() 108 | repeat 109 | local msg = v:getmsg() 110 | if msg then 111 | local typ, code, mx, my = msg[2], msg[3], msg[4], msg[5] 112 | if typ == 1 -- closewindow 113 | or (typ == 256 and code == 27) then -- escape key 114 | abort = true 115 | elseif typ == 2048 then -- interval 116 | paint = true 117 | end 118 | end 119 | until not msg 120 | if paint then 121 | effect() 122 | v:drawrgb(0, 0, screen, WIDTH, HEIGHT, PIXWIDTH, PIXHEIGHT) 123 | paint = false 124 | end 125 | until abort 126 | 127 | -------------------------------------------------------------------------------- /tekui/bin/tek/ui/class/boing.lua: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | -- tek.ui.class.boing 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | 8 | local ui = require "tek.ui" 9 | local Frame = ui.Frame 10 | 11 | local floor = math.floor 12 | local max = math.max 13 | local min = math.min 14 | local pi = math.pi 15 | local sin = math.sin 16 | 17 | module("tek.ui.class.boing", tek.ui.class.frame) 18 | _VERSION = "Boing 1.3" 19 | 20 | ------------------------------------------------------------------------------- 21 | -- Class implementation: 22 | ------------------------------------------------------------------------------- 23 | 24 | local Boing = _M 25 | 26 | function Boing.init(self) 27 | self = self or { } 28 | self.Boing = { 0x8000, 0x8000 } 29 | self.Boing[3] = 0x334 30 | self.Boing[4] = 0x472 31 | self.IntervalNotify = { self, "updateInterval" } 32 | self.Running = self.Running or false 33 | return Frame.init(self) 34 | end 35 | 36 | function Boing:setup(app, window) 37 | Frame.setup(self, app, window) 38 | self.Window:addNotify("Interval", ui.NOTIFY_ALWAYS, self.IntervalNotify) 39 | end 40 | 41 | function Boing:cleanup() 42 | self.Window:remNotify("Interval", ui.NOTIFY_ALWAYS, self.IntervalNotify) 43 | Frame.cleanup(self) 44 | end 45 | 46 | function Boing:draw() 47 | local d = self.Drawable 48 | local r = self.Rect 49 | local w = r[3] - r[1] + 1 50 | local h = r[4] - r[2] + 1 51 | local x0, y0, x1, y1 52 | local w2 = w - w / 20 53 | local h2 = h - h / 20 54 | x0 = (self.Boing[1] * w2) / 0x10000 + self.Rect[1] 55 | y0 = (self.Boing[2] * h2) / 0x10000 + self.Rect[2] 56 | d:fillRect(r[1], r[2], r[3], r[4], d.Pens[ui.PEN_SHINE]) 57 | d:fillRect(x0, y0, x0 + w/20 - 1, y0 + h/20 - 1, 58 | d.Pens[ui.PEN_SHADOW]) 59 | end 60 | 61 | function Boing:updateInterval() 62 | if self.Running then 63 | local b = self.Boing 64 | b[1] = b[1] + b[3] 65 | b[2] = b[2] + b[4] 66 | if b[1] <= 0 or b[1] >= 0x10000 then 67 | b[3] = -b[3] 68 | b[1] = b[1] + b[3] 69 | end 70 | if b[2] <= 0 or b[2] >= 0x10000 then 71 | b[4] = -b[4] 72 | b[2] = b[2] + b[4] 73 | end 74 | self.Redraw = true 75 | return true -- i want to be redrawn 76 | end 77 | end 78 | -------------------------------------------------------------------------------- /tekui/bin/tek/ui/class/plasma.lua: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | -- tek.ui.class.plasma 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | 8 | local ui = require "tek.ui" 9 | local db = require "tek.lib.debug" 10 | local Frame = ui.Area 11 | 12 | local cos = math.cos 13 | local floor = math.floor 14 | local max = math.max 15 | local min = math.min 16 | local pi = math.pi 17 | local sin = math.sin 18 | local unpack = unpack 19 | 20 | module("tek.ui.class.plasma", tek.ui.class.area) 21 | _VERSION = "Plasma 1.0" 22 | 23 | local WIDTH = 80 24 | local HEIGHT = 60 25 | local PIXWIDTH = 6 26 | local PIXHEIGHT = 6 27 | 28 | ------------------------------------------------------------------------------- 29 | -- Class implementation: 30 | ------------------------------------------------------------------------------- 31 | 32 | local Plasma = _M 33 | 34 | function Plasma:addgradient(sr, sg, sb, dr, dg, db, num) 35 | dr = (dr - sr) / (num - 1) 36 | dg = (dg - sg) / (num - 1) 37 | db = (db - sb) / (num - 1) 38 | local pal = self.Palette 39 | local pali = self.PalIndex 40 | for i = 0, num - 1 do 41 | pal[pali] = floor(sr) * 65536 + floor(sg) * 256 + floor(sb) 42 | pali = pali + 1 43 | sr = sr + dr 44 | sg = sg + dg 45 | sb = sb + db 46 | end 47 | self.PalIndex = pali 48 | end 49 | 50 | function Plasma.new(class, self) 51 | self = self or { } 52 | self.Screen = { } 53 | self.Palette = { } 54 | self.PalIndex = 0 55 | self.SinTab = { } 56 | self.Params = { 0, 0, 0, 0, 0 } -- xp1, xp2, yp1, yp2, yp3 57 | return Frame.new(class, self) 58 | end 59 | 60 | function Plasma.init(self) 61 | addgradient(self, 209,219,155, 79,33,57, 68) 62 | addgradient(self, 79,33,57, 209,130,255, 60) 63 | local sintab = self.SinTab 64 | for i = 0, 1023 do 65 | sintab[i] = sin(i / 1024 * pi * 2) 66 | end 67 | self.MinWidth = WIDTH * PIXWIDTH 68 | self.MinHeight = HEIGHT * PIXHEIGHT 69 | self.MaxWidth = WIDTH * PIXWIDTH 70 | self.MaxHeight = HEIGHT * PIXHEIGHT 71 | self.IntervalNotify = { self, "update" } 72 | return Frame.init(self) 73 | end 74 | 75 | function Plasma:show(display, drawable) 76 | if Frame.show(self, display, drawable) then 77 | self.Window:addNotify("Interval", ui.NOTIFY_ALWAYS, 78 | self.IntervalNotify) 79 | return true 80 | end 81 | end 82 | 83 | function Plasma:hide() 84 | Frame.hide(self) 85 | self.Window:remNotify("Interval", ui.NOTIFY_ALWAYS, self.IntervalNotify) 86 | end 87 | 88 | function Plasma:draw() 89 | 90 | local sintab = self.SinTab 91 | local palette = self.Palette 92 | local screen = self.Screen 93 | local pscale = #self.Palette / 10 94 | local p = self.Params 95 | local xp1, xp2, yp1, yp2, yp3 = unpack(p) 96 | local yc1, yc2, yc3 = yp1, yp2, yp3 97 | local c 98 | 99 | for y = 0, HEIGHT - 1 do 100 | local xc1, xc2 = xp1, xp2 101 | local ysin = sintab[yc1] + sintab[yc2] + sintab[yc3] + 5 102 | for x = y * WIDTH, (y + 1) * WIDTH - 1 do 103 | c = sintab[xc1] + sintab[xc2] + ysin 104 | screen[x] = palette[floor(c * pscale)] 105 | xc1 = (xc1 - 12) % 1024 106 | xc2 = (xc2 + 13) % 1024 107 | end 108 | yc1 = (yc1 + 8) % 1024 109 | yc2 = (yc2 + 11) % 1024 110 | yc3 = (yc3 - 18) % 1024 111 | end 112 | 113 | local d = self.Drawable 114 | local r = self.Rect 115 | d:drawRGB(r[1], r[2], screen, WIDTH, HEIGHT, 6, 6) 116 | 117 | end 118 | 119 | function Plasma:update() 120 | local p = self.Params 121 | local xp1, xp2, yp1, yp2, yp3 = unpack(p) 122 | yp1 = (yp1 - 9) % 1024 123 | yp2 = (yp2 + 4) % 1024 124 | yp3 = (yp3 + 5) % 1024 125 | xp1 = (xp1 + 7) % 1024 126 | xp2 = (xp2 - 2) % 1024 127 | p[1], p[2], p[3], p[4], p[5] = xp1, xp2, yp1, yp2, yp3 128 | self.Redraw = true 129 | end 130 | -------------------------------------------------------------------------------- /tekui/bin/tek/ui/class/tunnel.lua: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | -- tek.ui.class.tunnel 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | 8 | local ui = require "tek.ui" 9 | local db = require "tek.lib.debug" 10 | local Frame = ui.Frame 11 | 12 | local floor = math.floor 13 | local max = math.max 14 | local min = math.min 15 | local pi = math.pi 16 | local sin = math.sin 17 | 18 | module("tek.ui.class.tunnel", tek.ui.class.frame) 19 | _VERSION = "Tunnel 1.8" 20 | 21 | ------------------------------------------------------------------------------- 22 | -- Class implementation: 23 | ------------------------------------------------------------------------------- 24 | 25 | local Tunnel = _M 26 | 27 | function Tunnel:show(display, drawable) 28 | if Frame.show(self, display, drawable) then 29 | self.Window:addNotify("Interval", ui.NOTIFY_ALWAYS, 30 | self.IntervalNotify) 31 | return true 32 | end 33 | end 34 | 35 | function Tunnel:hide() 36 | Frame.hide(self) 37 | self.Window:remNotify("Interval", ui.NOTIFY_ALWAYS, self.IntervalNotify) 38 | end 39 | 40 | ------------------------------------------------------------------------------- 41 | 42 | function Tunnel:setNumSeg(val) 43 | self.numseg = val 44 | end 45 | function Tunnel:setSpeed(val) 46 | self.speed = val 47 | end 48 | function Tunnel:setViewZ(val) 49 | self.viewz = val 50 | end 51 | 52 | ------------------------------------------------------------------------------- 53 | 54 | function Tunnel.init(self) 55 | 56 | self.MinWidth = self.MinWidth or 128 57 | self.MinHeight = self.MinHeight or 128 58 | self.MaxWidth = self.MaxWidth or 640 59 | self.MaxHeight = self.MaxHeight or 480 60 | 61 | self.IntervalNotify = { self, "updateInterval" } 62 | 63 | -- movement table: 64 | self.dx = { } 65 | self.ndx = 32 66 | for i = 1, self.ndx do 67 | self.dx[i] = sin(i * pi * 2 / 32) * 5 68 | end 69 | 70 | -- current offs in movement table: 71 | self.cx = 1 72 | self.cy = 8 73 | 74 | self.numseg = 6 75 | self.speed = 13 76 | self.z = 0 77 | self.viewz = 0x50 78 | self.dist = 0x100 79 | self.size = { 320, 256 } 80 | 81 | return Frame.init(self) 82 | end 83 | 84 | function Tunnel:draw() 85 | local d = self.Drawable 86 | local p0, p1 = d.Pens[ui.PEN_SHADOW], d.Pens[ui.PEN_SHINE] 87 | local r = self.Rect 88 | 89 | d:fillRect(r[1], r[2], r[3], r[4], p0) 90 | 91 | local sx = floor((r[1] + r[3]) / 2) 92 | local sy = floor((r[2] + r[4]) / 2) 93 | 94 | local z = self.z + self.viewz 95 | local cx = self.cx 96 | local cy = self.cy 97 | 98 | for i = 1, self.numseg do 99 | 100 | local x = self.size[1] * self.viewz / z 101 | local y = self.size[2] * self.viewz / z 102 | 103 | local dx = self.dx[cx] * z / 256 104 | local dy = self.dx[cy] * z / 256 105 | 106 | local x0 = min(max(sx - x + dx, r[1]), r[3]) 107 | local y0 = min(max(sy - y + dy, r[2]), r[4]) 108 | local x1 = min(max(sx + x + dx, r[1]), r[3]) 109 | local y1 = min(max(sy + y + dy, r[2]), r[4]) 110 | if x0 ~= r[1] or x1 ~= r[3] or y0 ~= r[2] or y1 ~= r[4] then 111 | d:drawRect(x0, y0, x1, y1, p1) 112 | end 113 | z = z + self.dist 114 | cx = cx == self.ndx and 1 or cx + 1 115 | cy = cy == self.ndx and 1 or cy + 1 116 | end 117 | end 118 | 119 | function Tunnel:updateInterval() 120 | -- db.warn("update") 121 | self.z = self.z - self.speed 122 | if self.z < 0 then 123 | self.z = self.z + self.dist 124 | self.cx = self.cx == self.ndx and 1 or self.cx + 1 125 | self.cy = self.cy == self.ndx and 1 or self.cy + 1 126 | end 127 | self.Redraw = true 128 | end 129 | -------------------------------------------------------------------------------- /tekui/bin/vgroup.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local ui = require "tek.ui" 4 | 5 | ui.Application:new 6 | { 7 | Children = 8 | { 9 | ui.Window:new 10 | { 11 | Title = "Groups Demo", 12 | Children = 13 | { 14 | ui.ScrollGroup:new 15 | { 16 | Legend = "Virtual Group", 17 | Width = 500, 18 | Height = 500, 19 | HSliderMode = "on", 20 | VSliderMode = "on", 21 | Canvas = ui.Canvas:new 22 | { 23 | MaxWidth = 500, 24 | MaxHeight = 500, 25 | CanvasWidth = 500, 26 | CanvasHeight = 500, 27 | Child = ui.Group:new 28 | { 29 | GridWidth = 2, 30 | Children = 31 | { 32 | ui.text:new { Mode = "button", Style = "button", Width = "free", Height = "free", Text = "foo" }, 33 | ui.text:new { Mode = "button", Style = "button", Width = "free", Height = "free", Text = "foo" }, 34 | ui.text:new { Mode = "button", Style = "button", Width = "free", Height = "free", Text = "foo" }, 35 | ui.ScrollGroup:new 36 | { 37 | Legend = "Virtual Group", 38 | Width = 500, 39 | Height = 500, 40 | HSliderMode = "on", 41 | VSliderMode = "on", 42 | Canvas = ui.Canvas:new 43 | { 44 | CanvasWidth = 500, 45 | CanvasHeight = 500, 46 | Child = ui.Group:new 47 | { 48 | GridWidth = 2, 49 | Children = 50 | { 51 | ui.text:new { Mode = "button", Style = "button", Width = "free", Height = "free", Text = "foo" }, 52 | ui.text:new { Mode = "button", Style = "button", Width = "free", Height = "free", Text = "foo" }, 53 | ui.text:new { Mode = "button", Style = "button", Width = "free", Height = "free", Text = "foo" }, 54 | ui.ScrollGroup:new 55 | { 56 | Legend = "Virtual Group", 57 | Width = 500, 58 | Height = 500, 59 | HSliderMode = "on", 60 | VSliderMode = "on", 61 | Canvas = ui.Canvas:new 62 | { 63 | CanvasWidth = 500, 64 | CanvasHeight = 500, 65 | Child = ui.Group:new 66 | { 67 | GridWidth = 2, 68 | Children = 69 | { 70 | ui.text:new { Mode = "button", Style = "button", Width = "free", Height = "free", Text = "foo" }, 71 | ui.text:new { Mode = "button", Style = "button", Width = "free", Height = "free", Text = "foo" }, 72 | ui.text:new { Mode = "button", Style = "button", Width = "free", Height = "free", Text = "foo" }, 73 | ui.text:new { Mode = "button", Style = "button", Width = "free", Height = "free", Text = "foo" }, 74 | } 75 | } 76 | } 77 | } 78 | } 79 | } 80 | } 81 | } 82 | } 83 | } 84 | } 85 | } 86 | } 87 | } 88 | } 89 | }:run() 90 | -------------------------------------------------------------------------------- /tekui/config: -------------------------------------------------------------------------------- 1 | 2 | #------------------------------------------------------------------------------ 3 | # Platform to build against [Choices: posix] 4 | #------------------------------------------------------------------------------ 5 | 6 | PLATFORM ?= posix 7 | 8 | #------------------------------------------------------------------------------ 9 | # Default display driver [Choices: x11, dfb] 10 | # For the DirectFB driver, also adjust src/Makefile and tek/lib/Makefile 11 | #------------------------------------------------------------------------------ 12 | 13 | DISPLAY_DRIVER ?= x11 14 | 15 | #------------------------------------------------------------------------------ 16 | # Installation paths: 17 | #------------------------------------------------------------------------------ 18 | 19 | LUA_LIB = /usr/local/lib/lua/5.1 20 | LUA_SHARE = /usr/local/share/lua/5.1 21 | 22 | #------------------------------------------------------------------------------ 23 | # Libraries: 24 | #------------------------------------------------------------------------------ 25 | 26 | PLATFORM_LIBS = -pthread 27 | 28 | LUA_DEFS = -I/usr/local/include/lua51 -I/usr/include/lua5.1 29 | 30 | FREETYPE_DEFS = -I/usr/include/freetype2 -I/usr/X11R6/include/freetype2 31 | 32 | X11_LIBS = -L/usr/X11R6/lib -LX11 -lXext 33 | X11_DEFS = $(FREETYPE_DEFS) -D_XOPEN_SOURCE -I/usr/X11R6/include 34 | 35 | DFB_LIBS = `pkg-config --libs directfb` 36 | DFB_DEFS = $(FREETYPE_DEFS) `pkg-config --cflags directfb` 37 | 38 | #------------------------------------------------------------------------------ 39 | # Paths: 40 | #------------------------------------------------------------------------------ 41 | 42 | BASEDIR ?= . 43 | INCDIR = $(BASEDIR)/include 44 | LIBDIR = $(BASEDIR)/lib/$(PLATFORM) 45 | OBJDIR = build/$(PLATFORM) 46 | 47 | #------------------------------------------------------------------------------ 48 | # Compiler flags: 49 | #------------------------------------------------------------------------------ 50 | 51 | CC = gcc 52 | #DEBUG = -g -DTDEBUG=10 53 | WARN = -Wall -Wno-unused-parameter 54 | OPT = -O2 55 | INCL = -I. -Iinclude -I$(INCDIR) 56 | LIBCFLAGS = $(DEBUG) $(WARN) $(OPT) $(INCL) $(EXTRADEFS) -fpic 57 | MODCFLAGS = -shared -L $(LIBDIR) 58 | 59 | #------------------------------------------------------------------------------ 60 | # Build tools: 61 | #------------------------------------------------------------------------------ 62 | 63 | AR = ar r 64 | RM = rm 65 | RMDIR = rm -r 66 | MKDIR = mkdir -p 67 | ECHO = echo 68 | INSTALL = install 69 | 70 | #------------------------------------------------------------------------------ 71 | # Predefined targets: 72 | #------------------------------------------------------------------------------ 73 | 74 | default-help: 75 | @echo "===============================================================================" 76 | @echo "Default build targets:" 77 | @echo "-------------------------------------------------------------------------------" 78 | @echo "all ..................... build everything that is needed" 79 | @echo "libs .................... build libraries" 80 | @echo "modules ................. build shared objects" 81 | @echo "install ................. install modules globally" 82 | @echo "clean ................... delete temporary files" 83 | @echo "help .................... show these and all extra targets for this Makefile" 84 | @echo "===============================================================================" 85 | 86 | FORCE: 87 | 88 | $(BINDIR): 89 | -$(MKDIR) $@ 90 | $(MODDIR): 91 | -$(MKDIR) $@ 92 | $(LIBDIR): 93 | -$(MKDIR) $@ 94 | $(OBJDIR): 95 | -$(MKDIR) $@ 96 | -------------------------------------------------------------------------------- /tekui/doc/copyright.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | tekUI Copyright 7 | 8 | 9 | 10 |

11 | License 12 |

13 |

14 | tekUI is licensed under the terms of the MIT license reproduced 15 | below. It is free software: It can be used for both academic and 16 | commercial purposes at absolutely no cost, it qualifies as Open 17 | Source software and its license is compatible with GPL. 18 |

19 |
20 |

21 | Copyright © 2008 by the authors: 22 |

23 |
24 |
    25 |
  • 26 | Timm S. Müller <tmueller at schulze-mueller.de> 27 |
  • 28 |
  • 29 | Franciska Schulze <fschulze at schulze-mueller.de> 30 |
  • 31 |
32 |
33 |

34 | Permission is hereby granted, free of charge, to any person obtaining 35 | a copy of this software and associated documentation files (the 36 | "Software"), to deal in the Software without restriction, including 37 | without limitation the rights to use, copy, modify, merge, publish, 38 | distribute, sublicense, and/or sell copies of the Software, and to 39 | permit persons to whom the Software is furnished to do so, subject to 40 | the following conditions: 41 |

42 |

43 | The above copyright notice and this permission notice shall be 44 | included in all copies or substantial portions of the Software. 45 |

46 |

47 | Disclaimer 48 |

49 |

50 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 51 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 52 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 53 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 54 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 55 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 56 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 57 |

58 | 59 | 60 | -------------------------------------------------------------------------------- /tekui/doc/manual.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #000; 3 | background-color: #fff; 4 | font-family: sans-serif; 5 | text-align: justify; 6 | margin-right: 20px; 7 | margin-left: 20px; 8 | } 9 | 10 | h1, h2, h3, h4 { 11 | font-weight: normal; 12 | font-style: italic; 13 | } 14 | 15 | a:link, a:visited { 16 | color: #008; 17 | background-color: inherit; 18 | text-decoration: none; 19 | } 20 | 21 | a:link:hover, a:visited:hover { 22 | color: #008; 23 | background-color: #ddf; 24 | } 25 | 26 | a:link:active, a:visited:active { 27 | color: #f00; 28 | } 29 | 30 | hr { 31 | border: 0; 32 | height: 1px; 33 | color: #aaa; 34 | background-color: #aaa; 35 | } 36 | 37 | h3 code { 38 | font-family: inherit; 39 | } 40 | 41 | p code { 42 | /* background-color: #f2f2f2; */ 43 | } 44 | 45 | pre { 46 | /* font-size: 105%; */ 47 | /* font-style: italic; */ 48 | background-color: #f2f2f2; 49 | border: 1px solid #ddd; 50 | padding: 0.3em; 51 | } 52 | 53 | blockquote > ul { 54 | padding-left: 0; 55 | } 56 | blockquote { 57 | margin-top: 0; 58 | margin-bottom: 0; 59 | } 60 | 61 | table { 62 | border-collapse: collapse; 63 | } 64 | td { 65 | padding: 0.25em; 66 | border: 1px solid #ccc; 67 | } 68 | -------------------------------------------------------------------------------- /tekui/doc/todo.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | tekUI TODO 7 | 8 | 9 | 10 |

11 | TODO 12 |

13 |

14 | The scope of the current (alpha) release was determined by the 15 | smallest reasonable range of features needed for writing simple 16 | everyday applications. Chances are that the following issues need to 17 | be worked on: 18 |

19 |
20 |

21 | General 22 |

23 |
24 |
    25 |
  • 26 | Full internationalisation and localisation 27 |
  • 28 |
  • 29 | Bitmap graphics 30 |
  • 31 |
  • 32 | Individual style attributes 33 |
  • 34 |
  • 35 | Clipboard support 36 |
  • 37 |
  • 38 | Context menus 39 |
  • 40 |
  • 41 | Bubble help 42 |
  • 43 |
  • 44 | FloatText styling options 45 |
  • 46 |
  • 47 | Confinement of popup elements to the visible screen 48 |
  • 49 |
  • 50 | Eliminate occurences of float and double from the C library 51 |
  • 52 |
  • 53 | The TextInput gadget is quite unsatisfactory 54 |
  • 55 |
56 |
57 |

58 | Known bugs 59 |

60 |
61 |
    62 |
  • 63 | potential memory leak in visual.drawimage 64 |
  • 65 |
  • 66 | rare visual artifacts in lists 67 |
  • 68 |
  • 69 | Antialiased fonts unsupported under X11 with Composite Extension 70 |
  • 71 |
  • 72 | Doubleclick timeout is incorrectly handled when using an 73 | integer version of Lua 74 |
  • 75 |
76 |
77 | 78 | 79 | -------------------------------------------------------------------------------- /tekui/include/tek/config.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_CONFIG_H 3 | #define _TEK_CONFIG_H 4 | 5 | /* 6 | ** $Id: config.h,v 1.1 2008-06-30 12:34:46 tmueller Exp $ 7 | ** teklib/tek/config.h - Platform and compiler specific 8 | ** See copyright notice in teklib/COPYRIGHT 9 | */ 10 | 11 | #if defined(TSYS_POSIX) || defined(__linux) || defined(__FreeBSD__) 12 | #ifndef TSYS_POSIX 13 | #define TSYS_POSIX 14 | #endif 15 | #include 16 | #elif defined(TSYS_WINNT) || defined(_WIN32) 17 | #ifndef TSYS_WINNT 18 | #define TSYS_WINNT 19 | #endif 20 | #include 21 | #elif defined(TSYS_PS2) 22 | #include 23 | #endif 24 | 25 | /*****************************************************************************/ 26 | /* 27 | ** Module interface 28 | ** 29 | ** - Depending on your kind of module build, you may possibly want to 30 | ** set TMODAPI to "static". Note that module functions are not exported 31 | ** symbolically in TEKlib. 32 | ** 33 | ** - Depending on your platform, you may have to override TMODENTRY with 34 | ** declarations like __declspec(dllexport). See config/ for examples. 35 | ** 36 | ** - Depending on your preferred calling conventions, define TMODCALL to 37 | ** declare __stdargs, __fastcall etc. Some platforms allow (or require) 38 | ** to distinguish register and stack-based calling. When porting TEKlib 39 | ** to a new platform, try to ascertain the calling conventions for the 40 | ** entire platform, not only for a single compiler. 41 | */ 42 | 43 | #ifndef TMODAPI 44 | #define TMODAPI 45 | #endif 46 | 47 | #ifndef TLIBAPI 48 | #define TLIBAPI 49 | #endif 50 | 51 | #ifndef TMODCALL 52 | #define TMODCALL 53 | #endif 54 | 55 | #ifndef TMODENTRY 56 | #define TMODENTRY 57 | #endif 58 | 59 | #ifndef TMODINTERN 60 | #define TMODINTERN 61 | #endif 62 | 63 | /*****************************************************************************/ 64 | /* 65 | ** Callback, hook and task entries 66 | ** 67 | ** In config/yourplatform.h, override these with your preferred 68 | ** platform-specific calling conventions. See also the annotations 69 | ** for the module interface above. Stack/register calling conventions 70 | ** may be an issue here. 71 | */ 72 | 73 | #ifndef TCALLBACK 74 | #define TCALLBACK 75 | #endif 76 | 77 | #ifndef THOOKENTRY 78 | #define THOOKENTRY 79 | #endif 80 | 81 | #ifndef TTASKENTRY 82 | #define TTASKENTRY 83 | #endif 84 | 85 | /*****************************************************************************/ 86 | /* 87 | ** Inline 88 | ** Override with platform-specific declarations if available 89 | */ 90 | 91 | #ifndef TINLINE 92 | #define TINLINE 93 | #endif 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /tekui/include/tek/config/posix.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_CONFIG_POSIX_H 3 | #define _TEK_CONFIG_POSIX_H 4 | 5 | /* 6 | ** $Id: posix.h,v 1.1 2008-06-30 12:34:58 tmueller Exp $ 7 | ** teklib/tek/config/posix.h - POSIX types 8 | ** 9 | ** Written by Timm S. Mueller 10 | ** See copyright notice in teklib/COPYRIGHT 11 | */ 12 | 13 | /*****************************************************************************/ 14 | /* 15 | ** Elementary types 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | typedef char TCHR; 23 | typedef void TVOID; 24 | typedef void * TAPTR; 25 | typedef int8_t TINT8; 26 | typedef uint8_t TUINT8; 27 | typedef int16_t TINT16; 28 | typedef uint16_t TUINT16; 29 | typedef int32_t TINT32; 30 | typedef uint32_t TUINT32; 31 | typedef int64_t TINT64; 32 | typedef uint64_t TUINT64; 33 | typedef float TFLOAT; 34 | typedef double TDOUBLE; 35 | typedef intptr_t TINTPTR; 36 | typedef uintptr_t TUINTPTR; 37 | 38 | #define TSYS_HAVE_INT64 39 | 40 | /*****************************************************************************/ 41 | /* 42 | ** Alignment of allocations 43 | */ 44 | 45 | struct TMemNodeAlign { TUINT8 tmna_Chunk[8]; }; 46 | struct TMMUInfoAlign { TUINT8 tmua_Chunk[8]; }; 47 | struct TMemHeadAlign { TUINT8 tmha_Chunk[48]; }; 48 | 49 | /*****************************************************************************/ 50 | /* 51 | ** HAL Object container 52 | */ 53 | 54 | struct THALObject { TUINTPTR tho_Chunk[4]; }; 55 | typedef struct THALObject THALO; 56 | 57 | /*****************************************************************************/ 58 | /* 59 | ** Date type container 60 | */ 61 | 62 | typedef union { 63 | TDOUBLE tdtt_Double; 64 | struct { TUINT32 hi, lo; } tdtt_HiLo; 65 | } TDATE_T; 66 | 67 | /*****************************************************************************/ 68 | /* 69 | ** Debug support 70 | */ 71 | 72 | #define TDEBUG_PLATFORM_PUTS(s) fputs(s, stderr) 73 | #define TDEBUG_PLATFORM_FATAL() (abort(), 0) 74 | 75 | /*****************************************************************************/ 76 | /* 77 | ** Default locations 78 | */ 79 | 80 | #if !defined(TEKHOST_SYSDIR) 81 | #define TEKHOST_SYSDIR "/usr/local/tek/" 82 | #endif /* !defined(TEKHOST_SYSDIR) */ 83 | 84 | #if !defined(TEKHOST_MODDIR) 85 | #define TEKHOST_MODDIR TEKHOST_SYSDIR "mod/" 86 | #endif /* !defined(TEKHOST_MODDIR) */ 87 | 88 | #if !defined(TEKHOST_PROGDIR) 89 | #define TEKHOST_PROGDIR TNULL 90 | #endif /* !defined(TEKHOST_PROGDIR) */ 91 | 92 | /*****************************************************************************/ 93 | /* 94 | ** Module name extension 95 | */ 96 | 97 | #define TEKHOST_EXTSTR ".so" 98 | #define TEKHOST_EXTLEN 3 99 | 100 | /*****************************************************************************/ 101 | /* 102 | ** Inline 103 | */ 104 | 105 | #define TINLINE __inline 106 | 107 | /*****************************************************************************/ 108 | /* 109 | ** Calling conventions and visibility 110 | */ 111 | 112 | #if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ 113 | defined(__ELF__) 114 | #define TMODENTRY __attribute__ ((visibility("default"))) 115 | #define TMODINTERN __attribute__ ((visibility("hidden"))) 116 | #endif 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /tekui/include/tek/debug.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_DEBUG_H 3 | #define _TEK_DEBUG_H 4 | 5 | /* 6 | ** tek/debug.h - Debug support 7 | ** Written by Timm S. Mueller 8 | ** See copyright notice in teklib/COPYRIGHT 9 | */ 10 | 11 | #include 12 | 13 | #if defined(TDEBUG) && TDEBUG > 0 14 | extern TLIBAPI TINT TDebugPutS(TSTRPTR s); 15 | extern TLIBAPI TINT TDebugPrintF(TSTRPTR fmt, ...); 16 | extern TLIBAPI TINT TDebugFatal(void); 17 | #define TDB(level, x) ((level) >= (TDEBUG) ? ((x), (void)0) : (void)0) 18 | #define TDBPUTS(level, s) TDB(level, TDebugPutS(s)) 19 | #define TDBFATAL() TDEBUG_PLATFORM_FATAL() 20 | #define TDBPRINTF(level, x) \ 21 | TDB(level, (TDebugPrintF("(%02d %s:%d) ", level, __FILE__, __LINE__), \ 22 | TDebugPrintF x)) 23 | #define TDBASSERT(level, expr) TDB(level, (expr) ? (void)0 : \ 24 | ((TDebugPrintF("(%02d %s:%d) ", level, __FILE__, __LINE__), \ 25 | TDebugPrintF(#expr " : assertion failed\n"), TDEBUG_PLATFORM_FATAL()), \ 26 | (void)0)) 27 | #else 28 | #define TDB(level, x) ((void)0) 29 | #define TDBPRINTF(level, x) ((void)0) 30 | #define TDBFATAL() ((void)0) 31 | #define TDBASSERT(level, expr) ((void)0) 32 | #endif 33 | 34 | #define TDB_DEBUG 1 35 | #define TDB_TRACE 2 36 | #define TDB_INFO 4 37 | #define TDB_WARN 5 38 | #define TDB_ERROR 10 39 | #define TDB_FAIL 20 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /tekui/include/tek/inline/time.h: -------------------------------------------------------------------------------- 1 | #ifndef _TEK_INLINE_TIME_H 2 | #define _TEK_INLINE_TIME_H 3 | 4 | /* 5 | ** $Id: time.h,v 1.1 2008-06-30 12:34:58 tmueller Exp $ 6 | ** teklib/tek/inline/time.h - time inline calls 7 | ** 8 | ** See copyright notice in teklib/COPYRIGHT 9 | */ 10 | 11 | #include 12 | 13 | #define TSubTime(a,b) \ 14 | (*(((TMODCALL void(**)(TAPTR,TTIME *,TTIME *))(TTimeBase))[-9]))(TTimeBase,a,b) 15 | 16 | #define TAddTime(a,b) \ 17 | (*(((TMODCALL void(**)(TAPTR,TTIME *,TTIME *))(TTimeBase))[-10]))(TTimeBase,a,b) 18 | 19 | #define TCmpTime(a,b) \ 20 | (*(((TMODCALL TINT(**)(TAPTR,TTIME *,TTIME *))(TTimeBase))[-11]))(TTimeBase,a,b) 21 | 22 | #define TAllocTimeRequest(tags) \ 23 | (*(((TMODCALL TAPTR(**)(TAPTR,TTAGITEM *))(TTimeBase))[-12]))(TTimeBase,tags) 24 | 25 | #define TFreeTimeRequest(req) \ 26 | (*(((TMODCALL void(**)(TAPTR,TAPTR))(TTimeBase))[-13]))(TTimeBase,req) 27 | 28 | #define TQueryTime(req,t) \ 29 | (*(((TMODCALL void(**)(TAPTR,TAPTR,TTIME *))(TTimeBase))[-14]))(TTimeBase,req,t) 30 | 31 | #define TGetDate(req,dt,tz) \ 32 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR,TDATE *,TINT *))(TTimeBase))[-15]))(TTimeBase,req,dt,tz) 33 | 34 | #define TWaitTime(req,t,sig) \ 35 | (*(((TMODCALL TUINT(**)(TAPTR,TAPTR,TTIME *,TUINT))(TTimeBase))[-16]))(TTimeBase,req,t,sig) 36 | 37 | #define TWaitDate(req,dt,sig) \ 38 | (*(((TMODCALL TUINT(**)(TAPTR,TAPTR,TDATE *,TUINT))(TTimeBase))[-17]))(TTimeBase,req,dt,sig) 39 | 40 | #define TMakeDate(dt,d,m,y,t) \ 41 | (*(((TMODCALL TBOOL(**)(TAPTR,TDATE *,TINT,TINT,TINT,TTIME *))(TTimeBase))[-18]))(TTimeBase,dt,d,m,y,t) 42 | 43 | #define TAddDate(dt,nd,t) \ 44 | (*(((TMODCALL void(**)(TAPTR,TDATE *,TINT,TTIME *))(TTimeBase))[-19]))(TTimeBase,dt,nd,t) 45 | 46 | #define TSubDate(dt,nd,t) \ 47 | (*(((TMODCALL void(**)(TAPTR,TDATE *,TINT,TTIME *))(TTimeBase))[-20]))(TTimeBase,dt,nd,t) 48 | 49 | #define TDiffDate(dt1,dt2,t) \ 50 | (*(((TMODCALL TINT(**)(TAPTR,TDATE *,TDATE *,TTIME *))(TTimeBase))[-21]))(TTimeBase,dt1,dt2,t) 51 | 52 | #define TIsLeapYear(year) \ 53 | (*(((TMODCALL TBOOL(**)(TAPTR,TINT))(TTimeBase))[-22]))(TTimeBase,year) 54 | 55 | #define TIsValidDate(d,m,y) \ 56 | (*(((TMODCALL TBOOL(**)(TAPTR,TINT,TINT,TINT))(TTimeBase))[-23]))(TTimeBase,d,m,y) 57 | 58 | #define TPackDate(db,dt) \ 59 | (*(((TMODCALL TBOOL(**)(TAPTR,struct TDateBox *,TDATE *))(TTimeBase))[-24]))(TTimeBase,db,dt) 60 | 61 | #define TUnpackDate(dt,db,flg) \ 62 | (*(((TMODCALL void(**)(TAPTR,TDATE *,struct TDateBox *,TUINT))(TTimeBase))[-25]))(TTimeBase,dt,db,flg) 63 | 64 | #define TDateToJulian(dt) \ 65 | (*(((TMODCALL TDOUBLE(**)(TAPTR,TDATE *))(TTimeBase))[-26]))(TTimeBase,dt) 66 | 67 | #define TJulianToDate(jd,dt) \ 68 | (*(((TMODCALL void(**)(TAPTR,TDOUBLE,TDATE *))(TTimeBase))[-27]))(TTimeBase,jd,dt) 69 | 70 | #define TMYToJulian(m,y) \ 71 | (*(((TMODCALL TDOUBLE(**)(TAPTR,TINT,TINT))(TTimeBase))[-28]))(TTimeBase,m,y) 72 | 73 | #define TJulianToDMY(jd,pd,pm,py) \ 74 | (*(((TMODCALL TDOUBLE(**)(TAPTR,TDOUBLE,TINT *,TINT *,TINT *))(TTimeBase))[-29]))(TTimeBase,jd,pd,pm,py) 75 | 76 | #define TYDayToDM(yd,y,pd,pm) \ 77 | (*(((TMODCALL void(**)(TAPTR,TINT,TINT,TINT *,TINT *))(TTimeBase))[-30]))(TTimeBase,yd,y,pd,pm) 78 | 79 | #define TDMYToYDay(d,m,y) \ 80 | (*(((TMODCALL TINT(**)(TAPTR,TINT,TINT,TINT))(TTimeBase))[-31]))(TTimeBase,d,m,y) 81 | 82 | #define TGetWeekDay(d,m,y) \ 83 | (*(((TMODCALL TINT(**)(TAPTR,TINT,TINT,TINT))(TTimeBase))[-32]))(TTimeBase,d,m,y) 84 | 85 | #define TGetWeekNumber(d,m,y) \ 86 | (*(((TMODCALL TINT(**)(TAPTR,TINT,TINT,TINT))(TTimeBase))[-33]))(TTimeBase,d,m,y) 87 | 88 | #define TDelay(req,t) \ 89 | (*(((TMODCALL void(**)(TAPTR,TAPTR,TTIME *))(TTimeBase))[-34]))(TTimeBase,req,t) 90 | 91 | #endif /* _TEK_INLINE_TIME_H */ 92 | -------------------------------------------------------------------------------- /tekui/include/tek/lib/init.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_INIT_H 3 | #define _TEK_INIT_H 4 | 5 | /* 6 | ** $Id: init.h,v 1.1 2008-06-30 12:34:47 tmueller Exp $ 7 | ** teklib/boot/init.h - Startup library definitions 8 | ** 9 | ** Written by Timm S. Mueller 10 | ** See copyright notice in teklib/COPYRIGHT 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | /*****************************************************************************/ 19 | /* 20 | ** This initdata packet will be attached to exectask's userdata 21 | ** during the lifetime of apptask. 22 | */ 23 | 24 | struct TEKlibInit 25 | { 26 | /* inital boot handle */ 27 | TAPTR tli_BootHnd; 28 | /* host-specific ptr to hal module */ 29 | TAPTR tli_HALMod; 30 | /* host-specific ptr to exec module */ 31 | TAPTR tli_ExecMod; 32 | /* hal entry function */ 33 | TMODINITFUNC tli_HALEntry; 34 | /* exec entry function */ 35 | TMODINITFUNC tli_ExecEntry; 36 | /* hal module base */ 37 | TAPTR tli_HALBase; 38 | /* exec module base */ 39 | struct TModule *tli_ExecBase; 40 | /* PROGDIR: */ 41 | TSTRPTR tli_ProgDir; 42 | /* SYS: */ 43 | TSTRPTR tli_SysDir; 44 | /* system-wide module directory */ 45 | TSTRPTR tli_ModDir; 46 | /* host-specific execbase thread */ 47 | struct THALObject tli_ExecThread; 48 | /* to signal apptask that exec is running */ 49 | struct THALObject tli_InitEvent; 50 | /* execbase task handle */ 51 | struct TTask *tli_ExecTask; 52 | /* application task handle */ 53 | struct THandle *tli_AppTask; 54 | /* io task handle */ 55 | TAPTR tli_IOTask; 56 | /* original destructor for app task */ 57 | struct THook tli_OrgAppTaskHook; 58 | /* attributes for HAL init */ 59 | TTAGITEM tli_HALTags[7]; 60 | /* attributes for Exec init */ 61 | TTAGITEM tli_ExecTags[3]; 62 | /* named atom holding the argv vector */ 63 | TAPTR tli_AtomArgV; 64 | /* named atom holding a ptr to retvalue */ 65 | TAPTR tli_AtomRetValP; 66 | /* named atom holding a ptr to unique ID */ 67 | TAPTR tli_AtomUnique; 68 | /* named atom holding initmodules */ 69 | TAPTR tli_AtomInitMods; 70 | /* named atom holding argument string */ 71 | TAPTR tli_AtomArgs; 72 | /* named atom holding progname */ 73 | TAPTR tli_AtomProgName; 74 | /* unique ID */ 75 | TUINT tli_UniqueID; 76 | }; 77 | 78 | /*****************************************************************************/ 79 | /* 80 | ** User entrypoint 81 | */ 82 | 83 | extern TTASKENTRY void TEKMain(TAPTR task); 84 | 85 | /*****************************************************************************/ 86 | /* 87 | ** TEKlib init prototypes 88 | */ 89 | 90 | TLIBAPI TAPTR TEKlib_Init(TTAGITEM *tags); 91 | TLIBAPI void TEKlib_Exit(TAPTR handle); 92 | TLIBAPI TAPTR TEKlib_Alloc(TAPTR handle, TUINT size); 93 | TLIBAPI void TEKlib_Free(TAPTR handle, TAPTR mem, TUINT size); 94 | TLIBAPI void TEKlib_FreeVec(TAPTR handle, TAPTR mem); 95 | TLIBAPI TSTRPTR TEKlib_GetSysDir(TAPTR handle, TTAGITEM *tags); 96 | TLIBAPI TSTRPTR TEKlib_GetModDir(TAPTR handle, TTAGITEM *tags); 97 | TLIBAPI TSTRPTR TEKlib_GetProgDir(TAPTR handle, TTAGITEM *tags); 98 | TLIBAPI TAPTR TEKlib_LoadModule(TAPTR handle, TSTRPTR progdir, TSTRPTR moddir, 99 | TSTRPTR modname, TTAGITEM *tags); 100 | TLIBAPI void TEKlib_CloseModule(TAPTR handle, TAPTR halmod); 101 | TLIBAPI TMODINITFUNC TEKlib_GetEntry(TAPTR handle, TAPTR halmod, TSTRPTR name); 102 | TLIBAPI TUINT TEKlib_CallModule(TAPTR handle, TAPTR ModBase, TMODINITFUNC entry, 103 | TAPTR task, TAPTR mod, TUINT16 version, TTAGITEM *tags); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /tekui/include/tek/mod/hal.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_MOD_HAL_H 3 | #define _TEK_MOD_HAL_H 4 | 5 | /* 6 | ** $Id: hal.h,v 1.1 2008-06-30 12:34:54 tmueller Exp $ 7 | ** teklib/tek/mod/hal.h - HAL module private 8 | ** See copyright notice in teklib/COPYRIGHT 9 | */ 10 | 11 | #include 12 | 13 | /*****************************************************************************/ 14 | /* 15 | ** Access macros for the generic HAL object type. 16 | ** Some platform-specific structures may fit into sizeof(THALO), 17 | ** in which case an allocation can be avoided. The compiler should 18 | ** optimize away the non-applicable path. 19 | */ 20 | 21 | #define THALNewObject(hal,obj,type) \ 22 | ((type *)((sizeof(THALO) 11 | #include 12 | 13 | /*****************************************************************************/ 14 | 15 | #define TEOF (-1) 16 | 17 | /* 18 | ** File attribute tags - these can be passed to 19 | ** io_examine() and io_exnext() for attribute queries. 20 | ** 21 | ** if only TFATTR_Size is specified, and the file is larger than 22 | ** 2^32-2 bytes, the size returned will be 0xffffffff. 23 | */ 24 | 25 | #define TFATTR_Name (TTAG_USER + 0x4000) /* Object name */ 26 | #define TFATTR_Type (TTAG_USER + 0x4001) /* Object type, see below */ 27 | #define TFATTR_Size (TTAG_USER + 0x4002) /* Size, in bytes */ 28 | #define TFATTR_Date (TTAG_USER + 0x4003) /* Object's TDATE */ 29 | #define TFATTR_DateBox (TTAG_USER + 0x4004) /* Datebox structure */ 30 | #define TFATTR_SizeHigh (TTAG_USER + 0x4005) /* High-order 32 bit of size */ 31 | 32 | /* 33 | ** Object types 34 | */ 35 | 36 | #define TFTYPE_Unknown 0x00 /* Unknown object type */ 37 | #define TFTYPE_File 0x01 /* Regular file */ 38 | #define TFTYPE_Directory 0x02 /* Directory */ 39 | #define TFTYPE_Volume 0x12 /* Indicates a volume */ 40 | 41 | /* 42 | ** Lock modes 43 | */ 44 | 45 | #define TFLOCK_NONE 0 /* No locking */ 46 | #define TFLOCK_READ 1 /* Shared lock */ 47 | #define TFLOCK_WRITE 2 /* Exclusive lock */ 48 | 49 | /* 50 | ** Open modes 51 | */ 52 | 53 | #define TFMODE_OLDFILE 1 /* Existing file, read/write, not locked */ 54 | #define TFMODE_NEWFILE 2 /* New file, read/write, exclusive lock */ 55 | #define TFMODE_READONLY 3 /* Existing file, readonly, not locked */ 56 | #define TFMODE_READWRITE 4 /* Existing or new, read/write, shared */ 57 | 58 | /* 59 | ** Seek modes 60 | */ 61 | 62 | #define TFPOS_CURRENT 0 /* Seek from current */ 63 | #define TFPOS_BEGIN 1 /* Seek from beginning */ 64 | #define TFPOS_END (-1) /* Seek from end */ 65 | 66 | /* 67 | ** I/O Error codes - 68 | ** see exec.h for device-specific codes 69 | */ 70 | 71 | #define TIOERR_NOT_ENOUGH_MEMORY 16 72 | 73 | #define TIOERR_BAD_ARGUMENTS 32 74 | #define TIOERR_INVALID_NAME 33 75 | #define TIOERR_LINE_TOO_LONG 34 /* nameof, addpart... */ 76 | #define TIOERR_OUT_OF_RANGE 35 /* address range (seek...) */ 77 | 78 | #define TIOERR_DISK_FULL 48 79 | #define TIOERR_DISK_WRITE_PROTECTED 49 /* physically */ 80 | #define TIOERR_DISK_NOT_READY 50 81 | #define TIOERR_DISK_CORRUPT 51 82 | 83 | #define TIOERR_OBJECT_NOT_FOUND 64 84 | #define TIOERR_OBJECT_WRONG_TYPE 65 85 | #define TIOERR_OBJECT_EXISTS 66 86 | #define TIOERR_OBJECT_TOO_LARGE 67 87 | #define TIOERR_OBJECT_IN_USE 68 88 | #define TIOERR_ACCESS_DENIED 69 /* logically */ 89 | 90 | #define TIOERR_NO_MORE_ENTRIES 80 /* exnext */ 91 | #define TIOERR_NOT_SAME_DEVICE 81 92 | #define TIOERR_DIRECTORY_NOT_EMPTY 82 93 | #define TIOERR_TOO_MANY_LEVELS 83 94 | 95 | /* 96 | ** Name conversion modes 97 | */ 98 | 99 | #define TPPF_TEK2HOST 0x0012 /* convert to HOST naming convention */ 100 | #define TPPF_HOST2TEK 0x0021 /* convert to TEK naming convention */ 101 | 102 | /* 103 | ** Tags for opening and mounting 104 | */ 105 | 106 | #define TIOMount_Handler (TTAG_USER + 0x4100) /* Name of handler */ 107 | #define TIOMount_HndVersion (TTAG_USER + 0x4101) /* Handler version */ 108 | #define TIOMount_Device (TTAG_USER + 0x4102) /* Name of Exec device */ 109 | #define TIOMount_InitString (TTAG_USER + 0x4103) /* Startup control */ 110 | 111 | #define TIOMount_IOBase (TTAG_USER + 0x410f) /* Internal use */ 112 | #define TIOMount_Extended (TTAG_USER + 0x4110) /* User-defined tags */ 113 | 114 | /* Tags for locking */ 115 | 116 | #define TIOLock_NamePart (TTAG_USER + 0x4200) /* Passed to handler */ 117 | 118 | /* 119 | ** Mount action codes 120 | */ 121 | 122 | #define TIOMNT_REMOVE 0 123 | #define TIOMNT_ADD 1 124 | 125 | 126 | #endif 127 | -------------------------------------------------------------------------------- /tekui/include/tek/mod/posix/hal.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_MOD_POSIX_HAL_H 3 | #define _TEK_MOD_POSIX_HAL_H 4 | 5 | /* 6 | ** $Id: hal.h,v 1.1 2008-06-30 12:34:54 tmueller Exp $ 7 | ** teklib/tek/mod/hal/posix/hal.h - HAL internal structures on POSIX 8 | ** 9 | ** Written by Timm S. Mueller 10 | ** See copyright notice in teklib/COPYRIGHT 11 | ** 12 | ** These structures should be accessed only in platform-specific 13 | ** driver code 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | /*****************************************************************************/ 22 | 23 | struct HALSpecific 24 | { 25 | TTAGITEM hsp_Tags[4]; /* Host properties container */ 26 | TSTRPTR hsp_SysDir; /* Global system directory */ 27 | TSTRPTR hsp_ModDir; /* Global module directory */ 28 | TSTRPTR hsp_ProgDir; /* Application local directory */ 29 | pthread_key_t hsp_TSDKey; /* Thread specific data key */ 30 | pthread_mutex_t hsp_DevLock; /* Locking for module base */ 31 | pthread_mutex_t hsp_TimeLock; /* Thanks to localtime() */ 32 | TUINT hsp_RefCount; /* Open reference counter */ 33 | TAPTR hsp_ExecBase; /* Inserted at device open */ 34 | TAPTR hsp_DevTask; /* Created at device open */ 35 | struct TList hsp_ReqList; /* List of pending requests */ 36 | TINT hsp_TZSec; /* Seconds west of GMT */ 37 | }; 38 | 39 | struct HALThread 40 | { 41 | pthread_t hth_PThread; /* Thread handle */ 42 | void *hth_Data; /* Task data ptr */ 43 | void (*hth_Function)(void *); /* Task function */ 44 | TAPTR hth_HALBase; /* HAL module base ptr */ 45 | pthread_mutex_t hth_SigMutex; /* Signal mutex */ 46 | pthread_cond_t hth_SigCond; /* Signal conditional */ 47 | TUINT hth_SigState; /* Signal state */ 48 | }; 49 | 50 | struct HALModule 51 | { 52 | void *hmd_Lib; /* Host-specific module handle */ 53 | TMODINITFUNC hmd_InitFunc; /* Initfunction ptr */ 54 | TUINT16 hmd_Version; /* Module major version */ 55 | }; 56 | 57 | /*****************************************************************************/ 58 | /* 59 | ** Revision History 60 | ** $Log: hal.h,v $ 61 | ** Revision 1.1 2008-06-30 12:34:54 tmueller 62 | ** Initial revision 63 | ** 64 | ** Revision 1.2 2006/09/10 14:36:03 tmueller 65 | ** removed TNODE, TLIST and THNDL 66 | ** 67 | ** Revision 1.1.1.1 2006/08/20 22:15:26 tmueller 68 | ** intermediate import 69 | ** 70 | ** Revision 1.8 2006/06/25 22:23:48 tmueller 71 | ** removed TZDays 72 | ** 73 | ** Revision 1.7 2006/06/25 15:31:02 tmueller 74 | ** cosmetic 75 | ** 76 | ** Revision 1.6 2006/03/11 16:19:45 tmueller 77 | ** AbortIO now interrupts running TimeRequests as well, not just queued ones 78 | ** 79 | ** Revision 1.5 2005/11/20 16:08:39 tmueller 80 | ** added stricter funcptr declarations for modentries 81 | ** 82 | ** Revision 1.4 2005/09/13 02:45:09 tmueller 83 | ** updated copyright reference 84 | ** 85 | ** Revision 1.3 2003/12/20 14:00:18 tmueller 86 | ** hsp_TZSecDays renamed to hsp_TZDays 87 | ** 88 | ** Revision 1.2 2003/12/19 14:16:18 tmueller 89 | ** Added hsp_TZSecDays field 90 | ** 91 | ** Revision 1.1.1.1 2003/12/11 07:18:00 tmueller 92 | ** Krypton import 93 | ** 94 | ** Revision 1.2 2003/10/28 08:52:46 tmueller 95 | ** Reworked HAL-internal structures 96 | ** 97 | ** Revision 1.1.1.1 2003/03/08 18:28:40 tmueller 98 | ** Import to new chrooted pserver repository. 99 | ** 100 | ** Revision 1.1.1.1 2002/11/30 05:15:33 bifat 101 | ** import 102 | */ 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /tekui/include/tek/mod/time.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_MOD_TIME_H 3 | #define _TEK_MOD_TIME_H 4 | 5 | /* 6 | ** $Id: time.h,v 1.1 2008-06-30 12:34:54 tmueller Exp $ 7 | ** teklib/tek/mod/time.h - Time/date module definitions 8 | ** 9 | ** Written by Frank Pagels 10 | ** and Timm S. Mueller 11 | ** See copyright notice in teklib/COPYRIGHT 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | /*****************************************************************************/ 18 | /* 19 | ** Time and Date structure 20 | */ 21 | 22 | struct TTime 23 | { 24 | TINT ttm_Sec; /* Seconds */ 25 | TINT ttm_USec; /* 1/1000000th Seconds */ 26 | }; 27 | 28 | struct TDate 29 | { 30 | TDATE_T tdt_Day; /* Private */ 31 | }; 32 | 33 | typedef struct TTime TTIME; 34 | typedef struct TDate TDATE; 35 | 36 | /*****************************************************************************/ 37 | /* 38 | ** Weekday definitions 39 | */ 40 | 41 | #define TDT_SUNDAY 0 42 | #define TDT_MONDAY 1 43 | #define TDT_TUESDAY 2 44 | #define TDT_WEDNESDAY 3 45 | #define TDT_THURSDAY 4 46 | #define TDT_FRIDAY 5 47 | #define TDT_SATURDAY 6 48 | 49 | /*****************************************************************************/ 50 | /* 51 | ** "Datebox" - Date/Time container 52 | */ 53 | 54 | struct TDateBox 55 | { 56 | TUINT16 tdb_Fields; /* 0 Fields, see below */ 57 | TUINT16 tdb_Reserved1; /* 2 Reserved for future use */ 58 | TINT tdb_Year; /* 4 Year */ 59 | TUINT16 tdb_YDay; /* 8 Day of year 1...366 */ 60 | TUINT16 tdb_Month; /* 10 Month 1...12 */ 61 | TUINT16 tdb_Week; /* 12 Week of year 1...53 */ 62 | TUINT16 tdb_WDay; /* 14 Day of week 0 (sunday) ... 6 (saturday) */ 63 | TUINT16 tdb_Day; /* 16 Day of month 1...31 */ 64 | TUINT16 tdb_Hour; /* 18 Hour of day 0...23 */ 65 | TUINT16 tdb_Minute; /* 20 Minute of hour 0...59 */ 66 | TUINT16 tdb_Sec; /* 22 Second of minute 0...59 */ 67 | TUINT tdb_USec; /* 24 Microsecond of second 0... 999999 */ 68 | TUINT tdb_Reserved2; /* 28 Reserved for future extensions */ 69 | }; /* 32 bytes */ 70 | 71 | /* 72 | ** Corresponding flags in datebox->tdb_Fields if value present 73 | */ 74 | 75 | #define TDB_YEAR 0x0001 76 | #define TDB_YDAY 0x0002 77 | #define TDB_MONTH 0x0004 78 | #define TDB_WEEK 0x0008 79 | #define TDB_WDAY 0x0010 80 | #define TDB_DAY 0x0020 81 | #define TDB_HOUR 0x0040 82 | #define TDB_MINUTE 0x0080 83 | #define TDB_SEC 0x0100 84 | #define TDB_USEC 0x0200 85 | #define TDB_ALL 0x03ff 86 | 87 | /*****************************************************************************/ 88 | /* 89 | ** Timer I/O request 90 | */ 91 | 92 | struct TTimeRequest 93 | { 94 | struct TIORequest ttr_Req; /* I/O request header */ 95 | union 96 | { 97 | TTIME ttr_Time; /* Relative time */ 98 | 99 | struct 100 | { 101 | TDATE ttr_Date; /* Local or UT time */ 102 | TINT ttr_TimeZone; /* Seconds west of UT */ 103 | 104 | } ttr_Date; 105 | 106 | TINT ttr_DSSec; /* Number of seconds Daylight Saving */ 107 | 108 | } ttr_Data; 109 | }; 110 | 111 | /* 112 | ** I/O Commands 113 | */ 114 | 115 | #define TTREQ_GETTIME (TIOCMD_EXTENDED + 0) /* Get system rel. time */ 116 | #define TTREQ_GETUNIDATE (TIOCMD_EXTENDED + 1) /* Get universal */ 117 | #define TTREQ_GETLOCALDATE (TIOCMD_EXTENDED + 2) /* Get local */ 118 | #define TTREQ_ADDTIME (TIOCMD_EXTENDED + 3) /* Wait relative time */ 119 | #define TTREQ_ADDUNIDATE (TIOCMD_EXTENDED + 4) /* Wait for universal */ 120 | #define TTREQ_ADDLOCALDATE (TIOCMD_EXTENDED + 5) /* Wait for local */ 121 | #define TTREQ_GETDSFROMDATE (TIOCMD_EXTENDED + 6) /* Daylight saving sec. */ 122 | 123 | /*****************************************************************************/ 124 | /* 125 | ** Revision History 126 | ** $Log: time.h,v $ 127 | ** Revision 1.1 2008-06-30 12:34:54 tmueller 128 | ** Initial revision 129 | ** 130 | ** Revision 1.1.1.1 2006/08/20 22:15:25 tmueller 131 | ** intermediate import 132 | ** 133 | ** Revision 1.4 2006/08/19 11:26:16 tmueller 134 | ** renamed ttr_Sec to ttr_DSSec 135 | ** 136 | ** Revision 1.3 2006/06/25 22:23:21 tmueller 137 | ** added TTREQ_GETDSFROMDATE request 138 | ** 139 | ** Revision 1.2 2005/09/13 02:45:09 tmueller 140 | ** updated copyright reference 141 | ** 142 | ** Revision 1.1.1.1 2003/12/11 07:17:50 tmueller 143 | ** Krypton import 144 | ** 145 | ** Revision 1.2 2003/09/17 16:51:38 tmueller 146 | ** (TTAG) casts removed 147 | ** 148 | ** Revision 1.1.1.1 2003/03/08 18:28:40 tmueller 149 | ** Import to new chrooted pserver repository. 150 | ** 151 | ** Revision 1.2 2003/01/06 19:20:21 copper 152 | ** add Schwerin in townlist 153 | ** 154 | ** Revision 1.1.1.1 2002/11/30 05:15:33 bifat 155 | ** import 156 | */ 157 | 158 | #endif 159 | -------------------------------------------------------------------------------- /tekui/include/tek/proto/display.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_PROTO_DISPLAY_H 3 | #define _TEK_PROTO_DISPLAY_H 4 | 5 | #include 6 | #include 7 | 8 | extern TMODENTRY TUINT 9 | tek_init_display(TAPTR, struct TModule *, TUINT16, TTAGITEM *); 10 | 11 | #endif /* _TEK_PROTO_DISPLAY_H */ 12 | -------------------------------------------------------------------------------- /tekui/include/tek/proto/exec.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_PROTO_EXEC_H 3 | #define _TEK_PROTO_EXEC_H 4 | 5 | /* 6 | ** $Id: exec.h,v 1.1 2008-06-30 12:34:54 tmueller Exp $ 7 | ** teklib/tek/proto/exec.h - Exec module prototypes 8 | ** 9 | ** See copyright notice in teklib/COPYRIGHT 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | extern TMODENTRY TUINT 16 | tek_init_exec(TAPTR, struct TModule *, TUINT16, TTAGITEM *); 17 | 18 | #endif /* _TEK_PROTO_EXEC_H */ 19 | -------------------------------------------------------------------------------- /tekui/include/tek/proto/hal.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_PROTO_HAL_H 3 | #define _TEK_PROTO_HAL_H 4 | 5 | /* 6 | ** $Id: hal.h,v 1.1 2008-06-30 12:34:54 tmueller Exp $ 7 | ** teklib/tek/proto/hal.h - HAL module prototypes 8 | ** 9 | ** See copyright notice in teklib/COPYRIGHT 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | extern TMODENTRY TUINT 16 | tek_init_hal(TAPTR, struct TModule *, TUINT16, TTAGITEM *); 17 | 18 | #endif /* _TEK_PROTO_HAL_H */ 19 | -------------------------------------------------------------------------------- /tekui/include/tek/proto/io.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_PROTO_IO_H 3 | #define _TEK_PROTO_IO_H 4 | 5 | /* 6 | ** $Id: io.h,v 1.1 2008-06-30 12:34:54 tmueller Exp $ 7 | ** teklib/tek/proto/io.h - I/O module prototypes 8 | ** 9 | ** See copyright notice in teklib/COPYRIGHT 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | extern TMODENTRY TUINT 16 | tek_init_io(TAPTR, struct TModule *, TUINT16, TTAGITEM *); 17 | 18 | #endif /* _TEK_PROTO_IO_H */ 19 | -------------------------------------------------------------------------------- /tekui/include/tek/proto/time.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_PROTO_TIME_H 3 | #define _TEK_PROTO_TIME_H 4 | 5 | /* 6 | ** $Id: time.h,v 1.1 2008-06-30 12:34:54 tmueller Exp $ 7 | ** teklib/tek/proto/time.h - Time module prototypes 8 | ** 9 | ** See copyright notice in teklib/COPYRIGHT 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | extern TMODENTRY TUINT 16 | tek_init_time(TAPTR, struct TModule *, TUINT16, TTAGITEM *); 17 | 18 | #if !defined(TTIME_NO_API_COMPAT) 19 | /* 20 | ** old API functions (for compatibility) 21 | */ 22 | #define TTimeSub(mod,a,b) TTimeSubTime(mod,a,b) 23 | #define TTimeAdd(mod,a,b) TTimeAddTime(mod,a,b) 24 | #define TTimeCmp(mod,a,b) TTimeCmpTime(mod,a,b) 25 | #define TTimeAllocRequest(mod,tags) TTimeAllocTimeRequest(mod,tags) 26 | #define TTimeFreeRequest(mod,req) TTimeFreeTimeRequest(mod,req) 27 | #define TTimeQuery(mod,req,time) TTimeQueryTime(mod,req,time) 28 | #define TTimeWait(mod,req,time,sig) TTimeWaitTime(mod,req,time,sig) 29 | 30 | #endif 31 | 32 | #endif /* _TEK_PROTO_TIME_H */ 33 | -------------------------------------------------------------------------------- /tekui/include/tek/proto/visual.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_PROTO_VISUAL_H 3 | #define _TEK_PROTO_VISUAL_H 4 | 5 | /* 6 | ** $Id: visual.h,v 1.1 2008-06-30 12:34:54 tmueller Exp $ 7 | ** teklib/tek/proto/time.h - Time module prototypes 8 | ** 9 | ** See copyright notice in teklib/COPYRIGHT 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | extern TMODENTRY TUINT 16 | tek_init_visual(TAPTR, struct TModule *, TUINT16, TTAGITEM *); 17 | 18 | #endif /* _TEK_PROTO_VISUAL_H */ 19 | -------------------------------------------------------------------------------- /tekui/include/tek/stdcall/display.h: -------------------------------------------------------------------------------- 1 | #ifndef _TEK_STDCALL_DISPLAY_H 2 | #define _TEK_STDCALL_DISPLAY_H 3 | 4 | /* 5 | ** $Id: display.h,v 1.1 2008-06-30 12:34:56 tmueller Exp $ 6 | ** teklib/tek/stdcall/display.h - display module interface 7 | ** 8 | ** Written by Timm S. Mueller 9 | ** See copyright notice in teklib/COPYRIGHT 10 | */ 11 | 12 | #define TDisplayAllocReq(display) \ 13 | (*(((TMODCALL struct TVRequest *(**)(TAPTR))(display))[-9]))(display) 14 | 15 | #define TDisplayFreeReq(display,req) \ 16 | (*(((TMODCALL void(**)(TAPTR,struct TVRequest *))(display))[-10]))(display,req) 17 | 18 | #endif /* _TEK_STDCALL_DISPLAY_H */ 19 | -------------------------------------------------------------------------------- /tekui/include/tek/stdcall/hal.h: -------------------------------------------------------------------------------- 1 | #ifndef _TEK_STDCALL_HAL_H 2 | #define _TEK_STDCALL_HAL_H 3 | 4 | /* 5 | ** $Id: hal.h,v 1.1 2008-06-30 12:34:56 tmueller Exp $ 6 | ** teklib/tek/stdcall/hal.h - hal module interface 7 | ** 8 | ** See copyright notice in teklib/COPYRIGHT 9 | */ 10 | 11 | #define THALGetAttr(hal,tag,defval) \ 12 | (*(((TMODCALL TTAG(**)(TAPTR,TUINT,TTAG))(hal))[-9]))(hal,tag,defval) 13 | 14 | #define THALGetSysTime(hal,time) \ 15 | (*(((TMODCALL void(**)(TAPTR,TTIME *))(hal))[-10]))(hal,time) 16 | 17 | #define THALAlloc(hal,size) \ 18 | (*(((TMODCALL TAPTR(**)(TAPTR,TUINT))(hal))[-11]))(hal,size) 19 | 20 | #define THALFree(hal,mem,size) \ 21 | (*(((TMODCALL void(**)(TAPTR,TAPTR,TUINT))(hal))[-12]))(hal,mem,size) 22 | 23 | #define THALRealloc(hal,mem,oldsize,newsize) \ 24 | (*(((TMODCALL TAPTR(**)(TAPTR,TAPTR,TUINT,TUINT))(hal))[-13]))(hal,mem,oldsize,newsize) 25 | 26 | #define THALCopyMem(hal,src,dst,size) \ 27 | (*(((TMODCALL void(**)(TAPTR,TAPTR,TAPTR,TUINT))(hal))[-14]))(hal,src,dst,size) 28 | 29 | #define THALFillMem(hal,dst,len,val) \ 30 | (*(((TMODCALL void(**)(TAPTR,TAPTR,TUINT,TUINT8))(hal))[-15]))(hal,dst,len,val) 31 | 32 | #define THALInitLock(hal,lock) \ 33 | (*(((TMODCALL TBOOL(**)(TAPTR,THALO *))(hal))[-16]))(hal,lock) 34 | 35 | #define THALDestroyLock(hal,lock) \ 36 | (*(((TMODCALL void(**)(TAPTR,THALO *))(hal))[-17]))(hal,lock) 37 | 38 | #define THALLock(hal,lock) \ 39 | (*(((TMODCALL void(**)(TAPTR,THALO *))(hal))[-18]))(hal,lock) 40 | 41 | #define THALUnlock(hal,lock) \ 42 | (*(((TMODCALL void(**)(TAPTR,THALO *))(hal))[-19]))(hal,lock) 43 | 44 | #define THALInitThread(hal,thread,func,data) \ 45 | (*(((TMODCALL TBOOL(**)(TAPTR,THALO *,TTASKFUNC,TAPTR))(hal))[-20]))(hal,thread,func,data) 46 | 47 | #define THALDestroyThread(hal,thread) \ 48 | (*(((TMODCALL void(**)(TAPTR,THALO *))(hal))[-21]))(hal,thread) 49 | 50 | #define THALFindSelf(hal) \ 51 | (*(((TMODCALL TAPTR(**)(TAPTR))(hal))[-22]))(hal) 52 | 53 | #define THALWait(hal,signals) \ 54 | (*(((TMODCALL TUINT(**)(TAPTR,TUINT))(hal))[-23]))(hal,signals) 55 | 56 | #define THALSignal(hal,thread,signals) \ 57 | (*(((TMODCALL void(**)(TAPTR,THALO *,TUINT))(hal))[-24]))(hal,thread,signals) 58 | 59 | #define THALSetSignal(hal,newsigs,sigs) \ 60 | (*(((TMODCALL TUINT(**)(TAPTR,TUINT,TUINT))(hal))[-25]))(hal,newsigs,sigs) 61 | 62 | #define THALLoadModule(hal,name,version,possize,newgsize) \ 63 | (*(((TMODCALL TAPTR(**)(TAPTR,TSTRPTR,TUINT16,TUINT *,TUINT *))(hal))[-26]))(hal,name,version,possize,newgsize) 64 | 65 | #define THALCallModule(hal,mod,task,data) \ 66 | (*(((TMODCALL TBOOL(**)(TAPTR,TAPTR,TAPTR,TAPTR))(hal))[-27]))(hal,mod,task,data) 67 | 68 | #define THALUnloadModule(hal,mod) \ 69 | (*(((TMODCALL void(**)(TAPTR,TAPTR))(hal))[-28]))(hal,mod) 70 | 71 | #define THALScanModules(hal,prefix,hook) \ 72 | (*(((TMODCALL TBOOL(**)(TAPTR,TSTRPTR,struct THook *))(hal))[-29]))(hal,prefix,hook) 73 | 74 | #define THALDateToJulian(hal,date) \ 75 | (*(((TMODCALL TDOUBLE(**)(TAPTR,TDATE *))(hal))[-30]))(hal,date) 76 | 77 | #define THALJulianToDate(hal,jd,date) \ 78 | (*(((TMODCALL void(**)(TAPTR,TDOUBLE,TDATE *))(hal))[-31]))(hal,jd,date) 79 | 80 | #endif /* _TEK_STDCALL_HAL_H */ 81 | -------------------------------------------------------------------------------- /tekui/include/tek/stdcall/io.h: -------------------------------------------------------------------------------- 1 | #ifndef _TEK_STDCALL_IO_H 2 | #define _TEK_STDCALL_IO_H 3 | 4 | /* 5 | ** $Id: io.h,v 1.1 2008-06-30 12:34:54 tmueller Exp $ 6 | ** teklib/tek/stdcall/io.h - io module interface 7 | ** 8 | ** See copyright notice in teklib/COPYRIGHT 9 | */ 10 | 11 | #define TIOLockFile(io,name,mode,tags) \ 12 | (*(((TMODCALL TAPTR(**)(TAPTR,TSTRPTR,TUINT,TTAGITEM *))(io))[-9]))(io,name,mode,tags) 13 | 14 | #define TIOUnlockFile(io,lock) \ 15 | (*(((TMODCALL void(**)(TAPTR,TAPTR))(io))[-10]))(io,lock) 16 | 17 | #define TIOOpenFile(io,name,mode,tags) \ 18 | (*(((TMODCALL TAPTR(**)(TAPTR,TSTRPTR,TUINT,TTAGITEM *))(io))[-11]))(io,name,mode,tags) 19 | 20 | #define TIOCloseFile(io,fh) \ 21 | (*(((TMODCALL TBOOL(**)(TAPTR,TAPTR))(io))[-12]))(io,fh) 22 | 23 | #define TIORead(io,fh,buf,len) \ 24 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR,TAPTR,TINT))(io))[-13]))(io,fh,buf,len) 25 | 26 | #define TIOWrite(io,fh,buf,len) \ 27 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR,TAPTR,TINT))(io))[-14]))(io,fh,buf,len) 28 | 29 | #define TIOFlush(io,fh) \ 30 | (*(((TMODCALL TBOOL(**)(TAPTR,TAPTR))(io))[-15]))(io,fh) 31 | 32 | #define TIOSeek(io,fh,offs,offshi,mode) \ 33 | (*(((TMODCALL TUINT(**)(TAPTR,TAPTR,TINT,TINT *,TINT))(io))[-16]))(io,fh,offs,offshi,mode) 34 | 35 | #define TIOFPutC(io,fh,c) \ 36 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR,TINT))(io))[-17]))(io,fh,c) 37 | 38 | #define TIOFGetC(io,fh) \ 39 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR))(io))[-18]))(io,fh) 40 | 41 | #define TIOFEoF(io,fh) \ 42 | (*(((TMODCALL TBOOL(**)(TAPTR,TAPTR))(io))[-19]))(io,fh) 43 | 44 | #define TIOFRead(io,fh,buf,len) \ 45 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR,TAPTR,TINT))(io))[-20]))(io,fh,buf,len) 46 | 47 | #define TIOFWrite(io,fh,buf,len) \ 48 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR,TAPTR,TINT))(io))[-21]))(io,fh,buf,len) 49 | 50 | #define TIOExamine(io,lock,tags) \ 51 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR,TTAGITEM *))(io))[-22]))(io,lock,tags) 52 | 53 | #define TIOExNext(io,lock,tags) \ 54 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR,TTAGITEM *))(io))[-23]))(io,lock,tags) 55 | 56 | #define TIOChangeDir(io,lock) \ 57 | (*(((TMODCALL TAPTR(**)(TAPTR,TAPTR))(io))[-24]))(io,lock) 58 | 59 | #define TIOParentDir(io,lock) \ 60 | (*(((TMODCALL TAPTR(**)(TAPTR,TAPTR))(io))[-25]))(io,lock) 61 | 62 | #define TIONameOf(io,lock,buf,len) \ 63 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR,TSTRPTR,TINT))(io))[-26]))(io,lock,buf,len) 64 | 65 | #define TIODupLock(io,lock) \ 66 | (*(((TMODCALL TAPTR(**)(TAPTR,TAPTR))(io))[-27]))(io,lock) 67 | 68 | #define TIOOpenFromLock(io,lock) \ 69 | (*(((TMODCALL TAPTR(**)(TAPTR,TAPTR))(io))[-28]))(io,lock) 70 | 71 | #define TIOAddPart(io,p1,p2,buf,len) \ 72 | (*(((TMODCALL TINT(**)(TAPTR,TSTRPTR,TSTRPTR,TSTRPTR,TINT))(io))[-29]))(io,p1,p2,buf,len) 73 | 74 | #define TIOAssignLate(io,name,path) \ 75 | (*(((TMODCALL TBOOL(**)(TAPTR,TSTRPTR,TSTRPTR))(io))[-30]))(io,name,path) 76 | 77 | #define TIOAssignLock(io,name,lock) \ 78 | (*(((TMODCALL TBOOL(**)(TAPTR,TSTRPTR,TAPTR))(io))[-31]))(io,name,lock) 79 | 80 | #define TIORename(io,name,newname) \ 81 | (*(((TMODCALL TBOOL(**)(TAPTR,TSTRPTR,TSTRPTR))(io))[-32]))(io,name,newname) 82 | 83 | #define TIOMakeDir(io,name,tags) \ 84 | (*(((TMODCALL TAPTR(**)(TAPTR,TSTRPTR,TTAGITEM *))(io))[-33]))(io,name,tags) 85 | 86 | #define TIODeleteFile(io,name) \ 87 | (*(((TMODCALL TBOOL(**)(TAPTR,TSTRPTR))(io))[-34]))(io,name) 88 | 89 | #define TIOSetIOErr(io,newerr) \ 90 | (*(((TMODCALL TINT(**)(TAPTR,TINT))(io))[-35]))(io,newerr) 91 | 92 | #define TIOGetIOErr(io) \ 93 | (*(((TMODCALL TINT(**)(TAPTR))(io))[-36]))(io) 94 | 95 | #define TIOObtainPacket(io,path,namepart) \ 96 | (*(((TMODCALL TAPTR(**)(TAPTR,TSTRPTR,TSTRPTR *))(io))[-37]))(io,path,namepart) 97 | 98 | #define TIOReleasePacket(io,packet) \ 99 | (*(((TMODCALL void(**)(TAPTR,TAPTR))(io))[-38]))(io,packet) 100 | 101 | #define TIOFault(io,err,buf,len,tags) \ 102 | (*(((TMODCALL TINT(**)(TAPTR,TINT,TSTRPTR,TINT,TTAGITEM *))(io))[-39]))(io,err,buf,len,tags) 103 | 104 | #define TIOWaitChar(io,fh,timeout) \ 105 | (*(((TMODCALL TBOOL(**)(TAPTR,TAPTR,TINT))(io))[-40]))(io,fh,timeout) 106 | 107 | #define TIOIsInteractive(io,fh) \ 108 | (*(((TMODCALL TBOOL(**)(TAPTR,TAPTR))(io))[-41]))(io,fh) 109 | 110 | #define TIOOutputFH(io) \ 111 | (*(((TMODCALL TAPTR(**)(TAPTR))(io))[-42]))(io) 112 | 113 | #define TIOInputFH(io) \ 114 | (*(((TMODCALL TAPTR(**)(TAPTR))(io))[-43]))(io) 115 | 116 | #define TIOErrorFH(io) \ 117 | (*(((TMODCALL TAPTR(**)(TAPTR))(io))[-44]))(io) 118 | 119 | #define TIOMakeName(io,name,dest,dlen,mode,tags) \ 120 | (*(((TMODCALL TINT(**)(TAPTR,TSTRPTR,TSTRPTR,TINT,TINT,TTAGITEM *))(io))[-45]))(io,name,dest,dlen,mode,tags) 121 | 122 | #define TIOMount(io,name,action,tags) \ 123 | (*(((TMODCALL TBOOL(**)(TAPTR,TSTRPTR,TINT,TTAGITEM *))(io))[-46]))(io,name,action,tags) 124 | 125 | #define TIOFUngetC(io,fh,c) \ 126 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR,TINT))(io))[-47]))(io,fh,c) 127 | 128 | #define TIOFPutS(io,fh,s) \ 129 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR,TSTRPTR))(io))[-48]))(io,fh,s) 130 | 131 | #define TIOFGetS(io,fh,buf,len) \ 132 | (*(((TMODCALL TSTRPTR(**)(TAPTR,TAPTR,TSTRPTR,TINT))(io))[-49]))(io,fh,buf,len) 133 | 134 | #define TIOSetFileDate(io,name,date,tags) \ 135 | (*(((TMODCALL TBOOL(**)(TAPTR,TSTRPTR,TDATE *,TTAGITEM *))(io))[-50]))(io,name,date,tags) 136 | 137 | #endif /* _TEK_STDCALL_IO_H */ 138 | -------------------------------------------------------------------------------- /tekui/include/tek/stdcall/time.h: -------------------------------------------------------------------------------- 1 | #ifndef _TEK_STDCALL_TIME_H 2 | #define _TEK_STDCALL_TIME_H 3 | 4 | /* 5 | ** $Id: time.h,v 1.1 2008-06-30 12:34:58 tmueller Exp $ 6 | ** teklib/tek/stdcall/time.h - time module interface 7 | ** 8 | ** See copyright notice in teklib/COPYRIGHT 9 | */ 10 | 11 | #define TTimeSubTime(time,a,b) \ 12 | (*(((TMODCALL void(**)(TAPTR,TTIME *,TTIME *))(time))[-9]))(time,a,b) 13 | 14 | #define TTimeAddTime(time,a,b) \ 15 | (*(((TMODCALL void(**)(TAPTR,TTIME *,TTIME *))(time))[-10]))(time,a,b) 16 | 17 | #define TTimeCmpTime(time,a,b) \ 18 | (*(((TMODCALL TINT(**)(TAPTR,TTIME *,TTIME *))(time))[-11]))(time,a,b) 19 | 20 | #define TTimeAllocTimeRequest(time,tags) \ 21 | (*(((TMODCALL TAPTR(**)(TAPTR,TTAGITEM *))(time))[-12]))(time,tags) 22 | 23 | #define TTimeFreeTimeRequest(time,req) \ 24 | (*(((TMODCALL void(**)(TAPTR,TAPTR))(time))[-13]))(time,req) 25 | 26 | #define TTimeQueryTime(time,req,t) \ 27 | (*(((TMODCALL void(**)(TAPTR,TAPTR,TTIME *))(time))[-14]))(time,req,t) 28 | 29 | #define TTimeGetDate(time,req,dt,tz) \ 30 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR,TDATE *,TINT *))(time))[-15]))(time,req,dt,tz) 31 | 32 | #define TTimeWaitTime(time,req,t,sig) \ 33 | (*(((TMODCALL TUINT(**)(TAPTR,TAPTR,TTIME *,TUINT))(time))[-16]))(time,req,t,sig) 34 | 35 | #define TTimeWaitDate(time,req,dt,sig) \ 36 | (*(((TMODCALL TUINT(**)(TAPTR,TAPTR,TDATE *,TUINT))(time))[-17]))(time,req,dt,sig) 37 | 38 | #define TTimeMakeDate(time,dt,d,m,y,t) \ 39 | (*(((TMODCALL TBOOL(**)(TAPTR,TDATE *,TINT,TINT,TINT,TTIME *))(time))[-18]))(time,dt,d,m,y,t) 40 | 41 | #define TTimeAddDate(time,dt,nd,t) \ 42 | (*(((TMODCALL void(**)(TAPTR,TDATE *,TINT,TTIME *))(time))[-19]))(time,dt,nd,t) 43 | 44 | #define TTimeSubDate(time,dt,nd,t) \ 45 | (*(((TMODCALL void(**)(TAPTR,TDATE *,TINT,TTIME *))(time))[-20]))(time,dt,nd,t) 46 | 47 | #define TTimeDiffDate(time,dt1,dt2,t) \ 48 | (*(((TMODCALL TINT(**)(TAPTR,TDATE *,TDATE *,TTIME *))(time))[-21]))(time,dt1,dt2,t) 49 | 50 | #define TTimeIsLeapYear(time,year) \ 51 | (*(((TMODCALL TBOOL(**)(TAPTR,TINT))(time))[-22]))(time,year) 52 | 53 | #define TTimeIsValidDate(time,d,m,y) \ 54 | (*(((TMODCALL TBOOL(**)(TAPTR,TINT,TINT,TINT))(time))[-23]))(time,d,m,y) 55 | 56 | #define TTimePackDate(time,db,dt) \ 57 | (*(((TMODCALL TBOOL(**)(TAPTR,struct TDateBox *,TDATE *))(time))[-24]))(time,db,dt) 58 | 59 | #define TTimeUnpackDate(time,dt,db,flg) \ 60 | (*(((TMODCALL void(**)(TAPTR,TDATE *,struct TDateBox *,TUINT))(time))[-25]))(time,dt,db,flg) 61 | 62 | #define TTimeDateToJulian(time,dt) \ 63 | (*(((TMODCALL TDOUBLE(**)(TAPTR,TDATE *))(time))[-26]))(time,dt) 64 | 65 | #define TTimeJulianToDate(time,jd,dt) \ 66 | (*(((TMODCALL void(**)(TAPTR,TDOUBLE,TDATE *))(time))[-27]))(time,jd,dt) 67 | 68 | #define TTimeMYToJulian(time,m,y) \ 69 | (*(((TMODCALL TDOUBLE(**)(TAPTR,TINT,TINT))(time))[-28]))(time,m,y) 70 | 71 | #define TTimeJulianToDMY(time,jd,pd,pm,py) \ 72 | (*(((TMODCALL TDOUBLE(**)(TAPTR,TDOUBLE,TINT *,TINT *,TINT *))(time))[-29]))(time,jd,pd,pm,py) 73 | 74 | #define TTimeYDayToDM(time,yd,y,pd,pm) \ 75 | (*(((TMODCALL void(**)(TAPTR,TINT,TINT,TINT *,TINT *))(time))[-30]))(time,yd,y,pd,pm) 76 | 77 | #define TTimeDMYToYDay(time,d,m,y) \ 78 | (*(((TMODCALL TINT(**)(TAPTR,TINT,TINT,TINT))(time))[-31]))(time,d,m,y) 79 | 80 | #define TTimeGetWeekDay(time,d,m,y) \ 81 | (*(((TMODCALL TINT(**)(TAPTR,TINT,TINT,TINT))(time))[-32]))(time,d,m,y) 82 | 83 | #define TTimeGetWeekNumber(time,d,m,y) \ 84 | (*(((TMODCALL TINT(**)(TAPTR,TINT,TINT,TINT))(time))[-33]))(time,d,m,y) 85 | 86 | #define TTimeDelay(time,req,t) \ 87 | (*(((TMODCALL void(**)(TAPTR,TAPTR,TTIME *))(time))[-34]))(time,req,t) 88 | 89 | #endif /* _TEK_STDCALL_TIME_H */ 90 | -------------------------------------------------------------------------------- /tekui/include/tek/stdcall/visual.h: -------------------------------------------------------------------------------- 1 | #ifndef _TEK_STDCALL_VISUAL_H 2 | #define _TEK_STDCALL_VISUAL_H 3 | 4 | /* 5 | ** $Id: visual.h,v 1.1 2008-06-30 12:34:56 tmueller Exp $ 6 | ** teklib/tek/stdcall/visual.h - visual module interface 7 | ** 8 | ** See copyright notice in teklib/COPYRIGHT 9 | */ 10 | 11 | #define TVisualOpen(visual,tags) \ 12 | (*(((TMODCALL TAPTR(**)(TAPTR,TTAGITEM *))(visual))[-9]))(visual,tags) 13 | 14 | #define TVisualClose(visual,inst) \ 15 | (*(((TMODCALL TAPTR(**)(TAPTR,TAPTR))(visual))[-10]))(visual,inst) 16 | 17 | #define TVisualAttach(visual,tags) \ 18 | (*(((TMODCALL TAPTR(**)(TAPTR,TTAGITEM *))(visual))[-11]))(visual,tags) 19 | 20 | #define TVisualOpenFont(visual,tags) \ 21 | (*(((TMODCALL TAPTR(**)(TAPTR,TTAGITEM *))(visual))[-12]))(visual,tags) 22 | 23 | #define TVisualCloseFont(visual,font) \ 24 | (*(((TMODCALL void(**)(TAPTR,TAPTR))(visual))[-13]))(visual,font) 25 | 26 | #define TVisualGetFontAttrs(visual,font,tags) \ 27 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR,TTAGITEM *))(visual))[-14]))(visual,font,tags) 28 | 29 | #define TVisualTextSize(visual,font,text) \ 30 | (*(((TMODCALL TINT(**)(TAPTR,TAPTR,TSTRPTR))(visual))[-15]))(visual,font,text) 31 | 32 | #define TVisualQueryFonts(visual,tags) \ 33 | (*(((TMODCALL TAPTR(**)(TAPTR,TTAGITEM *))(visual))[-16]))(visual,tags) 34 | 35 | #define TVisualGetNextFont(visual,fqhandle) \ 36 | (*(((TMODCALL TTAGITEM *(**)(TAPTR,TAPTR))(visual))[-17]))(visual,fqhandle) 37 | 38 | #define TVisualGetPort(visual) \ 39 | (*(((TMODCALL TAPTR(**)(TAPTR))(visual))[-18]))(visual) 40 | 41 | #define TVisualSetInput(visual,clearflags,setflags) \ 42 | (*(((TMODCALL TUINT(**)(TAPTR,TUINT,TUINT))(visual))[-19]))(visual,clearflags,setflags) 43 | 44 | #define TVisualGetAttrs(visual,tags) \ 45 | (*(((TMODCALL TUINT(**)(TAPTR,TTAGITEM *))(visual))[-20]))(visual,tags) 46 | 47 | #define TVisualSetAttrs(visual,tags) \ 48 | (*(((TMODCALL TUINT(**)(TAPTR,TTAGITEM *))(visual))[-21]))(visual,tags) 49 | 50 | #define TVisualAllocPen(visual,rgb) \ 51 | (*(((TMODCALL TVPEN(**)(TAPTR,TUINT))(visual))[-22]))(visual,rgb) 52 | 53 | #define TVisualFreePen(visual,pen) \ 54 | (*(((TMODCALL void(**)(TAPTR,TVPEN))(visual))[-23]))(visual,pen) 55 | 56 | #define TVisualSetFont(visual,font) \ 57 | (*(((TMODCALL void(**)(TAPTR,TAPTR))(visual))[-24]))(visual,font) 58 | 59 | #define TVisualClear(visual,pen) \ 60 | (*(((TMODCALL void(**)(TAPTR,TVPEN))(visual))[-25]))(visual,pen) 61 | 62 | #define TVisualRect(visual,x,y,w,h,pen) \ 63 | (*(((TMODCALL void(**)(TAPTR,TINT,TINT,TINT,TINT,TVPEN))(visual))[-26]))(visual,x,y,w,h,pen) 64 | 65 | #define TVisualFRect(visual,x,y,w,h,pen) \ 66 | (*(((TMODCALL void(**)(TAPTR,TINT,TINT,TINT,TINT,TVPEN))(visual))[-27]))(visual,x,y,w,h,pen) 67 | 68 | #define TVisualLine(visual,x1,y1,x2,y2,pen) \ 69 | (*(((TMODCALL void(**)(TAPTR,TINT,TINT,TINT,TINT,TVPEN))(visual))[-28]))(visual,x1,y1,x2,y2,pen) 70 | 71 | #define TVisualPlot(visual,x,y,pen) \ 72 | (*(((TMODCALL void(**)(TAPTR,TINT,TINT,TVPEN))(visual))[-29]))(visual,x,y,pen) 73 | 74 | #define TVisualText(visual,x,y,text,len,fg,bg) \ 75 | (*(((TMODCALL void(**)(TAPTR,TINT,TINT,TSTRPTR,TINT,TVPEN,TVPEN))(visual))[-30]))(visual,x,y,text,len,fg,bg) 76 | 77 | #define TVisualDrawStrip(visual,array,num,tags) \ 78 | (*(((TMODCALL void(**)(TAPTR,TINT *,TINT,TTAGITEM *))(visual))[-31]))(visual,array,num,tags) 79 | 80 | #define TVisualDrawTags(visual,tags) \ 81 | (*(((TMODCALL void(**)(TAPTR,TTAGITEM *))(visual))[-32]))(visual,tags) 82 | 83 | #define TVisualDrawFan(visual,array,num,tags) \ 84 | (*(((TMODCALL void(**)(TAPTR,TINT *,TINT,TTAGITEM *))(visual))[-33]))(visual,array,num,tags) 85 | 86 | #define TVisualDrawArc(visual,x,y,w,h,angle1,angle2,pen) \ 87 | (*(((TMODCALL void(**)(TAPTR,TINT,TINT,TINT,TINT,TINT,TINT,TVPEN))(visual))[-34]))(visual,x,y,w,h,angle1,angle2,pen) 88 | 89 | #define TVisualCopyArea(visual,x,y,w,h,dx,dy,tags) \ 90 | (*(((TMODCALL void(**)(TAPTR,TINT,TINT,TINT,TINT,TINT,TINT,TTAGITEM *))(visual))[-35]))(visual,x,y,w,h,dx,dy,tags) 91 | 92 | #define TVisualSetClipRect(visual,x,y,w,h,tags) \ 93 | (*(((TMODCALL void(**)(TAPTR,TINT,TINT,TINT,TINT,TTAGITEM *))(visual))[-36]))(visual,x,y,w,h,tags) 94 | 95 | #define TVisualOpenDisplay(visual,tags) \ 96 | (*(((TMODCALL TAPTR(**)(TAPTR,TTAGITEM *))(visual))[-37]))(visual,tags) 97 | 98 | #define TVisualCloseDisplay(visual,display) \ 99 | (*(((TMODCALL void(**)(TAPTR,TAPTR))(visual))[-38]))(visual,display) 100 | 101 | #define TVisualQueryDisplays(visual,tags) \ 102 | (*(((TMODCALL TAPTR(**)(TAPTR,TTAGITEM *))(visual))[-39]))(visual,tags) 103 | 104 | #define TVisualGetNextDisplay(visual,handle) \ 105 | (*(((TMODCALL TTAGITEM *(**)(TAPTR,TAPTR))(visual))[-40]))(visual,handle) 106 | 107 | #define TVisualUnsetClipRect(visual) \ 108 | (*(((TMODCALL void(**)(TAPTR))(visual))[-41]))(visual) 109 | 110 | #define TVisualDrawFArc(visual,x,y,w,h,angle1,angle2,pen) \ 111 | (*(((TMODCALL void(**)(TAPTR,TINT,TINT,TINT,TINT,TINT,TINT,TVPEN))(visual))[-42]))(visual,x,y,w,h,angle1,angle2,pen) 112 | 113 | #define TVisualDrawBuffer(visual,x,y,buf,w,h,totw,tags) \ 114 | (*(((TMODCALL void(**)(TAPTR,TINT,TINT,TAPTR,TINT,TINT,TINT,TTAGITEM *))(visual))[-43]))(visual,x,y,buf,w,h,totw,tags) 115 | 116 | #endif /* _TEK_STDCALL_VISUAL_H */ 117 | -------------------------------------------------------------------------------- /tekui/include/tek/teklib.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEKLIB_H 3 | #define _TEKLIB_H 4 | 5 | /* 6 | ** $Id: teklib.h,v 1.1 2008-06-30 12:34:46 tmueller Exp $ 7 | ** teklib/tek/teklib.h - Link library functions for bootstrapping 8 | ** and for operating on elementary, public data structures 9 | ** 10 | ** Written by Timm S. Mueller 11 | ** See copyright notice in teklib/COPYRIGHT 12 | */ 13 | 14 | /*****************************************************************************/ 15 | 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | TLIBAPI TAPTR TEKCreate(TTAGITEM *tags); 24 | TLIBAPI void TDestroy(TAPTR handle); 25 | TLIBAPI void TDestroyList(struct TList *list); 26 | TLIBAPI TAPTR TNewInstance(TAPTR mod, TUINT possize, TUINT negsize); 27 | TLIBAPI void TFreeInstance(TAPTR mod); 28 | TLIBAPI void TInitVectors(TAPTR mod, const TMFPTR *vectors, TUINT numv); 29 | TLIBAPI TTAG TGetTag(TTAGITEM *taglist, TUINT tag, TTAG defvalue); 30 | TLIBAPI void TInitList(struct TList *list); 31 | TLIBAPI void TAddHead(struct TList *list, struct TNode *node); 32 | TLIBAPI void TAddTail(struct TList *list, struct TNode *node); 33 | TLIBAPI struct TNode *TRemHead(struct TList *list); 34 | TLIBAPI struct TNode *TRemTail(struct TList *list); 35 | TLIBAPI void TRemove(struct TNode *node); 36 | TLIBAPI void TNodeUp(struct TNode *node); 37 | TLIBAPI void TInsert(struct TList *list, struct TNode *node, 38 | struct TNode *prednode); 39 | TLIBAPI TBOOL TForEachTag(struct TTagItem *taglist, struct THook *hook); 40 | TLIBAPI struct THandle *TFindHandle(struct TList *list, TSTRPTR s2); 41 | TLIBAPI void TInitHook(struct THook *hook, THOOKFUNC func, TAPTR data); 42 | TLIBAPI TTAG TCallHookPkt(struct THook *hook, TAPTR obj, TTAG msg); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /tekui/include/tek/type.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_TYPE_H 3 | #define _TEK_TYPE_H 4 | 5 | /* 6 | ** $Id: type.h,v 1.1 2008-06-30 12:34:47 tmueller Exp $ 7 | ** teklib/tek/type.h - Basic types, constants, macros 8 | ** 9 | ** Written by Timm S. Mueller 10 | ** See copyright notice in teklib/COPYRIGHT 11 | */ 12 | 13 | #include 14 | 15 | /*****************************************************************************/ 16 | /* 17 | ** Aliased types 18 | */ 19 | 20 | /* 32bit signed integer: */ 21 | typedef TINT32 TINT; 22 | /* 32bit unsigned integer: */ 23 | typedef TUINT32 TUINT; 24 | /* Boolean: */ 25 | typedef TUINT TBOOL; 26 | /* Tag type; integers and pointers: */ 27 | typedef TINTPTR TTAG; 28 | /* Size type: */ 29 | typedef TINTPTR TSIZE; 30 | /* Stringptr type: */ 31 | typedef TCHR * TSTRPTR; 32 | 33 | /* Module function pointer type: */ 34 | typedef TMODCALL TINT (*TMFPTR)(TAPTR); 35 | 36 | /*****************************************************************************/ 37 | /* 38 | ** TagItem - key, value pair 39 | */ 40 | 41 | struct TTagItem 42 | { 43 | /* Tag identifier: */ 44 | TUINT tti_Tag; 45 | /* Tag value item: */ 46 | TTAG tti_Value; 47 | }; 48 | 49 | typedef struct TTagItem TTAGITEM; 50 | 51 | /* User tag item */ 52 | #define TTAG_USER 0x80000000 53 | /* Taglist ends with this item */ 54 | #define TTAG_DONE 0x00000000 55 | /* This item is being ignored */ 56 | #define TTAG_IGNORE 0x00000001 57 | /* List continues at tti_Value */ 58 | #define TTAG_MORE 0x00000002 59 | /* Skip this plus tti_Value items */ 60 | #define TTAG_SKIP 0x00000003 61 | /* Traverse sublist in tti_Value */ 62 | #define TTAG_GOSUB 0x00000004 63 | 64 | /*****************************************************************************/ 65 | /* 66 | ** Constants 67 | */ 68 | 69 | #define TNULL 0 70 | #define TTRUE 1 71 | #define TFALSE 0 72 | #define TPI (3.14159265358979323846) 73 | 74 | /*****************************************************************************/ 75 | /* 76 | ** Macros 77 | */ 78 | 79 | #define TABS(a) ((a) > 0 ? (a) : -(a)) 80 | #define TMIN(a,b) ((a) < (b) ? (a) : (b)) 81 | #define TMAX(a,b) ((a) > (b) ? (a) : (b)) 82 | #define TCLAMP(min,x,max) ((x) > (max) ? (max) : ((x) < (min) ? (min) : (x))) 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /tekui/src/Makefile: -------------------------------------------------------------------------------- 1 | 2 | BASEDIR ?= .. 3 | include $(BASEDIR)/config 4 | 5 | all: libs 6 | clean libs: 7 | cd teklib && $(MAKE) $@ 8 | cd hal && $(MAKE) $@ 9 | cd exec && $(MAKE) $@ 10 | cd time && $(MAKE) $@ 11 | cd visual && $(MAKE) $@ 12 | cd display_x11 && $(MAKE) $@ 13 | # cd display_dfb && $(MAKE) $@ 14 | -------------------------------------------------------------------------------- /tekui/src/display_dfb/Makefile: -------------------------------------------------------------------------------- 1 | 2 | BASEDIR ?= ../.. 3 | include $(BASEDIR)/config 4 | 5 | EXTRADEFS += $(DFB_DEFS) -DFNT_DEFDIR=\"$(LUA_SHARE)/tek/ui/font/\" \ 6 | -DCUR_DEFFILE=\"$(LUA_SHARE)/tek/ui/cursor/cursor-green.png\" 7 | 8 | ############################################################################### 9 | 10 | LIBS = \ 11 | $(LIBDIR)/libdisplay_dfb.a 12 | 13 | $(OBJDIR)/display_dfb_mod.lo: \ 14 | display_dfb_mod.c display_dfb_mod.h 15 | $(CC) $(LIBCFLAGS) -o $@ -c display_dfb_mod.c 16 | $(OBJDIR)/display_dfb_api.lo: \ 17 | display_dfb_api.c display_dfb_mod.h 18 | $(CC) $(LIBCFLAGS) -o $@ -c display_dfb_api.c 19 | $(OBJDIR)/display_dfb_font.lo: \ 20 | display_dfb_font.c display_dfb_mod.h 21 | $(CC) $(LIBCFLAGS) -o $@ -c display_dfb_font.c 22 | $(OBJDIR)/display_dfb_utf8.lo: \ 23 | display_dfb_utf8.c display_dfb_mod.h 24 | $(CC) $(LIBCFLAGS) -o $@ -c display_dfb_utf8.c 25 | 26 | $(LIBDIR)/libdisplay_dfb.a: \ 27 | $(OBJDIR)/display_dfb_mod.lo $(OBJDIR)/display_dfb_api.lo \ 28 | $(OBJDIR)/display_dfb_font.lo $(OBJDIR)/display_dfb_utf8.lo 29 | $(AR) $@ $? 30 | 31 | ############################################################################### 32 | 33 | libs: $(LIBDIR) $(OBJDIR) $(LIBS) 34 | 35 | clean: FORCE 36 | -$(RM) $(MODS) $(TOOLS) $(LIBS) 37 | -$(RMDIR) $(OBJDIR) 38 | -------------------------------------------------------------------------------- /tekui/src/display_x11/Makefile: -------------------------------------------------------------------------------- 1 | 2 | BASEDIR ?= ../.. 3 | include $(BASEDIR)/config 4 | 5 | EXTRADEFS += $(X11_DEFS) 6 | 7 | ############################################################################### 8 | 9 | LIBS = \ 10 | $(LIBDIR)/libdisplay_x11.a 11 | 12 | $(OBJDIR)/display_x11_mod.lo: \ 13 | display_x11_mod.c display_x11_mod.h 14 | $(CC) $(LIBCFLAGS) -o $@ -c display_x11_mod.c 15 | $(OBJDIR)/display_x11_api.lo: \ 16 | display_x11_api.c display_x11_mod.h 17 | $(CC) $(LIBCFLAGS) -o $@ -c display_x11_api.c 18 | $(OBJDIR)/display_x11_inst.lo: \ 19 | display_x11_inst.c display_x11_mod.h 20 | $(CC) $(LIBCFLAGS) -o $@ -c display_x11_inst.c 21 | $(OBJDIR)/display_x11_font.lo: \ 22 | display_x11_font.c display_x11_mod.h 23 | $(CC) $(LIBCFLAGS) -o $@ -c display_x11_font.c 24 | $(OBJDIR)/display_x11_utf8.lo: \ 25 | display_x11_utf8.c display_x11_mod.h 26 | $(CC) $(LIBCFLAGS) -o $@ -c display_x11_utf8.c 27 | 28 | $(LIBDIR)/libdisplay_x11.a: \ 29 | $(OBJDIR)/display_x11_mod.lo $(OBJDIR)/display_x11_api.lo \ 30 | $(OBJDIR)/display_x11_inst.lo $(OBJDIR)/display_x11_font.lo \ 31 | $(OBJDIR)/display_x11_utf8.lo 32 | $(AR) $@ $? 33 | 34 | ############################################################################### 35 | 36 | libs: $(LIBDIR) $(OBJDIR) $(LIBS) 37 | 38 | clean: FORCE 39 | -$(RM) $(MODS) $(TOOLS) $(LIBS) 40 | -$(RMDIR) $(OBJDIR) 41 | -------------------------------------------------------------------------------- /tekui/src/display_x11/display_x11_mod.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | ** teklib/src/visual/x11/display_x11_mod.c - X11 Display driver 4 | ** Written by Timm S. Mueller 5 | ** See copyright notice in teklib/COPYRIGHT 6 | */ 7 | 8 | #include "display_x11_mod.h" 9 | 10 | static TAPTR x11_modopen(TMOD_X11 *mod, TTAGITEM *tags); 11 | static void x11_modclose(TMOD_X11 *mod); 12 | static TMODAPI void x11_beginio(TMOD_X11 *mod, struct TVRequest *req); 13 | static TMODAPI TINT x11_abortio(TMOD_X11 *mod, struct TVRequest *req); 14 | static TMODAPI struct TVRequest *x11_allocreq(TMOD_X11 *mod); 15 | static TMODAPI void x11_freereq(TMOD_X11 *mod, struct TVRequest *req); 16 | 17 | static const TMFPTR 18 | x11_vectors[X11DISPLAY_NUMVECTORS] = 19 | { 20 | (TMFPTR) TNULL, 21 | (TMFPTR) TNULL, 22 | (TMFPTR) x11_beginio, 23 | (TMFPTR) x11_abortio, 24 | (TMFPTR) TNULL, 25 | (TMFPTR) TNULL, 26 | (TMFPTR) TNULL, 27 | (TMFPTR) TNULL, 28 | 29 | (TMFPTR) x11_allocreq, 30 | (TMFPTR) x11_freereq, 31 | }; 32 | 33 | static void 34 | x11_destroy(TMOD_X11 *mod) 35 | { 36 | TDBPRINTF(TDB_TRACE,("X11 module destroy...\n")); 37 | TDestroy(mod->x11_Lock); 38 | } 39 | 40 | static THOOKENTRY TTAG 41 | x11_dispatch(struct THook *hook, TAPTR obj, TTAG msg) 42 | { 43 | TMOD_X11 *mod = (TMOD_X11 *) hook->thk_Data; 44 | switch (msg) 45 | { 46 | case TMSG_DESTROY: 47 | x11_destroy(mod); 48 | break; 49 | case TMSG_OPENMODULE: 50 | return (TTAG) x11_modopen(mod, obj); 51 | case TMSG_CLOSEMODULE: 52 | x11_modclose(obj); 53 | } 54 | return 0; 55 | } 56 | 57 | TMODENTRY TUINT 58 | tek_init_display_x11(TAPTR task, struct TModule *vis, TUINT16 version, 59 | TTAGITEM *tags) 60 | { 61 | TMOD_X11 *mod = (TMOD_X11 *) vis; 62 | if (mod == TNULL) 63 | { 64 | if (version == 0xffff) 65 | return sizeof(TAPTR) * X11DISPLAY_NUMVECTORS; 66 | 67 | if (version <= X11DISPLAY_VERSION) 68 | return sizeof(TMOD_X11); 69 | 70 | return 0; 71 | } 72 | 73 | for (;;) 74 | { 75 | mod->x11_ExecBase = TGetExecBase(mod); 76 | mod->x11_Lock = TExecCreateLock(mod->x11_ExecBase, TNULL); 77 | if (mod->x11_Lock == TNULL) break; 78 | 79 | mod->x11_Module.tmd_Version = X11DISPLAY_VERSION; 80 | mod->x11_Module.tmd_Revision = X11DISPLAY_REVISION; 81 | mod->x11_Module.tmd_Handle.thn_Hook.thk_Entry = x11_dispatch; 82 | mod->x11_Module.tmd_Flags = TMODF_VECTORTABLE | TMODF_OPENCLOSE; 83 | TInitVectors(mod, x11_vectors, X11DISPLAY_NUMVECTORS); 84 | return TTRUE; 85 | } 86 | 87 | x11_destroy(mod); 88 | return TFALSE; 89 | } 90 | 91 | /*****************************************************************************/ 92 | /* 93 | ** Module open/close 94 | */ 95 | 96 | static TAPTR x11_modopen(TMOD_X11 *mod, TTAGITEM *tags) 97 | { 98 | TBOOL success = TTRUE; 99 | TExecLock(mod->x11_ExecBase, mod->x11_Lock); 100 | if (mod->x11_RefCount == 0) 101 | success = x11_init(mod, tags); 102 | if (success) 103 | mod->x11_RefCount++; 104 | TExecUnlock(mod->x11_ExecBase, mod->x11_Lock); 105 | if (success) 106 | return mod; 107 | return TNULL; 108 | } 109 | 110 | static void 111 | x11_modclose(TMOD_X11 *mod) 112 | { 113 | TDBPRINTF(TDB_TRACE,("Device close\n")); 114 | TExecLock(mod->x11_ExecBase, mod->x11_Lock); 115 | if (--mod->x11_RefCount == 0) 116 | x11_exit(mod); 117 | TExecUnlock(mod->x11_ExecBase, mod->x11_Lock); 118 | } 119 | 120 | /*****************************************************************************/ 121 | /* 122 | ** BeginIO/AbortIO 123 | */ 124 | 125 | static TMODAPI void 126 | x11_beginio(TMOD_X11 *mod, struct TVRequest *req) 127 | { 128 | TExecPutMsg(mod->x11_ExecBase, mod->x11_CmdPort, 129 | req->tvr_Req.io_ReplyPort, req); 130 | x11_wake(mod); 131 | } 132 | 133 | static TMODAPI TINT 134 | x11_abortio(TMOD_X11 *mod, struct TVRequest *req) 135 | { 136 | /* not supported: */ 137 | return -1; 138 | } 139 | 140 | /*****************************************************************************/ 141 | /* 142 | ** AllocReq/FreeReq 143 | */ 144 | 145 | static TMODAPI struct TVRequest * 146 | x11_allocreq(TMOD_X11 *mod) 147 | { 148 | struct TVRequest *req = TExecAllocMsg(mod->x11_ExecBase, 149 | sizeof(struct TVRequest)); 150 | if (req) 151 | req->tvr_Req.io_Device = (struct TModule *) mod; 152 | return req; 153 | } 154 | 155 | static TMODAPI void 156 | x11_freereq(TMOD_X11 *mod, struct TVRequest *req) 157 | { 158 | TExecFree(mod->x11_ExecBase, req); 159 | } 160 | -------------------------------------------------------------------------------- /tekui/src/exec/Makefile: -------------------------------------------------------------------------------- 1 | 2 | BASEDIR ?= ../.. 3 | include $(BASEDIR)/config 4 | 5 | ############################################################################### 6 | 7 | LIBS = \ 8 | $(LIBDIR)/libexec.a 9 | 10 | $(OBJDIR)/exec_mod.lo: \ 11 | exec_mod.c exec_mod.h $(INCDIR)/tek/mod/exec.h 12 | $(CC) $(LIBCFLAGS) -o $@ -c exec_mod.c 13 | $(OBJDIR)/exec_api.lo: \ 14 | exec_api.c exec_mod.h $(INCDIR)/tek/mod/exec.h 15 | $(CC) $(LIBCFLAGS) -o $@ -c exec_api.c 16 | $(OBJDIR)/exec_doexec.lo: \ 17 | exec_doexec.c exec_mod.h $(INCDIR)/tek/mod/exec.h 18 | $(CC) $(LIBCFLAGS) -o $@ -c exec_doexec.c 19 | $(OBJDIR)/exec_memory.lo: \ 20 | exec_memory.c exec_mod.h $(INCDIR)/tek/mod/exec.h 21 | $(CC) $(LIBCFLAGS) -o $@ -c exec_memory.c 22 | 23 | $(LIBDIR)/libexec.a: \ 24 | $(OBJDIR)/exec_mod.lo $(OBJDIR)/exec_api.lo $(OBJDIR)/exec_doexec.lo \ 25 | $(OBJDIR)/exec_memory.lo 26 | $(AR) $@ $? 27 | 28 | ############################################################################### 29 | 30 | libs: $(LIBDIR) $(OBJDIR) $(LIBS) 31 | 32 | clean: FORCE 33 | -$(RM) $(MODS) $(TOOLS) $(LIBS) 34 | -$(RMDIR) $(OBJDIR) 35 | -------------------------------------------------------------------------------- /tekui/src/hal/Makefile: -------------------------------------------------------------------------------- 1 | 2 | BASEDIR ?= ../.. 3 | include $(BASEDIR)/config 4 | 5 | ############################################################################### 6 | 7 | LIBS = \ 8 | $(LIBDIR)/libhal.a 9 | 10 | $(OBJDIR)/hal_mod.lo: hal_mod.c hal_mod.h $(INCDIR)/tek/mod/hal.h 11 | $(CC) $(LIBCFLAGS) -o $@ -c hal_mod.c 12 | $(OBJDIR)/hal.lo: $(PLATFORM)/hal.c hal_mod.h $(INCDIR)/tek/mod/hal.h 13 | $(CC) $(LIBCFLAGS) -o $@ -c $(PLATFORM)/hal.c 14 | 15 | $(LIBDIR)/libhal.a: \ 16 | $(OBJDIR)/hal_mod.lo $(OBJDIR)/hal.lo 17 | $(AR) $@ $? 18 | 19 | ############################################################################### 20 | 21 | libs: $(LIBDIR) $(OBJDIR) $(LIBS) 22 | 23 | clean: FORCE 24 | -$(RM) $(MODS) $(TOOLS) $(LIBS) 25 | -$(RMDIR) $(OBJDIR) 26 | -------------------------------------------------------------------------------- /tekui/src/hal/hal_mod.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_HAL_HAL_MOD_H 3 | #define _TEK_HAL_HAL_MOD_H 4 | 5 | /* 6 | ** $Id: hal_mod.h,v 1.1 2008-06-30 12:34:04 tmueller Exp $ 7 | ** teklib/mods/hal/hal_mod.h - HAL module internal definitions 8 | ** 9 | ** Written by Timm S. Mueller 10 | ** See copyright notice in teklib/COPYRIGHT 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #ifndef LOCAL 19 | #define LOCAL 20 | #endif 21 | 22 | #ifndef EXPORT 23 | #define EXPORT TMODAPI 24 | #endif 25 | 26 | /*****************************************************************************/ 27 | /* 28 | ** HAL module structure 29 | */ 30 | 31 | typedef struct 32 | { 33 | /* Module header */ 34 | struct TModule hmb_Module; 35 | /* Ptr to platform-specific data */ 36 | TAPTR hmb_Specific; 37 | /* Ptr to boot handle */ 38 | TAPTR hmb_BootHnd; 39 | } TMOD_HAL; 40 | 41 | /*****************************************************************************/ 42 | /* 43 | ** internal prototypes 44 | */ 45 | 46 | LOCAL TBOOL hal_init(TMOD_HAL *hal, TTAGITEM *tags); 47 | LOCAL void hal_exit(TMOD_HAL *hal); 48 | 49 | LOCAL TAPTR hal_allocself(TAPTR boot, TUINT size); 50 | LOCAL void hal_freeself(TAPTR boot, TAPTR mem, TUINT size); 51 | 52 | LOCAL struct TTimeRequest *hal_open(TMOD_HAL *hal, TAPTR task, TTAGITEM *tags); 53 | LOCAL void hal_close(TMOD_HAL *hal, TAPTR task); 54 | 55 | LOCAL void hal_subtime(TTIME *a, TTIME *b); 56 | LOCAL void hal_addtime(TTIME *a, TTIME *b); 57 | LOCAL TINT hal_cmptime(TTIME *a, TTIME *b); 58 | 59 | /*****************************************************************************/ 60 | /* 61 | ** API prototypes 62 | */ 63 | 64 | EXPORT void hal_beginio(TMOD_HAL *hal, struct TTimeRequest *req); 65 | EXPORT TINT hal_abortio(TMOD_HAL *hal, struct TTimeRequest *req); 66 | 67 | EXPORT TAPTR hal_alloc(TMOD_HAL *hal, TUINT size); 68 | EXPORT void hal_free(TMOD_HAL *hal, TAPTR mem, TUINT size); 69 | EXPORT TAPTR hal_realloc(TMOD_HAL *hal, TAPTR mem, TUINT oldsize, 70 | TUINT newsize); 71 | EXPORT void hal_copymem(TMOD_HAL *hal, TAPTR from, TAPTR to, TUINT numbytes); 72 | EXPORT void hal_fillmem(TMOD_HAL *hal, TAPTR dest, TUINT numbytes, 73 | TUINT8 fillval); 74 | EXPORT TBOOL hal_initlock(TMOD_HAL *hal, THALO *lock); 75 | EXPORT void hal_destroylock(TMOD_HAL *hal, THALO *lock); 76 | EXPORT void hal_lock(TMOD_HAL *hal, THALO *lock); 77 | EXPORT void hal_unlock(TMOD_HAL *hal, THALO *lock); 78 | EXPORT TBOOL hal_initthread(TMOD_HAL *hal, THALO *thread, 79 | TTASKENTRY void (*function)(TAPTR task), TAPTR data); 80 | EXPORT void hal_destroythread(TMOD_HAL *hal, THALO *thread); 81 | EXPORT TAPTR hal_findself(TMOD_HAL *hal); 82 | EXPORT TAPTR hal_loadmodule(TMOD_HAL *hal, TSTRPTR name, TUINT16 version, 83 | TUINT *psize, TUINT *nsize); 84 | EXPORT TBOOL hal_callmodule(TMOD_HAL *hal, TAPTR halmod, TAPTR task, 85 | TAPTR mod); 86 | EXPORT void hal_unloadmodule(TMOD_HAL *hal, TAPTR halmod); 87 | 88 | EXPORT TBOOL hal_scanmodules(TMOD_HAL *hal, TSTRPTR path, struct THook *hook); 89 | EXPORT TTAG hal_getattr(TMOD_HAL *hal, TUINT tag, TTAG defval); 90 | EXPORT TUINT hal_wait(TMOD_HAL *hal, TUINT signals); 91 | EXPORT void hal_signal(TMOD_HAL *hal, THALO *thread, TUINT signals); 92 | EXPORT TUINT hal_setsignal(TMOD_HAL *hal, TUINT newsig, TUINT sigmask); 93 | EXPORT void hal_getsystime(TMOD_HAL *hal, TTIME *time); 94 | 95 | EXPORT TDOUBLE hal_datetojulian(TMOD_HAL *hal, TDATE *date); 96 | EXPORT void hal_juliantodate(TMOD_HAL *hal, TDOUBLE jd, TDATE *date); 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /tekui/src/teklib/Makefile: -------------------------------------------------------------------------------- 1 | 2 | BASEDIR ?= ../.. 3 | include $(BASEDIR)/config 4 | 5 | ############################################################################### 6 | 7 | LIBS = \ 8 | $(LIBDIR)/libtekdebug.a \ 9 | $(LIBDIR)/libtekc.a \ 10 | $(LIBDIR)/libtek.a 11 | 12 | $(OBJDIR)/init.lo: init.c $(INCDIR)/tek/lib/init.h 13 | $(CC) $(LIBCFLAGS) -o $@ -c init.c 14 | $(OBJDIR)/teklib.lo: teklib.c 15 | $(CC) $(LIBCFLAGS) -o $@ -c teklib.c 16 | $(OBJDIR)/debug.lo: debug.c 17 | $(CC) $(LIBCFLAGS) -o $@ -c debug.c 18 | $(OBJDIR)/main.lo: $(PLATFORM)/main.c $(INCDIR)/tek/lib/init.h 19 | $(CC) $(LIBCFLAGS) -o $@ -c $(PLATFORM)/main.c 20 | $(OBJDIR)/host.lo: $(PLATFORM)/host.c $(INCDIR)/tek/lib/init.h 21 | $(CC) $(LIBCFLAGS) -o $@ -c $(PLATFORM)/host.c 22 | 23 | $(LIBDIR)/libtekc.a: \ 24 | $(OBJDIR)/init.lo $(OBJDIR)/teklib.lo $(OBJDIR)/host.lo 25 | $(AR) $@ $? 26 | $(LIBDIR)/libtek.a: \ 27 | $(OBJDIR)/teklib.lo 28 | $(AR) $@ $? 29 | $(LIBDIR)/libtekdebug.a: \ 30 | $(OBJDIR)/debug.lo 31 | $(AR) $@ $? 32 | 33 | ############################################################################### 34 | 35 | libs: $(LIBDIR) $(OBJDIR) $(LIBS) 36 | 37 | clean: FORCE 38 | -$(RM) $(MODS) $(TOOLS) $(LIBS) 39 | -$(RMDIR) $(OBJDIR) 40 | -------------------------------------------------------------------------------- /tekui/src/teklib/debug.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | ** $Id: debug.c,v 1.1 2008-06-30 12:34:40 tmueller Exp $ 4 | ** teklib/src/teklib/debug.c - Debug library 5 | ** 6 | ** Written by Timm S. Mueller 7 | ** See copyright notice in teklib/COPYRIGHT 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | TLIBAPI TINT 15 | TDebugPutS(TSTRPTR s) 16 | { 17 | TDEBUG_PLATFORM_PUTS(s); 18 | return 0; 19 | } 20 | 21 | TLIBAPI TINT 22 | TDebugPrintF(TSTRPTR fmt, ...) 23 | { 24 | static char buf[2048]; 25 | TINT numc; 26 | 27 | va_list args; 28 | 29 | va_start(args, fmt); 30 | 31 | numc = vsprintf(buf, fmt, args); 32 | 33 | va_end(args); 34 | 35 | buf[sizeof(buf) - 1] = 0; 36 | 37 | TDEBUG_PLATFORM_PUTS(buf); 38 | 39 | return numc; 40 | } 41 | 42 | TLIBAPI TINT 43 | TDebugFatal(void) 44 | { 45 | TDEBUG_PLATFORM_FATAL(); 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /tekui/src/time/Makefile: -------------------------------------------------------------------------------- 1 | 2 | BASEDIR ?= ../.. 3 | include $(BASEDIR)/config 4 | 5 | ############################################################################### 6 | 7 | LIBS = \ 8 | $(LIBDIR)/libtime.a 9 | 10 | $(OBJDIR)/time_mod.lo: \ 11 | time_mod.c $(INCDIR)/tek/mod/time.h 12 | $(CC) $(LIBCFLAGS) -o $@ -c time_mod.c 13 | 14 | $(LIBDIR)/libtime.a: \ 15 | $(OBJDIR)/time_mod.lo 16 | $(AR) $@ $? 17 | 18 | ############################################################################### 19 | 20 | libs: $(LIBDIR) $(OBJDIR) $(LIBS) 21 | 22 | clean: FORCE 23 | -$(RM) $(MODS) $(TOOLS) $(LIBS) 24 | -$(RMDIR) $(OBJDIR) 25 | -------------------------------------------------------------------------------- /tekui/src/visual/Makefile: -------------------------------------------------------------------------------- 1 | 2 | BASEDIR ?= ../.. 3 | include $(BASEDIR)/config 4 | 5 | ############################################################################### 6 | 7 | LIBS = \ 8 | $(LIBDIR)/libvisual.a 9 | 10 | $(OBJDIR)/visual_mod.lo: \ 11 | visual_mod.c $(INCDIR)/tek/mod/visual.h 12 | $(CC) $(LIBCFLAGS) -o $@ -c visual_mod.c 13 | $(OBJDIR)/visual_api.lo: \ 14 | visual_api.c $(INCDIR)/tek/mod/visual.h 15 | $(CC) $(LIBCFLAGS) -o $@ -c visual_api.c 16 | $(OBJDIR)/visual_hash.lo: \ 17 | visual_hash.c $(INCDIR)/tek/mod/visual.h 18 | $(CC) $(LIBCFLAGS) -o $@ -c visual_hash.c 19 | 20 | $(LIBDIR)/libvisual.a: \ 21 | $(OBJDIR)/visual_mod.lo $(OBJDIR)/visual_api.lo $(OBJDIR)/visual_hash.lo 22 | $(AR) $@ $? 23 | 24 | ############################################################################### 25 | 26 | libs: $(LIBDIR) $(OBJDIR) $(LIBS) 27 | 28 | clean: FORCE 29 | -$(RM) $(MODS) $(TOOLS) $(LIBS) 30 | -$(RMDIR) $(OBJDIR) 31 | -------------------------------------------------------------------------------- /tekui/src/visual/visual_mod.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _TEK_MODS_VISUAL_MOD_H 3 | #define _TEK_MODS_VISUAL_MOD_H 4 | 5 | /* 6 | ** teklib/src/visual/visual_mod.h - Visual module 7 | ** Written by Timm S. Mueller 8 | ** See copyright notice in teklib/COPYRIGHT 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | /*****************************************************************************/ 22 | 23 | #define VISUAL_VERSION 4 24 | #define VISUAL_REVISION 0 25 | #define VISUAL_NUMVECTORS 43 26 | 27 | #ifndef LOCAL 28 | #define LOCAL 29 | #endif 30 | 31 | #ifndef EXPORT 32 | #define EXPORT TMODAPI 33 | #endif 34 | 35 | #define VISUAL_MAXREQPERINSTANCE 64 36 | 37 | /*****************************************************************************/ 38 | 39 | struct vis_Hash; 40 | 41 | struct vis_HashNode 42 | { 43 | struct TNode node; 44 | TSTRPTR key; 45 | TTAG value; 46 | TUINT hash; 47 | }; 48 | 49 | typedef struct 50 | { 51 | /* Module header: */ 52 | struct TModule vis_Module; 53 | /* Exec module base ptr: */ 54 | TAPTR vis_ExecBase; 55 | /* Module global memory manager (thread safe): */ 56 | TAPTR vis_MemMgr; 57 | /* Locking for module base structure: */ 58 | TAPTR vis_Lock; 59 | /* Number of module opens: */ 60 | TAPTR vis_RefCount; 61 | /* Hash of displays: */ 62 | struct vis_Hash *vis_Displays; 63 | 64 | /* Instance-specific (not in base): */ 65 | 66 | struct TVRequest *vis_InitRequest; 67 | /* Display: */ 68 | TAPTR vis_Display; 69 | /* Visual instance ptr from backend: */ 70 | TAPTR vis_Visual; 71 | /* Current set of input types to listen for: */ 72 | TUINT vis_InputMask; 73 | /* Request pool: */ 74 | struct TList vis_ReqPool; 75 | /* Replyport for requests: */ 76 | TAPTR vis_CmdRPort; 77 | /* Port for input messages: */ 78 | TAPTR vis_IMsgPort; 79 | /* List of waiting asynchronous requests: */ 80 | struct TList vis_WaitList; 81 | /* Number of requests allocated so far: */ 82 | TINT vis_NumRequests; 83 | 84 | } TMOD_VIS; 85 | 86 | LOCAL struct vis_Hash *vis_createhash(TMOD_VIS *mod, TAPTR udata); 87 | LOCAL void vis_destroyhash(TMOD_VIS *mod, struct vis_Hash *hash); 88 | LOCAL int vis_puthash(TMOD_VIS *mod, struct vis_Hash *hash, const TSTRPTR key, 89 | TTAG value); 90 | LOCAL int vis_gethash(TMOD_VIS *mod, struct vis_Hash *hash, const TSTRPTR key, 91 | TTAG *valp); 92 | LOCAL int vis_remhash(TMOD_VIS *mod, struct vis_Hash *hash, const TSTRPTR key); 93 | LOCAL TUINT vis_hashtolist(TMOD_VIS *mod, struct vis_Hash *hash, 94 | struct TList *list); 95 | LOCAL void vis_hashunlist(TMOD_VIS *mod, struct vis_Hash *hash); 96 | 97 | /*****************************************************************************/ 98 | 99 | EXPORT TAPTR vis_openvisual(TMOD_VIS *mod, TTAGITEM *tags); 100 | EXPORT void vis_closevisual(TMOD_VIS *mod, TMOD_VIS *inst); 101 | EXPORT TAPTR vis_attach(TMOD_VIS *mod, TTAGITEM *tags); 102 | EXPORT TAPTR vis_openfont(TMOD_VIS *mod, TTAGITEM *tags); 103 | EXPORT void vis_closefont(TMOD_VIS *mod, TAPTR font); 104 | EXPORT TUINT vis_getfattrs(TMOD_VIS *mod, TAPTR font, TTAGITEM *tags); 105 | EXPORT TINT vis_textsize(TMOD_VIS *mod, TAPTR font, TSTRPTR t); 106 | EXPORT TAPTR vis_queryfonts(TMOD_VIS *mod, TTAGITEM *tags); 107 | EXPORT TTAGITEM *vis_getnextfont(TMOD_VIS *mod, TAPTR fqhandle); 108 | 109 | EXPORT TAPTR vis_getport(TMOD_VIS *mod); 110 | EXPORT TUINT vis_setinput(TMOD_VIS *mod, TUINT cmask, TUINT smask); 111 | EXPORT TUINT vis_getattrs(TMOD_VIS *mod, TTAGITEM *tags); 112 | EXPORT TUINT vis_setattrs(TMOD_VIS *mod, TTAGITEM *tags); 113 | EXPORT TVPEN vis_allocpen(TMOD_VIS *mod, TUINT rgb); 114 | EXPORT void vis_freepen(TMOD_VIS *mod, TVPEN pen); 115 | EXPORT void vis_setfont(TMOD_VIS *mod, TAPTR font); 116 | EXPORT void vis_clear(TMOD_VIS *mod, TVPEN pen); 117 | EXPORT void vis_rect(TMOD_VIS *mod, TINT x, TINT y, TINT w, TINT h, TVPEN pen); 118 | EXPORT void vis_frect(TMOD_VIS *mod, TINT x, TINT y, TINT w, TINT h, 119 | TVPEN pen); 120 | EXPORT void vis_line(TMOD_VIS *mod, TINT x1, TINT y1, TINT x2, TINT y2, 121 | TVPEN pen); 122 | EXPORT void vis_plot(TMOD_VIS *mod, TINT x, TINT y, TVPEN pen); 123 | EXPORT void vis_text(TMOD_VIS *mod, TINT x, TINT y, TSTRPTR t, TUINT l, 124 | TVPEN fg, TVPEN bg); 125 | 126 | EXPORT void vis_drawstrip(TMOD_VIS *mod, TINT *array, TINT num, TTAGITEM *tags); 127 | EXPORT void vis_drawtags(TMOD_VIS *mod, TTAGITEM *tags); 128 | EXPORT void vis_drawfan(TMOD_VIS *mod, TINT *array, TINT num, TTAGITEM *tags); 129 | EXPORT void vis_drawarc(TMOD_VIS *mod, TINT x, TINT y, TINT w, TINT h, 130 | TINT angle1, TINT angle2, TVPEN pen); 131 | 132 | EXPORT void vis_copyarea(TMOD_VIS *mod, TINT x, TINT y, TINT w, TINT h, 133 | TINT dx, TINT dy, TTAGITEM *tags); 134 | EXPORT void vis_setcliprect(TMOD_VIS *mod, TINT x, TINT y, TINT w, TINT h, 135 | TTAGITEM *tags); 136 | 137 | EXPORT TAPTR vis_opendisplay(TMOD_VIS *mod, TTAGITEM *tags); 138 | EXPORT void vis_closedisplay(TMOD_VIS *mod, TAPTR display); 139 | EXPORT TAPTR vis_querydisplays(TMOD_VIS *mod, TTAGITEM *tags); 140 | EXPORT TTAGITEM *vis_getnextdisplay(TMOD_VIS *mod, TAPTR dqhandle); 141 | 142 | EXPORT void vis_unsetcliprect(TMOD_VIS *mod); 143 | EXPORT void vis_drawfarc(TMOD_VIS *mod, TINT x, TINT y, TINT w, TINT h, 144 | TINT angle1, TINT angle2, TVPEN pen); 145 | 146 | EXPORT void vis_drawbuffer(TMOD_VIS *inst, 147 | TINT x, TINT y, TAPTR buf, TINT w, TINT h, TINT totw, TTAGITEM *tags); 148 | 149 | #endif 150 | -------------------------------------------------------------------------------- /tekui/tek/Makefile: -------------------------------------------------------------------------------- 1 | 2 | BASEDIR ?= .. 3 | include $(BASEDIR)/config 4 | 5 | ############################################################################### 6 | 7 | LUACLASSES = \ 8 | class/object.lua class/list.lua class/utf8string.lua 9 | 10 | install: 11 | $(INSTALL) -d $(LUA_SHARE)/tek/class 12 | $(INSTALL) class.lua ui.lua $(LUA_SHARE)/tek 13 | $(INSTALL) $(LUACLASSES) $(LUA_SHARE)/tek/class 14 | -------------------------------------------------------------------------------- /tekui/tek/class/example.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | ** example.c 4 | ** Written by Timm S. Mueller 5 | ** See copyright notice in COPYRIGHT 6 | ** 7 | ** Basic setup of a class for the tekUI toolkit written in C 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | /* Name of superclass: */ 15 | #define SUPERCLASS_NAME "tek.class" 16 | 17 | /* Name of this class: */ 18 | #define CLASS_NAME "tek.class.example" 19 | 20 | static const luaL_Reg classfuncs[] = 21 | { 22 | /* insert methods here */ 23 | { NULL, NULL } 24 | }; 25 | 26 | int luaopen_tek_class_example(lua_State *L) 27 | { 28 | lua_getglobal(L, "require"); 29 | /* s: */ 30 | lua_pushliteral(L, SUPERCLASS_NAME); 31 | /* s: , "superclass" */ 32 | lua_call(L, 1, 1); 33 | /* s: superclass */ 34 | lua_pushvalue(L, -1); 35 | /* s: superclass, superclass */ 36 | luaL_register(L, CLASS_NAME, classfuncs); 37 | /* s: superclass, superclass, class */ 38 | lua_call(L, 1, 1); 39 | /* s: superclass, class */ 40 | luaL_newmetatable(L, CLASS_NAME "*"); 41 | /* s: superclass, class, meta */ 42 | lua_getfield(L, -3, "newClass"); 43 | /* s: superclass, class, meta, */ 44 | lua_setfield(L, -2, "__call"); 45 | /* s: superclass, class, meta */ 46 | lua_pushvalue(L, -3); 47 | /* s: superclass, class, meta, superclass */ 48 | lua_setfield(L, -2, "__index"); 49 | /* s: superclass, class, meta */ 50 | lua_setmetatable(L, -2); 51 | /* s: superclass, class */ 52 | lua_pop(L, 2); 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /tekui/tek/class/list.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | -- 3 | -- tek.class.list 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | -- LINEAGE:: 8 | -- [[#ClassOverview]] : 9 | -- [[#tek.class : Class]] / 10 | -- List 11 | -- 12 | -- OVERVIEW:: 13 | -- This class implements a list container. 14 | -- 15 | -- IMPLEMENTS:: 16 | -- - List:addItem() - Adds an item to the list 17 | -- - List:changeItem() - Replaces an item in the list 18 | -- - List:checkPosition() - Verify position in the list 19 | -- - List:getN() - Returns the number of items in the list 20 | -- - List:getItem() - Returns the item at the specified position 21 | -- - List:remItem() - Removes an item from the list 22 | -- 23 | -- OVERRIDES:: 24 | -- - Class.new() 25 | -- 26 | ------------------------------------------------------------------------------- 27 | 28 | local Class = require "tek.class" 29 | local insert = table.insert 30 | local max = math.max 31 | local min = math.min 32 | local remove = table.remove 33 | 34 | module("tek.class.list", tek.class) 35 | _VERSION = "List 1.3" 36 | local List = _M 37 | 38 | ------------------------------------------------------------------------------- 39 | -- Class implementation: 40 | ------------------------------------------------------------------------------- 41 | 42 | function List.new(class, self) 43 | self = self or { } 44 | self.Items = self.Items or { } 45 | return Class.new(class, self) 46 | end 47 | 48 | ------------------------------------------------------------------------------- 49 | -- List:getN(): Returns the number of elements in the list. 50 | ------------------------------------------------------------------------------- 51 | 52 | function List:getN() 53 | return #self.Items 54 | end 55 | 56 | ------------------------------------------------------------------------------- 57 | -- List:getItem(pos): Returns the item at the specified position. 58 | ------------------------------------------------------------------------------- 59 | 60 | function List:getItem(lnr) 61 | return self.Items[lnr] 62 | end 63 | 64 | ------------------------------------------------------------------------------- 65 | -- pos = List:addItem(entry[, pos]): Adds an item to the list, optionally 66 | -- inserting it at the specified position. Returns the position at which the 67 | -- item was added. 68 | ------------------------------------------------------------------------------- 69 | 70 | function List:addItem(entry, lnr) 71 | local numl = self:getN() + 1 72 | if not lnr then 73 | insert(self.Items, entry) 74 | lnr = numl 75 | else 76 | lnr = min(max(1, lnr), numl) 77 | insert(self.Items, lnr, entry) 78 | end 79 | return lnr 80 | end 81 | 82 | ------------------------------------------------------------------------------- 83 | -- item = List:remItem(pos): Removes an item at the specified position 84 | -- in the list. The item is returned to the caller. 85 | ------------------------------------------------------------------------------- 86 | 87 | function List:remItem(lnr) 88 | if lnr > 0 and lnr <= self:getN() then 89 | return remove(self.Items, lnr) 90 | end 91 | end 92 | 93 | ------------------------------------------------------------------------------- 94 | -- success = List:changeItem(entry, pos): Changes the item at the specified 95 | -- position in the list. Returns a boolean indicating whether there was an 96 | -- item changed. 97 | ------------------------------------------------------------------------------- 98 | 99 | function List:changeItem(entry, pos) 100 | local numl = self:getN() 101 | if lnr > 0 and lnr <= numl then 102 | self.Items[lnr] = entry 103 | return true 104 | end 105 | end 106 | 107 | ------------------------------------------------------------------------------- 108 | -- success[, position] = checkPosition(position[, null_valid]) - 109 | -- Verifies that the given position is a valid index in the list; if the 110 | -- optional {{null_valid}} is specified, {{0}} is considered a valid index. 111 | -- If position is past (or before) the valid range, the last (respectively 112 | -- the first) valid index is returned as well. 113 | ------------------------------------------------------------------------------- 114 | 115 | function List:checkPosition(lnr, null_valid) 116 | if lnr == nil then 117 | return false 118 | elseif lnr == 0 then 119 | return null_valid or false, 0 120 | end 121 | local numl = self:getN() 122 | if lnr < 1 then 123 | return false, 1 124 | elseif lnr > numl then 125 | return false, numl 126 | end 127 | return true, lnr 128 | end 129 | -------------------------------------------------------------------------------- /tekui/tek/lib/Makefile: -------------------------------------------------------------------------------- 1 | 2 | BASEDIR ?= ../.. 3 | include $(BASEDIR)/config 4 | 5 | EXTRADEFS += $(LUA_DEFS) -DDISPLAY_DRIVER=\"$(DISPLAY_DRIVER)\" 6 | 7 | ############################################################################### 8 | 9 | MODS = region.so exec.so visual.so 10 | DISPLAYMODS = display/x11.so # display/dfb.so 11 | 12 | EXECLIBS = $(LIBDIR)/libhal.a $(LIBDIR)/libexec.a $(LIBDIR)/libtime.a $(LIBDIR)/libtekc.a $(LIBDIR)/libtekdebug.a 13 | VISUALLIBS = $(LIBDIR)/libvisual.a $(LIBDIR)/libtek.a $(LIBDIR)/libtekdebug.a 14 | DISPLAYX11LIBS = $(LIBDIR)/libdisplay_x11.a $(LIBDIR)/libtek.a $(LIBDIR)/libtekdebug.a 15 | DISPLAYDFBLIBS = $(LIBDIR)/libdisplay_dfb.a $(LIBDIR)/libtek.a $(LIBDIR)/libtekdebug.a 16 | 17 | region.so: $(OBJDIR)/region.lo 18 | $(CC) $(MODCFLAGS) -o $@ $(OBJDIR)/region.lo $(PLATFORM_LIBS) 19 | 20 | exec.so: $(OBJDIR)/exec_lua.lo $(EXECLIBS) 21 | $(CC) $(MODCFLAGS) -o $@ $(OBJDIR)/exec_lua.lo -L$(LIBDIR) -lhal -lexec -ltime -ltekc -ltekdebug $(PLATFORM_LIBS) 22 | 23 | visual.so: $(OBJDIR)/visual_lua.lo $(OBJDIR)/visual_api.lo $(VISUALLIBS) 24 | $(CC) $(MODCFLAGS) -o $@ $(OBJDIR)/visual_lua.lo $(OBJDIR)/visual_api.lo -L$(LIBDIR) -lvisual -ltek -ltekdebug 25 | 26 | display/x11.so: $(OBJDIR)/x11_lua.lo $(DISPLAYX11LIBS) 27 | $(CC) $(MODCFLAGS) -o $@ $(OBJDIR)/x11_lua.lo -L$(LIBDIR) -ldisplay_x11 -ltek -ltekdebug $(X11_LIBS) 28 | 29 | display/dfb.so: $(OBJDIR)/dfb_lua.lo $(DISPLAYDFBLIBS) 30 | $(CC) $(MODCFLAGS) -o $@ $(OBJDIR)/dfb_lua.lo -L$(LIBDIR) -ldisplay_dfb -ltek -ltekdebug $(DFB_LIBS) 31 | 32 | $(OBJDIR)/region.lo: region.c 33 | $(CC) $(LIBCFLAGS) -o $@ -c region.c 34 | 35 | $(OBJDIR)/exec_lua.lo: exec_lua.c 36 | $(CC) $(LIBCFLAGS) -o $@ -c exec_lua.c 37 | 38 | $(OBJDIR)/visual_lua.lo: visual_lua.c 39 | $(CC) $(LIBCFLAGS) -o $@ -c visual_lua.c 40 | $(OBJDIR)/visual_api.lo: visual_api.c 41 | $(CC) $(LIBCFLAGS) -o $@ -c visual_api.c 42 | 43 | $(OBJDIR)/x11_lua.lo: display/x11_lua.c 44 | $(CC) $(LIBCFLAGS) -o $@ -c display/x11_lua.c 45 | 46 | $(OBJDIR)/dfb_lua.lo: display/dfb_lua.c 47 | $(CC) $(LIBCFLAGS) -o $@ -c display/dfb_lua.c 48 | 49 | ############################################################################### 50 | 51 | modules: $(OBJDIR) $(MODS) $(DISPLAYMODS) 52 | 53 | install: 54 | $(INSTALL) -d $(LUA_LIB)/tek/lib/display 55 | $(INSTALL) -s $(MODS) $(LUA_LIB)/tek/lib 56 | $(INSTALL) -s $(DISPLAYMODS) $(LUA_LIB)/tek/lib/display 57 | $(INSTALL) -d $(LUA_SHARE)/tek/lib 58 | $(INSTALL) debug.lua $(LUA_SHARE)/tek/lib 59 | 60 | clean: FORCE 61 | -$(RM) $(MODS) $(DISPLAYMODS) $(LIBS) 62 | -$(RMDIR) $(OBJDIR) 63 | -------------------------------------------------------------------------------- /tekui/tek/lib/debug.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | -- 3 | -- tek.lib.debug 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | -- OVERVIEW:: 8 | -- Debug library - implements debug output and debug levels: 9 | -- 10 | -- 2 || TRACE || used for tracking bugs 11 | -- 4 || INFO || informational messages 12 | -- 5 || WARN || something unexpected happened 13 | -- 10 || ERROR || something went wrong, e.g. resource unavailable 14 | -- 20 || FAIL || something went wrong that can't be coped with 15 | -- 16 | -- The default debug level is 10 {{ERROR}}. To set the debug level 17 | -- globally, e.g.: 18 | -- db = require "tek.lib.debug" 19 | -- db.level = db.INFO 20 | -- 21 | -- The default debug output stream is {{stderr}}. 22 | -- To override it globally, e.g.: 23 | -- db = require "tek.lib.debug" 24 | -- f = io.open("logfile", "w") 25 | -- db.out = function(...) f:write(...) end 26 | -- 27 | -- FUNCTIONS:: 28 | -- - debug.print() - Print a text in the specified debug level 29 | -- - debug.execute() - Execute a function in the specified debug level 30 | -- - debug.trace() - Print a text in the {{TRACE}} debug level 31 | -- - debug.info() - Print a text in the {{INFO}} debug level 32 | -- - debug.warn() - Print a text in the {{WARN}} debug level 33 | -- - debug.error() - Print a text in the {{ERROR}} debug level 34 | -- - debug.fail() - Print a text in the {{FAIL}} debug level 35 | -- - debug.stacktrace() - Print a stacktrace in the specified debug level 36 | -- 37 | ------------------------------------------------------------------------------- 38 | 39 | local debug = require "debug" 40 | local getinfo = debug.getinfo 41 | local traceback = debug.traceback 42 | local stderr = require "io".stderr 43 | local tostring = tostring 44 | local tonumber = tonumber 45 | local type = type 46 | local unpack = unpack 47 | local select = select 48 | local time = os.time 49 | 50 | module "tek.lib.debug" 51 | _VERSION = "Debug 3.0" 52 | 53 | -- symbolic: 54 | 55 | TRACE = 2 56 | INFO = 4 57 | WARN = 5 58 | ERROR = 10 59 | FAIL = 20 60 | 61 | -- global defaults: 62 | 63 | level = ERROR 64 | out = function(...) stderr:write(...) end 65 | 66 | ------------------------------------------------------------------------------- 67 | -- print(lvl, msg, ...): Prints formatted text if the global debug level 68 | -- is less or equal the specified level. 69 | ------------------------------------------------------------------------------- 70 | 71 | function print(lvl, msg, ...) 72 | if level and lvl >= level then 73 | local t = getinfo(3, "lS") 74 | local arg = { } 75 | for i = 1, select('#', ...) do 76 | local v = select(i, ...) 77 | arg[i] = v and type(v) ~= "number" and tostring(v) or v or 0 78 | end 79 | out(("(%02d %d %s:%d) " .. msg):format(lvl, 80 | time(), t.short_src, t.currentline, unpack(arg)) .. "\n") 81 | end 82 | end 83 | 84 | ------------------------------------------------------------------------------- 85 | -- execute(lvl, func, ...): Executes the specified function if the global 86 | -- debug library is less or equal the specified level. 87 | ------------------------------------------------------------------------------- 88 | 89 | function execute(lvl, func, ...) 90 | if level and lvl >= level then 91 | return func(...) 92 | end 93 | end 94 | 95 | ------------------------------------------------------------------------------- 96 | -- trace(msg, ...): Prints formatted debug info with {{TRACE}} level 97 | ------------------------------------------------------------------------------- 98 | function trace(msg, ...) print(2, msg, ...) end 99 | 100 | ------------------------------------------------------------------------------- 101 | -- info(msg, ...): Prints formatted debug info with {{INFO}} level 102 | ------------------------------------------------------------------------------- 103 | function info(msg, ...) print(4, msg, ...) end 104 | 105 | ------------------------------------------------------------------------------- 106 | -- warn(msg, ...): Prints formatted debug info with {{WARN}} level 107 | ------------------------------------------------------------------------------- 108 | function warn(msg, ...) print(5, msg, ...) end 109 | 110 | ------------------------------------------------------------------------------- 111 | -- error(msg, ...): Prints formatted debug info with {{ERROR}} level 112 | ------------------------------------------------------------------------------- 113 | function error(msg, ...) print(10, msg, ...) end 114 | 115 | ------------------------------------------------------------------------------- 116 | -- fail(msg, ...): Prints formatted debug info with {{FAIL}} level 117 | ------------------------------------------------------------------------------- 118 | function fail(msg, ...) print(20, msg, ...) end 119 | 120 | ------------------------------------------------------------------------------- 121 | -- stacktrace(debuglevel, stacklevel): Prints a stacktrace starting at 122 | -- the function of the given {{level}} on the stack (excluding the 123 | -- {{stracktrace}} function itself) if the global debug level is less 124 | -- or equal the specified {{debuglevel}}. 125 | ------------------------------------------------------------------------------- 126 | 127 | function stacktrace(lvl, level) 128 | print(lvl, traceback("", level or 1 + 1)) 129 | end 130 | -------------------------------------------------------------------------------- /tekui/tek/lib/display/dfb_lua.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | ** tek.lib.display.dfb - binding of TEKlib's DirectFB driver to Lua 4 | ** Written by Timm S. Mueller 5 | ** See copyright notice in COPYRIGHT 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #define TEK_LIB_DISPLAY_DFB_CLASSNAME "tek.lib.display.dfb*" 17 | #define TEK_LIB_DISPLAY_DFB_BASECLASSNAME "tek.lib.display.dfb.base*" 18 | 19 | extern TMODENTRY TUINT 20 | tek_init_display_dfb(TAPTR, struct TModule *, TUINT16, TTAGITEM *); 21 | static TCALLBACK TINT tek_lib_display_dfb_close(lua_State *L); 22 | 23 | typedef struct 24 | { 25 | TAPTR Base; 26 | TAPTR ExecBase; 27 | TBOOL IsBase; 28 | 29 | } TEKDisplay; 30 | 31 | static const struct TInitModule initmodules[] = 32 | { 33 | { "display_dfb", tek_init_display_dfb, TNULL, 0 }, 34 | { TNULL } 35 | }; 36 | 37 | static struct TModInitNode im_display = 38 | { 39 | { TNULL, TNULL }, 40 | (struct TInitModule *) initmodules, 41 | TNULL, 42 | }; 43 | 44 | static const luaL_Reg libfuncs[] = 45 | { 46 | { TNULL, TNULL } 47 | }; 48 | 49 | static const luaL_Reg libmethods[] = 50 | { 51 | { "__gc", tek_lib_display_dfb_close }, 52 | { TNULL, TNULL } 53 | }; 54 | 55 | /*****************************************************************************/ 56 | 57 | static TCALLBACK TINT 58 | tek_lib_display_dfb_close(lua_State *L) 59 | { 60 | TEKDisplay *display = luaL_checkudata(L, 1, TEK_LIB_DISPLAY_DFB_CLASSNAME); 61 | TDBPRINTF(TDB_TRACE,("display %08x closing\n", display)); 62 | if (display->IsBase) 63 | { 64 | /* collected base; remove TEKlib module: */ 65 | TExecRemModules(display->ExecBase, 66 | (struct TModInitNode *) &im_display, 0); 67 | TDBPRINTF(TDB_TRACE,("display module removed\n")); 68 | } 69 | return 0; 70 | } 71 | 72 | /*****************************************************************************/ 73 | 74 | int luaopen_tek_lib_display_dfb(lua_State *L) 75 | { 76 | TAPTR exec; 77 | TEKDisplay *display; 78 | 79 | /* require "tek.lib.exec": */ 80 | lua_getglobal(L, "require"); 81 | /* s: "require" */ 82 | lua_pushliteral(L, "tek.lib.exec"); 83 | /* s: "require", "tek.lib.exec" */ 84 | lua_call(L, 1, 1); 85 | /* s: exectab */ 86 | lua_getfield(L, -1, "base"); 87 | /* s: exectab, execbase */ 88 | exec = *(TAPTR *) lua_touserdata(L, -1); 89 | 90 | /* register functions: */ 91 | luaL_register(L, "tek.lib.display.dfb", libfuncs); 92 | /* s: exectab, execbase, libtab */ 93 | 94 | /* create userdata: */ 95 | display = lua_newuserdata(L, sizeof(TEKDisplay)); 96 | /* s: exectab, execbase, libtab, libbase */ 97 | 98 | display->Base = TNULL; 99 | display->ExecBase = exec; 100 | display->IsBase = TTRUE; 101 | 102 | /* register base: */ 103 | lua_pushvalue(L, -1); 104 | /* s: exectab, execbase, libtab, libbase, libbase */ 105 | lua_setfield(L, LUA_REGISTRYINDEX, TEK_LIB_DISPLAY_DFB_BASECLASSNAME); 106 | /* s: exectab, execbase, libtab, libbase */ 107 | 108 | /* create metatable for userdata, register methods: */ 109 | luaL_newmetatable(L, TEK_LIB_DISPLAY_DFB_CLASSNAME); 110 | /* s: exectab, execbase, libtab, libbase, libmeta */ 111 | lua_pushvalue(L, -1); 112 | /* s: exectab, execbase, libtab, libbase, libmeta, libmeta */ 113 | lua_setfield(L, -2, "__index"); 114 | /* s: exectab, execbase, libtab, libbase, libmeta */ 115 | luaL_register(L, NULL, libmethods); 116 | /* s: exectab, execbase, libtab, libbase, libmeta */ 117 | lua_setmetatable(L, -2); 118 | /* s: exectab, execbase, libtab, libbase */ 119 | 120 | /* place exec reference in metatable: */ 121 | lua_getmetatable(L, -1); 122 | /* s: exectab, execbase, libtab, libbase, libmeta */ 123 | lua_pushvalue(L, -4); 124 | /* s: exectab, execbase, libtab, libbase, libmeta, execbase */ 125 | luaL_ref(L, -2); /* index returned is always 1 */ 126 | /* s: exectab, execbase, libtab, libbase, libmeta */ 127 | lua_pop(L, 5); 128 | 129 | /* Add visual module to TEKlib's internal module list: */ 130 | TExecAddModules(exec, (struct TModInitNode *) &im_display, 0); 131 | 132 | return 0; 133 | } 134 | -------------------------------------------------------------------------------- /tekui/tek/lib/display/x11_lua.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | ** tek.lib.display.x11 - binding of TEKlib's X11 driver to Lua 4 | ** Written by Timm S. Mueller 5 | ** See copyright notice in COPYRIGHT 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #define TEK_LIB_DISPLAY_X11_CLASSNAME "tek.lib.display.x11*" 17 | #define TEK_LIB_DISPLAY_X11_BASECLASSNAME "tek.lib.display.x11.base*" 18 | 19 | extern TMODENTRY TUINT 20 | tek_init_display_x11(TAPTR, struct TModule *, TUINT16, TTAGITEM *); 21 | static TCALLBACK TINT tek_lib_display_x11_close(lua_State *L); 22 | 23 | typedef struct 24 | { 25 | TAPTR Base; 26 | TAPTR ExecBase; 27 | TBOOL IsBase; 28 | 29 | } TEKDisplay; 30 | 31 | static const struct TInitModule initmodules[] = 32 | { 33 | { "display_x11", tek_init_display_x11, TNULL, 0 }, 34 | { TNULL } 35 | }; 36 | 37 | static struct TModInitNode im_display = 38 | { 39 | { TNULL, TNULL }, 40 | (struct TInitModule *) initmodules, 41 | TNULL, 42 | }; 43 | 44 | static const luaL_Reg libfuncs[] = 45 | { 46 | { TNULL, TNULL } 47 | }; 48 | 49 | static const luaL_Reg libmethods[] = 50 | { 51 | { "__gc", tek_lib_display_x11_close }, 52 | { TNULL, TNULL } 53 | }; 54 | 55 | /*****************************************************************************/ 56 | 57 | static TCALLBACK TINT 58 | tek_lib_display_x11_close(lua_State *L) 59 | { 60 | TEKDisplay *display = luaL_checkudata(L, 1, TEK_LIB_DISPLAY_X11_CLASSNAME); 61 | TDBPRINTF(TDB_TRACE,("display %08x closing\n", display)); 62 | if (display->IsBase) 63 | { 64 | /* collected base; remove TEKlib module: */ 65 | TExecRemModules(display->ExecBase, 66 | (struct TModInitNode *) &im_display, 0); 67 | TDBPRINTF(TDB_TRACE,("display module removed\n")); 68 | } 69 | return 0; 70 | } 71 | 72 | /*****************************************************************************/ 73 | 74 | int luaopen_tek_lib_display_x11(lua_State *L) 75 | { 76 | TAPTR exec; 77 | TEKDisplay *display; 78 | 79 | /* require "tek.lib.exec": */ 80 | lua_getglobal(L, "require"); 81 | /* s: "require" */ 82 | lua_pushliteral(L, "tek.lib.exec"); 83 | /* s: "require", "tek.lib.exec" */ 84 | lua_call(L, 1, 1); 85 | /* s: exectab */ 86 | lua_getfield(L, -1, "base"); 87 | /* s: exectab, execbase */ 88 | exec = *(TAPTR *) lua_touserdata(L, -1); 89 | 90 | /* register functions: */ 91 | luaL_register(L, "tek.lib.display.x11", libfuncs); 92 | /* s: exectab, execbase, libtab */ 93 | 94 | /* create userdata: */ 95 | display = lua_newuserdata(L, sizeof(TEKDisplay)); 96 | /* s: exectab, execbase, libtab, libbase */ 97 | 98 | display->Base = TNULL; 99 | display->ExecBase = exec; 100 | display->IsBase = TTRUE; 101 | 102 | /* register base: */ 103 | lua_pushvalue(L, -1); 104 | /* s: exectab, execbase, libtab, libbase, libbase */ 105 | lua_setfield(L, LUA_REGISTRYINDEX, TEK_LIB_DISPLAY_X11_BASECLASSNAME); 106 | /* s: exectab, execbase, libtab, libbase */ 107 | 108 | /* create metatable for userdata, register methods: */ 109 | luaL_newmetatable(L, TEK_LIB_DISPLAY_X11_CLASSNAME); 110 | /* s: exectab, execbase, libtab, libbase, libmeta */ 111 | lua_pushvalue(L, -1); 112 | /* s: exectab, execbase, libtab, libbase, libmeta, libmeta */ 113 | lua_setfield(L, -2, "__index"); 114 | /* s: exectab, execbase, libtab, libbase, libmeta */ 115 | luaL_register(L, NULL, libmethods); 116 | /* s: exectab, execbase, libtab, libbase, libmeta */ 117 | lua_setmetatable(L, -2); 118 | /* s: exectab, execbase, libtab, libbase */ 119 | 120 | /* place exec reference in metatable: */ 121 | lua_getmetatable(L, -1); 122 | /* s: exectab, execbase, libtab, libbase, libmeta */ 123 | lua_pushvalue(L, -4); 124 | /* s: exectab, execbase, libtab, libbase, libmeta, execbase */ 125 | luaL_ref(L, -2); /* index returned is always 1 */ 126 | /* s: exectab, execbase, libtab, libbase, libmeta */ 127 | lua_pop(L, 5); 128 | 129 | /* Add visual module to TEKlib's internal module list: */ 130 | TExecAddModules(exec, (struct TModInitNode *) &im_display, 0); 131 | 132 | return 0; 133 | } 134 | -------------------------------------------------------------------------------- /tekui/tek/lib/exec_lua.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | ** tek.lib.exec - binding of TEKlib modules HAL, Exec, Time to Lua 4 | ** Written by Timm S. Mueller 5 | ** See copyright notice in COPYRIGHT 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | static const struct TInitModule initmodules[] = 19 | { 20 | {"hal", tek_init_hal, TNULL, 0}, 21 | {"exec", tek_init_exec, TNULL, 0}, 22 | {"time", tek_init_time, TNULL, 0}, 23 | {TNULL} 24 | }; 25 | 26 | static const luaL_Reg libfuncs[] = 27 | { 28 | {NULL, NULL} 29 | }; 30 | 31 | static int 32 | tek_lib_exec_base_gc(lua_State *L) 33 | { 34 | TAPTR *pexec = luaL_checkudata(L, 1, "tek.lib.exec.base.meta"); 35 | if (*pexec) 36 | { 37 | TAPTR basetask = TExecFindTask(*pexec, TTASKNAME_ENTRY); 38 | TDestroy(basetask); 39 | TDBPRINTF(5,("Exec closed\n")); 40 | *pexec = TNULL; 41 | } 42 | return 0; 43 | } 44 | 45 | int luaopen_tek_lib_exec(lua_State *L) 46 | { 47 | TAPTR *pexec; 48 | TTAGITEM tags[2]; 49 | TAPTR basetask; 50 | 51 | luaL_register(L, "tek.lib.exec", libfuncs); 52 | /* s: libtab */ 53 | 54 | pexec = lua_newuserdata(L, sizeof(TAPTR)); 55 | /* s: libtab, udata */ 56 | *pexec = TNULL; 57 | 58 | luaL_newmetatable(L, "tek.lib.exec.base.meta"); 59 | /* s: libtab, udata, metatable */ 60 | lua_pushliteral(L, "__gc"); 61 | /* s: libtab, udata, metatable, "__gc" */ 62 | lua_pushcfunction(L, tek_lib_exec_base_gc); 63 | /* s: libtab, udata, metatable, "__gc", gcfunc */ 64 | lua_rawset(L, -3); 65 | /* s: libtab, udata, metatable */ 66 | lua_setmetatable(L, -2); 67 | /* s: libtab, udata */ 68 | lua_setfield(L, -2, "base"); 69 | /* s: libtab */ 70 | lua_pop(L, 1); 71 | 72 | tags[0].tti_Tag = TExecBase_ModInit; 73 | tags[0].tti_Value = (TTAG) initmodules; 74 | tags[1].tti_Tag = TTAG_DONE; 75 | 76 | basetask = TEKCreate(tags); 77 | if (basetask == TNULL) 78 | luaL_error(L, "Failed to initialize TEKlib"); 79 | 80 | *pexec = TGetExecBase(basetask); 81 | 82 | return 0; 83 | } 84 | -------------------------------------------------------------------------------- /tekui/tek/lib/visual_lua.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LUA_TEK_LIB_VISUAL_H 3 | #define LUA_TEK_LIB_VISUAL_H 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | extern TMODENTRY TUINT 16 | tek_init_display_x11(TAPTR, struct TModule *, TUINT16, TTAGITEM *); 17 | 18 | /*****************************************************************************/ 19 | 20 | #ifndef LUACFUNC 21 | #define LUACFUNC TCALLBACK 22 | #endif 23 | 24 | #ifndef EXPORT 25 | #define EXPORT TMODAPI 26 | #endif 27 | 28 | #ifndef LOCAL 29 | #define LOCAL TMODINTERN 30 | #endif 31 | 32 | /*****************************************************************************/ 33 | 34 | typedef struct 35 | { 36 | TINT nump; 37 | TINT *points; 38 | TVPEN *pens; 39 | 40 | } TEKDrawdata; 41 | 42 | typedef struct TEKVisual 43 | { 44 | /* Visualbase: */ 45 | TAPTR vis_Base; 46 | /* Execbase: */ 47 | TAPTR vis_ExecBase; 48 | /* Timebase: */ 49 | TAPTR vis_TimeBase; 50 | /* Time request */ 51 | TAPTR vis_TimeRequest; 52 | /* Reference to base (stored in metatable): */ 53 | int vis_refBase; 54 | /* Is base instance: */ 55 | TBOOL vis_isBase; 56 | 57 | /* Reference to font (stored in metatable): */ 58 | int vis_refFont; 59 | /* Font (always default font in base): */ 60 | TAPTR vis_Font; 61 | /* FontHeight (always default font height in base): */ 62 | TINT vis_FontHeight; 63 | 64 | /* Visual Display ptr: */ 65 | TAPTR vis_Display; 66 | 67 | /* Visual instance ptr: */ 68 | TAPTR vis_Visual; 69 | 70 | TEKDrawdata vis_Drawdata; 71 | 72 | /* ShiftX/Y: */ 73 | TINT vis_ShiftX, vis_ShiftY; 74 | 75 | TINT vis_RectBufferNum; 76 | TINT *vis_RectBuffer; 77 | 78 | } TEKVisual; 79 | 80 | typedef struct 81 | { 82 | /* Pen object: */ 83 | TVPEN pen_Pen; 84 | /* Visual: */ 85 | TEKVisual *pen_Visual; 86 | 87 | } TEKPen; 88 | 89 | typedef struct 90 | { 91 | /* Visualbase: */ 92 | TEKVisual *font_VisBase; 93 | /* Font object: */ 94 | TAPTR font_Font; 95 | /* Font height: */ 96 | TUINT font_Height; 97 | /* underline position: */ 98 | TINT font_UlPosition; 99 | /* underline thickness: */ 100 | TINT font_UlThickness; 101 | 102 | } TEKFont; 103 | 104 | /*****************************************************************************/ 105 | 106 | #define TExecBase vis->vis_ExecBase 107 | #define TTimeBase vis->vis_TimeBase 108 | 109 | #define TEK_LIB_VISUAL_BASECLASSNAME "tek.lib.visual.base*" 110 | #define TEK_LIB_VISUAL_CLASSNAME "tek.lib.visual*" 111 | #define TEK_LIB_VISUALPEN_CLASSNAME "tek.lib.visual.pen*" 112 | #define TEK_LIB_VISUALFONT_CLASSNAME "tek.lib.visual.font*" 113 | 114 | /*****************************************************************************/ 115 | 116 | LOCAL LUACFUNC TINT tek_lib_visual_open(lua_State *L); 117 | LOCAL LUACFUNC TINT tek_lib_visual_close(lua_State *L); 118 | 119 | LOCAL LUACFUNC TINT tek_lib_visual_wait(lua_State *L); 120 | LOCAL LUACFUNC TINT tek_lib_visual_sleep(lua_State *L); 121 | LOCAL LUACFUNC TINT tek_lib_visual_openfont(lua_State *L); 122 | LOCAL LUACFUNC TINT tek_lib_visual_closefont(lua_State *L); 123 | LOCAL LUACFUNC TINT tek_lib_visual_textsize_font(lua_State *L); 124 | LOCAL LUACFUNC TINT tek_lib_visual_gettime(lua_State *L); 125 | 126 | LOCAL LUACFUNC TINT tek_lib_visual_setinput(lua_State *L); 127 | LOCAL LUACFUNC TINT tek_lib_visual_clearinput(lua_State *L); 128 | LOCAL LUACFUNC TINT tek_lib_visual_getmsg(lua_State *L); 129 | LOCAL LUACFUNC TINT tek_lib_visual_allocpen(lua_State *L); 130 | LOCAL LUACFUNC TINT tek_lib_visual_freepen(lua_State *L); 131 | LOCAL LUACFUNC TINT tek_lib_visual_frect(lua_State *L); 132 | LOCAL LUACFUNC TINT tek_lib_visual_rect(lua_State *L); 133 | LOCAL LUACFUNC TINT tek_lib_visual_line(lua_State *L); 134 | LOCAL LUACFUNC TINT tek_lib_visual_plot(lua_State *L); 135 | LOCAL LUACFUNC TINT tek_lib_visual_text(lua_State *L); 136 | LOCAL LUACFUNC TINT tek_lib_visual_drawimage(lua_State *L); 137 | LOCAL LUACFUNC TINT tek_lib_visual_getattrs(lua_State *L); 138 | LOCAL LUACFUNC TINT tek_lib_visual_setattrs(lua_State *L); 139 | LOCAL LUACFUNC TINT tek_lib_visual_textsize_visual(lua_State *L); 140 | LOCAL LUACFUNC TINT tek_lib_visual_setfont(lua_State *L); 141 | LOCAL LUACFUNC TINT tek_lib_visual_copyarea(lua_State *L); 142 | LOCAL LUACFUNC TINT tek_lib_visual_setcliprect(lua_State *L); 143 | LOCAL LUACFUNC TINT tek_lib_visual_unsetcliprect(lua_State *L); 144 | LOCAL LUACFUNC TINT tek_lib_visual_setshift(lua_State *L); 145 | LOCAL LUACFUNC TINT tek_lib_visual_drawrgb(lua_State *L); 146 | LOCAL LUACFUNC TINT tek_lib_visual_getfontattrs(lua_State *L); 147 | 148 | #endif 149 | -------------------------------------------------------------------------------- /tekui/tek/ui/Makefile: -------------------------------------------------------------------------------- 1 | 2 | BASEDIR ?= ../.. 3 | include $(BASEDIR)/config 4 | 5 | EXTRADEFS += $(LUA_DEFS) 6 | 7 | LUACLASSES = \ 8 | class/application.lua class/area.lua class/border.lua class/canvas.lua \ 9 | class/checkmark.lua class/dirlist.lua class/display.lua \ 10 | class/drawable.lua class/element.lua class/family.lua class/floattext.lua \ 11 | class/frame.lua class/gadget.lua class/gauge.lua class/group.lua \ 12 | class/handle.lua class/image.lua class/listgadget.lua class/listview.lua \ 13 | class/menuitem.lua class/numeric.lua class/popitem.lua class/poplist.lua \ 14 | class/popupwindow.lua class/radiobutton.lua class/scrollbar.lua \ 15 | class/scrollgroup.lua class/slider.lua class/spacer.lua \ 16 | class/pagegroup.lua class/text.lua class/textinput.lua class/theme.lua \ 17 | class/vectorimage.lua class/window.lua 18 | LUABORDERS = \ 19 | border/blank.lua border/button.lua border/group.lua \ 20 | border/recess.lua border/socket.lua border/tab.lua \ 21 | border/cursor.lua 22 | 23 | ############################################################################### 24 | 25 | MODS = layout/default.so 26 | 27 | layout/default.so: $(OBJDIR)/default.lo 28 | $(CC) $(MODCFLAGS) -o $@ $(OBJDIR)/default.lo 29 | 30 | $(OBJDIR)/default.lo: layout/default.c 31 | $(CC) $(LIBCFLAGS) -o $@ -c layout/default.c 32 | 33 | ############################################################################### 34 | 35 | FONTS = font/Vera.ttf font/VeraMono.ttf 36 | CURSORS = cursor/cursor-green.png 37 | 38 | ############################################################################### 39 | 40 | modules: $(OBJDIR) $(MODS) 41 | 42 | install: 43 | $(INSTALL) -d $(LUA_LIB)/tek/ui/layout 44 | $(INSTALL) -d $(LUA_SHARE)/tek/ui/layout 45 | $(INSTALL) -d $(LUA_SHARE)/tek/ui/border 46 | $(INSTALL) -d $(LUA_SHARE)/tek/ui/class 47 | $(INSTALL) -d $(LUA_SHARE)/tek/ui/font 48 | $(INSTALL) -d $(LUA_SHARE)/tek/ui/cursor 49 | $(INSTALL) -s layout/default.so $(LUA_LIB)/tek/ui/layout 50 | $(INSTALL) $(LUACLASSES) $(LUA_SHARE)/tek/ui/class 51 | $(INSTALL) $(LUABORDERS) $(LUA_SHARE)/tek/ui/border 52 | $(INSTALL) $(FONTS) $(LUA_SHARE)/tek/ui/font 53 | $(INSTALL) $(CURSORS) $(LUA_SHARE)/tek/ui/cursor 54 | 55 | clean: FORCE 56 | -$(RM) $(MODS) $(LIBS) 57 | -$(RMDIR) $(OBJDIR) 58 | -------------------------------------------------------------------------------- /tekui/tek/ui/border/blank.lua: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | -- tek.ui.class.border.blank 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | 8 | local ui = require "tek.ui" 9 | local unpack = unpack 10 | 11 | module("tek.ui.border.blank", tek.ui.class.border) 12 | _VERSION = "BlankBorder 2.1" 13 | 14 | ------------------------------------------------------------------------------- 15 | -- Constants & Class data: 16 | ------------------------------------------------------------------------------- 17 | 18 | local DEF_BORDER = { 1, 1, 1, 1 } 19 | 20 | ------------------------------------------------------------------------------- 21 | -- Class implementation: 22 | ------------------------------------------------------------------------------- 23 | 24 | local Blank = _M 25 | 26 | function Blank:getBorder(element, border) 27 | return unpack(border or element.Display.Theme.BorderBlankBorder or 28 | DEF_BORDER) 29 | end 30 | 31 | function Blank:draw(element, border, r1, r2, r3, r4) 32 | local b1, b2, b3, b4 = self:getBorder(element, border) 33 | local d = element.Drawable 34 | local p1, p2 35 | if element.Focus then 36 | p1, p2 = d.Pens[ui.PEN_FOCUSSHINE], d.Pens[ui.PEN_FOCUSSHADOW] 37 | else 38 | p1 = d.Pens[element.Parent and element.Parent.Background or 39 | ui.PEN_AREABACK] 40 | p2 = p1 41 | end 42 | d:fillRect(r1 - b1, r2 - b2, r3 + b3, r2 - 1, p1) 43 | d:fillRect(r3 + 1, r2, r3 + b3, r4 + b4, p2) 44 | d:fillRect(r1 - b1, r4 + 1, r3 + b3, r4 + b4, p1) 45 | d:fillRect(r1 - b1, r2, r1 - 1, r4, p2) 46 | end 47 | -------------------------------------------------------------------------------- /tekui/tek/ui/border/button.lua: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | -- tek.ui.class.border.button 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | 8 | local ui = require "tek.ui" 9 | local unpack = unpack 10 | 11 | module("tek.ui.border.button", tek.ui.class.border) 12 | _VERSION = "ButtonBorder 2.0" 13 | 14 | ------------------------------------------------------------------------------- 15 | -- Constants & Class data: 16 | ------------------------------------------------------------------------------- 17 | 18 | local DEF_BORDER = { 2, 2, 2, 2 } 19 | 20 | ------------------------------------------------------------------------------- 21 | -- Class implementation: 22 | ------------------------------------------------------------------------------- 23 | 24 | local Button = _M 25 | 26 | function Button:getBorder(element, border) 27 | return unpack(border or element.Display.Theme.BorderButtonBorder or 28 | DEF_BORDER) 29 | end 30 | 31 | function Button:draw(element, border, r1, r2, r3, r4) 32 | local b1, b2, b3, b4 = self:getBorder(element, border) 33 | local d = element.Drawable 34 | local p1, p2 35 | if element.Selected then 36 | p1, p2 = d.Pens[ui.PEN_HALFSHADOW], d.Pens[ui.PEN_HALFSHINE] 37 | else 38 | p1, p2 = d.Pens[ui.PEN_HALFSHINE], d.Pens[ui.PEN_HALFSHADOW] 39 | end 40 | d:fillRect(r1 - b1, r2 - b2, r3 + b3, r2 - 1, p1) 41 | d:fillRect(r3 + 1, r2, r3 + b3, r4 + b4, p2) 42 | d:fillRect(r1 - b1, r4 + 1, r3 + b3, r4 + b4, p2) 43 | d:fillRect(r1 - b1, r2, r1 - 1, r4, p1) 44 | end 45 | -------------------------------------------------------------------------------- /tekui/tek/ui/border/cursor.lua: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | -- tek.ui.class.border.cursor 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | 8 | local ui = require "tek.ui" 9 | local unpack = unpack 10 | 11 | module("tek.ui.border.cursor", tek.ui.class.border) 12 | _VERSION = "Cursor Border 2.1" 13 | 14 | ------------------------------------------------------------------------------- 15 | -- Constants & Class data: 16 | ------------------------------------------------------------------------------- 17 | 18 | local DEF_BORDER = { 1, 1, 1, 1 } 19 | 20 | ------------------------------------------------------------------------------- 21 | -- Class implementation: 22 | ------------------------------------------------------------------------------- 23 | 24 | local Cursor = _M 25 | 26 | function Cursor:getBorder(element, border) 27 | return unpack(border or 28 | element.Display.Theme.BorderCursorBorder or DEF_BORDER) 29 | end 30 | 31 | function Cursor:draw(element, border, r1, r2, r3, r4) 32 | local b1, b2, b3, b4 = self:getBorder(element, border) 33 | local d = element.Drawable 34 | local p1 = d.Pens[ui.PEN_SHINE] 35 | d:fillRect(r1 - b1, r2 - b2, r3 + b3, r2 - 1, p1) 36 | d:fillRect(r3 + 1, r2, r3 + b3, r4 + b4, p1) 37 | d:fillRect(r1 - b1, r4 + 1, r3 + b3, r4 + b4, p1) 38 | d:fillRect(r1 - b1, r2, r1 - 1, r4, p1) 39 | end 40 | -------------------------------------------------------------------------------- /tekui/tek/ui/border/group.lua: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | -- tek.ui.border.group 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | 8 | local ui = require "tek.ui" 9 | local Region = require "tek.lib.region" 10 | 11 | local floor = math.floor 12 | 13 | module("tek.ui.border.group", tek.ui.class.border) 14 | _VERSION = "GroupBorder 3.1" 15 | 16 | ------------------------------------------------------------------------------- 17 | -- Constants & Class data: 18 | ------------------------------------------------------------------------------- 19 | 20 | local DEF_BORDER = { 1, 1, 1, 1 } 21 | 22 | ------------------------------------------------------------------------------- 23 | -- Class implementation: 24 | ------------------------------------------------------------------------------- 25 | 26 | local Group = _M 27 | 28 | local function getsizes(e, b) 29 | local tw, th 30 | b = b or e.Display.Theme.BorderGroupBorder or DEF_BORDER 31 | if e and e.Legend and e.LegendFont then 32 | tw, th = ui.Display:getTextSize(e.LegendFont, e.Legend) 33 | end 34 | return b[1], b[2], b[3], b[4], tw, th 35 | end 36 | 37 | function Group:getBorder(element, border) 38 | local b1, b2, b3, b4, _, th = getsizes(element, border) 39 | return b1, th or b2, b3, b4 40 | end 41 | 42 | function Group:draw(element, border, r1, r2, r3, r4) 43 | local b1, b2, b3, b4, tw, th = getsizes(element, border) 44 | local d = element.Drawable 45 | 46 | local p1, p2 47 | if element.Focus then 48 | p1, p2 = d.Pens[ui.PEN_FOCUSSHINE], d.Pens[ui.PEN_FOCUSSHADOW] 49 | else 50 | p1, p2 = d.Pens[ui.PEN_HALFSHADOW], d.Pens[ui.PEN_SHADOW] 51 | end 52 | 53 | d:fillRect(r1 - b1, r2 - b2, r3 + b3, r2 - 1, p1) 54 | d:fillRect(r3 + 1, r2, r3 + b3, r4 + b4, p2) 55 | d:fillRect(r1 - b1, r4 + 1, r3 + b3, r4 + b4, p2) 56 | d:fillRect(r1 - b1, r2, r1 - 1, r4, p1) 57 | if tw then 58 | local w = r3 - r1 + 1 59 | local tx = r1 + floor((w - tw) / 2) 60 | d:setFont(element.LegendFont) 61 | d:pushClipRect(r1 - b1, r2 - th, r3 + b3, r2 - 1) 62 | d:drawText(tx, r2 - th, element.Legend, d.Pens[ui.PEN_GROUPLABELTEXT], 63 | d.Pens[element.Background or ui.PEN_GROUPBACK]) 64 | d:popClipRect() 65 | end 66 | end 67 | 68 | function Group:getRegion(element, border, x0, y0, x1, y1) 69 | local b1, b2, b3, b4, tw, th = getsizes(element, border) 70 | local b = Region.new(x0 - b1, y0 - b2, x1 + b3, y1 + b4) 71 | if tw then 72 | local w = x1 - x0 + 1 73 | local tx = x0 + floor((w - tw) / 2) 74 | b:orRect(tx, y0 - th, tx + tw - 1, y0 - 1) 75 | end 76 | b:subRect(x0, y0, x1, y1) 77 | return b 78 | end 79 | -------------------------------------------------------------------------------- /tekui/tek/ui/border/recess.lua: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | -- tek.ui.class.border.recess 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | 8 | local ui = require "tek.ui" 9 | local unpack = unpack 10 | 11 | module("tek.ui.border.recess", tek.ui.class.border) 12 | _VERSION = "RecessBorder 2.0" 13 | 14 | ------------------------------------------------------------------------------- 15 | -- Constants & Class data: 16 | ------------------------------------------------------------------------------- 17 | 18 | local DEF_BORDER = { 2, 2, 2, 2 } 19 | 20 | ------------------------------------------------------------------------------- 21 | -- Class implementation: 22 | ------------------------------------------------------------------------------- 23 | 24 | local Recess = _M 25 | 26 | function Recess:getBorder(element, border) 27 | return unpack(border or element.Display.Theme.BorderRecessBorder or 28 | DEF_BORDER) 29 | end 30 | 31 | function Recess:draw(element, border, r1, r2, r3, r4) 32 | local b1, b2, b3, b4 = self:getBorder(element, border) 33 | local d = element.Drawable 34 | local p1, p2 35 | if element.Focus then 36 | p1, p2 = d.Pens[ui.PEN_FOCUSSHADOW], d.Pens[ui.PEN_FOCUSSHINE] 37 | else 38 | p1, p2 = d.Pens[ui.PEN_HALFSHADOW], d.Pens[ui.PEN_HALFSHINE] 39 | end 40 | d:fillRect(r1 - b1, r2 - b2, r3 + b3, r2 - 1, p1) 41 | d:fillRect(r3 + 1, r2, r3 + b3, r4 + b4, p2) 42 | d:fillRect(r1 - b1, r4 + 1, r3 + b3, r4 + b4, p2) 43 | d:fillRect(r1 - b1, r2, r1 - 1, r4, p1) 44 | end 45 | -------------------------------------------------------------------------------- /tekui/tek/ui/border/socket.lua: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | -- tek.ui.class.border.socket 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | 8 | local ui = require "tek.ui" 9 | local unpack = unpack 10 | 11 | module("tek.ui.border.socket", tek.ui.class.border) 12 | _VERSION = "SocketBorder 2.1" 13 | 14 | ------------------------------------------------------------------------------- 15 | -- Constants & Class data: 16 | ------------------------------------------------------------------------------- 17 | 18 | local DEF_BORDER = { 1, 1, 1, 1 } 19 | 20 | ------------------------------------------------------------------------------- 21 | -- Class implementation: 22 | ------------------------------------------------------------------------------- 23 | 24 | local Socket = _M 25 | 26 | function Socket:getBorder(element, border) 27 | return unpack(border or element.Display.Theme.BorderSocketBorder or 28 | DEF_BORDER) 29 | end 30 | 31 | function Socket:draw(element, border, r1, r2, r3, r4) 32 | local b1, b2, b3, b4 = self:getBorder(element, border) 33 | local d = element.Drawable 34 | local p1, p2 35 | if element.Focus then 36 | p1, p2 = d.Pens[ui.PEN_FOCUSSHINE], d.Pens[ui.PEN_FOCUSSHADOW] 37 | else 38 | p1, p2 = d.Pens[ui.PEN_SHADOW], d.Pens[ui.PEN_SHADOW] 39 | end 40 | d:fillRect(r1 - b1, r2 - b2, r3 + b3, r2 - 1, p1) 41 | d:fillRect(r3 + 1, r2, r3 + b3, r4 + b4, p2) 42 | d:fillRect(r1 - b1, r4 + 1, r3 + b3, r4 + b4, p2) 43 | d:fillRect(r1 - b1, r2, r1 - 1, r4, p1) 44 | end 45 | -------------------------------------------------------------------------------- /tekui/tek/ui/border/tab.lua: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | -- tek.ui.class.border.tab 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | 8 | local ui = require "tek.ui" 9 | local unpack = unpack 10 | 11 | module("tek.ui.border.tab", tek.ui.class.border) 12 | _VERSION = "TabBorder 1.0" 13 | 14 | ------------------------------------------------------------------------------- 15 | -- Constants & Class data: 16 | ------------------------------------------------------------------------------- 17 | 18 | local DEF_BORDER = { 2, 2, 2, 2 } 19 | 20 | ------------------------------------------------------------------------------- 21 | -- Class implementation: 22 | ------------------------------------------------------------------------------- 23 | 24 | local Tab = _M 25 | 26 | function Tab:getBorder(element, border) 27 | return unpack(border or element.Display.Theme.BorderTabBorder or 28 | DEF_BORDER) 29 | end 30 | 31 | function Tab:draw(element, border, r1, r2, r3, r4) 32 | local b1, b2, b3, b4 = self:getBorder(element, border) 33 | local d = element.Drawable 34 | local p1, p2 35 | if element.Selected then 36 | p1, p2 = d.Pens[ui.PEN_HALFSHINE], d.Pens[ui.PEN_HALFSHADOW] 37 | else 38 | p1, p2 = d.Pens[ui.PEN_HALFSHADOW], d.Pens[ui.PEN_HALFSHINE] 39 | end 40 | d:fillRect(r1 - b1, r2 - b2, r3 + b3, r2 - 1, p1) 41 | d:fillRect(r3 + 1, r2, r3 + b3, r4 + b4, p2) 42 | d:fillRect(r1 - b1, r4 + 1, r3 + b3, r4 + b4, d.Pens[ui.PEN_GROUPBACK]) 43 | d:fillRect(r1 - b1, r2, r1 - 1, r4, p1) 44 | end 45 | -------------------------------------------------------------------------------- /tekui/tek/ui/class/border.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | -- 3 | -- tek.ui.class.border 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | -- LINEAGE:: 8 | -- [[#ClassOverview]] : 9 | -- [[#tek.class : Class]] / 10 | -- [[#tek.class.object : Object]] / 11 | -- Border 12 | -- 13 | -- OVERVIEW:: 14 | -- This is the base class of all border classes. Border classes are 15 | -- located in the directory {{tek/ui/border}}. 16 | -- 17 | -- IMPLEMENTS:: 18 | -- - Border:draw() - Draw a border 19 | -- - Border:getBorder() - Get a border class' border thicknesses 20 | -- - Border:getRegion() - Get a region representing the border outline 21 | -- - Border.loadClass() - Load a border class 22 | -- 23 | ------------------------------------------------------------------------------- 24 | 25 | local ui = require "tek.ui" 26 | local Object = require "tek.class.object" 27 | local Region = require "tek.lib.region" 28 | local newRegion = Region.new 29 | local unpack = unpack 30 | 31 | module("tek.ui.class.border", tek.class.object) 32 | _VERSION = "Border 3.0" 33 | 34 | ------------------------------------------------------------------------------- 35 | -- Class implementation: 36 | ------------------------------------------------------------------------------- 37 | 38 | local Border = _M 39 | 40 | ------------------------------------------------------------------------------- 41 | -- Border.loadClass(stylename): This function tries to load the named 42 | -- border class; if the class cannot be found, returns the base class. 43 | ------------------------------------------------------------------------------- 44 | 45 | function Border.loadClass(style) 46 | local class 47 | if style and style ~= "" then 48 | class = ui.loadClass("border", style) 49 | end 50 | return class or Border 51 | end 52 | 53 | ------------------------------------------------------------------------------- 54 | -- left, right, top, bottom = Border:getBorder(element[, borders]): 55 | -- If specified, unpacks and returns the table {{borders}}, otherwise 56 | -- returns the class' default border thicknesses (with possible style 57 | -- variations for the given element) in the order left, right, top, bottom. 58 | ------------------------------------------------------------------------------- 59 | 60 | function Border:getBorder() 61 | return 0, 0, 0, 0 62 | end 63 | 64 | ------------------------------------------------------------------------------- 65 | -- Border:draw(element, bordertab, x0, y0, x1, y1): Draws the specified table 66 | -- of border thicknesses into the given rectangle, with possible style 67 | -- variations for the given element. 68 | ------------------------------------------------------------------------------- 69 | 70 | function Border:draw() 71 | end 72 | 73 | ------------------------------------------------------------------------------- 74 | -- region = Border:getRegion(element, bordertab, x0, y0, x1, y1): Returns a 75 | -- [[#tek.lib.region : Region]] representing the outline of the specified 76 | -- border thicknesses for the given rectangle, with possible style variations 77 | -- for the given element. 78 | ------------------------------------------------------------------------------- 79 | 80 | function Border:getRegion(element, border, x0, y0, x1, y1) 81 | local b1, b2, b3, b4 = self:getBorder(element, border) 82 | if b1 > 0 or b2 > 0 or b3 > 0 or b4 > 0 then 83 | local b = newRegion(x0 - b1, y0 - b2, x1 + b3, y1 + b4) 84 | b:subRect(x0, y0, x1, y1) 85 | return b 86 | end 87 | return false 88 | end 89 | -------------------------------------------------------------------------------- /tekui/tek/ui/class/display.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | -- 3 | -- tek.ui.class.display 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | -- LINEAGE:: 8 | -- [[#ClassOverview]] : 9 | -- [[#tek.class : Class]] / 10 | -- [[#tek.class.object : Object]] / 11 | -- Display 12 | -- 13 | -- OVERVIEW:: 14 | -- This class manages a display device. 15 | -- 16 | -- ATTRIBUTES:: 17 | -- - {{Theme [IG]}} ([[#tek.ui.class.them : Theme]]) 18 | -- Theme object; if none is supplied during initialization, 19 | -- one is created. 20 | -- 21 | -- IMPLEMENTS:: 22 | -- - Display:closeFont() - Close font 23 | -- - Display:getFontAttrs() - Get font attributes 24 | -- - Display:getTime() - Get system time 25 | -- - Display:openFont() - Open a named font 26 | -- - Display:openVisual() - Open a visual 27 | -- - Display:sleep() - Sleep for a period of time 28 | -- - Display:getTextSize() - Get size of text rendered with a given font 29 | -- - Display:wait() - Wait for a list of visuals 30 | -- 31 | -- OVERRIDES:: 32 | -- - Class.new() 33 | -- 34 | ------------------------------------------------------------------------------- 35 | 36 | local db = require "tek.lib.debug" 37 | local ui = require "tek.ui" 38 | local Class = require "tek.class" 39 | local Visual = require "tek.lib.visual" 40 | local Theme = ui.Theme 41 | 42 | local tonumber = tonumber 43 | 44 | module("tek.ui.class.display", tek.class) 45 | _VERSION = "Display 6.0" 46 | 47 | ------------------------------------------------------------------------------- 48 | -- Class implementation: 49 | ------------------------------------------------------------------------------- 50 | 51 | local Display = _M 52 | 53 | function Display.new(class, self) 54 | self.Theme = self.Theme or Theme:new { ImportConfig = true } 55 | self.FontCache = { } 56 | return Class.new(class, self) 57 | end 58 | 59 | ------------------------------------------------------------------------------- 60 | -- width, height = Display:getTextSize(font, text): Returns the width and 61 | -- height of the specified {{text}} when it is rendered with the given 62 | -- {{font}}. 63 | ------------------------------------------------------------------------------- 64 | 65 | function Display:getTextSize(...) 66 | return Visual.textsize(...) 67 | end 68 | 69 | ------------------------------------------------------------------------------- 70 | -- font = Display:openFont(fontname): Opens the named font. For a discussion 71 | -- of the fontname format, see [[#tek.ui.class.text : Text]]. 72 | ------------------------------------------------------------------------------- 73 | 74 | function Display:openFont(fname) 75 | fname = fname or "" 76 | if not self.FontCache[fname] then 77 | local deff = self.Theme.DefFonts 78 | local name, size = fname:match("^([^:]*):?(%d*)$") 79 | if deff[name] then 80 | local nname, nsize = deff[name]:match("^([^:]*):?(%d*)$") 81 | if size == "" then 82 | size = nsize 83 | end 84 | name = nname 85 | end 86 | size = size ~= "" and tonumber(size) or nil 87 | for name in name:gmatch("%s*([^,]*)%s*,?") do 88 | if name ~= "" then 89 | db.info("Fontname: %s -> %s:%d", fname, name, size or -1) 90 | local font = Visual.openfont(name, size) 91 | if font then 92 | local r = { font, font:getattrs { }, fname, name } 93 | self.FontCache[fname] = r 94 | self.FontCache[font] = r 95 | return font 96 | end 97 | end 98 | end 99 | return 100 | end 101 | return self.FontCache[fname][1] 102 | end 103 | 104 | ------------------------------------------------------------------------------- 105 | -- Display:closeFont(font): Closes the specified font 106 | ------------------------------------------------------------------------------- 107 | 108 | function Display:closeFont(display, font) 109 | end 110 | 111 | ------------------------------------------------------------------------------- 112 | -- Display:getFontAttrs(font): Returns the font attributes height, 113 | -- underline position and underline thickness. 114 | ------------------------------------------------------------------------------- 115 | 116 | function Display:getFontAttrs(font) 117 | local a = self.FontCache[font][2] 118 | return a.Height, a.UlPosition, a.UlThickness 119 | end 120 | 121 | ------------------------------------------------------------------------------- 122 | -- wait: 123 | ------------------------------------------------------------------------------- 124 | 125 | function Display:wait(...) 126 | return Visual.wait(...) 127 | end 128 | 129 | ------------------------------------------------------------------------------- 130 | -- sleep: 131 | ------------------------------------------------------------------------------- 132 | 133 | function Display:sleep(...) 134 | return Visual.sleep(...) 135 | end 136 | 137 | ------------------------------------------------------------------------------- 138 | -- getTime: 139 | ------------------------------------------------------------------------------- 140 | 141 | function Display:getTime(...) 142 | return Visual.gettime(...) 143 | end 144 | 145 | ------------------------------------------------------------------------------- 146 | -- openVisual: 147 | ------------------------------------------------------------------------------- 148 | 149 | function Display:openVisual(...) 150 | return Visual.open(...) 151 | end 152 | -------------------------------------------------------------------------------- /tekui/tek/ui/class/family.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | -- 3 | -- tek.ui.class.family 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | -- LINEAGE:: 8 | -- [[#ClassOverview]] : 9 | -- [[#tek.class : Class]] / 10 | -- [[#tek.class.object : Object]] / 11 | -- Family 12 | -- 13 | -- OVERVIEW:: 14 | -- This class implements a container for child object. 15 | -- 16 | -- ATTRIBUTES:: 17 | -- - {{Children [IG]}} (table) 18 | -- Array of child objects 19 | -- 20 | -- FUNCTIONS:: 21 | -- - Family:addMember() 22 | -- - Family:remMember() 23 | -- 24 | ------------------------------------------------------------------------------- 25 | 26 | local db = require "tek.lib.debug" 27 | local Object = require "tek.class.object" 28 | local insert = table.insert 29 | local ipairs = ipairs 30 | local remove = table.remove 31 | 32 | module("tek.ui.class.family", tek.class.object) 33 | _VERSION = "Family 2.3" 34 | 35 | ------------------------------------------------------------------------------- 36 | -- Class implementation: 37 | ------------------------------------------------------------------------------- 38 | 39 | local Family = _M 40 | 41 | function Family.init(self) 42 | self.Children = self.Children or { } 43 | return Object.init(self) 44 | end 45 | 46 | ------------------------------------------------------------------------------- 47 | -- success = addMember(child[, pos]): Invokes the specified child's 48 | -- [[connect()][#Element:connect]] method to check for its ability to 49 | -- integrate into the family, and if successful, inserts it into the 50 | -- family's list of children. Optionally, the child is inserted into the 51 | -- list at the specified position. 52 | ------------------------------------------------------------------------------- 53 | 54 | function Family:addMember(child, pos) 55 | if child:connect(self) then 56 | if pos then 57 | insert(self.Children, pos, child) 58 | else 59 | insert(self.Children, child) 60 | end 61 | return true 62 | end 63 | end 64 | 65 | ------------------------------------------------------------------------------- 66 | -- success = remMember(child): Looks up {{child}} in the family's list of 67 | -- children, and if it can be found, invokes its 68 | -- [[disconnect()][#Element:disconnect]] method and removes it from the list. 69 | ------------------------------------------------------------------------------- 70 | 71 | function Family:remMember(child) 72 | for pos, e in ipairs(self.Children) do 73 | if e == child then 74 | child:disconnect(self) 75 | remove(self.Children, pos) 76 | return true 77 | end 78 | end 79 | end 80 | -------------------------------------------------------------------------------- /tekui/tek/ui/class/image.lua: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | -- tek.ui.class.image 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | 8 | local db = require "tek.lib.debug" 9 | local ui = require "tek.ui" 10 | local Gadget = ui.Gadget 11 | local floor = math.floor 12 | local max = math.max 13 | 14 | module("tek.ui.class.image", tek.ui.class.gadget) 15 | _VERSION = "Image 1.6" 16 | 17 | ------------------------------------------------------------------------------- 18 | -- Constants & Class data: 19 | ------------------------------------------------------------------------------- 20 | 21 | local DEF_IMAGEMARGIN = { 0, 0, 0, 0 } 22 | 23 | ------------------------------------------------------------------------------- 24 | -- Class implementation: 25 | ------------------------------------------------------------------------------- 26 | 27 | local Image = _M 28 | 29 | function Image.init(self) 30 | self.DrawRect = { 0, 0, 0, 0 } 31 | self.ImageMargin = self.ImageMargin or false 32 | return Gadget.init(self) 33 | end 34 | 35 | ------------------------------------------------------------------------------- 36 | -- show: 37 | ------------------------------------------------------------------------------- 38 | 39 | function Image:show(display, drawable) 40 | local theme = display.Theme 41 | self.ImageMargin = self.ImageMargin or DEF_IMAGEMARGIN 42 | return Gadget.show(self, display, drawable) 43 | end 44 | 45 | ------------------------------------------------------------------------------- 46 | -- askMinMax: 47 | ------------------------------------------------------------------------------- 48 | 49 | function Image:askMinMax(m1, m2, m3, m4) 50 | local m = self.ImageMargin 51 | m1 = m1 + m[1] + m[3] 52 | m2 = m2 + m[2] + m[4] 53 | m3 = m3 + m[1] + m[3] 54 | m4 = m4 + m[2] + m[4] 55 | return Gadget.askMinMax(self, m1, m2, m3, m4) 56 | end 57 | 58 | ------------------------------------------------------------------------------- 59 | -- layout: 60 | ------------------------------------------------------------------------------- 61 | 62 | function Image:layout(x0, y0, x1, y1, markdamage) 63 | if Gadget.layout(self, x0, y0, x1, y1, markdamage) then 64 | local r = self.Rect 65 | local p = self.PaddingAndBorder 66 | local m = self.ImageMargin 67 | local w = r[3] - r[1] - p[1] - p[3] - m[1] - m[3] + 1 68 | local h = r[4] - r[2] - p[2] - p[4] - m[2] - m[3] + 1 69 | local x = r[1] + p[1] + m[1] 70 | local y = r[2] + p[2] + m[2] 71 | local d = self.DrawRect 72 | d[1] = x 73 | d[2] = y 74 | d[3] = x + w - 1 75 | d[4] = y + h - 1 76 | return true 77 | end 78 | end 79 | 80 | ------------------------------------------------------------------------------- 81 | -- draw: 82 | ------------------------------------------------------------------------------- 83 | 84 | function Image:draw() 85 | Gadget.draw(self) 86 | if self.Image then 87 | self.Image:draw(self.Drawable, self.DrawRect) 88 | end 89 | end 90 | -------------------------------------------------------------------------------- /tekui/tek/ui/class/listview.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | -- 3 | -- tek.ui.class.listview 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | -- LINEAGE:: 8 | -- [[#ClassOverview]] : 9 | -- [[#tek.class : Class]] / 10 | -- [[#tek.class.object : Object]] / 11 | -- [[#tek.ui.class.element : Element]] / 12 | -- [[#tek.ui.class.area : Area]] / 13 | -- [[#tek.ui.class.frame : Frame]] / 14 | -- [[#tek.ui.class.gadget : Gadget]] / 15 | -- [[#tek.ui.class.group : Group]] / 16 | -- ListView 17 | -- 18 | -- OVERVIEW:: 19 | -- This class implements a [[#tek.ui.class.group : Group]] containing 20 | -- a [[#tek.ui.class.scrollgroup : ScrollGroup]] and optionally a 21 | -- group of column headers; its main purpose is to automate the somewhat 22 | -- complicated setup of multi-column lists with headers, but it can be 23 | -- used for single-column lists and lists without column headers as well. 24 | -- 25 | -- ATTRIBUTES:: 26 | -- - {{Headers [I]}} (table) 27 | -- An array of strings containing the captions of column headers. 28 | -- [Default: unspecified] 29 | -- - {{HSliderMode [I]}} (string) 30 | -- This attribute is passed on the 31 | -- [[#tek.ui.class.scrollgroup : ScrollGroup]] - see there. 32 | -- - {{VSliderMode [I]}} (string) 33 | -- This attribute is passed on the 34 | -- [[#tek.ui.class.scrollgroup : ScrollGroup]] - see there. 35 | -- 36 | ------------------------------------------------------------------------------- 37 | 38 | local ui = require "tek.ui" 39 | local List = require "tek.class.list" 40 | local Canvas = ui.Canvas 41 | local Gadget = ui.Gadget 42 | local Group = ui.Group 43 | local ListGadget = ui.ListGadget 44 | local ScrollBar = ui.ScrollBar 45 | local ScrollGroup = ui.ScrollGroup 46 | local Text = ui.Text 47 | 48 | local ipairs = ipairs 49 | 50 | module("tek.ui.class.listview", tek.ui.class.group) 51 | _VERSION = "ListView 4.2" 52 | 53 | ------------------------------------------------------------------------------- 54 | -- HeadItem: 55 | ------------------------------------------------------------------------------- 56 | 57 | local DEF_HEADITEM_BORDER = { 0, 0, 0, 0 } 58 | local DEF_HEADITEM_IBORDER = { 1, 1, 1, 1 } 59 | local DEF_HEADITEM_MARGIN = { 0, 0, 0, 0 } 60 | local DEF_HEADITEM_PADDING = { 0, 0, 0, 0 } 61 | 62 | local HeadItem = Text:newClass { _NAME = "_listviewhead" } 63 | 64 | function HeadItem.init(self) 65 | self = self or { } 66 | self.TextHAlign = "left" 67 | self.Margin = DEF_HEADITEM_MARGIN 68 | self.BorderStyle = "none" 69 | self.IBorderStyle = "button" 70 | self.Mode = "inert" 71 | self.IBorder = DEF_HEADITEM_IBORDER 72 | self.Border = DEF_HEADITEM_BORDER 73 | self.Width = "auto" 74 | self.Padding = DEF_HEADITEM_PADDING 75 | return Text.init(self) 76 | end 77 | 78 | function HeadItem:setState(bg) 79 | Text.setState(self, bg or ui.PEN_GROUPBACK) 80 | end 81 | 82 | function HeadItem:askMinMax(m1, m2, m3, m4) 83 | local w, h = self:getTextSize() 84 | m1 = m1 + w 85 | m2 = m2 + h 86 | m3 = m3 + w 87 | m4 = m4 + h 88 | return Gadget.askMinMax(self, m1, m2, m3, m4) 89 | end 90 | 91 | ------------------------------------------------------------------------------- 92 | -- ListView: 93 | ------------------------------------------------------------------------------- 94 | 95 | local ListView = _M 96 | 97 | function ListView.new(class, self) 98 | self = self or { } 99 | 100 | self.Child = self.Child or ListGadget:new() 101 | self.HeaderGroup = self.HeaderGroup or false 102 | self.Headers = self.Headers or false 103 | self.HSliderMode = self.HSliderMode or "on" 104 | self.VSliderGroup = false 105 | self.VSliderMode = self.VSliderMode or "on" 106 | 107 | if self.Headers and not self.HeaderGroup then 108 | local c = { } 109 | for i, caption in ipairs(self.Headers) do 110 | c[i] = HeadItem:new { Text = caption } 111 | end 112 | self.HeaderGroup = Group:new { Width = "fill", Children = c } 113 | end 114 | 115 | if self.HeaderGroup then 116 | self.VSliderGroup = ScrollBar:new { Orientation = "vertical", Min = 0 } 117 | self.Child.HeaderGroup = self.HeaderGroup 118 | self.Children = 119 | { 120 | ScrollGroup:new 121 | { 122 | VSliderMode = "off", 123 | HSliderMode = self.HSliderMode, 124 | KeepMinHeight = true, 125 | Canvas = Canvas:new 126 | { 127 | passMsg = function(self, msg) 128 | -- pass input unmodified: 129 | return self.Child:passMsg(msg) 130 | end, 131 | AutoHeight = true, 132 | AutoWidth = true, 133 | Child = Group:new 134 | { 135 | Orientation = "vertical", 136 | Children = 137 | { 138 | self.HeaderGroup, 139 | ScrollGroup:new 140 | { 141 | VSliderMode = "off", 142 | HSliderMode = "off", 143 | VSliderGroup = self.VSliderGroup, 144 | Canvas = Canvas:new 145 | { 146 | Child = self.Child 147 | } 148 | } 149 | } 150 | } 151 | } 152 | }, 153 | self.VSliderGroup 154 | } 155 | -- point element that determines listgadget alignment to outer canvas: 156 | self.Child.AlignElement = self.Children[1].Canvas 157 | else 158 | self.Children = 159 | { 160 | ScrollGroup:new 161 | { 162 | VSliderMode = self.VSliderMode, 163 | HSliderMode = self.HSliderMode, 164 | Canvas = Canvas:new 165 | { 166 | Child = self.Child 167 | } 168 | } 169 | } 170 | end 171 | 172 | return Group.new(class, self) 173 | end 174 | -------------------------------------------------------------------------------- /tekui/tek/ui/class/popupwindow.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | -- 3 | -- tek.ui.class.popupwindow 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | -- LINEAGE:: 8 | -- [[#ClassOverview]] : 9 | -- [[#tek.class : Class]] / 10 | -- [[#tek.class.object : Object]] / 11 | -- [[#tek.ui.class.element : Element]] / 12 | -- [[#tek.ui.class.area : Area]] / 13 | -- [[#tek.ui.class.frame : Frame]] / 14 | -- [[#tek.ui.class.gadget : Gadget]] / 15 | -- [[#tek.ui.class.group : Group]] / 16 | -- [[#tek.ui.class.group : Window]] / 17 | -- PopupWindow 18 | -- 19 | -- OVERVIEW:: 20 | -- This class specializes a Window for the use by a 21 | -- [[#tek.ui.class.popitem : PopItem]]. 22 | -- 23 | -- OVERRIDES:: 24 | -- - Object.init() 25 | -- - Area:show() 26 | -- - Area:passMsg() 27 | -- 28 | ------------------------------------------------------------------------------- 29 | 30 | local ui = require "tek.ui" 31 | local Window = ui.Window 32 | local ipairs = ipairs 33 | local max = math.max 34 | 35 | module("tek.ui.class.popupwindow", tek.ui.class.window) 36 | _VERSION = "PopupWindow 1.2" 37 | 38 | local PopupWindow = _M 39 | 40 | ------------------------------------------------------------------------------- 41 | -- Constants and class data: 42 | ------------------------------------------------------------------------------- 43 | 44 | local DEF_POPUPMARGIN = { 0, 0, 0, 0 } 45 | local DEF_SHORTCUT_XOFFS = 20 46 | local MSG_MOUSEOVER = ui.MSG_MOUSEOVER 47 | local MSG_INTERVAL = ui.MSG_INTERVAL 48 | 49 | ------------------------------------------------------------------------------- 50 | -- PopupWindow class: 51 | ------------------------------------------------------------------------------- 52 | 53 | function PopupWindow.init(self) 54 | self.PopupBase = self.PopupBase or false 55 | self.BGPen = self.BGPen or ui.PEN_MENUBACK 56 | self.BeginPopupTicks = 0 57 | self.Border = self.Border or false 58 | self.BorderStyle = self.BorderStyle or "socket" 59 | self.DelayedBeginPopup = false 60 | self.DelayedEndPopup = false 61 | self.Margin = self.Margin or DEF_POPUPMARGIN 62 | self.MaxWidth = self.MaxWidth or 0 63 | self.MaxHeight = self.MaxHeight or 0 64 | self.Padding = self.Padding or false 65 | return Window.init(self) 66 | end 67 | 68 | function PopupWindow:show(display) 69 | if Window.show(self, display) then 70 | -- determine width of menuitems in group: 71 | local maxw = 0 72 | for _, e in ipairs(self.Children) do 73 | if e:checkDescend(ui.MenuItem) then 74 | maxw = max(maxw, e:getTextSize()) 75 | end 76 | end 77 | for _, e in ipairs(self.Children) do 78 | -- align shortcut text (if present): 79 | if e:checkDescend(ui.MenuItem) and e.TextRecords[2] then 80 | e.TextRecords[2][5] = maxw + DEF_SHORTCUT_XOFFS 81 | end 82 | end 83 | return true 84 | end 85 | end 86 | 87 | function PopupWindow:passMsg(msg) 88 | if msg[2] == MSG_INTERVAL then 89 | self.BeginPopupTicks = self.BeginPopupTicks - 1 90 | if self.BeginPopupTicks < 0 then 91 | if self.DelayedBeginPopup then 92 | if not self.DelayedBeginPopup.PopupWindow then 93 | self.DelayedBeginPopup:beginPopup() 94 | end 95 | self.DelayedBeginPopup = false 96 | elseif self.DelayedEndPopup then 97 | if self.DelayedEndPopup.PopupWindow then 98 | self.DelayedEndPopup:endPopup() 99 | end 100 | self.DelayedEndPopup = false 101 | end 102 | end 103 | elseif msg[2] == MSG_MOUSEOVER then 104 | if msg[3] == 0 then 105 | if self.DelayedEndPopup then 106 | self:setHiliteElement(self.DelayedEndPopup) 107 | self.DelayedEndPopup = false 108 | end 109 | end 110 | -- do not pass control back to window msg handler: 111 | return false 112 | end 113 | return Window.passMsg(self, msg) 114 | end 115 | -------------------------------------------------------------------------------- /tekui/tek/ui/class/radiobutton.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | -- 3 | -- tek.ui.class.radiobutton 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | -- LINEAGE:: 8 | -- [[#ClassOverview]] : 9 | -- [[#tek.class : Class]] / 10 | -- [[#tek.class.object : Object]] / 11 | -- [[#tek.ui.class.element : Element]] / 12 | -- [[#tek.ui.class.area : Area]] / 13 | -- [[#tek.ui.class.frame : Frame]] / 14 | -- [[#tek.ui.class.gadget : Gadget]] / 15 | -- [[#tek.ui.class.text : Text]] / 16 | -- [[#tek.ui.class.checkmark : CheckMark]] / 17 | -- RadioButton 18 | -- 19 | -- OVERVIEW:: 20 | -- Specialization of a [[#tek.ui.class.checkmark : CheckMark]] to 21 | -- implement mutually exclusive 'radio buttons'; they really make 22 | -- sense only if more than one of their kind are grouped together. 23 | -- 24 | -- OVERRIDES:: 25 | -- - Object.init() 26 | -- - Gadget:onSelect() 27 | -- 28 | ------------------------------------------------------------------------------- 29 | 30 | local ui = require "tek.ui" 31 | local CheckMark = ui.CheckMark 32 | local VectorImage = ui.VectorImage 33 | 34 | local ipairs = ipairs 35 | 36 | module("tek.ui.class.radiobutton", tek.ui.class.checkmark) 37 | _VERSION = "RadioButton 1.5" 38 | 39 | ------------------------------------------------------------------------------- 40 | -- Constants & Class data: 41 | ------------------------------------------------------------------------------- 42 | 43 | local coords = 44 | { 45 | -- dot: 46 | 0, 0, -1, 2, -2, 1, -2, -1, -1, -2, 1, -2, 2, -1, 2, 1, 1, 2, 47 | -- shadow: 48 | -3, 4, -4, 3, -3, -2, -4, -3, -2, -3, -3, -4, 4, -3, 3, -4, 49 | -- shine: 50 | -3, 3, 3, 4, 2, 3, 4, 3, 3, 2, 3, -3, 51 | } 52 | 53 | -- shadow: 54 | local points1 = { 10, 18, 19, 20, 21, 22, 16, 23 } 55 | -- shine: 56 | local points2 = { 10, 11, 12, 13, 14, 15, 16, 17 } 57 | -- dot: 58 | local points3 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 2 } 59 | 60 | local RadioImage1 = VectorImage:new 61 | { 62 | ImageData = 63 | { 64 | Coords = coords, 65 | Primitives = 66 | { 67 | { 0x1000, 8, Points = points1, Pen = ui.PEN_HALFSHADOW }, 68 | { 0x1000, 8, Points = points2, Pen = ui.PEN_HALFSHINE }, 69 | }, 70 | MinMax = { -4, 4, 4, -4 }, 71 | } 72 | } 73 | 74 | local RadioImage2 = VectorImage:new 75 | { 76 | ImageData = 77 | { 78 | Coords = coords, 79 | Primitives = { 80 | { 0x1000, 8, Points = points1, Pen = ui.PEN_HALFSHINE }, 81 | { 0x1000, 8, Points = points2, Pen = ui.PEN_HALFSHADOW }, 82 | { 0x2000, 10, Points = points3, Pen = ui.PEN_BUTTONTEXT }, 83 | }, 84 | MinMax = { -4, 4, 4, -4 }, 85 | } 86 | } 87 | 88 | ------------------------------------------------------------------------------- 89 | -- Class implementation: 90 | ------------------------------------------------------------------------------- 91 | 92 | local RadioButton = _M 93 | 94 | function RadioButton.init(self) 95 | self.Image = self.Image or RadioImage1 96 | self.AltImage = self.AltImage or RadioImage2 97 | self.Mode = self.Mode or "touch" 98 | return CheckMark.init(self) 99 | end 100 | 101 | ------------------------------------------------------------------------------- 102 | -- onSelect: 103 | ------------------------------------------------------------------------------- 104 | 105 | function RadioButton:onSelect(selected) 106 | if selected then 107 | -- unselect siblings in group: 108 | local myclass = self:getClass() 109 | for _, e in ipairs(self.Parent.Children) do 110 | if e ~= self and e:getClass() == myclass and e.Selected then 111 | e:setValue("Selected", false) -- no notify 112 | end 113 | end 114 | end 115 | CheckMark.onSelect(self, selected) 116 | end 117 | -------------------------------------------------------------------------------- /tekui/tek/ui/class/spacer.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | -- 3 | -- tek.ui.class.spacer 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | -- LINEAGE:: 8 | -- [[#ClassOverview]] : 9 | -- [[#tek.class : Class]] / 10 | -- [[#tek.class.object : Object]] / 11 | -- [[#tek.ui.class.element : Element]] / 12 | -- [[#tek.ui.class.area : Area]] / 13 | -- [[#tek.ui.class.frame : Frame]] / 14 | -- Spacer 15 | -- 16 | -- OVERVIEW:: 17 | -- This class implements a separator 18 | -- that helps to arrange elements in a group visually. 19 | -- 20 | -- OVERRIDES:: 21 | -- - Area:askMinMax() 22 | -- - Area:show() 23 | -- 24 | ------------------------------------------------------------------------------- 25 | 26 | local ui = require "tek.ui" 27 | local Frame = ui.Frame 28 | 29 | module("tek.ui.class.spacer", tek.ui.class.frame) 30 | _VERSION = "Spacer 1.3" 31 | 32 | ------------------------------------------------------------------------------- 33 | -- Constants & Class data: 34 | ------------------------------------------------------------------------------- 35 | 36 | local DEF_BORDER = { 1, 1, 1, 1 } 37 | local DEF_PADDING = { 0, 0, 0, 0 } 38 | 39 | ------------------------------------------------------------------------------- 40 | -- Class implementation: 41 | ------------------------------------------------------------------------------- 42 | 43 | local Spacer = _M 44 | 45 | ------------------------------------------------------------------------------- 46 | -- show: 47 | ------------------------------------------------------------------------------- 48 | 49 | function Spacer:show(display, drawable) 50 | local theme = display.Theme 51 | -- outer spacing: 52 | self.Margin = self.Margin or theme.SpacerMargin or false 53 | -- outer border: 54 | self.Border = self.Border or theme.SpacerBorder or DEF_BORDER 55 | -- inner spacing: 56 | self.Padding = self.Padding or theme.SpacerPadding or DEF_PADDING 57 | -- outer borderstyle: 58 | self.BorderStyle = self.BorderStyle or theme.SpacerBorderStyle or "recess" 59 | return Frame.show(self, display, drawable) 60 | end 61 | 62 | ------------------------------------------------------------------------------- 63 | -- askMinMax: 64 | ------------------------------------------------------------------------------- 65 | 66 | function Spacer:askMinMax(m1, m2, m3, m4) 67 | local o = self.Parent and self.Parent:getStructure() 68 | if o == 1 then 69 | self.Height = "fill" 70 | self.Width = "auto" 71 | else 72 | self.Width = "fill" 73 | self.Height = "auto" 74 | end 75 | return Frame.askMinMax(self, m1, m2, m3, m4) 76 | end 77 | -------------------------------------------------------------------------------- /tekui/tek/ui/class/vectorimage.lua: -------------------------------------------------------------------------------- 1 | 2 | -- 3 | -- tek.ui.class.vectorimage 4 | -- Written by Timm S. Mueller 5 | -- See copyright notice in COPYRIGHT 6 | -- 7 | -- OVERVIEW:: 8 | -- Implements vector graphics rendering 9 | -- 10 | 11 | module("tek.ui.class.vectorimage", tek.class) 12 | _VERSION = "VectorImage 1.1" 13 | 14 | ------------------------------------------------------------------------------- 15 | -- Class implementation: 16 | ------------------------------------------------------------------------------- 17 | 18 | local VectorImage = _M 19 | 20 | function VectorImage:draw(drawable, rect) 21 | VectorImage.render(drawable, rect, self.ImageData) 22 | end 23 | 24 | ------------------------------------------------------------------------------- 25 | -- Static methods: 26 | ------------------------------------------------------------------------------- 27 | 28 | function VectorImage.render(drawable, rect, data) 29 | data.PenTable = drawable.Pens 30 | data.Rect = rect 31 | drawable:drawImage(data) -- TODO: pass PenTable, Rect 32 | end 33 | -------------------------------------------------------------------------------- /tekui/tek/ui/cursor/cursor-green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luaforge/tekui/b3e50bda6b95b46c766937b78d361c7c10e38739/tekui/tek/ui/cursor/cursor-green.png -------------------------------------------------------------------------------- /tekui/tek/ui/font/Vera.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luaforge/tekui/b3e50bda6b95b46c766937b78d361c7c10e38739/tekui/tek/ui/font/Vera.ttf -------------------------------------------------------------------------------- /tekui/tek/ui/font/VeraMono.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luaforge/tekui/b3e50bda6b95b46c766937b78d361c7c10e38739/tekui/tek/ui/font/VeraMono.ttf --------------------------------------------------------------------------------