├── .gitignore ├── CMakeLists.txt ├── COPYING ├── CREDITS ├── ChangeLog ├── README ├── README.md ├── cmake └── modules │ ├── FindPHP5.cmake │ ├── FindQScintilla.cmake │ ├── FindQt4.cmake │ ├── FindQwt.cmake │ ├── FindQwt5.cmake │ └── MacroPushRequiredVars.cmake ├── examples └── calculator │ ├── button.php │ ├── calculator.php │ └── main.php ├── kalyptus ├── Ast.pm ├── ChangeLog ├── Iter.pm ├── Makefile.cvs ├── Makefile.in ├── README ├── TODO ├── Version ├── dcopidlng ├── findperl ├── install-sh ├── kalyptus ├── kalyptusCxxToCSharp.pm ├── kalyptusCxxToECMA.pm ├── kalyptusCxxToKimono.pm ├── kalyptusCxxToSmoke.pm ├── kalyptusCxxToSwig.pm ├── kalyptusDataDict.pm ├── kdocAstUtil.pm ├── kdocLib.pm ├── kdocParseDoc.pm ├── kdocUtil.pm └── perlbin ├── smoke ├── CMakeLists.txt ├── README ├── kde │ ├── CMakeLists.txt │ ├── generate.pl.cmake │ ├── generate.pl.in │ ├── generate_makefile_am.pl │ ├── header_list │ ├── hint_header_list.pl │ ├── kde_header_list │ ├── qt_smoke.h │ └── qtguess.pl.cmake ├── plasma │ ├── CMakeLists.txt │ ├── generate.pl.cmake │ ├── generate_makefile_am.pl │ ├── header_list │ ├── hint_header_list.pl │ ├── plasma_header_list │ ├── qt_smoke.h │ └── qtguess.pl.cmake ├── qt │ ├── CMakeLists.txt │ ├── configure.in.in │ ├── generate.pl.cmake │ ├── generate.pl.in │ ├── generate_makefile_am.pl │ ├── header_list │ ├── hint_header_list.pl │ ├── qscintilla2_header_list │ ├── qscintilla_header_list │ ├── qt_smoke.h │ ├── qtguess.pl.cmake │ ├── qwt_header_list │ └── smokeqt.pro └── smoke.h ├── src ├── CMakeLists.txt ├── context.cpp ├── context.h ├── functions.cpp ├── handlers.cpp ├── marshall.h ├── marshall_basetypes.h ├── marshall_primitives.h ├── marshall_types.cpp ├── marshall_types.h ├── php_qt.cpp ├── php_qt.h ├── phpqt_internals.cpp ├── phpqt_internals.h ├── qstring.cpp ├── qstring.h ├── smokephp.cpp ├── smokephp.h ├── zend_handlers.cpp └── zend_handlers.h ├── tests ├── QStringTestCase.php ├── QtAdvancedTestCase.php ├── QtApplicationTestCase.php ├── QtBasicTestCase.php ├── QtLoadModuleTestCase.php ├── QtStressTestCase.php ├── box2buttons.php ├── designer.php ├── phpqt_from_scratch.sh ├── qFunctions.php ├── unicode.php └── unicode.xml ├── tools ├── CMakeLists.txt └── uic │ ├── CMakeLists.txt │ ├── customwidgetsinfo.cpp │ ├── customwidgetsinfo.h │ ├── databaseinfo.cpp │ ├── databaseinfo.h │ ├── driver.cpp │ ├── driver.h │ ├── globaldefs.h │ ├── main.cpp │ ├── option.h │ ├── php │ ├── phpextractimages.cpp │ ├── phpextractimages.h │ ├── phpwritedeclaration.cpp │ ├── phpwritedeclaration.h │ ├── phpwriteicondata.cpp │ ├── phpwriteicondata.h │ ├── phpwriteicondeclaration.cpp │ ├── phpwriteicondeclaration.h │ ├── phpwriteiconinitialization.cpp │ ├── phpwriteiconinitialization.h │ ├── phpwriteincludes.cpp │ ├── phpwriteincludes.h │ ├── phpwriteinitialization.cpp │ └── phpwriteinitialization.h │ ├── qclass_lib_map.h │ ├── treewalker.cpp │ ├── treewalker.h │ ├── ui4.cpp │ ├── ui4.h │ ├── uic.cpp │ ├── uic.h │ ├── uic.pri │ ├── uic.pro │ ├── utils.h │ ├── validator.cpp │ └── validator.h └── tutorials ├── t1 └── main.php ├── t10 ├── cannonfield.php ├── lcdrange.php └── main.php ├── t11 ├── cannonfield.php ├── lcdrange.php └── main.php ├── t2 └── main.php ├── t3 └── main.php ├── t4 └── main.php ├── t5 └── main.php ├── t6 └── main.php ├── t7 └── main.php ├── t8 ├── cannonfield.php ├── lcdrange.php └── main.php └── t9 ├── cannonfield.php ├── lcdrange.php └── main.php /.gitignore: -------------------------------------------------------------------------------- 1 | build/* -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | PROJECT(PHP-Qt) 3 | 4 | set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) 5 | set(kdebindings_SOURCE_DIR ${PHP-Qt_SOURCE_DIR}) 6 | 7 | 8 | find_package(Perl REQUIRED) # for kalyptus 9 | find_package(Qt4 REQUIRED) # for kalyptus 10 | 11 | INCLUDE_DIRECTORIES (${QT_INCLUDES}) 12 | 13 | include(FindPHP5) 14 | 15 | IF(NOT PHP5_FOUND) 16 | MESSAGE(FATAL_ERROR "PHP5 could not be found!") 17 | ENDIF(NOT PHP5_FOUND) 18 | 19 | OPTION(ENABLE_SMOKEKDE "build SmokeKDE" OFF) 20 | OPTION(ENABLE_SMOKEPLASMA "build SmokePLASMA" OFF) 21 | add_subdirectory(smoke) 22 | add_subdirectory(src) 23 | add_subdirectory(tests) 24 | add_subdirectory(tools) 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Licensing 2 | =============== 3 | 4 | PHP-Qt licensing is dependent upon the license of the dynamically linked Qt library. 5 | In the case that the linked Qt library is Qt Open Source Edition, PHP-Qt is licensed under the terms of the GNU General Public License version 2. 6 | 7 | You may write commercial, proprietary, or otherwise non-free software only if you have purchased a commercial edition of Qt. 8 | Purchase of a commercial edition of Qt, however, does not entitle you to support (technical or otherwise) for PHP-Qt of any kind. 9 | Additionally the following conditions apply to PHP-Qt when linked against Qt Commercial Edition: 10 | 11 | 1. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 12 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 13 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 14 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 15 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 17 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 18 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 19 | REPAIR OR CORRECTION. 20 | 21 | 2. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 22 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 23 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 24 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 25 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 26 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 27 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 28 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 29 | POSSIBILITY OF SUCH DAMAGES. 30 | 31 | 3. By linking PHP-Qt against Qt Commercial Edition you indicate your acceptance of 32 | these conditions. 33 | 34 | If you want to develop Free or Open Source software for release under the GPL, 35 | you can link against the Qt Open Source Edition. 36 | 37 | Please note that PHP-Qt is dynamically linked against the Qt library and 38 | Qt header files are necessary for building PHP-Qt. 39 | 40 | More information can be found here: 41 | Qt licensing: http://www.trolltech.com/products/qt/licenses/licensing/ 42 | Qt Open Source Edition: http://www.trolltech.com/download/opensource.html 43 | GPL License: http://www.gnu.org/licenses/gpl.html 44 | 45 | 46 | Trademarks 47 | ========== 48 | 49 | Qt is a trademark of Trolltech. 50 | 51 | -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- 1 | php_qt 2 | ============================================== 3 | Thomas Moenicke 4 | main developer, maintainer 5 | 6 | contributors 7 | Katrina Niolet 8 | Jean-Luc Gyger 9 | Ferenc Veres 10 | 11 | parts of PHP-Qt are derived from the QtRuby sources, written by: 12 | Richard Dale 13 | 14 | which is a ruby version of the PerlQt/Smoke project, written by: 15 | Ashley Winters 16 | Germain Garand 17 | David Faure 18 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2007-012-10 Thomas Moenicke 2 | * added layout support for user interface compiler 3 | 4 | 2007-012-09 Thomas Moenicke 5 | * ported to MacOS (Leopard) 6 | 7 | 2007-009-23 Thomas Moenicke 8 | * implemented handler of method '__clone' 9 | * unittests for references and copies of objects 10 | 11 | 2007-009-23 Thomas Moenicke 12 | * ownership of objects belong to the script when created by it 13 | 14 | 2007-009-22 Thomas Moenicke 15 | * wrote tutorial 11 16 | 17 | 2007-009-22 Thomas Moenicke 18 | * improved calling of ambiguous methods 19 | 20 | 2007-009-14 Thomas Moenicke 21 | * added a well-defined context for threads 22 | 23 | 2007-009-14 Thomas Moenicke 24 | * wrote tutorial 10 25 | 26 | 2007-009-12 Thomas Moenicke 27 | * code for metaobjects refactored 28 | 29 | 2007-009-09 Thomas Moenicke 30 | * automatic conversion of double into long and opposite 31 | 32 | 2007-009-08 Thomas Moenicke 33 | * wrote tutorial 9 34 | 35 | 2007-009-08 Thomas Moenicke 36 | * fixed scope of member variables 37 | 38 | 2007-009-07 Thomas Moenicke 39 | * allocating more memory for marshalling 'double' 40 | 41 | 2007-009-03 Thomas Moenicke 42 | * code for calling slots refactored 43 | 44 | 2007-008-31 Thomas Moenicke 45 | * implemented user interface compiler for PHP 46 | 47 | 2007-008-31 Thomas Moenicke 48 | * QString::fromUtf8() 49 | 50 | 2007-008-27 Thomas Moenicke 51 | * implemented arguments for custom signals which now can be connected to any Qt or custom slots 52 | 53 | 2007-007-12 Katrina Niolet 54 | 55 | * Updated installation instructions to include step by step proccess for building outside of the source tree 56 | 57 | 2007-007-12 Thomas Moenicke 58 | 59 | * virtual method calls improved (memory issues) 60 | * internally re-organized 61 | * references improved 62 | 63 | 2007-005-20 Thomas Moenicke 64 | 65 | * mapping of zend object instead of zval 66 | 67 | 2007-003-22 Thomas Moenicke 68 | 69 | * call of virtual methods 70 | 71 | 2007-003-22 Thomas Moenicke 72 | 73 | * call of overwritten protected methods 74 | 75 | 2007-003-22 Thomas Moenicke 76 | 77 | * signal handler added 78 | 79 | 2007-003-21 Thomas Moenicke 80 | 81 | * object oriented handlers (see QtRuby) 82 | 83 | 2007-003-4 Thomas Moenicke 84 | 85 | * Debugging for metaobject system added 86 | * parent_ce_ptr 87 | 88 | 2007-003-4 Thomas Moenicke 89 | 90 | * handling of QString - string in return and argument types 91 | * more tests added 92 | 93 | 2007-002-27 Thomas Moenicke 94 | 95 | * implemented constantHandler which fetchs constants from Qt 96 | * registered QString 97 | * improved inheritance 98 | * added unittests 99 | 100 | 2007-002-25 Thomas Moenicke 101 | 102 | * replaced the :: operator 103 | * cached the class_entry table 104 | 105 | 2007-002-19 Thomas Moenicke 106 | 107 | * new cmake build system added 108 | * implemented QString since it is not in Smoke 109 | * Updated copies of smoke and kalyptus 110 | 111 | 2006-011-18 Thomas Moenicke 112 | 113 | * method argument handling: support for arrays, references 114 | * some enums added 115 | * internal function check_function 116 | * fixed some minor bugs 117 | 118 | 2006-011-7 Thomas Moenicke 119 | 120 | * function tr() implemented 121 | 122 | 2006-011-5 Thomas Moenicke 123 | 124 | * Code rewritten and ported to kdebindings::Smoke 125 | * all classes and methods are supported with basic argument types and classes 126 | * enum values are like eg Qt::Horizontal instead of QT_ALIGNMENT_HORIZONTAL 127 | * License: GPL 128 | * PHP-Qt objects are casted automatically 129 | * QMetaObjects are created in class constructor and related pointers are stored in a hash table 130 | 131 | 2006-06-08 Thomas Moenicke (v.0.0.3) "Lilli" 132 | 133 | * tutorial 7 and an example application 134 | * automatically conversion of PHP strings into QStrings in method calls 135 | * function 'qobject_cast' implemented 136 | * handling of all allowed arguments in methods, with fast lookup table for inheritance 137 | * Signals-Slots and custom Signals-Slots implemented 138 | * better error handling for debugging 139 | * #ifdef statements to exclude unimplemented classes to compile safely 140 | * kalyptus extension rewritten 141 | 142 | 2006-01-23 Thomas Moenicke (v.0.0.2) "Fridolin" 143 | 144 | * a lot of new classes added 145 | * kalyptus extension written 146 | * multiple inheritance added 147 | * method overloading added 148 | * tutorials (1-6) added 149 | * UTF-8/UTF-16 support prepared 150 | * objects are stored in a way that ensures safety 151 | 152 | 2005-11-06 Thomas Moenicke (v.0.0.1) 153 | 154 | * initial import 155 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | PHP-Qt - an extension for PHP5 that enables the writing of PHP software using 2 | the Qt Toolkit. 3 | ================================================================================ 4 | 5 | PHP-Qt is an extension for PHP5 that provides an object-oriented interface to 6 | the Qt4 Framework and allows 7 | one to write Qt applications in the PHP language. 8 | 9 | Requirements 10 | ============ 11 | 12 | PHP 5.1 or greater (5.2 or greater is recommended) 13 | PHP header files and the development scripts 14 | (package may be called php-devel) 15 | 16 | Qt4 header files 17 | (package may be called qt4-devel) 18 | 19 | CMake 20 | 21 | Note: at this time compilation has only been tested in a Unix environment. 22 | 23 | Compiling and installation 24 | ========================== 25 | 26 | Both of these methods will compile and install PHP-Qt as a module. 27 | 28 | The quick and easy way: 29 | 30 | 1) change to the directory where you placed the php-qt sources 31 | 2) create a directory here named 'build' and change into it 32 | 3) run 'cmake ..' (see Troubleshooting below if you have more than one 33 | version of Qt installed or you get errors here) 34 | 4) run 'make' 35 | 5) run 'make install' 36 | 6) run 'ldconfig' 37 | 7) add the line 'extension=php_qt.so' to your php.ini 38 | 39 | 40 | The more detailed way: 41 | 42 | First make sure CMake, your PHP header files, and your Qt header files are 43 | installed. 44 | Then, get PHP-Qt either by downloading or checking out from SVN and placing it 45 | into its own directory. 46 | 47 | Next it is necessary to create your build environment for compiling. 48 | To do this, just change into the directory where you placed PHP-Qt and 49 | create a directory named 'build' 50 | run: 51 | 52 | cmake .. 53 | 54 | If needed you can give arguments to CMake via the -D option, such as: 55 |   -DQT_INCLUDE_DIR=/usr/lib/qt4/include 56 |   -DQT_LIBRARY_DIR=/usr/lib/qt4 57 |   -DQT_QMAKE_EXECUTABLE=/usr/lib/qt4/bin/qmake 58 |   59 | If no arguments are given, CMake will try to find the Qt4 and PHP5 files in 60 | the default or standard paths such as /usr/include, /usr/local/include etc. 61 | 62 | Next, run: 63 | 64 | make 65 | 66 | to build the extension. If the compilation is successful run: 67 | 68 | make install 69 | 70 | to copy 'php_qt.so' into php's extension directory. If it fails please check 71 | if you have permissions and all related paths on your system are correct. 72 | 73 | To update the cache of the run-time linker run: 74 | 75 | ldconfig 76 | 77 | so that the shared libraries will be found when starting PHP. 78 | 79 | Edit your php.ini configuration file and add the line: 80 | 81 | extension=php_qt.so 82 | 83 | to enable the extension. 84 | 85 | You can test whether your installation was successful by executing: 86 | 87 | php -i | grep -i qt 88 | 89 | You should get an output like this: 90 | 91 | php_qt 92 | PHP-Qt support => enabled 93 | qt.codec => UTF8 => UTF8 94 | 95 | To remove old objectfiles run: 96 | 97 | make clean 98 | 99 | To test it, simply run one of the test scripts in the php_qt/test/ 100 | subdirectory. 101 | 102 | Troubleshooting 103 | =================================== 104 | 105 | If you get the following error: 106 | CMake Error: Could NOT find QtCore. 107 | 108 | Try running cmake as: 109 | cmake ..  -DQT_QMAKE_EXECUTABLE=/usr/lib/qt4/bin/qmake 110 | (you may need to replace the /usr/lib/qt4/bin/qmake if yours is in another 111 | place) 112 | 113 | For other problems try checking CMakeFiles/CMakeError.log for more details. 114 | 115 | Hint: enable debugging with 116 | cmake .. -DCMAKE_BUILD_TYPE=debug 117 | 118 | Mailing lists 119 | ============= 120 | 121 | user discussion 122 | ----------------- 123 | users mailing list 124 | 125 | address:      php-qt-users@lists.sourceforge.net 126 | Subscription: https://lists.sourceforge.net/lists/listinfo/php-qt-users 127 | Archive:      http://sourceforge.net/mailarchive/forum.php?forum=php-qt-users 128 | 129 | Website 130 | ======= 131 | 132 | The website for the project: 133 | 134 |     http://www.php-qt.org 135 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Readme 2 | ====== 3 | 4 | This is just a clone of php-qt, originally hosted here: http://php-qt.berlios.de/ 5 | 6 | The project looks abandoned so i'm trying to make it work again, at the moment it doesn't compile on QT 5.0 7 | 8 | 9 | === 10 | PHP-Qt - an extension for PHP5 that enables the writing of PHP software using the Qt Toolkit. 11 | === 12 | 13 | ================================================================================ 14 | 15 | PHP-Qt is an extension for PHP5 that provides an object-oriented interface to 16 | the Qt4 Framework and allows 17 | one to write Qt applications in the PHP language. 18 | 19 | Requirements 20 | ============ 21 | 22 | PHP 5.1 or greater (5.2 or greater is recommended) 23 | PHP header files and the development scripts 24 | (package may be called php-devel) 25 | 26 | Qt4 header files 27 | (package may be called qt4-devel) 28 | 29 | CMake 30 | 31 | Note: at this time compilation has only been tested in a Unix environment. 32 | 33 | Compiling and installation 34 | ========================== 35 | 36 | Both of these methods will compile and install PHP-Qt as a module. 37 | 38 | The quick and easy way: 39 | 40 | 1) change to the directory where you placed the php-qt sources 41 | 2) create a directory here named 'build' and change into it 42 | 3) run 'cmake ..' (see Troubleshooting below if you have more than one 43 | version of Qt installed or you get errors here) 44 | 4) run 'make' 45 | 5) run 'make install' 46 | 6) run 'ldconfig' 47 | 7) add the line 'extension=php_qt.so' to your php.ini 48 | 49 | 50 | The more detailed way: 51 | 52 | First make sure CMake, your PHP header files, and your Qt header files are 53 | installed. 54 | Then, get PHP-Qt either by downloading or checking out from SVN and placing it 55 | into its own directory. 56 | 57 | Next it is necessary to create your build environment for compiling. 58 | To do this, just change into the directory where you placed PHP-Qt and 59 | create a directory named 'build' 60 | run: 61 | 62 | cmake .. 63 | 64 | If needed you can give arguments to CMake via the -D option, such as: 65 |   -DQT_INCLUDE_DIR=/usr/lib/qt4/include 66 |   -DQT_LIBRARY_DIR=/usr/lib/qt4 67 |   -DQT_QMAKE_EXECUTABLE=/usr/lib/qt4/bin/qmake 68 |   69 | If no arguments are given, CMake will try to find the Qt4 and PHP5 files in 70 | the default or standard paths such as /usr/include, /usr/local/include etc. 71 | 72 | Next, run: 73 | 74 | make 75 | 76 | to build the extension. If the compilation is successful run: 77 | 78 | make install 79 | 80 | to copy 'php_qt.so' into php's extension directory. If it fails please check 81 | if you have permissions and all related paths on your system are correct. 82 | 83 | To update the cache of the run-time linker run: 84 | 85 | ldconfig 86 | 87 | so that the shared libraries will be found when starting PHP. 88 | 89 | Edit your php.ini configuration file and add the line: 90 | 91 | extension=php_qt.so 92 | 93 | to enable the extension. 94 | 95 | You can test whether your installation was successful by executing: 96 | 97 | php -i | grep -i qt 98 | 99 | You should get an output like this: 100 | 101 | php_qt 102 | PHP-Qt support => enabled 103 | qt.codec => UTF8 => UTF8 104 | 105 | To remove old objectfiles run: 106 | 107 | make clean 108 | 109 | To test it, simply run one of the test scripts in the php_qt/test/ 110 | subdirectory. 111 | 112 | Troubleshooting 113 | =================================== 114 | 115 | If you get the following error: 116 | CMake Error: Could NOT find QtCore. 117 | 118 | Try running cmake as: 119 | cmake ..  -DQT_QMAKE_EXECUTABLE=/usr/lib/qt4/bin/qmake 120 | (you may need to replace the /usr/lib/qt4/bin/qmake if yours is in another 121 | place) 122 | 123 | For other problems try checking CMakeFiles/CMakeError.log for more details. 124 | 125 | Hint: enable debugging with 126 | cmake .. -DCMAKE_BUILD_TYPE=debug 127 | 128 | Mailing lists 129 | ============= 130 | 131 | user discussion 132 | ----------------- 133 | users mailing list 134 | 135 | address:      php-qt-users@lists.sourceforge.net 136 | Subscription: https://lists.sourceforge.net/lists/listinfo/php-qt-users 137 | Archive:      http://sourceforge.net/mailarchive/forum.php?forum=php-qt-users 138 | 139 | Website 140 | ======= 141 | 142 | The website for the project: 143 | 144 |     http://www.php-qt.org 145 | -------------------------------------------------------------------------------- /cmake/modules/FindPHP5.cmake: -------------------------------------------------------------------------------- 1 | # - Find PHP5 2 | # This module finds if PHP5 is installed and determines where the include files 3 | # and libraries are. It also determines what the name of the library is. This 4 | # code sets the following variables: 5 | # 6 | # PHP5_INCLUDE_PATH = path to where php.h can be found 7 | # PHP5_EXECUTABLE = full path to the php4 binary 8 | # 9 | # file is derived from FindPHP4.cmake 10 | # 11 | 12 | SET(PHP5_FOUND "NO") 13 | 14 | SET(PHP5_POSSIBLE_INCLUDE_PATHS 15 | /usr/include/php5 16 | /usr/local/include/php5 17 | /usr/include/php 18 | /usr/local/include/php 19 | /usr/local/apache/php 20 | ) 21 | 22 | SET(PHP5_POSSIBLE_LIB_PATHS 23 | /usr/lib 24 | ) 25 | 26 | #FIND_PATH(PHP5_FOUND_INCLUDE_PATH main/php.h 27 | # ${PHP5_POSSIBLE_INCLUDE_PATHS}) 28 | # 29 | #IF(PHP5_FOUND_INCLUDE_PATH) 30 | # SET(php5_paths "${PHP5_POSSIBLE_INCLUDE_PATHS}") 31 | # FOREACH(php5_path Zend main TSRM) 32 | # SET(php5_paths ${php5_paths} "${PHP5_FOUND_INCLUDE_PATH}/${php5_path}") 33 | # ENDFOREACH(php5_path Zend main TSRM) 34 | # SET(PHP5_INCLUDE_PATH "${php5_paths}" INTERNAL "PHP5 include paths") 35 | #ENDIF(PHP5_FOUND_INCLUDE_PATH) 36 | 37 | FIND_PROGRAM(PHP5_EXECUTABLE 38 | NAMES php5 php 39 | PATHS 40 | /usr/bin 41 | /usr/local/bin 42 | ) 43 | 44 | MARK_AS_ADVANCED( 45 | PHP5_EXECUTABLE 46 | PHP5_FOUND_INCLUDE_PATH 47 | ) 48 | 49 | IF(APPLE) 50 | # this is a hack for now 51 | SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS 52 | "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -Wl,-flat_namespace") 53 | FOREACH(symbol 54 | __efree 55 | __emalloc 56 | __estrdup 57 | __object_init_ex 58 | __zend_get_parameters_array_ex 59 | __zend_list_find 60 | __zval_copy_ctor 61 | _add_property_zval_ex 62 | _alloc_globals 63 | _compiler_globals 64 | _convert_to_double 65 | _convert_to_long 66 | _zend_error 67 | _zend_hash_find 68 | _zend_register_internal_class_ex 69 | _zend_register_list_destructors_ex 70 | _zend_register_resource 71 | _zend_rsrc_list_get_rsrc_type 72 | _zend_wrong_param_count 73 | _zval_used_for_init 74 | _zend_register_list_destructors_ex 75 | _zend_hash_exists 76 | __zend_hash_init_ex 77 | _php_info_print_table_header 78 | _zend_hash_destroy 79 | __ecalloc 80 | _zend_parse_parameters 81 | _php_sprintf 82 | _php_info_print_table_start 83 | _zend_hash_apply_with_arguments 84 | __estrndup 85 | _zend_fetch_class 86 | _zend_register_internal_class 87 | _zend_objects_get_address 88 | _zend_get_std_object_handlers 89 | _zend_read_property 90 | _zend_register_ini_entries 91 | __erealloc 92 | _zend_hash_internal_pointer_reset_ex 93 | _convert_to_null 94 | __convert_to_string 95 | _php_info_print_table_end 96 | _executor_globals 97 | __safe_emalloc 98 | _zend_str_tolower_copy 99 | __zval_copy_ctor_func 100 | _zend_hash_get_current_key_ex 101 | _zend_hash_num_elements 102 | _display_ini_entries 103 | _zend_ini_string 104 | _zval_update_constant 105 | _zend_do_inheritance 106 | __zval_ptr_dtor 107 | _zend_opcode_handlers 108 | _zval_add_ref 109 | _zend_hash_get_current_data_ex 110 | _zend_get_class_entry 111 | _zend_hash_move_forward_ex 112 | _zend_hash_get_current_key_type_ex 113 | _call_user_function 114 | ) 115 | SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS 116 | "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS},-U,${symbol}") 117 | ENDFOREACH(symbol) 118 | ENDIF(APPLE) 119 | 120 | 121 | FIND_PROGRAM(PHP5_CONFIG_EXECUTABLE 122 | NAMES php5-config php-config 123 | ) 124 | 125 | EXECUTE_PROCESS(COMMAND ${PHP5_CONFIG_EXECUTABLE} --version 126 | OUTPUT_VARIABLE PHP5_VERSION) 127 | 128 | EXECUTE_PROCESS(COMMAND ${PHP5_CONFIG_EXECUTABLE} --extension-dir 129 | OUTPUT_VARIABLE PHP5_EXTENSION_DIR) 130 | STRING(REPLACE "\n" "" PHP5_EXTENSION_DIR "${PHP5_EXTENSION_DIR}") 131 | 132 | EXECUTE_PROCESS(COMMAND ${PHP5_CONFIG_EXECUTABLE} --includes 133 | OUTPUT_VARIABLE PHP5_INCLUDES) 134 | STRING(REPLACE "-I" ";" PHP5_INCLUDES "${PHP5_INCLUDES}") 135 | STRING(REPLACE " " "" PHP5_INCLUDES "${PHP5_INCLUDES}") 136 | LIST(GET PHP5_INCLUDES 0 PHP5_INCLUDE_DIR) 137 | 138 | set(PHP5_MAIN_INCLUDE_DIR ${PHP5_INCLUDE_DIR}/main) 139 | set(PHP5_TSRM_INCLUDE_DIR ${PHP5_INCLUDE_DIR}/TSRM) 140 | set(PHP5_ZEND_INCLUDE_DIR ${PHP5_INCLUDE_DIR}/Zend) 141 | set(PHP5_REGEX_INCLUDE_DIR ${PHP5_INCLUDE_DIR}/regex) 142 | set(PHP5_EXT_INCLUDE_DIR ${PHP5_INCLUDE_DIR}/ext) 143 | set(PHP5_DATE_INCLUDE_DIR ${PHP5_INCLUDE_DIR}/ext/date/lib) 144 | set(PHP5_STANDARD_INCLUDE_DIR ${PHP5_INCLUDE_DIR}/ext/standard) 145 | 146 | MESSAGE(STATUS ${PHP5_MAIN_INCLUDE_DIR}) 147 | 148 | IF(PHP5_VERSION LESS 5) 149 | MESSAGE(FATAL_ERROR "PHP version is not 5 or later") 150 | ENDIF(PHP5_VERSION LESS 5) 151 | 152 | IF(PHP5_EXECUTABLE AND PHP5_INCLUDES) 153 | set(PHP5_FOUND "yes") 154 | MESSAGE(STATUS "Found PHP5-Version ${PHP5_VERSION}") 155 | ENDIF(PHP5_EXECUTABLE AND PHP5_INCLUDES) 156 | 157 | -------------------------------------------------------------------------------- /cmake/modules/FindQScintilla.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find the QScintilla2 includes and library 2 | # which defines 3 | # 4 | # QSCINTILLA_FOUND - system has QScintilla2 5 | # QSCINTILLA_INCLUDE_DIR - where to find qextscintilla.h 6 | # QSCINTILLA_LIBRARIES - the libraries to link against to use QScintilla 7 | # QSCINTILLA_LIBRARY - where to find the QScintilla library (not for general use) 8 | 9 | # copyright (c) 2007 Thomas Moenicke thomas.moenicke@kdemail.net 10 | # 11 | # Redistribution and use is allowed according to the terms of the BSD license. 12 | 13 | IF(NOT QT4_FOUND) 14 | INCLUDE(FindQt4) 15 | ENDIF(NOT QT4_FOUND) 16 | 17 | SET(QSCINTILLA_FOUND "NO") 18 | 19 | IF(QT4_FOUND) 20 | FIND_PATH(QSCINTILLA_INCLUDE_DIR qsciglobal.h 21 | "${QT_INCLUDE_DIR}/Qsci" 22 | ) 23 | 24 | SET(QSCINTILLA_NAMES ${QSCINTILLA_NAMES} qscintilla2 libqscintilla2) 25 | FIND_LIBRARY(QSCINTILLA_LIBRARY 26 | NAMES ${QSCINTILLA_NAMES} 27 | PATHS ${QT_LIBRARY_DIR} 28 | ) 29 | 30 | IF (QSCINTILLA_LIBRARY) 31 | 32 | SET(QSCINTILLA_LIBRARIES ${QSCINTILLA_LIBRARY}) 33 | SET(QSCINTILLA_FOUND "YES") 34 | 35 | IF (CYGWIN) 36 | IF(BUILD_SHARED_LIBS) 37 | # No need to define QSCINTILLA_USE_DLL here, because it's default for Cygwin. 38 | ELSE(BUILD_SHARED_LIBS) 39 | SET (QSCINTILLA_DEFINITIONS -DQSCINTILLA_STATIC) 40 | ENDIF(BUILD_SHARED_LIBS) 41 | ENDIF (CYGWIN) 42 | 43 | ENDIF (QSCINTILLA_LIBRARY) 44 | ENDIF(QT4_FOUND) 45 | 46 | IF (QSCINTILLA_FOUND) 47 | IF (NOT QScintilla_FIND_QUIETLY) 48 | MESSAGE(STATUS "Found QScintilla2: ${QSCINTILLA_LIBRARY}") 49 | ENDIF (NOT QScintilla_FIND_QUIETLY) 50 | ELSE (QSCINTILLA_FOUND) 51 | IF (QScintilla_FIND_REQUIRED) 52 | MESSAGE(FATAL_ERROR "Could not find QScintilla library") 53 | ENDIF (QScintilla_FIND_REQUIRED) 54 | ENDIF (QSCINTILLA_FOUND) 55 | 56 | MARK_AS_ADVANCED(QSCINTILLA_INCLUDE_DIR QSCINTILLA_LIBRARY) 57 | 58 | -------------------------------------------------------------------------------- /cmake/modules/FindQwt.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find the Qwt includes and library 2 | # which defines 3 | # 4 | # QWT_FOUND - system has Qwt 5 | # QWT_INCLUDE_DIR - where to find qwt.h 6 | # QWT_LIBRARIES - the libraries to link against to use Qwt 7 | # QWT_LIBRARY - where to find the Qwt library (not for general use) 8 | 9 | # copyright (c) 2006 Thomas Moenicke thomas.moenicke@kdemail.net 10 | # 11 | # Redistribution and use is allowed according to the terms of the BSD license. 12 | 13 | IF(NOT QT4_FOUND) 14 | INCLUDE(FindQt4) 15 | ENDIF(NOT QT4_FOUND) 16 | 17 | SET(QWT_FOUND "NO") 18 | 19 | IF(QT4_FOUND) 20 | FIND_PATH(QWT_INCLUDE_DIR qwt.h 21 | /usr/local/qwt/include 22 | /usr/include/qwt 23 | ) 24 | 25 | SET(QWT_NAMES ${QWT_NAMES} qwt libqwt) 26 | FIND_LIBRARY(QWT_LIBRARY 27 | NAMES ${QWT_NAMES} 28 | PATHS /usr/local/qwt/lib 29 | ) 30 | 31 | IF (QWT_LIBRARY) 32 | 33 | SET(QWT_LIBRARIES ${QWT_LIBRARY}) 34 | SET(QWT_FOUND "YES") 35 | 36 | IF (CYGWIN) 37 | IF(BUILD_SHARED_LIBS) 38 | # No need to define QWT_USE_DLL here, because it's default for Cygwin. 39 | ELSE(BUILD_SHARED_LIBS) 40 | SET (QWT_DEFINITIONS -DQWT_STATIC) 41 | ENDIF(BUILD_SHARED_LIBS) 42 | ENDIF (CYGWIN) 43 | 44 | ENDIF (QWT_LIBRARY) 45 | ENDIF(QT4_FOUND) 46 | 47 | IF (QWT_FOUND) 48 | IF (NOT QWT_FIND_QUIETLY) 49 | MESSAGE(STATUS "Found Qwt: ${QWT_LIBRARY}") 50 | ENDIF (NOT QWT_FIND_QUIETLY) 51 | ELSE (QWT_FOUND) 52 | IF (QWT_FIND_REQUIRED) 53 | MESSAGE(FATAL_ERROR "Could not find Qwt library") 54 | ENDIF (QWT_FIND_REQUIRED) 55 | ENDIF (QWT_FOUND) 56 | 57 | MARK_AS_ADVANCED(QWT_INCLUDE_DIR QWT_LIBRARY) 58 | 59 | -------------------------------------------------------------------------------- /cmake/modules/FindQwt5.cmake: -------------------------------------------------------------------------------- 1 | # Find the Qwt 5.x includes and library, either the version linked to Qt3 or the version linked to Qt4 2 | # 3 | # On Windows it makes these assumptions: 4 | # - the Qwt DLL is where the other DLLs for Qt are (QT_DIR\bin) or in the path 5 | # - the Qwt .h files are in QT_DIR\include\Qwt or in the path 6 | # - the Qwt .lib is where the other LIBs for Qt are (QT_DIR\lib) or in the path 7 | # 8 | # Qwt5_INCLUDE_DIR - where to find qwt.h if Qwt 9 | # Qwt5_Qt4_LIBRARY - The Qwt5 library linked against Qt4 (if it exists) 10 | # Qwt5_Qt3_LIBRARY - The Qwt5 library linked against Qt4 (if it exists) 11 | # Qwt5_Qt4_FOUND - Qwt5 was found and uses Qt4 12 | # Qwt5_Qt3_FOUND - Qwt5 was found and uses Qt3 13 | # Qwt5_FOUND - Set to TRUE if Qwt5 was found (linked either to Qt3 or Qt4) 14 | 15 | # Copyright (c) 2007, Pau Garcia i Quiles, 16 | # 17 | # Redistribution and use is allowed according to the terms of the BSD license. 18 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 19 | 20 | # Condition is "(A OR B) AND C", CMake does not support parentheses but it evaluates left to right 21 | IF(Qwt5_Qt4_LIBRARY OR Qwt5_Qt3_LIBRARY AND Qwt5_INCLUDE_DIR) 22 | SET(Qwt5_FIND_QUIETLY TRUE) 23 | ENDIF(Qwt5_Qt4_LIBRARY OR Qwt5_Qt3_LIBRARY AND Qwt5_INCLUDE_DIR) 24 | 25 | IF(NOT QT4_FOUND) 26 | FIND_PACKAGE( Qt4 REQUIRED QUIET ) 27 | ENDIF(NOT QT4_FOUND) 28 | 29 | IF( QT4_FOUND ) 30 | # Is Qwt5 installed? Look for header files 31 | FIND_PATH( Qwt5_INCLUDE_DIR qwt.h 32 | PATHS ${QT_INCLUDE_DIR} /usr/local/qwt/include /usr/local/include /usr/include/qwt /usr/include 33 | PATH_SUFFIXES qwt qwt5 qwt-qt4 qwt5-qt4 qwt-qt3 qwt5-qt3 include qwt/include qwt5/include qwt-qt4/include qwt5-qt4/include qwt-qt3/include qwt5-qt3/include ENV PATH) 34 | 35 | # Find Qwt version 36 | IF( Qwt5_INCLUDE_DIR ) 37 | FILE( READ ${Qwt5_INCLUDE_DIR}/qwt_global.h QWT_GLOBAL_H ) 38 | STRING( REGEX MATCH "#define *QWT_VERSION *(0x05*)" QWT_IS_VERSION_5 ${QWT_GLOBAL_H}) 39 | 40 | IF( QWT_IS_VERSION_5 ) 41 | STRING(REGEX REPLACE ".*#define[\\t\\ ]+QWT_VERSION_STR[\\t\\ ]+\"([0-9]+\\.[0-9]+\\.[0-9]+)\".*" "\\1" Qwt_VERSION "${QWT_GLOBAL_H}") 42 | 43 | # Find Qwt5 library linked to Qt4 44 | FIND_LIBRARY( Qwt5_Qt4_TENTATIVE_LIBRARY NAMES qwt5-qt4 qwt-qt4 qwt5 qwt PATHS /usr/local/qwt/lib /usr/local/lib /usr/lib ) 45 | IF( UNIX AND NOT CYGWIN) 46 | IF( Qwt5_Qt4_TENTATIVE_LIBRARY ) 47 | #MESSAGE("Qwt5_Qt4_TENTATIVE_LIBRARY = ${Qwt5_Qt4_TENTATIVE_LIBRARY}") 48 | EXECUTE_PROCESS( COMMAND "ldd" ${Qwt5_Qt4_TENTATIVE_LIBRARY} OUTPUT_VARIABLE Qwt_Qt4_LIBRARIES_LINKED_TO ) 49 | STRING( REGEX MATCH "QtCore" Qwt5_IS_LINKED_TO_Qt4 ${Qwt_Qt4_LIBRARIES_LINKED_TO}) 50 | IF( Qwt5_IS_LINKED_TO_Qt4 ) 51 | SET( Qwt5_Qt4_LIBRARY ${Qwt5_Qt4_TENTATIVE_LIBRARY} ) 52 | SET( Qwt5_Qt4_FOUND TRUE ) 53 | IF (NOT Qwt5_FIND_QUIETLY) 54 | MESSAGE( STATUS "Found Qwt: ${Qwt5_Qt4_LIBRARY}" ) 55 | ENDIF (NOT Qwt5_FIND_QUIETLY) 56 | ENDIF( Qwt5_IS_LINKED_TO_Qt4 ) 57 | ENDIF( Qwt5_Qt4_TENTATIVE_LIBRARY ) 58 | ELSE( UNIX AND NOT CYGWIN) 59 | # Assumes qwt.dll is in the Qt dir 60 | SET( Qwt5_Qt4_LIBRARY ${Qwt5_Qt4_TENTATIVE_LIBRARY} ) 61 | SET( Qwt5_Qt4_FOUND TRUE ) 62 | IF (NOT Qwt5_FIND_QUIETLY) 63 | MESSAGE( STATUS "Found Qwt version ${Qwt_VERSION} linked to Qt4" ) 64 | ENDIF (NOT Qwt5_FIND_QUIETLY) 65 | ENDIF( UNIX AND NOT CYGWIN) 66 | 67 | 68 | # Find Qwt5 library linked to Qt3 69 | FIND_LIBRARY( Qwt5_Qt3_TENTATIVE_LIBRARY NAMES qwt-qt3 qwt qwt5-qt3 qwt5 ) 70 | IF( UNIX AND NOT CYGWIN) 71 | IF( Qwt5_Qt3_TENTATIVE_LIBRARY ) 72 | #MESSAGE("Qwt5_Qt3_TENTATIVE_LIBRARY = ${Qwt5_Qt3_TENTATIVE_LIBRARY}") 73 | EXECUTE_PROCESS( COMMAND "ldd" ${Qwt5_Qt3_TENTATIVE_LIBRARY} OUTPUT_VARIABLE Qwt-Qt3_LIBRARIES_LINKED_TO ) 74 | STRING( REGEX MATCH "qt-mt" Qwt5_IS_LINKED_TO_Qt3 ${Qwt-Qt3_LIBRARIES_LINKED_TO}) 75 | IF( Qwt5_IS_LINKED_TO_Qt3 ) 76 | SET( Qwt5_Qt3_LIBRARY ${Qwt5_Qt3_TENTATIVE_LIBRARY} ) 77 | SET( Qwt5_Qt3_FOUND TRUE ) 78 | IF (NOT Qwt5_FIND_QUIETLY) 79 | MESSAGE( STATUS "Found Qwt version ${Qwt_VERSION} linked to Qt3" ) 80 | ENDIF (NOT Qwt5_FIND_QUIETLY) 81 | ENDIF( Qwt5_IS_LINKED_TO_Qt3 ) 82 | ENDIF( Qwt5_Qt3_TENTATIVE_LIBRARY ) 83 | ELSE( UNIX AND NOT CYGWIN) 84 | SET( Qwt5_Qt3_LIBRARY ${Qwt5_Qt3_TENTATIVE_LIBRARY} ) 85 | SET( Qwt5_Qt3_FOUND TRUE ) 86 | IF (NOT Qwt5_FIND_QUIETLY) 87 | MESSAGE( STATUS "Found Qwt: ${Qwt5_Qt3_LIBRARY}" ) 88 | ENDIF (NOT Qwt5_FIND_QUIETLY) 89 | ENDIF( UNIX AND NOT CYGWIN) 90 | 91 | ENDIF( QWT_IS_VERSION_5 ) 92 | 93 | IF( Qwt5_Qt4_FOUND OR Qwt5_Qt3_FOUND ) 94 | SET( Qwt5_FOUND TRUE ) 95 | ENDIF( Qwt5_Qt4_FOUND OR Qwt5_Qt3_FOUND ) 96 | 97 | MARK_AS_ADVANCED( Qwt5_INCLUDE_DIR Qwt5_Qt4_LIBRARY Qwt5_Qt3_LIBRARY ) 98 | ENDIF( Qwt5_INCLUDE_DIR ) 99 | 100 | IF (NOT Qwt5_FOUND AND Qwt5_FIND_REQUIRED) 101 | MESSAGE(FATAL_ERROR "Could not find Qwt 5.x") 102 | ENDIF (NOT Qwt5_FOUND AND Qwt5_FIND_REQUIRED) 103 | 104 | ENDIF( QT4_FOUND ) -------------------------------------------------------------------------------- /cmake/modules/MacroPushRequiredVars.cmake: -------------------------------------------------------------------------------- 1 | # this module defines two macros: 2 | # MACRO_PUSH_REQUIRED_VARS() 3 | # and 4 | # MACRO_POP_REQUIRED_VARS() 5 | # use these if you call cmake macros which use 6 | # any of the CMAKE_REQUIRED_XXX variables 7 | # 8 | # Usage: 9 | # MACRO_PUSH_REQUIRED_VARS() 10 | # SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF) 11 | # CHECK_FUNCTION_EXISTS(...) 12 | # MACRO_POP_REQUIRED_VARS() 13 | 14 | # Copyright (c) 2006, Alexander Neundorf, 15 | # 16 | # Redistribution and use is allowed according to the terms of the BSD license. 17 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 18 | 19 | MACRO(MACRO_PUSH_REQUIRED_VARS) 20 | 21 | IF(NOT DEFINED _PUSH_REQUIRED_VARS_COUNTER) 22 | SET(_PUSH_REQUIRED_VARS_COUNTER 0) 23 | ENDIF(NOT DEFINED _PUSH_REQUIRED_VARS_COUNTER) 24 | 25 | MATH(EXPR _PUSH_REQUIRED_VARS_COUNTER "${_PUSH_REQUIRED_VARS_COUNTER}+1") 26 | 27 | SET(_CMAKE_REQUIRED_INCLUDES_SAVE_${_PUSH_REQUIRED_VARS_COUNTER} ${CMAKE_REQUIRED_INCLUDES}) 28 | SET(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_PUSH_REQUIRED_VARS_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS}) 29 | SET(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_PUSH_REQUIRED_VARS_COUNTER} ${CMAKE_REQUIRED_LIBRARIES}) 30 | SET(_CMAKE_REQUIRED_FLAGS_SAVE_${_PUSH_REQUIRED_VARS_COUNTER} ${CMAKE_REQUIRED_FLAGS}) 31 | ENDMACRO(MACRO_PUSH_REQUIRED_VARS) 32 | 33 | MACRO(MACRO_POP_REQUIRED_VARS) 34 | 35 | # don't pop more than we pushed 36 | IF("${_PUSH_REQUIRED_VARS_COUNTER}" GREATER "0") 37 | 38 | SET(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_PUSH_REQUIRED_VARS_COUNTER}}) 39 | SET(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_PUSH_REQUIRED_VARS_COUNTER}}) 40 | SET(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_PUSH_REQUIRED_VARS_COUNTER}}) 41 | SET(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_PUSH_REQUIRED_VARS_COUNTER}}) 42 | 43 | MATH(EXPR _PUSH_REQUIRED_VARS_COUNTER "${_PUSH_REQUIRED_VARS_COUNTER}-1") 44 | ENDIF("${_PUSH_REQUIRED_VARS_COUNTER}" GREATER "0") 45 | 46 | ENDMACRO(MACRO_POP_REQUIRED_VARS) 47 | 48 | -------------------------------------------------------------------------------- /examples/calculator/button.php: -------------------------------------------------------------------------------- 1 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); 19 | $this->setText($text); 20 | 21 | $newPalette = new QPalette(); 22 | $newPalette->setColor(QPalette::Button, $color); 23 | $this->setPalette($newPalette); 24 | } 25 | } 26 | 27 | ?> -------------------------------------------------------------------------------- /examples/calculator/main.php: -------------------------------------------------------------------------------- 1 | show(); 22 | $app->exec(); 23 | 24 | ?> -------------------------------------------------------------------------------- /kalyptus/Ast.pm: -------------------------------------------------------------------------------- 1 | package Ast; 2 | use strict; 3 | 4 | use vars qw/ $this $pack @endCodes /; 5 | 6 | #----------------------------------------------------------------------------- 7 | # This package is used to create a simple Abstract Syntax tree. Each node 8 | # in the AST is an associative array and supports two kinds of properties - 9 | # scalars and lists of scalars. 10 | # See SchemParser.pm for an example of usage. 11 | # ... Sriram 12 | #----------------------------------------------------------------------------- 13 | 14 | # Constructor 15 | # e.g AST::New ("personnel") 16 | # Stores the argument in a property called astNodeName whose sole purpose 17 | # is to support Print() 18 | 19 | sub New { 20 | my ($this) = {"astNodeName" => $_[0]}; 21 | bless ($this); 22 | return $this; 23 | } 24 | 25 | # Add a property to this object 26 | # $astNode->AddProp("className", "Employee"); 27 | 28 | sub AddProp { 29 | my ($this) = $_[0]; 30 | $this->{$_[1]} = $_[2]; 31 | } 32 | 33 | # Equivalent to AddProp, except the property name is associated 34 | # with a list of values 35 | # $classAstNode->AddProp("attrList", $attrAstNode); 36 | 37 | sub AddPropList { 38 | my ($this) = $_[0]; 39 | if (! exists $this->{$_[1]}) { 40 | $this->{$_[1]} = []; 41 | } 42 | push (@{$this->{$_[1]}}, $_[2]); 43 | } 44 | 45 | # Returns a list of all the property names of this object 46 | sub GetProps { 47 | my ($this) = $_[0]; 48 | return keys %{$this}; 49 | } 50 | 51 | sub Visit { 52 | # Converts each of this AstNode's properties into global variables. 53 | # The global variables are introduced into package "main" 54 | # At the same time, a piece of code is formed to undo this work above - 55 | # $endCode essentially contains the values of these global variables 56 | # before they are mangled. endCode gets pushed into a stack (endCodes), 57 | # which is unwound by UnVisit(). 58 | 59 | local ($this, $pack) = @_; 60 | 61 | 62 | my $code = ""; 63 | my $endCode = ""; 64 | 65 | 66 | foreach my $k (keys %{$this}) { 67 | 68 | my $glob = $pack."::".$k; 69 | 70 | if ( defined $$glob ) { 71 | 72 | if ( ${$glob} ne "" ) { 73 | $$glob =~ s/\'/\\\'/g; 74 | } 75 | 76 | $endCode .= '$'.$pack.'::'.$k. " = '".$$glob."';"; 77 | } else { 78 | $endCode .= '$'.$pack . "::". $k . ' = "";'; 79 | } 80 | $code .= '$'.$pack . "::" . $k . "= \$this->{\"$k\"};"; 81 | } 82 | push (@endCodes, $endCode); 83 | eval($code) if $code; 84 | } 85 | 86 | sub UnVisit { 87 | my $code = pop(@endCodes); 88 | eval($code) if ($code); 89 | } 90 | 91 | 1; 92 | -------------------------------------------------------------------------------- /kalyptus/Makefile.cvs: -------------------------------------------------------------------------------- 1 | 2 | all: configure 3 | 4 | configure: configure.in 5 | autoconf 6 | -------------------------------------------------------------------------------- /kalyptus/Makefile.in: -------------------------------------------------------------------------------- 1 | prefix = @prefix@ 2 | exec_prefix = @exec_prefix@ 3 | perl = @perl@ 4 | install = @INSTALL@ 5 | bin = kalyptus 6 | pm = kdocUtil.pm kdocAstUtil.pm kdocParseDoc.pm kdocLib.pm \ 7 | Ast.pm kalyptusDataDict.pm kalyptusCxxToC.pm \ 8 | kalyptusCxxToObjc.pm kalyptusCxxToJava.pm \ 9 | kalyptusCxxToSmoke.pm kalyptusCxxToCSharp.pm \ 10 | Iter.pm 11 | pmextra = 12 | bindir = ${exec_prefix}/bin 13 | pmdir = ${prefix}/share/kalyptus 14 | srcdocdir= . 15 | VERSION=@Version@ 16 | 17 | all: kalyptus.local 18 | 19 | kalyptus.local: @srcdir@/kalyptus 20 | cp @srcdir@/kalyptus kalyptus.local 21 | perl -npi -e 's%^#\!.*$$%#!'${perl}' -I'${pmdir}'%g;' kalyptus.local 22 | perl -npi -e 's#\$$Version\\\$$#'"${VERSION}"'#g;' kalyptus.local 23 | 24 | install: all 25 | ${install} -d $(DESTDIR)${bindir} 26 | ${install} -m 755 kalyptus.local $(DESTDIR)${bindir}/kalyptus 27 | ${install} -d $(DESTDIR)${pmdir} 28 | for file in ${pm} ${pmextra}; do \ 29 | ${install} -m 644 @srcdir@/$$file $(DESTDIR)${pmdir}; \ 30 | done 31 | 32 | uninstall: 33 | (cd $(DESTDIR)${bindir} && rm -f ${bin}) 34 | (cd $(DESTDIR)${pmdir} && rm -f ${pm}) 35 | -rmdir $(DESTDIR)${bindir} 36 | -rmdir $(DESTDIR)${pmdir} 37 | 38 | clean: 39 | rm -f kalyptus.local 40 | 41 | distclean: clean 42 | rm -f Makefile config.status config.log config.cache perlbin 43 | 44 | srcdoc: 45 | pod2html --flush --title KALYPTUS $(bin) $(pm) \ 46 | --outfile $(srcdocdir)/kalyptus-doc.html 47 | tags: 48 | perltags kalyptus *.pm 49 | 50 | check: 51 | @for dir in $(bin) $(pm); do \ 52 | echo "** Checking: $$dir"; \ 53 | perl -wc $$dir; done 54 | -------------------------------------------------------------------------------- /kalyptus/README: -------------------------------------------------------------------------------- 1 | 2 | KALYPTUS -- C, Objective-C and Java bindings generator 3 | 4 | Version 0.9 5 | 6 | KALYPTUS creates language bindings for Qt and KDE C++ libraries 7 | directly from the headers. Documentation embedded in special doc 8 | comments in the source is translated to an appropriate format for 9 | the target language. 10 | 11 | REQUIREMENTS 12 | 13 | You need perl 5.005 or greater to run kalyptus. 14 | 15 | HOWTO 16 | 17 | If you are running this straight from CVS, you will need to run 18 | 19 | make -f Makefile.cvs 20 | 21 | before building. 22 | 23 | This should install kalyptus: 24 | 25 | ./configure; make; make install 26 | 27 | CREDITS 28 | ------- 29 | 30 | Richard Dale - kdoc adaption, C/Objective-C/Java code generation. 31 | 32 | Sirtaj Singh Kang for writing the original kdoc utility (kalyptus was 33 | derived from kdoc). 34 | 35 | Copyright(C) 2001, Lost Highway Ltd 36 | 37 | ------ 38 | 39 | Copyright(C) 1999, Sirtaj Singh Kang 40 | Distributed under the GPL. 41 | 42 | NOTES ON USING THE CONVERTER 43 | ---------------------------- 44 | 45 | JAVA 46 | ---- 47 | 48 | Here are some of the shell commands that were used in the conversion process: 49 | 50 | Remove any Q_OVERRIDE macros from the Qt headers, and remove EXPORT_DOCKCLASS from the 51 | KDE headers 52 | 53 | # Generate Java and C++ sources. Copy all the target headers to directory 'test/tmp' 54 | kalyptus -fjava test/tmp/*.h test/tmp/dom/*.h test/tmp/kio/*.h test/tmp/kdeprint/*.h \ 55 | test/tmp/kjs/*.h test/tmp/kparts/*.h test/tmp/kdesu/*.h test/ktextedit/*.h test/tmp/libkmid/*.h 56 | 57 | # Shorten generated filenames 58 | mv DOM__Node.cpp DOMNode.cpp 59 | mv DOM__Node.java DOMNode.java 60 | mv DOM__Document.cpp DOMDocument.cpp 61 | mv DOM__Document.java DOMDocument.java 62 | for FILE in *__* ; do 63 | NAME=`echo $FILE | sed -e 's/^.*__//'`; 64 | echo $NAME; 65 | mv $FILE $NAME; 66 | done 67 | mv SlaveInterface.cpp Slave.cpp 68 | mv SlaveInterface.java Slave.java 69 | 70 | # Edit and Compile the generated java 71 | cd kdejava/koala/org/kde/koala 72 | make 73 | 74 | # Build C++ JNI .h header files 75 | cd qtjava/javalib/org/kde/qt 76 | for FILE in *.class ; do NAME=`echo $FILE | sed 's/.class//'`; echo $NAME; javah -classpath '../../..' org.kde.qt.$NAME ; done 77 | for FILE in org_kde* ; do NAME=`echo $FILE | sed -e 's/org_kde_qt_//'`; echo $NAME; mv $FILE $NAME; done 78 | 79 | cd kdejava/koala/org/kde/koala 80 | for FILE in *.class ; do NAME=`echo $FILE | sed 's/.class//'`; echo $NAME; javah -classpath '../../..:../../../../../qtjava/javalib/qtjava.jar' org.kde.koala.$NAME ; done 81 | for FILE in org_kde* ; do NAME=`echo $FILE | sed -e 's/org_kde_koala_//'`; echo $NAME; mv $FILE $NAME; done 82 | # Copy headers to kdejava/koala/kdejava 83 | 84 | # Check that the JNI .h function names match the .cpp ones 85 | cd kdejava/koala/org/kde/koala 86 | grep ^Java_ *.cpp | sed -e 's/^[^:]*:\([^(]*\).*/\1/' | grep -v '[/]' | sort | uniq > cpp.fns 87 | grep Java_ *.h | awk '{ print $4 }' | grep -v '[/]' | sort | uniq > h.fns 88 | kompare h.fns cpp.fns 89 | # Reconcile and fix any differences 90 | 91 | # Edit and compile the generated .cpp and .h files with KDevelop 92 | 93 | -------------------------------------------------------------------------------- /kalyptus/TODO: -------------------------------------------------------------------------------- 1 | Add more target languages, such as PHP and Pascal 2 | 3 | Use a perl parser generator to define the grammar for 4 | C++ method arguments. 5 | 6 | Write documentation for a how to on bindings generation. 7 | 8 | -------------------------------------------------------------------------------- /kalyptus/Version: -------------------------------------------------------------------------------- 1 | 0.91 2 | -------------------------------------------------------------------------------- /kalyptus/dcopidlng: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [[ -z $KALYPTUS || ! -d $KALYPTUS ]] 3 | then 4 | echo "Please set enviroment variable KALYPTUS to point to your kdebindings/kaltyptus checkout directory" 5 | exit 6 | fi 7 | perl -I$KALYPTUS $KALYPTUS/kalyptus $2 --allow_k_dcop_accessors -f dcopidl $1 2>/tmp/dcopidlng.stderr.$$ 8 | if [[ $? -ne 0 ]] 9 | then 10 | cat /tmp/dcopidlng.stderr.$$ 11 | fi 12 | rm /tmp/dcopidlng.stderr.$$ 13 | -------------------------------------------------------------------------------- /kalyptus/findperl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | test -f perlbin && rm perlbin 4 | 5 | for p in `echo $PATH | tr ":" " "` 6 | do 7 | if [ -x $p/perl ] 8 | then 9 | if $p/perl -e 'require 5.000;' 10 | then 11 | echo $p/perl > perlbin 12 | exit 0 13 | fi 14 | fi 15 | 16 | done 17 | exit 1 18 | -------------------------------------------------------------------------------- /kalyptus/kdocLib.pm: -------------------------------------------------------------------------------- 1 | 2 | =head1 kdocLib 3 | 4 | Writes out a library file. 5 | 6 | NOTES ON THE NEW FORMAT 7 | 8 | Stores: class name, members, hierarchy 9 | node types are not stored 10 | 11 | 12 | File Format Spec 13 | ---------------- 14 | 15 | header 16 | zero or more members, each of 17 | method 18 | member 19 | class, each of 20 | inheritance 21 | zero or more members 22 | 23 | 24 | 25 | Unrecognized lines ignored. 26 | 27 | Sample 28 | ------ 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | =cut 41 | 42 | package kdocLib; 43 | use strict; 44 | 45 | use Carp; 46 | use File::Path; 47 | use File::Basename; 48 | 49 | use Ast; 50 | use kdocAstUtil; 51 | use kdocUtil; 52 | 53 | 54 | use vars qw/ $exe $lib $root $plang $outputdir $docpath $url $compress /; 55 | 56 | BEGIN { 57 | $exe = basename $0; 58 | } 59 | 60 | sub writeDoc 61 | { 62 | ( $lib, $root, $plang, $outputdir, $docpath, $url, 63 | $compress ) = @_; 64 | my $outfile = "$outputdir/$lib.kalyptus"; 65 | $url = $docpath unless defined $url; 66 | 67 | mkpath( $outputdir ) unless -f $outputdir; 68 | 69 | if( $compress ) { 70 | open( LIB, "| gzip -9 > \"$outfile.gz\"" ) 71 | || die "$exe: couldn't write to $outfile.gz\n"; 72 | 73 | } 74 | else { 75 | open( LIB, ">$outfile" ) 76 | || die "$exe: couldn't write to $outfile\n"; 77 | } 78 | 79 | my $libdesc = ""; 80 | if ( defined $root->{LibDoc} ) { 81 | $libdesc="".$root->{LibDoc}->{astNodeName}.""; 82 | } 83 | 84 | print LIB< 86 | 87 | 88 | 89 | $lib 90 | $libdesc 91 | 92 | LTEXT 93 | 94 | writeNode( $root, "" ); 95 | close LIB; 96 | } 97 | 98 | sub writeNode 99 | { 100 | my ( $n, $prefix ) = @_; 101 | return if !exists $n->{Compound}; 102 | return if exists $n->{Forward} && !exists $n->{KidAccess}; 103 | 104 | if( $n != $root ) { 105 | $prefix .= $n->{astNodeName}; 106 | print LIB "{astNodeName}, 107 | "\" REF=\"$prefix.html\">\n"; 108 | } 109 | else { 110 | print LIB "\n"; 111 | my $stats = $root->{Stats}; 112 | foreach my $stat ( keys %$stats ) { 113 | print LIB "", 114 | $stats->{$stat},"\n"; 115 | } 116 | print LIB "\n"; 117 | } 118 | 119 | if( exists $n->{Ancestors} ) { 120 | my $in; 121 | foreach $in ( @{$n->{Ancestors}} ) { 122 | $in =~ s/\s+//g; 123 | print LIB "\n"; 124 | } 125 | } 126 | 127 | return if !exists $n->{Kids}; 128 | my $kid; 129 | my $type; 130 | 131 | foreach $kid ( @{$n->{Kids}} ) { 132 | next if exists $kid->{ExtSource} 133 | || $kid->{Access} eq "private"; 134 | 135 | if ( exists $kid->{Compound} ) { 136 | if( $n != $root ) { 137 | writeNode( $kid, $prefix."::" ); 138 | } 139 | else { 140 | writeNode( $kid, "" ); 141 | } 142 | next; 143 | } 144 | 145 | $type = $kid->{NodeType} eq "method" ? 146 | "ME" : "M"; 147 | 148 | print LIB "<$type NAME=\"", $kid->{astNodeName}, 149 | "\" REF=\"$prefix.html#", $kid->{astNodeName}, "\">\n"; 150 | } 151 | 152 | if( $n != $root ) { 153 | print LIB "\n"; 154 | } 155 | } 156 | 157 | sub readLibrary 158 | { 159 | my( $rootsub, $name, $path, $relurl ) = @_; 160 | $path = "." unless defined $path; 161 | my $real = $path."/".$name.".kalyptus"; 162 | my $url = "."; 163 | my @stack = (); 164 | my $version = "2.0"; 165 | my $new; 166 | my $root = undef; 167 | my $n = undef; 168 | my $havecomp = -r "$real.gz"; 169 | my $haveuncomp = -r "$real"; 170 | 171 | if ( $haveuncomp ) { 172 | open( LIB, "$real" ) || die "Can't read lib $real\n"; 173 | } 174 | 175 | if( $havecomp ) { 176 | if ( $haveuncomp ) { 177 | warn "$exe: two libs exist: $real and $real.gz. " 178 | ."Using $real\n"; 179 | } 180 | else { 181 | open( LIB, "gunzip < \"$real.gz\"|" ) 182 | || die "Can't read pipe gunzip < \"$real.gz\": $?\n"; 183 | } 184 | } 185 | 186 | while( ) { 187 | next if /^\s*$/; 188 | if ( !/^\s*/ ) { 195 | # TODO: what do we do with the version number? 196 | $version = $1; 197 | } 198 | elsif ( // ) { 206 | $root = $rootsub->( $1 ); 207 | $n = $root; 208 | } 209 | elsif ( // ) { 210 | # class 211 | $new = Ast::New( $1 ); 212 | $new->AddProp( "NodeType", "class" ); 213 | $new->AddProp( "Compound", 1 ); 214 | $new->AddProp( "ExtSource", $name ); 215 | 216 | # already escaped at this point! 217 | $new->AddProp( "Ref", $url.$2 ); 218 | 219 | $root = $n = $rootsub->( "CXX" ) unless defined $root; 220 | kdocAstUtil::attachChild( $n, $new ); 221 | push @stack, $n; 222 | $n = $new; 223 | } 224 | elsif ( m## ) { 225 | # ancestor 226 | kdocAstUtil::newInherit( $n, $1 ); 227 | } 228 | elsif ( m## ) { 229 | # end class 230 | $n = pop @stack; 231 | } 232 | elsif ( m#<(M\w*)\s+NAME="(.*?)"\s+REF="(.*?)"\s*># ) { 233 | # member 234 | $new = Ast::New( $2 ); 235 | $new->AddProp( "NodeType", $1 eq "ME" ? "method" : "var" ); 236 | $new->AddProp( "ExtSource", $name ); 237 | $new->AddProp( "Flags", "" ); 238 | $new->AddProp( "Ref", $url.$3 ); 239 | 240 | kdocAstUtil::attachChild( $n, $new ); 241 | } 242 | } 243 | } 244 | 245 | 1; 246 | -------------------------------------------------------------------------------- /kalyptus/kdocUtil.pm: -------------------------------------------------------------------------------- 1 | 2 | package kdocUtil; 3 | 4 | use strict; 5 | 6 | 7 | =head1 kdocUtil 8 | 9 | General utilities. 10 | 11 | =head2 countReg 12 | 13 | Parameters: string, regexp 14 | 15 | Returns the number of times of regexp occurs in string. 16 | 17 | =cut 18 | 19 | sub countReg 20 | { 21 | my( $str, $regexp ) = @_; 22 | my( $count ) = 0; 23 | 24 | while( $str =~ /$regexp/s ) { 25 | $count++; 26 | 27 | $str =~ s/$regexp//s; 28 | } 29 | 30 | return $count; 31 | } 32 | 33 | =head2 findCommonPrefix 34 | 35 | Parameters: string, string 36 | 37 | Returns the prefix common to both strings. An empty string 38 | is returned if the strings have no common prefix. 39 | 40 | =cut 41 | 42 | sub findCommonPrefix 43 | { 44 | my @s1 = split( "/", $_[0] ); 45 | my @s2 = split( "/", $_[1] ); 46 | my $accum = ""; 47 | my $len = ($#s2 > $#s1 ) ? $#s1 : $#s2; 48 | 49 | for my $i ( 0..$len ) { 50 | # print "Compare: $i '$s1[$i]', '$s2[$i]'\n"; 51 | last if $s1[ $i ] ne $s2[ $i ]; 52 | $accum .= $s1[ $i ]."/"; 53 | } 54 | 55 | return $accum; 56 | } 57 | 58 | =head2 makeRelativePath 59 | 60 | Parameters: localpath, destpath 61 | 62 | Returns a relative path to the destination from the local path, 63 | after removal of any common prefix. 64 | 65 | =cut 66 | 67 | sub makeRelativePath 68 | { 69 | my ( $from, $to ) = @_; 70 | 71 | # remove prefix 72 | $from .= '/' unless $from =~ m#/$#; 73 | $to .= '/' unless $to =~ m#/$#; 74 | 75 | my $pfx = findCommonPrefix( $from, $to ); 76 | 77 | if ( $pfx ne "" ) { 78 | $from =~ s/^$pfx//g; 79 | $to =~ s/^$pfx//g; 80 | } 81 | # print "Prefix is '$pfx'\n"; 82 | 83 | $from =~ s#/+#/#g; 84 | $to =~ s#/+#/#g; 85 | $pfx = countReg( $from, '\/' ); 86 | 87 | my $rel = "../" x $pfx; 88 | $rel .= $to; 89 | 90 | return $rel; 91 | } 92 | 93 | sub hostName 94 | { 95 | my $host = ""; 96 | my @hostenvs = qw( HOST HOSTNAME COMPUTERNAME ); 97 | 98 | # Host name 99 | foreach my $evar ( @hostenvs ) { 100 | next unless defined $ENV{ $evar }; 101 | 102 | $host = $ENV{ $evar }; 103 | last; 104 | } 105 | 106 | if( $host eq "" ) { 107 | $host = `uname -n`; 108 | chop $host; 109 | } 110 | 111 | return $host; 112 | } 113 | 114 | sub userName 115 | { 116 | my $who = ""; 117 | my @userenvs = qw( USERNAME USER LOGNAME ); 118 | 119 | # User name 120 | foreach my $evar ( @userenvs ) { 121 | next unless defined $ENV{ $evar }; 122 | 123 | $who = $ENV{ $evar }; 124 | last; 125 | } 126 | 127 | if( $who eq "" ) { 128 | if ( $who = `whoami` ) { 129 | chop $who; 130 | } 131 | elsif ( $who - `who am i` ) { 132 | $who = ( split (/ /, $who ) )[0]; 133 | } 134 | } 135 | 136 | return $who; 137 | } 138 | 139 | =head2 splitUnnested 140 | Helper to split a list using a delimiter, but looking for 141 | nesting with (), {}, [] and <>. 142 | Example: splitting int a, QPair d, e="," 143 | on ',' will give 3 items in the list. 144 | 145 | Parameter: delimiter, string 146 | Returns: array, after splitting the string 147 | 148 | Thanks to Ashley Winters 149 | =cut 150 | sub splitUnnested($$) { 151 | my $delim = shift; 152 | my $string = shift; 153 | my(%open) = ( 154 | '[' => ']', 155 | '(' => ')', 156 | '<' => '>', 157 | '{' => '}', 158 | ); 159 | my(%close) = reverse %open; 160 | my @ret; 161 | my $depth = 0; 162 | my $start = 0; 163 | my $indoublequotes = 0; 164 | my $insinglequotes = 0; 165 | while($string =~ /($delim|<<|>>|[][}{)(><\"\'])/g) { 166 | my $c = $1; 167 | if(!$insinglequotes and !$indoublequotes) { 168 | if(!$depth and $c eq $delim) { 169 | my $len = pos($string) - $start - 1; 170 | push @ret, substr($string, $start, $len); 171 | $start = pos($string); 172 | } elsif( $c eq "'") { 173 | $insinglequotes = 1; 174 | } elsif( $c eq '"') { 175 | $indoublequotes = 1; 176 | } elsif($open{$c}) { 177 | $depth++; 178 | } elsif($close{$c}) { 179 | $depth--; 180 | } 181 | } elsif($c eq '"' and $indoublequotes) { 182 | $indoublequotes = 0; 183 | } elsif ($c eq "'" and $insinglequotes) { 184 | $insinglequotes = 0; 185 | } 186 | } 187 | 188 | my $subs = substr($string, $start); 189 | push @ret, $subs if ($subs); 190 | return @ret; 191 | } 192 | 193 | 1; 194 | 195 | -------------------------------------------------------------------------------- /kalyptus/perlbin: -------------------------------------------------------------------------------- 1 | /usr/bin/perl 2 | -------------------------------------------------------------------------------- /smoke/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | OPTION(ENABLE_SMOKE "build Smoke" ON) 2 | OPTION(ENABLE_SMOKEKDE "build SmokeKDE" ON) 3 | OPTION(ENABLE_SMOKEPLASMA "build SmokePlasma" OFF) 4 | 5 | set(SMOKE_ENABLED "no") 6 | if(ENABLE_SMOKE OR ENABLE_SMOKEKDE) 7 | add_subdirectory(qt) 8 | if(ENABLE_SMOKEKDE) 9 | add_subdirectory(kde) 10 | set(SMOKE_ENABLED "yes - Qt and KDE") 11 | else(ENABLE_SMOKEKDE) 12 | set(SMOKE_ENABLED "yes - Qt only") 13 | endif(ENABLE_SMOKEKDE) 14 | 15 | endif(ENABLE_SMOKE OR ENABLE_SMOKEKDE) 16 | 17 | if(ENABLE_SMOKEPLASMA) 18 | add_subdirectory(plasma) 19 | endif(ENABLE_SMOKEPLASMA) 20 | 21 | message(STATUS "Build Smoke... " ${SMOKE_ENABLED}) 22 | 23 | ########### install files ############### 24 | 25 | # KDE specific 26 | #install( FILES smoke.h DESTINATION ${INCLUDE_INSTALL_DIR} ) 27 | 28 | # Qt only 29 | #install( FILES smoke.h DESTINATION ${INSTALL_DIR}/include ) 30 | 31 | install( FILES smoke.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include ) 32 | -------------------------------------------------------------------------------- /smoke/README: -------------------------------------------------------------------------------- 1 | SMOKE stands for "Scripting Meta Object Kompiler Engine" - for instance ;) 2 | 3 | This directory compiles a smokeqt (and later a smokekde) library, which 4 | contain interfaces to (almost) all Qt and KDE classes. 5 | The next PerlQt/PerlKDE will be based on SMOKE. 6 | However SMOKE is language-independent enough for other bindings (e.g. to 7 | other scripting languages) to be based on it. 8 | 9 | Note that the .cpp source files are auto-generated by kalyptus, from reading 10 | the Qt/KDE headers. 11 | 12 | 13 | Regenerating 14 | ============ 15 | 16 | For SmokeQt: 17 | cd qt 18 | ./qtguess.pl 19 | ./generate.pl 20 | make 21 | 22 | -------------------------------------------------------------------------------- /smoke/kde/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories( ${CMAKE_SOURCE_DIR}/smoke ${INCLUDE_INSTALL_DIR}/khexedit/ ) 3 | 4 | set(srcdir ${CMAKE_CURRENT_SOURCE_DIR}) 5 | set(KDE_PREFIX ${CMAKE_INSTALL_PREFIX}) 6 | set(qt_includes ${QT_INCLUDE_DIR}) 7 | set(kde_includes ${KDE4_INCLUDE_DIR}) 8 | if(OPENGL_FOUND AND OPENGL_GLU_FOUND) 9 | set(KDE_HAVE_GL "yes") 10 | else(OPENGL_FOUND AND OPENGL_GLU_FOUND) 11 | set(KDE_HAVE_GL "no") 12 | endif(OPENGL_FOUND AND OPENGL_GLU_FOUND) 13 | 14 | # for qtguess.pl 15 | set(qt_test_threshold 10) 16 | set(qtflags "-lQtCore -lQtGui") 17 | FOREACH(filename ${QT_INCLUDES}) 18 | set(all_includes "-I${filename} ${all_includes}") 19 | ENDFOREACH(filename) 20 | 21 | 22 | # macro is defined in qt-copy/src/qbase.pri but couldn't be found by qtguess, so I append it manually 23 | file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/qtdefines "QT_NO_CAST_TO_ASCII\n") 24 | 25 | ########### next target ############### 26 | 27 | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/smokedata.cpp 28 | ${CMAKE_CURRENT_BINARY_DIR}/x_1.cpp 29 | ${CMAKE_CURRENT_BINARY_DIR}/x_2.cpp 30 | ${CMAKE_CURRENT_BINARY_DIR}/x_3.cpp 31 | ${CMAKE_CURRENT_BINARY_DIR}/x_4.cpp 32 | ${CMAKE_CURRENT_BINARY_DIR}/x_5.cpp 33 | ${CMAKE_CURRENT_BINARY_DIR}/x_6.cpp 34 | ${CMAKE_CURRENT_BINARY_DIR}/x_7.cpp 35 | ${CMAKE_CURRENT_BINARY_DIR}/x_8.cpp 36 | ${CMAKE_CURRENT_BINARY_DIR}/x_9.cpp 37 | ${CMAKE_CURRENT_BINARY_DIR}/x_10.cpp 38 | ${CMAKE_CURRENT_BINARY_DIR}/x_11.cpp 39 | ${CMAKE_CURRENT_BINARY_DIR}/x_12.cpp 40 | ${CMAKE_CURRENT_BINARY_DIR}/x_13.cpp 41 | ${CMAKE_CURRENT_BINARY_DIR}/x_14.cpp 42 | ${CMAKE_CURRENT_BINARY_DIR}/x_15.cpp 43 | ${CMAKE_CURRENT_BINARY_DIR}/x_16.cpp 44 | ${CMAKE_CURRENT_BINARY_DIR}/x_17.cpp 45 | ${CMAKE_CURRENT_BINARY_DIR}/x_18.cpp 46 | ${CMAKE_CURRENT_BINARY_DIR}/x_19.cpp 47 | ${CMAKE_CURRENT_BINARY_DIR}/x_20.cpp 48 | 49 | COMMAND ${PERL_EXECUTABLE} ARGS ${CMAKE_CURRENT_BINARY_DIR}/qtguess.pl 50 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/qtguess.pl 51 | 52 | COMMAND ${PERL_EXECUTABLE} ARGS ${CMAKE_CURRENT_BINARY_DIR}/generate.pl 53 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/generate.pl 54 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 55 | 56 | macro_add_file_dependencies( ${CMAKE_CURRENT_BINARY_DIR}/smokedata.cpp ${CMAKE_CURRENT_BINARY_DIR}/x_1.cpp ) 57 | 58 | 59 | set(smokekde_LIB_SRCS ${CMAKE_CURRENT_BINARY_DIR}/smokedata.cpp 60 | ${CMAKE_CURRENT_BINARY_DIR}/x_1.cpp 61 | ${CMAKE_CURRENT_BINARY_DIR}/x_2.cpp 62 | ${CMAKE_CURRENT_BINARY_DIR}/x_3.cpp 63 | ${CMAKE_CURRENT_BINARY_DIR}/x_4.cpp 64 | ${CMAKE_CURRENT_BINARY_DIR}/x_5.cpp 65 | ${CMAKE_CURRENT_BINARY_DIR}/x_6.cpp 66 | ${CMAKE_CURRENT_BINARY_DIR}/x_7.cpp 67 | ${CMAKE_CURRENT_BINARY_DIR}/x_8.cpp 68 | ${CMAKE_CURRENT_BINARY_DIR}/x_9.cpp 69 | ${CMAKE_CURRENT_BINARY_DIR}/x_10.cpp 70 | ${CMAKE_CURRENT_BINARY_DIR}/x_11.cpp 71 | ${CMAKE_CURRENT_BINARY_DIR}/x_12.cpp 72 | ${CMAKE_CURRENT_BINARY_DIR}/x_13.cpp 73 | ${CMAKE_CURRENT_BINARY_DIR}/x_14.cpp 74 | ${CMAKE_CURRENT_BINARY_DIR}/x_15.cpp 75 | ${CMAKE_CURRENT_BINARY_DIR}/x_16.cpp 76 | ${CMAKE_CURRENT_BINARY_DIR}/x_17.cpp 77 | ${CMAKE_CURRENT_BINARY_DIR}/x_18.cpp 78 | ${CMAKE_CURRENT_BINARY_DIR}/x_19.cpp 79 | ${CMAKE_CURRENT_BINARY_DIR}/x_20.cpp 80 | ) 81 | 82 | # Needed to make QSqlRelationalDelegate compile 83 | ADD_DEFINITIONS (-DQT_GUI_LIB) 84 | 85 | INCLUDE(${QT_USE_FILE}) 86 | # At this point, QT_LIBRARIES will contain a list of the found Qt Libs 87 | # and QT_INCLUDES contains the directories of the found includes 88 | 89 | FOREACH(filename ${QT_INCLUDES}) 90 | set(all_includes "-I${filename} ${all_includes}") 91 | ENDFOREACH(filename) 92 | 93 | FOREACH(incname ${QT_INCLUDES}) 94 | SET(qt_incs "'${incname}', ${qt_incs}") 95 | ENDFOREACH(incname) 96 | 97 | FOREACH(libname ${QT_LIBRARIES}) 98 | set(all_libs "${libname} ${all_libs}") 99 | ENDFOREACH(libname) 100 | 101 | configure_file(generate.pl.cmake ${CMAKE_CURRENT_BINARY_DIR}/generate.pl @ONLY ) 102 | configure_file(qtguess.pl.cmake ${CMAKE_CURRENT_BINARY_DIR}/qtguess.pl @ONLY) 103 | 104 | kde4_add_library(smokekde SHARED ${smokekde_LIB_SRCS}) 105 | 106 | target_link_libraries(smokekde 107 | ${QT_QTNETWORK_LIBRARY} 108 | ${QT_QTSQL_LIBRARY} 109 | ${QT_QTOPENGL_LIBRARY} 110 | ${QT_QTXML_LIBRARY} 111 | ${QT_QTSVG_LIBRARY} 112 | ${QT_QTUITOOLS_LIBRARY} 113 | ${QT_QT3SUPPORT_LIBRARY} 114 | ${KDE4_KDECORE_LIBS} 115 | ${KDE4_KDEUI_LIBS} 116 | ${KDE4_KIO_LIBS} 117 | ${KDE4_KNOTIFYCONFIG_LIBS} 118 | ${KDE4_KNEWSTUFF2_LIBS} 119 | ${KDE4_KDNSSD_LIBS} 120 | ${KDE4_KHTML_LIBS} 121 | ${KDE4_KDE3SUPPORT_LIBS} 122 | ${KDE4_KUTILS_LIBS} 123 | kmediaplayer 124 | kntlm ) 125 | 126 | set_target_properties(smokekde PROPERTIES VERSION 2.0.0 SOVERSION 2 ) 127 | install(TARGETS smokekde DESTINATION ${LIB_INSTALL_DIR} ) 128 | -------------------------------------------------------------------------------- /smoke/kde/generate_makefile_am.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use File::Basename; 4 | 5 | my $here = `pwd`; 6 | chomp $here; 7 | my $outdir = $here; 8 | my $tempfile = "$outdir/.Makefile.am.tmpfile"; 9 | 10 | # Update list of source files in $outdir/Makefile.am 11 | open( MAKEFILE, "<$outdir/Makefile.am" ) or die; 12 | my $makeFileData = ''; 13 | my $found = 0; 14 | while () { 15 | if (/^libsmokeqt_la_SOURCES/) 16 | { 17 | $found = 1; 18 | $makeFileData .= "libsmokeqt_la_SOURCES = smokedata.cpp"; 19 | } 20 | $makeFileData .= $_ if (!$found); 21 | } 22 | close MAKEFILE; 23 | 24 | die "libsmokeqt_la_SOURCES not found" if (!$found); 25 | 26 | open( MAKEFILE, ">$tempfile" ) or die; 27 | print MAKEFILE $makeFileData; 28 | 29 | my $count = 0; 30 | opendir (FILES, $outdir) or die; 31 | foreach $filename (readdir(FILES)) { 32 | if ( $filename =~ /^x_.*\.cpp$/ ) { 33 | if ( $count++ == 7 ) { 34 | $count = 0; 35 | print MAKEFILE " \\\n"; 36 | } 37 | print MAKEFILE " $filename"; 38 | } 39 | } 40 | 41 | print MAKEFILE "\n"; 42 | close MAKEFILE; 43 | closedir FILES; 44 | 45 | system "cmp -s $tempfile $outdir/Makefile.am"; 46 | if ($? >> 8) { 47 | system "cp -f $tempfile $outdir/Makefile.am"; 48 | print STDERR "Makefile.am updated.\n"; 49 | } 50 | else { 51 | print STDERR "Makefile.am unchanged.\n"; 52 | } 53 | system "rm -f $tempfile"; 54 | 55 | exit 0; 56 | -------------------------------------------------------------------------------- /smoke/kde/hint_header_list.pl: -------------------------------------------------------------------------------- 1 | 2 | # CVS admin : run this script to compare the set of Qt headers to 3 | # the actual content of header_list 4 | 5 | $l = "header_list"; 6 | $q = $ENV{'QTDIR'} || die "QTDIR not set\n"; 7 | @h = <$q/include/*.h>; 8 | grep s|.*/(.*\.h)|$1|, @h; 9 | open(IN, $l) or die "$!: $l\n"; 10 | @old = ; 11 | chomp @old; 12 | map{ $h{$_}++ } @h; 13 | map{ $old{$_}++ } @old; 14 | map{ $diff{$_}++ unless $old{$_} } keys %h; 15 | map{ delete $diff{$_} if /^qconfig.*/ or !/^q/ } keys %diff; 16 | print "Check if any of the following headers should be added to $l:\n\n"; 17 | print join "\n", keys %diff, "\n" 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /smoke/kde/qt_smoke.h: -------------------------------------------------------------------------------- 1 | #ifndef QT_SMOKE_H 2 | #define QT_SMOKE_H 3 | 4 | #include 5 | // Defined in smokedata.cpp, initialized by init_qt_Smoke(), used by all .cpp files 6 | extern KDE_EXPORT Smoke* qt_Smoke; 7 | extern KDE_EXPORT void init_qt_Smoke(); 8 | 9 | class QGlobalSpace { }; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /smoke/plasma/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories( ${CMAKE_SOURCE_DIR}/smoke ${INCLUDE_INSTALL_DIR}/khexedit/ ) 3 | 4 | set(srcdir ${CMAKE_CURRENT_SOURCE_DIR}) 5 | set(KDE_PREFIX ${CMAKE_INSTALL_PREFIX}) 6 | set(qt_includes ${QT_INCLUDE_DIR}) 7 | set(kde_includes ${KDE4_INCLUDE_DIR}) 8 | if(OPENGL_FOUND AND OPENGL_GLU_FOUND) 9 | set(KDE_HAVE_GL "yes") 10 | else(OPENGL_FOUND AND OPENGL_GLU_FOUND) 11 | set(KDE_HAVE_GL "no") 12 | endif(OPENGL_FOUND AND OPENGL_GLU_FOUND) 13 | 14 | # for qtguess.pl 15 | set(qt_test_threshold 10) 16 | set(qtflags "-lQtCore -lQtGui") 17 | FOREACH(filename ${QT_INCLUDES}) 18 | set(all_includes "-I${filename} ${all_includes}") 19 | ENDFOREACH(filename) 20 | 21 | configure_file(generate.pl.cmake ${CMAKE_CURRENT_BINARY_DIR}/generate.pl @ONLY ) 22 | configure_file(qtguess.pl.cmake ${CMAKE_CURRENT_BINARY_DIR}/qtguess.pl @ONLY) 23 | 24 | # macro is defined in qt-copy/src/qbase.pri but couldn't be found by qtguess, so I append it manually 25 | file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/qtdefines "QT_NO_CAST_TO_ASCII\n") 26 | 27 | ########### next target ############### 28 | 29 | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/smokedata.cpp 30 | ${CMAKE_CURRENT_BINARY_DIR}/x_1.cpp 31 | ${CMAKE_CURRENT_BINARY_DIR}/x_2.cpp 32 | ${CMAKE_CURRENT_BINARY_DIR}/x_3.cpp 33 | ${CMAKE_CURRENT_BINARY_DIR}/x_4.cpp 34 | ${CMAKE_CURRENT_BINARY_DIR}/x_5.cpp 35 | ${CMAKE_CURRENT_BINARY_DIR}/x_6.cpp 36 | ${CMAKE_CURRENT_BINARY_DIR}/x_7.cpp 37 | ${CMAKE_CURRENT_BINARY_DIR}/x_8.cpp 38 | ${CMAKE_CURRENT_BINARY_DIR}/x_9.cpp 39 | ${CMAKE_CURRENT_BINARY_DIR}/x_10.cpp 40 | ${CMAKE_CURRENT_BINARY_DIR}/x_11.cpp 41 | ${CMAKE_CURRENT_BINARY_DIR}/x_12.cpp 42 | ${CMAKE_CURRENT_BINARY_DIR}/x_13.cpp 43 | ${CMAKE_CURRENT_BINARY_DIR}/x_14.cpp 44 | ${CMAKE_CURRENT_BINARY_DIR}/x_15.cpp 45 | ${CMAKE_CURRENT_BINARY_DIR}/x_16.cpp 46 | ${CMAKE_CURRENT_BINARY_DIR}/x_17.cpp 47 | ${CMAKE_CURRENT_BINARY_DIR}/x_18.cpp 48 | ${CMAKE_CURRENT_BINARY_DIR}/x_19.cpp 49 | ${CMAKE_CURRENT_BINARY_DIR}/x_20.cpp 50 | 51 | COMMAND ${PERL_EXECUTABLE} ARGS ${CMAKE_CURRENT_BINARY_DIR}/qtguess.pl 52 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/qtguess.pl 53 | 54 | COMMAND ${PERL_EXECUTABLE} ARGS ${CMAKE_CURRENT_BINARY_DIR}/generate.pl 55 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/generate.pl 56 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 57 | 58 | macro_add_file_dependencies( ${CMAKE_CURRENT_BINARY_DIR}/smokedata.cpp ${CMAKE_CURRENT_BINARY_DIR}/x_1.cpp ) 59 | 60 | 61 | set(smokeplasma_LIB_SRCS ${CMAKE_CURRENT_BINARY_DIR}/smokedata.cpp 62 | ${CMAKE_CURRENT_BINARY_DIR}/x_1.cpp 63 | ${CMAKE_CURRENT_BINARY_DIR}/x_2.cpp 64 | ${CMAKE_CURRENT_BINARY_DIR}/x_3.cpp 65 | ${CMAKE_CURRENT_BINARY_DIR}/x_4.cpp 66 | ${CMAKE_CURRENT_BINARY_DIR}/x_5.cpp 67 | ${CMAKE_CURRENT_BINARY_DIR}/x_6.cpp 68 | ${CMAKE_CURRENT_BINARY_DIR}/x_7.cpp 69 | ${CMAKE_CURRENT_BINARY_DIR}/x_8.cpp 70 | ${CMAKE_CURRENT_BINARY_DIR}/x_9.cpp 71 | ${CMAKE_CURRENT_BINARY_DIR}/x_10.cpp 72 | ${CMAKE_CURRENT_BINARY_DIR}/x_11.cpp 73 | ${CMAKE_CURRENT_BINARY_DIR}/x_12.cpp 74 | ${CMAKE_CURRENT_BINARY_DIR}/x_13.cpp 75 | ${CMAKE_CURRENT_BINARY_DIR}/x_14.cpp 76 | ${CMAKE_CURRENT_BINARY_DIR}/x_15.cpp 77 | ${CMAKE_CURRENT_BINARY_DIR}/x_16.cpp 78 | ${CMAKE_CURRENT_BINARY_DIR}/x_17.cpp 79 | ${CMAKE_CURRENT_BINARY_DIR}/x_18.cpp 80 | ${CMAKE_CURRENT_BINARY_DIR}/x_19.cpp 81 | ${CMAKE_CURRENT_BINARY_DIR}/x_20.cpp 82 | ) 83 | 84 | # Needed to make QSqlRelationalDelegate compile 85 | ADD_DEFINITIONS (-DQT_GUI_LIB) 86 | 87 | kde4_add_library(smokeplasma SHARED ${smokeplasma_LIB_SRCS}) 88 | 89 | target_link_libraries(smokeplasma 90 | ${QT_QTNETWORK_LIBRARY} 91 | ${QT_QTSQL_LIBRARY} 92 | ${QT_QTOPENGL_LIBRARY} 93 | ${QT_QTXML_LIBRARY} 94 | ${QT_QTSVG_LIBRARY} 95 | ${QT_QTUITOOLS_LIBRARY} 96 | ${QT_QT3SUPPORT_LIBRARY} 97 | ${KDE4_KDECORE_LIBS} 98 | ${KDE4_KDEUI_LIBS} 99 | ${KDE4_KIO_LIBS} 100 | ${KDE4_KNOTIFYCONFIG_LIBS} 101 | ${KDE4_KNEWSTUFF2_LIBS} 102 | ${KDE4_KDNSSD_LIBS} 103 | ${KDE4_KHTML_LIBS} 104 | ${KDE4_KDE3SUPPORT_LIBS} 105 | ${KDE4_KUTILS_LIBS} 106 | kmediaplayer 107 | plasma 108 | taskmanager 109 | kntlm ) 110 | 111 | set_target_properties(smokeplasma PROPERTIES VERSION 2.0.0 SOVERSION 2 ) 112 | install(TARGETS smokeplasma DESTINATION ${LIB_INSTALL_DIR} ) 113 | 114 | 115 | ########### install files ############### 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /smoke/plasma/generate_makefile_am.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use File::Basename; 4 | 5 | my $here = `pwd`; 6 | chomp $here; 7 | my $outdir = $here; 8 | my $tempfile = "$outdir/.Makefile.am.tmpfile"; 9 | 10 | # Update list of source files in $outdir/Makefile.am 11 | open( MAKEFILE, "<$outdir/Makefile.am" ) or die; 12 | my $makeFileData = ''; 13 | my $found = 0; 14 | while () { 15 | if (/^libsmokeqt_la_SOURCES/) 16 | { 17 | $found = 1; 18 | $makeFileData .= "libsmokeqt_la_SOURCES = smokedata.cpp"; 19 | } 20 | $makeFileData .= $_ if (!$found); 21 | } 22 | close MAKEFILE; 23 | 24 | die "libsmokeqt_la_SOURCES not found" if (!$found); 25 | 26 | open( MAKEFILE, ">$tempfile" ) or die; 27 | print MAKEFILE $makeFileData; 28 | 29 | my $count = 0; 30 | opendir (FILES, $outdir) or die; 31 | foreach $filename (readdir(FILES)) { 32 | if ( $filename =~ /^x_.*\.cpp$/ ) { 33 | if ( $count++ == 7 ) { 34 | $count = 0; 35 | print MAKEFILE " \\\n"; 36 | } 37 | print MAKEFILE " $filename"; 38 | } 39 | } 40 | 41 | print MAKEFILE "\n"; 42 | close MAKEFILE; 43 | closedir FILES; 44 | 45 | system "cmp -s $tempfile $outdir/Makefile.am"; 46 | if ($? >> 8) { 47 | system "cp -f $tempfile $outdir/Makefile.am"; 48 | print STDERR "Makefile.am updated.\n"; 49 | } 50 | else { 51 | print STDERR "Makefile.am unchanged.\n"; 52 | } 53 | system "rm -f $tempfile"; 54 | 55 | exit 0; 56 | -------------------------------------------------------------------------------- /smoke/plasma/hint_header_list.pl: -------------------------------------------------------------------------------- 1 | 2 | # CVS admin : run this script to compare the set of Qt headers to 3 | # the actual content of header_list 4 | 5 | $l = "header_list"; 6 | $q = $ENV{'QTDIR'} || die "QTDIR not set\n"; 7 | @h = <$q/include/*.h>; 8 | grep s|.*/(.*\.h)|$1|, @h; 9 | open(IN, $l) or die "$!: $l\n"; 10 | @old = ; 11 | chomp @old; 12 | map{ $h{$_}++ } @h; 13 | map{ $old{$_}++ } @old; 14 | map{ $diff{$_}++ unless $old{$_} } keys %h; 15 | map{ delete $diff{$_} if /^qconfig.*/ or !/^q/ } keys %diff; 16 | print "Check if any of the following headers should be added to $l:\n\n"; 17 | print join "\n", keys %diff, "\n" 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /smoke/plasma/qt_smoke.h: -------------------------------------------------------------------------------- 1 | #ifndef QT_SMOKE_H 2 | #define QT_SMOKE_H 3 | 4 | #include 5 | // Defined in smokedata.cpp, initialized by init_qt_Smoke(), used by all .cpp files 6 | extern KDE_EXPORT Smoke* qt_Smoke; 7 | extern KDE_EXPORT void init_qt_Smoke(); 8 | 9 | class QGlobalSpace { }; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /smoke/qt/configure.in.in: -------------------------------------------------------------------------------- 1 | 2 | AC_HAVE_GL 3 | KDE_HAVE_GL=yes; 4 | if test "X$GLLIB" = "X"; then 5 | KDE_HAVE_GL=no 6 | fi 7 | 8 | AC_SUBST(KDE_HAVE_GL) 9 | 10 | AC_ARG_WITH( 11 | threshold, 12 | [ --with-threshold@<:@=0..15@:>@ Smoke: Qt tests threshold Default:10 Lower=more tests], 13 | [ qt_test_threshold="$withval" ], 14 | [ qt_test_threshold=10 ] 15 | ) 16 | AC_SUBST(qt_test_threshold) 17 | 18 | if test "X$kde_build_libsmoke" = "Xqt" -o "X$kde_build_libsmoke" = "Xqt kde"; then 19 | 20 | AC_CONFIG_FILES([ smoke/qt/qtguess.pl ], [ 21 | cd smoke/qt 22 | perl qtguess.pl 23 | cd ../.. 24 | ]) 25 | AC_CONFIG_FILES([ smoke/qt/generate.pl ], [ 26 | ]) 27 | fi 28 | 29 | dnl ------- 30 | dnl Test for libqscintilla (QScintilla support) 31 | dnl ------- 32 | 33 | AC_ARG_ENABLE( 34 | qscintilla, 35 | [ --enable-qscintilla@<:@=yes|no@:>@ Smoke: build Smoke with QScintilla extention for qt @<:@default:no@:>@], 36 | [ qtextscintilla="$enableval" ], 37 | [ qtextscintilla="no" ] 38 | ) 39 | AC_SUBST(qtextscintilla) 40 | 41 | AC_DEFUN([AC_FIND_QSCINTILLA], 42 | [ 43 | AC_MSG_CHECKING([for libqscintilla]) 44 | AC_CACHE_VAL(ac_cv_lib_qscintilla, 45 | [ 46 | kde_ldflags_save="$LDFLAGS" 47 | kde_libs_save="$LIBS" 48 | kde_cxxflags_save="$CXXFLAGS" 49 | 50 | LIBS="-lqscintilla $LIBQT $LIBS" 51 | CXXFLAGS="$CXXFLAGS $all_includes" 52 | LDFLAGS="$LDFLAGS $all_libraries $USER_LDFLAGS" 53 | 54 | AC_TRY_LINK([ 55 | #include 56 | ], 57 | [ 58 | QextScintillaBase s; 59 | ], 60 | eval "ac_cv_lib_qscintilla='-lqscintilla'", 61 | eval "ac_cv_lib_qscintilla=no") 62 | 63 | LDFLAGS=$kde_ldflags_save 64 | LIBS=$kde_libs_save 65 | CXXFLAGS=$kde_cxxflags_save 66 | ]) 67 | 68 | if test ! "$ac_cv_lib_qscintilla" = no; then 69 | AC_DEFINE_UNQUOTED(HAVE_LIBQSCINTILLA, 1, [Define if you have libqscintilla]) 70 | LIBQSCINTILLA="$ac_cv_lib_qscintilla" 71 | AC_MSG_RESULT($ac_cv_lib_qscintilla) 72 | else 73 | AC_MSG_ERROR(not found. 74 | Check your installation and look into config.log) 75 | LIBQSCINTILLA="" 76 | fi 77 | AC_SUBST(LIBQSCINTILLA) 78 | ]) 79 | 80 | if test "X$qtextscintilla" = "Xyes" ; then 81 | AC_FIND_QSCINTILLA 82 | fi 83 | 84 | dnl ------- 85 | dnl Test for libQtDBus (D-Bus support) 86 | dnl ------- 87 | 88 | AC_ARG_ENABLE( 89 | qtdbus, 90 | [ --enable-qtdbus@<:@=yes|no@:>@ Smoke: build Smoke with QtDbus extention for qt @<:@default:no@:>@], 91 | [ qtdbus="$enableval" ], 92 | [ qtdbus="no" ] 93 | ) 94 | AC_SUBST(qtdbus) 95 | 96 | AC_DEFUN([AC_FIND_QTDBUS], 97 | [ 98 | AC_MSG_CHECKING([for libQtDBus]) 99 | AC_CACHE_VAL(ac_cv_lib_qtdbus, 100 | [ 101 | AC_LANG_SAVE 102 | AC_LANG_CPLUSPLUS 103 | 104 | kde_ldflags_save="$LDFLAGS" 105 | kde_libs_save="$LIBS" 106 | kde_cxxflags_save="$CXXFLAGS" 107 | 108 | LIBS="-lQtDBus $LIB_QTCORE $LIB_QTXML $LIBS" 109 | CXXFLAGS="$CXXFLAGS $all_includes -DDBUS_COMPILATION" 110 | LDFLAGS="$LDFLAGS $all_libraries $USER_LDFLAGS" 111 | 112 | AC_TRY_LINK([ 113 | #include 114 | ], 115 | [ 116 | QDBusConnection b = QDBusConnection::sessionBus(); 117 | ], 118 | eval "ac_cv_lib_qtdbus='-lQtDBus'", 119 | eval "ac_cv_lib_qtdbus=no") 120 | 121 | LDFLAGS=$kde_ldflags_save 122 | LIBS=$kde_libs_save 123 | CXXFLAGS=$kde_cxxflags_save 124 | AC_LANG_RESTORE 125 | ]) 126 | 127 | if test ! "$ac_cv_lib_qtdbus" = no; then 128 | AC_DEFINE_UNQUOTED(HAVE_LIBQTDBUS, 1, [Define if you have libdbus-qt4-1]) 129 | LIBQTDBUS="$ac_cv_lib_qtdbus" 130 | AC_MSG_RESULT($ac_cv_lib_qtdbus) 131 | else 132 | AC_MSG_ERROR(not found. 133 | Check your installation and look into config.log) 134 | LIBQTDBUS="" 135 | fi 136 | AC_SUBST(LIBQTDBUS) 137 | ]) 138 | 139 | if test "X$qtdbus" = "Xyes" ; then 140 | AC_FIND_QTDBUS 141 | fi 142 | 143 | dnl ------- 144 | dnl Test for libqwt (Scientific Plotting library) 145 | dnl ------- 146 | 147 | AC_ARG_ENABLE( 148 | qwt, 149 | [ --enable-qwt@<:@=yes|no@:>@ Smoke: build Smoke with Qwt extention for qt @<:@default:no@:>@], 150 | [ qwt="$enableval" ], 151 | [ qwt="no" ] 152 | ) 153 | AC_SUBST(qwt) 154 | 155 | AC_DEFUN([AC_FIND_QWT], 156 | [ 157 | AC_MSG_CHECKING([for libqwt]) 158 | AC_CACHE_VAL(ac_cv_lib_qwt, 159 | [ 160 | AC_LANG_SAVE 161 | AC_LANG_CPLUSPLUS 162 | 163 | kde_ldflags_save="$LDFLAGS" 164 | kde_libs_save="$LIBS" 165 | kde_cxxflags_save="$CXXFLAGS" 166 | 167 | LIBS="-lqwt $LIB_QTCORE $LIB_QTXML $LIBS" 168 | CXXFLAGS="$CXXFLAGS $all_includes" 169 | LDFLAGS="$LDFLAGS $all_libraries $USER_LDFLAGS" 170 | 171 | AC_TRY_LINK([ 172 | #include 173 | ], 174 | [ 175 | QwtPlot p; 176 | ], 177 | eval "ac_cv_lib_qwt='-lqwt'", 178 | eval "ac_cv_lib_qwt=no") 179 | 180 | LDFLAGS=$kde_ldflags_save 181 | LIBS=$kde_libs_save 182 | CXXFLAGS=$kde_cxxflags_save 183 | AC_LANG_RESTORE 184 | ]) 185 | 186 | if test ! "$ac_cv_lib_qwt" = no; then 187 | AC_DEFINE_UNQUOTED(HAVE_LIBQWT, 1, [Define if you have libqwt]) 188 | LIBQWT="$ac_cv_lib_qwt" 189 | AC_MSG_RESULT($ac_cv_lib_qwt) 190 | else 191 | AC_MSG_ERROR(not found. 192 | Check your installation and look into config.log) 193 | LIBQWT="" 194 | fi 195 | AC_SUBST(LIBQWT) 196 | ]) 197 | 198 | if test "X$qwt" = "Xyes" ; then 199 | AC_FIND_QWT 200 | fi 201 | -------------------------------------------------------------------------------- /smoke/qt/generate_makefile_am.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use File::Basename; 4 | 5 | my $here = `pwd`; 6 | chomp $here; 7 | my $outdir = $here; 8 | my $tempfile = "$outdir/.Makefile.am.tmpfile"; 9 | 10 | # Update list of source files in $outdir/Makefile.am 11 | open( MAKEFILE, "<$outdir/Makefile.am" ) or die; 12 | my $makeFileData = ''; 13 | my $found = 0; 14 | while () { 15 | if (/^libsmokeqt_la_SOURCES/) 16 | { 17 | $found = 1; 18 | $makeFileData .= "libsmokeqt_la_SOURCES = smokedata.cpp"; 19 | } 20 | $makeFileData .= $_ if (!$found); 21 | } 22 | close MAKEFILE; 23 | 24 | die "libsmokeqt_la_SOURCES not found" if (!$found); 25 | 26 | open( MAKEFILE, ">$tempfile" ) or die; 27 | print MAKEFILE $makeFileData; 28 | 29 | my $count = 0; 30 | opendir (FILES, $outdir) or die; 31 | foreach $filename (readdir(FILES)) { 32 | if ( $filename =~ /^x_.*\.cpp$/ ) { 33 | if ( $count++ == 7 ) { 34 | $count = 0; 35 | print MAKEFILE " \\\n"; 36 | } 37 | print MAKEFILE " $filename"; 38 | } 39 | } 40 | 41 | print MAKEFILE "\n"; 42 | close MAKEFILE; 43 | closedir FILES; 44 | 45 | system "cmp -s $tempfile $outdir/Makefile.am"; 46 | if ($? >> 8) { 47 | system "cp -f $tempfile $outdir/Makefile.am"; 48 | print STDERR "Makefile.am updated.\n"; 49 | } 50 | else { 51 | print STDERR "Makefile.am unchanged.\n"; 52 | } 53 | system "rm -f $tempfile"; 54 | 55 | exit 0; 56 | -------------------------------------------------------------------------------- /smoke/qt/hint_header_list.pl: -------------------------------------------------------------------------------- 1 | 2 | # CVS admin : run this script to compare the set of Qt headers to 3 | # the actual content of header_list 4 | 5 | $l = "header_list"; 6 | $q = $ENV{'QTDIR'} || die "QTDIR not set\n"; 7 | @h = <$q/include/*.h>; 8 | grep s|.*/(.*\.h)|$1|, @h; 9 | open(IN, $l) or die "$!: $l\n"; 10 | @old = ; 11 | chomp @old; 12 | map{ $h{$_}++ } @h; 13 | map{ $old{$_}++ } @old; 14 | map{ $diff{$_}++ unless $old{$_} } keys %h; 15 | map{ delete $diff{$_} if /^qconfig.*/ or !/^q/ } keys %diff; 16 | print "Check if any of the following headers should be added to $l:\n\n"; 17 | print join "\n", keys %diff, "\n" 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /smoke/qt/qscintilla2_header_list: -------------------------------------------------------------------------------- 1 | qsciapis.h 2 | qscicommand.h 3 | qscicommandset.h 4 | qscidocument.h 5 | qsciglobal.h 6 | qscilexerbash.h 7 | qscilexerbatch.h 8 | qscilexercpp.h 9 | qscilexercsharp.h 10 | qscilexercss.h 11 | qscilexerdiff.h 12 | qscilexer.h 13 | qscilexerhtml.h 14 | qscilexeridl.h 15 | qscilexerjava.h 16 | qscilexerjavascript.h 17 | qscilexerlua.h 18 | qscilexermakefile.h 19 | qscilexerperl.h 20 | qscilexerpov.h 21 | qscilexerproperties.h 22 | qscilexerpython.h 23 | qscilexerruby.h 24 | qscilexersql.h 25 | qscilexertex.h 26 | qscimacro.h 27 | qscintilla2_header_list 28 | qsciprinter.h 29 | qsciscintillabase.h 30 | qsciscintilla.h 31 | -------------------------------------------------------------------------------- /smoke/qt/qscintilla_header_list: -------------------------------------------------------------------------------- 1 | qextscintilla.h 2 | qextscintillaapis.h 3 | qextscintillabase.h 4 | qextscintillacommand.h 5 | qextscintillacommandset.h 6 | qextscintilladocument.h 7 | qextscintillaglobal.h 8 | qextscintillalexer.h 9 | qextscintillalexerbash.h 10 | qextscintillalexercpp.h 11 | qextscintillalexercsharp.h 12 | qextscintillalexerhtml.h 13 | qextscintillalexeridl.h 14 | qextscintillalexerjava.h 15 | qextscintillalexerjavascript.h 16 | qextscintillalexerlua.h 17 | qextscintillalexerperl.h 18 | qextscintillalexerpython.h 19 | qextscintillalexerruby.h 20 | qextscintillalexersql.h 21 | qextscintillamacro.h 22 | qextscintillaprinter.h 23 | -------------------------------------------------------------------------------- /smoke/qt/qt_smoke.h: -------------------------------------------------------------------------------- 1 | #ifndef QT_SMOKE_H 2 | #define QT_SMOKE_H 3 | 4 | // Don't use kdemacros.h/KDE_EXPORT here as it needs to be free of KDE dependencies 5 | #include 6 | // Defined in smokedata.cpp, initialized by init_qt_Smoke(), used by all .cpp files 7 | extern Q_DECL_EXPORT Smoke* qt_Smoke; 8 | extern Q_DECL_EXPORT void init_qt_Smoke(); 9 | 10 | class QGlobalSpace { }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /smoke/qt/qwt_header_list: -------------------------------------------------------------------------------- 1 | qwt_abstract_scale_draw.h 2 | qwt_abstract_scale.h 3 | qwt_abstract_slider.h 4 | qwt_analog_clock.h 5 | qwt_array.h 6 | qwt_arrow_button.h 7 | qwt_color_map.h 8 | qwt_compass.h 9 | qwt_compass_rose.h 10 | qwt_counter.h 11 | qwt_curve_fitter.h 12 | qwt_data.h 13 | qwt_dial.h 14 | qwt_dial_needle.h 15 | qwt_double_interval.h 16 | qwt_double_range.h 17 | qwt_double_rect.h 18 | qwt_dyngrid_layout.h 19 | qwt_event_pattern.h 20 | qwt_global.h 21 | qwt.h 22 | qwt_interval_data.h 23 | qwt_knob.h 24 | qwt_layout_metrics.h 25 | qwt_legend.h 26 | qwt_legend_item.h 27 | qwt_math.h 28 | qwt_paint_buffer.h 29 | qwt_painter.h 30 | qwt_panner.h 31 | qwt_picker.h 32 | qwt_picker_machine.h 33 | qwt_plot_canvas.h 34 | qwt_plot_curve.h 35 | qwt_plot_dict.h 36 | qwt_plot_grid.h 37 | qwt_plot.h 38 | qwt_plot_item.h 39 | qwt_plot_layout.h 40 | qwt_plot_magnifier.h 41 | qwt_plot_marker.h 42 | qwt_plot_panner.h 43 | qwt_plot_picker.h 44 | qwt_plot_printfilter.h 45 | qwt_plot_rasteritem.h 46 | qwt_plot_spectrogram.h 47 | qwt_plot_zoomer.h 48 | qwt_polygon.h 49 | qwt_raster_data.h 50 | qwt_rect.h 51 | qwt_round_scale_draw.h 52 | qwt_scale_div.h 53 | qwt_scale_draw.h 54 | qwt_scale_engine.h 55 | qwt_scale_map.h 56 | qwt_scale_widget.h 57 | qwt_slider.h 58 | qwt_spline.h 59 | qwt_symbol.h 60 | qwt_text_engine.h 61 | qwt_text.h 62 | qwt_text_label.h 63 | qwt_text_plugin.h 64 | qwt_thermo.h 65 | qwt_valuelist.h 66 | qwt_wheel.h 67 | -------------------------------------------------------------------------------- /smoke/qt/smokeqt.pro: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # Automatically generated by qmake (2.00a) lun 17. abr 22:10:08 2006 3 | ###################################################################### 4 | 5 | QT += network xml sql opengl svg uitools 6 | TEMPLATE = lib 7 | TARGET += 8 | DEPENDPATH += . 9 | INCLUDEPATH += . 10 | INCLUDEPATH += .. 11 | 12 | # Add a 'qdbus' option if building with QtDBus: 13 | CONFIG += uitools 14 | 15 | DEFINES += QT_NO_DEBUG_STREAM 16 | 17 | # Input 18 | HEADERS += qt_smoke.h 19 | SOURCES += smokedata.cpp \ 20 | x_1.cpp \ 21 | x_10.cpp \ 22 | x_11.cpp \ 23 | x_12.cpp \ 24 | x_13.cpp \ 25 | x_14.cpp \ 26 | x_15.cpp \ 27 | x_16.cpp \ 28 | x_17.cpp \ 29 | x_18.cpp \ 30 | x_19.cpp \ 31 | x_2.cpp \ 32 | x_20.cpp \ 33 | x_3.cpp \ 34 | x_4.cpp \ 35 | x_5.cpp \ 36 | x_6.cpp \ 37 | x_7.cpp \ 38 | x_8.cpp \ 39 | x_9.cpp 40 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories( 3 | ${QT_INCLUDE_DIR} 4 | ${CMAKE_SOURCE_DIR}/smoke 5 | ${CMAKE_CURRENT_SOURCE_DIR} 6 | ${PHP5_INCLUDE_DIR} 7 | ${PHP5_MAIN_INCLUDE_DIR} 8 | ${PHP5_TSRM_INCLUDE_DIR} 9 | ${PHP5_ZEND_INCLUDE_DIR} 10 | ${PHP5_REGEX_INCLUDE_DIR} 11 | ${PHP5_EXT_INCLUDE_DIR} 12 | ${PHP5_DATE_INCLUDE_DIR} 13 | ${PHP5_STANDARD_INCLUDE_DIR} 14 | ) 15 | 16 | set(phpqt_LIB_SRCS 17 | functions.cpp 18 | php_qt.cpp 19 | zend_handlers.cpp 20 | phpqt_internals.cpp 21 | smokephp.cpp 22 | qstring.cpp 23 | marshall_types.cpp 24 | handlers.cpp 25 | context.cpp 26 | ) 27 | 28 | add_library(php_qt MODULE ${phpqt_LIB_SRCS}) 29 | 30 | target_link_libraries(php_qt 31 | ${QT_QTCORE_LIBRARY} 32 | ${QT_QTSVG_LIBRARY} 33 | ${QT_QTGUI_LIBRARY} 34 | ${QT_QTNETWORK_LIBRARY} 35 | ${QT_QTSQL_LIBRARY} 36 | ${QT_QTOPENGL_LIBRARY} 37 | ${QT_QTXML_LIBRARY} 38 | ${QT_QTUITOOLS_LIBRARY} 39 | ${QTDBUS_LIBRARY} 40 | ${QSCINTILLA_LIBRARIES} 41 | ${QWT_LIBRARIES} 42 | smokeqt) 43 | set_target_properties(php_qt PROPERTIES PREFIX "") 44 | 45 | IF(APPLE) 46 | set_target_properties(php_qt PROPERTIES PREFIX "" LINK_FLAGS ${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} SUFFIX ".so") 47 | ENDIF(APPLE) 48 | 49 | install(TARGETS php_qt DESTINATION ${PHP5_EXTENSION_DIR}/ ) 50 | -------------------------------------------------------------------------------- /src/context.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * PHP-Qt - The PHP language bindings for Qt 3 | * 4 | * Copyright (C) 2006 - 2007 5 | * Thomas Moenicke 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | */ 22 | 23 | #include "context.h" 24 | 25 | Context* Context::m_Context = 0; 26 | 27 | void Context::createContext() 28 | { 29 | m_Context = new Context; 30 | } 31 | 32 | void Context::destroyContext() 33 | { 34 | delete m_Context; 35 | } 36 | 37 | void 38 | Context::setActiveCe(zend_class_entry* ce) 39 | { 40 | m_Context->m_activeCe = ce; 41 | } 42 | 43 | zend_class_entry* 44 | Context::activeCe() 45 | { 46 | return m_Context->m_activeCe; 47 | } 48 | 49 | zval* 50 | Context::activeScope() 51 | { 52 | return m_Context->m_activeScope; 53 | } 54 | 55 | void 56 | Context::setActiveScope(zval* zval_ptr) 57 | { 58 | m_Context->m_activeScope = zval_ptr; 59 | } 60 | 61 | void 62 | Context::setParentCall(bool pc) 63 | { 64 | m_Context->m_parentCall = pc; 65 | } 66 | 67 | bool 68 | Context::parentCall() 69 | { 70 | return m_Context->m_parentCall; 71 | } 72 | 73 | void 74 | Context::setMethodName(const char* name) 75 | { 76 | m_Context->m_methodNameStack.push( new QByteArray(name) ); 77 | } 78 | 79 | void 80 | Context::removeMethodName() 81 | { 82 | m_Context->m_methodNameStack.pop(); 83 | } 84 | 85 | QByteArray* 86 | Context::methodName() 87 | { 88 | return m_Context->m_methodNameStack.top(); 89 | } 90 | 91 | const char* 92 | Context::methodNameC() 93 | { 94 | return m_Context->m_methodNameStack.top()->constData(); 95 | } 96 | -------------------------------------------------------------------------------- /src/context.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CONTEXT_H 3 | #define CONTEXT_H 4 | 5 | #include 6 | #include 7 | #include "zend.h" 8 | 9 | /*! 10 | * API to access to some context settings 11 | */ 12 | 13 | class Context 14 | { 15 | static Context* m_Context; 16 | 17 | QStack m_methodNameStack; 18 | zend_class_entry* m_activeCe; 19 | zval* m_activeScope; 20 | bool m_parentCall; 21 | 22 | Context(){}; 23 | ~Context(){}; 24 | 25 | public: 26 | static void createContext(); 27 | static void destroyContext(); 28 | 29 | static zend_class_entry* activeCe(); 30 | static zval* activeScope(); 31 | static bool parentCall(); 32 | static void removeMethodName(); 33 | static QByteArray* methodName(); 34 | static const char* methodNameC(); 35 | 36 | static void setActiveCe(zend_class_entry* activeCePtr); 37 | static void setActiveScope(zval* zval_ptr); 38 | static void setParentCall(bool pc); 39 | static void setMethodName(const char* name); 40 | 41 | }; 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /src/marshall.h: -------------------------------------------------------------------------------- 1 | #ifndef MARSHALL_H 2 | #define MARSHALL_H 3 | 4 | #include "smoke.h" 5 | #include 6 | 7 | class SmokeType; 8 | 9 | class Marshall { 10 | public: 11 | /** 12 | * FromZVAL is used for virtual function return ce_ptrs and regular 13 | * method arguments. 14 | * 15 | * ToZVAL is used for method return-values and virtual function 16 | * arguments. 17 | */ 18 | typedef void (*HandlerFn)(Marshall *); 19 | enum Action { FromZVAL, ToZVAL }; 20 | virtual SmokeType type() = 0; 21 | virtual Action action() = 0; 22 | virtual Smoke::StackItem &item() = 0; 23 | virtual zval* var() = 0; 24 | virtual zval* var(zval* zval_ptr) = 0; 25 | virtual void unsupported() = 0; 26 | virtual Smoke *smoke() = 0; 27 | virtual bool doAlloc() { return false; } 28 | /** 29 | * For return-values, next() does nothing. 30 | * For FromRV, next() calls the method and returns. 31 | * For ToRV, next() calls the virtual function and returns. 32 | * 33 | * Required to reset Marshall object to the state it was 34 | * before being called when it returns. 35 | */ 36 | virtual void next() = 0; 37 | /** 38 | * For FromSV, cleanup() returns false when the handler should free 39 | * any allocated memory after next(). 40 | * 41 | * For ToSV, cleanup() returns true when the handler should delete 42 | * the pointer passed to it. 43 | */ 44 | virtual bool cleanup() = 0; 45 | 46 | virtual ~Marshall() {} 47 | 48 | /** returns a pointer to the return value pointer, we need that for 49 | * overriding the return value defined by ZEND 50 | */ 51 | virtual zval** return_value_ptr() = 0; 52 | 53 | }; 54 | 55 | class SmokeEnumWrapper { 56 | public: 57 | Marshall *m; 58 | }; 59 | 60 | class SmokeClassWrapper { 61 | public: 62 | Marshall *m; 63 | }; 64 | 65 | struct TypeHandler { 66 | const char *name; 67 | Marshall::HandlerFn fn; 68 | }; 69 | 70 | class smokephp_object; 71 | void* construct_copy(smokephp_object* o); 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/phpqt_internals.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * PHP-Qt - The PHP language bindings for Qt 3 | * 4 | * Copyright (C) 2006 - 2007 5 | * Thomas Moenicke 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | */ 22 | 23 | #ifndef PHPQT_INTERNALS_H 24 | #define PHPQT_INTERNALS_H 25 | 26 | class QMetaObject; 27 | class QString; 28 | 29 | #include "php_qt.h" 30 | 31 | namespace PHPQt 32 | { 33 | 34 | void destroyHashtable(zend_rsrc_list_entry *rsrc); 35 | 36 | zval* callPHPMethod(const zval* zend_ptr, const char* methodname, const zend_uint param_count, zval** params); 37 | bool methodExists(const zend_class_entry* ce_ptr, const char* methodname); 38 | bool getMocData(zval* this_ptr, const char* classname, const QMetaObject* superdata, QString* meta_stringdata, uint* signature); 39 | void createMetaObject(smokephp_object* o, zval* this_ptr); 40 | int metacall(smokephp_object* this_ptr, Smoke::StackItem* args, QMetaObject::Call _c, int _id, void **_a); 41 | const char* checkForOperator(const char* fname); 42 | 43 | void* getQtObjectFromZval(const zval* this_ptr); 44 | smokephp_object* getSmokePHPObjectFromZval(const zval* this_ptr); 45 | smokephp_object* getSmokePHPObjectFromQt(const void* QtPtr); 46 | void setSmokePHPObject(smokephp_object* o); 47 | bool SmokePHPObjectExists(const zval* this_ptr); 48 | bool SmokePHPObjectExists(const void* ptr); 49 | 50 | bool unmapSmokePHPObject(const zval* o); 51 | 52 | smokephp_object* createObject(zval* zval_ptr, const void* ptr, const zend_class_entry* ce = 0, const Smoke::Index classId = 0); 53 | smokephp_object* cloneObject(zval* zval_ptr, smokephp_object* so, const void* copyPtr); 54 | smokephp_object* createOriginal(zval* zval_ptr, void* ptr); 55 | 56 | /*! 57 | * API to access to some context settings 58 | */ 59 | /* 60 | class Context 61 | { 62 | 63 | static Context* m_Context; 64 | 65 | QStack m_methodNameStack; 66 | zend_class_entry* m_activeCe; 67 | zval* m_activeScope; 68 | bool m_parentCall; 69 | 70 | Context(); 71 | ~Context(); 72 | public: 73 | static void createContext(){ m_Context = new Context; } 74 | static void destroyContext(); 75 | 76 | static zend_class_entry* activeCe(); 77 | static zval* activeScope(); 78 | static bool parentCall(); 79 | static void removeMethodName(); 80 | static QByteArray* methodName(); 81 | static const char* methodNameC(); 82 | 83 | static void setActiveCe(zend_class_entry* activeCePtr); 84 | static void setActiveScope(zval* zval_ptr); 85 | static void setParentCall(bool pc); 86 | static void setMethodName(const char* name); 87 | 88 | }; // class PHPQt::Context 89 | */ 90 | }; // namespace PHPQt 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /src/qstring.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * PHP-Qt - The PHP language bindings for Qt 3 | * 4 | * Copyright (C) 2006 - 2007 5 | * Thomas Moenicke 6 | * Katrina Niolet 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation; either version 2 11 | * of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | * 22 | */ 23 | 24 | extern "C" { 25 | 26 | ZEND_METHOD(QString, __toString); 27 | ZEND_METHOD(QString, compare); 28 | ZEND_METHOD(QString, utf16); 29 | ZEND_METHOD(QString, constData); 30 | ZEND_METHOD(QString, insert); 31 | ZEND_METHOD(QString, clear); 32 | ZEND_METHOD(QString, setUtf16); 33 | ZEND_METHOD(QString, prepend); 34 | ZEND_METHOD(QString, trimmed); 35 | ZEND_METHOD(QString, chop); 36 | ZEND_METHOD(QString, leftJustified); 37 | ZEND_METHOD(QString, squeeze); 38 | ZEND_METHOD(QString, count); 39 | ZEND_METHOD(QString, fromAscii); 40 | ZEND_METHOD(QString, toLongLong); 41 | ZEND_METHOD(QString, toUpper); 42 | ZEND_METHOD(QString, __construct); 43 | ZEND_METHOD(QString, normalized); 44 | ZEND_METHOD(QString, fromUtf16); 45 | ZEND_METHOD(QString, isRightToLeft); 46 | ZEND_METHOD(QString, setNum); 47 | ZEND_METHOD(QString, endsWith); 48 | ZEND_METHOD(QString, number); 49 | ZEND_METHOD(QString, localeAwareCompare); 50 | ZEND_METHOD(QString, section); 51 | ZEND_METHOD(QString, isSimpleText); 52 | ZEND_METHOD(QString, size); 53 | ZEND_METHOD(QString, simplified); 54 | ZEND_METHOD(QString, toUInt); 55 | ZEND_METHOD(QString, toUShort); 56 | ZEND_METHOD(QString, truncate); 57 | ZEND_METHOD(QString, toAscii); 58 | ZEND_METHOD(QString, length); 59 | ZEND_METHOD(QString, right); 60 | ZEND_METHOD(QString, push_front); 61 | ZEND_METHOD(QString, toUtf8); 62 | ZEND_METHOD(QString, toULongLong); 63 | ZEND_METHOD(QString, indexOf); 64 | ZEND_METHOD(QString, fromRawData); 65 | ZEND_METHOD(QString, constEnd); 66 | ZEND_METHOD(QString, left); 67 | ZEND_METHOD(QString, fromLocal8Bit); 68 | ZEND_METHOD(QString, startsWith); 69 | ZEND_METHOD(QString, remove); 70 | ZEND_METHOD(QString, isEmpty); 71 | ZEND_METHOD(QString, arg); 72 | ZEND_METHOD(QString, vsprintf); 73 | ZEND_METHOD(QString, toFloat); 74 | ZEND_METHOD(QString, isDetached); 75 | ZEND_METHOD(QString, reserve); 76 | ZEND_METHOD(QString, toULong); 77 | ZEND_METHOD(QString, toShort); 78 | ZEND_METHOD(QString, split); 79 | ZEND_METHOD(QString, setUnicode); 80 | ZEND_METHOD(QString, fromLatin1); 81 | ZEND_METHOD(QString, data); 82 | ZEND_METHOD(QString, toLatin1); 83 | ZEND_METHOD(QString, end); 84 | ZEND_METHOD(QString, contains); 85 | ZEND_METHOD(QString, resize); 86 | ZEND_METHOD(QString, replace); 87 | ZEND_METHOD(QString, fromUtf8); 88 | ZEND_METHOD(QString, toLong); 89 | ZEND_METHOD(QString, detach); 90 | ZEND_METHOD(QString, append); 91 | ZEND_METHOD(QString, mid); 92 | ZEND_METHOD(QString, toDouble); 93 | ZEND_METHOD(QString, fill); 94 | ZEND_METHOD(QString, rightJustified); 95 | ZEND_METHOD(QString, toLower); 96 | ZEND_METHOD(QString, lastIndexOf); 97 | ZEND_METHOD(QString, unicode); 98 | ZEND_METHOD(QString, at); 99 | ZEND_METHOD(QString, begin); 100 | ZEND_METHOD(QString, push_back); 101 | ZEND_METHOD(QString, capacity); 102 | ZEND_METHOD(QString, constBegin); 103 | ZEND_METHOD(QString, toLocal8Bit); 104 | ZEND_METHOD(QString, toInt); 105 | ZEND_METHOD(QString, isNull); 106 | 107 | } // extern "C" 108 | -------------------------------------------------------------------------------- /src/zend_handlers.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * PHP-Qt - The PHP language bindings for Qt 3 | * 4 | * Copyright (C) 2006 5 | * Thomas Moenicke 6 | * Katrina Niolet 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation; either version 2 11 | * of the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | * 22 | */ 23 | 24 | #ifndef ZEND_HANDLERS_H 25 | #define ZEND_HANDLERS_H 26 | 27 | #include 28 | 29 | // for opcode handler 30 | #define PHPQT_OPHANDLER_COUNT ((25 * 151) + 1) 31 | #define EX__(element) execute_data->element 32 | #define EX_T(offset) (*(temp_variable *)((char *) EX__(Ts) + offset)) 33 | 34 | namespace ZendHandlers { 35 | 36 | /*! 37 | * handler for regular method calls 38 | */ 39 | 40 | union _zend_function* proxyHandler(zval **obj_ptr, char* methodName, int methodName_len TSRMLS_DC); 41 | 42 | /*! 43 | * handler for constant method calls 44 | * and for the parent:: statement too 45 | */ 46 | 47 | #undef EX 48 | #define EX(element) execute_data->element 49 | 50 | int constantMethodHandler(ZEND_OPCODE_HANDLER_ARGS); 51 | 52 | /*! 53 | * handler for constants 54 | */ 55 | 56 | int constantHandler(ZEND_OPCODE_HANDLER_ARGS); 57 | 58 | /*! 59 | * handler for cloning objects 60 | */ 61 | 62 | int cloneHandler(ZEND_OPCODE_HANDLER_ARGS); 63 | 64 | /*! 65 | * install handlers 66 | */ 67 | 68 | void installZendHandlers(); 69 | 70 | } // namespace ZendHandlers 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /tests/QStringTestCase.php: -------------------------------------------------------------------------------- 1 | assertEquals($s2->__toString(), "bird", "Could not construct QString!"); 20 | $s3 = new QString(40); // QString ( QChar ch ) 21 | $this->assertEquals($s3->__toString(), "(", "Could not construct QString!"); 22 | $s4 = new QString("helicopter"); 23 | $this->assertEquals($s4->__toString(), "helicopter", "Could not construct QString!"); 24 | // $s5 = new QString(40,3); 25 | // $this->assertEquals($s5->__toString(), "(((", "Could not construct QString!"); 26 | echo "\ntesting QString::__construct() passed"; 27 | } 28 | 29 | function test_append() { 30 | $s1 = new QString("bird"); 31 | $s2 = new QString(" plug"); 32 | $s1->append($s2); 33 | $this->assertEquals($s1->__toString(), "bird plug", "Could not append QString to QString!"); 34 | $s1->append(" helicopter"); 35 | $this->assertEquals($s1->__toString(), "bird plug helicopter", "Could not append string to QString!"); 36 | $s1->append(40); 37 | $this->assertEquals($s1->__toString(), "bird plug helicopter(", "Could not append QChar to QString!"); 38 | echo "\ntesting QString::append() passed"; 39 | } 40 | 41 | function test_toInt() { 42 | $s1 = new QString("24"); 43 | $this->assertEquals($s1->toInt(), 24, "Could not get integer!"); 44 | echo "\ntesting QString::toInt() passed"; 45 | } 46 | 47 | function test_toDouble() { 48 | $s1 = new QString("24.3"); 49 | $this->assertEquals($s1->toDouble(), 24.3, "Could not get double!"); 50 | echo "\ntesting QString::toDouble() passed"; 51 | } 52 | 53 | function test_number() { 54 | $this->assertEquals(QString::number(24)->__toString(), "24", "Could not get string version of integer!"); 55 | $this->assertEquals(QString::number(24.3)->__toString(), "24.3", "Could not get string version of double!"); 56 | echo "\ntesting QString::number() passed"; 57 | } 58 | 59 | function test_isEmpty() { 60 | $s1 = new QString(); 61 | $this->assertTrue($s1->isEmpty(), "Could not ask isEmpty()!"); 62 | $s1->append("I"); 63 | $this->assertFalse($s1->isEmpty(), "Could not ask isEmpty()!"); 64 | echo "\ntesting QString::isEmpty() passed"; 65 | } 66 | 67 | function test_clear() { 68 | $s1 = new QString("hello"); 69 | $s1->clear(); 70 | $this->assertEquals($s1->__toString(), "", "Could not clear()!"); 71 | echo "\ntesting QString::clear() passed"; 72 | } 73 | 74 | } 75 | 76 | ?> -------------------------------------------------------------------------------- /tests/QtAdvancedTestCase.php: -------------------------------------------------------------------------------- 1 | myProperty = $p; 20 | } 21 | } 22 | 23 | class myColor2 extends QColor { 24 | public $myProperty; 25 | public function __construct($r,$g,$b,$p) { 26 | parent::__construct($r,$g,$b); 27 | $this->myProperty = $p; 28 | } 29 | public function __clone() 30 | { 31 | $this->myProperty = $this->myProperty * 2; 32 | } 33 | } 34 | 35 | $app = new QApplication($argc, $argv); 36 | 37 | class QtAdvancedTestCase extends PHPUnit_Framework_TestCase { 38 | 39 | public function __construct($name) { 40 | parent::__construct($name); 41 | } 42 | 43 | // test references 44 | function testReference() { 45 | $a = new QPushButton("a text"); 46 | $b = &$a; // create the reference 47 | $a->setText("text changed"); 48 | echo "\ntesting reference"; 49 | $this->assertEquals($b->text()->__toString(), "text changed", "Creating a reference does not work!"); 50 | echo " passed"; 51 | } 52 | 53 | // test cloning, change the original and check the clone 54 | function testClone() { 55 | $a = new QColor(100,200,255); 56 | $b = clone $a; // create the reference 57 | $a->setBlue(123); 58 | echo "\ntesting clone"; 59 | $this->assertEquals($b->blue(), 255, "Cloning an object does not work!"); 60 | echo " passed (check clone)"; 61 | } 62 | 63 | // test cloning, change the clone and test the original 64 | function testClone2() { 65 | $a = new QColor(100,200,255); 66 | $b = clone $a; // create the reference 67 | echo "\ntesting clone"; 68 | $b->setRed(75); 69 | $this->assertEquals($a->red(), 100, "Cloning an object does not work (error: original has changed)!"); 70 | echo " passed (check original)"; 71 | } 72 | 73 | // test cloning a custom object, change the original and test the clone 74 | function testClone3() { 75 | $a = new myColor(100,200,255,24); 76 | $b = clone $a; // create the reference 77 | echo "\ntesting clone"; 78 | $this->assertEquals($b->myProperty, 24, "Cloning a selfwritten object does not work (error: property has changed)!"); 79 | echo " passed (check childs)"; 80 | } 81 | 82 | // test cloning a custom object, overwrite the __clone magic method and test the clone 83 | function testClone4() { 84 | $a = new myColor2(100,200,255,24); 85 | $b = clone $a; // create the reference 86 | echo "\ntesting clone"; 87 | $this->assertEquals($b->myProperty, 48, "Cloning a selfwritten object does not work (error: __clone() was not called)!"); 88 | echo " passed (check __clone())"; 89 | } 90 | 91 | // test cloning a custom object, overwrite the __clone magic method and test the original 92 | function testClone5() { 93 | $a = new myColor2(100,200,255,24); 94 | $b = clone $a; // create the reference 95 | echo "\ntesting clone"; 96 | $this->assertEquals($a->myProperty, 24, "Cloning a selfwritten object does not work (error: original has been modified)!"); 97 | echo " passed (check original after __clone())"; 98 | } 99 | 100 | } // end test 101 | 102 | ?> -------------------------------------------------------------------------------- /tests/QtApplicationTestCase.php: -------------------------------------------------------------------------------- 1 | button = new QPushButton(tr("quit"), $this); 35 | $this->connect($this->button, SIGNAL('clicked()'), QCoreApplication::instance(), SLOT('quit()')); 36 | } 37 | 38 | } 39 | 40 | class QtApplicationTestCase extends PHPUnit_Framework_TestCase { 41 | 42 | private $app; 43 | 44 | public function __construct($name) { 45 | parent::__construct($name); 46 | $argc=1; 47 | $argv=array("argv"); 48 | $this->app = new QApplication($argc,$argv); 49 | } 50 | 51 | // try to get the same object 52 | function testObjectBack() { 53 | echo "\ntesting getting object back"; 54 | $this->assertEquals(is_object(QApplication::instance()), true, "Could not fetch instance of QApplication!"); 55 | // we need this, otherwise ZE would destroy $app too early 56 | QTimer::singleShot(100,QApplication::instance(),SLOT("quit()")); 57 | echo " passed"; 58 | } 59 | 60 | // try to create and check a reference 61 | function testReference() { 62 | echo "\ntesting getting a reference"; 63 | /* $argc=1; 64 | $argv=array("argv"); 65 | $app = new QApplication($argc,$argv); 66 | */ 67 | // set the object name to 'original' 68 | $this->app->setObjectName(new QString("original")); 69 | // create a reference 70 | $app_ref = &$this->app; 71 | // set the reference's object name 72 | $app_ref->setObjectName(new QString("reference")); 73 | // now we expect the reference name at the original 74 | $this->assertEquals($this->app->objectName()->__toString(), "reference", "Could not fetch instance of QApplication!"); 75 | QTimer::singleShot(100,$this->app,SLOT("quit()")); 76 | echo " passed"; 77 | } 78 | 79 | function testVirtualMethod() { 80 | echo "\ntesting calling a virtual method"; 81 | 82 | /* $argc=1; 83 | $argv=array("argv"); 84 | $app = new MyApplication($argc, $argv); 85 | */ 86 | $myWidget = new MyWidget(); 87 | $myWidget->show(); 88 | $this->app->exec(); 89 | 90 | echo " passed"; 91 | 92 | 93 | } 94 | 95 | function testCallingSlot() 96 | { 97 | #return; 98 | // $clickedButton = qobject_cast($this->sender(), new QToolButton()); 99 | /* 100 | $argc=1; 101 | $argv=array("argv"); 102 | $app = new MyApplication($argc, $argv); 103 | */ 104 | QTimer::singleShot(100,$this->app,SLOT("mySlot()")); 105 | print "OK"; 106 | QTimer::singleShot(100,$this->app,SLOT("quit()")); 107 | print "OK"; 108 | # $app->exec(); 109 | } 110 | 111 | } 112 | 113 | ?> -------------------------------------------------------------------------------- /tests/QtLoadModuleTestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(extension_loaded('php_qt'), "Module PHP-Qt is not loaded!"); 19 | } 20 | 21 | function testClassQt() { 22 | $this->assertTrue(class_exists('Qt'), "class Qt not found!"); 23 | } 24 | 25 | function testClassQString() { 26 | $this->assertTrue(class_exists('QString'), "class QString not found!"); 27 | } 28 | 29 | } 30 | 31 | ?> -------------------------------------------------------------------------------- /tests/QtStressTestCase.php: -------------------------------------------------------------------------------- 1 | setObjectName("hallo"); 23 | echo $i++."\n"; 24 | echo $b->objectName(); 25 | $b->__destruct(); 26 | } 27 | 28 | } 29 | 30 | } 31 | 32 | ?> -------------------------------------------------------------------------------- /tests/box2buttons.php: -------------------------------------------------------------------------------- 1 | mainWidget = $mainWidget; 17 | 18 | $this->button1 = new QPushButton("About Qt!"); 19 | $this->button2 = new QPushButton("Quit"); 20 | $this->addWidget($this->button1); 21 | $this->addWidget($this->button2); 22 | 23 | } 24 | 25 | function __destruct() 26 | { 27 | $this->button1 = 0; 28 | $this->button2 = 0; 29 | $this->mainWidget = 0; 30 | } 31 | 32 | function show() 33 | { 34 | $this->mainWidget->show(); 35 | } 36 | } 37 | 38 | 39 | $app = new QApplication($argc,$argv); 40 | 41 | $box = new Box(); 42 | $box->show(); 43 | 44 | QObject::connect($box->button1, SIGNAL("clicked()"), $app, SLOT("aboutQt()")); 45 | QObject::connect($box->button2, SIGNAL("clicked()"), $app, SLOT("quit()")); 46 | 47 | $app->exec(); 48 | 49 | ?> 50 | -------------------------------------------------------------------------------- /tests/designer.php: -------------------------------------------------------------------------------- 1 | setupUi($window); 10 | 11 | $window->show(); 12 | $app->exec(); 13 | 14 | ?> -------------------------------------------------------------------------------- /tests/qFunctions.php: -------------------------------------------------------------------------------- 1 | 132 | -------------------------------------------------------------------------------- /tests/unicode.php: -------------------------------------------------------------------------------- 1 | layout = new QVBoxLayout($this); 19 | 20 | // Load the test xml 21 | $unicodeXml = new DOMDocument(); 22 | $unicodeXml->load("unicode.xml"); 23 | $xpath = new DOMXPath($unicodeXml); 24 | $dataNodes = $xpath->query("/test/data"); 25 | 26 | // Loop on all data node and create buttons 27 | foreach($dataNodes as $data) 28 | { 29 | $this->buttons[] = new QLineEdit(QString::fromUtf8($data->nodeValue, -1),$this); 30 | 31 | foreach($data->attributes as $attribute){ 32 | $this->layout->addWidget(new QLabel($attribute->name.": ".$attribute->value)); 33 | } 34 | 35 | $this->layout->addWidget($this->buttons[count($this->buttons)-1]); 36 | } 37 | 38 | $this->buttons[] = new QLineEdit("Test",$this); 39 | $this->layout->addWidget($this->buttons[count($this->buttons)-1]); 40 | 41 | $this->buttons[] = new QLineEdit(("second Test"),$this); 42 | $this->layout->addWidget($this->buttons[count($this->buttons)-1]); 43 | 44 | } 45 | 46 | } 47 | 48 | $app = new QApplication($argc,$argv); 49 | $widget = new TestButtons(); 50 | $widget->show(); 51 | $app->exec(); 52 | 53 | ?> 54 | -------------------------------------------------------------------------------- /tests/unicode.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | This is a test text 4 | Árvíztűrő tükörfúrógép 5 | これはテストテキストである 6 | 이것은 시험 원본 이다 7 | Это будет текст испытания 8 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(uic) 2 | 3 | 4 | -------------------------------------------------------------------------------- /tools/uic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) 2 | include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/php ) 3 | 4 | ########### next target ############### 5 | 6 | set(uic_bin_SRCS 7 | customwidgetsinfo.cpp 8 | databaseinfo.cpp 9 | driver.cpp 10 | treewalker.cpp 11 | ui4.cpp 12 | uic.cpp 13 | validator.cpp 14 | ${CMAKE_CURRENT_SOURCE_DIR}/php/phpextractimages.cpp # remove 15 | ${CMAKE_CURRENT_SOURCE_DIR}/php/phpwritedeclaration.cpp 16 | ${CMAKE_CURRENT_SOURCE_DIR}/php/phpwriteincludes.cpp 17 | ${CMAKE_CURRENT_SOURCE_DIR}/php/phpwriteicondata.cpp 18 | ${CMAKE_CURRENT_SOURCE_DIR}/php/phpwriteicondeclaration.cpp 19 | ${CMAKE_CURRENT_SOURCE_DIR}/php/phpwriteiconinitialization.cpp 20 | ${CMAKE_CURRENT_SOURCE_DIR}/php/phpwriteinitialization.cpp 21 | main.cpp ) 22 | 23 | add_executable(uic_bin ${uic_bin_SRCS}) 24 | set_target_properties(uic_bin PROPERTIES OUTPUT_NAME uicp) 25 | set_target_properties(uic_bin PROPERTIES COMPILE_FLAGS -DQT_UIC_PHP_GENERATOR) 26 | 27 | target_link_libraries(uic_bin ${QT_QTCORE_LIBRARY} ${QT_QTXML_LIBRARY} ) 28 | 29 | install(TARGETS uic_bin DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) 30 | 31 | 32 | ########### next target ############### 33 | 34 | 35 | ########### install files ############### 36 | -------------------------------------------------------------------------------- /tools/uic/customwidgetsinfo.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #include "customwidgetsinfo.h" 25 | #include "driver.h" 26 | #include "ui4.h" 27 | #include "utils.h" 28 | 29 | CustomWidgetsInfo::CustomWidgetsInfo() 30 | { 31 | } 32 | 33 | void CustomWidgetsInfo::acceptUI(DomUI *node) 34 | { 35 | m_customWidgets.clear(); 36 | 37 | if (node->elementCustomWidgets()) 38 | acceptCustomWidgets(node->elementCustomWidgets()); 39 | } 40 | 41 | void CustomWidgetsInfo::acceptCustomWidgets(DomCustomWidgets *node) 42 | { 43 | TreeWalker::acceptCustomWidgets(node); 44 | } 45 | 46 | void CustomWidgetsInfo::acceptCustomWidget(DomCustomWidget *node) 47 | { 48 | if (node->elementClass().isEmpty()) 49 | return; 50 | 51 | m_customWidgets.insert(node->elementClass(), node); 52 | } 53 | 54 | bool CustomWidgetsInfo::extends(const QString &className, const QString &baseClassName) const 55 | { 56 | if (className == baseClassName) 57 | return true; 58 | 59 | if (DomCustomWidget *c = customWidget(className)) 60 | return c->elementExtends() == baseClassName; 61 | 62 | return false; 63 | } 64 | 65 | QString CustomWidgetsInfo::realClassName(const QString &className) const 66 | { 67 | if (className == QLatin1String("Line")) 68 | return QLatin1String("QFrame"); 69 | 70 | return className; 71 | } 72 | 73 | DomScript *CustomWidgetsInfo::customWidgetScript(const QString &name) const 74 | { 75 | if (m_customWidgets.empty()) 76 | return 0; 77 | 78 | const NameCustomWidgetMap::const_iterator it = m_customWidgets.constFind(name); 79 | if (it == m_customWidgets.constEnd()) 80 | return 0; 81 | 82 | return it.value()->elementScript(); 83 | } 84 | -------------------------------------------------------------------------------- /tools/uic/customwidgetsinfo.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef CUSTOMWIDGETSINFO_H 25 | #define CUSTOMWIDGETSINFO_H 26 | 27 | #include "treewalker.h" 28 | #include 29 | #include 30 | 31 | class Driver; 32 | class DomScript; 33 | 34 | class CustomWidgetsInfo : public TreeWalker 35 | { 36 | public: 37 | CustomWidgetsInfo(); 38 | 39 | void acceptUI(DomUI *node); 40 | 41 | void acceptCustomWidgets(DomCustomWidgets *node); 42 | void acceptCustomWidget(DomCustomWidget *node); 43 | 44 | inline QStringList customWidgets() const 45 | { return m_customWidgets.keys(); } 46 | 47 | inline bool hasCustomWidget(const QString &name) const 48 | { return m_customWidgets.contains(name); } 49 | 50 | inline DomCustomWidget *customWidget(const QString &name) const 51 | { return m_customWidgets.value(name); } 52 | 53 | DomScript *customWidgetScript(const QString &name) const; 54 | 55 | QString realClassName(const QString &className) const; 56 | 57 | bool extends(const QString &className, const QString &baseClassName) const; 58 | 59 | private: 60 | typedef QMap NameCustomWidgetMap; 61 | NameCustomWidgetMap m_customWidgets; 62 | bool m_scriptsActivated; 63 | }; 64 | 65 | #endif // CUSTOMWIDGETSINFO_H 66 | -------------------------------------------------------------------------------- /tools/uic/databaseinfo.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #include "databaseinfo.h" 25 | #include "driver.h" 26 | #include "ui4.h" 27 | #include "utils.h" 28 | 29 | DatabaseInfo::DatabaseInfo(Driver *drv) 30 | : driver(drv) 31 | { 32 | } 33 | 34 | void DatabaseInfo::acceptUI(DomUI *node) 35 | { 36 | m_connections.clear(); 37 | m_cursors.clear(); 38 | m_fields.clear(); 39 | 40 | TreeWalker::acceptUI(node); 41 | 42 | m_connections = unique(m_connections); 43 | } 44 | 45 | void DatabaseInfo::acceptWidget(DomWidget *node) 46 | { 47 | QHash properties = propertyMap(node->elementProperty()); 48 | 49 | DomProperty *frameworkCode = properties.value(QLatin1String("frameworkCode"), 0); 50 | if (frameworkCode && toBool(frameworkCode->elementBool()) == false) 51 | return; 52 | 53 | DomProperty *db = properties.value(QLatin1String("database"), 0); 54 | if (db && db->elementStringList()) { 55 | QStringList info = db->elementStringList()->elementString(); 56 | 57 | QString connection = info.size() > 0 ? info.at(0) : QString(); 58 | if (connection.isEmpty()) 59 | return; 60 | m_connections.append(connection); 61 | 62 | QString table = info.size() > 1 ? info.at(1) : QString(); 63 | if (table.isEmpty()) 64 | return; 65 | m_cursors[connection].append(table); 66 | 67 | QString field = info.size() > 2 ? info.at(2) : QString(); 68 | if (field.isEmpty()) 69 | return; 70 | m_fields[connection].append(field); 71 | } 72 | 73 | TreeWalker::acceptWidget(node); 74 | } 75 | 76 | -------------------------------------------------------------------------------- /tools/uic/databaseinfo.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef DATABASEINFO_H 25 | #define DATABASEINFO_H 26 | 27 | #include "treewalker.h" 28 | #include 29 | #include 30 | 31 | class Driver; 32 | 33 | class DatabaseInfo : public TreeWalker 34 | { 35 | public: 36 | DatabaseInfo(Driver *driver); 37 | 38 | void acceptUI(DomUI *node); 39 | void acceptWidget(DomWidget *node); 40 | 41 | inline QStringList connections() const 42 | { return m_connections; } 43 | 44 | inline QStringList cursors(const QString &connection) const 45 | { return m_cursors.value(connection); } 46 | 47 | inline QStringList fields(const QString &connection) const 48 | { return m_fields.value(connection); } 49 | 50 | private: 51 | Driver *driver; 52 | QStringList m_connections; 53 | QMap m_cursors; 54 | QMap m_fields; 55 | }; 56 | 57 | #endif // DATABASEINFO_H 58 | -------------------------------------------------------------------------------- /tools/uic/driver.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef DRIVER_H 25 | #define DRIVER_H 26 | 27 | #include "option.h" 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | class QTextStream; 34 | class DomUI; 35 | class DomWidget; 36 | class DomSpacer; 37 | class DomLayout; 38 | class DomLayoutItem; 39 | class DomActionGroup; 40 | class DomAction; 41 | 42 | class Driver 43 | { 44 | public: 45 | Driver(); 46 | virtual ~Driver(); 47 | 48 | // tools 49 | bool printDependencies(const QString &fileName); 50 | bool uic(const QString &fileName, QTextStream *output = 0); 51 | bool uic(const QString &fileName, DomUI *ui, QTextStream *output = 0); 52 | 53 | // configuration 54 | inline QTextStream &output() const { return *m_output; } 55 | inline Option &option() { return m_option; } 56 | 57 | // initialization 58 | void reset(); 59 | 60 | // error 61 | inline QStringList problems() { return m_problems; } 62 | inline void addProblem(const QString &problem) { m_problems.append(problem); } 63 | 64 | // utils 65 | static QString headerFileName(const QString &fileName); 66 | QString headerFileName() const; 67 | 68 | static QString normalizedName(const QString &name); 69 | static QString qtify(const QString &name); 70 | QString unique(const QString &instanceName=QString(), 71 | const QString &className=QString()); 72 | 73 | // symbol table 74 | QString findOrInsertWidget(DomWidget *ui_widget); 75 | QString findOrInsertSpacer(DomSpacer *ui_spacer); 76 | QString findOrInsertLayout(DomLayout *ui_layout); 77 | QString findOrInsertLayoutItem(DomLayoutItem *ui_layoutItem); 78 | QString findOrInsertName(const QString &name); 79 | QString findOrInsertActionGroup(DomActionGroup *ui_group); 80 | QString findOrInsertAction(DomAction *ui_action); 81 | 82 | inline bool hasName(const QString &name) const 83 | { return m_nameRepository.contains(name); } 84 | 85 | DomWidget *widgetByName(const QString &name) const; 86 | DomSpacer *spacerByName(const QString &name) const; 87 | DomLayout *layoutByName(const QString &name) const; 88 | DomActionGroup *actionGroupByName(const QString &name) const; 89 | DomAction *actionByName(const QString &name) const; 90 | 91 | // pixmap 92 | void insertPixmap(const QString &pixmap); 93 | bool containsPixmap(const QString &pixmap) const; 94 | 95 | private: 96 | Option m_option; 97 | QTextStream m_stdout; 98 | QTextStream *m_output; 99 | 100 | QStringList m_problems; 101 | 102 | // symbol tables 103 | QHash m_widgets; 104 | QHash m_spacers; 105 | QHash m_layouts; 106 | QHash m_actionGroups; 107 | QHash m_actions; 108 | QHash m_nameRepository; 109 | QHash m_pixmaps; 110 | }; 111 | 112 | #endif // DRIVER_H 113 | -------------------------------------------------------------------------------- /tools/uic/globaldefs.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef GLOBALDEFS_H 25 | #define GLOBALDEFS_H 26 | 27 | enum { BOXLAYOUT_DEFAULT_MARGIN = 11 }; 28 | enum { BOXLAYOUT_DEFAULT_SPACING = 6 }; 29 | 30 | #endif // GLOBALDEFS_H 31 | -------------------------------------------------------------------------------- /tools/uic/option.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef OPTION_H 25 | #define OPTION_H 26 | 27 | #include 28 | 29 | struct Option 30 | { 31 | enum Generator 32 | { 33 | PhpGenerator, 34 | CppGenerator, 35 | JavaGenerator 36 | }; 37 | 38 | unsigned int headerProtection : 1; 39 | unsigned int copyrightHeader : 1; 40 | unsigned int generateImplemetation : 1; 41 | unsigned int generateNamespace : 1; 42 | unsigned int autoConnection : 1; 43 | unsigned int dependencies : 1; 44 | unsigned int extractImages : 1; 45 | Generator generator; 46 | 47 | QString inputFile; 48 | QString outputFile; 49 | QString qrcOutputFile; 50 | QString indent; 51 | QString prefix; 52 | QString postfix; 53 | QString translateFunction; 54 | QString uic3; 55 | #ifdef QT_UIC_JAVA_GENERATOR 56 | QString javaPackage; 57 | QString javaOutputDirectory; 58 | #endif 59 | 60 | Option() 61 | : headerProtection(1), 62 | copyrightHeader(1), 63 | generateImplemetation(0), 64 | generateNamespace(1), 65 | autoConnection(1), 66 | dependencies(0), 67 | extractImages(0), 68 | generator(PhpGenerator), 69 | prefix(QLatin1String("Ui_")) 70 | { indent.fill(QLatin1Char(' '), 4); } 71 | }; 72 | 73 | #endif // OPTION_H 74 | -------------------------------------------------------------------------------- /tools/uic/php/phpextractimages.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #include 25 | #include "phpextractimages.h" 26 | #include "phpwriteicondata.h" 27 | #include "driver.h" 28 | #include "ui4.h" 29 | #include "utils.h" 30 | #include "uic.h" 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | namespace PHP { 39 | 40 | ExtractImages::ExtractImages(const Option &opt) 41 | : m_output(0), m_option(opt) 42 | { 43 | } 44 | 45 | void ExtractImages::acceptUI(DomUI *node) 46 | { 47 | if (!m_option.extractImages) 48 | return; 49 | 50 | if (node->elementImages() == 0) 51 | return; 52 | 53 | QString className = node->elementClass() + m_option.postfix; 54 | 55 | QFile f; 56 | if (m_option.qrcOutputFile.size()) { 57 | f.setFileName(m_option.qrcOutputFile); 58 | if (!f.open(QIODevice::WriteOnly | QFile::Text)) { 59 | fprintf(stderr, "Could not create resource file\n"); 60 | return; 61 | } 62 | 63 | QFileInfo fi(m_option.qrcOutputFile); 64 | QDir dir = fi.absoluteDir(); 65 | if (!dir.exists("images") && !dir.mkdir("images")) { 66 | fprintf(stderr, "Could not create image dir\n"); 67 | return; 68 | } 69 | dir.cd("images"); 70 | m_imagesDir = dir; 71 | 72 | m_output = new QTextStream(&f); 73 | m_output->setCodec(QTextCodec::codecForName("UTF-8")); 74 | 75 | QTextStream &out = *m_output; 76 | 77 | out << "\n"; 78 | out << " \n"; 79 | TreeWalker::acceptUI(node); 80 | out << " \n"; 81 | out << "\n"; 82 | 83 | f.close(); 84 | delete m_output; 85 | m_output = 0; 86 | } 87 | } 88 | 89 | void ExtractImages::acceptImages(DomImages *images) 90 | { 91 | TreeWalker::acceptImages(images); 92 | } 93 | 94 | void ExtractImages::acceptImage(DomImage *image) 95 | { 96 | QString format = image->elementData()->attributeFormat(); 97 | QString extension = format.left(format.indexOf('.')).toLower(); 98 | QString fname = m_imagesDir.absoluteFilePath(image->attributeName() + QLatin1Char('.') + extension); 99 | 100 | *m_output << " images/" << image->attributeName() << QLatin1Char('.') + extension << "\n"; 101 | 102 | QFile f; 103 | f.setFileName(fname); 104 | if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) { 105 | fprintf(stderr, "Could not create image file\n"); 106 | return; 107 | } 108 | 109 | if (format == QLatin1String("XPM.GZ")) { 110 | QTextStream *imageOut = new QTextStream(&f); 111 | imageOut->setCodec(QTextCodec::codecForName("UTF-8")); 112 | 113 | PHP::WriteIconData::writeImage(*imageOut, QString(), image); 114 | delete imageOut; 115 | } else { 116 | PHP::WriteIconData::writeImage(f, image); 117 | } 118 | 119 | f.close(); 120 | } 121 | 122 | } // namespace PHP 123 | -------------------------------------------------------------------------------- /tools/uic/php/phpextractimages.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef CPPEXTRACTIMAGES_H 25 | #define CPPEXTRACTIMAGES_H 26 | 27 | #include "treewalker.h" 28 | #include 29 | 30 | class QTextStream; 31 | class Driver; 32 | class Uic; 33 | 34 | struct Option; 35 | 36 | namespace PHP { 37 | 38 | class ExtractImages : public TreeWalker 39 | { 40 | public: 41 | ExtractImages(const Option &opt); 42 | 43 | void acceptUI(DomUI *node); 44 | void acceptImages(DomImages *images); 45 | void acceptImage(DomImage *image); 46 | 47 | private: 48 | QTextStream *m_output; 49 | const Option &m_option; 50 | QDir m_imagesDir; 51 | }; 52 | 53 | } // namespace PHP 54 | 55 | #endif // CPPEXTRACTIMAGES_H 56 | -------------------------------------------------------------------------------- /tools/uic/php/phpwritedeclaration.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef CPPWRITEDECLARATION_H 25 | #define CPPWRITEDECLARATION_H 26 | 27 | #include "treewalker.h" 28 | 29 | class QTextStream; 30 | class Driver; 31 | class Uic; 32 | 33 | struct Option; 34 | 35 | namespace PHP { 36 | 37 | struct WriteDeclaration : public TreeWalker 38 | { 39 | WriteDeclaration(Uic *uic, bool activateScripts); 40 | 41 | void acceptUI(DomUI *node); 42 | void acceptWidget(DomWidget *node); 43 | void acceptSpacer(DomSpacer *node); 44 | void acceptLayout(DomLayout *node); 45 | void acceptActionGroup(DomActionGroup *node); 46 | void acceptAction(DomAction *node); 47 | 48 | private: 49 | Uic *m_uic; 50 | Driver *m_driver; 51 | QTextStream &m_output; 52 | const Option &m_option; 53 | const bool m_activateScripts; 54 | }; 55 | 56 | } // namespace PHP 57 | 58 | #endif // CPPWRITEDECLARATION_H 59 | -------------------------------------------------------------------------------- /tools/uic/php/phpwriteicondata.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #include "phpwriteicondata.h" 25 | #include "driver.h" 26 | #include "ui4.h" 27 | #include "uic.h" 28 | 29 | #include 30 | 31 | namespace PHP { 32 | 33 | static QByteArray transformImageData(QString data) 34 | { 35 | int baSize = data.length() / 2; 36 | uchar *ba = new uchar[baSize]; 37 | for (int i = 0; i < baSize; ++i) { 38 | char h = data[2 * (i)].toLatin1(); 39 | char l = data[2 * (i) + 1].toLatin1(); 40 | uchar r = 0; 41 | if (h <= '9') 42 | r += h - '0'; 43 | else 44 | r += h - 'a' + 10; 45 | r = r << 4; 46 | if (l <= '9') 47 | r += l - '0'; 48 | else 49 | r += l - 'a' + 10; 50 | ba[i] = r; 51 | } 52 | QByteArray ret(reinterpret_cast(ba), baSize); 53 | delete [] ba; 54 | return ret; 55 | } 56 | 57 | static QByteArray unzipXPM(QString data, ulong& length) 58 | { 59 | #ifndef QT_NO_COMPRESS 60 | const int lengthOffset = 4; 61 | QByteArray ba(lengthOffset, ' '); 62 | 63 | // qUncompress() expects the first 4 bytes to be the expected length of the 64 | // uncompressed data 65 | ba[0] = (length & 0xff000000) >> 24; 66 | ba[1] = (length & 0x00ff0000) >> 16; 67 | ba[2] = (length & 0x0000ff00) >> 8; 68 | ba[3] = (length & 0x000000ff); 69 | ba.append(transformImageData(data)); 70 | QByteArray baunzip = qUncompress(ba); 71 | return baunzip; 72 | #else 73 | Q_UNUSED(data); 74 | Q_UNUSED(length); 75 | return QByteArray(); 76 | #endif 77 | } 78 | 79 | 80 | WriteIconData::WriteIconData(Uic *uic) 81 | : driver(uic->driver()), output(uic->output()), option(uic->option()) 82 | { 83 | } 84 | 85 | void WriteIconData::acceptUI(DomUI *node) 86 | { 87 | TreeWalker::acceptUI(node); 88 | } 89 | 90 | void WriteIconData::acceptImages(DomImages *images) 91 | { 92 | TreeWalker::acceptImages(images); 93 | } 94 | 95 | void WriteIconData::acceptImage(DomImage *image) 96 | { 97 | writeImage(output, option.indent, image); 98 | } 99 | 100 | void WriteIconData::writeImage(QTextStream &output, const QString &indent, DomImage *image) 101 | { 102 | QString img = image->attributeName() + QLatin1String("_data"); 103 | QString data = image->elementData()->text(); 104 | QString fmt = image->elementData()->attributeFormat(); 105 | int size = image->elementData()->attributeLength(); 106 | 107 | if (fmt == QLatin1String("XPM.GZ")) { 108 | ulong length = size; 109 | QByteArray baunzip = unzipXPM(data, length); 110 | length = baunzip.size(); 111 | // shouldn't we test the initial 'length' against the 112 | // resulting 'length' to catch corrupt UIC files? 113 | int a = 0; 114 | int column = 0; 115 | bool inQuote = false; 116 | output << indent << "static const char* const " << img << "[] = { \n"; 117 | while (baunzip[a] != '\"') 118 | a++; 119 | for (; a < (int) length; a++) { 120 | output << baunzip[a]; 121 | if (baunzip[a] == '\n') { 122 | column = 0; 123 | } else if (baunzip[a] == '"') { 124 | inQuote = !inQuote; 125 | } 126 | 127 | if (column++ >= 511 && inQuote) { 128 | output << "\"\n\""; // be nice with MSVC & Co. 129 | column = 1; 130 | } 131 | } 132 | 133 | if (! baunzip.trimmed ().endsWith ("};")) 134 | output << "};"; 135 | 136 | output << "\n\n"; 137 | } else { 138 | output << indent << "static const unsigned char " << img << "[] = { \n"; 139 | output << indent; 140 | int a ; 141 | for (a = 0; a < (int) (data.length()/2)-1; a++) { 142 | output << "0x" << QString(data[2*a]) << QString(data[2*a+1]) << ','; 143 | if (a % 12 == 11) 144 | output << "\n" << indent; 145 | else 146 | output << " "; 147 | } 148 | output << "0x" << QString(data[2*a]) << QString(data[2*a+1]) << '\n'; 149 | output << "};\n\n"; 150 | } 151 | } 152 | 153 | void WriteIconData::writeImage(QIODevice &output, DomImage *image) 154 | { 155 | QByteArray array = transformImageData(image->elementData()->text()); 156 | output.write(array, array.size()); 157 | } 158 | 159 | } // namespace PHP 160 | -------------------------------------------------------------------------------- /tools/uic/php/phpwriteicondata.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef CPPWRITEICONDATA_H 25 | #define CPPWRITEICONDATA_H 26 | 27 | #include "treewalker.h" 28 | 29 | class QTextStream; 30 | class QIODevice; 31 | class Driver; 32 | class Uic; 33 | 34 | struct Option; 35 | 36 | namespace PHP { 37 | 38 | class WriteIconData : public TreeWalker 39 | { 40 | public: 41 | WriteIconData(Uic *uic); 42 | 43 | void acceptUI(DomUI *node); 44 | void acceptImages(DomImages *images); 45 | void acceptImage(DomImage *image); 46 | 47 | static void writeImage(QTextStream &output, const QString &indent, DomImage *image); 48 | static void writeImage(QIODevice &output, DomImage *image); 49 | 50 | private: 51 | Driver *driver; 52 | QTextStream &output; 53 | const Option &option; 54 | }; 55 | 56 | } // namespace PHP 57 | 58 | #endif // CPPWRITEICONDATA_H 59 | -------------------------------------------------------------------------------- /tools/uic/php/phpwriteicondeclaration.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #include "phpwriteicondeclaration.h" 25 | #include "driver.h" 26 | #include "ui4.h" 27 | #include "uic.h" 28 | 29 | #include 30 | 31 | namespace PHP { 32 | 33 | WriteIconDeclaration::WriteIconDeclaration(Uic *uic) 34 | : driver(uic->driver()), output(uic->output()), option(uic->option()) 35 | { 36 | } 37 | 38 | void WriteIconDeclaration::acceptUI(DomUI *node) 39 | { 40 | TreeWalker::acceptUI(node); 41 | } 42 | 43 | void WriteIconDeclaration::acceptImages(DomImages *images) 44 | { 45 | TreeWalker::acceptImages(images); 46 | } 47 | 48 | void WriteIconDeclaration::acceptImage(DomImage *image) 49 | { 50 | QString name = image->attributeName(); 51 | if (name.isEmpty()) 52 | return; 53 | 54 | driver->insertPixmap(name); 55 | output << option.indent << option.indent << name << "_ID,\n"; 56 | } 57 | 58 | } // namespace PHP 59 | -------------------------------------------------------------------------------- /tools/uic/php/phpwriteicondeclaration.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef CPPWRITEICONDECLARATION_H 25 | #define CPPWRITEICONDECLARATION_H 26 | 27 | #include "treewalker.h" 28 | 29 | class QTextStream; 30 | class Driver; 31 | class Uic; 32 | 33 | struct Option; 34 | 35 | namespace PHP { 36 | 37 | class WriteIconDeclaration : public TreeWalker 38 | { 39 | public: 40 | WriteIconDeclaration(Uic *uic); 41 | 42 | void acceptUI(DomUI *node); 43 | void acceptImages(DomImages *images); 44 | void acceptImage(DomImage *image); 45 | 46 | private: 47 | Uic *uic; 48 | Driver *driver; 49 | QTextStream &output; 50 | const Option &option; 51 | }; 52 | 53 | } // namespace PHP 54 | 55 | #endif // CPPWRITEICONDECLARATION_H 56 | -------------------------------------------------------------------------------- /tools/uic/php/phpwriteiconinitialization.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #include "phpwriteiconinitialization.h" 25 | #include "phpwriteicondata.h" 26 | #include "driver.h" 27 | #include "ui4.h" 28 | #include "utils.h" 29 | #include "uic.h" 30 | 31 | #include 32 | 33 | namespace PHP { 34 | 35 | WriteIconInitialization::WriteIconInitialization(Uic *uic) 36 | : driver(uic->driver()), output(uic->output()), option(uic->option()) 37 | { 38 | this->uic = uic; 39 | } 40 | 41 | void WriteIconInitialization::acceptUI(DomUI *node) 42 | { 43 | if (node->elementImages() == 0) 44 | return; 45 | 46 | QString className = node->elementClass() + option.postfix; 47 | 48 | output << option.indent << "static QPixmap " << "icon(IconID id)\n" 49 | << option.indent << "{\n"; 50 | 51 | WriteIconData(uic).acceptUI(node); 52 | 53 | output << option.indent << "switch (id) {\n"; 54 | 55 | TreeWalker::acceptUI(node); 56 | 57 | output << option.indent << option.indent << "default: return QPixmap();\n"; 58 | 59 | output << option.indent << "} // switch\n" 60 | << option.indent << "} // icon\n\n"; 61 | } 62 | 63 | void WriteIconInitialization::acceptImages(DomImages *images) 64 | { 65 | TreeWalker::acceptImages(images); 66 | } 67 | 68 | void WriteIconInitialization::acceptImage(DomImage *image) 69 | { 70 | QString img = image->attributeName() + QLatin1String("_data"); 71 | QString data = image->elementData()->text(); 72 | QString fmt = image->elementData()->attributeFormat(); 73 | 74 | QString imageId = image->attributeName() + QLatin1String("_ID"); 75 | QString imageData = image->attributeName() + QLatin1String("_data"); 76 | QString ind = option.indent + option.indent; 77 | 78 | output << ind << "case " << imageId << ": "; 79 | 80 | if (fmt == QLatin1String("XPM.GZ")) { 81 | output << "return " << "QPixmap((const char**)" << imageData << ");\n"; 82 | } else { 83 | output << " { QImage img; img.loadFromData(" << imageData << ", sizeof(" << imageData << "), " << fixString(fmt, ind) << "); return QPixmap::fromImage(img); }\n"; 84 | } 85 | } 86 | 87 | } // namespace PHP 88 | -------------------------------------------------------------------------------- /tools/uic/php/phpwriteiconinitialization.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef CPPWRITEICONINITIALIZATION_H 25 | #define CPPWRITEICONINITIALIZATION_H 26 | 27 | #include "treewalker.h" 28 | 29 | class QTextStream; 30 | class Driver; 31 | class Uic; 32 | 33 | struct Option; 34 | 35 | namespace PHP { 36 | 37 | class WriteIconInitialization : public TreeWalker 38 | { 39 | public: 40 | WriteIconInitialization(Uic *uic); 41 | 42 | void acceptUI(DomUI *node); 43 | void acceptImages(DomImages *images); 44 | void acceptImage(DomImage *image); 45 | 46 | private: 47 | Uic *uic; 48 | Driver *driver; 49 | QTextStream &output; 50 | const Option &option; 51 | }; 52 | 53 | } // namespace PHP 54 | 55 | #endif // CPPWRITEICONINITIALIZATION_H 56 | -------------------------------------------------------------------------------- /tools/uic/php/phpwriteincludes.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef CPPWRITEINCLUDES_H 25 | #define CPPWRITEINCLUDES_H 26 | 27 | #include "treewalker.h" 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | class QTextStream; 35 | class Driver; 36 | class Uic; 37 | 38 | namespace PHP { 39 | 40 | struct WriteIncludes : public TreeWalker 41 | { 42 | WriteIncludes(Uic *uic); 43 | 44 | void acceptUI(DomUI *node); 45 | void acceptWidget(DomWidget *node); 46 | void acceptLayout(DomLayout *node); 47 | void acceptSpacer(DomSpacer *node); 48 | void acceptProperty(DomProperty *node); 49 | void acceptWidgetScripts(const DomScripts &, DomWidget *, const DomWidgets &); 50 | 51 | // 52 | // custom widgets 53 | // 54 | void acceptCustomWidgets(DomCustomWidgets *node); 55 | void acceptCustomWidget(DomCustomWidget *node); 56 | 57 | // 58 | // include hints 59 | // 60 | void acceptIncludes(DomIncludes *node); 61 | void acceptInclude(DomInclude *node); 62 | 63 | bool scriptsActivated() const { return m_scriptsActivated; } 64 | 65 | private: 66 | void add(const QString &className, const QString &header = QString(), bool global = false); 67 | 68 | private: 69 | typedef QMap OrderedSet; 70 | void insertIncludeForClass(const QString &className, QString header = QString(), bool global = false); 71 | void insertInclude(const QString &header, bool global); 72 | void writeHeaders(const OrderedSet &headers, bool global); 73 | QString headerForClassName(const QString &className) const; 74 | void activateScripts(); 75 | 76 | const Uic *m_uic; 77 | QTextStream &m_output; 78 | 79 | OrderedSet m_localIncludes; 80 | OrderedSet m_globalIncludes; 81 | QSet m_includeBaseNames; 82 | 83 | QSet m_knownClasses; 84 | 85 | typedef QHash StringMap; 86 | StringMap m_classToHeader; 87 | StringMap m_oldHeaderToNewHeader; 88 | bool m_scriptsActivated; 89 | }; 90 | 91 | } // namespace PHP 92 | 93 | #endif // CPPWRITEINCLUDES_H 94 | -------------------------------------------------------------------------------- /tools/uic/treewalker.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef TREEWALKER_H 25 | #define TREEWALKER_H 26 | 27 | #include 28 | 29 | class DomUI; 30 | class DomLayoutDefault; 31 | class DomLayoutFunction; 32 | class DomTabStops; 33 | class DomLayout; 34 | class DomLayoutItem; 35 | class DomWidget; 36 | class DomSpacer; 37 | class DomColor; 38 | class DomColorGroup; 39 | class DomPalette; 40 | class DomFont; 41 | class DomPoint; 42 | class DomRect; 43 | class DomSizePolicy; 44 | class DomSize; 45 | class DomDate; 46 | class DomTime; 47 | class DomDateTime; 48 | class DomProperty; 49 | class DomCustomWidgets; 50 | class DomCustomWidget; 51 | class DomAction; 52 | class DomActionGroup; 53 | class DomActionRef; 54 | class DomImages; 55 | class DomImage; 56 | class DomItem; 57 | class DomIncludes; 58 | class DomInclude; 59 | class DomString; 60 | class DomResourcePixmap; 61 | class DomResources; 62 | class DomResource; 63 | class DomConnections; 64 | class DomConnection; 65 | class DomConnectionHints; 66 | class DomConnectionHint; 67 | class DomScript; 68 | 69 | struct TreeWalker 70 | { 71 | inline virtual ~TreeWalker() {} 72 | 73 | virtual void acceptUI(DomUI *ui); 74 | virtual void acceptLayoutDefault(DomLayoutDefault *layoutDefault); 75 | virtual void acceptLayoutFunction(DomLayoutFunction *layoutFunction); 76 | virtual void acceptTabStops(DomTabStops *tabStops); 77 | virtual void acceptCustomWidgets(DomCustomWidgets *customWidgets); 78 | virtual void acceptCustomWidget(DomCustomWidget *customWidget); 79 | virtual void acceptLayout(DomLayout *layout); 80 | virtual void acceptLayoutItem(DomLayoutItem *layoutItem); 81 | virtual void acceptWidget(DomWidget *widget); 82 | virtual void acceptSpacer(DomSpacer *spacer); 83 | virtual void acceptColor(DomColor *color); 84 | virtual void acceptColorGroup(DomColorGroup *colorGroup); 85 | virtual void acceptPalette(DomPalette *palette); 86 | virtual void acceptFont(DomFont *font); 87 | virtual void acceptPoint(DomPoint *point); 88 | virtual void acceptRect(DomRect *rect); 89 | virtual void acceptSizePolicy(DomSizePolicy *sizePolicy); 90 | virtual void acceptSize(DomSize *size); 91 | virtual void acceptDate(DomDate *date); 92 | virtual void acceptTime(DomTime *time); 93 | virtual void acceptDateTime(DomDateTime *dateTime); 94 | virtual void acceptProperty(DomProperty *property); 95 | typedef QList DomScripts; 96 | typedef QList DomWidgets; 97 | virtual void acceptWidgetScripts(const DomScripts &, DomWidget *node, const DomWidgets &childWidgets); 98 | virtual void acceptImages(DomImages *images); 99 | virtual void acceptImage(DomImage *image); 100 | virtual void acceptIncludes(DomIncludes *includes); 101 | virtual void acceptInclude(DomInclude *incl); 102 | virtual void acceptAction(DomAction *action); 103 | virtual void acceptActionGroup(DomActionGroup *actionGroup); 104 | virtual void acceptActionRef(DomActionRef *actionRef); 105 | virtual void acceptConnections(DomConnections *connections); 106 | virtual void acceptConnection(DomConnection *connection); 107 | virtual void acceptConnectionHints(DomConnectionHints *connectionHints); 108 | virtual void acceptConnectionHint(DomConnectionHint *connectionHint); 109 | }; 110 | 111 | #endif // TREEWALKER_H 112 | -------------------------------------------------------------------------------- /tools/uic/uic.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef UIC_H 25 | #define UIC_H 26 | 27 | #include "databaseinfo.h" 28 | #include "customwidgetsinfo.h" 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | class QTextStream; 35 | class QIODevice; 36 | 37 | class Driver; 38 | class DomUI; 39 | class DomWidget; 40 | class DomSpacer; 41 | class DomLayout; 42 | class DomLayoutItem; 43 | class DomItem; 44 | 45 | struct Option; 46 | 47 | class Uic 48 | { 49 | public: 50 | Uic(Driver *driver); 51 | ~Uic(); 52 | 53 | bool printDependencies(); 54 | 55 | inline Driver *driver() const 56 | { return drv; } 57 | 58 | inline QTextStream &output() 59 | { return out; } 60 | 61 | inline const Option &option() const 62 | { return opt; } 63 | 64 | inline QString pixmapFunction() const 65 | { return pixFunction; } 66 | 67 | inline void setPixmapFunction(const QString &f) 68 | { pixFunction = f; } 69 | 70 | inline bool hasExternalPixmap() const 71 | { return externalPix; } 72 | 73 | inline void setExternalPixmap(bool b) 74 | { externalPix = b; } 75 | 76 | inline const DatabaseInfo *databaseInfo() const 77 | { return &info; } 78 | 79 | inline const CustomWidgetsInfo *customWidgetsInfo() const 80 | { return &cWidgetsInfo; } 81 | 82 | bool write(QIODevice *in); 83 | 84 | #ifdef QT_UIC_JAVA_GENERATOR 85 | bool jwrite(DomUI *ui); 86 | #endif 87 | 88 | #ifdef QT_UIC_CPP_GENERATOR 89 | bool write(DomUI *ui); 90 | #endif 91 | 92 | #ifdef QT_UIC_PHP_GENERATOR 93 | bool pwrite(DomUI *ui); 94 | #endif 95 | 96 | bool isMainWindow(const QString &className) const; 97 | bool isToolBar(const QString &className) const; 98 | bool isStatusBar(const QString &className) const; 99 | bool isButton(const QString &className) const; 100 | bool isContainer(const QString &className) const; 101 | bool isMenuBar(const QString &className) const; 102 | bool isMenu(const QString &className) const; 103 | 104 | private: 105 | // copyright header 106 | void writeCopyrightHeader(DomUI *ui); 107 | 108 | #ifdef QT_UIC_CPP_GENERATOR 109 | // header protection 110 | void writeHeaderProtectionStart(); 111 | void writeHeaderProtectionEnd(); 112 | #endif 113 | 114 | private: 115 | Driver *drv; 116 | QTextStream &out; 117 | Option &opt; 118 | DatabaseInfo info; 119 | CustomWidgetsInfo cWidgetsInfo; 120 | QString pixFunction; 121 | bool externalPix; 122 | }; 123 | 124 | #endif // UIC_H 125 | -------------------------------------------------------------------------------- /tools/uic/uic.pri: -------------------------------------------------------------------------------- 1 | 2 | INCLUDEPATH += $$PWD 3 | 4 | HEADERS += \ 5 | $$PWD/customwidgetsinfo.h \ 6 | $$PWD/databaseinfo.h \ 7 | $$PWD/driver.h \ 8 | $$PWD/globaldefs.h \ 9 | $$PWD/option.h \ 10 | $$PWD/treewalker.h \ 11 | $$PWD/ui4.h \ 12 | $$PWD/uic.h \ 13 | $$PWD/utils.h \ 14 | $$PWD/validator.h 15 | 16 | SOURCES += \ 17 | $$PWD/customwidgetsinfo.cpp \ 18 | $$PWD/databaseinfo.cpp \ 19 | $$PWD/driver.cpp \ 20 | $$PWD/treewalker.cpp \ 21 | $$PWD/ui4.cpp \ 22 | $$PWD/uic.cpp \ 23 | $$PWD/validator.cpp 24 | -------------------------------------------------------------------------------- /tools/uic/uic.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | QT = xml core 3 | CONFIG += warn_on console no_batch 4 | CONFIG -= app_bundle 5 | build_all:!build_pass { 6 | CONFIG -= build_all 7 | CONFIG += release 8 | } 9 | 10 | unix:!contains(QT_CONFIG, zlib):LIBS += -lz 11 | 12 | TARGET = uic 13 | DESTDIR = ../../../bin 14 | 15 | DEFINES += QT_BOOTSTRAPPED QT_UIC QT_LITE_UNICODE QT_NO_DATASTREAM \ 16 | QT_NO_THREAD QT_NO_QOBJECT QT_NO_UNICODETABLES QT_NO_LIBRARY \ 17 | QT_NO_SYSTEMLOCALE QT_NO_GEOM_VARIANT 18 | win32:DEFINES += QT_NODLL 19 | 20 | CONFIG -= qt 21 | INCLUDEPATH = ../../corelib/arch/generic $$QT_BUILD_TREE/include . \ 22 | $$QT_BUILD_TREE/include/QtCore $$QT_BUILD_TREE/include/QtXml 23 | DEPENDPATH += $$INCLUDEPATH ../../corelib/base ../../corelib/tools ../../corelib/io ../../corelib/codecs ../../xml 24 | 25 | include(uic.pri) 26 | include(cpp/cpp.pri) 27 | 28 | SOURCES += main.cpp 29 | 30 | 31 | # Qt tools needed to link rcc 32 | SOURCES += ../../corelib/global/qglobal.cpp \ 33 | ../../corelib/global/qnumeric.cpp \ 34 | ../../corelib/io/qbuffer.cpp \ 35 | ../../corelib/io/qdir.cpp \ 36 | ../../corelib/io/qdiriterator.cpp \ 37 | ../../corelib/io/qfile.cpp \ 38 | ../../corelib/io/qfileinfo.cpp \ 39 | ../../corelib/io/qfsfileengine.cpp \ 40 | ../../corelib/io/qfsfileengine_iterator.cpp \ 41 | ../../corelib/io/qiodevice.cpp \ 42 | ../../corelib/io/qtemporaryfile.cpp \ 43 | ../../corelib/io/qtextstream.cpp \ 44 | ../../corelib/io/qurl.cpp \ 45 | ../../corelib/tools/qbytearraymatcher.cpp \ 46 | ../../corelib/tools/qdatetime.cpp \ 47 | ../../corelib/tools/qhash.cpp \ 48 | ../../corelib/tools/qlistdata.cpp \ 49 | ../../corelib/tools/qlocale.cpp \ 50 | ../../corelib/tools/qmap.cpp \ 51 | ../../corelib/tools/qstring.cpp \ 52 | ../../corelib/tools/qstringlist.cpp \ 53 | ../../corelib/tools/qvector.cpp \ 54 | ../../corelib/io/qabstractfileengine.cpp \ 55 | ../../corelib/tools/qbytearray.cpp \ 56 | ../../corelib/tools/qbitarray.cpp \ 57 | ../../corelib/tools/qvsnprintf.cpp \ 58 | ../../corelib/tools/qregexp.cpp \ 59 | ../../corelib/kernel/qmetatype.cpp \ 60 | ../../corelib/kernel/qvariant.cpp \ 61 | ../../corelib/codecs/qtextcodec.cpp \ 62 | ../../corelib/codecs/qutfcodec.cpp \ 63 | ../../corelib/codecs/qisciicodec.cpp \ 64 | ../../corelib/codecs/qtsciicodec.cpp \ 65 | ../../corelib/codecs/qlatincodec.cpp \ 66 | ../../corelib/codecs/qsimplecodec.cpp \ 67 | ../../xml/qdom.cpp \ 68 | ../../xml/qxmlutils_p.cpp \ 69 | ../../xml/qxml.cpp 70 | 71 | unix:SOURCES += ../../corelib/io/qfsfileengine_unix.cpp ../../corelib/io/qfsfileengine_iterator_unix.cpp 72 | 73 | win32:SOURCES += ../../corelib/io/qfsfileengine_win.cpp ../../corelib/io/qfsfileengine_iterator_win.cpp 74 | 75 | macx: { 76 | QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.3 #enables weak linking for 10.3 (exported) 77 | SOURCES += ../../corelib/kernel/qcore_mac.cpp 78 | LIBS += -framework CoreServices 79 | } 80 | 81 | contains(QT_CONFIG, zlib) { 82 | INCLUDEPATH += ../../3rdparty/zlib 83 | SOURCES+= \ 84 | ../3rdparty/zlib/adler32.c \ 85 | ../3rdparty/zlib/compress.c \ 86 | ../3rdparty/zlib/crc32.c \ 87 | ../3rdparty/zlib/deflate.c \ 88 | ../3rdparty/zlib/gzio.c \ 89 | ../3rdparty/zlib/inffast.c \ 90 | ../3rdparty/zlib/inflate.c \ 91 | ../3rdparty/zlib/inftrees.c \ 92 | ../3rdparty/zlib/trees.c \ 93 | ../3rdparty/zlib/uncompr.c \ 94 | ../3rdparty/zlib/zutil.c 95 | } else:!contains(QT_CONFIG, no-zlib) { 96 | unix:LIBS += -lz 97 | # win32:LIBS += libz.lib 98 | } 99 | 100 | target.path=$$[QT_INSTALL_BINS] 101 | INSTALLS += target 102 | 103 | DESTDIR = ../../../bin 104 | include(../../qt_targets.pri) 105 | -------------------------------------------------------------------------------- /tools/uic/utils.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef UTILS_H 25 | #define UTILS_H 26 | 27 | #include "ui4.h" 28 | #include 29 | #include 30 | #include 31 | 32 | inline bool toBool(const QString &str) 33 | { return str.toLower() == QLatin1String("true"); } 34 | 35 | inline QString toString(const DomString *str) 36 | { return str ? str->text() : QString(); } 37 | 38 | inline QString fixString(const QString &str, const QString &indent) 39 | { 40 | QString cursegment; 41 | QStringList result; 42 | QByteArray utf8 = str.toUtf8(); 43 | 44 | for (int i = 0; i < utf8.length(); ++i) { 45 | const uchar cbyte = utf8.at(i); 46 | if (cbyte >= 0x80) { 47 | cursegment += QLatin1String("\\"); 48 | cursegment += QString::number(cbyte, 8); 49 | } else { 50 | switch(cbyte) { 51 | case '\\': 52 | cursegment += QLatin1String("\\\\"); break; 53 | case '\"': 54 | cursegment += QLatin1String("\\\""); break; 55 | case '\r': 56 | break; 57 | case '\n': 58 | cursegment += QLatin1String("\\n\"\n\""); break; 59 | case '$': 60 | break; 61 | default: 62 | cursegment += QLatin1Char(cbyte); 63 | } 64 | } 65 | 66 | if (cursegment.length() > 1024) { 67 | result << cursegment; 68 | cursegment.clear(); 69 | } 70 | } 71 | 72 | if (!cursegment.isEmpty()) 73 | result << cursegment; 74 | 75 | 76 | QString joinstr = QLatin1String("\"\n"); 77 | joinstr += indent; 78 | joinstr += indent; 79 | joinstr += QLatin1Char('"'); 80 | 81 | QString rc(QLatin1Char('"')); 82 | rc += result.join(joinstr); 83 | rc += QLatin1Char('"'); 84 | return rc; 85 | } 86 | 87 | inline QHash propertyMap(const QList &properties) 88 | { 89 | QHash map; 90 | 91 | for (int i=0; iattributeName(), p); 94 | } 95 | 96 | return map; 97 | } 98 | 99 | inline QStringList unique(const QStringList &lst) 100 | { 101 | QHash h; 102 | for (int i=0; i 30 | 31 | Validator::Validator(Uic *uic) 32 | : driver(uic->driver()), output(uic->output()), option(uic->option()) 33 | { 34 | this->uic = uic; 35 | } 36 | 37 | void Validator::acceptUI(DomUI *node) 38 | { 39 | TreeWalker::acceptUI(node); 40 | } 41 | 42 | void Validator::acceptWidget(DomWidget *node) 43 | { 44 | (void) driver->findOrInsertWidget(node); 45 | 46 | TreeWalker::acceptWidget(node); 47 | } 48 | 49 | void Validator::acceptLayoutItem(DomLayoutItem *node) 50 | { 51 | (void) driver->findOrInsertLayoutItem(node); 52 | 53 | TreeWalker::acceptLayoutItem(node); 54 | } 55 | 56 | void Validator::acceptLayout(DomLayout *node) 57 | { 58 | (void) driver->findOrInsertLayout(node); 59 | 60 | TreeWalker::acceptLayout(node); 61 | } 62 | 63 | void Validator::acceptActionGroup(DomActionGroup *node) 64 | { 65 | (void) driver->findOrInsertActionGroup(node); 66 | 67 | TreeWalker::acceptActionGroup(node); 68 | } 69 | 70 | void Validator::acceptAction(DomAction *node) 71 | { 72 | (void) driver->findOrInsertAction(node); 73 | 74 | TreeWalker::acceptAction(node); 75 | } 76 | -------------------------------------------------------------------------------- /tools/uic/validator.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 4 | ** 5 | ** This file is part of the tools applications of the Qt Toolkit. 6 | ** 7 | ** This file may be used under the terms of the GNU General Public 8 | ** License version 2.0 as published by the Free Software Foundation 9 | ** and appearing in the file LICENSE.GPL included in the packaging of 10 | ** this file. Please review the following information to ensure GNU 11 | ** General Public Licensing requirements will be met: 12 | ** http://www.trolltech.com/products/qt/opensource.html 13 | ** 14 | ** If you are unsure which license is appropriate for your use, please 15 | ** review the following information: 16 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 17 | ** sales department at sales@trolltech.com. 18 | ** 19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | ** 22 | ****************************************************************************/ 23 | 24 | #ifndef VALIDATOR_H 25 | #define VALIDATOR_H 26 | 27 | #include "treewalker.h" 28 | 29 | class QTextStream; 30 | class Driver; 31 | class Uic; 32 | 33 | struct Option; 34 | 35 | struct Validator : public TreeWalker 36 | { 37 | Validator(Uic *uic); 38 | 39 | void acceptUI(DomUI *node); 40 | void acceptWidget(DomWidget *node); 41 | 42 | void acceptLayoutItem(DomLayoutItem *node); 43 | void acceptLayout(DomLayout *node); 44 | 45 | void acceptActionGroup(DomActionGroup *node); 46 | void acceptAction(DomAction *node); 47 | 48 | private: 49 | Driver *driver; 50 | QTextStream &output; 51 | const Option &option; 52 | Uic *uic; 53 | }; 54 | 55 | #endif // VALIDATOR_H 56 | -------------------------------------------------------------------------------- /tutorials/t1/main.php: -------------------------------------------------------------------------------- 1 | resize(100, 30); 20 | 21 | $hello->show(); 22 | $app->exec(); 23 | 24 | ?> 25 | -------------------------------------------------------------------------------- /tutorials/t10/cannonfield.php: -------------------------------------------------------------------------------- 1 | currentAngle = 45; 30 | $this->currentForce = 0; 31 | $this->setPalette(new QPalette(new QColor(250, 250, 200))); 32 | $this->setAutoFillBackground(true); 33 | } 34 | 35 | public function angle() { return $this->currentAngle; } 36 | public function force() { return $this->currentForce; } 37 | 38 | public function setAngle($angle) 39 | { 40 | if ($angle < 5) 41 | $angle = 5; 42 | if ($angle > 70) 43 | $angle = 70; 44 | if ($this->currentAngle == $angle) 45 | return; 46 | $this->currentAngle = $angle; 47 | $this->update( $this->cannonRect() ); 48 | emit( $this->angleChanged($this->currentAngle) ); 49 | } 50 | 51 | public function setForce($force) 52 | { 53 | if ($force < 0) 54 | $force = 0; 55 | if ($this->currentForce == $force) 56 | return; 57 | $this->currentForce = $force; 58 | emit( $this->forceChanged($this->currentForce) ); 59 | } 60 | 61 | 62 | protected function paintEvent ($event) { 63 | $painter = new QPainter($this); 64 | $painter->setPen(Qt::NoPen); 65 | $painter->setBrush(new QBrush(new QColor(0,0,255))); 66 | 67 | $painter->translate(0, $this->rect()->height()); 68 | $painter->drawPie(new QRect(-35, -35, 70, 70), 0, 90 * 16); 69 | $painter->rotate(-$this->currentAngle); 70 | $painter->drawRect(new QRect(30, -5, 20, 10)); 71 | 72 | $painter->end(); 73 | } 74 | 75 | private function cannonRect() 76 | { 77 | $result = new QRect(0, 0, 50, 50); 78 | $result->moveBottomLeft($this->rect()->bottomLeft()); 79 | return $result; 80 | } 81 | } 82 | 83 | ?> -------------------------------------------------------------------------------- /tutorials/t10/lcdrange.php: -------------------------------------------------------------------------------- 1 | lcd = new QLCDNumber(2); 28 | $this->lcd->setSegmentStyle(QLCDNumber::Filled); 29 | 30 | $this->slider = new QSlider(Qt::Horizontal); 31 | $this->slider->setRange(0, 99); 32 | $this->slider->setValue(0); 33 | 34 | $this->connect($this->slider, SIGNAL('valueChanged(int)'), $this->lcd, SLOT('display(int)')); 35 | $this->connect($this->slider, SIGNAL('valueChanged(int)'), $this, SIGNAL('valueChanged(int)')); 36 | 37 | $layout = new QVBoxLayout(); 38 | $layout->addWidget($this->lcd); 39 | $layout->addWidget($this->slider); 40 | $this->setLayout($layout); 41 | $this->setFocusProxy($this->slider); 42 | } 43 | 44 | public function value() 45 | { 46 | return $this->slider->value(); 47 | } 48 | 49 | public function setValue($value = 0) 50 | { 51 | $this->slider->setValue($value); 52 | } 53 | 54 | public function setRange($minValue, $maxValue) 55 | { 56 | if ($minValue < 0 || $maxValue > 99 || $minValue > $maxValue) { 57 | echo "LCDRange::setRange(".$minValue.", ".$maxValue.")\n". 58 | "\tRange must be 0..99\n". 59 | "\tand minValue must not be greater than maxValue"; 60 | return; 61 | } 62 | $this->slider->setRange($minValue, $maxValue); 63 | } 64 | 65 | }; 66 | 67 | ?> -------------------------------------------------------------------------------- /tutorials/t10/main.php: -------------------------------------------------------------------------------- 1 | setFont(new QFont("Times", 18, QFont::Bold)); 26 | 27 | QObject::connect($quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()')); 28 | 29 | $angle = new LCDRange(); 30 | $angle->setRange(5, 70); 31 | 32 | $force = new LCDRange(); 33 | $force->setRange(10, 50); 34 | 35 | $cannonField = new CannonField(); 36 | 37 | QObject::connect($angle, SIGNAL('valueChanged(int)'), $cannonField, SLOT('setAngle(int)')); 38 | QObject::connect($cannonField, SIGNAL('angleChanged(int)'), $angle, SLOT('setValue(int)')); 39 | 40 | QObject::connect($force, SIGNAL('valueChanged(int)'), $cannonField, SLOT('setForce(int)')); 41 | QObject::connect($cannonField, SIGNAL('forceChanged(int)'), $force, SLOT('setValue(int)')); 42 | 43 | $leftLayout = new QVBoxLayout(); 44 | $leftLayout->addWidget($angle); 45 | $leftLayout->addWidget($force); 46 | 47 | $gridLayout = new QGridLayout(); 48 | $gridLayout->addWidget($quit, 0, 0); 49 | $gridLayout->addLayout($leftLayout, 1, 0); 50 | $gridLayout->addWidget($cannonField, 1, 1, 2, 1); 51 | $gridLayout->setColumnStretch(1, 10); 52 | $this->setLayout($gridLayout); 53 | 54 | $angle->setValue(60); 55 | $force->setValue(25); 56 | $angle->setFocus(); 57 | 58 | } 59 | } 60 | 61 | $app = new QApplication($argc, $argv); 62 | $widget = new MyWidget(); 63 | $widget->setGeometry(100, 100, 500, 355); 64 | $widget->show(); 65 | $app->exec(); 66 | 67 | ?> -------------------------------------------------------------------------------- /tutorials/t11/cannonfield.php: -------------------------------------------------------------------------------- 1 | currentAngle = 45; 37 | $this->currentForce = 0; 38 | $this->timerCount = 0; 39 | $this->autoShootTimer = new QTimer($this); 40 | QObject::connect( $this->autoShootTimer, SIGNAL('timeout()'), $this, SLOT('moveShot()') ); 41 | $this->shootAngle = 0; 42 | $this->shootForce = 0; 43 | $this->setPalette(new QPalette(new QColor(250, 250, 200))); 44 | $this->setAutoFillBackground(true); 45 | 46 | $this->barrelRect = new QRect(30, -5, 20, 10); 47 | } 48 | 49 | public function angle() { return $this->currentAngle; } 50 | public function force() { return $this->currentForce; } 51 | 52 | public function setAngle($angle) 53 | { 54 | if ($angle < 5) 55 | $angle = 5; 56 | if ($angle > 70) 57 | $angle = 70; 58 | if ($this->currentAngle == $angle) 59 | return; 60 | $this->currentAngle = $angle; 61 | $this->update( $this->cannonRect() ); 62 | emit( $this->angleChanged($this->currentAngle) ); 63 | } 64 | 65 | public function setForce($force) 66 | { 67 | if ($force < 0) 68 | $force = 0; 69 | if ($this->currentForce == $force) 70 | return; 71 | $this->currentForce = $force; 72 | emit( $this->forceChanged($this->currentForce) ); 73 | } 74 | 75 | public function shoot() 76 | { 77 | if ($this->autoShootTimer->isActive()) 78 | return; 79 | 80 | $this->timerCount = 0; 81 | $this->shootAngle = $this->currentAngle; 82 | $this->shootForce = $this->currentForce; 83 | $this->autoShootTimer->start(5); 84 | } 85 | 86 | public function moveShot() 87 | { 88 | $region = $this->shotRect(); 89 | ++$this->timerCount; 90 | 91 | $shotR = $this->shotRect(); 92 | 93 | if ($shotR->x() > $this->width() || $shotR->y() > $this->height()) { 94 | $this->autoShootTimer->stop(); 95 | } 96 | else { 97 | $region = $region->unite($shotR); 98 | } 99 | $this->update( $region ); 100 | } 101 | 102 | protected function paintEvent ($event) { 103 | $painter = new QPainter($this); 104 | 105 | $this->paintCannon($painter); 106 | 107 | if ($this->autoShootTimer->isActive()) 108 | $this->paintShot($painter); 109 | 110 | $painter->end(); 111 | } 112 | 113 | private function paintShot($painter) 114 | { 115 | $painter->setPen(Qt::NoPen); 116 | $painter->setBrush(Qt::black); 117 | $painter->drawRect($this->shotRect()); 118 | } 119 | 120 | private function paintCannon($painter) 121 | { 122 | $painter->setPen(Qt::NoPen); 123 | $painter->setBrush(new QBrush(new QColor(0,0,255))); 124 | 125 | $painter->save(); 126 | $painter->translate(0, $this->height()); 127 | $painter->drawPie(new QRect(-35, -35, 70, 70), 0, 90 * 16); 128 | $painter->rotate(-$this->currentAngle); 129 | $painter->drawRect($this->barrelRect); 130 | $painter->restore(); 131 | } 132 | 133 | private function cannonRect() 134 | { 135 | $result = new QRect(0, 0, 50, 50); 136 | $result->moveBottomLeft($this->rect()->bottomLeft()); 137 | return $result; 138 | } 139 | 140 | private function shotRect() 141 | { 142 | $gravity = 4.0; 143 | 144 | $time = $this->timerCount / 20.0; 145 | $velocity = $this->shootForce; 146 | $radians = $this->shootAngle * 3.14159265 / 180; 147 | 148 | $velx = $velocity * cos($radians); 149 | $vely = $velocity * sin($radians); 150 | 151 | $x0 = ($this->barrelRect->right() + 5) * cos($radians); 152 | $y0 = ($this->barrelRect->right() + 5) * sin($radians); 153 | $x = $x0 + $velx * $time; 154 | $y = $y0 + $vely * $time - 0.5 * $gravity * $time * $time; 155 | 156 | $result = new QRect(0, 0, 6, 6); 157 | $result->moveCenter(new QPoint( qRound($x), $this->height() - 1 - qRound($y))); 158 | return $result; 159 | } 160 | 161 | } 162 | 163 | ?> -------------------------------------------------------------------------------- /tutorials/t11/lcdrange.php: -------------------------------------------------------------------------------- 1 | lcd = new QLCDNumber(2); 28 | $this->lcd->setSegmentStyle(QLCDNumber::Filled); 29 | 30 | $this->slider = new QSlider(Qt::Horizontal); 31 | $this->slider->setRange(0, 99); 32 | $this->slider->setValue(0); 33 | 34 | $this->connect($this->slider, SIGNAL('valueChanged(int)'), $this->lcd, SLOT('display(int)')); 35 | $this->connect($this->slider, SIGNAL('valueChanged(int)'), $this, SIGNAL('valueChanged(int)')); 36 | 37 | $layout = new QVBoxLayout(); 38 | $layout->addWidget($this->lcd); 39 | $layout->addWidget($this->slider); 40 | $this->setLayout($layout); 41 | $this->setFocusProxy($this->slider); 42 | } 43 | 44 | public function value() 45 | { 46 | return $this->slider->value(); 47 | } 48 | 49 | public function setValue($value = 0) 50 | { 51 | $this->slider->setValue($value); 52 | } 53 | 54 | public function setRange($minValue, $maxValue) 55 | { 56 | if ($minValue < 0 || $maxValue > 99 || $minValue > $maxValue) { 57 | echo "LCDRange::setRange(".$minValue.", ".$maxValue.")\n". 58 | "\tRange must be 0..99\n". 59 | "\tand minValue must not be greater than maxValue"; 60 | return; 61 | } 62 | $this->slider->setRange($minValue, $maxValue); 63 | } 64 | 65 | }; 66 | 67 | ?> -------------------------------------------------------------------------------- /tutorials/t11/main.php: -------------------------------------------------------------------------------- 1 | setFont(new QFont("Times", 18, QFont::Bold)); 26 | 27 | QObject::connect($quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()')); 28 | 29 | $angle = new LCDRange(); 30 | $angle->setRange(5, 70); 31 | 32 | $force = new LCDRange(); 33 | $force->setRange(10, 50); 34 | 35 | $cannonField = new CannonField(); 36 | 37 | QObject::connect($angle, SIGNAL('valueChanged(int)'), $cannonField, SLOT('setAngle(int)')); 38 | QObject::connect($cannonField, SIGNAL('angleChanged(int)'), $angle, SLOT('setValue(int)')); 39 | 40 | QObject::connect($force, SIGNAL('valueChanged(int)'), $cannonField, SLOT('setForce(int)')); 41 | QObject::connect($cannonField, SIGNAL('forceChanged(int)'), $force, SLOT('setValue(int)')); 42 | 43 | $shoot = new QPushButton(tr("&Shoot")); 44 | $shoot->setFont(new QFont("Times", 18, QFont::Bold)); 45 | 46 | QObject::connect($shoot, SIGNAL('clicked()'), $cannonField, SLOT('shoot()')); 47 | 48 | $topLayout = new QHBoxLayout(); 49 | $topLayout->addWidget($shoot); 50 | $topLayout->addStretch(1); 51 | 52 | $leftLayout = new QVBoxLayout(); 53 | $leftLayout->addWidget($angle); 54 | $leftLayout->addWidget($force); 55 | 56 | $gridLayout = new QGridLayout(); 57 | $gridLayout->addWidget($quit, 0, 0); 58 | $gridLayout->addLayout($topLayout, 0, 1); 59 | $gridLayout->addLayout($leftLayout, 1, 0); 60 | $gridLayout->addWidget($cannonField, 1, 1, 2, 1); 61 | $gridLayout->setColumnStretch(1, 10); 62 | $this->setLayout($gridLayout); 63 | 64 | $angle->setValue(60); 65 | $force->setValue(25); 66 | $angle->setFocus(); 67 | 68 | } 69 | } 70 | 71 | $app = new QApplication($argc, $argv); 72 | $widget = new MyWidget(); 73 | $widget->setGeometry(100, 100, 500, 355); 74 | $widget->show(); 75 | $app->exec(); 76 | 77 | ?> -------------------------------------------------------------------------------- /tutorials/t2/main.php: -------------------------------------------------------------------------------- 1 | resize(75,30); 20 | $quit->setFont(new QFont("Times", 18, QFont::Bold)); 21 | 22 | QObject::connect($quit,SIGNAL('clicked()'),$app,SLOT('quit()')); 23 | 24 | $quit->show(); 25 | $app->exec(); 26 | 27 | ?> 28 | -------------------------------------------------------------------------------- /tutorials/t3/main.php: -------------------------------------------------------------------------------- 1 | resize(200,120); 20 | 21 | $quit = new QPushButton("Quit", $window); 22 | $quit->setFont(new QFont("Times", 18, QFont::Bold)); 23 | $quit->setGeometry(10, 40, 180, 40); 24 | 25 | QObject::connect($quit,SIGNAL('clicked()'), $app, SLOT('quit()')); 26 | 27 | $window->show(); 28 | $app->exec(); 29 | 30 | ?> 31 | -------------------------------------------------------------------------------- /tutorials/t4/main.php: -------------------------------------------------------------------------------- 1 | setFixedSize(200, 120); 26 | 27 | $this->quit = new QPushButton(tr("Quit"), $this); 28 | $this->quit->setGeometry(62, 40, 75, 30); 29 | $this->quit->setFont(new QFont("Times", 18, QFont::Bold)); 30 | 31 | /* the macro qApp is not available in php-qt, we use QApplication::instance() directly. */ 32 | $this->connect($this->quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()')); 33 | } 34 | 35 | } 36 | 37 | $app = new QApplication($argc,$argv); 38 | $widget = new MyWidget(); 39 | $widget->show(); 40 | $app->exec(); 41 | 42 | ?> 43 | -------------------------------------------------------------------------------- /tutorials/t5/main.php: -------------------------------------------------------------------------------- 1 | quit = new QPushButton(tr("Quit")); 29 | $this->quit->setFont(new QFont("Times", 18, QFont::Bold)); 30 | 31 | $this->lcd = new QLCDNumber(2); 32 | $this->lcd->setSegmentStyle(QLCDNumber::Filled); 33 | 34 | $this->slider = new QSlider(Qt::Horizontal); 35 | $this->slider->setRange(0, 99); 36 | $this->slider->setValue(0); 37 | 38 | $this->connect($this->quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()')); 39 | $this->connect($this->slider, SIGNAL('valueChanged(int)'),$this->lcd, SLOT('display(int)')); 40 | 41 | $this->layout = new QVBoxLayout(); 42 | $this->layout->addWidget($this->quit); 43 | $this->layout->addWidget($this->lcd); 44 | $this->layout->addWidget($this->slider); 45 | $this->setLayout($this->layout); 46 | } 47 | } 48 | 49 | 50 | $app = new QApplication($argc,$argv); 51 | 52 | $widget = new MyWidget(); 53 | $widget->show(); 54 | 55 | $app->exec(); 56 | 57 | ?> 58 | -------------------------------------------------------------------------------- /tutorials/t6/main.php: -------------------------------------------------------------------------------- 1 | lcd = new QLCDNumber(2); 27 | $this->lcd->setSegmentStyle(QLCDNumber::Filled); 28 | 29 | $this->slider = new QSlider(Qt::Horizontal); 30 | $this->slider->setRange(0, 99); 31 | $this->slider->setValue(0); 32 | $this->connect($this->slider, SIGNAL('valueChanged(int)'), 33 | $this->lcd, SLOT('display(int)')); 34 | 35 | $this->layout = new QVBoxLayout(); 36 | $this->layout->addWidget($this->lcd); 37 | $this->layout->addWidget($this->slider); 38 | $this->setLayout($this->layout); 39 | } 40 | }; 41 | 42 | class MyWidget extends QWidget 43 | { 44 | private $quit; 45 | private $grid; 46 | private $layout; 47 | 48 | function __construct() 49 | { 50 | parent::__construct(); 51 | 52 | $this->quit = new QPushButton(tr("Quit")); 53 | $this->quit->setFont(new QFont("Times", 18, QFont::Bold)); 54 | $this->connect($this->quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()')); 55 | 56 | $this->grid = new QGridLayout(); 57 | for ($row = 0; $row < 4; ++$row) { 58 | for ($column = 0; $column < 4; ++$column) { 59 | $this->grid->addWidget(new LCDRange(), $row, $column); 60 | } 61 | } 62 | 63 | $this->layout = new QVBoxLayout(); 64 | $this->layout->addWidget($this->quit); 65 | $this->layout->addLayout($this->grid); 66 | $this->setLayout($this->layout); 67 | } 68 | } 69 | 70 | $app = new QApplication($argc,$argv); 71 | $widget = new MyWidget(); 72 | $widget->show(); 73 | $app->exec(); 74 | 75 | ?> 76 | -------------------------------------------------------------------------------- /tutorials/t7/main.php: -------------------------------------------------------------------------------- 1 | lcd = new QLCDNumber(2); 30 | $this->lcd->setSegmentStyle(QLCDNumber::Filled); 31 | 32 | $this->slider = new QSlider(Qt::Horizontal); 33 | $this->slider->setRange(0, 99); 34 | $this->slider->setValue(0); 35 | 36 | $this->connect($this->slider, SIGNAL('valueChanged(int)'), 37 | $this->lcd, SLOT('display(int)')); 38 | $this->connect($this->slider, SIGNAL('valueChanged(int)'), 39 | $this,SIGNAL('valueChanged(int)')); 40 | 41 | $this->layout = new QVBoxLayout(); 42 | $this->layout->addWidget($this->lcd); 43 | $this->layout->addWidget($this->slider); 44 | $this->setLayout($this->layout); 45 | } 46 | 47 | function value(){ 48 | return $this->slider->value(); 49 | } 50 | 51 | function setValue($value){ 52 | $this->slider->setValue($value); 53 | } 54 | }; 55 | 56 | class MyWidget extends QWidget 57 | { 58 | private $quit; 59 | private $grid; 60 | private $layout; 61 | 62 | function __construct() 63 | { 64 | parent::__construct(); 65 | 66 | $this->quit = new QPushButton(tr("Quit")); 67 | $this->quit->setFont(new QFont("Times", 18, QFont::Bold)); 68 | $this->connect($this->quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()')); 69 | 70 | $this->grid = new QGridLayout(); 71 | for ($row = 0; $row < 3; ++$row) { 72 | for ($column = 0; $column < 3; ++$column) { 73 | $lcdRange = new LCDRange(); 74 | $this->grid->addWidget($lcdRange, $row, $column); 75 | if($previousRange) 76 | $this->connect($lcdRange, SIGNAL('valueChanged(int)'), $previousRange, SLOT('setValue(int)')); 77 | $previousRange = $lcdRange; 78 | } 79 | 80 | } 81 | 82 | $this->layout = new QVBoxLayout(); 83 | $this->layout->addWidget($this->quit); 84 | $this->layout->addLayout($this->grid); 85 | $this->setLayout($this->layout); 86 | } 87 | } 88 | 89 | $app = new QApplication($argc,$argv); 90 | 91 | $widget = new MyWidget(); 92 | $widget->show(); 93 | $app->exec(); 94 | 95 | ?> 96 | -------------------------------------------------------------------------------- /tutorials/t8/cannonfield.php: -------------------------------------------------------------------------------- 1 | currentAngle = 45; 29 | $this->setPalette(new QPalette(new QColor(250, 250, 200))); 30 | $this->setAutoFillBackground(true); 31 | 32 | } 33 | 34 | public function angle() { return $this->currentAngle; } 35 | 36 | public function setAngle($angle) 37 | { 38 | if ($angle < 5) 39 | $angle = 5; 40 | if ($angle > 70) 41 | $angle = 70; 42 | if ($this->currentAngle == $angle) 43 | return; 44 | $this->currentAngle = $angle; 45 | $this->update(); 46 | emit($this->angleChanged($this->currentAngle)); 47 | } 48 | 49 | protected function paintEvent ($event) { 50 | $painter = new QPainter($this); 51 | $painter->drawText(200, 200, 52 | tr("Angle = ") . QString::number($this->currentAngle)); 53 | $painter->end(); 54 | } 55 | 56 | } 57 | 58 | ?> -------------------------------------------------------------------------------- /tutorials/t8/lcdrange.php: -------------------------------------------------------------------------------- 1 | lcd = new QLCDNumber(2); 28 | $this->lcd->setSegmentStyle(QLCDNumber::Filled); 29 | 30 | $this->slider = new QSlider(Qt::Horizontal); 31 | $this->slider->setRange(0, 99); 32 | $this->slider->setValue(0); 33 | 34 | $this->connect($this->slider, SIGNAL('valueChanged(int)'), $this->lcd, SLOT('display(int)')); 35 | $this->connect($this->slider, SIGNAL('valueChanged(int)'), $this, SIGNAL('valueChanged(int)')); 36 | 37 | $layout = new QVBoxLayout(); 38 | $layout->addWidget($this->lcd); 39 | $layout->addWidget($this->slider); 40 | $this->setLayout($layout); 41 | $this->setFocusProxy($this->slider); 42 | } 43 | 44 | public function value() 45 | { 46 | return $this->slider->value(); 47 | } 48 | 49 | public function setValue($value = 0) 50 | { 51 | $this->slider->setValue($value); 52 | } 53 | 54 | public function setRange($minValue, $maxValue) 55 | { 56 | if ($minValue < 0 || $maxValue > 99 || $minValue > $maxValue) { 57 | echo "LCDRange::setRange(".$minValue.", ".$maxValue.")\n". 58 | "\tRange must be 0..99\n". 59 | "\tand minValue must not be greater than maxValue"; 60 | return; 61 | } 62 | $this->slider->setRange($minValue, $maxValue); 63 | } 64 | 65 | }; 66 | 67 | ?> -------------------------------------------------------------------------------- /tutorials/t8/main.php: -------------------------------------------------------------------------------- 1 | setFont(new QFont("Times", 18, QFont::Bold)); 26 | 27 | QObject::connect($quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()')); 28 | 29 | $angle = new LCDRange(); 30 | $angle->setRange(5, 70); 31 | 32 | $cannonField = new CannonField(); 33 | 34 | QObject::connect($angle, SIGNAL('valueChanged(int)'), $cannonField, SLOT('setAngle(int)')); 35 | QObject::connect($cannonField, SIGNAL('angleChanged(int)'), $angle, SLOT('setValue(int)')); 36 | 37 | $gridLayout = new QGridLayout(); 38 | $gridLayout->addWidget($quit, 0, 0); 39 | $gridLayout->addWidget($angle, 1, 0); 40 | $gridLayout->addWidget($cannonField, 1, 1, 2, 1); 41 | $gridLayout->setColumnStretch(1, 10); 42 | $this->setLayout($gridLayout); 43 | 44 | $angle->setValue(60); 45 | $angle->setFocus(); 46 | 47 | } 48 | } 49 | 50 | $app = new QApplication($argc, $argv); 51 | $widget = new MyWidget(); 52 | $widget->setGeometry(100, 100, 500, 355); 53 | $widget->show(); 54 | $app->exec(); 55 | 56 | ?> -------------------------------------------------------------------------------- /tutorials/t9/cannonfield.php: -------------------------------------------------------------------------------- 1 | currentAngle = 45; 29 | $this->setPalette(new QPalette(new QColor(250, 250, 200))); 30 | $this->setAutoFillBackground(true); 31 | 32 | } 33 | 34 | public function angle() { return $this->currentAngle; } 35 | 36 | public function setAngle($angle) 37 | { 38 | if ($angle < 5) 39 | $angle = 5; 40 | if ($angle > 70) 41 | $angle = 70; 42 | if ($this->currentAngle == $angle) 43 | return; 44 | $this->currentAngle = $angle; 45 | $this->update(); 46 | emit($this->angleChanged($this->currentAngle)); 47 | } 48 | 49 | protected function paintEvent ($event) { 50 | $painter = new QPainter($this); 51 | $painter->setPen(Qt::NoPen); 52 | $painter->setBrush(new QBrush(new QColor(0,0,255))); 53 | 54 | $painter->translate(0, $this->rect()->height()); 55 | $painter->drawPie(new QRect(-35, -35, 70, 70), 0, 90 * 16); 56 | $painter->rotate(-$this->currentAngle); 57 | $painter->drawRect(new QRect(30, -5, 20, 10)); 58 | 59 | $painter->end(); 60 | } 61 | 62 | } 63 | 64 | ?> -------------------------------------------------------------------------------- /tutorials/t9/lcdrange.php: -------------------------------------------------------------------------------- 1 | lcd = new QLCDNumber(2); 28 | $this->lcd->setSegmentStyle(QLCDNumber::Filled); 29 | 30 | $this->slider = new QSlider(Qt::Horizontal); 31 | $this->slider->setRange(0, 99); 32 | $this->slider->setValue(0); 33 | 34 | $this->connect($this->slider, SIGNAL('valueChanged(int)'), $this->lcd, SLOT('display(int)')); 35 | $this->connect($this->slider, SIGNAL('valueChanged(int)'), $this, SIGNAL('valueChanged(int)')); 36 | 37 | $layout = new QVBoxLayout(); 38 | $layout->addWidget($this->lcd); 39 | $layout->addWidget($this->slider); 40 | $this->setLayout($layout); 41 | $this->setFocusProxy($this->slider); 42 | } 43 | 44 | public function value() 45 | { 46 | return $this->slider->value(); 47 | } 48 | 49 | public function setValue($value = 0) 50 | { 51 | $this->slider->setValue($value); 52 | } 53 | 54 | public function setRange($minValue, $maxValue) 55 | { 56 | if ($minValue < 0 || $maxValue > 99 || $minValue > $maxValue) { 57 | echo "LCDRange::setRange(".$minValue.", ".$maxValue.")\n". 58 | "\tRange must be 0..99\n". 59 | "\tand minValue must not be greater than maxValue"; 60 | return; 61 | } 62 | $this->slider->setRange($minValue, $maxValue); 63 | } 64 | 65 | }; 66 | 67 | ?> -------------------------------------------------------------------------------- /tutorials/t9/main.php: -------------------------------------------------------------------------------- 1 | setFont(new QFont("Times", 18, QFont::Bold)); 26 | 27 | QObject::connect($quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()')); 28 | 29 | $angle = new LCDRange(); 30 | $angle->setRange(5, 70); 31 | 32 | $cannonField = new CannonField(); 33 | 34 | QObject::connect($angle, SIGNAL('valueChanged(int)'), $cannonField, SLOT('setAngle(int)')); 35 | QObject::connect($cannonField, SIGNAL('angleChanged(int)'), $angle, SLOT('setValue(int)')); 36 | 37 | $gridLayout = new QGridLayout(); 38 | $gridLayout->addWidget($quit, 0, 0); 39 | $gridLayout->addWidget($angle, 1, 0); 40 | $gridLayout->addWidget($cannonField, 1, 1, 2, 1); 41 | $gridLayout->setColumnStretch(1, 10); 42 | $this->setLayout($gridLayout); 43 | 44 | $angle->setValue(60); 45 | $angle->setFocus(); 46 | 47 | } 48 | } 49 | 50 | $app = new QApplication($argc, $argv); 51 | $widget = new MyWidget(); 52 | $widget->setGeometry(100, 100, 500, 355); 53 | $widget->show(); 54 | $app->exec(); 55 | 56 | ?> --------------------------------------------------------------------------------