├── .gitignore ├── .travis.yml ├── .travis ├── valgrind_test.sh └── valgrind_test.supp ├── LICENSE ├── README.md ├── docs ├── enums.md └── reference.md ├── examples ├── common.css ├── hello │ ├── hello.lua │ └── main.lua ├── luacheck │ ├── luacheck.lua │ └── main.lua └── resources ├── luawt-0.0-1.rockspec ├── spec ├── luawt_spec.lua ├── luawtest_spec.lua ├── shared_spec.lua └── widgets_spec.lua ├── src ├── boost-xtime.hpp └── luawt │ ├── .gitignore │ ├── Global.hpp │ ├── MyApplication.cpp │ ├── WAbstractItemView.cpp │ ├── WAbstractMedia.cpp │ ├── WAbstractSpinBox.cpp │ ├── WAbstractToggleButton.cpp │ ├── WAnchor.cpp │ ├── WAudio.cpp │ ├── WBreak.cpp │ ├── WCalendar.cpp │ ├── WCheckBox.cpp │ ├── WComboBox.cpp │ ├── WCompositeWidget.cpp │ ├── WContainerWidget.cpp │ ├── WDateEdit.cpp │ ├── WDatePicker.cpp │ ├── WDefaultLoadingIndicator.cpp │ ├── WDialog.cpp │ ├── WDoubleSpinBox.cpp │ ├── WEnvironment.cpp │ ├── WFileUpload.cpp │ ├── WFlashObject.cpp │ ├── WFormWidget.cpp │ ├── WGLWidget.cpp │ ├── WGoogleMap.cpp │ ├── WGroupBox.cpp │ ├── WIconPair.cpp │ ├── WImage.cpp │ ├── WInPlaceEdit.cpp │ ├── WInteractWidget.cpp │ ├── WLabel.cpp │ ├── WLineEdit.cpp │ ├── WMediaPlayer.cpp │ ├── WMenu.cpp │ ├── WMenuItem.cpp │ ├── WMessageBox.cpp │ ├── WNavigationBar.cpp │ ├── WOverlayLoadingIndicator.cpp │ ├── WPaintedWidget.cpp │ ├── WPanel.cpp │ ├── WPopupMenu.cpp │ ├── WPopupWidget.cpp │ ├── WProgressBar.cpp │ ├── WPushButton.cpp │ ├── WRadioButton.cpp │ ├── WScrollArea.cpp │ ├── WSelectionBox.cpp │ ├── WServer.cpp │ ├── WSlider.cpp │ ├── WSpinBox.cpp │ ├── WSplitButton.cpp │ ├── WStackedWidget.cpp │ ├── WSuggestionPopup.cpp │ ├── WTabWidget.cpp │ ├── WTable.cpp │ ├── WTableCell.cpp │ ├── WTableView.cpp │ ├── WTemplate.cpp │ ├── WTemplateFormView.cpp │ ├── WTestEnvironment.cpp │ ├── WText.cpp │ ├── WTextArea.cpp │ ├── WTextEdit.cpp │ ├── WTimerWidget.cpp │ ├── WToolBar.cpp │ ├── WTree.cpp │ ├── WTreeNode.cpp │ ├── WTreeTable.cpp │ ├── WTreeTableNode.cpp │ ├── WTreeView.cpp │ ├── WValidationStatus.cpp │ ├── WVideo.cpp │ ├── WViewWidget.cpp │ ├── WVirtualImage.cpp │ ├── WWebWidget.cpp │ ├── WWidget.cpp │ ├── enums.hpp │ ├── globals.hpp │ ├── init.cpp │ ├── shared.cpp │ ├── test.cpp │ └── test.lua └── tools ├── automate_bindings.py ├── automate_bindings.sh ├── blacklist.yaml ├── blacklist_test.yaml ├── gen-docs.lua └── mystyle /.gitignore: -------------------------------------------------------------------------------- 1 | # vim 2 | *.swp 3 | *.swo 4 | 5 | # build 6 | *.so 7 | *.o 8 | 9 | # gcov 10 | *.gcda 11 | *.gcno 12 | *.gcov 13 | 14 | # astyle 15 | *.orig 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | sudo: required 3 | dist: trusty # modern Wt 4 | 5 | env: 6 | global: 7 | - LUAROCKS=2.2.2 8 | matrix: 9 | - LUA="lua 5.1" 10 | - LUA="lua 5.2" 11 | - LUA="lua 5.3" 12 | - LUA="luajit 2.0" 13 | - LUA="luajit 2.1" 14 | 15 | branches: 16 | only: 17 | - master 18 | 19 | before_install: 20 | - sudo apt-get update 21 | - sudo apt-get install --yes gccxml libwt-dev libwthttp-dev libwttest-dev libyaml-dev 22 | - sudo pip install -U cpp-coveralls 23 | - sudo pip install hererocks 24 | - sudo pip install pygccxml 25 | - sudo pip install pyyaml 26 | - hererocks here --$LUA --luarocks $LUAROCKS 27 | - eval $(./here/bin/luarocks path --bin) 28 | 29 | install: 30 | - luarocks make 31 | 32 | before_script: 33 | - sudo apt-get install --yes valgrind 34 | - luarocks install busted 35 | - luarocks install luasocket 36 | - git clone https://github.com/starius/config 37 | - ./config/.bin/install-astyle 38 | 39 | script: 40 | - export LD_PRELOAD=/lib/x86_64-linux-gnu/libpthread.so.0 41 | - busted --shuffle --repeat=5 spec/* 42 | - if [[ "$LUA" != *"luajit"* ]]; then bash .travis/valgrind_test.sh; fi 43 | - luarocks make CFLAGS="-O0 -g -fPIC -ftest-coverage -fprofile-arcs" LIBFLAG="-shared --coverage" 44 | - busted spec/* 45 | # `after_success` section was moved to `script`, because we need to 46 | # catch errors in automate_bindings.py, but all the errors in 47 | # `after_success` sections are ignored by the worker. 48 | - coveralls --include src 49 | - ./tools/automate_bindings.sh --bind /usr/include/Wt/WText 50 | - mv src/luawt/WText.cpp src/luawt/WText.cpp.orig 51 | - ./tools/automate_bindings.sh --bind /usr/include/Wt/WText --blacklist tools/blacklist_test.yaml --module-only 52 | - "! cmp src/luawt/WText.cpp src/luawt/WText.cpp.orig" 53 | -------------------------------------------------------------------------------- /.travis/valgrind_test.sh: -------------------------------------------------------------------------------- 1 | set -xue 2 | 3 | export UNDER_VALGRIND=YES 4 | 5 | echo 'os.exit = function() end' > exitless-busted 6 | echo 'require "busted.runner"({ standalone = false, batch = true })' >> exitless-busted 7 | valgrind \ 8 | --error-exitcode=1 \ 9 | --leak-check=full \ 10 | --gen-suppressions=all \ 11 | --suppressions=.travis/valgrind_test.supp \ 12 | lua \ 13 | exitless-busted --sort spec/* 14 | rm exitless-busted 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # luawt 2 | 3 | [![Build Status][build-status]][travis] 4 | [![Coverage Status][coveralls-badge]][coveralls-page] 5 | [![License][license]](LICENSE) 6 | [![gitter][gitter-badge]][gitter-page] 7 | 8 | Lua bindings for Wt. 9 | 10 | ## Install 11 | 12 | Install [Wt][wt] `>=` 3.3.0 and [luarocks][luarocks]. 13 | 14 | Clone the repo and do 15 | `$ luarocks make` 16 | 17 | or 18 | 19 | `$ luarocks install luawt` 20 | 21 | ## Check 22 | 23 | `$ busted` 24 | 25 | ## How to use 26 | 27 | A Web application in luawt is just a Lua program. 28 | 29 | ```lua 30 | -- This code is executed in constructor of new application. 31 | -- It setups widgets of a start page shown to a user. 32 | local code = [[ 33 | -- app is an instance of WApplication 34 | -- env is an instance of WEnvironment 35 | local app, env = ... 36 | 37 | -- To create new widgets, we need luawt module. 38 | local luawt = require 'luawt' 39 | 40 | -- Create widgets. 41 | local textarea = luawt.WTextArea(app:root()) 42 | local button = luawt.WPushButton(app:root()) 43 | button:setText("Click me") 44 | 45 | -- Setup signal handler: uppercase text in the textarea. 46 | button:clicked():connect(function() 47 | textarea:setText(textarea:text():upper()) 48 | end) 49 | ]] 50 | 51 | local luawt = require 'luawt' 52 | 53 | -- Start WServer with the code above. 54 | local server = luawt.WServer({ 55 | code = code, 56 | ip = '127.0.0.1', 57 | port = 8080, 58 | }) 59 | server:start() 60 | server:waitForShutdown() 61 | ``` 62 | 63 | See [the list of Wt classes bound to luawt][reference]. 64 | 65 | See [examples][examples]: 66 | * hello [source][hello-source], [demo][hello-demo], 67 | * luacheck [source][luacheck-source], [demo][luacheck-demo]. 68 | 69 | ## How to bind new class 70 | 71 | - new .cpp file 72 | - globals.hpp 73 | - init.cpp (note that base must be before child) 74 | - rockspec 75 | 76 | There is the tool [automate bindings][automate_bindings] which is used 77 | to generate most of the code. To generate code compatible with wide 78 | range of Wt versions, the tool has an option to provide a blacklist 79 | of classes and methods to omit. It has also an option to generate 80 | such a blacklist. 81 | 82 | The tool [gen docs][gen-docs] is used to generate 83 | [reference][reference]. 84 | 85 | [license]: https://img.shields.io/badge/License-GPL2-brightgreen.png 86 | [travis]: https://travis-ci.org/LuaAndC/luawt 87 | [build-status]: https://travis-ci.org/LuaAndC/luawt.png?branch=master 88 | [coveralls-page]: https://coveralls.io/r/LuaAndC/luawt 89 | [coveralls-badge]: https://coveralls.io/repos/LuaAndC/luawt/badge.png 90 | [gitter-page]: https://gitter.im/luawt/Lobby 91 | [gitter-badge]: https://badges.gitter.im/USER/REPO.png 92 | [examples]: https://github.com/LuaAndC/luawt/tree/master/examples 93 | [reference]: https://github.com/LuaAndC/luawt/blob/master/docs/reference.md 94 | [automate_bindings]: https://github.com/LuaAndC/luawt/blob/master/tools/automate_bindings.py 95 | [gen-docs]: https://github.com/LuaAndC/luawt/blob/master/tools/gen-docs.lua 96 | [wt]: https://www.webtoolkit.eu/ 97 | [luarocks]: https://luarocks.org/ 98 | [hello-source]: https://github.com/LuaAndC/luawt/tree/master/examples/hello 99 | [hello-demo]: http://78.47.9.147:12346/ 100 | [luacheck-source]: https://github.com/LuaAndC/luawt/tree/master/examples/luacheck 101 | [luacheck-demo]: http://78.47.9.147:12345/ 102 | -------------------------------------------------------------------------------- /docs/enums.md: -------------------------------------------------------------------------------- 1 | # Dealing with enums 2 | 3 | ## Standard (normal) enums 4 | 5 | Passing in the form of a string or a number: 6 | ``` 7 | ... 8 | app:root():setContentAlignment('AlignCenter') 9 | -- OR 10 | app:root():setContentAlignment(4) 11 | ``` 12 | 13 | Return only in the form of a string, which can be converted 14 | to a number though (see `luawt.enums` section). 15 | ``` 16 | ... 17 | local google_map = luawt.WGoogleMap(1) 18 | google_map:apiVersion() --> 'Version3' 19 | ``` 20 | 21 | ## Special (flag) enums 22 | 23 | Passing in the form of a table containing all the strings 24 | in the given flags combination, e.g.: 25 | ``` 26 | ... 27 | local button = luawt.WPushButton(app:root()) 28 | button:setVerticalAlignment({'AlignTop', 'AlignSub'}) 29 | ``` 30 | Options for standard enums work as well: 31 | ``` 32 | ... 33 | local button = luawt.WPushButton(app:root()) 34 | button:setVerticalAlignment('AlignTop') 35 | -- Or 36 | button:setVerticalAlignment(192) 37 | -- Is equal to button:setVerticalAlignment({'AlignTop', 'AlignSuper'}) 38 | ``` 39 | 40 | Return in the form of table (['enum_string'] --> enum_value) 41 | ``` 42 | ... 43 | 44 | button:setVerticalAlignment({'AlignTop', 'AlignSub'}) 45 | button:verticalAlignment() --> {AlignSub = 32, AlignTop = 128,} 46 | ``` 47 | 48 | ## `luawt.enums` section 49 | 50 | Tables for getting values correspoding to the given strings, e.g.: 51 | ``` 52 | luawt.enums.Side.Bottom --> 2 53 | luawt.enums.Side.CenterX --> 16 54 | ``` 55 | -------------------------------------------------------------------------------- /examples/common.css: -------------------------------------------------------------------------------- 1 | .button { 2 | border-top: 1px solid #96d1f8; 3 | background: #65a9d7; 4 | background: -webkit-gradient(linear, left top, left bottom, from(#1ad445), to(#65a9d7)); 5 | background: -webkit-linear-gradient(top, #1ad445, #65a9d7); 6 | background: -moz-linear-gradient(top, #1ad445, #65a9d7); 7 | background: -ms-linear-gradient(top, #1ad445, #65a9d7); 8 | background: -o-linear-gradient(top, #1ad445, #65a9d7); 9 | padding: 1% 2.5%; 10 | -webkit-border-radius: 16%; 11 | -moz-border-radius: 12%; 12 | border-radius: 12%; 13 | -webkit-box-shadow: rgba(0,0,0,1) 0 1px 0; 14 | -moz-box-shadow: rgba(0,0,0,1) 0 1px 0; 15 | box-shadow: rgba(0,0,0,1) 0 1px 0; 16 | text-shadow: rgba(0,0,0,.4) 0 1px 0; 17 | color: #000000; 18 | font-size: 100%; 19 | font-family: Georgia, serif; 20 | text-decoration: none; 21 | vertical-align: middle; 22 | } 23 | .button:hover { 24 | border-top-color: #28597a; 25 | background: #28597a; 26 | color: #ccc; 27 | } 28 | .button:active { 29 | border-top-color: #1b435e; 30 | background: #1b435e; 31 | } 32 | 33 | .my_text { 34 | font-weight:normal;color:#1A28A3;letter-spacing:1pt;word-spacing:2pt;font-size:160%;text-align:center;font-family:trebuchet MS, sans-serif;line-height:1; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /examples/hello/hello.lua: -------------------------------------------------------------------------------- 1 | -- This code is executed in constructor of new application. 2 | -- It setups widgets of a start page shown to a user. 3 | local luawt = require 'luawt' 4 | 5 | -- app is an instance of WApplication 6 | -- env is an instance of WEnvironment 7 | local app, env = ... 8 | 9 | function breakTheLine() 10 | app:root():addWidget(luawt.WBreak()) 11 | app:root():addWidget(luawt.WBreak()) 12 | end 13 | 14 | function mainApp() 15 | app:setTitle('Hello!') 16 | -- Use CSS style sheet file. Note that it should be in docroot 17 | -- specified by WServer's options. 18 | app:useStyleSheet('./common.css') 19 | -- Set AlignmentFlag enum in the form of string. 20 | app:root():setContentAlignment('AlignCenter') 21 | -- Enums can be represented in many ways, see docs/enums.md 22 | -- for more information. 23 | 24 | -- Create widgets. 25 | local text = luawt.WText('Your name, please?') 26 | breakTheLine() 27 | local name_edit = luawt.WLineEdit(app:root()) 28 | breakTheLine() 29 | name_edit:setFocus() 30 | local button = luawt.WPushButton('Greet me', app:root()) 31 | -- Set CSS style classes (from common.css). 32 | button:setStyleClass('button') 33 | text:setStyleClass('my_text') 34 | -- Setup singal handler. 35 | button:clicked():connect(function() 36 | text:setText('Hello there, ' .. name_edit:text()) 37 | end) 38 | end 39 | 40 | mainApp() 41 | -------------------------------------------------------------------------------- /examples/hello/main.lua: -------------------------------------------------------------------------------- 1 | local luawt = require 'luawt' 2 | 3 | -- Get code of the application as a string. 4 | local module_file = io.open('./examples/hello/hello.lua', 'r') 5 | local code = module_file:read('*all') 6 | module_file:close() 7 | 8 | -- Create and start WServer. 9 | -- `docroot` option is needed to find static resources (CSS in our case). 10 | local server = luawt.WServer({ 11 | code = code, 12 | ip = '0.0.0.0', 13 | port = 12346, 14 | docroot = './examples', 15 | }) 16 | server:start() 17 | server:waitForShutdown() 18 | -------------------------------------------------------------------------------- /examples/luacheck/luacheck.lua: -------------------------------------------------------------------------------- 1 | -- This code is executed in constructor of new application. 2 | -- It setups widgets of a start page shown to a user. 3 | local luacheck = require 'luacheck' 4 | local luawt = require 'luawt' 5 | 6 | -- app is an instance of WApplication 7 | -- env is an instance of WEnvironment 8 | local app, env = ... 9 | 10 | app:setTitle('luacheck') 11 | -- Use CSS style sheet file. Note that it should be in docroot 12 | -- specified by WServer's options. 13 | app:useStyleSheet('./common.css') 14 | 15 | -- Set AlignmentFlag enum in the form of string. 16 | app:root():setContentAlignment('AlignCenter') 17 | -- Enums can be represented in many ways, see docs/enums.md 18 | -- for more information. 19 | 20 | -- Create widgets. 21 | local textarea = luawt.WTextArea(app:root()) 22 | app:root():addWidget(luawt.WBreak()) 23 | local button = luawt.WPushButton(app:root()) 24 | app:root():addWidget(luawt.WBreak()) 25 | button:setText('Check Lua syntax') 26 | local result = luawt.WText(app:root()) 27 | -- Set CSS style classes (from common.css). 28 | result:setStyleClass('my_text') 29 | button:setStyleClass('button') 30 | 31 | -- Setup signal handler. 32 | button:clicked():connect(function() 33 | -- Play with luacheck a bit. 34 | local c = luacheck.check_strings({textarea:text()}) 35 | if c.fatals + c.errors + c.warnings > 0 then 36 | local error_msg = '' 37 | for i = 1, #c[1] do 38 | error_msg = error_msg .. luacheck.get_message(c[1][i]) .. '\n' 39 | end 40 | result:setText('\nErrors: \n' .. error_msg) 41 | else 42 | result:setText('No errors') 43 | end 44 | end) 45 | -------------------------------------------------------------------------------- /examples/luacheck/main.lua: -------------------------------------------------------------------------------- 1 | local luawt = require 'luawt' 2 | 3 | -- Get code of the application as a string. 4 | local module_file = io.open('./examples/luacheck/luacheck.lua', 'r') 5 | local code = module_file:read('*all') 6 | module_file:close() 7 | 8 | -- Create and start WServer. 9 | -- `docroot` option is needed to find static resources (CSS in our case). 10 | local server = luawt.WServer({ 11 | code = code, 12 | ip = '0.0.0.0', 13 | port = 12345, 14 | docroot = './examples', 15 | }) 16 | server:start() 17 | server:waitForShutdown() 18 | -------------------------------------------------------------------------------- /examples/resources: -------------------------------------------------------------------------------- 1 | /usr/share/Wt/resources/ -------------------------------------------------------------------------------- /luawt-0.0-1.rockspec: -------------------------------------------------------------------------------- 1 | -- luawt, Lua bindings for Wt 2 | -- Copyright (c) 2015-2017 Pavel Dolgov and Boris Nagaev 3 | -- See the LICENSE file for terms of use. 4 | 5 | local function merge(...) 6 | local arrays = {...} 7 | local results = {} 8 | local z = 1 9 | for i = 1, #arrays do 10 | for j = 1, #arrays[i] do 11 | results[z] = arrays[i][j] 12 | z = z + 1 13 | end 14 | end 15 | return results 16 | end 17 | 18 | local common = { 19 | sources = { 20 | "src/luawt/MyApplication.cpp", 21 | "src/luawt/WAbstractItemView.cpp", 22 | "src/luawt/WAbstractMedia.cpp", 23 | "src/luawt/WAbstractSpinBox.cpp", 24 | "src/luawt/WAbstractToggleButton.cpp", 25 | "src/luawt/WAnchor.cpp", 26 | "src/luawt/WAudio.cpp", 27 | "src/luawt/WBreak.cpp", 28 | "src/luawt/WCalendar.cpp", 29 | "src/luawt/WCheckBox.cpp", 30 | "src/luawt/WComboBox.cpp", 31 | "src/luawt/WCompositeWidget.cpp", 32 | "src/luawt/WContainerWidget.cpp", 33 | "src/luawt/WDateEdit.cpp", 34 | "src/luawt/WDatePicker.cpp", 35 | "src/luawt/WDefaultLoadingIndicator.cpp", 36 | "src/luawt/WDialog.cpp", 37 | "src/luawt/WDoubleSpinBox.cpp", 38 | "src/luawt/WEnvironment.cpp", 39 | "src/luawt/WFileUpload.cpp", 40 | "src/luawt/WFlashObject.cpp", 41 | "src/luawt/WFormWidget.cpp", 42 | "src/luawt/WGLWidget.cpp", 43 | "src/luawt/WGoogleMap.cpp", 44 | "src/luawt/WGroupBox.cpp", 45 | "src/luawt/WIconPair.cpp", 46 | "src/luawt/WImage.cpp", 47 | "src/luawt/WInPlaceEdit.cpp", 48 | "src/luawt/WInteractWidget.cpp", 49 | "src/luawt/WLabel.cpp", 50 | "src/luawt/WLineEdit.cpp", 51 | "src/luawt/WMediaPlayer.cpp", 52 | "src/luawt/WMenu.cpp", 53 | "src/luawt/WMenuItem.cpp", 54 | "src/luawt/WMessageBox.cpp", 55 | "src/luawt/WNavigationBar.cpp", 56 | "src/luawt/WOverlayLoadingIndicator.cpp", 57 | "src/luawt/WPaintedWidget.cpp", 58 | "src/luawt/WPanel.cpp", 59 | "src/luawt/WPopupMenu.cpp", 60 | "src/luawt/WPopupWidget.cpp", 61 | "src/luawt/WProgressBar.cpp", 62 | "src/luawt/WPushButton.cpp", 63 | "src/luawt/WRadioButton.cpp", 64 | "src/luawt/WScrollArea.cpp", 65 | "src/luawt/WSelectionBox.cpp", 66 | "src/luawt/WSlider.cpp", 67 | "src/luawt/WSpinBox.cpp", 68 | "src/luawt/WSplitButton.cpp", 69 | "src/luawt/WStackedWidget.cpp", 70 | "src/luawt/WSuggestionPopup.cpp", 71 | "src/luawt/WTabWidget.cpp", 72 | "src/luawt/WTable.cpp", 73 | "src/luawt/WTableCell.cpp", 74 | "src/luawt/WTableView.cpp", 75 | "src/luawt/WTemplate.cpp", 76 | "src/luawt/WTemplateFormView.cpp", 77 | "src/luawt/WText.cpp", 78 | "src/luawt/WTextArea.cpp", 79 | "src/luawt/WTextEdit.cpp", 80 | "src/luawt/WTimerWidget.cpp", 81 | "src/luawt/WToolBar.cpp", 82 | "src/luawt/WTree.cpp", 83 | "src/luawt/WTreeNode.cpp", 84 | "src/luawt/WTreeTable.cpp", 85 | "src/luawt/WTreeTableNode.cpp", 86 | "src/luawt/WTreeView.cpp", 87 | "src/luawt/WValidationStatus.cpp", 88 | "src/luawt/WVideo.cpp", 89 | "src/luawt/WViewWidget.cpp", 90 | "src/luawt/WVirtualImage.cpp", 91 | "src/luawt/WWebWidget.cpp", 92 | "src/luawt/WWidget.cpp", 93 | "src/luawt/init.cpp", 94 | "src/luawt/shared.cpp", 95 | "src/luawt/test.cpp", 96 | }, 97 | libraries = { 98 | "wt", 99 | }, 100 | incdirs = { 101 | "src", -- for boost-xtime.hpp 102 | }, 103 | } 104 | 105 | package = "luawt" 106 | version = "0.0-1" 107 | source = { 108 | url = "git+https://github.com/LuaAndC/luawt.git", 109 | } 110 | description = { 111 | summary = "Lua bindings for Wt", 112 | homepage = "https://github.com/LuaAndC/luawt", 113 | license = "GPL 2.0", 114 | } 115 | dependencies = { 116 | "lua >= 5.1", 117 | } 118 | external_dependencies = { 119 | WT = { 120 | header = "Wt/WConfig.h", 121 | }, 122 | } 123 | build = { 124 | type = "builtin", 125 | modules = { 126 | luawt = { 127 | sources = merge( 128 | common.sources, 129 | {"src/luawt/WServer.cpp"} 130 | ), 131 | libraries = merge( 132 | common.libraries, 133 | { 134 | "wthttp", 135 | "boost_system-mt", 136 | } 137 | ), 138 | incdirs = common.incdirs, 139 | }, 140 | luawtest = { 141 | sources = merge( 142 | common.sources, 143 | {"src/luawt/WTestEnvironment.cpp"} 144 | ), 145 | defines = { 146 | "LUAWTEST", 147 | }, 148 | libraries = merge( 149 | common.libraries, 150 | { 151 | "wttest", 152 | "boost_system-mt", 153 | } 154 | ), 155 | incdirs = common.incdirs, 156 | }, 157 | ['luawt.test'] = "src/luawt/test.lua", 158 | }, 159 | } 160 | build.platforms = { 161 | unix = { 162 | modules = { 163 | luawt = { 164 | libraries = merge( 165 | common.libraries, 166 | { 167 | "wthttp", 168 | "boost_system", 169 | "stdc++", 170 | } 171 | ), 172 | }, 173 | luawtest = { 174 | libraries = merge( 175 | common.libraries, 176 | { 177 | "wttest", 178 | "boost_system", 179 | "stdc++", 180 | } 181 | ), 182 | }, 183 | }, 184 | }, 185 | } 186 | -------------------------------------------------------------------------------- /spec/luawt_spec.lua: -------------------------------------------------------------------------------- 1 | -- luawt, Lua bindings for Wt 2 | -- Copyright (c) 2015-2017 Pavel Dolgov and Boris Nagaev 3 | -- See the LICENSE file for terms of use. 4 | 5 | local test = require 'luawt.test' 6 | 7 | describe("luawt", function() 8 | 9 | it("#requires main module", function() 10 | require 'luawt' 11 | end) 12 | 13 | pending("supports Wt's #signal/slot system", function() 14 | local code = [[ 15 | local app, env = ... 16 | local luawt = require 'luawt' 17 | local button = luawt.WPushButton(app:root()) 18 | button:clicked():connect(function() 19 | button:setText("was pressed") 20 | end) 21 | button:clicked():emit() 22 | ]] 23 | local server, wt_config, data = test.getData(code) 24 | assert.truthy(data:match('was pressed')) 25 | test.clear(server, wt_config, false) 26 | end) 27 | 28 | it("#works fine with #WPushButton's set/isDefault", function() 29 | local code = [[ 30 | local app, env = ... 31 | local luawt = require 'luawt' 32 | local button = luawt.WPushButton(app:root()) 33 | button:setDefault(true) 34 | local state1 = button:isDefault() 35 | button:setDefault(false) 36 | local state2 = button:isDefault() 37 | local text = tostring(state1) .. tostring(state2) 38 | button:setText(text) 39 | ]] 40 | local server, wt_config, data = test.getData(code) 41 | assert.truthy(data:match('10')) 42 | test.clear(server, wt_config, false) 43 | end) 44 | 45 | pending("uses #wrap with unknown exceptions", function() 46 | local code = [[ 47 | local luawt = require 'luawt' 48 | luawt.Test.unknownException() 49 | ]] 50 | local ip = '127.0.0.1' 51 | local port = 56789 52 | local wt_config = test.baseConfig() 53 | local server = test.createServer(code, ip, port, wt_config) 54 | assert.has_no_error(function() 55 | server:start() 56 | os.execute("sleep 1") 57 | test.socketRequest(port) 58 | os.execute("sleep 1") 59 | server:stop(true) 60 | end) 61 | os.remove(wt_config) 62 | end) 63 | 64 | pending("can stop the server #forcibly", function() 65 | local code = '' 66 | local server, wt_config = test.getData(code) 67 | test.clear(server, wt_config, true) 68 | end) 69 | 70 | pending("doesn't throw on bad #syntax in lua code", function() 71 | local code = "(;(;(;)))))" 72 | local ip = '127.0.0.1' 73 | local port = 56789 74 | local wt_config = test.baseConfig() 75 | local server = test.createServer(code, ip, port, wt_config) 76 | assert.has_no_error(function() 77 | server:start() 78 | os.execute("sleep 1") 79 | test.socketRequest(port) 80 | os.execute("sleep 1") 81 | server:stop(true) 82 | end) 83 | os.remove(wt_config) 84 | end) 85 | 86 | it("creates #simple application", function() 87 | local code = [[ 88 | local app, env = ... 89 | local luawt = require 'luawt' 90 | local text = "IP: " .. env:clientAddress() 91 | local button = luawt.WPushButton(app:root()) 92 | button:setText(text) 93 | ]] 94 | local server, wt_config, data = test.getData(code) 95 | assert.truthy(data:match('IP:')) 96 | test.clear(server, wt_config, false) 97 | end) 98 | 99 | it("provides different ways for using #enums", function() 100 | local luawt = require 'luawt' 101 | local code = [[ 102 | local app, env = ... 103 | local luawt = require 'luawt' 104 | local google_map = luawt.WGoogleMap(1) 105 | local api_version = google_map:apiVersion() 106 | luawt.Shared.api_version = api_version 107 | luawt.Shared.api_version_val = 108 | luawt.enums.WGoogleMap_ApiVersion[api_version] 109 | local google_map2 = luawt.WGoogleMap('Version2') 110 | api_version = google_map2:apiVersion() 111 | luawt.Shared.api_version2 = api_version 112 | luawt.Shared.api_version_val2 = 113 | luawt.enums.WGoogleMap_ApiVersion[api_version] 114 | ]] 115 | local server, wt_config, data = test.getData(code) 116 | assert.truthy(luawt.Shared.api_version == "Version3") 117 | assert.truthy(tonumber(luawt.Shared.api_version_val) == 1) 118 | assert.truthy(luawt.Shared.api_version2 == "Version2") 119 | assert.truthy(tonumber(luawt.Shared.api_version_val2) == 0) 120 | test.clear(server, wt_config, false) 121 | end) 122 | 123 | it("provides facilities for handling #special_enums", function() 124 | local luawt = require 'luawt' 125 | local code = [[ 126 | local app, env = ... 127 | local luawt = require 'luawt' 128 | local test = require 'luawt.test' 129 | local button = luawt.WPushButton(app:root()) 130 | button:setVerticalAlignment('AlignTop') 131 | local align1 = button:verticalAlignment() 132 | luawt.Shared.align1_size = test.sizeOf(align1) 133 | luawt.Shared.align1_el1 = align1['AlignTop'] 134 | button:setVerticalAlignment({'AlignTop', 'AlignSub'}) 135 | local align2 = button:verticalAlignment() 136 | luawt.Shared.align2_size = test.sizeOf(align2) 137 | luawt.Shared.align2_el1 = align2['AlignTop'] 138 | luawt.Shared.align2_el2 = align2['AlignSub'] 139 | button:setVerticalAlignment(192) 140 | local align3 = button:verticalAlignment() 141 | luawt.Shared.align3_size = test.sizeOf(align3) 142 | luawt.Shared.align3_el1 = align3['AlignTop'] 143 | luawt.Shared.align3_el2 = align3['AlignSuper'] 144 | ]] 145 | local server, wt_config, data = test.getData(code) 146 | assert.truthy(tonumber(luawt.Shared.align1_size) == 1) 147 | assert.truthy(tonumber(luawt.Shared.align1_el1) == 128) 148 | assert.truthy(tonumber(luawt.Shared.align2_size) == 2) 149 | assert.truthy(tonumber(luawt.Shared.align2_el1) == 128) 150 | assert.truthy(tonumber(luawt.Shared.align2_el2) == 32) 151 | assert.truthy(tonumber(luawt.Shared.align3_size) == 2) 152 | assert.truthy(tonumber(luawt.Shared.align3_el1) == 128) 153 | assert.truthy(tonumber(luawt.Shared.align3_el2) == 64) 154 | test.clear(server, wt_config, false) 155 | end) 156 | 157 | end) 158 | -------------------------------------------------------------------------------- /spec/luawtest_spec.lua: -------------------------------------------------------------------------------- 1 | -- luawt, Lua bindings for Wt 2 | -- Copyright (c) 2015-2017 Pavel Dolgov and Boris Nagaev 3 | -- See the LICENSE file for terms of use. 4 | 5 | if os.getenv('UNDER_VALGRIND') then 6 | return 7 | end 8 | 9 | describe("luawtest", function() 10 | 11 | it("#requires main module", function() 12 | require 'luawtest' 13 | end) 14 | 15 | it("builds test application without a server", function() 16 | local luawtest = require 'luawtest' 17 | local env = luawtest.WTestEnvironment() 18 | local app = luawtest.MyApplication(env) 19 | local button = luawtest.WPushButton(app:root()) 20 | button:setText("кнопка") 21 | end) 22 | end) 23 | -------------------------------------------------------------------------------- /spec/shared_spec.lua: -------------------------------------------------------------------------------- 1 | -- luawt, Lua bindings for Wt 2 | -- Copyright (c) 2015-2017 Pavel Dolgov and Boris Nagaev 3 | -- See the LICENSE file for terms of use. 4 | 5 | local test = require 'luawt.test' 6 | 7 | describe("luawt.Shared", function() 8 | 9 | it("uses Shared correctly", function() 10 | local luawt = require 'luawt' 11 | luawt.Shared.test = 'true' 12 | assert.equal(luawt.Shared.test, 'true') 13 | luawt.Shared.test = nil 14 | assert.equal(luawt.Shared.test, nil) 15 | end) 16 | 17 | it("syncs from child thread", function() 18 | local luawt = require 'luawt' 19 | luawt.Shared.foo = "bar" 20 | local code = [[ 21 | local luawt = require 'luawt' 22 | assert(luawt.Shared.foo == "bar") 23 | luawt.Shared.bar = "foo" 24 | ]] 25 | local server, wt_config = test.getData(code) 26 | test.clear(server, wt_config, false) 27 | assert(luawt.Shared.bar == "foo") 28 | end) 29 | 30 | end) 31 | -------------------------------------------------------------------------------- /spec/widgets_spec.lua: -------------------------------------------------------------------------------- 1 | -- luawt, Lua bindings for Wt 2 | -- Copyright (c) 2015-2017 Pavel Dolgov and Boris Nagaev 3 | -- See the LICENSE file for terms of use. 4 | 5 | local test = require 'luawt.test' 6 | 7 | describe("luawt widgets", function() 8 | 9 | -- List of widgets tests 10 | it("creates WMenu", function() 11 | test.testWidget("WMenu", true) 12 | end) 13 | it("creates WBreak", function() 14 | test.testWidget("WBreak", true) 15 | end) 16 | it("creates WCalendar", function() 17 | test.testWidget("WCalendar", true) 18 | end) 19 | it("creates WTemplate", function() 20 | test.testWidget("WTemplate", true) 21 | end) 22 | it("creates WTableView", function() 23 | test.testWidget("WTableView", true) 24 | end) 25 | it("creates WContainerWidget", function() 26 | test.testWidget("WContainerWidget", true) 27 | end) 28 | it("creates WGroupBox", function() 29 | test.testWidget("WGroupBox", true) 30 | end) 31 | it("creates WPushButton", function() 32 | test.testWidget("WPushButton", true) 33 | end) 34 | it("creates WProgressBar", function() 35 | test.testWidget("WProgressBar", true) 36 | end) 37 | it("creates WPanel", function() 38 | test.testWidget("WPanel", true) 39 | end) 40 | it("creates WScrollArea", function() 41 | test.testWidget("WScrollArea", true) 42 | end) 43 | it("creates WLineEdit", function() 44 | test.testWidget("WLineEdit", true) 45 | end) 46 | it("creates WComboBox", function() 47 | test.testWidget("WComboBox", true) 48 | end) 49 | it("creates WTable", function() 50 | test.testWidget("WTable", true) 51 | end) 52 | it("creates WDoubleSpinBox", function() 53 | test.testWidget("WDoubleSpinBox", true) 54 | end) 55 | it("creates WTreeTable", function() 56 | test.testWidget("WTreeTable", true) 57 | end) 58 | it("creates WTextEdit", function() 59 | test.testWidget("WTextEdit", true) 60 | end) 61 | it("creates WSpinBox", function() 62 | test.testWidget("WSpinBox", true) 63 | end) 64 | it("creates WDefaultLoadingIndicator", function() 65 | test.testWidget("WDefaultLoadingIndicator", false) 66 | end) 67 | it("creates WPopupMenu", function() 68 | test.testWidget("WPopupMenu", false) 69 | end) 70 | it("creates WAnchor", function() 71 | test.testWidget("WAnchor", true) 72 | end) 73 | it("creates WSplitButton", function() 74 | test.testWidget("WSplitButton", true) 75 | end) 76 | it("creates WVideo", function() 77 | test.testWidget("WVideo", true) 78 | end) 79 | it("creates WToolBar", function() 80 | test.testWidget("WToolBar", true) 81 | end) 82 | it("creates WNavigationBar", function() 83 | test.testWidget("WNavigationBar", true) 84 | end) 85 | it("creates WTreeView", function() 86 | test.testWidget("WTreeView", true) 87 | end) 88 | it("creates WTemplateFormView", function() 89 | test.testWidget("WTemplateFormView", true) 90 | end) 91 | it("creates WSlider", function() 92 | test.testWidget("WSlider", true) 93 | end) 94 | it("creates WAudio", function() 95 | test.testWidget("WAudio", true) 96 | end) 97 | it("creates WGoogleMap", function() 98 | test.testWidget("WGoogleMap", true) 99 | end) 100 | it("creates WFileUpload", function() 101 | test.testWidget("WFileUpload", true) 102 | end) 103 | it("creates WImage", function() 104 | test.testWidget("WImage", true) 105 | end) 106 | it("creates WCheckBox", function() 107 | test.testWidget("WCheckBox", true) 108 | end) 109 | it("creates WOverlayLoadingIndicator", function() 110 | test.testWidget("WOverlayLoadingIndicator", false) 111 | end) 112 | it("creates WRadioButton", function() 113 | test.testWidget("WRadioButton", true) 114 | end) 115 | it("creates WTabWidget", function() 116 | test.testWidget("WTabWidget", true) 117 | end) 118 | it("creates WStackedWidget", function() 119 | test.testWidget("WStackedWidget", true) 120 | end) 121 | it("creates WText", function() 122 | test.testWidget("WText", true) 123 | end) 124 | it("creates WSelectionBox", function() 125 | test.testWidget("WSelectionBox", true) 126 | end) 127 | it("creates WTree", function() 128 | test.testWidget("WTree", true) 129 | end) 130 | it("creates WTextArea", function() 131 | test.testWidget("WTextArea", true) 132 | end) 133 | it("creates WDateEdit", function() 134 | test.testWidget("WDateEdit", true) 135 | end) 136 | it("creates WLabel", function() 137 | test.testWidget("WLabel", true) 138 | end) 139 | it("creates WDatePicker", function() 140 | test.testWidget("WDatePicker", true) 141 | end) 142 | 143 | end) 144 | -------------------------------------------------------------------------------- /src/boost-xtime.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2001-2003 2 | // William E. Kempf 3 | // Copyright (C) 2007-8 Anthony Williams 4 | // 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | #ifndef BOOST_XTIME_WEK070601_HPP 9 | #define BOOST_XTIME_WEK070601_HPP 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | namespace boost { 20 | 21 | enum xtime_clock_types { 22 | TIME_UTC_ = 1 23 | }; 24 | 25 | struct xtime { 26 | #if defined(BOOST_NO_INT64_T) 27 | typedef int_fast32_t xtime_sec_t; //INT_FAST32_MIN <= sec <= INT_FAST32_MAX 28 | #else 29 | typedef int_fast64_t xtime_sec_t; //INT_FAST64_MIN <= sec <= INT_FAST64_MAX 30 | #endif 31 | 32 | typedef int_fast32_t xtime_nsec_t; 33 | //0 <= xtime.nsec < NANOSECONDS_PER_SECOND 34 | 35 | xtime_sec_t sec; 36 | xtime_nsec_t nsec; 37 | 38 | operator system_time() const { 39 | return boost::posix_time::from_time_t(0) + 40 | boost::posix_time::seconds(static_cast(sec)) + 41 | #ifdef BOOST_DATE_TIME_HAS_NANOSECONDS 42 | boost::posix_time::nanoseconds(nsec); 43 | #else 44 | boost::posix_time::microseconds((nsec + 500) / 1000); 45 | #endif 46 | } 47 | 48 | }; 49 | 50 | inline xtime get_xtime(boost::system_time const& abs_time) { 51 | xtime res; 52 | boost::posix_time::time_duration const time_since_epoch = 53 | abs_time - boost::posix_time::from_time_t(0); 54 | res.sec = static_cast(time_since_epoch.total_seconds()); 55 | res.nsec = static_cast 56 | (time_since_epoch.fractional_seconds() * 57 | (1000000000 / time_since_epoch.ticks_per_second())); 58 | return res; 59 | } 60 | 61 | inline int xtime_get(struct xtime* xtp, int clock_type) { 62 | if (clock_type == TIME_UTC_) { 63 | *xtp = get_xtime(get_system_time()); 64 | return clock_type; 65 | } 66 | return 0; 67 | } 68 | 69 | inline int xtime_cmp(const xtime& xt1, const xtime& xt2) { 70 | if (xt1.sec == xt2.sec) { 71 | return (int)(xt1.nsec - xt2.nsec); 72 | } else { 73 | return (xt1.sec > xt2.sec) ? 1 : -1; 74 | } 75 | } 76 | 77 | } // namespace boost 78 | 79 | #include 80 | 81 | #endif //BOOST_XTIME_WEK070601_HPP 82 | 83 | -------------------------------------------------------------------------------- /src/luawt/.gitignore: -------------------------------------------------------------------------------- 1 | xml 2 | -------------------------------------------------------------------------------- /src/luawt/Global.hpp: -------------------------------------------------------------------------------- 1 | /* luawt, Lua bindings for Wt 2 | * Copyright (c) 2015-2017 Pavel Dolgov and Boris Nagaev 3 | * 4 | * See the LICENSE file for terms of use. 5 | */ 6 | 7 | #ifndef GLOBAL_HPP_ 8 | #define GLOBAL_HPP_ 9 | 10 | #include 11 | #include 12 | 13 | // Useful typedefs. 14 | typedef long long int lint; 15 | 16 | typedef std::set StrsSet; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/luawt/WAudio.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | 6 | #include "enums.hpp" 7 | #include "globals.hpp" 8 | 9 | static const char* WAudio_make_args0[] = {NULL}; 10 | static const char* WAudio_make_args1[] = {luawt_typeToStr(), NULL}; 11 | static const char* const* const luawt_WAudio_make_args[] = {WAudio_make_args0, WAudio_make_args1, NULL}; 12 | 13 | int luawt_WAudio_make(lua_State* L) { 14 | int index = luawt_getSuitableArgsGroup(L, luawt_WAudio_make_args); 15 | if (index == 0) { 16 | WAudio* l_result = new WAudio(); 17 | MyApplication* app = MyApplication::instance(); 18 | if (!app) { 19 | delete l_result; 20 | throw std::logic_error("No WApplication when creating WAudio"); 21 | } 22 | app->root()->addWidget(l_result); 23 | luawt_toLua(L, l_result); 24 | return 1; 25 | } else if (index == 1) { 26 | Wt::WContainerWidget* parent = 27 | luawt_checkFromLua(L, 1); 28 | WAudio* l_result = new WAudio(parent); 29 | luawt_toLua(L, l_result); 30 | return 1; 31 | } else { 32 | return luaL_error(L, "Wrong arguments for WAudio.make"); 33 | } 34 | } 35 | 36 | static const char* WAudio_jsAudioRef_args0[] = {luawt_typeToStr(), NULL}; 37 | static const char* const* const luawt_WAudio_jsAudioRef_args[] = {WAudio_jsAudioRef_args0, NULL}; 38 | 39 | int luawt_WAudio_jsAudioRef(lua_State* L) { 40 | int index = luawt_getSuitableArgsGroup(L, luawt_WAudio_jsAudioRef_args); 41 | WAudio* self = luawt_checkFromLua(L, 1); 42 | if (index == 0) { 43 | std::string l_result = self->jsAudioRef(); 44 | lua_pushstring(L, l_result.c_str()); 45 | return 1; 46 | } else { 47 | return luaL_error(L, "Wrong arguments for WAudio.jsAudioRef"); 48 | } 49 | } 50 | 51 | ADD_SIGNAL(playbackStarted, WAudio, Wt::NoClass) 52 | ADD_SIGNAL(playbackPaused, WAudio, Wt::NoClass) 53 | ADD_SIGNAL(ended, WAudio, Wt::NoClass) 54 | ADD_SIGNAL(timeUpdated, WAudio, Wt::NoClass) 55 | ADD_SIGNAL(volumeChanged, WAudio, Wt::NoClass) 56 | ADD_SIGNAL(keyWentDown, WAudio, Wt::WKeyEvent) 57 | ADD_SIGNAL(keyPressed, WAudio, Wt::WKeyEvent) 58 | ADD_SIGNAL(keyWentUp, WAudio, Wt::WKeyEvent) 59 | ADD_SIGNAL(enterPressed, WAudio, Wt::NoClass) 60 | ADD_SIGNAL(escapePressed, WAudio, Wt::NoClass) 61 | ADD_SIGNAL(clicked, WAudio, Wt::WMouseEvent) 62 | ADD_SIGNAL(doubleClicked, WAudio, Wt::WMouseEvent) 63 | ADD_SIGNAL(mouseWentDown, WAudio, Wt::WMouseEvent) 64 | ADD_SIGNAL(mouseWentUp, WAudio, Wt::WMouseEvent) 65 | ADD_SIGNAL(mouseWentOut, WAudio, Wt::WMouseEvent) 66 | ADD_SIGNAL(mouseWentOver, WAudio, Wt::WMouseEvent) 67 | ADD_SIGNAL(mouseMoved, WAudio, Wt::WMouseEvent) 68 | ADD_SIGNAL(mouseDragged, WAudio, Wt::WMouseEvent) 69 | ADD_SIGNAL(mouseWheel, WAudio, Wt::WMouseEvent) 70 | ADD_SIGNAL(touchStarted, WAudio, Wt::WTouchEvent) 71 | ADD_SIGNAL(touchEnded, WAudio, Wt::WTouchEvent) 72 | ADD_SIGNAL(touchMoved, WAudio, Wt::WTouchEvent) 73 | ADD_SIGNAL(gestureStarted, WAudio, Wt::WGestureEvent) 74 | ADD_SIGNAL(gestureChanged, WAudio, Wt::WGestureEvent) 75 | ADD_SIGNAL(gestureEnded, WAudio, Wt::WGestureEvent) 76 | 77 | static const luaL_Reg luawt_WAudio_methods[] = { 78 | METHOD(WAudio, jsAudioRef), 79 | METHOD(WAudio, playbackStarted), 80 | METHOD(WAudio, playbackPaused), 81 | METHOD(WAudio, ended), 82 | METHOD(WAudio, timeUpdated), 83 | METHOD(WAudio, volumeChanged), 84 | METHOD(WAudio, keyWentDown), 85 | METHOD(WAudio, keyPressed), 86 | METHOD(WAudio, keyWentUp), 87 | METHOD(WAudio, enterPressed), 88 | METHOD(WAudio, escapePressed), 89 | METHOD(WAudio, clicked), 90 | METHOD(WAudio, doubleClicked), 91 | METHOD(WAudio, mouseWentDown), 92 | METHOD(WAudio, mouseWentUp), 93 | METHOD(WAudio, mouseWentOut), 94 | METHOD(WAudio, mouseWentOver), 95 | METHOD(WAudio, mouseMoved), 96 | METHOD(WAudio, mouseDragged), 97 | METHOD(WAudio, mouseWheel), 98 | METHOD(WAudio, touchStarted), 99 | METHOD(WAudio, touchEnded), 100 | METHOD(WAudio, touchMoved), 101 | METHOD(WAudio, gestureStarted), 102 | METHOD(WAudio, gestureChanged), 103 | METHOD(WAudio, gestureEnded), 104 | {NULL, NULL}, 105 | }; 106 | 107 | void luawt_WAudio(lua_State* L) { 108 | const char* base = luawt_typeToStr(); 109 | assert(base); 110 | DECLARE_CLASS( 111 | WAudio, 112 | L, 113 | wrap::func, 114 | 0, 115 | luawt_WAudio_methods, 116 | base 117 | ); 118 | } 119 | -------------------------------------------------------------------------------- /src/luawt/WBreak.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | 6 | #include "enums.hpp" 7 | #include "globals.hpp" 8 | 9 | static const char* WBreak_make_args0[] = {NULL}; 10 | static const char* WBreak_make_args1[] = {luawt_typeToStr(), NULL}; 11 | static const char* const* const luawt_WBreak_make_args[] = {WBreak_make_args0, WBreak_make_args1, NULL}; 12 | 13 | int luawt_WBreak_make(lua_State* L) { 14 | int index = luawt_getSuitableArgsGroup(L, luawt_WBreak_make_args); 15 | if (index == 0) { 16 | WBreak* l_result = new WBreak(); 17 | MyApplication* app = MyApplication::instance(); 18 | if (!app) { 19 | delete l_result; 20 | throw std::logic_error("No WApplication when creating WBreak"); 21 | } 22 | app->root()->addWidget(l_result); 23 | luawt_toLua(L, l_result); 24 | return 1; 25 | } else if (index == 1) { 26 | Wt::WContainerWidget* parent = 27 | luawt_checkFromLua(L, 1); 28 | WBreak* l_result = new WBreak(parent); 29 | luawt_toLua(L, l_result); 30 | return 1; 31 | } else { 32 | return luaL_error(L, "Wrong arguments for WBreak.make"); 33 | } 34 | } 35 | 36 | static const luaL_Reg luawt_WBreak_methods[] = { 37 | {NULL, NULL}, 38 | }; 39 | 40 | void luawt_WBreak(lua_State* L) { 41 | const char* base = luawt_typeToStr(); 42 | assert(base); 43 | DECLARE_CLASS( 44 | WBreak, 45 | L, 46 | wrap::func, 47 | 0, 48 | luawt_WBreak_methods, 49 | base 50 | ); 51 | } 52 | -------------------------------------------------------------------------------- /src/luawt/WCheckBox.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "enums.hpp" 8 | #include "globals.hpp" 9 | 10 | static const char* WCheckBox_make_args0[] = {NULL}; 11 | static const char* WCheckBox_make_args1[] = {luawt_typeToStr(), NULL}; 12 | static const char* WCheckBox_make_args2[] = {"char const *", NULL}; 13 | static const char* WCheckBox_make_args3[] = {"char const *", luawt_typeToStr(), NULL}; 14 | static const char* const* const luawt_WCheckBox_make_args[] = {WCheckBox_make_args0, WCheckBox_make_args1, WCheckBox_make_args2, WCheckBox_make_args3, NULL}; 15 | 16 | int luawt_WCheckBox_make(lua_State* L) { 17 | int index = luawt_getSuitableArgsGroup(L, luawt_WCheckBox_make_args); 18 | if (index == 0) { 19 | WCheckBox* l_result = new WCheckBox(); 20 | MyApplication* app = MyApplication::instance(); 21 | if (!app) { 22 | delete l_result; 23 | throw std::logic_error("No WApplication when creating WCheckBox"); 24 | } 25 | app->root()->addWidget(l_result); 26 | luawt_toLua(L, l_result); 27 | return 1; 28 | } else if (index == 1) { 29 | Wt::WContainerWidget* parent = 30 | luawt_checkFromLua(L, 1); 31 | WCheckBox* l_result = new WCheckBox(parent); 32 | luawt_toLua(L, l_result); 33 | return 1; 34 | } else if (index == 2) { 35 | char const* raw1 = lua_tostring(L, 1); 36 | Wt::WString text = Wt::WString(raw1); 37 | WCheckBox* l_result = new WCheckBox(text); 38 | MyApplication* app = MyApplication::instance(); 39 | if (!app) { 40 | delete l_result; 41 | throw std::logic_error("No WApplication when creating WCheckBox"); 42 | } 43 | app->root()->addWidget(l_result); 44 | luawt_toLua(L, l_result); 45 | return 1; 46 | } else if (index == 3) { 47 | char const* raw1 = lua_tostring(L, 1); 48 | Wt::WString text = Wt::WString(raw1); 49 | Wt::WContainerWidget* parent = 50 | luawt_checkFromLua(L, 2); 51 | WCheckBox* l_result = new WCheckBox(text, parent); 52 | luawt_toLua(L, l_result); 53 | return 1; 54 | } else { 55 | return luaL_error(L, "Wrong arguments for WCheckBox.make"); 56 | } 57 | } 58 | 59 | static const char* WCheckBox_setCheckState_args0[] = {luawt_typeToStr(), "enum", NULL}; 60 | static const char* const* const luawt_WCheckBox_setCheckState_args[] = {WCheckBox_setCheckState_args0, NULL}; 61 | 62 | int luawt_WCheckBox_setCheckState(lua_State* L) { 63 | int index = luawt_getSuitableArgsGroup(L, luawt_WCheckBox_setCheckState_args); 64 | WCheckBox* self = luawt_checkFromLua(L, 1); 65 | if (index == 0) { 66 | Wt::CheckState state = static_cast(luawt_getEnum( 67 | L, 68 | luawt_enum_CheckState_str, 69 | luawt_enum_CheckState_val, 70 | 2, 71 | "Wrong enum type in args of WCheckBox.setCheckState" 72 | )); 73 | self->setCheckState(state); 74 | return 0; 75 | } else { 76 | return luaL_error(L, "Wrong arguments for WCheckBox.setCheckState"); 77 | } 78 | } 79 | 80 | static const char* WCheckBox_isTristate_args0[] = {luawt_typeToStr(), NULL}; 81 | static const char* const* const luawt_WCheckBox_isTristate_args[] = {WCheckBox_isTristate_args0, NULL}; 82 | 83 | int luawt_WCheckBox_isTristate(lua_State* L) { 84 | int index = luawt_getSuitableArgsGroup(L, luawt_WCheckBox_isTristate_args); 85 | WCheckBox* self = luawt_checkFromLua(L, 1); 86 | if (index == 0) { 87 | bool l_result = self->isTristate(); 88 | lua_pushboolean(L, l_result); 89 | return 1; 90 | } else { 91 | return luaL_error(L, "Wrong arguments for WCheckBox.isTristate"); 92 | } 93 | } 94 | 95 | static const char* WCheckBox_setTristate_args0[] = {luawt_typeToStr(), NULL}; 96 | static const char* WCheckBox_setTristate_args1[] = {luawt_typeToStr(), "bool", NULL}; 97 | static const char* const* const luawt_WCheckBox_setTristate_args[] = {WCheckBox_setTristate_args0, WCheckBox_setTristate_args1, NULL}; 98 | 99 | int luawt_WCheckBox_setTristate(lua_State* L) { 100 | int index = luawt_getSuitableArgsGroup(L, luawt_WCheckBox_setTristate_args); 101 | WCheckBox* self = luawt_checkFromLua(L, 1); 102 | if (index == 0) { 103 | self->setTristate(); 104 | return 0; 105 | } else if (index == 1) { 106 | bool tristate = lua_toboolean(L, 2); 107 | self->setTristate(tristate); 108 | return 0; 109 | } else { 110 | return luaL_error(L, "Wrong arguments for WCheckBox.setTristate"); 111 | } 112 | } 113 | 114 | static const char* WCheckBox_checkState_args0[] = {luawt_typeToStr(), NULL}; 115 | static const char* const* const luawt_WCheckBox_checkState_args[] = {WCheckBox_checkState_args0, NULL}; 116 | 117 | int luawt_WCheckBox_checkState(lua_State* L) { 118 | int index = luawt_getSuitableArgsGroup(L, luawt_WCheckBox_checkState_args); 119 | WCheckBox* self = luawt_checkFromLua(L, 1); 120 | if (index == 0) { 121 | Wt::CheckState l_result = self->checkState(); 122 | luawt_returnEnum(L, luawt_enum_CheckState_str, luawt_enum_CheckState_val, l_result, "CheckState"); 123 | return 1; 124 | } else { 125 | return luaL_error(L, "Wrong arguments for WCheckBox.checkState"); 126 | } 127 | } 128 | 129 | ADD_SIGNAL(checked, WCheckBox, Wt::NoClass) 130 | ADD_SIGNAL(unChecked, WCheckBox, Wt::NoClass) 131 | ADD_SIGNAL(changed, WCheckBox, Wt::NoClass) 132 | ADD_SIGNAL(selected, WCheckBox, Wt::NoClass) 133 | ADD_SIGNAL(blurred, WCheckBox, Wt::NoClass) 134 | ADD_SIGNAL(focussed, WCheckBox, Wt::NoClass) 135 | ADD_SIGNAL(keyWentDown, WCheckBox, Wt::WKeyEvent) 136 | ADD_SIGNAL(keyPressed, WCheckBox, Wt::WKeyEvent) 137 | ADD_SIGNAL(keyWentUp, WCheckBox, Wt::WKeyEvent) 138 | ADD_SIGNAL(enterPressed, WCheckBox, Wt::NoClass) 139 | ADD_SIGNAL(escapePressed, WCheckBox, Wt::NoClass) 140 | ADD_SIGNAL(clicked, WCheckBox, Wt::WMouseEvent) 141 | ADD_SIGNAL(doubleClicked, WCheckBox, Wt::WMouseEvent) 142 | ADD_SIGNAL(mouseWentDown, WCheckBox, Wt::WMouseEvent) 143 | ADD_SIGNAL(mouseWentUp, WCheckBox, Wt::WMouseEvent) 144 | ADD_SIGNAL(mouseWentOut, WCheckBox, Wt::WMouseEvent) 145 | ADD_SIGNAL(mouseWentOver, WCheckBox, Wt::WMouseEvent) 146 | ADD_SIGNAL(mouseMoved, WCheckBox, Wt::WMouseEvent) 147 | ADD_SIGNAL(mouseDragged, WCheckBox, Wt::WMouseEvent) 148 | ADD_SIGNAL(mouseWheel, WCheckBox, Wt::WMouseEvent) 149 | ADD_SIGNAL(touchStarted, WCheckBox, Wt::WTouchEvent) 150 | ADD_SIGNAL(touchEnded, WCheckBox, Wt::WTouchEvent) 151 | ADD_SIGNAL(touchMoved, WCheckBox, Wt::WTouchEvent) 152 | ADD_SIGNAL(gestureStarted, WCheckBox, Wt::WGestureEvent) 153 | ADD_SIGNAL(gestureChanged, WCheckBox, Wt::WGestureEvent) 154 | ADD_SIGNAL(gestureEnded, WCheckBox, Wt::WGestureEvent) 155 | 156 | static const luaL_Reg luawt_WCheckBox_methods[] = { 157 | METHOD(WCheckBox, setTristate), 158 | METHOD(WCheckBox, isTristate), 159 | METHOD(WCheckBox, setCheckState), 160 | METHOD(WCheckBox, checkState), 161 | METHOD(WCheckBox, checked), 162 | METHOD(WCheckBox, unChecked), 163 | METHOD(WCheckBox, changed), 164 | METHOD(WCheckBox, selected), 165 | METHOD(WCheckBox, blurred), 166 | METHOD(WCheckBox, focussed), 167 | METHOD(WCheckBox, keyWentDown), 168 | METHOD(WCheckBox, keyPressed), 169 | METHOD(WCheckBox, keyWentUp), 170 | METHOD(WCheckBox, enterPressed), 171 | METHOD(WCheckBox, escapePressed), 172 | METHOD(WCheckBox, clicked), 173 | METHOD(WCheckBox, doubleClicked), 174 | METHOD(WCheckBox, mouseWentDown), 175 | METHOD(WCheckBox, mouseWentUp), 176 | METHOD(WCheckBox, mouseWentOut), 177 | METHOD(WCheckBox, mouseWentOver), 178 | METHOD(WCheckBox, mouseMoved), 179 | METHOD(WCheckBox, mouseDragged), 180 | METHOD(WCheckBox, mouseWheel), 181 | METHOD(WCheckBox, touchStarted), 182 | METHOD(WCheckBox, touchEnded), 183 | METHOD(WCheckBox, touchMoved), 184 | METHOD(WCheckBox, gestureStarted), 185 | METHOD(WCheckBox, gestureChanged), 186 | METHOD(WCheckBox, gestureEnded), 187 | {NULL, NULL}, 188 | }; 189 | 190 | void luawt_WCheckBox(lua_State* L) { 191 | const char* base = luawt_typeToStr(); 192 | assert(base); 193 | DECLARE_CLASS( 194 | WCheckBox, 195 | L, 196 | wrap::func, 197 | 0, 198 | luawt_WCheckBox_methods, 199 | base 200 | ); 201 | } 202 | -------------------------------------------------------------------------------- /src/luawt/WDateEdit.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "enums.hpp" 9 | #include "globals.hpp" 10 | 11 | static const char* WDateEdit_make_args0[] = {NULL}; 12 | static const char* WDateEdit_make_args1[] = {luawt_typeToStr(), NULL}; 13 | static const char* const* const luawt_WDateEdit_make_args[] = {WDateEdit_make_args0, WDateEdit_make_args1, NULL}; 14 | 15 | int luawt_WDateEdit_make(lua_State* L) { 16 | int index = luawt_getSuitableArgsGroup(L, luawt_WDateEdit_make_args); 17 | if (index == 0) { 18 | WDateEdit* l_result = new WDateEdit(); 19 | MyApplication* app = MyApplication::instance(); 20 | if (!app) { 21 | delete l_result; 22 | throw std::logic_error("No WApplication when creating WDateEdit"); 23 | } 24 | app->root()->addWidget(l_result); 25 | luawt_toLua(L, l_result); 26 | return 1; 27 | } else if (index == 1) { 28 | Wt::WContainerWidget* parent = 29 | luawt_checkFromLua(L, 1); 30 | WDateEdit* l_result = new WDateEdit(parent); 31 | luawt_toLua(L, l_result); 32 | return 1; 33 | } else { 34 | return luaL_error(L, "Wrong arguments for WDateEdit.make"); 35 | } 36 | } 37 | 38 | static const char* WDateEdit_setFormat_args0[] = {luawt_typeToStr(), "char const *", NULL}; 39 | static const char* const* const luawt_WDateEdit_setFormat_args[] = {WDateEdit_setFormat_args0, NULL}; 40 | 41 | int luawt_WDateEdit_setFormat(lua_State* L) { 42 | int index = luawt_getSuitableArgsGroup(L, luawt_WDateEdit_setFormat_args); 43 | WDateEdit* self = luawt_checkFromLua(L, 1); 44 | if (index == 0) { 45 | char const* raw2 = lua_tostring(L, 2); 46 | Wt::WString format = Wt::WString(raw2); 47 | self->setFormat(format); 48 | return 0; 49 | } else { 50 | return luaL_error(L, "Wrong arguments for WDateEdit.setFormat"); 51 | } 52 | } 53 | 54 | static const char* WDateEdit_calendar_args0[] = {luawt_typeToStr(), NULL}; 55 | static const char* const* const luawt_WDateEdit_calendar_args[] = {WDateEdit_calendar_args0, NULL}; 56 | 57 | int luawt_WDateEdit_calendar(lua_State* L) { 58 | int index = luawt_getSuitableArgsGroup(L, luawt_WDateEdit_calendar_args); 59 | WDateEdit* self = luawt_checkFromLua(L, 1); 60 | if (index == 0) { 61 | Wt::WCalendar* l_result = self->calendar(); 62 | luawt_toLua(L, l_result); 63 | return 1; 64 | } else { 65 | return luaL_error(L, "Wrong arguments for WDateEdit.calendar"); 66 | } 67 | } 68 | 69 | static const char* WDateEdit_format_args0[] = {luawt_typeToStr(), NULL}; 70 | static const char* const* const luawt_WDateEdit_format_args[] = {WDateEdit_format_args0, NULL}; 71 | 72 | int luawt_WDateEdit_format(lua_State* L) { 73 | int index = luawt_getSuitableArgsGroup(L, luawt_WDateEdit_format_args); 74 | WDateEdit* self = luawt_checkFromLua(L, 1); 75 | if (index == 0) { 76 | Wt::WString l_result = self->format(); 77 | lua_pushstring(L, l_result.toUTF8().c_str()); 78 | return 1; 79 | } else { 80 | return luaL_error(L, "Wrong arguments for WDateEdit.format"); 81 | } 82 | } 83 | 84 | ADD_SIGNAL(changed, WDateEdit, Wt::NoClass) 85 | ADD_SIGNAL(selected, WDateEdit, Wt::NoClass) 86 | ADD_SIGNAL(blurred, WDateEdit, Wt::NoClass) 87 | ADD_SIGNAL(focussed, WDateEdit, Wt::NoClass) 88 | ADD_SIGNAL(keyWentDown, WDateEdit, Wt::WKeyEvent) 89 | ADD_SIGNAL(keyPressed, WDateEdit, Wt::WKeyEvent) 90 | ADD_SIGNAL(keyWentUp, WDateEdit, Wt::WKeyEvent) 91 | ADD_SIGNAL(enterPressed, WDateEdit, Wt::NoClass) 92 | ADD_SIGNAL(escapePressed, WDateEdit, Wt::NoClass) 93 | ADD_SIGNAL(clicked, WDateEdit, Wt::WMouseEvent) 94 | ADD_SIGNAL(doubleClicked, WDateEdit, Wt::WMouseEvent) 95 | ADD_SIGNAL(mouseWentDown, WDateEdit, Wt::WMouseEvent) 96 | ADD_SIGNAL(mouseWentUp, WDateEdit, Wt::WMouseEvent) 97 | ADD_SIGNAL(mouseWentOut, WDateEdit, Wt::WMouseEvent) 98 | ADD_SIGNAL(mouseWentOver, WDateEdit, Wt::WMouseEvent) 99 | ADD_SIGNAL(mouseMoved, WDateEdit, Wt::WMouseEvent) 100 | ADD_SIGNAL(mouseDragged, WDateEdit, Wt::WMouseEvent) 101 | ADD_SIGNAL(mouseWheel, WDateEdit, Wt::WMouseEvent) 102 | ADD_SIGNAL(touchStarted, WDateEdit, Wt::WTouchEvent) 103 | ADD_SIGNAL(touchEnded, WDateEdit, Wt::WTouchEvent) 104 | ADD_SIGNAL(touchMoved, WDateEdit, Wt::WTouchEvent) 105 | ADD_SIGNAL(gestureStarted, WDateEdit, Wt::WGestureEvent) 106 | ADD_SIGNAL(gestureChanged, WDateEdit, Wt::WGestureEvent) 107 | ADD_SIGNAL(gestureEnded, WDateEdit, Wt::WGestureEvent) 108 | 109 | static const luaL_Reg luawt_WDateEdit_methods[] = { 110 | METHOD(WDateEdit, setFormat), 111 | METHOD(WDateEdit, format), 112 | METHOD(WDateEdit, calendar), 113 | METHOD(WDateEdit, changed), 114 | METHOD(WDateEdit, selected), 115 | METHOD(WDateEdit, blurred), 116 | METHOD(WDateEdit, focussed), 117 | METHOD(WDateEdit, keyWentDown), 118 | METHOD(WDateEdit, keyPressed), 119 | METHOD(WDateEdit, keyWentUp), 120 | METHOD(WDateEdit, enterPressed), 121 | METHOD(WDateEdit, escapePressed), 122 | METHOD(WDateEdit, clicked), 123 | METHOD(WDateEdit, doubleClicked), 124 | METHOD(WDateEdit, mouseWentDown), 125 | METHOD(WDateEdit, mouseWentUp), 126 | METHOD(WDateEdit, mouseWentOut), 127 | METHOD(WDateEdit, mouseWentOver), 128 | METHOD(WDateEdit, mouseMoved), 129 | METHOD(WDateEdit, mouseDragged), 130 | METHOD(WDateEdit, mouseWheel), 131 | METHOD(WDateEdit, touchStarted), 132 | METHOD(WDateEdit, touchEnded), 133 | METHOD(WDateEdit, touchMoved), 134 | METHOD(WDateEdit, gestureStarted), 135 | METHOD(WDateEdit, gestureChanged), 136 | METHOD(WDateEdit, gestureEnded), 137 | {NULL, NULL}, 138 | }; 139 | 140 | void luawt_WDateEdit(lua_State* L) { 141 | const char* base = luawt_typeToStr(); 142 | assert(base); 143 | DECLARE_CLASS( 144 | WDateEdit, 145 | L, 146 | wrap::func, 147 | 0, 148 | luawt_WDateEdit_methods, 149 | base 150 | ); 151 | } 152 | -------------------------------------------------------------------------------- /src/luawt/WDefaultLoadingIndicator.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "enums.hpp" 8 | #include "globals.hpp" 9 | 10 | static const char* WDefaultLoadingIndicator_make_args0[] = {NULL}; 11 | static const char* const* const luawt_WDefaultLoadingIndicator_make_args[] = {WDefaultLoadingIndicator_make_args0, NULL}; 12 | 13 | int luawt_WDefaultLoadingIndicator_make(lua_State* L) { 14 | int index = luawt_getSuitableArgsGroup(L, luawt_WDefaultLoadingIndicator_make_args); 15 | if (index == 0) { 16 | WDefaultLoadingIndicator* l_result = new WDefaultLoadingIndicator(); 17 | MyApplication* app = MyApplication::instance(); 18 | if (!app) { 19 | delete l_result; 20 | throw std::logic_error("No WApplication when creating WDefaultLoadingIndicator"); 21 | } 22 | app->root()->addWidget(l_result); 23 | luawt_toLua(L, l_result); 24 | return 1; 25 | } else { 26 | return luaL_error(L, "Wrong arguments for WDefaultLoadingIndicator.make"); 27 | } 28 | } 29 | 30 | static const char* WDefaultLoadingIndicator_widget_args0[] = {luawt_typeToStr(), NULL}; 31 | static const char* const* const luawt_WDefaultLoadingIndicator_widget_args[] = {WDefaultLoadingIndicator_widget_args0, NULL}; 32 | 33 | int luawt_WDefaultLoadingIndicator_widget(lua_State* L) { 34 | int index = luawt_getSuitableArgsGroup(L, luawt_WDefaultLoadingIndicator_widget_args); 35 | WDefaultLoadingIndicator* self = luawt_checkFromLua(L, 1); 36 | if (index == 0) { 37 | Wt::WWidget* l_result = self->widget(); 38 | luawt_toLua(L, l_result); 39 | return 1; 40 | } else { 41 | return luaL_error(L, "Wrong arguments for WDefaultLoadingIndicator.widget"); 42 | } 43 | } 44 | 45 | static const char* WDefaultLoadingIndicator_setMessage_args0[] = {luawt_typeToStr(), "char const *", NULL}; 46 | static const char* const* const luawt_WDefaultLoadingIndicator_setMessage_args[] = {WDefaultLoadingIndicator_setMessage_args0, NULL}; 47 | 48 | int luawt_WDefaultLoadingIndicator_setMessage(lua_State* L) { 49 | int index = luawt_getSuitableArgsGroup(L, luawt_WDefaultLoadingIndicator_setMessage_args); 50 | WDefaultLoadingIndicator* self = luawt_checkFromLua(L, 1); 51 | if (index == 0) { 52 | char const* raw2 = lua_tostring(L, 2); 53 | Wt::WString text = Wt::WString(raw2); 54 | self->setMessage(text); 55 | return 0; 56 | } else { 57 | return luaL_error(L, "Wrong arguments for WDefaultLoadingIndicator.setMessage"); 58 | } 59 | } 60 | 61 | ADD_SIGNAL(keyWentDown, WDefaultLoadingIndicator, Wt::WKeyEvent) 62 | ADD_SIGNAL(keyPressed, WDefaultLoadingIndicator, Wt::WKeyEvent) 63 | ADD_SIGNAL(keyWentUp, WDefaultLoadingIndicator, Wt::WKeyEvent) 64 | ADD_SIGNAL(enterPressed, WDefaultLoadingIndicator, Wt::NoClass) 65 | ADD_SIGNAL(escapePressed, WDefaultLoadingIndicator, Wt::NoClass) 66 | ADD_SIGNAL(clicked, WDefaultLoadingIndicator, Wt::WMouseEvent) 67 | ADD_SIGNAL(doubleClicked, WDefaultLoadingIndicator, Wt::WMouseEvent) 68 | ADD_SIGNAL(mouseWentDown, WDefaultLoadingIndicator, Wt::WMouseEvent) 69 | ADD_SIGNAL(mouseWentUp, WDefaultLoadingIndicator, Wt::WMouseEvent) 70 | ADD_SIGNAL(mouseWentOut, WDefaultLoadingIndicator, Wt::WMouseEvent) 71 | ADD_SIGNAL(mouseWentOver, WDefaultLoadingIndicator, Wt::WMouseEvent) 72 | ADD_SIGNAL(mouseMoved, WDefaultLoadingIndicator, Wt::WMouseEvent) 73 | ADD_SIGNAL(mouseDragged, WDefaultLoadingIndicator, Wt::WMouseEvent) 74 | ADD_SIGNAL(mouseWheel, WDefaultLoadingIndicator, Wt::WMouseEvent) 75 | ADD_SIGNAL(touchStarted, WDefaultLoadingIndicator, Wt::WTouchEvent) 76 | ADD_SIGNAL(touchEnded, WDefaultLoadingIndicator, Wt::WTouchEvent) 77 | ADD_SIGNAL(touchMoved, WDefaultLoadingIndicator, Wt::WTouchEvent) 78 | ADD_SIGNAL(gestureStarted, WDefaultLoadingIndicator, Wt::WGestureEvent) 79 | ADD_SIGNAL(gestureChanged, WDefaultLoadingIndicator, Wt::WGestureEvent) 80 | ADD_SIGNAL(gestureEnded, WDefaultLoadingIndicator, Wt::WGestureEvent) 81 | 82 | static const luaL_Reg luawt_WDefaultLoadingIndicator_methods[] = { 83 | METHOD(WDefaultLoadingIndicator, widget), 84 | METHOD(WDefaultLoadingIndicator, setMessage), 85 | METHOD(WDefaultLoadingIndicator, keyWentDown), 86 | METHOD(WDefaultLoadingIndicator, keyPressed), 87 | METHOD(WDefaultLoadingIndicator, keyWentUp), 88 | METHOD(WDefaultLoadingIndicator, enterPressed), 89 | METHOD(WDefaultLoadingIndicator, escapePressed), 90 | METHOD(WDefaultLoadingIndicator, clicked), 91 | METHOD(WDefaultLoadingIndicator, doubleClicked), 92 | METHOD(WDefaultLoadingIndicator, mouseWentDown), 93 | METHOD(WDefaultLoadingIndicator, mouseWentUp), 94 | METHOD(WDefaultLoadingIndicator, mouseWentOut), 95 | METHOD(WDefaultLoadingIndicator, mouseWentOver), 96 | METHOD(WDefaultLoadingIndicator, mouseMoved), 97 | METHOD(WDefaultLoadingIndicator, mouseDragged), 98 | METHOD(WDefaultLoadingIndicator, mouseWheel), 99 | METHOD(WDefaultLoadingIndicator, touchStarted), 100 | METHOD(WDefaultLoadingIndicator, touchEnded), 101 | METHOD(WDefaultLoadingIndicator, touchMoved), 102 | METHOD(WDefaultLoadingIndicator, gestureStarted), 103 | METHOD(WDefaultLoadingIndicator, gestureChanged), 104 | METHOD(WDefaultLoadingIndicator, gestureEnded), 105 | {NULL, NULL}, 106 | }; 107 | 108 | void luawt_WDefaultLoadingIndicator(lua_State* L) { 109 | const char* base = luawt_typeToStr(); 110 | assert(base); 111 | DECLARE_CLASS( 112 | WDefaultLoadingIndicator, 113 | L, 114 | wrap::func, 115 | 0, 116 | luawt_WDefaultLoadingIndicator_methods, 117 | base 118 | ); 119 | } 120 | -------------------------------------------------------------------------------- /src/luawt/WEnvironment.cpp: -------------------------------------------------------------------------------- 1 | /* luawt, Lua bindings for Wt 2 | * Copyright (c) 2015-2017 Pavel Dolgov and Boris Nagaev 3 | * 4 | * See the LICENSE file for terms of use. 5 | */ 6 | 7 | #include 8 | 9 | #include "boost-xtime.hpp" 10 | #include 11 | #include 12 | 13 | #include "globals.hpp" 14 | 15 | /** Returns the IP address of the client */ 16 | int luawt_WEnvironment_clientAddress(lua_State* L) { 17 | const std::string& address = 18 | WApplication::instance()->environment().clientAddress(); 19 | lua_pushlstring(L, address.c_str(), address.size()); 20 | return 1; 21 | } 22 | 23 | static const luaL_Reg luawt_WEnvironment_methods[] = { 24 | METHOD(WEnvironment, clientAddress), 25 | {NULL, NULL}, 26 | }; 27 | 28 | void luawt_WEnvironment(lua_State* L) { 29 | DECLARE_CLASS( 30 | WEnvironment, 31 | L, 32 | 0, 33 | 0, 34 | luawt_WEnvironment_methods, 35 | 0 36 | ); 37 | } 38 | -------------------------------------------------------------------------------- /src/luawt/WFlashObject.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "enums.hpp" 10 | #include "globals.hpp" 11 | 12 | static const char* WFlashObject_make_args0[] = {"char const *", NULL}; 13 | static const char* WFlashObject_make_args1[] = {"char const *", luawt_typeToStr(), NULL}; 14 | static const char* const* const luawt_WFlashObject_make_args[] = {WFlashObject_make_args0, WFlashObject_make_args1, NULL}; 15 | 16 | int luawt_WFlashObject_make(lua_State* L) { 17 | int index = luawt_getSuitableArgsGroup(L, luawt_WFlashObject_make_args); 18 | if (index == 0) { 19 | char const* raw1 = lua_tostring(L, 1); 20 | std::string url = std::string(raw1); 21 | WFlashObject* l_result = new WFlashObject(url); 22 | MyApplication* app = MyApplication::instance(); 23 | if (!app) { 24 | delete l_result; 25 | throw std::logic_error("No WApplication when creating WFlashObject"); 26 | } 27 | app->root()->addWidget(l_result); 28 | luawt_toLua(L, l_result); 29 | return 1; 30 | } else if (index == 1) { 31 | char const* raw1 = lua_tostring(L, 1); 32 | std::string url = std::string(raw1); 33 | Wt::WContainerWidget* parent = 34 | luawt_checkFromLua(L, 2); 35 | WFlashObject* l_result = new WFlashObject(url, parent); 36 | luawt_toLua(L, l_result); 37 | return 1; 38 | } else { 39 | return luaL_error(L, "Wrong arguments for WFlashObject.make"); 40 | } 41 | } 42 | 43 | static const char* WFlashObject_setAlternativeContent_args0[] = {luawt_typeToStr(), luawt_typeToStr(), NULL}; 44 | static const char* const* const luawt_WFlashObject_setAlternativeContent_args[] = {WFlashObject_setAlternativeContent_args0, NULL}; 45 | 46 | int luawt_WFlashObject_setAlternativeContent(lua_State* L) { 47 | int index = luawt_getSuitableArgsGroup(L, luawt_WFlashObject_setAlternativeContent_args); 48 | WFlashObject* self = luawt_checkFromLua(L, 1); 49 | if (index == 0) { 50 | Wt::WWidget* alternative = 51 | luawt_checkFromLua(L, 2); 52 | self->setAlternativeContent(alternative); 53 | return 0; 54 | } else { 55 | return luaL_error(L, "Wrong arguments for WFlashObject.setAlternativeContent"); 56 | } 57 | } 58 | 59 | static const char* WFlashObject_setFlashVariable_args0[] = {luawt_typeToStr(), "char const *", "char const *", NULL}; 60 | static const char* const* const luawt_WFlashObject_setFlashVariable_args[] = {WFlashObject_setFlashVariable_args0, NULL}; 61 | 62 | int luawt_WFlashObject_setFlashVariable(lua_State* L) { 63 | int index = luawt_getSuitableArgsGroup(L, luawt_WFlashObject_setFlashVariable_args); 64 | WFlashObject* self = luawt_checkFromLua(L, 1); 65 | if (index == 0) { 66 | char const* raw2 = lua_tostring(L, 2); 67 | std::string name = std::string(raw2); 68 | char const* raw3 = lua_tostring(L, 3); 69 | Wt::WString value = Wt::WString(raw3); 70 | self->setFlashVariable(name, value); 71 | return 0; 72 | } else { 73 | return luaL_error(L, "Wrong arguments for WFlashObject.setFlashVariable"); 74 | } 75 | } 76 | 77 | static const char* WFlashObject_setFlashParameter_args0[] = {luawt_typeToStr(), "char const *", "char const *", NULL}; 78 | static const char* const* const luawt_WFlashObject_setFlashParameter_args[] = {WFlashObject_setFlashParameter_args0, NULL}; 79 | 80 | int luawt_WFlashObject_setFlashParameter(lua_State* L) { 81 | int index = luawt_getSuitableArgsGroup(L, luawt_WFlashObject_setFlashParameter_args); 82 | WFlashObject* self = luawt_checkFromLua(L, 1); 83 | if (index == 0) { 84 | char const* raw2 = lua_tostring(L, 2); 85 | std::string name = std::string(raw2); 86 | char const* raw3 = lua_tostring(L, 3); 87 | Wt::WString value = Wt::WString(raw3); 88 | self->setFlashParameter(name, value); 89 | return 0; 90 | } else { 91 | return luaL_error(L, "Wrong arguments for WFlashObject.setFlashParameter"); 92 | } 93 | } 94 | 95 | static const char* WFlashObject_resize_args0[] = {luawt_typeToStr(), "double", "double", NULL}; 96 | static const char* const* const luawt_WFlashObject_resize_args[] = {WFlashObject_resize_args0, NULL}; 97 | 98 | int luawt_WFlashObject_resize(lua_State* L) { 99 | int index = luawt_getSuitableArgsGroup(L, luawt_WFlashObject_resize_args); 100 | WFlashObject* self = luawt_checkFromLua(L, 1); 101 | if (index == 0) { 102 | double raw2 = lua_tonumber(L, 2); 103 | Wt::WLength width = Wt::WLength(raw2); 104 | double raw3 = lua_tonumber(L, 3); 105 | Wt::WLength height = Wt::WLength(raw3); 106 | self->resize(width, height); 107 | return 0; 108 | } else { 109 | return luaL_error(L, "Wrong arguments for WFlashObject.resize"); 110 | } 111 | } 112 | 113 | static const char* WFlashObject_jsFlashRef_args0[] = {luawt_typeToStr(), NULL}; 114 | static const char* const* const luawt_WFlashObject_jsFlashRef_args[] = {WFlashObject_jsFlashRef_args0, NULL}; 115 | 116 | int luawt_WFlashObject_jsFlashRef(lua_State* L) { 117 | int index = luawt_getSuitableArgsGroup(L, luawt_WFlashObject_jsFlashRef_args); 118 | WFlashObject* self = luawt_checkFromLua(L, 1); 119 | if (index == 0) { 120 | std::string l_result = self->jsFlashRef(); 121 | lua_pushstring(L, l_result.c_str()); 122 | return 1; 123 | } else { 124 | return luaL_error(L, "Wrong arguments for WFlashObject.jsFlashRef"); 125 | } 126 | } 127 | 128 | static const luaL_Reg luawt_WFlashObject_methods[] = { 129 | METHOD(WFlashObject, resize), 130 | METHOD(WFlashObject, setFlashParameter), 131 | METHOD(WFlashObject, setFlashVariable), 132 | METHOD(WFlashObject, jsFlashRef), 133 | METHOD(WFlashObject, setAlternativeContent), 134 | {NULL, NULL}, 135 | }; 136 | 137 | void luawt_WFlashObject(lua_State* L) { 138 | const char* base = luawt_typeToStr(); 139 | assert(base); 140 | DECLARE_CLASS( 141 | WFlashObject, 142 | L, 143 | wrap::func, 144 | 0, 145 | luawt_WFlashObject_methods, 146 | base 147 | ); 148 | } 149 | -------------------------------------------------------------------------------- /src/luawt/WGroupBox.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "enums.hpp" 8 | #include "globals.hpp" 9 | 10 | static const char* WGroupBox_make_args0[] = {NULL}; 11 | static const char* WGroupBox_make_args1[] = {luawt_typeToStr(), NULL}; 12 | static const char* WGroupBox_make_args2[] = {"char const *", NULL}; 13 | static const char* WGroupBox_make_args3[] = {"char const *", luawt_typeToStr(), NULL}; 14 | static const char* const* const luawt_WGroupBox_make_args[] = {WGroupBox_make_args0, WGroupBox_make_args1, WGroupBox_make_args2, WGroupBox_make_args3, NULL}; 15 | 16 | int luawt_WGroupBox_make(lua_State* L) { 17 | int index = luawt_getSuitableArgsGroup(L, luawt_WGroupBox_make_args); 18 | if (index == 0) { 19 | WGroupBox* l_result = new WGroupBox(); 20 | MyApplication* app = MyApplication::instance(); 21 | if (!app) { 22 | delete l_result; 23 | throw std::logic_error("No WApplication when creating WGroupBox"); 24 | } 25 | app->root()->addWidget(l_result); 26 | luawt_toLua(L, l_result); 27 | return 1; 28 | } else if (index == 1) { 29 | Wt::WContainerWidget* parent = 30 | luawt_checkFromLua(L, 1); 31 | WGroupBox* l_result = new WGroupBox(parent); 32 | luawt_toLua(L, l_result); 33 | return 1; 34 | } else if (index == 2) { 35 | char const* raw1 = lua_tostring(L, 1); 36 | Wt::WString title = Wt::WString(raw1); 37 | WGroupBox* l_result = new WGroupBox(title); 38 | MyApplication* app = MyApplication::instance(); 39 | if (!app) { 40 | delete l_result; 41 | throw std::logic_error("No WApplication when creating WGroupBox"); 42 | } 43 | app->root()->addWidget(l_result); 44 | luawt_toLua(L, l_result); 45 | return 1; 46 | } else if (index == 3) { 47 | char const* raw1 = lua_tostring(L, 1); 48 | Wt::WString title = Wt::WString(raw1); 49 | Wt::WContainerWidget* parent = 50 | luawt_checkFromLua(L, 2); 51 | WGroupBox* l_result = new WGroupBox(title, parent); 52 | luawt_toLua(L, l_result); 53 | return 1; 54 | } else { 55 | return luaL_error(L, "Wrong arguments for WGroupBox.make"); 56 | } 57 | } 58 | 59 | static const char* WGroupBox_setTitle_args0[] = {luawt_typeToStr(), "char const *", NULL}; 60 | static const char* const* const luawt_WGroupBox_setTitle_args[] = {WGroupBox_setTitle_args0, NULL}; 61 | 62 | int luawt_WGroupBox_setTitle(lua_State* L) { 63 | int index = luawt_getSuitableArgsGroup(L, luawt_WGroupBox_setTitle_args); 64 | WGroupBox* self = luawt_checkFromLua(L, 1); 65 | if (index == 0) { 66 | char const* raw2 = lua_tostring(L, 2); 67 | Wt::WString title = Wt::WString(raw2); 68 | self->setTitle(title); 69 | return 0; 70 | } else { 71 | return luaL_error(L, "Wrong arguments for WGroupBox.setTitle"); 72 | } 73 | } 74 | 75 | static const char* WGroupBox_refresh_args0[] = {luawt_typeToStr(), NULL}; 76 | static const char* const* const luawt_WGroupBox_refresh_args[] = {WGroupBox_refresh_args0, NULL}; 77 | 78 | int luawt_WGroupBox_refresh(lua_State* L) { 79 | int index = luawt_getSuitableArgsGroup(L, luawt_WGroupBox_refresh_args); 80 | WGroupBox* self = luawt_checkFromLua(L, 1); 81 | if (index == 0) { 82 | self->refresh(); 83 | return 0; 84 | } else { 85 | return luaL_error(L, "Wrong arguments for WGroupBox.refresh"); 86 | } 87 | } 88 | 89 | static const char* WGroupBox_title_args0[] = {luawt_typeToStr(), NULL}; 90 | static const char* const* const luawt_WGroupBox_title_args[] = {WGroupBox_title_args0, NULL}; 91 | 92 | int luawt_WGroupBox_title(lua_State* L) { 93 | int index = luawt_getSuitableArgsGroup(L, luawt_WGroupBox_title_args); 94 | WGroupBox* self = luawt_checkFromLua(L, 1); 95 | if (index == 0) { 96 | Wt::WString const& l_result = self->title(); 97 | lua_pushstring(L, l_result.toUTF8().c_str()); 98 | return 1; 99 | } else { 100 | return luaL_error(L, "Wrong arguments for WGroupBox.title"); 101 | } 102 | } 103 | 104 | ADD_SIGNAL(scrolled, WGroupBox, Wt::WScrollEvent) 105 | ADD_SIGNAL(keyWentDown, WGroupBox, Wt::WKeyEvent) 106 | ADD_SIGNAL(keyPressed, WGroupBox, Wt::WKeyEvent) 107 | ADD_SIGNAL(keyWentUp, WGroupBox, Wt::WKeyEvent) 108 | ADD_SIGNAL(enterPressed, WGroupBox, Wt::NoClass) 109 | ADD_SIGNAL(escapePressed, WGroupBox, Wt::NoClass) 110 | ADD_SIGNAL(clicked, WGroupBox, Wt::WMouseEvent) 111 | ADD_SIGNAL(doubleClicked, WGroupBox, Wt::WMouseEvent) 112 | ADD_SIGNAL(mouseWentDown, WGroupBox, Wt::WMouseEvent) 113 | ADD_SIGNAL(mouseWentUp, WGroupBox, Wt::WMouseEvent) 114 | ADD_SIGNAL(mouseWentOut, WGroupBox, Wt::WMouseEvent) 115 | ADD_SIGNAL(mouseWentOver, WGroupBox, Wt::WMouseEvent) 116 | ADD_SIGNAL(mouseMoved, WGroupBox, Wt::WMouseEvent) 117 | ADD_SIGNAL(mouseDragged, WGroupBox, Wt::WMouseEvent) 118 | ADD_SIGNAL(mouseWheel, WGroupBox, Wt::WMouseEvent) 119 | ADD_SIGNAL(touchStarted, WGroupBox, Wt::WTouchEvent) 120 | ADD_SIGNAL(touchEnded, WGroupBox, Wt::WTouchEvent) 121 | ADD_SIGNAL(touchMoved, WGroupBox, Wt::WTouchEvent) 122 | ADD_SIGNAL(gestureStarted, WGroupBox, Wt::WGestureEvent) 123 | ADD_SIGNAL(gestureChanged, WGroupBox, Wt::WGestureEvent) 124 | ADD_SIGNAL(gestureEnded, WGroupBox, Wt::WGestureEvent) 125 | 126 | static const luaL_Reg luawt_WGroupBox_methods[] = { 127 | METHOD(WGroupBox, title), 128 | METHOD(WGroupBox, setTitle), 129 | METHOD(WGroupBox, refresh), 130 | METHOD(WGroupBox, scrolled), 131 | METHOD(WGroupBox, keyWentDown), 132 | METHOD(WGroupBox, keyPressed), 133 | METHOD(WGroupBox, keyWentUp), 134 | METHOD(WGroupBox, enterPressed), 135 | METHOD(WGroupBox, escapePressed), 136 | METHOD(WGroupBox, clicked), 137 | METHOD(WGroupBox, doubleClicked), 138 | METHOD(WGroupBox, mouseWentDown), 139 | METHOD(WGroupBox, mouseWentUp), 140 | METHOD(WGroupBox, mouseWentOut), 141 | METHOD(WGroupBox, mouseWentOver), 142 | METHOD(WGroupBox, mouseMoved), 143 | METHOD(WGroupBox, mouseDragged), 144 | METHOD(WGroupBox, mouseWheel), 145 | METHOD(WGroupBox, touchStarted), 146 | METHOD(WGroupBox, touchEnded), 147 | METHOD(WGroupBox, touchMoved), 148 | METHOD(WGroupBox, gestureStarted), 149 | METHOD(WGroupBox, gestureChanged), 150 | METHOD(WGroupBox, gestureEnded), 151 | {NULL, NULL}, 152 | }; 153 | 154 | void luawt_WGroupBox(lua_State* L) { 155 | const char* base = luawt_typeToStr(); 156 | assert(base); 157 | DECLARE_CLASS( 158 | WGroupBox, 159 | L, 160 | wrap::func, 161 | 0, 162 | luawt_WGroupBox_methods, 163 | base 164 | ); 165 | } 166 | -------------------------------------------------------------------------------- /src/luawt/WIconPair.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "enums.hpp" 8 | #include "globals.hpp" 9 | 10 | static const char* WIconPair_make_args0[] = {"char const *", "char const *", NULL}; 11 | static const char* WIconPair_make_args1[] = {"char const *", "char const *", "bool", NULL}; 12 | static const char* WIconPair_make_args2[] = {"char const *", "char const *", "bool", luawt_typeToStr(), NULL}; 13 | static const char* const* const luawt_WIconPair_make_args[] = {WIconPair_make_args0, WIconPair_make_args1, WIconPair_make_args2, NULL}; 14 | 15 | int luawt_WIconPair_make(lua_State* L) { 16 | int index = luawt_getSuitableArgsGroup(L, luawt_WIconPair_make_args); 17 | if (index == 0) { 18 | char const* raw1 = lua_tostring(L, 1); 19 | std::string icon1URL = std::string(raw1); 20 | char const* raw2 = lua_tostring(L, 2); 21 | std::string icon2URL = std::string(raw2); 22 | WIconPair* l_result = new WIconPair(icon1URL, icon2URL); 23 | MyApplication* app = MyApplication::instance(); 24 | if (!app) { 25 | delete l_result; 26 | throw std::logic_error("No WApplication when creating WIconPair"); 27 | } 28 | app->root()->addWidget(l_result); 29 | luawt_toLua(L, l_result); 30 | return 1; 31 | } else if (index == 1) { 32 | char const* raw1 = lua_tostring(L, 1); 33 | std::string icon1URL = std::string(raw1); 34 | char const* raw2 = lua_tostring(L, 2); 35 | std::string icon2URL = std::string(raw2); 36 | bool clickIsSwitch = lua_toboolean(L, 3); 37 | WIconPair* l_result = new WIconPair(icon1URL, icon2URL, clickIsSwitch); 38 | MyApplication* app = MyApplication::instance(); 39 | if (!app) { 40 | delete l_result; 41 | throw std::logic_error("No WApplication when creating WIconPair"); 42 | } 43 | app->root()->addWidget(l_result); 44 | luawt_toLua(L, l_result); 45 | return 1; 46 | } else if (index == 2) { 47 | char const* raw1 = lua_tostring(L, 1); 48 | std::string icon1URL = std::string(raw1); 49 | char const* raw2 = lua_tostring(L, 2); 50 | std::string icon2URL = std::string(raw2); 51 | bool clickIsSwitch = lua_toboolean(L, 3); 52 | Wt::WContainerWidget* parent = 53 | luawt_checkFromLua(L, 4); 54 | WIconPair* l_result = new WIconPair(icon1URL, icon2URL, clickIsSwitch, parent); 55 | luawt_toLua(L, l_result); 56 | return 1; 57 | } else { 58 | return luaL_error(L, "Wrong arguments for WIconPair.make"); 59 | } 60 | } 61 | 62 | static const char* WIconPair_icon1_args0[] = {luawt_typeToStr(), NULL}; 63 | static const char* const* const luawt_WIconPair_icon1_args[] = {WIconPair_icon1_args0, NULL}; 64 | 65 | int luawt_WIconPair_icon1(lua_State* L) { 66 | int index = luawt_getSuitableArgsGroup(L, luawt_WIconPair_icon1_args); 67 | WIconPair* self = luawt_checkFromLua(L, 1); 68 | if (index == 0) { 69 | Wt::WImage* l_result = self->icon1(); 70 | luawt_toLua(L, l_result); 71 | return 1; 72 | } else { 73 | return luaL_error(L, "Wrong arguments for WIconPair.icon1"); 74 | } 75 | } 76 | 77 | static const char* WIconPair_icon2_args0[] = {luawt_typeToStr(), NULL}; 78 | static const char* const* const luawt_WIconPair_icon2_args[] = {WIconPair_icon2_args0, NULL}; 79 | 80 | int luawt_WIconPair_icon2(lua_State* L) { 81 | int index = luawt_getSuitableArgsGroup(L, luawt_WIconPair_icon2_args); 82 | WIconPair* self = luawt_checkFromLua(L, 1); 83 | if (index == 0) { 84 | Wt::WImage* l_result = self->icon2(); 85 | luawt_toLua(L, l_result); 86 | return 1; 87 | } else { 88 | return luaL_error(L, "Wrong arguments for WIconPair.icon2"); 89 | } 90 | } 91 | 92 | static const char* WIconPair_showIcon1_args0[] = {luawt_typeToStr(), NULL}; 93 | static const char* const* const luawt_WIconPair_showIcon1_args[] = {WIconPair_showIcon1_args0, NULL}; 94 | 95 | int luawt_WIconPair_showIcon1(lua_State* L) { 96 | int index = luawt_getSuitableArgsGroup(L, luawt_WIconPair_showIcon1_args); 97 | WIconPair* self = luawt_checkFromLua(L, 1); 98 | if (index == 0) { 99 | self->showIcon1(); 100 | return 0; 101 | } else { 102 | return luaL_error(L, "Wrong arguments for WIconPair.showIcon1"); 103 | } 104 | } 105 | 106 | static const char* WIconPair_showIcon2_args0[] = {luawt_typeToStr(), NULL}; 107 | static const char* const* const luawt_WIconPair_showIcon2_args[] = {WIconPair_showIcon2_args0, NULL}; 108 | 109 | int luawt_WIconPair_showIcon2(lua_State* L) { 110 | int index = luawt_getSuitableArgsGroup(L, luawt_WIconPair_showIcon2_args); 111 | WIconPair* self = luawt_checkFromLua(L, 1); 112 | if (index == 0) { 113 | self->showIcon2(); 114 | return 0; 115 | } else { 116 | return luaL_error(L, "Wrong arguments for WIconPair.showIcon2"); 117 | } 118 | } 119 | 120 | static const char* WIconPair_state_args0[] = {luawt_typeToStr(), NULL}; 121 | static const char* const* const luawt_WIconPair_state_args[] = {WIconPair_state_args0, NULL}; 122 | 123 | int luawt_WIconPair_state(lua_State* L) { 124 | int index = luawt_getSuitableArgsGroup(L, luawt_WIconPair_state_args); 125 | WIconPair* self = luawt_checkFromLua(L, 1); 126 | if (index == 0) { 127 | int l_result = self->state(); 128 | lua_pushinteger(L, l_result); 129 | return 1; 130 | } else { 131 | return luaL_error(L, "Wrong arguments for WIconPair.state"); 132 | } 133 | } 134 | 135 | static const char* WIconPair_setState_args0[] = {luawt_typeToStr(), "int", NULL}; 136 | static const char* const* const luawt_WIconPair_setState_args[] = {WIconPair_setState_args0, NULL}; 137 | 138 | int luawt_WIconPair_setState(lua_State* L) { 139 | int index = luawt_getSuitableArgsGroup(L, luawt_WIconPair_setState_args); 140 | WIconPair* self = luawt_checkFromLua(L, 1); 141 | if (index == 0) { 142 | int num = lua_tointeger(L, 2); 143 | self->setState(num); 144 | return 0; 145 | } else { 146 | return luaL_error(L, "Wrong arguments for WIconPair.setState"); 147 | } 148 | } 149 | 150 | ADD_SIGNAL(icon1Clicked, WIconPair, Wt::WMouseEvent) 151 | ADD_SIGNAL(icon2Clicked, WIconPair, Wt::WMouseEvent) 152 | 153 | static const luaL_Reg luawt_WIconPair_methods[] = { 154 | METHOD(WIconPair, setState), 155 | METHOD(WIconPair, state), 156 | METHOD(WIconPair, icon1), 157 | METHOD(WIconPair, icon2), 158 | METHOD(WIconPair, showIcon1), 159 | METHOD(WIconPair, showIcon2), 160 | METHOD(WIconPair, icon1Clicked), 161 | METHOD(WIconPair, icon2Clicked), 162 | {NULL, NULL}, 163 | }; 164 | 165 | void luawt_WIconPair(lua_State* L) { 166 | const char* base = luawt_typeToStr(); 167 | assert(base); 168 | DECLARE_CLASS( 169 | WIconPair, 170 | L, 171 | wrap::func, 172 | 0, 173 | luawt_WIconPair_methods, 174 | base 175 | ); 176 | } 177 | -------------------------------------------------------------------------------- /src/luawt/WInteractWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | 5 | #include "enums.hpp" 6 | #include "globals.hpp" 7 | 8 | static const char* WInteractWidget_load_args0[] = {luawt_typeToStr(), NULL}; 9 | static const char* const* const luawt_WInteractWidget_load_args[] = {WInteractWidget_load_args0, NULL}; 10 | 11 | int luawt_WInteractWidget_load(lua_State* L) { 12 | int index = luawt_getSuitableArgsGroup(L, luawt_WInteractWidget_load_args); 13 | WInteractWidget* self = luawt_checkFromLua(L, 1); 14 | if (index == 0) { 15 | self->load(); 16 | return 0; 17 | } else { 18 | return luaL_error(L, "Wrong arguments for WInteractWidget.load"); 19 | } 20 | } 21 | 22 | static const char* WInteractWidget_mouseOverDelay_args0[] = {luawt_typeToStr(), NULL}; 23 | static const char* const* const luawt_WInteractWidget_mouseOverDelay_args[] = {WInteractWidget_mouseOverDelay_args0, NULL}; 24 | 25 | int luawt_WInteractWidget_mouseOverDelay(lua_State* L) { 26 | int index = luawt_getSuitableArgsGroup(L, luawt_WInteractWidget_mouseOverDelay_args); 27 | WInteractWidget* self = luawt_checkFromLua(L, 1); 28 | if (index == 0) { 29 | int l_result = self->mouseOverDelay(); 30 | lua_pushinteger(L, l_result); 31 | return 1; 32 | } else { 33 | return luaL_error(L, "Wrong arguments for WInteractWidget.mouseOverDelay"); 34 | } 35 | } 36 | 37 | static const char* WInteractWidget_isEnabled_args0[] = {luawt_typeToStr(), NULL}; 38 | static const char* const* const luawt_WInteractWidget_isEnabled_args[] = {WInteractWidget_isEnabled_args0, NULL}; 39 | 40 | int luawt_WInteractWidget_isEnabled(lua_State* L) { 41 | int index = luawt_getSuitableArgsGroup(L, luawt_WInteractWidget_isEnabled_args); 42 | WInteractWidget* self = luawt_checkFromLua(L, 1); 43 | if (index == 0) { 44 | bool l_result = self->isEnabled(); 45 | lua_pushboolean(L, l_result); 46 | return 1; 47 | } else { 48 | return luaL_error(L, "Wrong arguments for WInteractWidget.isEnabled"); 49 | } 50 | } 51 | 52 | static const char* WInteractWidget_setMouseOverDelay_args0[] = {luawt_typeToStr(), "int", NULL}; 53 | static const char* const* const luawt_WInteractWidget_setMouseOverDelay_args[] = {WInteractWidget_setMouseOverDelay_args0, NULL}; 54 | 55 | int luawt_WInteractWidget_setMouseOverDelay(lua_State* L) { 56 | int index = luawt_getSuitableArgsGroup(L, luawt_WInteractWidget_setMouseOverDelay_args); 57 | WInteractWidget* self = luawt_checkFromLua(L, 1); 58 | if (index == 0) { 59 | int delay = lua_tointeger(L, 2); 60 | self->setMouseOverDelay(delay); 61 | return 0; 62 | } else { 63 | return luaL_error(L, "Wrong arguments for WInteractWidget.setMouseOverDelay"); 64 | } 65 | } 66 | 67 | static const char* WInteractWidget_setPopup_args0[] = {luawt_typeToStr(), "bool", NULL}; 68 | static const char* const* const luawt_WInteractWidget_setPopup_args[] = {WInteractWidget_setPopup_args0, NULL}; 69 | 70 | int luawt_WInteractWidget_setPopup(lua_State* L) { 71 | int index = luawt_getSuitableArgsGroup(L, luawt_WInteractWidget_setPopup_args); 72 | WInteractWidget* self = luawt_checkFromLua(L, 1); 73 | if (index == 0) { 74 | bool popup = lua_toboolean(L, 2); 75 | self->setPopup(popup); 76 | return 0; 77 | } else { 78 | return luaL_error(L, "Wrong arguments for WInteractWidget.setPopup"); 79 | } 80 | } 81 | 82 | ADD_SIGNAL(keyWentDown, WInteractWidget, Wt::WKeyEvent) 83 | ADD_SIGNAL(keyPressed, WInteractWidget, Wt::WKeyEvent) 84 | ADD_SIGNAL(keyWentUp, WInteractWidget, Wt::WKeyEvent) 85 | ADD_SIGNAL(enterPressed, WInteractWidget, Wt::NoClass) 86 | ADD_SIGNAL(escapePressed, WInteractWidget, Wt::NoClass) 87 | ADD_SIGNAL(clicked, WInteractWidget, Wt::WMouseEvent) 88 | ADD_SIGNAL(doubleClicked, WInteractWidget, Wt::WMouseEvent) 89 | ADD_SIGNAL(mouseWentDown, WInteractWidget, Wt::WMouseEvent) 90 | ADD_SIGNAL(mouseWentUp, WInteractWidget, Wt::WMouseEvent) 91 | ADD_SIGNAL(mouseWentOut, WInteractWidget, Wt::WMouseEvent) 92 | ADD_SIGNAL(mouseWentOver, WInteractWidget, Wt::WMouseEvent) 93 | ADD_SIGNAL(mouseMoved, WInteractWidget, Wt::WMouseEvent) 94 | ADD_SIGNAL(mouseDragged, WInteractWidget, Wt::WMouseEvent) 95 | ADD_SIGNAL(mouseWheel, WInteractWidget, Wt::WMouseEvent) 96 | ADD_SIGNAL(touchStarted, WInteractWidget, Wt::WTouchEvent) 97 | ADD_SIGNAL(touchEnded, WInteractWidget, Wt::WTouchEvent) 98 | ADD_SIGNAL(touchMoved, WInteractWidget, Wt::WTouchEvent) 99 | ADD_SIGNAL(gestureStarted, WInteractWidget, Wt::WGestureEvent) 100 | ADD_SIGNAL(gestureChanged, WInteractWidget, Wt::WGestureEvent) 101 | ADD_SIGNAL(gestureEnded, WInteractWidget, Wt::WGestureEvent) 102 | 103 | static const luaL_Reg luawt_WInteractWidget_methods[] = { 104 | METHOD(WInteractWidget, setMouseOverDelay), 105 | METHOD(WInteractWidget, mouseOverDelay), 106 | METHOD(WInteractWidget, setPopup), 107 | METHOD(WInteractWidget, load), 108 | METHOD(WInteractWidget, isEnabled), 109 | METHOD(WInteractWidget, keyWentDown), 110 | METHOD(WInteractWidget, keyPressed), 111 | METHOD(WInteractWidget, keyWentUp), 112 | METHOD(WInteractWidget, enterPressed), 113 | METHOD(WInteractWidget, escapePressed), 114 | METHOD(WInteractWidget, clicked), 115 | METHOD(WInteractWidget, doubleClicked), 116 | METHOD(WInteractWidget, mouseWentDown), 117 | METHOD(WInteractWidget, mouseWentUp), 118 | METHOD(WInteractWidget, mouseWentOut), 119 | METHOD(WInteractWidget, mouseWentOver), 120 | METHOD(WInteractWidget, mouseMoved), 121 | METHOD(WInteractWidget, mouseDragged), 122 | METHOD(WInteractWidget, mouseWheel), 123 | METHOD(WInteractWidget, touchStarted), 124 | METHOD(WInteractWidget, touchEnded), 125 | METHOD(WInteractWidget, touchMoved), 126 | METHOD(WInteractWidget, gestureStarted), 127 | METHOD(WInteractWidget, gestureChanged), 128 | METHOD(WInteractWidget, gestureEnded), 129 | {NULL, NULL}, 130 | }; 131 | 132 | void luawt_WInteractWidget(lua_State* L) { 133 | const char* base = luawt_typeToStr(); 134 | assert(base); 135 | DECLARE_CLASS( 136 | WInteractWidget, 137 | L, 138 | 0, 139 | 0, 140 | luawt_WInteractWidget_methods, 141 | base 142 | ); 143 | } 144 | -------------------------------------------------------------------------------- /src/luawt/WMessageBox.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "enums.hpp" 9 | #include "globals.hpp" 10 | 11 | static const char* WMessageBox_text_args0[] = {luawt_typeToStr(), NULL}; 12 | static const char* const* const luawt_WMessageBox_text_args[] = {WMessageBox_text_args0, NULL}; 13 | 14 | int luawt_WMessageBox_text(lua_State* L) { 15 | int index = luawt_getSuitableArgsGroup(L, luawt_WMessageBox_text_args); 16 | WMessageBox* self = luawt_checkFromLua(L, 1); 17 | if (index == 0) { 18 | Wt::WString const& l_result = self->text(); 19 | lua_pushstring(L, l_result.toUTF8().c_str()); 20 | return 1; 21 | } else { 22 | return luaL_error(L, "Wrong arguments for WMessageBox.text"); 23 | } 24 | } 25 | 26 | static const char* WMessageBox_setText_args0[] = {luawt_typeToStr(), "char const *", NULL}; 27 | static const char* const* const luawt_WMessageBox_setText_args[] = {WMessageBox_setText_args0, NULL}; 28 | 29 | int luawt_WMessageBox_setText(lua_State* L) { 30 | int index = luawt_getSuitableArgsGroup(L, luawt_WMessageBox_setText_args); 31 | WMessageBox* self = luawt_checkFromLua(L, 1); 32 | if (index == 0) { 33 | char const* raw2 = lua_tostring(L, 2); 34 | Wt::WString text = Wt::WString(raw2); 35 | self->setText(text); 36 | return 0; 37 | } else { 38 | return luaL_error(L, "Wrong arguments for WMessageBox.setText"); 39 | } 40 | } 41 | 42 | static const char* WMessageBox_textWidget_args0[] = {luawt_typeToStr(), NULL}; 43 | static const char* const* const luawt_WMessageBox_textWidget_args[] = {WMessageBox_textWidget_args0, NULL}; 44 | 45 | int luawt_WMessageBox_textWidget(lua_State* L) { 46 | int index = luawt_getSuitableArgsGroup(L, luawt_WMessageBox_textWidget_args); 47 | WMessageBox* self = luawt_checkFromLua(L, 1); 48 | if (index == 0) { 49 | Wt::WText* l_result = self->textWidget(); 50 | luawt_toLua(L, l_result); 51 | return 1; 52 | } else { 53 | return luaL_error(L, "Wrong arguments for WMessageBox.textWidget"); 54 | } 55 | } 56 | 57 | static const char* WMessageBox_addButton_args0[] = {luawt_typeToStr(), "char const *", "enum", NULL}; 58 | static const char* const* const luawt_WMessageBox_addButton_args[] = {WMessageBox_addButton_args0, NULL}; 59 | 60 | int luawt_WMessageBox_addButton(lua_State* L) { 61 | int index = luawt_getSuitableArgsGroup(L, luawt_WMessageBox_addButton_args); 62 | WMessageBox* self = luawt_checkFromLua(L, 1); 63 | if (index == 0) { 64 | char const* raw2 = lua_tostring(L, 2); 65 | Wt::WString text = Wt::WString(raw2); 66 | Wt::StandardButton result = static_cast(luawt_getEnum( 67 | L, 68 | luawt_enum_StandardButton_str, 69 | luawt_enum_StandardButton_val, 70 | 3, 71 | "Wrong enum type in args of WMessageBox.addButton" 72 | )); 73 | Wt::WPushButton* l_result = self->addButton(text, result); 74 | luawt_toLua(L, l_result); 75 | return 1; 76 | } else { 77 | return luaL_error(L, "Wrong arguments for WMessageBox.addButton"); 78 | } 79 | } 80 | 81 | static const char* WMessageBox_buttonResult_args0[] = {luawt_typeToStr(), NULL}; 82 | static const char* const* const luawt_WMessageBox_buttonResult_args[] = {WMessageBox_buttonResult_args0, NULL}; 83 | 84 | int luawt_WMessageBox_buttonResult(lua_State* L) { 85 | int index = luawt_getSuitableArgsGroup(L, luawt_WMessageBox_buttonResult_args); 86 | WMessageBox* self = luawt_checkFromLua(L, 1); 87 | if (index == 0) { 88 | Wt::StandardButton l_result = self->buttonResult(); 89 | luawt_returnEnum(L, luawt_enum_StandardButton_str, luawt_enum_StandardButton_val, l_result, "StandardButton"); 90 | return 1; 91 | } else { 92 | return luaL_error(L, "Wrong arguments for WMessageBox.buttonResult"); 93 | } 94 | } 95 | 96 | static const char* WMessageBox_button_args0[] = {luawt_typeToStr(), "enum", NULL}; 97 | static const char* const* const luawt_WMessageBox_button_args[] = {WMessageBox_button_args0, NULL}; 98 | 99 | int luawt_WMessageBox_button(lua_State* L) { 100 | int index = luawt_getSuitableArgsGroup(L, luawt_WMessageBox_button_args); 101 | WMessageBox* self = luawt_checkFromLua(L, 1); 102 | if (index == 0) { 103 | Wt::StandardButton button = static_cast(luawt_getEnum( 104 | L, 105 | luawt_enum_StandardButton_str, 106 | luawt_enum_StandardButton_val, 107 | 2, 108 | "Wrong enum type in args of WMessageBox.button" 109 | )); 110 | Wt::WPushButton* l_result = self->button(button); 111 | luawt_toLua(L, l_result); 112 | return 1; 113 | } else { 114 | return luaL_error(L, "Wrong arguments for WMessageBox.button"); 115 | } 116 | } 117 | 118 | static const char* WMessageBox_setIcon_args0[] = {luawt_typeToStr(), "enum", NULL}; 119 | static const char* const* const luawt_WMessageBox_setIcon_args[] = {WMessageBox_setIcon_args0, NULL}; 120 | 121 | int luawt_WMessageBox_setIcon(lua_State* L) { 122 | int index = luawt_getSuitableArgsGroup(L, luawt_WMessageBox_setIcon_args); 123 | WMessageBox* self = luawt_checkFromLua(L, 1); 124 | if (index == 0) { 125 | Wt::Icon icon = static_cast(luawt_getEnum( 126 | L, 127 | luawt_enum_Icon_str, 128 | luawt_enum_Icon_val, 129 | 2, 130 | "Wrong enum type in args of WMessageBox.setIcon" 131 | )); 132 | self->setIcon(icon); 133 | return 0; 134 | } else { 135 | return luaL_error(L, "Wrong arguments for WMessageBox.setIcon"); 136 | } 137 | } 138 | 139 | static const char* WMessageBox_setButtons_args0[] = {luawt_typeToStr(), "enum", NULL}; 140 | static const char* const* const luawt_WMessageBox_setButtons_args[] = {WMessageBox_setButtons_args0, NULL}; 141 | 142 | int luawt_WMessageBox_setButtons(lua_State* L) { 143 | int index = luawt_getSuitableArgsGroup(L, luawt_WMessageBox_setButtons_args); 144 | WMessageBox* self = luawt_checkFromLua(L, 1); 145 | if (index == 0) { 146 | Wt::WFlags buttons = static_cast(luawt_getEnum( 147 | L, 148 | luawt_enum_StandardButton_str, 149 | luawt_enum_StandardButton_val, 150 | 2, 151 | "Wrong enum type in args of WMessageBox.setButtons" 152 | )); 153 | self->setButtons(buttons); 154 | return 0; 155 | } else { 156 | return luaL_error(L, "Wrong arguments for WMessageBox.setButtons"); 157 | } 158 | } 159 | 160 | static const char* WMessageBox_icon_args0[] = {luawt_typeToStr(), NULL}; 161 | static const char* const* const luawt_WMessageBox_icon_args[] = {WMessageBox_icon_args0, NULL}; 162 | 163 | int luawt_WMessageBox_icon(lua_State* L) { 164 | int index = luawt_getSuitableArgsGroup(L, luawt_WMessageBox_icon_args); 165 | WMessageBox* self = luawt_checkFromLua(L, 1); 166 | if (index == 0) { 167 | Wt::Icon l_result = self->icon(); 168 | luawt_returnEnum(L, luawt_enum_Icon_str, luawt_enum_Icon_val, l_result, "Icon"); 169 | return 1; 170 | } else { 171 | return luaL_error(L, "Wrong arguments for WMessageBox.icon"); 172 | } 173 | } 174 | 175 | static const luaL_Reg luawt_WMessageBox_methods[] = { 176 | METHOD(WMessageBox, setText), 177 | METHOD(WMessageBox, text), 178 | METHOD(WMessageBox, textWidget), 179 | METHOD(WMessageBox, setIcon), 180 | METHOD(WMessageBox, icon), 181 | METHOD(WMessageBox, addButton), 182 | METHOD(WMessageBox, setButtons), 183 | METHOD(WMessageBox, button), 184 | METHOD(WMessageBox, buttonResult), 185 | {NULL, NULL}, 186 | }; 187 | 188 | void luawt_WMessageBox(lua_State* L) { 189 | const char* base = luawt_typeToStr(); 190 | assert(base); 191 | DECLARE_CLASS( 192 | WMessageBox, 193 | L, 194 | 0, 195 | 0, 196 | luawt_WMessageBox_methods, 197 | base 198 | ); 199 | } 200 | -------------------------------------------------------------------------------- /src/luawt/WOverlayLoadingIndicator.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "enums.hpp" 8 | #include "globals.hpp" 9 | 10 | static const char* WOverlayLoadingIndicator_make_args0[] = {NULL}; 11 | static const char* WOverlayLoadingIndicator_make_args1[] = {"char const *", NULL}; 12 | static const char* WOverlayLoadingIndicator_make_args2[] = {"char const *", "char const *", NULL}; 13 | static const char* WOverlayLoadingIndicator_make_args3[] = {"char const *", "char const *", "char const *", NULL}; 14 | static const char* const* const luawt_WOverlayLoadingIndicator_make_args[] = {WOverlayLoadingIndicator_make_args0, WOverlayLoadingIndicator_make_args1, WOverlayLoadingIndicator_make_args2, WOverlayLoadingIndicator_make_args3, NULL}; 15 | 16 | int luawt_WOverlayLoadingIndicator_make(lua_State* L) { 17 | int index = luawt_getSuitableArgsGroup(L, luawt_WOverlayLoadingIndicator_make_args); 18 | if (index == 0) { 19 | WOverlayLoadingIndicator* l_result = new WOverlayLoadingIndicator(); 20 | MyApplication* app = MyApplication::instance(); 21 | if (!app) { 22 | delete l_result; 23 | throw std::logic_error("No WApplication when creating WOverlayLoadingIndicator"); 24 | } 25 | app->root()->addWidget(l_result); 26 | luawt_toLua(L, l_result); 27 | return 1; 28 | } else if (index == 1) { 29 | char const* raw1 = lua_tostring(L, 1); 30 | Wt::WString styleClass = Wt::WString(raw1); 31 | WOverlayLoadingIndicator* l_result = new WOverlayLoadingIndicator(styleClass); 32 | MyApplication* app = MyApplication::instance(); 33 | if (!app) { 34 | delete l_result; 35 | throw std::logic_error("No WApplication when creating WOverlayLoadingIndicator"); 36 | } 37 | app->root()->addWidget(l_result); 38 | luawt_toLua(L, l_result); 39 | return 1; 40 | } else if (index == 2) { 41 | char const* raw1 = lua_tostring(L, 1); 42 | Wt::WString styleClass = Wt::WString(raw1); 43 | char const* raw2 = lua_tostring(L, 2); 44 | Wt::WString backgroundStyleClass = Wt::WString(raw2); 45 | WOverlayLoadingIndicator* l_result = new WOverlayLoadingIndicator(styleClass, backgroundStyleClass); 46 | MyApplication* app = MyApplication::instance(); 47 | if (!app) { 48 | delete l_result; 49 | throw std::logic_error("No WApplication when creating WOverlayLoadingIndicator"); 50 | } 51 | app->root()->addWidget(l_result); 52 | luawt_toLua(L, l_result); 53 | return 1; 54 | } else if (index == 3) { 55 | char const* raw1 = lua_tostring(L, 1); 56 | Wt::WString styleClass = Wt::WString(raw1); 57 | char const* raw2 = lua_tostring(L, 2); 58 | Wt::WString backgroundStyleClass = Wt::WString(raw2); 59 | char const* raw3 = lua_tostring(L, 3); 60 | Wt::WString textStyleClass = Wt::WString(raw3); 61 | WOverlayLoadingIndicator* l_result = new WOverlayLoadingIndicator(styleClass, backgroundStyleClass, textStyleClass); 62 | MyApplication* app = MyApplication::instance(); 63 | if (!app) { 64 | delete l_result; 65 | throw std::logic_error("No WApplication when creating WOverlayLoadingIndicator"); 66 | } 67 | app->root()->addWidget(l_result); 68 | luawt_toLua(L, l_result); 69 | return 1; 70 | } else { 71 | return luaL_error(L, "Wrong arguments for WOverlayLoadingIndicator.make"); 72 | } 73 | } 74 | 75 | static const char* WOverlayLoadingIndicator_widget_args0[] = {luawt_typeToStr(), NULL}; 76 | static const char* const* const luawt_WOverlayLoadingIndicator_widget_args[] = {WOverlayLoadingIndicator_widget_args0, NULL}; 77 | 78 | int luawt_WOverlayLoadingIndicator_widget(lua_State* L) { 79 | int index = luawt_getSuitableArgsGroup(L, luawt_WOverlayLoadingIndicator_widget_args); 80 | WOverlayLoadingIndicator* self = luawt_checkFromLua(L, 1); 81 | if (index == 0) { 82 | Wt::WWidget* l_result = self->widget(); 83 | luawt_toLua(L, l_result); 84 | return 1; 85 | } else { 86 | return luaL_error(L, "Wrong arguments for WOverlayLoadingIndicator.widget"); 87 | } 88 | } 89 | 90 | static const char* WOverlayLoadingIndicator_setMessage_args0[] = {luawt_typeToStr(), "char const *", NULL}; 91 | static const char* const* const luawt_WOverlayLoadingIndicator_setMessage_args[] = {WOverlayLoadingIndicator_setMessage_args0, NULL}; 92 | 93 | int luawt_WOverlayLoadingIndicator_setMessage(lua_State* L) { 94 | int index = luawt_getSuitableArgsGroup(L, luawt_WOverlayLoadingIndicator_setMessage_args); 95 | WOverlayLoadingIndicator* self = luawt_checkFromLua(L, 1); 96 | if (index == 0) { 97 | char const* raw2 = lua_tostring(L, 2); 98 | Wt::WString text = Wt::WString(raw2); 99 | self->setMessage(text); 100 | return 0; 101 | } else { 102 | return luaL_error(L, "Wrong arguments for WOverlayLoadingIndicator.setMessage"); 103 | } 104 | } 105 | 106 | ADD_SIGNAL(scrolled, WOverlayLoadingIndicator, Wt::WScrollEvent) 107 | ADD_SIGNAL(keyWentDown, WOverlayLoadingIndicator, Wt::WKeyEvent) 108 | ADD_SIGNAL(keyPressed, WOverlayLoadingIndicator, Wt::WKeyEvent) 109 | ADD_SIGNAL(keyWentUp, WOverlayLoadingIndicator, Wt::WKeyEvent) 110 | ADD_SIGNAL(enterPressed, WOverlayLoadingIndicator, Wt::NoClass) 111 | ADD_SIGNAL(escapePressed, WOverlayLoadingIndicator, Wt::NoClass) 112 | ADD_SIGNAL(clicked, WOverlayLoadingIndicator, Wt::WMouseEvent) 113 | ADD_SIGNAL(doubleClicked, WOverlayLoadingIndicator, Wt::WMouseEvent) 114 | ADD_SIGNAL(mouseWentDown, WOverlayLoadingIndicator, Wt::WMouseEvent) 115 | ADD_SIGNAL(mouseWentUp, WOverlayLoadingIndicator, Wt::WMouseEvent) 116 | ADD_SIGNAL(mouseWentOut, WOverlayLoadingIndicator, Wt::WMouseEvent) 117 | ADD_SIGNAL(mouseWentOver, WOverlayLoadingIndicator, Wt::WMouseEvent) 118 | ADD_SIGNAL(mouseMoved, WOverlayLoadingIndicator, Wt::WMouseEvent) 119 | ADD_SIGNAL(mouseDragged, WOverlayLoadingIndicator, Wt::WMouseEvent) 120 | ADD_SIGNAL(mouseWheel, WOverlayLoadingIndicator, Wt::WMouseEvent) 121 | ADD_SIGNAL(touchStarted, WOverlayLoadingIndicator, Wt::WTouchEvent) 122 | ADD_SIGNAL(touchEnded, WOverlayLoadingIndicator, Wt::WTouchEvent) 123 | ADD_SIGNAL(touchMoved, WOverlayLoadingIndicator, Wt::WTouchEvent) 124 | ADD_SIGNAL(gestureStarted, WOverlayLoadingIndicator, Wt::WGestureEvent) 125 | ADD_SIGNAL(gestureChanged, WOverlayLoadingIndicator, Wt::WGestureEvent) 126 | ADD_SIGNAL(gestureEnded, WOverlayLoadingIndicator, Wt::WGestureEvent) 127 | 128 | static const luaL_Reg luawt_WOverlayLoadingIndicator_methods[] = { 129 | METHOD(WOverlayLoadingIndicator, widget), 130 | METHOD(WOverlayLoadingIndicator, setMessage), 131 | METHOD(WOverlayLoadingIndicator, scrolled), 132 | METHOD(WOverlayLoadingIndicator, keyWentDown), 133 | METHOD(WOverlayLoadingIndicator, keyPressed), 134 | METHOD(WOverlayLoadingIndicator, keyWentUp), 135 | METHOD(WOverlayLoadingIndicator, enterPressed), 136 | METHOD(WOverlayLoadingIndicator, escapePressed), 137 | METHOD(WOverlayLoadingIndicator, clicked), 138 | METHOD(WOverlayLoadingIndicator, doubleClicked), 139 | METHOD(WOverlayLoadingIndicator, mouseWentDown), 140 | METHOD(WOverlayLoadingIndicator, mouseWentUp), 141 | METHOD(WOverlayLoadingIndicator, mouseWentOut), 142 | METHOD(WOverlayLoadingIndicator, mouseWentOver), 143 | METHOD(WOverlayLoadingIndicator, mouseMoved), 144 | METHOD(WOverlayLoadingIndicator, mouseDragged), 145 | METHOD(WOverlayLoadingIndicator, mouseWheel), 146 | METHOD(WOverlayLoadingIndicator, touchStarted), 147 | METHOD(WOverlayLoadingIndicator, touchEnded), 148 | METHOD(WOverlayLoadingIndicator, touchMoved), 149 | METHOD(WOverlayLoadingIndicator, gestureStarted), 150 | METHOD(WOverlayLoadingIndicator, gestureChanged), 151 | METHOD(WOverlayLoadingIndicator, gestureEnded), 152 | {NULL, NULL}, 153 | }; 154 | 155 | void luawt_WOverlayLoadingIndicator(lua_State* L) { 156 | const char* base = luawt_typeToStr(); 157 | assert(base); 158 | DECLARE_CLASS( 159 | WOverlayLoadingIndicator, 160 | L, 161 | wrap::func, 162 | 0, 163 | luawt_WOverlayLoadingIndicator_methods, 164 | base 165 | ); 166 | } 167 | -------------------------------------------------------------------------------- /src/luawt/WPaintedWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | 6 | #include "enums.hpp" 7 | #include "globals.hpp" 8 | 9 | static const char* WPaintedWidget_setPreferredMethod_args0[] = {luawt_typeToStr(), "enum", NULL}; 10 | static const char* const* const luawt_WPaintedWidget_setPreferredMethod_args[] = {WPaintedWidget_setPreferredMethod_args0, NULL}; 11 | 12 | int luawt_WPaintedWidget_setPreferredMethod(lua_State* L) { 13 | int index = luawt_getSuitableArgsGroup(L, luawt_WPaintedWidget_setPreferredMethod_args); 14 | WPaintedWidget* self = luawt_checkFromLua(L, 1); 15 | if (index == 0) { 16 | Wt::WPaintedWidget::Method method = static_cast(luawt_getEnum( 17 | L, 18 | luawt_enum_WPaintedWidget_Method_str, 19 | luawt_enum_WPaintedWidget_Method_val, 20 | 2, 21 | "Wrong enum type in args of WPaintedWidget.setPreferredMethod" 22 | )); 23 | self->setPreferredMethod(method); 24 | return 0; 25 | } else { 26 | return luaL_error(L, "Wrong arguments for WPaintedWidget.setPreferredMethod"); 27 | } 28 | } 29 | 30 | static const char* WPaintedWidget_update_args0[] = {luawt_typeToStr(), NULL}; 31 | static const char* WPaintedWidget_update_args1[] = {luawt_typeToStr(), "enum", NULL}; 32 | static const char* const* const luawt_WPaintedWidget_update_args[] = {WPaintedWidget_update_args0, WPaintedWidget_update_args1, NULL}; 33 | 34 | int luawt_WPaintedWidget_update(lua_State* L) { 35 | int index = luawt_getSuitableArgsGroup(L, luawt_WPaintedWidget_update_args); 36 | WPaintedWidget* self = luawt_checkFromLua(L, 1); 37 | if (index == 0) { 38 | self->update(); 39 | return 0; 40 | } else if (index == 1) { 41 | Wt::WFlags flags = static_cast(luawt_getEnum( 42 | L, 43 | luawt_enum_PaintFlag_str, 44 | luawt_enum_PaintFlag_val, 45 | 2, 46 | "Wrong enum type in args of WPaintedWidget.update" 47 | )); 48 | self->update(flags); 49 | return 0; 50 | } else { 51 | return luaL_error(L, "Wrong arguments for WPaintedWidget.update"); 52 | } 53 | } 54 | 55 | static const char* WPaintedWidget_resize_args0[] = {luawt_typeToStr(), "double", "double", NULL}; 56 | static const char* const* const luawt_WPaintedWidget_resize_args[] = {WPaintedWidget_resize_args0, NULL}; 57 | 58 | int luawt_WPaintedWidget_resize(lua_State* L) { 59 | int index = luawt_getSuitableArgsGroup(L, luawt_WPaintedWidget_resize_args); 60 | WPaintedWidget* self = luawt_checkFromLua(L, 1); 61 | if (index == 0) { 62 | double raw2 = lua_tonumber(L, 2); 63 | Wt::WLength width = Wt::WLength(raw2); 64 | double raw3 = lua_tonumber(L, 3); 65 | Wt::WLength height = Wt::WLength(raw3); 66 | self->resize(width, height); 67 | return 0; 68 | } else { 69 | return luaL_error(L, "Wrong arguments for WPaintedWidget.resize"); 70 | } 71 | } 72 | 73 | static const char* WPaintedWidget_preferredMethod_args0[] = {luawt_typeToStr(), NULL}; 74 | static const char* const* const luawt_WPaintedWidget_preferredMethod_args[] = {WPaintedWidget_preferredMethod_args0, NULL}; 75 | 76 | int luawt_WPaintedWidget_preferredMethod(lua_State* L) { 77 | int index = luawt_getSuitableArgsGroup(L, luawt_WPaintedWidget_preferredMethod_args); 78 | WPaintedWidget* self = luawt_checkFromLua(L, 1); 79 | if (index == 0) { 80 | Wt::WPaintedWidget::Method l_result = self->preferredMethod(); 81 | luawt_returnEnum(L, luawt_enum_WPaintedWidget_Method_str, luawt_enum_WPaintedWidget_Method_val, l_result, "WPaintedWidget::Method"); 82 | return 1; 83 | } else { 84 | return luaL_error(L, "Wrong arguments for WPaintedWidget.preferredMethod"); 85 | } 86 | } 87 | 88 | ADD_SIGNAL(keyWentDown, WPaintedWidget, Wt::WKeyEvent) 89 | ADD_SIGNAL(keyPressed, WPaintedWidget, Wt::WKeyEvent) 90 | ADD_SIGNAL(keyWentUp, WPaintedWidget, Wt::WKeyEvent) 91 | ADD_SIGNAL(enterPressed, WPaintedWidget, Wt::NoClass) 92 | ADD_SIGNAL(escapePressed, WPaintedWidget, Wt::NoClass) 93 | ADD_SIGNAL(clicked, WPaintedWidget, Wt::WMouseEvent) 94 | ADD_SIGNAL(doubleClicked, WPaintedWidget, Wt::WMouseEvent) 95 | ADD_SIGNAL(mouseWentDown, WPaintedWidget, Wt::WMouseEvent) 96 | ADD_SIGNAL(mouseWentUp, WPaintedWidget, Wt::WMouseEvent) 97 | ADD_SIGNAL(mouseWentOut, WPaintedWidget, Wt::WMouseEvent) 98 | ADD_SIGNAL(mouseWentOver, WPaintedWidget, Wt::WMouseEvent) 99 | ADD_SIGNAL(mouseMoved, WPaintedWidget, Wt::WMouseEvent) 100 | ADD_SIGNAL(mouseDragged, WPaintedWidget, Wt::WMouseEvent) 101 | ADD_SIGNAL(mouseWheel, WPaintedWidget, Wt::WMouseEvent) 102 | ADD_SIGNAL(touchStarted, WPaintedWidget, Wt::WTouchEvent) 103 | ADD_SIGNAL(touchEnded, WPaintedWidget, Wt::WTouchEvent) 104 | ADD_SIGNAL(touchMoved, WPaintedWidget, Wt::WTouchEvent) 105 | ADD_SIGNAL(gestureStarted, WPaintedWidget, Wt::WGestureEvent) 106 | ADD_SIGNAL(gestureChanged, WPaintedWidget, Wt::WGestureEvent) 107 | ADD_SIGNAL(gestureEnded, WPaintedWidget, Wt::WGestureEvent) 108 | 109 | static const luaL_Reg luawt_WPaintedWidget_methods[] = { 110 | METHOD(WPaintedWidget, setPreferredMethod), 111 | METHOD(WPaintedWidget, preferredMethod), 112 | METHOD(WPaintedWidget, update), 113 | METHOD(WPaintedWidget, resize), 114 | METHOD(WPaintedWidget, keyWentDown), 115 | METHOD(WPaintedWidget, keyPressed), 116 | METHOD(WPaintedWidget, keyWentUp), 117 | METHOD(WPaintedWidget, enterPressed), 118 | METHOD(WPaintedWidget, escapePressed), 119 | METHOD(WPaintedWidget, clicked), 120 | METHOD(WPaintedWidget, doubleClicked), 121 | METHOD(WPaintedWidget, mouseWentDown), 122 | METHOD(WPaintedWidget, mouseWentUp), 123 | METHOD(WPaintedWidget, mouseWentOut), 124 | METHOD(WPaintedWidget, mouseWentOver), 125 | METHOD(WPaintedWidget, mouseMoved), 126 | METHOD(WPaintedWidget, mouseDragged), 127 | METHOD(WPaintedWidget, mouseWheel), 128 | METHOD(WPaintedWidget, touchStarted), 129 | METHOD(WPaintedWidget, touchEnded), 130 | METHOD(WPaintedWidget, touchMoved), 131 | METHOD(WPaintedWidget, gestureStarted), 132 | METHOD(WPaintedWidget, gestureChanged), 133 | METHOD(WPaintedWidget, gestureEnded), 134 | {NULL, NULL}, 135 | }; 136 | 137 | void luawt_WPaintedWidget(lua_State* L) { 138 | const char* base = luawt_typeToStr(); 139 | assert(base); 140 | DECLARE_CLASS( 141 | WPaintedWidget, 142 | L, 143 | 0, 144 | 0, 145 | luawt_WPaintedWidget_methods, 146 | base 147 | ); 148 | } 149 | -------------------------------------------------------------------------------- /src/luawt/WPopupWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | 6 | #include "enums.hpp" 7 | #include "globals.hpp" 8 | 9 | static const char* WPopupWidget_orientation_args0[] = {luawt_typeToStr(), NULL}; 10 | static const char* const* const luawt_WPopupWidget_orientation_args[] = {WPopupWidget_orientation_args0, NULL}; 11 | 12 | int luawt_WPopupWidget_orientation(lua_State* L) { 13 | int index = luawt_getSuitableArgsGroup(L, luawt_WPopupWidget_orientation_args); 14 | WPopupWidget* self = luawt_checkFromLua(L, 1); 15 | if (index == 0) { 16 | Wt::Orientation l_result = self->orientation(); 17 | luawt_returnEnum(L, luawt_enum_Orientation_str, luawt_enum_Orientation_val, l_result, "Orientation"); 18 | return 1; 19 | } else { 20 | return luaL_error(L, "Wrong arguments for WPopupWidget.orientation"); 21 | } 22 | } 23 | 24 | static const char* WPopupWidget_isTransient_args0[] = {luawt_typeToStr(), NULL}; 25 | static const char* const* const luawt_WPopupWidget_isTransient_args[] = {WPopupWidget_isTransient_args0, NULL}; 26 | 27 | int luawt_WPopupWidget_isTransient(lua_State* L) { 28 | int index = luawt_getSuitableArgsGroup(L, luawt_WPopupWidget_isTransient_args); 29 | WPopupWidget* self = luawt_checkFromLua(L, 1); 30 | if (index == 0) { 31 | bool l_result = self->isTransient(); 32 | lua_pushboolean(L, l_result); 33 | return 1; 34 | } else { 35 | return luaL_error(L, "Wrong arguments for WPopupWidget.isTransient"); 36 | } 37 | } 38 | 39 | static const char* WPopupWidget_autoHideDelay_args0[] = {luawt_typeToStr(), NULL}; 40 | static const char* const* const luawt_WPopupWidget_autoHideDelay_args[] = {WPopupWidget_autoHideDelay_args0, NULL}; 41 | 42 | int luawt_WPopupWidget_autoHideDelay(lua_State* L) { 43 | int index = luawt_getSuitableArgsGroup(L, luawt_WPopupWidget_autoHideDelay_args); 44 | WPopupWidget* self = luawt_checkFromLua(L, 1); 45 | if (index == 0) { 46 | int l_result = self->autoHideDelay(); 47 | lua_pushinteger(L, l_result); 48 | return 1; 49 | } else { 50 | return luaL_error(L, "Wrong arguments for WPopupWidget.autoHideDelay"); 51 | } 52 | } 53 | 54 | static const char* WPopupWidget_setTransient_args0[] = {luawt_typeToStr(), "bool", NULL}; 55 | static const char* WPopupWidget_setTransient_args1[] = {luawt_typeToStr(), "bool", "int", NULL}; 56 | static const char* const* const luawt_WPopupWidget_setTransient_args[] = {WPopupWidget_setTransient_args0, WPopupWidget_setTransient_args1, NULL}; 57 | 58 | int luawt_WPopupWidget_setTransient(lua_State* L) { 59 | int index = luawt_getSuitableArgsGroup(L, luawt_WPopupWidget_setTransient_args); 60 | WPopupWidget* self = luawt_checkFromLua(L, 1); 61 | if (index == 0) { 62 | bool transient = lua_toboolean(L, 2); 63 | self->setTransient(transient); 64 | return 0; 65 | } else if (index == 1) { 66 | bool transient = lua_toboolean(L, 2); 67 | int autoHideDelay = lua_tointeger(L, 3); 68 | self->setTransient(transient, autoHideDelay); 69 | return 0; 70 | } else { 71 | return luaL_error(L, "Wrong arguments for WPopupWidget.setTransient"); 72 | } 73 | } 74 | 75 | static const char* WPopupWidget_setAnchorWidget_args0[] = {luawt_typeToStr(), luawt_typeToStr(), NULL}; 76 | static const char* WPopupWidget_setAnchorWidget_args1[] = {luawt_typeToStr(), luawt_typeToStr(), "enum", NULL}; 77 | static const char* const* const luawt_WPopupWidget_setAnchorWidget_args[] = {WPopupWidget_setAnchorWidget_args0, WPopupWidget_setAnchorWidget_args1, NULL}; 78 | 79 | int luawt_WPopupWidget_setAnchorWidget(lua_State* L) { 80 | int index = luawt_getSuitableArgsGroup(L, luawt_WPopupWidget_setAnchorWidget_args); 81 | WPopupWidget* self = luawt_checkFromLua(L, 1); 82 | if (index == 0) { 83 | Wt::WWidget* widget = 84 | luawt_checkFromLua(L, 2); 85 | self->setAnchorWidget(widget); 86 | return 0; 87 | } else if (index == 1) { 88 | Wt::WWidget* widget = 89 | luawt_checkFromLua(L, 2); 90 | Wt::Orientation orientation = static_cast(luawt_getEnum( 91 | L, 92 | luawt_enum_Orientation_str, 93 | luawt_enum_Orientation_val, 94 | 3, 95 | "Wrong enum type in args of WPopupWidget.setAnchorWidget" 96 | )); 97 | self->setAnchorWidget(widget, orientation); 98 | return 0; 99 | } else { 100 | return luaL_error(L, "Wrong arguments for WPopupWidget.setAnchorWidget"); 101 | } 102 | } 103 | 104 | static const char* WPopupWidget_anchorWidget_args0[] = {luawt_typeToStr(), NULL}; 105 | static const char* const* const luawt_WPopupWidget_anchorWidget_args[] = {WPopupWidget_anchorWidget_args0, NULL}; 106 | 107 | int luawt_WPopupWidget_anchorWidget(lua_State* L) { 108 | int index = luawt_getSuitableArgsGroup(L, luawt_WPopupWidget_anchorWidget_args); 109 | WPopupWidget* self = luawt_checkFromLua(L, 1); 110 | if (index == 0) { 111 | Wt::WWidget* l_result = self->anchorWidget(); 112 | luawt_toLua(L, l_result); 113 | return 1; 114 | } else { 115 | return luaL_error(L, "Wrong arguments for WPopupWidget.anchorWidget"); 116 | } 117 | } 118 | 119 | static const luaL_Reg luawt_WPopupWidget_methods[] = { 120 | METHOD(WPopupWidget, setAnchorWidget), 121 | METHOD(WPopupWidget, anchorWidget), 122 | METHOD(WPopupWidget, orientation), 123 | METHOD(WPopupWidget, setTransient), 124 | METHOD(WPopupWidget, isTransient), 125 | METHOD(WPopupWidget, autoHideDelay), 126 | {NULL, NULL}, 127 | }; 128 | 129 | void luawt_WPopupWidget(lua_State* L) { 130 | const char* base = luawt_typeToStr(); 131 | assert(base); 132 | DECLARE_CLASS( 133 | WPopupWidget, 134 | L, 135 | 0, 136 | 0, 137 | luawt_WPopupWidget_methods, 138 | base 139 | ); 140 | } 141 | -------------------------------------------------------------------------------- /src/luawt/WRadioButton.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "enums.hpp" 8 | #include "globals.hpp" 9 | 10 | static const char* WRadioButton_make_args0[] = {NULL}; 11 | static const char* WRadioButton_make_args1[] = {luawt_typeToStr(), NULL}; 12 | static const char* WRadioButton_make_args2[] = {"char const *", NULL}; 13 | static const char* WRadioButton_make_args3[] = {"char const *", luawt_typeToStr(), NULL}; 14 | static const char* const* const luawt_WRadioButton_make_args[] = {WRadioButton_make_args0, WRadioButton_make_args1, WRadioButton_make_args2, WRadioButton_make_args3, NULL}; 15 | 16 | int luawt_WRadioButton_make(lua_State* L) { 17 | int index = luawt_getSuitableArgsGroup(L, luawt_WRadioButton_make_args); 18 | if (index == 0) { 19 | WRadioButton* l_result = new WRadioButton(); 20 | MyApplication* app = MyApplication::instance(); 21 | if (!app) { 22 | delete l_result; 23 | throw std::logic_error("No WApplication when creating WRadioButton"); 24 | } 25 | app->root()->addWidget(l_result); 26 | luawt_toLua(L, l_result); 27 | return 1; 28 | } else if (index == 1) { 29 | Wt::WContainerWidget* parent = 30 | luawt_checkFromLua(L, 1); 31 | WRadioButton* l_result = new WRadioButton(parent); 32 | luawt_toLua(L, l_result); 33 | return 1; 34 | } else if (index == 2) { 35 | char const* raw1 = lua_tostring(L, 1); 36 | Wt::WString text = Wt::WString(raw1); 37 | WRadioButton* l_result = new WRadioButton(text); 38 | MyApplication* app = MyApplication::instance(); 39 | if (!app) { 40 | delete l_result; 41 | throw std::logic_error("No WApplication when creating WRadioButton"); 42 | } 43 | app->root()->addWidget(l_result); 44 | luawt_toLua(L, l_result); 45 | return 1; 46 | } else if (index == 3) { 47 | char const* raw1 = lua_tostring(L, 1); 48 | Wt::WString text = Wt::WString(raw1); 49 | Wt::WContainerWidget* parent = 50 | luawt_checkFromLua(L, 2); 51 | WRadioButton* l_result = new WRadioButton(text, parent); 52 | luawt_toLua(L, l_result); 53 | return 1; 54 | } else { 55 | return luaL_error(L, "Wrong arguments for WRadioButton.make"); 56 | } 57 | } 58 | 59 | ADD_SIGNAL(checked, WRadioButton, Wt::NoClass) 60 | ADD_SIGNAL(unChecked, WRadioButton, Wt::NoClass) 61 | ADD_SIGNAL(changed, WRadioButton, Wt::NoClass) 62 | ADD_SIGNAL(selected, WRadioButton, Wt::NoClass) 63 | ADD_SIGNAL(blurred, WRadioButton, Wt::NoClass) 64 | ADD_SIGNAL(focussed, WRadioButton, Wt::NoClass) 65 | ADD_SIGNAL(keyWentDown, WRadioButton, Wt::WKeyEvent) 66 | ADD_SIGNAL(keyPressed, WRadioButton, Wt::WKeyEvent) 67 | ADD_SIGNAL(keyWentUp, WRadioButton, Wt::WKeyEvent) 68 | ADD_SIGNAL(enterPressed, WRadioButton, Wt::NoClass) 69 | ADD_SIGNAL(escapePressed, WRadioButton, Wt::NoClass) 70 | ADD_SIGNAL(clicked, WRadioButton, Wt::WMouseEvent) 71 | ADD_SIGNAL(doubleClicked, WRadioButton, Wt::WMouseEvent) 72 | ADD_SIGNAL(mouseWentDown, WRadioButton, Wt::WMouseEvent) 73 | ADD_SIGNAL(mouseWentUp, WRadioButton, Wt::WMouseEvent) 74 | ADD_SIGNAL(mouseWentOut, WRadioButton, Wt::WMouseEvent) 75 | ADD_SIGNAL(mouseWentOver, WRadioButton, Wt::WMouseEvent) 76 | ADD_SIGNAL(mouseMoved, WRadioButton, Wt::WMouseEvent) 77 | ADD_SIGNAL(mouseDragged, WRadioButton, Wt::WMouseEvent) 78 | ADD_SIGNAL(mouseWheel, WRadioButton, Wt::WMouseEvent) 79 | ADD_SIGNAL(touchStarted, WRadioButton, Wt::WTouchEvent) 80 | ADD_SIGNAL(touchEnded, WRadioButton, Wt::WTouchEvent) 81 | ADD_SIGNAL(touchMoved, WRadioButton, Wt::WTouchEvent) 82 | ADD_SIGNAL(gestureStarted, WRadioButton, Wt::WGestureEvent) 83 | ADD_SIGNAL(gestureChanged, WRadioButton, Wt::WGestureEvent) 84 | ADD_SIGNAL(gestureEnded, WRadioButton, Wt::WGestureEvent) 85 | 86 | static const luaL_Reg luawt_WRadioButton_methods[] = { 87 | METHOD(WRadioButton, checked), 88 | METHOD(WRadioButton, unChecked), 89 | METHOD(WRadioButton, changed), 90 | METHOD(WRadioButton, selected), 91 | METHOD(WRadioButton, blurred), 92 | METHOD(WRadioButton, focussed), 93 | METHOD(WRadioButton, keyWentDown), 94 | METHOD(WRadioButton, keyPressed), 95 | METHOD(WRadioButton, keyWentUp), 96 | METHOD(WRadioButton, enterPressed), 97 | METHOD(WRadioButton, escapePressed), 98 | METHOD(WRadioButton, clicked), 99 | METHOD(WRadioButton, doubleClicked), 100 | METHOD(WRadioButton, mouseWentDown), 101 | METHOD(WRadioButton, mouseWentUp), 102 | METHOD(WRadioButton, mouseWentOut), 103 | METHOD(WRadioButton, mouseWentOver), 104 | METHOD(WRadioButton, mouseMoved), 105 | METHOD(WRadioButton, mouseDragged), 106 | METHOD(WRadioButton, mouseWheel), 107 | METHOD(WRadioButton, touchStarted), 108 | METHOD(WRadioButton, touchEnded), 109 | METHOD(WRadioButton, touchMoved), 110 | METHOD(WRadioButton, gestureStarted), 111 | METHOD(WRadioButton, gestureChanged), 112 | METHOD(WRadioButton, gestureEnded), 113 | {NULL, NULL}, 114 | }; 115 | 116 | void luawt_WRadioButton(lua_State* L) { 117 | const char* base = luawt_typeToStr(); 118 | assert(base); 119 | DECLARE_CLASS( 120 | WRadioButton, 121 | L, 122 | wrap::func, 123 | 0, 124 | luawt_WRadioButton_methods, 125 | base 126 | ); 127 | } 128 | -------------------------------------------------------------------------------- /src/luawt/WSelectionBox.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | 6 | #include "enums.hpp" 7 | #include "globals.hpp" 8 | 9 | static const char* WSelectionBox_make_args0[] = {NULL}; 10 | static const char* WSelectionBox_make_args1[] = {luawt_typeToStr(), NULL}; 11 | static const char* const* const luawt_WSelectionBox_make_args[] = {WSelectionBox_make_args0, WSelectionBox_make_args1, NULL}; 12 | 13 | int luawt_WSelectionBox_make(lua_State* L) { 14 | int index = luawt_getSuitableArgsGroup(L, luawt_WSelectionBox_make_args); 15 | if (index == 0) { 16 | WSelectionBox* l_result = new WSelectionBox(); 17 | MyApplication* app = MyApplication::instance(); 18 | if (!app) { 19 | delete l_result; 20 | throw std::logic_error("No WApplication when creating WSelectionBox"); 21 | } 22 | app->root()->addWidget(l_result); 23 | luawt_toLua(L, l_result); 24 | return 1; 25 | } else if (index == 1) { 26 | Wt::WContainerWidget* parent = 27 | luawt_checkFromLua(L, 1); 28 | WSelectionBox* l_result = new WSelectionBox(parent); 29 | luawt_toLua(L, l_result); 30 | return 1; 31 | } else { 32 | return luaL_error(L, "Wrong arguments for WSelectionBox.make"); 33 | } 34 | } 35 | 36 | static const char* WSelectionBox_clearSelection_args0[] = {luawt_typeToStr(), NULL}; 37 | static const char* const* const luawt_WSelectionBox_clearSelection_args[] = {WSelectionBox_clearSelection_args0, NULL}; 38 | 39 | int luawt_WSelectionBox_clearSelection(lua_State* L) { 40 | int index = luawt_getSuitableArgsGroup(L, luawt_WSelectionBox_clearSelection_args); 41 | WSelectionBox* self = luawt_checkFromLua(L, 1); 42 | if (index == 0) { 43 | self->clearSelection(); 44 | return 0; 45 | } else { 46 | return luaL_error(L, "Wrong arguments for WSelectionBox.clearSelection"); 47 | } 48 | } 49 | 50 | static const char* WSelectionBox_selectionMode_args0[] = {luawt_typeToStr(), NULL}; 51 | static const char* const* const luawt_WSelectionBox_selectionMode_args[] = {WSelectionBox_selectionMode_args0, NULL}; 52 | 53 | int luawt_WSelectionBox_selectionMode(lua_State* L) { 54 | int index = luawt_getSuitableArgsGroup(L, luawt_WSelectionBox_selectionMode_args); 55 | WSelectionBox* self = luawt_checkFromLua(L, 1); 56 | if (index == 0) { 57 | Wt::SelectionMode l_result = self->selectionMode(); 58 | luawt_returnEnum(L, luawt_enum_SelectionMode_str, luawt_enum_SelectionMode_val, l_result, "SelectionMode"); 59 | return 1; 60 | } else { 61 | return luaL_error(L, "Wrong arguments for WSelectionBox.selectionMode"); 62 | } 63 | } 64 | 65 | static const char* WSelectionBox_verticalSize_args0[] = {luawt_typeToStr(), NULL}; 66 | static const char* const* const luawt_WSelectionBox_verticalSize_args[] = {WSelectionBox_verticalSize_args0, NULL}; 67 | 68 | int luawt_WSelectionBox_verticalSize(lua_State* L) { 69 | int index = luawt_getSuitableArgsGroup(L, luawt_WSelectionBox_verticalSize_args); 70 | WSelectionBox* self = luawt_checkFromLua(L, 1); 71 | if (index == 0) { 72 | int l_result = self->verticalSize(); 73 | lua_pushinteger(L, l_result); 74 | return 1; 75 | } else { 76 | return luaL_error(L, "Wrong arguments for WSelectionBox.verticalSize"); 77 | } 78 | } 79 | 80 | static const char* WSelectionBox_setVerticalSize_args0[] = {luawt_typeToStr(), "int", NULL}; 81 | static const char* const* const luawt_WSelectionBox_setVerticalSize_args[] = {WSelectionBox_setVerticalSize_args0, NULL}; 82 | 83 | int luawt_WSelectionBox_setVerticalSize(lua_State* L) { 84 | int index = luawt_getSuitableArgsGroup(L, luawt_WSelectionBox_setVerticalSize_args); 85 | WSelectionBox* self = luawt_checkFromLua(L, 1); 86 | if (index == 0) { 87 | int items = lua_tointeger(L, 2); 88 | self->setVerticalSize(items); 89 | return 0; 90 | } else { 91 | return luaL_error(L, "Wrong arguments for WSelectionBox.setVerticalSize"); 92 | } 93 | } 94 | 95 | static const char* WSelectionBox_setSelectionMode_args0[] = {luawt_typeToStr(), "enum", NULL}; 96 | static const char* const* const luawt_WSelectionBox_setSelectionMode_args[] = {WSelectionBox_setSelectionMode_args0, NULL}; 97 | 98 | int luawt_WSelectionBox_setSelectionMode(lua_State* L) { 99 | int index = luawt_getSuitableArgsGroup(L, luawt_WSelectionBox_setSelectionMode_args); 100 | WSelectionBox* self = luawt_checkFromLua(L, 1); 101 | if (index == 0) { 102 | Wt::SelectionMode mode = static_cast(luawt_getEnum( 103 | L, 104 | luawt_enum_SelectionMode_str, 105 | luawt_enum_SelectionMode_val, 106 | 2, 107 | "Wrong enum type in args of WSelectionBox.setSelectionMode" 108 | )); 109 | self->setSelectionMode(mode); 110 | return 0; 111 | } else { 112 | return luaL_error(L, "Wrong arguments for WSelectionBox.setSelectionMode"); 113 | } 114 | } 115 | 116 | ADD_SIGNAL(changed, WSelectionBox, Wt::NoClass) 117 | ADD_SIGNAL(selected, WSelectionBox, Wt::NoClass) 118 | ADD_SIGNAL(blurred, WSelectionBox, Wt::NoClass) 119 | ADD_SIGNAL(focussed, WSelectionBox, Wt::NoClass) 120 | ADD_SIGNAL(keyWentDown, WSelectionBox, Wt::WKeyEvent) 121 | ADD_SIGNAL(keyPressed, WSelectionBox, Wt::WKeyEvent) 122 | ADD_SIGNAL(keyWentUp, WSelectionBox, Wt::WKeyEvent) 123 | ADD_SIGNAL(enterPressed, WSelectionBox, Wt::NoClass) 124 | ADD_SIGNAL(escapePressed, WSelectionBox, Wt::NoClass) 125 | ADD_SIGNAL(clicked, WSelectionBox, Wt::WMouseEvent) 126 | ADD_SIGNAL(doubleClicked, WSelectionBox, Wt::WMouseEvent) 127 | ADD_SIGNAL(mouseWentDown, WSelectionBox, Wt::WMouseEvent) 128 | ADD_SIGNAL(mouseWentUp, WSelectionBox, Wt::WMouseEvent) 129 | ADD_SIGNAL(mouseWentOut, WSelectionBox, Wt::WMouseEvent) 130 | ADD_SIGNAL(mouseWentOver, WSelectionBox, Wt::WMouseEvent) 131 | ADD_SIGNAL(mouseMoved, WSelectionBox, Wt::WMouseEvent) 132 | ADD_SIGNAL(mouseDragged, WSelectionBox, Wt::WMouseEvent) 133 | ADD_SIGNAL(mouseWheel, WSelectionBox, Wt::WMouseEvent) 134 | ADD_SIGNAL(touchStarted, WSelectionBox, Wt::WTouchEvent) 135 | ADD_SIGNAL(touchEnded, WSelectionBox, Wt::WTouchEvent) 136 | ADD_SIGNAL(touchMoved, WSelectionBox, Wt::WTouchEvent) 137 | ADD_SIGNAL(gestureStarted, WSelectionBox, Wt::WGestureEvent) 138 | ADD_SIGNAL(gestureChanged, WSelectionBox, Wt::WGestureEvent) 139 | ADD_SIGNAL(gestureEnded, WSelectionBox, Wt::WGestureEvent) 140 | 141 | static const luaL_Reg luawt_WSelectionBox_methods[] = { 142 | METHOD(WSelectionBox, verticalSize), 143 | METHOD(WSelectionBox, setVerticalSize), 144 | METHOD(WSelectionBox, setSelectionMode), 145 | METHOD(WSelectionBox, selectionMode), 146 | METHOD(WSelectionBox, clearSelection), 147 | METHOD(WSelectionBox, changed), 148 | METHOD(WSelectionBox, selected), 149 | METHOD(WSelectionBox, blurred), 150 | METHOD(WSelectionBox, focussed), 151 | METHOD(WSelectionBox, keyWentDown), 152 | METHOD(WSelectionBox, keyPressed), 153 | METHOD(WSelectionBox, keyWentUp), 154 | METHOD(WSelectionBox, enterPressed), 155 | METHOD(WSelectionBox, escapePressed), 156 | METHOD(WSelectionBox, clicked), 157 | METHOD(WSelectionBox, doubleClicked), 158 | METHOD(WSelectionBox, mouseWentDown), 159 | METHOD(WSelectionBox, mouseWentUp), 160 | METHOD(WSelectionBox, mouseWentOut), 161 | METHOD(WSelectionBox, mouseWentOver), 162 | METHOD(WSelectionBox, mouseMoved), 163 | METHOD(WSelectionBox, mouseDragged), 164 | METHOD(WSelectionBox, mouseWheel), 165 | METHOD(WSelectionBox, touchStarted), 166 | METHOD(WSelectionBox, touchEnded), 167 | METHOD(WSelectionBox, touchMoved), 168 | METHOD(WSelectionBox, gestureStarted), 169 | METHOD(WSelectionBox, gestureChanged), 170 | METHOD(WSelectionBox, gestureEnded), 171 | {NULL, NULL}, 172 | }; 173 | 174 | void luawt_WSelectionBox(lua_State* L) { 175 | const char* base = luawt_typeToStr(); 176 | assert(base); 177 | DECLARE_CLASS( 178 | WSelectionBox, 179 | L, 180 | wrap::func, 181 | 0, 182 | luawt_WSelectionBox_methods, 183 | base 184 | ); 185 | } 186 | -------------------------------------------------------------------------------- /src/luawt/WServer.cpp: -------------------------------------------------------------------------------- 1 | /* luawt, Lua bindings for Wt 2 | * Copyright (c) 2015-2017 Pavel Dolgov and Boris Nagaev 3 | * 4 | * See the LICENSE file for terms of use. 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #include "boost-xtime.hpp" 11 | #include 12 | #include 13 | #include 14 | 15 | #include "globals.hpp" 16 | 17 | class luawt_AppCreator { 18 | public: 19 | luawt_AppCreator(void* shared, const std::string& code): 20 | shared_(shared), code_(code) { 21 | } 22 | 23 | WApplication* operator()(const WEnvironment& env) const { 24 | std::auto_ptr app( 25 | new MyApplication(0, shared_, env) 26 | ); 27 | int status = luaL_loadstring(app->L(), 28 | code_.c_str()); 29 | checkPcallStatus(app->L(), status); 30 | luawt_toLua(app->L(), &(*app)); 31 | WEnvironment& env_nonconst = 32 | const_cast(env); 33 | luawt_toLua(app->L(), &env_nonconst); 34 | status = lua_pcall(app->L(), 2, 0, 0); 35 | checkPcallStatus(app->L(), status); 36 | return app.release(); 37 | } 38 | 39 | private: 40 | std::string code_; 41 | void* shared_; 42 | }; 43 | 44 | /** Creates the Wt application server 45 | Argument 1 is table of options 46 | Possible options: code, port, config. 47 | */ 48 | int luawt_WServer_make(lua_State* L) { 49 | luaL_checktype(L, 1, LUA_TTABLE); 50 | // get code 51 | lua_getfield(L, 1, "code"); 52 | size_t code_len; 53 | const char* code = luaL_checklstring(L, -1, &code_len); 54 | // get IP 55 | lua_getfield(L, 1, "ip"); 56 | const char* ip = luaL_checkstring(L, -1); 57 | // get port 58 | lua_getfield(L, 1, "port"); 59 | const char* port = luaL_checkstring(L, -1); 60 | // get config 61 | const char* config = 0; 62 | lua_getfield(L, 1, "wt_config"); 63 | if (!lua_isnil(L, -1)) { 64 | config = luaL_checkstring(L, -1); 65 | } 66 | // get document root for static files 67 | const char* docroot = 0; 68 | lua_getfield(L, 1, "docroot"); 69 | if (!lua_isnil(L, -1)) { 70 | docroot = luaL_checkstring(L, -1); 71 | } 72 | // make argc, argv 73 | typedef std::vector Options; 74 | Options opt; 75 | opt.push_back("luawt"); 76 | opt.push_back("--http-address"); 77 | opt.push_back(ip); 78 | opt.push_back("--http-port"); 79 | opt.push_back(port); 80 | if (config) { 81 | opt.push_back("--config"); 82 | opt.push_back(config); 83 | } 84 | if (docroot) { 85 | opt.push_back("--docroot"); 86 | opt.push_back(docroot); 87 | } else { 88 | opt.push_back("--docroot=/usr/include/Wt"); 89 | } 90 | opt.push_back(0); 91 | WServer* server = reinterpret_cast( 92 | lua_newuserdata(L, sizeof(WServer)) 93 | ); 94 | int argc = opt.size() - 1; 95 | char** argv = const_cast(&opt[0]); 96 | new (server) WServer(); 97 | server->setServerConfiguration(argc, argv); 98 | server->addEntryPoint( 99 | Wt::Application, 100 | luawt_AppCreator( 101 | luawt_getShared(L), 102 | std::string(code, code_len) 103 | ) 104 | ); 105 | luaL_getmetatable(L, "luawt_WServer"); 106 | lua_setmetatable(L, -2); 107 | return 1; 108 | } 109 | 110 | int luawt_WServer_start(lua_State* L) { 111 | WServer* server = reinterpret_cast( 112 | luaL_checkudata(L, 1, "luawt_WServer") 113 | ); 114 | bool ok = server->start(); 115 | lua_pushboolean(L, ok); 116 | return 1; 117 | } 118 | 119 | int luawt_WServer_stop(lua_State* L) { 120 | WServer* s = reinterpret_cast( 121 | luaL_checkudata(L, 1, "luawt_WServer") 122 | ); 123 | bool force = lua_toboolean(L, 2); 124 | if (force) { 125 | s->ioService().boost::asio::io_service::stop(); 126 | } 127 | s->stop(); 128 | return 0; 129 | } 130 | 131 | int luawt_WServer_waitForShutdown(lua_State* L) { 132 | WServer* s = reinterpret_cast( 133 | luaL_checkudata(L, 1, "luawt_WServer") 134 | ); 135 | s->waitForShutdown(); 136 | return 0; 137 | } 138 | 139 | int luawt_WServer_gc(lua_State* L) { 140 | WServer* s = reinterpret_cast( 141 | luaL_checkudata(L, 1, "luawt_WServer") 142 | ); 143 | s->WServer::~WServer(); 144 | return 0; 145 | } 146 | 147 | static const luaL_Reg luawt_WServer_mt[] = { 148 | MT_METHOD(WServer, gc), 149 | {NULL, NULL}, 150 | }; 151 | 152 | static const luaL_Reg luawt_WServer_methods[] = { 153 | METHOD(WServer, start), 154 | METHOD(WServer, stop), 155 | METHOD(WServer, waitForShutdown), 156 | {NULL, NULL}, 157 | }; 158 | 159 | void luawt_WServer(lua_State* L) { 160 | luaL_newmetatable(L, "luawt_WServer"); 161 | my_setfuncs(L, luawt_WServer_mt); 162 | lua_newtable(L); 163 | my_setfuncs(L, luawt_WServer_methods); 164 | lua_setfield(L, -2, "__index"); 165 | lua_pop(L, 1); // mt 166 | // put make to luawt 167 | luaL_getmetatable(L, "luawt"); 168 | lua_pushcfunction(L, wrap::func); 169 | lua_setfield(L, -2, "WServer"); 170 | lua_pop(L, 1); // luawt 171 | } 172 | -------------------------------------------------------------------------------- /src/luawt/WSplitButton.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "enums.hpp" 10 | #include "globals.hpp" 11 | 12 | static const char* WSplitButton_make_args0[] = {NULL}; 13 | static const char* WSplitButton_make_args1[] = {luawt_typeToStr(), NULL}; 14 | static const char* WSplitButton_make_args2[] = {"char const *", NULL}; 15 | static const char* WSplitButton_make_args3[] = {"char const *", luawt_typeToStr(), NULL}; 16 | static const char* const* const luawt_WSplitButton_make_args[] = {WSplitButton_make_args0, WSplitButton_make_args1, WSplitButton_make_args2, WSplitButton_make_args3, NULL}; 17 | 18 | int luawt_WSplitButton_make(lua_State* L) { 19 | int index = luawt_getSuitableArgsGroup(L, luawt_WSplitButton_make_args); 20 | if (index == 0) { 21 | WSplitButton* l_result = new WSplitButton(); 22 | MyApplication* app = MyApplication::instance(); 23 | if (!app) { 24 | delete l_result; 25 | throw std::logic_error("No WApplication when creating WSplitButton"); 26 | } 27 | app->root()->addWidget(l_result); 28 | luawt_toLua(L, l_result); 29 | return 1; 30 | } else if (index == 1) { 31 | Wt::WContainerWidget* parent = 32 | luawt_checkFromLua(L, 1); 33 | WSplitButton* l_result = new WSplitButton(parent); 34 | luawt_toLua(L, l_result); 35 | return 1; 36 | } else if (index == 2) { 37 | char const* raw1 = lua_tostring(L, 1); 38 | Wt::WString label = Wt::WString(raw1); 39 | WSplitButton* l_result = new WSplitButton(label); 40 | MyApplication* app = MyApplication::instance(); 41 | if (!app) { 42 | delete l_result; 43 | throw std::logic_error("No WApplication when creating WSplitButton"); 44 | } 45 | app->root()->addWidget(l_result); 46 | luawt_toLua(L, l_result); 47 | return 1; 48 | } else if (index == 3) { 49 | char const* raw1 = lua_tostring(L, 1); 50 | Wt::WString label = Wt::WString(raw1); 51 | Wt::WContainerWidget* parent = 52 | luawt_checkFromLua(L, 2); 53 | WSplitButton* l_result = new WSplitButton(label, parent); 54 | luawt_toLua(L, l_result); 55 | return 1; 56 | } else { 57 | return luaL_error(L, "Wrong arguments for WSplitButton.make"); 58 | } 59 | } 60 | 61 | static const char* WSplitButton_menu_args0[] = {luawt_typeToStr(), NULL}; 62 | static const char* const* const luawt_WSplitButton_menu_args[] = {WSplitButton_menu_args0, NULL}; 63 | 64 | int luawt_WSplitButton_menu(lua_State* L) { 65 | int index = luawt_getSuitableArgsGroup(L, luawt_WSplitButton_menu_args); 66 | WSplitButton* self = luawt_checkFromLua(L, 1); 67 | if (index == 0) { 68 | Wt::WPopupMenu* l_result = self->menu(); 69 | luawt_toLua(L, l_result); 70 | return 1; 71 | } else { 72 | return luaL_error(L, "Wrong arguments for WSplitButton.menu"); 73 | } 74 | } 75 | 76 | static const char* WSplitButton_actionButton_args0[] = {luawt_typeToStr(), NULL}; 77 | static const char* const* const luawt_WSplitButton_actionButton_args[] = {WSplitButton_actionButton_args0, NULL}; 78 | 79 | int luawt_WSplitButton_actionButton(lua_State* L) { 80 | int index = luawt_getSuitableArgsGroup(L, luawt_WSplitButton_actionButton_args); 81 | WSplitButton* self = luawt_checkFromLua(L, 1); 82 | if (index == 0) { 83 | Wt::WPushButton* l_result = self->actionButton(); 84 | luawt_toLua(L, l_result); 85 | return 1; 86 | } else { 87 | return luaL_error(L, "Wrong arguments for WSplitButton.actionButton"); 88 | } 89 | } 90 | 91 | static const char* WSplitButton_dropDownButton_args0[] = {luawt_typeToStr(), NULL}; 92 | static const char* const* const luawt_WSplitButton_dropDownButton_args[] = {WSplitButton_dropDownButton_args0, NULL}; 93 | 94 | int luawt_WSplitButton_dropDownButton(lua_State* L) { 95 | int index = luawt_getSuitableArgsGroup(L, luawt_WSplitButton_dropDownButton_args); 96 | WSplitButton* self = luawt_checkFromLua(L, 1); 97 | if (index == 0) { 98 | Wt::WPushButton* l_result = self->dropDownButton(); 99 | luawt_toLua(L, l_result); 100 | return 1; 101 | } else { 102 | return luaL_error(L, "Wrong arguments for WSplitButton.dropDownButton"); 103 | } 104 | } 105 | 106 | static const char* WSplitButton_setMenu_args0[] = {luawt_typeToStr(), luawt_typeToStr(), NULL}; 107 | static const char* const* const luawt_WSplitButton_setMenu_args[] = {WSplitButton_setMenu_args0, NULL}; 108 | 109 | int luawt_WSplitButton_setMenu(lua_State* L) { 110 | int index = luawt_getSuitableArgsGroup(L, luawt_WSplitButton_setMenu_args); 111 | WSplitButton* self = luawt_checkFromLua(L, 1); 112 | if (index == 0) { 113 | Wt::WPopupMenu* menu = 114 | luawt_checkFromLua(L, 2); 115 | self->setMenu(menu); 116 | return 0; 117 | } else { 118 | return luaL_error(L, "Wrong arguments for WSplitButton.setMenu"); 119 | } 120 | } 121 | 122 | static const luaL_Reg luawt_WSplitButton_methods[] = { 123 | METHOD(WSplitButton, actionButton), 124 | METHOD(WSplitButton, dropDownButton), 125 | METHOD(WSplitButton, setMenu), 126 | METHOD(WSplitButton, menu), 127 | {NULL, NULL}, 128 | }; 129 | 130 | void luawt_WSplitButton(lua_State* L) { 131 | const char* base = luawt_typeToStr(); 132 | assert(base); 133 | DECLARE_CLASS( 134 | WSplitButton, 135 | L, 136 | wrap::func, 137 | 0, 138 | luawt_WSplitButton_methods, 139 | base 140 | ); 141 | } 142 | -------------------------------------------------------------------------------- /src/luawt/WTableCell.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | 6 | #include "enums.hpp" 7 | #include "globals.hpp" 8 | 9 | static const char* WTableCell_rowSpan_args0[] = {luawt_typeToStr(), NULL}; 10 | static const char* const* const luawt_WTableCell_rowSpan_args[] = {WTableCell_rowSpan_args0, NULL}; 11 | 12 | int luawt_WTableCell_rowSpan(lua_State* L) { 13 | int index = luawt_getSuitableArgsGroup(L, luawt_WTableCell_rowSpan_args); 14 | WTableCell* self = luawt_checkFromLua(L, 1); 15 | if (index == 0) { 16 | int l_result = self->rowSpan(); 17 | lua_pushinteger(L, l_result); 18 | return 1; 19 | } else { 20 | return luaL_error(L, "Wrong arguments for WTableCell.rowSpan"); 21 | } 22 | } 23 | 24 | static const char* WTableCell_column_args0[] = {luawt_typeToStr(), NULL}; 25 | static const char* const* const luawt_WTableCell_column_args[] = {WTableCell_column_args0, NULL}; 26 | 27 | int luawt_WTableCell_column(lua_State* L) { 28 | int index = luawt_getSuitableArgsGroup(L, luawt_WTableCell_column_args); 29 | WTableCell* self = luawt_checkFromLua(L, 1); 30 | if (index == 0) { 31 | int l_result = self->column(); 32 | lua_pushinteger(L, l_result); 33 | return 1; 34 | } else { 35 | return luaL_error(L, "Wrong arguments for WTableCell.column"); 36 | } 37 | } 38 | 39 | static const char* WTableCell_setRowSpan_args0[] = {luawt_typeToStr(), "int", NULL}; 40 | static const char* const* const luawt_WTableCell_setRowSpan_args[] = {WTableCell_setRowSpan_args0, NULL}; 41 | 42 | int luawt_WTableCell_setRowSpan(lua_State* L) { 43 | int index = luawt_getSuitableArgsGroup(L, luawt_WTableCell_setRowSpan_args); 44 | WTableCell* self = luawt_checkFromLua(L, 1); 45 | if (index == 0) { 46 | int rowSpan = lua_tointeger(L, 2); 47 | self->setRowSpan(rowSpan); 48 | return 0; 49 | } else { 50 | return luaL_error(L, "Wrong arguments for WTableCell.setRowSpan"); 51 | } 52 | } 53 | 54 | static const char* WTableCell_setColumnSpan_args0[] = {luawt_typeToStr(), "int", NULL}; 55 | static const char* const* const luawt_WTableCell_setColumnSpan_args[] = {WTableCell_setColumnSpan_args0, NULL}; 56 | 57 | int luawt_WTableCell_setColumnSpan(lua_State* L) { 58 | int index = luawt_getSuitableArgsGroup(L, luawt_WTableCell_setColumnSpan_args); 59 | WTableCell* self = luawt_checkFromLua(L, 1); 60 | if (index == 0) { 61 | int colSpan = lua_tointeger(L, 2); 62 | self->setColumnSpan(colSpan); 63 | return 0; 64 | } else { 65 | return luaL_error(L, "Wrong arguments for WTableCell.setColumnSpan"); 66 | } 67 | } 68 | 69 | static const char* WTableCell_columnSpan_args0[] = {luawt_typeToStr(), NULL}; 70 | static const char* const* const luawt_WTableCell_columnSpan_args[] = {WTableCell_columnSpan_args0, NULL}; 71 | 72 | int luawt_WTableCell_columnSpan(lua_State* L) { 73 | int index = luawt_getSuitableArgsGroup(L, luawt_WTableCell_columnSpan_args); 74 | WTableCell* self = luawt_checkFromLua(L, 1); 75 | if (index == 0) { 76 | int l_result = self->columnSpan(); 77 | lua_pushinteger(L, l_result); 78 | return 1; 79 | } else { 80 | return luaL_error(L, "Wrong arguments for WTableCell.columnSpan"); 81 | } 82 | } 83 | 84 | static const char* WTableCell_table_args0[] = {luawt_typeToStr(), NULL}; 85 | static const char* const* const luawt_WTableCell_table_args[] = {WTableCell_table_args0, NULL}; 86 | 87 | int luawt_WTableCell_table(lua_State* L) { 88 | int index = luawt_getSuitableArgsGroup(L, luawt_WTableCell_table_args); 89 | WTableCell* self = luawt_checkFromLua(L, 1); 90 | if (index == 0) { 91 | Wt::WTable* l_result = self->table(); 92 | luawt_toLua(L, l_result); 93 | return 1; 94 | } else { 95 | return luaL_error(L, "Wrong arguments for WTableCell.table"); 96 | } 97 | } 98 | 99 | static const char* WTableCell_row_args0[] = {luawt_typeToStr(), NULL}; 100 | static const char* const* const luawt_WTableCell_row_args[] = {WTableCell_row_args0, NULL}; 101 | 102 | int luawt_WTableCell_row(lua_State* L) { 103 | int index = luawt_getSuitableArgsGroup(L, luawt_WTableCell_row_args); 104 | WTableCell* self = luawt_checkFromLua(L, 1); 105 | if (index == 0) { 106 | int l_result = self->row(); 107 | lua_pushinteger(L, l_result); 108 | return 1; 109 | } else { 110 | return luaL_error(L, "Wrong arguments for WTableCell.row"); 111 | } 112 | } 113 | 114 | ADD_SIGNAL(scrolled, WTableCell, Wt::WScrollEvent) 115 | ADD_SIGNAL(keyWentDown, WTableCell, Wt::WKeyEvent) 116 | ADD_SIGNAL(keyPressed, WTableCell, Wt::WKeyEvent) 117 | ADD_SIGNAL(keyWentUp, WTableCell, Wt::WKeyEvent) 118 | ADD_SIGNAL(enterPressed, WTableCell, Wt::NoClass) 119 | ADD_SIGNAL(escapePressed, WTableCell, Wt::NoClass) 120 | ADD_SIGNAL(clicked, WTableCell, Wt::WMouseEvent) 121 | ADD_SIGNAL(doubleClicked, WTableCell, Wt::WMouseEvent) 122 | ADD_SIGNAL(mouseWentDown, WTableCell, Wt::WMouseEvent) 123 | ADD_SIGNAL(mouseWentUp, WTableCell, Wt::WMouseEvent) 124 | ADD_SIGNAL(mouseWentOut, WTableCell, Wt::WMouseEvent) 125 | ADD_SIGNAL(mouseWentOver, WTableCell, Wt::WMouseEvent) 126 | ADD_SIGNAL(mouseMoved, WTableCell, Wt::WMouseEvent) 127 | ADD_SIGNAL(mouseDragged, WTableCell, Wt::WMouseEvent) 128 | ADD_SIGNAL(mouseWheel, WTableCell, Wt::WMouseEvent) 129 | ADD_SIGNAL(touchStarted, WTableCell, Wt::WTouchEvent) 130 | ADD_SIGNAL(touchEnded, WTableCell, Wt::WTouchEvent) 131 | ADD_SIGNAL(touchMoved, WTableCell, Wt::WTouchEvent) 132 | ADD_SIGNAL(gestureStarted, WTableCell, Wt::WGestureEvent) 133 | ADD_SIGNAL(gestureChanged, WTableCell, Wt::WGestureEvent) 134 | ADD_SIGNAL(gestureEnded, WTableCell, Wt::WGestureEvent) 135 | 136 | static const luaL_Reg luawt_WTableCell_methods[] = { 137 | METHOD(WTableCell, setRowSpan), 138 | METHOD(WTableCell, rowSpan), 139 | METHOD(WTableCell, setColumnSpan), 140 | METHOD(WTableCell, columnSpan), 141 | METHOD(WTableCell, row), 142 | METHOD(WTableCell, column), 143 | METHOD(WTableCell, table), 144 | METHOD(WTableCell, scrolled), 145 | METHOD(WTableCell, keyWentDown), 146 | METHOD(WTableCell, keyPressed), 147 | METHOD(WTableCell, keyWentUp), 148 | METHOD(WTableCell, enterPressed), 149 | METHOD(WTableCell, escapePressed), 150 | METHOD(WTableCell, clicked), 151 | METHOD(WTableCell, doubleClicked), 152 | METHOD(WTableCell, mouseWentDown), 153 | METHOD(WTableCell, mouseWentUp), 154 | METHOD(WTableCell, mouseWentOut), 155 | METHOD(WTableCell, mouseWentOver), 156 | METHOD(WTableCell, mouseMoved), 157 | METHOD(WTableCell, mouseDragged), 158 | METHOD(WTableCell, mouseWheel), 159 | METHOD(WTableCell, touchStarted), 160 | METHOD(WTableCell, touchEnded), 161 | METHOD(WTableCell, touchMoved), 162 | METHOD(WTableCell, gestureStarted), 163 | METHOD(WTableCell, gestureChanged), 164 | METHOD(WTableCell, gestureEnded), 165 | {NULL, NULL}, 166 | }; 167 | 168 | void luawt_WTableCell(lua_State* L) { 169 | const char* base = luawt_typeToStr(); 170 | assert(base); 171 | DECLARE_CLASS( 172 | WTableCell, 173 | L, 174 | 0, 175 | 0, 176 | luawt_WTableCell_methods, 177 | base 178 | ); 179 | } 180 | -------------------------------------------------------------------------------- /src/luawt/WTemplateFormView.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "enums.hpp" 8 | #include "globals.hpp" 9 | 10 | static const char* WTemplateFormView_make_args0[] = {NULL}; 11 | static const char* WTemplateFormView_make_args1[] = {luawt_typeToStr(), NULL}; 12 | static const char* WTemplateFormView_make_args2[] = {"char const *", NULL}; 13 | static const char* WTemplateFormView_make_args3[] = {"char const *", luawt_typeToStr(), NULL}; 14 | static const char* const* const luawt_WTemplateFormView_make_args[] = {WTemplateFormView_make_args0, WTemplateFormView_make_args1, WTemplateFormView_make_args2, WTemplateFormView_make_args3, NULL}; 15 | 16 | int luawt_WTemplateFormView_make(lua_State* L) { 17 | int index = luawt_getSuitableArgsGroup(L, luawt_WTemplateFormView_make_args); 18 | if (index == 0) { 19 | WTemplateFormView* l_result = new WTemplateFormView(); 20 | MyApplication* app = MyApplication::instance(); 21 | if (!app) { 22 | delete l_result; 23 | throw std::logic_error("No WApplication when creating WTemplateFormView"); 24 | } 25 | app->root()->addWidget(l_result); 26 | luawt_toLua(L, l_result); 27 | return 1; 28 | } else if (index == 1) { 29 | Wt::WContainerWidget* parent = 30 | luawt_checkFromLua(L, 1); 31 | WTemplateFormView* l_result = new WTemplateFormView(parent); 32 | luawt_toLua(L, l_result); 33 | return 1; 34 | } else if (index == 2) { 35 | char const* raw1 = lua_tostring(L, 1); 36 | Wt::WString text = Wt::WString(raw1); 37 | WTemplateFormView* l_result = new WTemplateFormView(text); 38 | MyApplication* app = MyApplication::instance(); 39 | if (!app) { 40 | delete l_result; 41 | throw std::logic_error("No WApplication when creating WTemplateFormView"); 42 | } 43 | app->root()->addWidget(l_result); 44 | luawt_toLua(L, l_result); 45 | return 1; 46 | } else if (index == 3) { 47 | char const* raw1 = lua_tostring(L, 1); 48 | Wt::WString text = Wt::WString(raw1); 49 | Wt::WContainerWidget* parent = 50 | luawt_checkFromLua(L, 2); 51 | WTemplateFormView* l_result = new WTemplateFormView(text, parent); 52 | luawt_toLua(L, l_result); 53 | return 1; 54 | } else { 55 | return luaL_error(L, "Wrong arguments for WTemplateFormView.make"); 56 | } 57 | } 58 | 59 | ADD_SIGNAL(keyWentDown, WTemplateFormView, Wt::WKeyEvent) 60 | ADD_SIGNAL(keyPressed, WTemplateFormView, Wt::WKeyEvent) 61 | ADD_SIGNAL(keyWentUp, WTemplateFormView, Wt::WKeyEvent) 62 | ADD_SIGNAL(enterPressed, WTemplateFormView, Wt::NoClass) 63 | ADD_SIGNAL(escapePressed, WTemplateFormView, Wt::NoClass) 64 | ADD_SIGNAL(clicked, WTemplateFormView, Wt::WMouseEvent) 65 | ADD_SIGNAL(doubleClicked, WTemplateFormView, Wt::WMouseEvent) 66 | ADD_SIGNAL(mouseWentDown, WTemplateFormView, Wt::WMouseEvent) 67 | ADD_SIGNAL(mouseWentUp, WTemplateFormView, Wt::WMouseEvent) 68 | ADD_SIGNAL(mouseWentOut, WTemplateFormView, Wt::WMouseEvent) 69 | ADD_SIGNAL(mouseWentOver, WTemplateFormView, Wt::WMouseEvent) 70 | ADD_SIGNAL(mouseMoved, WTemplateFormView, Wt::WMouseEvent) 71 | ADD_SIGNAL(mouseDragged, WTemplateFormView, Wt::WMouseEvent) 72 | ADD_SIGNAL(mouseWheel, WTemplateFormView, Wt::WMouseEvent) 73 | ADD_SIGNAL(touchStarted, WTemplateFormView, Wt::WTouchEvent) 74 | ADD_SIGNAL(touchEnded, WTemplateFormView, Wt::WTouchEvent) 75 | ADD_SIGNAL(touchMoved, WTemplateFormView, Wt::WTouchEvent) 76 | ADD_SIGNAL(gestureStarted, WTemplateFormView, Wt::WGestureEvent) 77 | ADD_SIGNAL(gestureChanged, WTemplateFormView, Wt::WGestureEvent) 78 | ADD_SIGNAL(gestureEnded, WTemplateFormView, Wt::WGestureEvent) 79 | 80 | static const luaL_Reg luawt_WTemplateFormView_methods[] = { 81 | METHOD(WTemplateFormView, keyWentDown), 82 | METHOD(WTemplateFormView, keyPressed), 83 | METHOD(WTemplateFormView, keyWentUp), 84 | METHOD(WTemplateFormView, enterPressed), 85 | METHOD(WTemplateFormView, escapePressed), 86 | METHOD(WTemplateFormView, clicked), 87 | METHOD(WTemplateFormView, doubleClicked), 88 | METHOD(WTemplateFormView, mouseWentDown), 89 | METHOD(WTemplateFormView, mouseWentUp), 90 | METHOD(WTemplateFormView, mouseWentOut), 91 | METHOD(WTemplateFormView, mouseWentOver), 92 | METHOD(WTemplateFormView, mouseMoved), 93 | METHOD(WTemplateFormView, mouseDragged), 94 | METHOD(WTemplateFormView, mouseWheel), 95 | METHOD(WTemplateFormView, touchStarted), 96 | METHOD(WTemplateFormView, touchEnded), 97 | METHOD(WTemplateFormView, touchMoved), 98 | METHOD(WTemplateFormView, gestureStarted), 99 | METHOD(WTemplateFormView, gestureChanged), 100 | METHOD(WTemplateFormView, gestureEnded), 101 | {NULL, NULL}, 102 | }; 103 | 104 | void luawt_WTemplateFormView(lua_State* L) { 105 | const char* base = luawt_typeToStr(); 106 | assert(base); 107 | DECLARE_CLASS( 108 | WTemplateFormView, 109 | L, 110 | wrap::func, 111 | 0, 112 | luawt_WTemplateFormView_methods, 113 | base 114 | ); 115 | } 116 | -------------------------------------------------------------------------------- /src/luawt/WTestEnvironment.cpp: -------------------------------------------------------------------------------- 1 | /* luawt, Lua bindings for Wt 2 | * Copyright (c) 2015-2017 Pavel Dolgov and Boris Nagaev 3 | * 4 | * See the LICENSE file for terms of use. 5 | */ 6 | 7 | #include "boost-xtime.hpp" 8 | #include 9 | 10 | #include "globals.hpp" 11 | 12 | using namespace Test; 13 | 14 | int luawt_WTestEnvironment_make(lua_State* L) { 15 | WTestEnvironment* wtest = reinterpret_cast( 16 | lua_newuserdata(L, sizeof(WTestEnvironment)) 17 | ); 18 | new (wtest) WTestEnvironment(); 19 | luaL_getmetatable(L, "luawt_WTestEnvironment"); 20 | lua_setmetatable(L, -2); 21 | return 1; 22 | } 23 | 24 | int luawt_WTestEnvironment_gc(lua_State* L) { 25 | WTestEnvironment* s = reinterpret_cast( 26 | luaL_checkudata(L, 1, "luawt_WTestEnvironment") 27 | ); 28 | s->WTestEnvironment::~WTestEnvironment(); 29 | return 0; 30 | } 31 | 32 | static const luaL_Reg luawt_WTestEnvironment_mt[] = { 33 | METHOD(WTestEnvironment, gc), 34 | {NULL, NULL}, 35 | }; 36 | 37 | void luawt_WTestEnvironment(lua_State* L) { 38 | luaL_newmetatable(L, "luawt_WTestEnvironment"); 39 | my_setfuncs(L, luawt_WTestEnvironment_mt); 40 | lua_pop(L, 1); // mt 41 | // put make to luawt 42 | luaL_getmetatable(L, "luawt"); 43 | lua_pushcfunction(L, wrap::func); 44 | lua_setfield(L, -2, "WTestEnvironment"); 45 | lua_pop(L, 1); // luawt 46 | } 47 | -------------------------------------------------------------------------------- /src/luawt/WTimerWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | 5 | #include "enums.hpp" 6 | #include "globals.hpp" 7 | 8 | static const char* WTimerWidget_timerStart_args0[] = {luawt_typeToStr(), "bool", NULL}; 9 | static const char* const* const luawt_WTimerWidget_timerStart_args[] = {WTimerWidget_timerStart_args0, NULL}; 10 | 11 | int luawt_WTimerWidget_timerStart(lua_State* L) { 12 | int index = luawt_getSuitableArgsGroup(L, luawt_WTimerWidget_timerStart_args); 13 | WTimerWidget* self = luawt_checkFromLua(L, 1); 14 | if (index == 0) { 15 | bool jsRepeat = lua_toboolean(L, 2); 16 | self->timerStart(jsRepeat); 17 | return 0; 18 | } else { 19 | return luaL_error(L, "Wrong arguments for WTimerWidget.timerStart"); 20 | } 21 | } 22 | 23 | static const char* WTimerWidget_timerExpired_args0[] = {luawt_typeToStr(), NULL}; 24 | static const char* const* const luawt_WTimerWidget_timerExpired_args[] = {WTimerWidget_timerExpired_args0, NULL}; 25 | 26 | int luawt_WTimerWidget_timerExpired(lua_State* L) { 27 | int index = luawt_getSuitableArgsGroup(L, luawt_WTimerWidget_timerExpired_args); 28 | WTimerWidget* self = luawt_checkFromLua(L, 1); 29 | if (index == 0) { 30 | bool l_result = self->timerExpired(); 31 | lua_pushboolean(L, l_result); 32 | return 1; 33 | } else { 34 | return luaL_error(L, "Wrong arguments for WTimerWidget.timerExpired"); 35 | } 36 | } 37 | 38 | ADD_SIGNAL(keyWentDown, WTimerWidget, Wt::WKeyEvent) 39 | ADD_SIGNAL(keyPressed, WTimerWidget, Wt::WKeyEvent) 40 | ADD_SIGNAL(keyWentUp, WTimerWidget, Wt::WKeyEvent) 41 | ADD_SIGNAL(enterPressed, WTimerWidget, Wt::NoClass) 42 | ADD_SIGNAL(escapePressed, WTimerWidget, Wt::NoClass) 43 | ADD_SIGNAL(clicked, WTimerWidget, Wt::WMouseEvent) 44 | ADD_SIGNAL(doubleClicked, WTimerWidget, Wt::WMouseEvent) 45 | ADD_SIGNAL(mouseWentDown, WTimerWidget, Wt::WMouseEvent) 46 | ADD_SIGNAL(mouseWentUp, WTimerWidget, Wt::WMouseEvent) 47 | ADD_SIGNAL(mouseWentOut, WTimerWidget, Wt::WMouseEvent) 48 | ADD_SIGNAL(mouseWentOver, WTimerWidget, Wt::WMouseEvent) 49 | ADD_SIGNAL(mouseMoved, WTimerWidget, Wt::WMouseEvent) 50 | ADD_SIGNAL(mouseDragged, WTimerWidget, Wt::WMouseEvent) 51 | ADD_SIGNAL(mouseWheel, WTimerWidget, Wt::WMouseEvent) 52 | ADD_SIGNAL(touchStarted, WTimerWidget, Wt::WTouchEvent) 53 | ADD_SIGNAL(touchEnded, WTimerWidget, Wt::WTouchEvent) 54 | ADD_SIGNAL(touchMoved, WTimerWidget, Wt::WTouchEvent) 55 | ADD_SIGNAL(gestureStarted, WTimerWidget, Wt::WGestureEvent) 56 | ADD_SIGNAL(gestureChanged, WTimerWidget, Wt::WGestureEvent) 57 | ADD_SIGNAL(gestureEnded, WTimerWidget, Wt::WGestureEvent) 58 | 59 | static const luaL_Reg luawt_WTimerWidget_methods[] = { 60 | METHOD(WTimerWidget, timerStart), 61 | METHOD(WTimerWidget, timerExpired), 62 | METHOD(WTimerWidget, keyWentDown), 63 | METHOD(WTimerWidget, keyPressed), 64 | METHOD(WTimerWidget, keyWentUp), 65 | METHOD(WTimerWidget, enterPressed), 66 | METHOD(WTimerWidget, escapePressed), 67 | METHOD(WTimerWidget, clicked), 68 | METHOD(WTimerWidget, doubleClicked), 69 | METHOD(WTimerWidget, mouseWentDown), 70 | METHOD(WTimerWidget, mouseWentUp), 71 | METHOD(WTimerWidget, mouseWentOut), 72 | METHOD(WTimerWidget, mouseWentOver), 73 | METHOD(WTimerWidget, mouseMoved), 74 | METHOD(WTimerWidget, mouseDragged), 75 | METHOD(WTimerWidget, mouseWheel), 76 | METHOD(WTimerWidget, touchStarted), 77 | METHOD(WTimerWidget, touchEnded), 78 | METHOD(WTimerWidget, touchMoved), 79 | METHOD(WTimerWidget, gestureStarted), 80 | METHOD(WTimerWidget, gestureChanged), 81 | METHOD(WTimerWidget, gestureEnded), 82 | {NULL, NULL}, 83 | }; 84 | 85 | void luawt_WTimerWidget(lua_State* L) { 86 | const char* base = luawt_typeToStr(); 87 | assert(base); 88 | DECLARE_CLASS( 89 | WTimerWidget, 90 | L, 91 | 0, 92 | 0, 93 | luawt_WTimerWidget_methods, 94 | base 95 | ); 96 | } 97 | -------------------------------------------------------------------------------- /src/luawt/WToolBar.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "enums.hpp" 8 | #include "globals.hpp" 9 | 10 | static const char* WToolBar_make_args0[] = {NULL}; 11 | static const char* WToolBar_make_args1[] = {luawt_typeToStr(), NULL}; 12 | static const char* const* const luawt_WToolBar_make_args[] = {WToolBar_make_args0, WToolBar_make_args1, NULL}; 13 | 14 | int luawt_WToolBar_make(lua_State* L) { 15 | int index = luawt_getSuitableArgsGroup(L, luawt_WToolBar_make_args); 16 | if (index == 0) { 17 | WToolBar* l_result = new WToolBar(); 18 | MyApplication* app = MyApplication::instance(); 19 | if (!app) { 20 | delete l_result; 21 | throw std::logic_error("No WApplication when creating WToolBar"); 22 | } 23 | app->root()->addWidget(l_result); 24 | luawt_toLua(L, l_result); 25 | return 1; 26 | } else if (index == 1) { 27 | Wt::WContainerWidget* parent = 28 | luawt_checkFromLua(L, 1); 29 | WToolBar* l_result = new WToolBar(parent); 30 | luawt_toLua(L, l_result); 31 | return 1; 32 | } else { 33 | return luaL_error(L, "Wrong arguments for WToolBar.make"); 34 | } 35 | } 36 | 37 | static const char* WToolBar_count_args0[] = {luawt_typeToStr(), NULL}; 38 | static const char* const* const luawt_WToolBar_count_args[] = {WToolBar_count_args0, NULL}; 39 | 40 | int luawt_WToolBar_count(lua_State* L) { 41 | int index = luawt_getSuitableArgsGroup(L, luawt_WToolBar_count_args); 42 | WToolBar* self = luawt_checkFromLua(L, 1); 43 | if (index == 0) { 44 | int l_result = self->count(); 45 | lua_pushinteger(L, l_result); 46 | return 1; 47 | } else { 48 | return luaL_error(L, "Wrong arguments for WToolBar.count"); 49 | } 50 | } 51 | 52 | static const char* WToolBar_widget_args0[] = {luawt_typeToStr(), "int", NULL}; 53 | static const char* const* const luawt_WToolBar_widget_args[] = {WToolBar_widget_args0, NULL}; 54 | 55 | int luawt_WToolBar_widget(lua_State* L) { 56 | int index = luawt_getSuitableArgsGroup(L, luawt_WToolBar_widget_args); 57 | WToolBar* self = luawt_checkFromLua(L, 1); 58 | if (index == 0) { 59 | int index = lua_tointeger(L, 2); 60 | Wt::WWidget* l_result = self->widget(index); 61 | luawt_toLua(L, l_result); 62 | return 1; 63 | } else { 64 | return luaL_error(L, "Wrong arguments for WToolBar.widget"); 65 | } 66 | } 67 | 68 | static const char* WToolBar_isCompact_args0[] = {luawt_typeToStr(), NULL}; 69 | static const char* const* const luawt_WToolBar_isCompact_args[] = {WToolBar_isCompact_args0, NULL}; 70 | 71 | int luawt_WToolBar_isCompact(lua_State* L) { 72 | int index = luawt_getSuitableArgsGroup(L, luawt_WToolBar_isCompact_args); 73 | WToolBar* self = luawt_checkFromLua(L, 1); 74 | if (index == 0) { 75 | bool l_result = self->isCompact(); 76 | lua_pushboolean(L, l_result); 77 | return 1; 78 | } else { 79 | return luaL_error(L, "Wrong arguments for WToolBar.isCompact"); 80 | } 81 | } 82 | 83 | static const char* WToolBar_setCompact_args0[] = {luawt_typeToStr(), "bool", NULL}; 84 | static const char* const* const luawt_WToolBar_setCompact_args[] = {WToolBar_setCompact_args0, NULL}; 85 | 86 | int luawt_WToolBar_setCompact(lua_State* L) { 87 | int index = luawt_getSuitableArgsGroup(L, luawt_WToolBar_setCompact_args); 88 | WToolBar* self = luawt_checkFromLua(L, 1); 89 | if (index == 0) { 90 | bool compact = lua_toboolean(L, 2); 91 | self->setCompact(compact); 92 | return 0; 93 | } else { 94 | return luaL_error(L, "Wrong arguments for WToolBar.setCompact"); 95 | } 96 | } 97 | 98 | static const char* WToolBar_addSeparator_args0[] = {luawt_typeToStr(), NULL}; 99 | static const char* const* const luawt_WToolBar_addSeparator_args[] = {WToolBar_addSeparator_args0, NULL}; 100 | 101 | int luawt_WToolBar_addSeparator(lua_State* L) { 102 | int index = luawt_getSuitableArgsGroup(L, luawt_WToolBar_addSeparator_args); 103 | WToolBar* self = luawt_checkFromLua(L, 1); 104 | if (index == 0) { 105 | self->addSeparator(); 106 | return 0; 107 | } else { 108 | return luaL_error(L, "Wrong arguments for WToolBar.addSeparator"); 109 | } 110 | } 111 | 112 | static const luaL_Reg luawt_WToolBar_methods[] = { 113 | METHOD(WToolBar, addSeparator), 114 | METHOD(WToolBar, count), 115 | METHOD(WToolBar, widget), 116 | METHOD(WToolBar, setCompact), 117 | METHOD(WToolBar, isCompact), 118 | {NULL, NULL}, 119 | }; 120 | 121 | void luawt_WToolBar(lua_State* L) { 122 | const char* base = luawt_typeToStr(); 123 | assert(base); 124 | DECLARE_CLASS( 125 | WToolBar, 126 | L, 127 | wrap::func, 128 | 0, 129 | luawt_WToolBar_methods, 130 | base 131 | ); 132 | } 133 | -------------------------------------------------------------------------------- /src/luawt/WTree.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "enums.hpp" 8 | #include "globals.hpp" 9 | 10 | static const char* WTree_make_args0[] = {NULL}; 11 | static const char* WTree_make_args1[] = {luawt_typeToStr(), NULL}; 12 | static const char* const* const luawt_WTree_make_args[] = {WTree_make_args0, WTree_make_args1, NULL}; 13 | 14 | int luawt_WTree_make(lua_State* L) { 15 | int index = luawt_getSuitableArgsGroup(L, luawt_WTree_make_args); 16 | if (index == 0) { 17 | WTree* l_result = new WTree(); 18 | MyApplication* app = MyApplication::instance(); 19 | if (!app) { 20 | delete l_result; 21 | throw std::logic_error("No WApplication when creating WTree"); 22 | } 23 | app->root()->addWidget(l_result); 24 | luawt_toLua(L, l_result); 25 | return 1; 26 | } else if (index == 1) { 27 | Wt::WContainerWidget* parent = 28 | luawt_checkFromLua(L, 1); 29 | WTree* l_result = new WTree(parent); 30 | luawt_toLua(L, l_result); 31 | return 1; 32 | } else { 33 | return luaL_error(L, "Wrong arguments for WTree.make"); 34 | } 35 | } 36 | 37 | static const char* WTree_clearSelection_args0[] = {luawt_typeToStr(), NULL}; 38 | static const char* const* const luawt_WTree_clearSelection_args[] = {WTree_clearSelection_args0, NULL}; 39 | 40 | int luawt_WTree_clearSelection(lua_State* L) { 41 | int index = luawt_getSuitableArgsGroup(L, luawt_WTree_clearSelection_args); 42 | WTree* self = luawt_checkFromLua(L, 1); 43 | if (index == 0) { 44 | self->clearSelection(); 45 | return 0; 46 | } else { 47 | return luaL_error(L, "Wrong arguments for WTree.clearSelection"); 48 | } 49 | } 50 | 51 | static const char* WTree_setSelectionMode_args0[] = {luawt_typeToStr(), "enum", NULL}; 52 | static const char* const* const luawt_WTree_setSelectionMode_args[] = {WTree_setSelectionMode_args0, NULL}; 53 | 54 | int luawt_WTree_setSelectionMode(lua_State* L) { 55 | int index = luawt_getSuitableArgsGroup(L, luawt_WTree_setSelectionMode_args); 56 | WTree* self = luawt_checkFromLua(L, 1); 57 | if (index == 0) { 58 | Wt::SelectionMode mode = static_cast(luawt_getEnum( 59 | L, 60 | luawt_enum_SelectionMode_str, 61 | luawt_enum_SelectionMode_val, 62 | 2, 63 | "Wrong enum type in args of WTree.setSelectionMode" 64 | )); 65 | self->setSelectionMode(mode); 66 | return 0; 67 | } else { 68 | return luaL_error(L, "Wrong arguments for WTree.setSelectionMode"); 69 | } 70 | } 71 | 72 | static const char* WTree_treeRoot_args0[] = {luawt_typeToStr(), NULL}; 73 | static const char* const* const luawt_WTree_treeRoot_args[] = {WTree_treeRoot_args0, NULL}; 74 | 75 | int luawt_WTree_treeRoot(lua_State* L) { 76 | int index = luawt_getSuitableArgsGroup(L, luawt_WTree_treeRoot_args); 77 | WTree* self = luawt_checkFromLua(L, 1); 78 | if (index == 0) { 79 | Wt::WTreeNode* l_result = self->treeRoot(); 80 | luawt_toLua(L, l_result); 81 | return 1; 82 | } else { 83 | return luaL_error(L, "Wrong arguments for WTree.treeRoot"); 84 | } 85 | } 86 | 87 | static const char* WTree_setTreeRoot_args0[] = {luawt_typeToStr(), luawt_typeToStr(), NULL}; 88 | static const char* const* const luawt_WTree_setTreeRoot_args[] = {WTree_setTreeRoot_args0, NULL}; 89 | 90 | int luawt_WTree_setTreeRoot(lua_State* L) { 91 | int index = luawt_getSuitableArgsGroup(L, luawt_WTree_setTreeRoot_args); 92 | WTree* self = luawt_checkFromLua(L, 1); 93 | if (index == 0) { 94 | Wt::WTreeNode* root = 95 | luawt_checkFromLua(L, 2); 96 | self->setTreeRoot(root); 97 | return 0; 98 | } else { 99 | return luaL_error(L, "Wrong arguments for WTree.setTreeRoot"); 100 | } 101 | } 102 | 103 | static const char* WTree_isSelected_args0[] = {luawt_typeToStr(), luawt_typeToStr(), NULL}; 104 | static const char* const* const luawt_WTree_isSelected_args[] = {WTree_isSelected_args0, NULL}; 105 | 106 | int luawt_WTree_isSelected(lua_State* L) { 107 | int index = luawt_getSuitableArgsGroup(L, luawt_WTree_isSelected_args); 108 | WTree* self = luawt_checkFromLua(L, 1); 109 | if (index == 0) { 110 | Wt::WTreeNode* node = 111 | luawt_checkFromLua(L, 2); 112 | bool l_result = self->isSelected(node); 113 | lua_pushboolean(L, l_result); 114 | return 1; 115 | } else { 116 | return luaL_error(L, "Wrong arguments for WTree.isSelected"); 117 | } 118 | } 119 | 120 | static const char* WTree_selectionMode_args0[] = {luawt_typeToStr(), NULL}; 121 | static const char* const* const luawt_WTree_selectionMode_args[] = {WTree_selectionMode_args0, NULL}; 122 | 123 | int luawt_WTree_selectionMode(lua_State* L) { 124 | int index = luawt_getSuitableArgsGroup(L, luawt_WTree_selectionMode_args); 125 | WTree* self = luawt_checkFromLua(L, 1); 126 | if (index == 0) { 127 | Wt::SelectionMode l_result = self->selectionMode(); 128 | luawt_returnEnum(L, luawt_enum_SelectionMode_str, luawt_enum_SelectionMode_val, l_result, "SelectionMode"); 129 | return 1; 130 | } else { 131 | return luaL_error(L, "Wrong arguments for WTree.selectionMode"); 132 | } 133 | } 134 | 135 | static const char* WTree_select_args0[] = {luawt_typeToStr(), luawt_typeToStr(), NULL}; 136 | static const char* WTree_select_args1[] = {luawt_typeToStr(), luawt_typeToStr(), "bool", NULL}; 137 | static const char* const* const luawt_WTree_select_args[] = {WTree_select_args0, WTree_select_args1, NULL}; 138 | 139 | int luawt_WTree_select(lua_State* L) { 140 | int index = luawt_getSuitableArgsGroup(L, luawt_WTree_select_args); 141 | WTree* self = luawt_checkFromLua(L, 1); 142 | if (index == 0) { 143 | Wt::WTreeNode* node = 144 | luawt_checkFromLua(L, 2); 145 | self->select(node); 146 | return 0; 147 | } else if (index == 1) { 148 | Wt::WTreeNode* node = 149 | luawt_checkFromLua(L, 2); 150 | bool selected = lua_toboolean(L, 3); 151 | self->select(node, selected); 152 | return 0; 153 | } else { 154 | return luaL_error(L, "Wrong arguments for WTree.select"); 155 | } 156 | } 157 | 158 | static const luaL_Reg luawt_WTree_methods[] = { 159 | METHOD(WTree, setTreeRoot), 160 | METHOD(WTree, treeRoot), 161 | METHOD(WTree, setSelectionMode), 162 | METHOD(WTree, selectionMode), 163 | METHOD(WTree, select), 164 | METHOD(WTree, isSelected), 165 | METHOD(WTree, clearSelection), 166 | {NULL, NULL}, 167 | }; 168 | 169 | void luawt_WTree(lua_State* L) { 170 | const char* base = luawt_typeToStr(); 171 | assert(base); 172 | DECLARE_CLASS( 173 | WTree, 174 | L, 175 | wrap::func, 176 | 0, 177 | luawt_WTree_methods, 178 | base 179 | ); 180 | } 181 | -------------------------------------------------------------------------------- /src/luawt/WTreeTable.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "enums.hpp" 13 | #include "globals.hpp" 14 | 15 | static const char* WTreeTable_make_args0[] = {NULL}; 16 | static const char* WTreeTable_make_args1[] = {luawt_typeToStr(), NULL}; 17 | static const char* const* const luawt_WTreeTable_make_args[] = {WTreeTable_make_args0, WTreeTable_make_args1, NULL}; 18 | 19 | int luawt_WTreeTable_make(lua_State* L) { 20 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTable_make_args); 21 | if (index == 0) { 22 | WTreeTable* l_result = new WTreeTable(); 23 | MyApplication* app = MyApplication::instance(); 24 | if (!app) { 25 | delete l_result; 26 | throw std::logic_error("No WApplication when creating WTreeTable"); 27 | } 28 | app->root()->addWidget(l_result); 29 | luawt_toLua(L, l_result); 30 | return 1; 31 | } else if (index == 1) { 32 | Wt::WContainerWidget* parent = 33 | luawt_checkFromLua(L, 1); 34 | WTreeTable* l_result = new WTreeTable(parent); 35 | luawt_toLua(L, l_result); 36 | return 1; 37 | } else { 38 | return luaL_error(L, "Wrong arguments for WTreeTable.make"); 39 | } 40 | } 41 | 42 | static const char* WTreeTable_columnCount_args0[] = {luawt_typeToStr(), NULL}; 43 | static const char* const* const luawt_WTreeTable_columnCount_args[] = {WTreeTable_columnCount_args0, NULL}; 44 | 45 | int luawt_WTreeTable_columnCount(lua_State* L) { 46 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTable_columnCount_args); 47 | WTreeTable* self = luawt_checkFromLua(L, 1); 48 | if (index == 0) { 49 | int l_result = self->columnCount(); 50 | lua_pushinteger(L, l_result); 51 | return 1; 52 | } else { 53 | return luaL_error(L, "Wrong arguments for WTreeTable.columnCount"); 54 | } 55 | } 56 | 57 | static const char* WTreeTable_treeRoot_args0[] = {luawt_typeToStr(), NULL}; 58 | static const char* const* const luawt_WTreeTable_treeRoot_args[] = {WTreeTable_treeRoot_args0, NULL}; 59 | 60 | int luawt_WTreeTable_treeRoot(lua_State* L) { 61 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTable_treeRoot_args); 62 | WTreeTable* self = luawt_checkFromLua(L, 1); 63 | if (index == 0) { 64 | Wt::WTreeTableNode* l_result = self->treeRoot(); 65 | luawt_toLua(L, l_result); 66 | return 1; 67 | } else { 68 | return luaL_error(L, "Wrong arguments for WTreeTable.treeRoot"); 69 | } 70 | } 71 | 72 | static const char* WTreeTable_columnWidth_args0[] = {luawt_typeToStr(), "int", NULL}; 73 | static const char* const* const luawt_WTreeTable_columnWidth_args[] = {WTreeTable_columnWidth_args0, NULL}; 74 | 75 | int luawt_WTreeTable_columnWidth(lua_State* L) { 76 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTable_columnWidth_args); 77 | WTreeTable* self = luawt_checkFromLua(L, 1); 78 | if (index == 0) { 79 | int column = lua_tointeger(L, 2); 80 | Wt::WLength l_result = self->columnWidth(column); 81 | lua_pushnumber(L, l_result.value()); 82 | return 1; 83 | } else { 84 | return luaL_error(L, "Wrong arguments for WTreeTable.columnWidth"); 85 | } 86 | } 87 | 88 | static const char* WTreeTable_setTreeRoot_args0[] = {luawt_typeToStr(), luawt_typeToStr(), "char const *", NULL}; 89 | static const char* const* const luawt_WTreeTable_setTreeRoot_args[] = {WTreeTable_setTreeRoot_args0, NULL}; 90 | 91 | int luawt_WTreeTable_setTreeRoot(lua_State* L) { 92 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTable_setTreeRoot_args); 93 | WTreeTable* self = luawt_checkFromLua(L, 1); 94 | if (index == 0) { 95 | Wt::WTreeTableNode* root = 96 | luawt_checkFromLua(L, 2); 97 | char const* raw3 = lua_tostring(L, 3); 98 | Wt::WString header = Wt::WString(raw3); 99 | self->setTreeRoot(root, header); 100 | return 0; 101 | } else { 102 | return luaL_error(L, "Wrong arguments for WTreeTable.setTreeRoot"); 103 | } 104 | } 105 | 106 | static const char* WTreeTable_tree_args0[] = {luawt_typeToStr(), NULL}; 107 | static const char* const* const luawt_WTreeTable_tree_args[] = {WTreeTable_tree_args0, NULL}; 108 | 109 | int luawt_WTreeTable_tree(lua_State* L) { 110 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTable_tree_args); 111 | WTreeTable* self = luawt_checkFromLua(L, 1); 112 | if (index == 0) { 113 | Wt::WTree* l_result = self->tree(); 114 | luawt_toLua(L, l_result); 115 | return 1; 116 | } else { 117 | return luaL_error(L, "Wrong arguments for WTreeTable.tree"); 118 | } 119 | } 120 | 121 | static const char* WTreeTable_setTree_args0[] = {luawt_typeToStr(), luawt_typeToStr(), "char const *", NULL}; 122 | static const char* const* const luawt_WTreeTable_setTree_args[] = {WTreeTable_setTree_args0, NULL}; 123 | 124 | int luawt_WTreeTable_setTree(lua_State* L) { 125 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTable_setTree_args); 126 | WTreeTable* self = luawt_checkFromLua(L, 1); 127 | if (index == 0) { 128 | Wt::WTree* tree = 129 | luawt_checkFromLua(L, 2); 130 | char const* raw3 = lua_tostring(L, 3); 131 | Wt::WString header = Wt::WString(raw3); 132 | self->setTree(tree, header); 133 | return 0; 134 | } else { 135 | return luaL_error(L, "Wrong arguments for WTreeTable.setTree"); 136 | } 137 | } 138 | 139 | static const char* WTreeTable_header_args0[] = {luawt_typeToStr(), "int", NULL}; 140 | static const char* const* const luawt_WTreeTable_header_args[] = {WTreeTable_header_args0, NULL}; 141 | 142 | int luawt_WTreeTable_header(lua_State* L) { 143 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTable_header_args); 144 | WTreeTable* self = luawt_checkFromLua(L, 1); 145 | if (index == 0) { 146 | int column = lua_tointeger(L, 2); 147 | Wt::WText* l_result = self->header(column); 148 | luawt_toLua(L, l_result); 149 | return 1; 150 | } else { 151 | return luaL_error(L, "Wrong arguments for WTreeTable.header"); 152 | } 153 | } 154 | 155 | static const char* WTreeTable_addColumn_args0[] = {luawt_typeToStr(), "char const *", "double", NULL}; 156 | static const char* const* const luawt_WTreeTable_addColumn_args[] = {WTreeTable_addColumn_args0, NULL}; 157 | 158 | int luawt_WTreeTable_addColumn(lua_State* L) { 159 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTable_addColumn_args); 160 | WTreeTable* self = luawt_checkFromLua(L, 1); 161 | if (index == 0) { 162 | char const* raw2 = lua_tostring(L, 2); 163 | Wt::WString header = Wt::WString(raw2); 164 | double raw3 = lua_tonumber(L, 3); 165 | Wt::WLength width = Wt::WLength(raw3); 166 | self->addColumn(header, width); 167 | return 0; 168 | } else { 169 | return luaL_error(L, "Wrong arguments for WTreeTable.addColumn"); 170 | } 171 | } 172 | 173 | static const char* WTreeTable_headerWidget_args0[] = {luawt_typeToStr(), NULL}; 174 | static const char* const* const luawt_WTreeTable_headerWidget_args[] = {WTreeTable_headerWidget_args0, NULL}; 175 | 176 | int luawt_WTreeTable_headerWidget(lua_State* L) { 177 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTable_headerWidget_args); 178 | WTreeTable* self = luawt_checkFromLua(L, 1); 179 | if (index == 0) { 180 | Wt::WWidget* l_result = self->headerWidget(); 181 | luawt_toLua(L, l_result); 182 | return 1; 183 | } else { 184 | return luaL_error(L, "Wrong arguments for WTreeTable.headerWidget"); 185 | } 186 | } 187 | 188 | static const luaL_Reg luawt_WTreeTable_methods[] = { 189 | METHOD(WTreeTable, addColumn), 190 | METHOD(WTreeTable, columnCount), 191 | METHOD(WTreeTable, setTreeRoot), 192 | METHOD(WTreeTable, treeRoot), 193 | METHOD(WTreeTable, setTree), 194 | METHOD(WTreeTable, tree), 195 | METHOD(WTreeTable, columnWidth), 196 | METHOD(WTreeTable, header), 197 | METHOD(WTreeTable, headerWidget), 198 | {NULL, NULL}, 199 | }; 200 | 201 | void luawt_WTreeTable(lua_State* L) { 202 | const char* base = luawt_typeToStr(); 203 | assert(base); 204 | DECLARE_CLASS( 205 | WTreeTable, 206 | L, 207 | wrap::func, 208 | 0, 209 | luawt_WTreeTable_methods, 210 | base 211 | ); 212 | } 213 | -------------------------------------------------------------------------------- /src/luawt/WTreeTableNode.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "enums.hpp" 11 | #include "globals.hpp" 12 | 13 | static const char* WTreeTableNode_make_args0[] = {"char const *", NULL}; 14 | static const char* WTreeTableNode_make_args1[] = {"char const *", luawt_typeToStr(), NULL}; 15 | static const char* WTreeTableNode_make_args2[] = {"char const *", luawt_typeToStr(), luawt_typeToStr(), NULL}; 16 | static const char* const* const luawt_WTreeTableNode_make_args[] = {WTreeTableNode_make_args0, WTreeTableNode_make_args1, WTreeTableNode_make_args2, NULL}; 17 | 18 | int luawt_WTreeTableNode_make(lua_State* L) { 19 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTableNode_make_args); 20 | if (index == 0) { 21 | char const* raw1 = lua_tostring(L, 1); 22 | Wt::WString labelText = Wt::WString(raw1); 23 | WTreeTableNode* l_result = new WTreeTableNode(labelText); 24 | MyApplication* app = MyApplication::instance(); 25 | if (!app) { 26 | delete l_result; 27 | throw std::logic_error("No WApplication when creating WTreeTableNode"); 28 | } 29 | app->root()->addWidget(l_result); 30 | luawt_toLua(L, l_result); 31 | return 1; 32 | } else if (index == 1) { 33 | char const* raw1 = lua_tostring(L, 1); 34 | Wt::WString labelText = Wt::WString(raw1); 35 | Wt::WIconPair* labelIcon = 36 | luawt_checkFromLua(L, 2); 37 | WTreeTableNode* l_result = new WTreeTableNode(labelText, labelIcon); 38 | MyApplication* app = MyApplication::instance(); 39 | if (!app) { 40 | delete l_result; 41 | throw std::logic_error("No WApplication when creating WTreeTableNode"); 42 | } 43 | app->root()->addWidget(l_result); 44 | luawt_toLua(L, l_result); 45 | return 1; 46 | } else if (index == 2) { 47 | char const* raw1 = lua_tostring(L, 1); 48 | Wt::WString labelText = Wt::WString(raw1); 49 | Wt::WIconPair* labelIcon = 50 | luawt_checkFromLua(L, 2); 51 | Wt::WTreeTableNode* parentNode = 52 | luawt_checkFromLua(L, 3); 53 | WTreeTableNode* l_result = new WTreeTableNode(labelText, labelIcon, parentNode); 54 | MyApplication* app = MyApplication::instance(); 55 | if (!app) { 56 | delete l_result; 57 | throw std::logic_error("No WApplication when creating WTreeTableNode"); 58 | } 59 | app->root()->addWidget(l_result); 60 | luawt_toLua(L, l_result); 61 | return 1; 62 | } else { 63 | return luaL_error(L, "Wrong arguments for WTreeTableNode.make"); 64 | } 65 | } 66 | 67 | static const char* WTreeTableNode_insertChildNode_args0[] = {luawt_typeToStr(), "int", luawt_typeToStr(), NULL}; 68 | static const char* const* const luawt_WTreeTableNode_insertChildNode_args[] = {WTreeTableNode_insertChildNode_args0, NULL}; 69 | 70 | int luawt_WTreeTableNode_insertChildNode(lua_State* L) { 71 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTableNode_insertChildNode_args); 72 | WTreeTableNode* self = luawt_checkFromLua(L, 1); 73 | if (index == 0) { 74 | int index = lua_tointeger(L, 2); 75 | Wt::WTreeNode* node = 76 | luawt_checkFromLua(L, 3); 77 | self->insertChildNode(index, node); 78 | return 0; 79 | } else { 80 | return luaL_error(L, "Wrong arguments for WTreeTableNode.insertChildNode"); 81 | } 82 | } 83 | 84 | static const char* WTreeTableNode_table_args0[] = {luawt_typeToStr(), NULL}; 85 | static const char* const* const luawt_WTreeTableNode_table_args[] = {WTreeTableNode_table_args0, NULL}; 86 | 87 | int luawt_WTreeTableNode_table(lua_State* L) { 88 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTableNode_table_args); 89 | WTreeTableNode* self = luawt_checkFromLua(L, 1); 90 | if (index == 0) { 91 | Wt::WTreeTable* l_result = self->table(); 92 | luawt_toLua(L, l_result); 93 | return 1; 94 | } else { 95 | return luaL_error(L, "Wrong arguments for WTreeTableNode.table"); 96 | } 97 | } 98 | 99 | static const char* WTreeTableNode_setColumnWidget_args0[] = {luawt_typeToStr(), "int", luawt_typeToStr(), NULL}; 100 | static const char* const* const luawt_WTreeTableNode_setColumnWidget_args[] = {WTreeTableNode_setColumnWidget_args0, NULL}; 101 | 102 | int luawt_WTreeTableNode_setColumnWidget(lua_State* L) { 103 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTableNode_setColumnWidget_args); 104 | WTreeTableNode* self = luawt_checkFromLua(L, 1); 105 | if (index == 0) { 106 | int column = lua_tointeger(L, 2); 107 | Wt::WWidget* item = 108 | luawt_checkFromLua(L, 3); 109 | self->setColumnWidget(column, item); 110 | return 0; 111 | } else { 112 | return luaL_error(L, "Wrong arguments for WTreeTableNode.setColumnWidget"); 113 | } 114 | } 115 | 116 | static const char* WTreeTableNode_columnWidget_args0[] = {luawt_typeToStr(), "int", NULL}; 117 | static const char* const* const luawt_WTreeTableNode_columnWidget_args[] = {WTreeTableNode_columnWidget_args0, NULL}; 118 | 119 | int luawt_WTreeTableNode_columnWidget(lua_State* L) { 120 | int index = luawt_getSuitableArgsGroup(L, luawt_WTreeTableNode_columnWidget_args); 121 | WTreeTableNode* self = luawt_checkFromLua(L, 1); 122 | if (index == 0) { 123 | int column = lua_tointeger(L, 2); 124 | Wt::WWidget* l_result = self->columnWidget(column); 125 | luawt_toLua(L, l_result); 126 | return 1; 127 | } else { 128 | return luaL_error(L, "Wrong arguments for WTreeTableNode.columnWidget"); 129 | } 130 | } 131 | 132 | ADD_SIGNAL(expanded, WTreeTableNode, Wt::WMouseEvent) 133 | ADD_SIGNAL(collapsed, WTreeTableNode, Wt::WMouseEvent) 134 | 135 | static const luaL_Reg luawt_WTreeTableNode_methods[] = { 136 | METHOD(WTreeTableNode, setColumnWidget), 137 | METHOD(WTreeTableNode, columnWidget), 138 | METHOD(WTreeTableNode, table), 139 | METHOD(WTreeTableNode, insertChildNode), 140 | METHOD(WTreeTableNode, expanded), 141 | METHOD(WTreeTableNode, collapsed), 142 | {NULL, NULL}, 143 | }; 144 | 145 | void luawt_WTreeTableNode(lua_State* L) { 146 | const char* base = luawt_typeToStr(); 147 | assert(base); 148 | DECLARE_CLASS( 149 | WTreeTableNode, 150 | L, 151 | wrap::func, 152 | 0, 153 | luawt_WTreeTableNode_methods, 154 | base 155 | ); 156 | } 157 | -------------------------------------------------------------------------------- /src/luawt/WValidationStatus.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "enums.hpp" 9 | #include "globals.hpp" 10 | 11 | static const char* WValidationStatus_make_args0[] = {luawt_typeToStr(), NULL}; 12 | static const char* WValidationStatus_make_args1[] = {luawt_typeToStr(), luawt_typeToStr(), NULL}; 13 | static const char* WValidationStatus_make_args2[] = {luawt_typeToStr(), luawt_typeToStr(), luawt_typeToStr(), NULL}; 14 | static const char* WValidationStatus_make_args3[] = {luawt_typeToStr(), luawt_typeToStr(), luawt_typeToStr(), luawt_typeToStr(), NULL}; 15 | static const char* WValidationStatus_make_args4[] = {luawt_typeToStr(), luawt_typeToStr(), luawt_typeToStr(), luawt_typeToStr(), luawt_typeToStr(), NULL}; 16 | static const char* const* const luawt_WValidationStatus_make_args[] = {WValidationStatus_make_args0, WValidationStatus_make_args1, WValidationStatus_make_args2, WValidationStatus_make_args3, WValidationStatus_make_args4, NULL}; 17 | 18 | int luawt_WValidationStatus_make(lua_State* L) { 19 | int index = luawt_getSuitableArgsGroup(L, luawt_WValidationStatus_make_args); 20 | if (index == 0) { 21 | Wt::WFormWidget* field = 22 | luawt_checkFromLua(L, 1); 23 | WValidationStatus* l_result = new WValidationStatus(field); 24 | MyApplication* app = MyApplication::instance(); 25 | if (!app) { 26 | delete l_result; 27 | throw std::logic_error("No WApplication when creating WValidationStatus"); 28 | } 29 | app->root()->addWidget(l_result); 30 | luawt_toLua(L, l_result); 31 | return 1; 32 | } else if (index == 1) { 33 | Wt::WFormWidget* field = 34 | luawt_checkFromLua(L, 1); 35 | Wt::WWidget* validStateWidget = 36 | luawt_checkFromLua(L, 2); 37 | WValidationStatus* l_result = new WValidationStatus(field, validStateWidget); 38 | MyApplication* app = MyApplication::instance(); 39 | if (!app) { 40 | delete l_result; 41 | throw std::logic_error("No WApplication when creating WValidationStatus"); 42 | } 43 | app->root()->addWidget(l_result); 44 | luawt_toLua(L, l_result); 45 | return 1; 46 | } else if (index == 2) { 47 | Wt::WFormWidget* field = 48 | luawt_checkFromLua(L, 1); 49 | Wt::WWidget* validStateWidget = 50 | luawt_checkFromLua(L, 2); 51 | Wt::WWidget* invalidStateWidget = 52 | luawt_checkFromLua(L, 3); 53 | WValidationStatus* l_result = new WValidationStatus(field, validStateWidget, invalidStateWidget); 54 | MyApplication* app = MyApplication::instance(); 55 | if (!app) { 56 | delete l_result; 57 | throw std::logic_error("No WApplication when creating WValidationStatus"); 58 | } 59 | app->root()->addWidget(l_result); 60 | luawt_toLua(L, l_result); 61 | return 1; 62 | } else if (index == 3) { 63 | Wt::WFormWidget* field = 64 | luawt_checkFromLua(L, 1); 65 | Wt::WWidget* validStateWidget = 66 | luawt_checkFromLua(L, 2); 67 | Wt::WWidget* invalidStateWidget = 68 | luawt_checkFromLua(L, 3); 69 | Wt::WWidget* invalidEmptyStateWidget = 70 | luawt_checkFromLua(L, 4); 71 | WValidationStatus* l_result = new WValidationStatus(field, validStateWidget, invalidStateWidget, invalidEmptyStateWidget); 72 | MyApplication* app = MyApplication::instance(); 73 | if (!app) { 74 | delete l_result; 75 | throw std::logic_error("No WApplication when creating WValidationStatus"); 76 | } 77 | app->root()->addWidget(l_result); 78 | luawt_toLua(L, l_result); 79 | return 1; 80 | } else if (index == 4) { 81 | Wt::WFormWidget* field = 82 | luawt_checkFromLua(L, 1); 83 | Wt::WWidget* validStateWidget = 84 | luawt_checkFromLua(L, 2); 85 | Wt::WWidget* invalidStateWidget = 86 | luawt_checkFromLua(L, 3); 87 | Wt::WWidget* invalidEmptyStateWidget = 88 | luawt_checkFromLua(L, 4); 89 | Wt::WContainerWidget* parent = 90 | luawt_checkFromLua(L, 5); 91 | WValidationStatus* l_result = new WValidationStatus(field, validStateWidget, invalidStateWidget, invalidEmptyStateWidget, parent); 92 | luawt_toLua(L, l_result); 93 | return 1; 94 | } else { 95 | return luaL_error(L, "Wrong arguments for WValidationStatus.make"); 96 | } 97 | } 98 | 99 | static const char* WValidationStatus_valid_args0[] = {luawt_typeToStr(), NULL}; 100 | static const char* const* const luawt_WValidationStatus_valid_args[] = {WValidationStatus_valid_args0, NULL}; 101 | 102 | int luawt_WValidationStatus_valid(lua_State* L) { 103 | int index = luawt_getSuitableArgsGroup(L, luawt_WValidationStatus_valid_args); 104 | WValidationStatus* self = luawt_checkFromLua(L, 1); 105 | if (index == 0) { 106 | bool l_result = self->valid(); 107 | lua_pushboolean(L, l_result); 108 | return 1; 109 | } else { 110 | return luaL_error(L, "Wrong arguments for WValidationStatus.valid"); 111 | } 112 | } 113 | 114 | static const luaL_Reg luawt_WValidationStatus_methods[] = { 115 | METHOD(WValidationStatus, valid), 116 | {NULL, NULL}, 117 | }; 118 | 119 | void luawt_WValidationStatus(lua_State* L) { 120 | const char* base = luawt_typeToStr(); 121 | assert(base); 122 | DECLARE_CLASS( 123 | WValidationStatus, 124 | L, 125 | wrap::func, 126 | 0, 127 | luawt_WValidationStatus_methods, 128 | base 129 | ); 130 | } 131 | -------------------------------------------------------------------------------- /src/luawt/WVideo.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "enums.hpp" 8 | #include "globals.hpp" 9 | 10 | static const char* WVideo_make_args0[] = {NULL}; 11 | static const char* WVideo_make_args1[] = {luawt_typeToStr(), NULL}; 12 | static const char* const* const luawt_WVideo_make_args[] = {WVideo_make_args0, WVideo_make_args1, NULL}; 13 | 14 | int luawt_WVideo_make(lua_State* L) { 15 | int index = luawt_getSuitableArgsGroup(L, luawt_WVideo_make_args); 16 | if (index == 0) { 17 | WVideo* l_result = new WVideo(); 18 | MyApplication* app = MyApplication::instance(); 19 | if (!app) { 20 | delete l_result; 21 | throw std::logic_error("No WApplication when creating WVideo"); 22 | } 23 | app->root()->addWidget(l_result); 24 | luawt_toLua(L, l_result); 25 | return 1; 26 | } else if (index == 1) { 27 | Wt::WContainerWidget* parent = 28 | luawt_checkFromLua(L, 1); 29 | WVideo* l_result = new WVideo(parent); 30 | luawt_toLua(L, l_result); 31 | return 1; 32 | } else { 33 | return luaL_error(L, "Wrong arguments for WVideo.make"); 34 | } 35 | } 36 | 37 | static const char* WVideo_jsVideoRef_args0[] = {luawt_typeToStr(), NULL}; 38 | static const char* const* const luawt_WVideo_jsVideoRef_args[] = {WVideo_jsVideoRef_args0, NULL}; 39 | 40 | int luawt_WVideo_jsVideoRef(lua_State* L) { 41 | int index = luawt_getSuitableArgsGroup(L, luawt_WVideo_jsVideoRef_args); 42 | WVideo* self = luawt_checkFromLua(L, 1); 43 | if (index == 0) { 44 | std::string l_result = self->jsVideoRef(); 45 | lua_pushstring(L, l_result.c_str()); 46 | return 1; 47 | } else { 48 | return luaL_error(L, "Wrong arguments for WVideo.jsVideoRef"); 49 | } 50 | } 51 | 52 | static const char* WVideo_resize_args0[] = {luawt_typeToStr(), "double", "double", NULL}; 53 | static const char* const* const luawt_WVideo_resize_args[] = {WVideo_resize_args0, NULL}; 54 | 55 | int luawt_WVideo_resize(lua_State* L) { 56 | int index = luawt_getSuitableArgsGroup(L, luawt_WVideo_resize_args); 57 | WVideo* self = luawt_checkFromLua(L, 1); 58 | if (index == 0) { 59 | double raw2 = lua_tonumber(L, 2); 60 | Wt::WLength width = Wt::WLength(raw2); 61 | double raw3 = lua_tonumber(L, 3); 62 | Wt::WLength height = Wt::WLength(raw3); 63 | self->resize(width, height); 64 | return 0; 65 | } else { 66 | return luaL_error(L, "Wrong arguments for WVideo.resize"); 67 | } 68 | } 69 | 70 | static const char* WVideo_setPoster_args0[] = {luawt_typeToStr(), "char const *", NULL}; 71 | static const char* const* const luawt_WVideo_setPoster_args[] = {WVideo_setPoster_args0, NULL}; 72 | 73 | int luawt_WVideo_setPoster(lua_State* L) { 74 | int index = luawt_getSuitableArgsGroup(L, luawt_WVideo_setPoster_args); 75 | WVideo* self = luawt_checkFromLua(L, 1); 76 | if (index == 0) { 77 | char const* raw2 = lua_tostring(L, 2); 78 | std::string url = std::string(raw2); 79 | self->setPoster(url); 80 | return 0; 81 | } else { 82 | return luaL_error(L, "Wrong arguments for WVideo.setPoster"); 83 | } 84 | } 85 | 86 | ADD_SIGNAL(playbackStarted, WVideo, Wt::NoClass) 87 | ADD_SIGNAL(playbackPaused, WVideo, Wt::NoClass) 88 | ADD_SIGNAL(ended, WVideo, Wt::NoClass) 89 | ADD_SIGNAL(timeUpdated, WVideo, Wt::NoClass) 90 | ADD_SIGNAL(volumeChanged, WVideo, Wt::NoClass) 91 | ADD_SIGNAL(keyWentDown, WVideo, Wt::WKeyEvent) 92 | ADD_SIGNAL(keyPressed, WVideo, Wt::WKeyEvent) 93 | ADD_SIGNAL(keyWentUp, WVideo, Wt::WKeyEvent) 94 | ADD_SIGNAL(enterPressed, WVideo, Wt::NoClass) 95 | ADD_SIGNAL(escapePressed, WVideo, Wt::NoClass) 96 | ADD_SIGNAL(clicked, WVideo, Wt::WMouseEvent) 97 | ADD_SIGNAL(doubleClicked, WVideo, Wt::WMouseEvent) 98 | ADD_SIGNAL(mouseWentDown, WVideo, Wt::WMouseEvent) 99 | ADD_SIGNAL(mouseWentUp, WVideo, Wt::WMouseEvent) 100 | ADD_SIGNAL(mouseWentOut, WVideo, Wt::WMouseEvent) 101 | ADD_SIGNAL(mouseWentOver, WVideo, Wt::WMouseEvent) 102 | ADD_SIGNAL(mouseMoved, WVideo, Wt::WMouseEvent) 103 | ADD_SIGNAL(mouseDragged, WVideo, Wt::WMouseEvent) 104 | ADD_SIGNAL(mouseWheel, WVideo, Wt::WMouseEvent) 105 | ADD_SIGNAL(touchStarted, WVideo, Wt::WTouchEvent) 106 | ADD_SIGNAL(touchEnded, WVideo, Wt::WTouchEvent) 107 | ADD_SIGNAL(touchMoved, WVideo, Wt::WTouchEvent) 108 | ADD_SIGNAL(gestureStarted, WVideo, Wt::WGestureEvent) 109 | ADD_SIGNAL(gestureChanged, WVideo, Wt::WGestureEvent) 110 | ADD_SIGNAL(gestureEnded, WVideo, Wt::WGestureEvent) 111 | 112 | static const luaL_Reg luawt_WVideo_methods[] = { 113 | METHOD(WVideo, setPoster), 114 | METHOD(WVideo, jsVideoRef), 115 | METHOD(WVideo, resize), 116 | METHOD(WVideo, playbackStarted), 117 | METHOD(WVideo, playbackPaused), 118 | METHOD(WVideo, ended), 119 | METHOD(WVideo, timeUpdated), 120 | METHOD(WVideo, volumeChanged), 121 | METHOD(WVideo, keyWentDown), 122 | METHOD(WVideo, keyPressed), 123 | METHOD(WVideo, keyWentUp), 124 | METHOD(WVideo, enterPressed), 125 | METHOD(WVideo, escapePressed), 126 | METHOD(WVideo, clicked), 127 | METHOD(WVideo, doubleClicked), 128 | METHOD(WVideo, mouseWentDown), 129 | METHOD(WVideo, mouseWentUp), 130 | METHOD(WVideo, mouseWentOut), 131 | METHOD(WVideo, mouseWentOver), 132 | METHOD(WVideo, mouseMoved), 133 | METHOD(WVideo, mouseDragged), 134 | METHOD(WVideo, mouseWheel), 135 | METHOD(WVideo, touchStarted), 136 | METHOD(WVideo, touchEnded), 137 | METHOD(WVideo, touchMoved), 138 | METHOD(WVideo, gestureStarted), 139 | METHOD(WVideo, gestureChanged), 140 | METHOD(WVideo, gestureEnded), 141 | {NULL, NULL}, 142 | }; 143 | 144 | void luawt_WVideo(lua_State* L) { 145 | const char* base = luawt_typeToStr(); 146 | assert(base); 147 | DECLARE_CLASS( 148 | WVideo, 149 | L, 150 | wrap::func, 151 | 0, 152 | luawt_WVideo_methods, 153 | base 154 | ); 155 | } 156 | -------------------------------------------------------------------------------- /src/luawt/WViewWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "boost-xtime.hpp" 2 | 3 | #include 4 | 5 | #include "enums.hpp" 6 | #include "globals.hpp" 7 | 8 | static const char* WViewWidget_load_args0[] = {luawt_typeToStr(), NULL}; 9 | static const char* const* const luawt_WViewWidget_load_args[] = {WViewWidget_load_args0, NULL}; 10 | 11 | int luawt_WViewWidget_load(lua_State* L) { 12 | int index = luawt_getSuitableArgsGroup(L, luawt_WViewWidget_load_args); 13 | WViewWidget* self = luawt_checkFromLua(L, 1); 14 | if (index == 0) { 15 | self->load(); 16 | return 0; 17 | } else { 18 | return luaL_error(L, "Wrong arguments for WViewWidget.load"); 19 | } 20 | } 21 | 22 | static const char* WViewWidget_refresh_args0[] = {luawt_typeToStr(), NULL}; 23 | static const char* const* const luawt_WViewWidget_refresh_args[] = {WViewWidget_refresh_args0, NULL}; 24 | 25 | int luawt_WViewWidget_refresh(lua_State* L) { 26 | int index = luawt_getSuitableArgsGroup(L, luawt_WViewWidget_refresh_args); 27 | WViewWidget* self = luawt_checkFromLua(L, 1); 28 | if (index == 0) { 29 | self->refresh(); 30 | return 0; 31 | } else { 32 | return luaL_error(L, "Wrong arguments for WViewWidget.refresh"); 33 | } 34 | } 35 | 36 | static const char* WViewWidget_update_args0[] = {luawt_typeToStr(), NULL}; 37 | static const char* const* const luawt_WViewWidget_update_args[] = {WViewWidget_update_args0, NULL}; 38 | 39 | int luawt_WViewWidget_update(lua_State* L) { 40 | int index = luawt_getSuitableArgsGroup(L, luawt_WViewWidget_update_args); 41 | WViewWidget* self = luawt_checkFromLua(L, 1); 42 | if (index == 0) { 43 | self->update(); 44 | return 0; 45 | } else { 46 | return luaL_error(L, "Wrong arguments for WViewWidget.update"); 47 | } 48 | } 49 | 50 | static const char* WViewWidget_render_args0[] = {luawt_typeToStr(), "enum", NULL}; 51 | static const char* const* const luawt_WViewWidget_render_args[] = {WViewWidget_render_args0, NULL}; 52 | 53 | int luawt_WViewWidget_render(lua_State* L) { 54 | int index = luawt_getSuitableArgsGroup(L, luawt_WViewWidget_render_args); 55 | WViewWidget* self = luawt_checkFromLua(L, 1); 56 | if (index == 0) { 57 | Wt::WFlags flags = static_cast(luawt_getEnum( 58 | L, 59 | luawt_enum_RenderFlag_str, 60 | luawt_enum_RenderFlag_val, 61 | 2, 62 | "Wrong enum type in args of WViewWidget.render" 63 | )); 64 | self->render(flags); 65 | return 0; 66 | } else { 67 | return luaL_error(L, "Wrong arguments for WViewWidget.render"); 68 | } 69 | } 70 | 71 | static const luaL_Reg luawt_WViewWidget_methods[] = { 72 | METHOD(WViewWidget, update), 73 | METHOD(WViewWidget, load), 74 | METHOD(WViewWidget, render), 75 | METHOD(WViewWidget, refresh), 76 | {NULL, NULL}, 77 | }; 78 | 79 | void luawt_WViewWidget(lua_State* L) { 80 | const char* base = luawt_typeToStr(); 81 | assert(base); 82 | DECLARE_CLASS( 83 | WViewWidget, 84 | L, 85 | 0, 86 | 0, 87 | luawt_WViewWidget_methods, 88 | base 89 | ); 90 | } 91 | -------------------------------------------------------------------------------- /src/luawt/init.cpp: -------------------------------------------------------------------------------- 1 | /* luawt, Lua bindings for Wt 2 | * Copyright (c) 2015-2017 Pavel Dolgov and Boris Nagaev 3 | * 4 | * See the LICENSE file for terms of use. 5 | */ 6 | 7 | #include "globals.hpp" 8 | 9 | typedef void (*luawt_Function)(lua_State* L); 10 | 11 | typedef struct luawt_Reg { 12 | const char* name; 13 | luawt_Function func; 14 | } luawt_Reg; 15 | 16 | #define MODULE(name) {#name, luawt_##name} 17 | static const luawt_Reg luawt_modules[] = { 18 | // Base must be before child 19 | MODULE(MyApplication), 20 | MODULE(Shared), 21 | MODULE(Test), 22 | MODULE(WEnvironment), 23 | #ifdef LUAWTEST 24 | MODULE(WTestEnvironment), 25 | #else 26 | MODULE(WServer), 27 | #endif 28 | MODULE(WWidget), 29 | MODULE(WCompositeWidget), 30 | MODULE(WPopupWidget), 31 | MODULE(WDialog), 32 | MODULE(WSuggestionPopup), 33 | MODULE(WMessageBox), 34 | MODULE(WValidationStatus), 35 | MODULE(WToolBar), 36 | MODULE(WSplitButton), 37 | MODULE(WMediaPlayer), 38 | MODULE(WCalendar), 39 | MODULE(WDatePicker), 40 | MODULE(WAbstractItemView), 41 | MODULE(WTreeNode), 42 | MODULE(WInPlaceEdit), 43 | MODULE(WVirtualImage), 44 | MODULE(WPanel), 45 | MODULE(WTabWidget), 46 | MODULE(WIconPair), 47 | MODULE(WGoogleMap), 48 | MODULE(WWebWidget), 49 | MODULE(WBreak), 50 | MODULE(WInteractWidget), 51 | MODULE(WTimerWidget), 52 | MODULE(WAbstractMedia), 53 | MODULE(WVideo), 54 | MODULE(WAudio), 55 | MODULE(WTemplate), 56 | MODULE(WTemplateFormView), 57 | MODULE(WNavigationBar), 58 | MODULE(WGLWidget), 59 | MODULE(WProgressBar), 60 | MODULE(WFlashObject), 61 | MODULE(WScrollArea), 62 | MODULE(WImage), 63 | MODULE(WText), 64 | MODULE(WDefaultLoadingIndicator), 65 | MODULE(WLabel), 66 | MODULE(WTableView), 67 | MODULE(WTreeView), 68 | MODULE(WTreeTableNode), 69 | MODULE(WMenu), 70 | MODULE(WPopupMenu), 71 | MODULE(WTreeTable), 72 | MODULE(WFileUpload), 73 | MODULE(WTree), 74 | MODULE(WContainerWidget), 75 | MODULE(WTableCell), 76 | MODULE(WMenuItem), 77 | MODULE(WFormWidget), 78 | MODULE(WLineEdit), 79 | MODULE(WDateEdit), 80 | MODULE(WComboBox), 81 | MODULE(WTextArea), 82 | MODULE(WAbstractSpinBox), 83 | MODULE(WSpinBox), 84 | MODULE(WAbstractToggleButton), 85 | MODULE(WRadioButton), 86 | MODULE(WCheckBox), 87 | MODULE(WSlider), 88 | MODULE(WSelectionBox), 89 | MODULE(WDoubleSpinBox), 90 | MODULE(WPaintedWidget), 91 | MODULE(WTable), 92 | MODULE(WTextEdit), 93 | MODULE(WViewWidget), 94 | MODULE(WAnchor), 95 | MODULE(WOverlayLoadingIndicator), 96 | MODULE(WStackedWidget), 97 | MODULE(WGroupBox), 98 | MODULE(WPushButton), 99 | {NULL, NULL}, 100 | }; 101 | #undef MODULE 102 | 103 | extern "C" { 104 | 105 | #ifdef LUAWTEST 106 | int luaopen_luawtest(lua_State* L) 107 | #else 108 | int luaopen_luawt(lua_State* L) 109 | #endif 110 | { 111 | luaL_newmetatable(L, "luawt"); // module luawt 112 | luawt_setEnumsTables(L); 113 | for (const luawt_Reg* reg = luawt_modules; reg->name; ++reg) { 114 | int stack_size1 = lua_gettop(L); 115 | reg->func(L); // must not change stack 116 | int stack_size2 = lua_gettop(L); 117 | assert(stack_size2 == stack_size1); 118 | } 119 | return 1; 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /src/luawt/shared.cpp: -------------------------------------------------------------------------------- 1 | /* luawt, Lua bindings for Wt 2 | * Copyright (c) 2015-2017 Pavel Dolgov and Boris Nagaev 3 | * 4 | * See the LICENSE file for terms of use. 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #include "boost-xtime.hpp" 11 | #include 12 | 13 | #include "globals.hpp" 14 | 15 | typedef std::string Str; 16 | typedef std::map Map; 17 | typedef Map::const_iterator It; 18 | 19 | struct ProtectedMap { 20 | Map shared; 21 | boost::mutex mtx; 22 | }; 23 | 24 | int luawt_Shared_index(lua_State* L) { 25 | ProtectedMap* pm = reinterpret_cast( 26 | luawt_getShared(L) 27 | ); 28 | boost::mutex::scoped_lock lock(pm->mtx); 29 | size_t key_len; 30 | const char* key = luaL_checklstring(L, 2, &key_len); 31 | It iterator = pm->shared.find(Str(key, key_len)); 32 | if (iterator != pm->shared.end()) { 33 | const Str& value = iterator->second; 34 | lua_pushlstring(L, value.c_str(), value.size()); 35 | } else { 36 | lua_pushnil(L); 37 | } 38 | return 1; 39 | } 40 | 41 | int luawt_Shared_newindex(lua_State* L) { 42 | ProtectedMap* pm = reinterpret_cast( 43 | luawt_getShared(L) 44 | ); 45 | boost::mutex::scoped_lock lock(pm->mtx); 46 | size_t key_len, value_len; 47 | const char* key = luaL_checklstring(L, 2, &key_len); 48 | const char* value = lua_tolstring(L, 3, &value_len); 49 | if (value == 0) { 50 | // remove key 51 | pm->shared.erase(Str(key, key_len)); 52 | } else { 53 | pm->shared[Str(key, key_len)] = Str(value, value_len); 54 | } 55 | return 0; 56 | } 57 | 58 | static const luaL_Reg luawt_shared_functions[] = { 59 | MT_METHOD(Shared, index), 60 | MT_METHOD(Shared, newindex), 61 | {NULL, NULL}, 62 | }; 63 | 64 | void luawt_Shared(lua_State* L) { 65 | lua_getfield(L, LUA_REGISTRYINDEX, "luawt_pm"); 66 | if (lua_type(L, -1) == LUA_TNIL) { 67 | // FIXME memory leak 68 | luawt_setShared(L, new ProtectedMap); 69 | } 70 | lua_pop(L, 1); // registry["luawt_pm"] 71 | luaL_getmetatable(L, "luawt"); 72 | assert(lua_type(L, -1) == LUA_TTABLE); 73 | lua_newtable(L); // Shared table 74 | lua_newtable(L); // metatable of Shared 75 | my_setfuncs(L, luawt_shared_functions); 76 | lua_setmetatable(L, -2); 77 | lua_setfield(L, -2, "Shared"); 78 | lua_pop(L, 1); // luawt 79 | } 80 | 81 | void* luawt_getShared(lua_State* L) { 82 | lua_getfield(L, LUA_REGISTRYINDEX, "luawt_pm"); 83 | if (lua_type(L, -1) != LUA_TLIGHTUSERDATA) { 84 | luaL_error(L, "registry['luawt_pm'] not initialized"); 85 | } 86 | void* out = lua_touserdata(L, -1); 87 | lua_pop(L, 1); 88 | return out; 89 | } 90 | 91 | void luawt_setShared(lua_State* L, void* pm) { 92 | lua_pushlightuserdata(L, pm); 93 | lua_setfield(L, LUA_REGISTRYINDEX, "luawt_pm"); 94 | } 95 | -------------------------------------------------------------------------------- /src/luawt/test.cpp: -------------------------------------------------------------------------------- 1 | /* luawt, Lua bindings for Wt 2 | * Copyright (c) 2015-2017 Pavel Dolgov and Boris Nagaev 3 | * 4 | * See the LICENSE file for terms of use. 5 | */ 6 | 7 | #include "globals.hpp" 8 | 9 | int luawt_Test_unknownException(lua_State* L) { 10 | int error; 11 | throw error; 12 | } 13 | 14 | static const luaL_Reg luawt_Test_functions[] = { 15 | METHOD(Test, unknownException), 16 | {NULL, NULL}, 17 | }; 18 | 19 | void luawt_Test(lua_State* L) { 20 | luaL_getmetatable(L, "luawt"); 21 | assert(lua_type(L, -1) == LUA_TTABLE); 22 | lua_newtable(L); // Test table 23 | my_setfuncs(L, luawt_Test_functions); 24 | lua_setfield(L, -2, "Test"); 25 | lua_pop(L, 1); // luawt 26 | } 27 | -------------------------------------------------------------------------------- /src/luawt/test.lua: -------------------------------------------------------------------------------- 1 | -- luawt, Lua bindings for Wt 2 | -- Copyright (c) 2015-2017 Pavel Dolgov and Boris Nagaev 3 | -- See the LICENSE file for terms of use. 4 | 5 | local test = {} 6 | 7 | function test.sizeOf(table) 8 | local count = 0 9 | for k in pairs(table) do 10 | count = count + 1 11 | end 12 | return count 13 | end 14 | 15 | function test.socketRequest(port) 16 | local http_client = require 'socket.http' 17 | local data = http_client.request('http://127.0.0.1:' .. port) 18 | return data 19 | end 20 | 21 | function test.baseConfig() 22 | local wt_config = os.tmpname() 23 | local file = io.open(wt_config, 'w') 24 | local config = [=[ 25 | 26 | 27 | 28 | true 29 | 30 | 31 | ]=] 32 | file:write(config) 33 | file:close() 34 | return wt_config 35 | end 36 | 37 | function test.createServer(code, ip, port, wt_config) 38 | local luawt = require 'luawt' 39 | local server = luawt.WServer({ 40 | code = code, 41 | ip = ip, 42 | port = port, 43 | wt_config = wt_config, 44 | }) 45 | return server 46 | end 47 | 48 | function test.getData(code) 49 | local ip = '127.0.0.1' 50 | local port = 56789 51 | local wt_config = test.baseConfig() 52 | local server = test.createServer(code, ip, port, wt_config) 53 | server:start() 54 | os.execute("sleep 1") 55 | local data = test.socketRequest(port) 56 | return server, wt_config, data 57 | end 58 | 59 | function test.clear(server, wt_config, force) 60 | os.execute("sleep 1") 61 | server:stop(force) 62 | os.remove(wt_config) 63 | end 64 | 65 | function test.baseTest(code) 66 | local luawt = require 'luawt' 67 | local server, wt_config, data = test.getData(code) 68 | local bust_assert = require 'busted'.assert 69 | bust_assert.truthy(data:match(luawt.Shared.widget_id)) -- ID should be there 70 | test.clear(server, wt_config) 71 | end 72 | 73 | function test.testWidget(name, constructor_has_arguments) 74 | local code = [[ 75 | local app, env = ... 76 | local luawt = require 'luawt' 77 | local widget = luawt.%s(%s) 78 | luawt.Shared.widget_id = widget:id() 79 | ]] 80 | test.baseTest(code:format(name, '')) 81 | if constructor_has_arguments then 82 | test.baseTest(code:format(name, 'app:root()')) 83 | end 84 | end 85 | 86 | return test 87 | -------------------------------------------------------------------------------- /tools/automate_bindings.sh: -------------------------------------------------------------------------------- 1 | ./tools/automate_bindings.py "$@" 2 | ./tools/mystyle ./src/luawt/*.cpp 3 | -------------------------------------------------------------------------------- /tools/blacklist.yaml: -------------------------------------------------------------------------------- 1 | WAbstractItemView: 2 | methods: 3 | - clearSelection 4 | - setHeaderClickSortEnabled 5 | - setObjectName 6 | - sortEnabled 7 | WAbstractSpinBox: 8 | methods: 9 | - refresh 10 | WAbstractToggleButton: 11 | methods: 12 | - refresh 13 | - setTextFormat 14 | - setWordWrap 15 | - textFormat 16 | - wordWrap 17 | WAnchor: 18 | methods: 19 | - canReceiveFocus 20 | - setFirstFocus 21 | - tabIndex 22 | WApplication: 23 | methods: 24 | - removeStyleSheet 25 | - setConnectionMonitor 26 | - waitForEvent 27 | signatures: 28 | - quit(WString) 29 | WCheckBox: 30 | methods: 31 | - isPartialStateSelectable 32 | - setPartialStateSelectable 33 | WComboBox: 34 | methods: 35 | - noSelectionEnabled 36 | - selectionMode 37 | - setNoSelectionEnabled 38 | WCompositeWidget: 39 | methods: 40 | - canReceiveFocus 41 | - hasFocus 42 | - objectName 43 | - propagateSetVisible 44 | - setCanReceiveFocus 45 | - setDeferredToolTip 46 | - setFirstFocus 47 | - setFocus 48 | - setObjectName 49 | - zIndex 50 | WDateEdit: 51 | methods: 52 | - load 53 | WDatePicker: 54 | methods: 55 | - popupWidget 56 | WDialog: 57 | methods: 58 | - raiseToFront 59 | - setAutoFocus 60 | signatures: 61 | - rejectWhenEscapePressed() 62 | - rejectWhenEscapePressed(bool) 63 | WDoubleSpinBox: 64 | methods: 65 | - refresh 66 | WFileUpload: 67 | methods: 68 | - setFilters 69 | WGLWidget: 70 | methods: 71 | - attachShader 72 | - bindAttribLocation 73 | - bindBuffer 74 | - bindFramebuffer 75 | - bindRenderbuffer 76 | - bindTexture 77 | - bufferSubData 78 | - clearBinaryResources 79 | - compileShader 80 | - createAndLoadArrayBuffer 81 | - createBuffer 82 | - createFramebuffer 83 | - createProgram 84 | - createRenderbuffer 85 | - createShader 86 | - createTexture 87 | - createTextureAndLoad 88 | - deleteBuffer 89 | - deleteFramebuffer 90 | - deleteProgram 91 | - deleteRenderbuffer 92 | - deleteShader 93 | - deleteTexture 94 | - detachShader 95 | - disableVertexAttribArray 96 | - enableVertexAttribArray 97 | - framebufferRenderbuffer 98 | - framebufferTexture2D 99 | - getAttribLocation 100 | - getUniformLocation 101 | - initializeGL 102 | - linkProgram 103 | - paintGL 104 | - resizeGL 105 | - restoringContext 106 | - setClientSideMouseHandler 107 | - setRenderOptions 108 | - shaderSource 109 | - uniform1f 110 | - uniform1i 111 | - uniform2f 112 | - uniform2i 113 | - uniform3f 114 | - uniform3i 115 | - uniform4f 116 | - uniform4i 117 | - updateGL 118 | - useProgram 119 | - validateProgram 120 | - vertexAttrib1f 121 | - vertexAttrib2f 122 | - vertexAttrib3f 123 | - vertexAttrib4f 124 | - vertexAttribPointer 125 | - webglNotAvailable 126 | signatures: 127 | - bufferData(WGLWidget::GLenum,::std::string,WGLWidget::GLenum) 128 | - bufferData(WGLWidget::GLenum,::std::string,unsignedint,unsignedint,WGLWidget::GLenum) 129 | WIcon: 130 | whole class: true 131 | WInPlaceEdit: 132 | methods: 133 | - placeholderText 134 | - setPlaceholderText 135 | signatures: 136 | - WInPlaceEdit(WContainerWidget*) 137 | - WInPlaceEdit(bool,WString,WContainerWidget*) 138 | WMediaPlayer: 139 | methods: 140 | - refresh 141 | WMessageBox: 142 | methods: 143 | - buttons 144 | - defaultButton 145 | - escapeButton 146 | - iconImage 147 | - setDefaultButton 148 | - setEscapeButton 149 | - setStandardButtons 150 | - standardButtons 151 | signatures: 152 | - addButton(StandardButton) 153 | - addButton(WPushButton*,StandardButton) 154 | WMenu: 155 | signatures: 156 | - addItem(WMenuItem*) 157 | - insertItem(int,WMenuItem*) 158 | WSuggestionPopup: 159 | methods: 160 | - currentItem 161 | - editRole 162 | - setDropDownIconUnfiltered 163 | - setEditRole 164 | WTabWidget: 165 | methods: 166 | - setOverflow 167 | WTableCell: 168 | methods: 169 | - WTableCell 170 | - isVisible 171 | WTableView: 172 | methods: 173 | - scrollTo 174 | - setOverflow 175 | WTemplate: 176 | methods: 177 | - encodeTemplateText 178 | - getErrorText 179 | - setEncodeTemplateText 180 | - setWidgetIdMode 181 | - varName 182 | - widgetIdMode 183 | WText: 184 | methods: 185 | - setTextAlignment 186 | - textAlignment 187 | WTextEdit: 188 | methods: 189 | - propagateSetEnabled 190 | - setPlaceholderText 191 | - setReadOnly 192 | - version 193 | WTimeEdit: 194 | whole class: true 195 | WTimePicker: 196 | whole class: true 197 | WToolBar: 198 | methods: 199 | - addWidget 200 | - removeWidget 201 | - setOrientation 202 | signatures: 203 | - addButton(WPushButton*) 204 | - addButton(WPushButton*,AlignmentFlag) 205 | - addButton(WSplitButton*) 206 | - addButton(WSplitButton*,AlignmentFlag) 207 | WWidget: 208 | methods: 209 | - canReceiveFocus 210 | - hasFocus 211 | - isExposed 212 | - setCanReceiveFocus 213 | - setDeferredToolTip 214 | - setFirstFocus 215 | - setFocus 216 | - setObjectName 217 | - zIndex 218 | 219 | -------------------------------------------------------------------------------- /tools/blacklist_test.yaml: -------------------------------------------------------------------------------- 1 | WText: 2 | methods: 3 | - mouseWentDown 4 | signatures: 5 | - WText(WString,WContainerWidget*) 6 | -------------------------------------------------------------------------------- /tools/gen-docs.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local luawt = require 'luawt' 4 | 5 | local non_abstract = {} 6 | for k in pairs(luawt) do 7 | if k:sub(1, 1) == 'W' or k == 'MyApplication' then 8 | non_abstract[k] = true 9 | end 10 | end 11 | 12 | local reg = debug.getregistry() 13 | local classes = {} 14 | for k in pairs(reg) do 15 | local demangled = k:match('^2Wt%d+(.+)E$') 16 | if demangled then 17 | table.insert(classes, demangled) 18 | end 19 | end 20 | table.insert(classes, 'luawt_WServer') 21 | table.insert(classes, 'MyApplication') 22 | table.sort(classes) 23 | 24 | print('# List of Wt classes bound to luawt') 25 | 26 | for _, c in ipairs(classes) do 27 | local module_name = c 28 | if c == 'luawt_WServer' then 29 | module_name = 'WServer' 30 | elseif c == 'MyApplication' then 31 | module_name = 'WApplication' 32 | end 33 | local url = ( 34 | "https://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1%s.html" 35 | ):format(module_name) 36 | local typ = '' 37 | if not non_abstract[c] then 38 | typ = ' (abstract)' 39 | end 40 | print((' * [%s](%s)%s'):format(c, url, typ)) 41 | local mangled = ('2Wt%d%sE'):format(#c, c) 42 | if c == 'luawt_WServer' then 43 | mangled = 'luawt_WServer' 44 | elseif c == 'MyApplication' then 45 | mangled = '3MyApplication' 46 | end 47 | local mt = reg[mangled] 48 | if mt ~= nil then 49 | local methods = {} 50 | for m in pairs(mt.__index) do 51 | table.insert(methods, m) 52 | end 53 | table.sort(methods) 54 | for _, m in ipairs(methods) do 55 | print((' * %s'):format(m)) 56 | end 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /tools/mystyle: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | files=$@ 3 | if [[ $files == "" ]] ; then 4 | files="`find * -name '*.?pp'` `find * -name '*.?xx'`" 5 | fi 6 | 7 | astyle --style=java --add-brackets --lineend=linux --align-pointer=type \ 8 | --delete-empty-lines --convert-tabs --pad-header --pad-oper --unpad-paren \ 9 | --indent-col1-comments \ 10 | --indent-after-parens \ 11 | --indent-continuation=1 \ 12 | --quiet $files 13 | 14 | # add empty line after each function or class 15 | sed '/^};\?$/,+1s/^\([^}#].\+\)/\n\1/' -i $files 16 | 17 | # remove double empty lines 18 | sed '/^$/N;/^\n$/D' -i $files 19 | 20 | # remove empty line (after }) before \endcode (doxygen examples) 21 | sed ':begin;$!N;s@^\n\\endcode@\\endcode@;tbegin;P;D' -i $files 22 | 23 | # FOREACH (void * p, b) --> FOREACH (void* p, b) 24 | sed '/\(FOREACH\)/s/\(\w\) \([*&]\)/\1\2/' -i $files 25 | sed '/^\(\s*foreach\)/s/\(\w\) \([*&]\)/\1\2/' -i $files 26 | 27 | # FOREACH(a, b) --> FOREACH (a, b) 28 | sed '/define/!s/\(FOREACH\)(/\1 (/' -i $files 29 | sed '/define/!s/^\(\s*foreach\)(/\1 (/' -i $files 30 | 31 | # BOOST_AUTO_TEST_CASE(test) --> BOOST_AUTO_TEST_CASE (test) 32 | sed '/define/!s/\(^\s*[A-Z0-9_]\+\)(\(.\+\)) {$/\1 (\2) {/' -i $files 33 | 34 | # remove extra space before ; 35 | sed 's@ ;@;@g' -i $files 36 | 37 | # remove double spaces 38 | sed '/\/!s@\> \<@ @g' -i $files 39 | 40 | # append new line to the last line 41 | #sed '$s@\(.\+\)@\1\n@g' -i $files 42 | # remove new line after the last line 43 | #sed '${/^$/D}' -i $files 44 | 45 | # fix indentation of "for (int a : b)" 46 | sed ':begin;$!N;s@^\(\s\+\)\([^\n]\+\)\nfor@\1\2\n\1for@;tbegin;P;D' -i $files 47 | 48 | # #include -> #include 49 | sed 's/^#include