├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── AUTHORS.md ├── CMakeLists.txt ├── CONTRIBUTING.md ├── COPYING.lib.md ├── Doxyfile ├── DoxygenLayout.xml ├── README.md ├── appveyor.yml ├── doc └── .gitignore ├── doxygen ├── button_icon.png ├── button_split.png ├── debug.dox ├── design.dox ├── intro.dox ├── main.dox └── mditab.png ├── examples ├── CMakeLists.txt ├── example-button.c ├── example-button.h ├── example-button.rc ├── example-chart.c ├── example-chart.h ├── example-chart.rc ├── example-default.rc ├── example-dllgetversion.c ├── example-expand.c ├── example-expand.h ├── example-expand.rc ├── example-grid-customdraw.c ├── example-grid-ownerdata.c ├── example-grid.c ├── example-grid.h ├── example-grid.rc ├── example-html.c ├── example-html.rc ├── example-imgview.c ├── example-imgview.h ├── example-imgview.rc ├── example-mditab-dwm.c ├── example-mditab-dwm.h ├── example-mditab-dwm.rc ├── example-mditab.c ├── example-mditab.h ├── example-mditab.rc ├── example-mdview.c ├── example-mdview.h ├── example-mdview.rc ├── example-menubar.c ├── example-menubar.h ├── example-menubar.rc ├── example-treelist-ownerdata.c ├── example-treelist-ownerdata.h ├── example-treelist-ownerdata.rc ├── example-treelist.c └── res │ ├── app.ico │ ├── bear.ico │ ├── binary.ico │ ├── doc.html │ ├── doc.md │ ├── folder.ico │ ├── history.bmp │ ├── image.png │ ├── img_list.bmp │ ├── lenna.bmp │ ├── lenna.gif │ ├── lenna.jpg │ ├── lenna.png │ ├── manifest.xml │ ├── string.ico │ └── style.css ├── include ├── mCtrl │ ├── _common.h │ ├── _defs.h │ ├── button.h │ ├── chart.h │ ├── dialog.h │ ├── expand.h │ ├── grid.h │ ├── html.h │ ├── imgview.h │ ├── mditab.h │ ├── mdview.h │ ├── menubar.h │ ├── staticlib.h │ ├── table.h │ ├── treelist.h │ └── version.h └── mctrl.h ├── lib ├── acutest │ ├── .gitrepo │ ├── .travis.yml │ ├── CMakeLists.txt │ ├── LICENSE.md │ ├── README.md │ ├── appveyor.yml │ ├── examples │ │ ├── CMakeLists.txt │ │ ├── c-example.c │ │ └── cpp-example.cc │ └── include │ │ └── acutest.h ├── c-reusables │ ├── .gitrepo │ ├── .travis.yml │ ├── CMakeLists.txt │ ├── LICENSE.md │ ├── README.md │ ├── appveyor.yml │ ├── codecov.yml │ ├── coverity.sh │ ├── data │ │ ├── buffer.c │ │ ├── buffer.h │ │ ├── list.h │ │ ├── rbtree.c │ │ ├── rbtree.h │ │ ├── value.c │ │ └── value.h │ ├── encode │ │ ├── base64.c │ │ ├── base64.h │ │ ├── hex.c │ │ └── hex.h │ ├── hash │ │ ├── crc32.c │ │ ├── crc32.h │ │ ├── fnv1a.c │ │ └── fnv1a.h │ ├── mem │ │ ├── malloca.h │ │ ├── memchunk.c │ │ └── memchunk.h │ ├── misc │ │ ├── cmdline.c │ │ ├── cmdline.h │ │ └── defs.h │ ├── tests │ │ ├── CMakeLists.txt │ │ ├── acutest.h │ │ ├── test-base64.c │ │ ├── test-buffer.c │ │ ├── test-cmdline.c │ │ ├── test-crc32.c │ │ ├── test-defs.c │ │ ├── test-fnv1a.c │ │ ├── test-hex.c │ │ ├── test-list.c │ │ ├── test-malloca.c │ │ ├── test-memstream.c │ │ ├── test-rbtree.c │ │ └── test-value.c │ └── win32 │ │ ├── memstream.c │ │ └── memstream.h ├── c-win32 │ ├── .gitrepo │ ├── LICENSE.md │ ├── README.md │ └── include │ │ ├── .gitattributes │ │ ├── c-d2d1.h │ │ ├── c-dwrite.h │ │ └── c-gdiplus.h ├── hsluv-c │ ├── .gitignore │ ├── .gitrepo │ ├── .travis.yml │ ├── CMakeLists.txt │ ├── LICENSE.md │ ├── README.md │ ├── src │ │ ├── CMakeLists.txt │ │ ├── hsluv.c │ │ └── hsluv.h │ └── tests │ │ ├── .gitattributes │ │ ├── CMakeLists.txt │ │ ├── acutest.h │ │ ├── scripts │ │ ├── snapshot-json2c.py │ │ └── snapshot-rev4.json │ │ ├── snapshot.h │ │ └── test_hsluv.c ├── md4c-utf16 │ ├── CMakeLists.txt │ ├── README.md │ ├── md4c-utf16.c │ └── md4c-utf16.h └── md4c │ ├── .gitrepo │ ├── .travis.yml │ ├── CHANGELOG.md │ ├── CMakeLists.txt │ ├── LICENSE.md │ ├── README.md │ ├── appveyor.yml │ ├── codecov.yml │ ├── md2html │ ├── CMakeLists.txt │ ├── cmdline.c │ ├── cmdline.h │ ├── entity.c │ ├── entity.h │ ├── md2html.1 │ ├── md2html.c │ ├── render_html.c │ └── render_html.h │ ├── md4c │ ├── CMakeLists.txt │ ├── md4c.c │ ├── md4c.h │ └── md4c.pc.in │ ├── scripts │ ├── build_folding_map.py │ ├── build_punct_map.py │ ├── build_whitespace_map.py │ ├── coverity.sh │ ├── run-tests.sh │ └── unicode │ │ ├── CaseFolding.txt │ │ └── DerivedGeneralCategory.txt │ └── test │ ├── LICENSE │ ├── cmark.py │ ├── coverage.txt │ ├── latex-math.txt │ ├── normalize.py │ ├── pathological_tests.py │ ├── permissive-email-autolinks.txt │ ├── permissive-url-autolinks.txt │ ├── permissive-www-autolinks.txt │ ├── spec.txt │ ├── spec_tests.py │ ├── strikethrough.txt │ ├── tables.txt │ ├── tasklists.txt │ ├── underline.txt │ └── wiki-links.txt ├── misc └── coverity-scan-model.c ├── scripts ├── build-entity-map.py ├── coverity.sh ├── data │ └── entities.json ├── mkres.sh └── release.sh ├── src ├── CMakeLists.txt ├── anim.c ├── anim.h ├── button.c ├── button.h ├── chart.c ├── chart.h ├── color.c ├── color.h ├── compat.h ├── comua.c ├── comua.h ├── debug.c ├── debug.h ├── dialog.c ├── dialog.h ├── doublebuffer.c ├── doublebuffer.h ├── dsa.c ├── dsa.h ├── entity.c ├── entity.h ├── entity_map.h ├── expand.c ├── expand.h ├── generic.c ├── generic.h ├── grid.c ├── grid.h ├── html.c ├── html.h ├── imgview.c ├── imgview.h ├── labeledit.c ├── labeledit.h ├── mCtrl.def ├── mditab.c ├── mditab.h ├── mdtext.c ├── mdtext.h ├── mdview.c ├── mdview.h ├── menubar.c ├── menubar.h ├── misc.c ├── misc.h ├── module.c ├── module.h ├── mousedrag.c ├── mousedrag.h ├── mousewheel.c ├── mousewheel.h ├── res │ ├── divider-h.cur │ ├── divider-v.cur │ ├── divopen-h.cur │ ├── divopen-v.cur │ ├── expand-19x19.bmp │ ├── expand-24x24.bmp │ ├── expand-29x29.bmp │ ├── lang-cs.rc │ ├── lang-en.rc │ ├── lang-fr.rc │ └── lang-it.rc ├── resource.h ├── resource.h.in ├── resource.rc ├── rgn16.c ├── rgn16.h ├── table.c ├── table.h ├── tooltip.c ├── tooltip.h ├── treelist.c ├── treelist.h ├── url.c ├── url.h ├── version.c ├── version.h.in ├── viewlist.c ├── viewlist.h ├── xcom.c ├── xcom.h ├── xd2d.c ├── xd2d.h ├── xdwm.c ├── xdwm.h ├── xdwrite.c ├── xdwrite.h ├── xwic.c └── xwic.h └── tests ├── CMakeLists.txt ├── test-build.c ├── test-grid.c └── test-table.c /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '[Bug] ...' 5 | 6 | --- 7 | 8 | **mCtrl version:** 9 | Specify mCtrl version. Include whether it is 32-bit or 64-bit build and whether 10 | it is Release or Debug configuration. 11 | 12 | **Windows version:** 13 | Specify Windows version. Is it 32-bit or 64-bit Windows? If relevant, specify 14 | also version of other system components. For example if the bug is about the 15 | HTML control, it can be important what version of Microsoft Explorer is 16 | installed on the system. 17 | 18 | **Describe the bug:** 19 | Describe the bug. The description should cover the following questions: 20 | 1. What behavior do you expect? 21 | 2. What behavior do you get? 22 | 3. How to reproduce the issue? 23 | 24 | **Is the issue related to building?** 25 | If the bug is related to building mCtrl or building your project against its 26 | headers, specify what tool(s) you are using. E.g. is it Microsoft Visual 27 | Studio? Mingw-w64? Something else? What version of it? 28 | 29 | **Attachments:** 30 | If it is relevant, attach a screenshot illustrating what's wrong. 31 | 32 | Also, if it is relevant, providing some code reproducing the issue can be vital. 33 | Ideally in some of these forms: 34 | * a complete source code which can compile as a standalone C or C++ program; 35 | * a patch or pull request to be applied to one of the examples in mCtrl source 36 | tree; 37 | * or (if it is not overly long) as a C function (or few functions) which can 38 | replace whole function (or few functions) in one of those examples. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "Feature request" 3 | about: Suggest an idea for this project 4 | title: '[Feature Request] ...' 5 | labels: 'enhancement' 6 | 7 | --- 8 | 9 | **Is your feature request related to a problem? Please describe.** 10 | A clear and concise description of what the problem is. 11 | Example: I'm always frustrated when... 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've 18 | considered. 19 | 20 | **Additional context** 21 | Add any other context or screenshots about the feature request here. 22 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | 2 | # mCtrl Authors 3 | 4 | The following people (in alphabetical order) have contributed to the mCtrl 5 | project. (Please, make a pull request or let us know if you are missing in 6 | the list.) 7 | 8 | **Jeff Armstrong** (WWW: https://github.com/ArmstrongJ) 9 | * Tree-list view multi-selection. 10 | * Various fixes. 11 | 12 | **Martin Mitáš** (WWW: https://github.com/mity, e-mail: mity@morous.org) 13 | * Founder and main developer. 14 | 15 | **Adam Pritchard** (WWW: https://github.com/adam-p) 16 | * JavaScript integration to the HTML control. 17 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.7) 3 | project(mCtrl C) 4 | 5 | set(MCTRL_MAJOR_VERSION 0) 6 | set(MCTRL_MINOR_VERSION 11) 7 | set(MCTRL_PATCH_VERSION 5) 8 | set(MCTRL_VERSION ${MCTRL_MAJOR_VERSION}.${MCTRL_MINOR_VERSION}.${MCTRL_PATCH_VERSION}) 9 | 10 | 11 | set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo MinSizeRel) 12 | if ("${CMAKE_BUILD_TYPE}" STREQUAL "") 13 | set(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE}) 14 | endif() 15 | 16 | 17 | set(CMAKE_SHARED_LIBRARY_PREFIX "") 18 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") 19 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") 20 | 21 | # set up include-directories 22 | include_directories("${PROJECT_SOURCE_DIR}/include") 23 | include_directories("${PROJECT_SOURCE_DIR}/lib") 24 | include_directories("${PROJECT_SOURCE_DIR}/lib/acutest/include") 25 | include_directories("${PROJECT_SOURCE_DIR}/lib/hsluv-c/src") 26 | include_directories("${PROJECT_SOURCE_DIR}/lib/c-win32/include") 27 | include_directories("${PROJECT_SOURCE_DIR}/lib/md4c-utf16") 28 | 29 | set(HSLUV_C_TESTS OFF CACHE BOOL "Disable building hsluv-c tests.") 30 | set(MCTRL_BUILD_COMPLETETREE ON CACHE BOOL "Tell examples/CMakeListst.txt it is built as part of complete mCtrl build.") 31 | 32 | 33 | OPTION(MCTRL_BUILD_EXAMPLES "Enable/disable building of mCtrl examples" ON) 34 | OPTION(MCTRL_BUILD_TESTS "Enable/disable building of mCtrl tests" ON) 35 | 36 | # Note this an experimental feature. 37 | # See discussion in https://github.com/mity/mctrl/issues/75 38 | OPTION(MCTRL_BUILD_STATIC "Enable/disable build of mCtrl as a static lib" OFF) 39 | 40 | 41 | if(MSVC) 42 | # Enforce multi-threading runtime lib. 43 | string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") 44 | string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") 45 | string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_RELWITHDEBINFO "{$CMAKE_C_FLAGS_RELWITHDEBINFO}") 46 | string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}") 47 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") 48 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") 49 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} /MT") 50 | set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_RELEASE} /MT") 51 | endif() 52 | 53 | 54 | # Add sub-directories 55 | add_subdirectory(lib/hsluv-c) 56 | add_subdirectory(lib/md4c-utf16) 57 | add_subdirectory(src) 58 | if(MCTRL_BUILD_EXAMPLES) 59 | add_subdirectory(examples) 60 | endif() 61 | if(MCTRL_BUILD_TESTS) 62 | add_subdirectory(tests) 63 | endif() 64 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # YAML definition for Appveyor.com continuous integration. 2 | # See http://www.appveyor.com/docs/appveyor-yml 3 | 4 | version: '{branch}-{build}' 5 | 6 | before_build: 7 | - 'cmake --version' 8 | - 'if "%PLATFORM%"=="x64" cmake -G "Visual Studio 12 Win64" .' 9 | - 'if not "%PLATFORM%"=="x64" cmake -G "Visual Studio 12" .' 10 | 11 | build: 12 | project: mCtrl.sln 13 | verbosity: minimal 14 | 15 | after_build: 16 | - '%CONFIGURATION%\test-build.exe' 17 | 18 | skip_tags: true 19 | 20 | os: Windows Server 2012 R2 21 | 22 | configuration: 23 | - Debug 24 | - Release 25 | 26 | platform: 27 | - x64 # 64-bit build 28 | - win32 # 32-bit build 29 | 30 | artifacts: 31 | - path: $(configuration)/*.dll 32 | - path: $(configuration)/*.lib 33 | - path: $(configuration)/*.exe 34 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | *.* -------------------------------------------------------------------------------- /doxygen/button_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/doxygen/button_icon.png -------------------------------------------------------------------------------- /doxygen/button_split.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/doxygen/button_split.png -------------------------------------------------------------------------------- /doxygen/debug.dox: -------------------------------------------------------------------------------- 1 | /** 2 | * @page page_debug Debugging (with) mCtrl 3 | * 4 | * 5 | * @section sec_debug_build Debug Build 6 | * 7 | * @c MCTRL.DLL can be built in Release as well as in Debug configuration. 8 | * In production, the release build should always be used. However for 9 | * diagnostics, debugging and during development of you application, or even 10 | * when developing mCtrl itself, the Debug build may be very helpful. 11 | * 12 | * In general, the debug builds of @c MCTRL.DLL should be binary compatible 13 | * and usable as a drop-in replacement of the Release builds of @c MCTRL.DLL. 14 | * 15 | * The Debug builds differs from the Release builds in the following ways: 16 | * - It is built with majority of compiler optimizations disabled. 17 | * - It is built with debug information so the debugger can provide more info. 18 | * (That is as long as using the same toolchain as mCtrl was built with as 19 | * Microsoft tools in general do not understand DWARF format as produced 20 | * by @c gcc, and @c gdb does not understand PDB format as produced by 21 | * Microsoft's compiler.) 22 | * - It contains some internal assertions to catch internal mCtrl bugs. 23 | * If an assertion is hit, a message box with info about it is displayed, 24 | * a debug message is logged out and the process is terminated. (Under 25 | * debugger, the execution is interrupted via @c DebugBreak() or similar 26 | * function instead of process termination so developer can perform 27 | * further analyzes of the issue.) 28 | * - In case of a detected error (e.g. a @c MCTRL.DLL function called with 29 | * an invalid parameter), it logs down a debug message explaining the issue. 30 | * (See below for more details.) 31 | * 32 | * Since version 0.11.0, debug builds for @c gcc as well as for Visual Studio 33 | * are included in the released binary packages. 34 | * 35 | * 36 | * @section dec_debug_log Debug Logging 37 | * 38 | * As noted above, the debug build of @c MCTRL.DLL logs down some messages 39 | * during the runtime of application linked with @c MCTRL.DLL. The logging 40 | * is performed via the @c OutputDebugString() function. 41 | * 42 | * So this debug output may be seen with any application capable of catching, 43 | * this output which includes Microsoft debugger within Microsoft Visual Studio 44 | * (just run your application within the debugger), @c gdb (ditto), or 45 | * DebugView utility available from the package of SysInternals utilities (see 46 | * https://technet.microsoft.com/en-us/sysinternals/). 47 | * 48 | * Seeing this debug output may help whenever something with mCtrl goes wrong 49 | * and this makes the Debug build of @c MCTRL.DLL very valuable tool during 50 | * application development: 51 | * - If any call (function or control message) to @c MCTRL.DLL fails, the 52 | * output may provide a hint about the reason. 53 | * - Even if it is internal mCtrl bug, the output may be helpful as a part 54 | * of bug report for diagnoses by mCtrl developers. 55 | */ 56 | -------------------------------------------------------------------------------- /doxygen/main.dox: -------------------------------------------------------------------------------- 1 | /** 2 | * @mainpage 3 | * 4 | * mCtrl is @c C open source library for MS Windows, providing a set of user 5 | * interface controls, that complement the standard set as offered by @c 6 | * USER32.DLL and @c COMCTL32.DLL libraries. 7 | * 8 | * Please check project homepage http://mctrl.org for newer versions and more 9 | * actual information. 10 | * 11 | * 12 | * @section sec_license License 13 | * 14 | * This library is free software; you can redistribute it and/or modify it 15 | * under the terms of the GNU Lesser General Public License as published by 16 | * the Free Software Foundation; either version 2.1 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * This library is distributed in the hope that it will be useful, but 20 | * without any warranty; without even the implied warranty of 21 | * merchantability or fitness for a particular purpose. See the 22 | * 23 | * GNU Lesser General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU Lesser General Public 26 | * License along with this library; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 28 | * Boston, MA 02110-1301 USA 29 | * 30 | * 31 | * @section sec_toc Table of Contents 32 | * 33 | * @subsection toc_general General Design 34 | * - @ref page_intro 35 | * - @ref page_design 36 | * - @ref page_debug 37 | * 38 | * @subsection toc_controls Control Reference 39 | * - @ref mCtrl/button.h - Enhanced button control 40 | * - @ref mCtrl/chart.h - Chart control 41 | * - @ref mCtrl/expand.h - Expand/collapse control 42 | * - @ref mCtrl/grid.h - Grid control 43 | * - @ref mCtrl/html.h - HTML control 44 | * - @ref mCtrl/imgview.h - Image view control 45 | * - @ref mCtrl/mditab.h - MDI tab control 46 | * - @ref mCtrl/mdview.h - Markdown view control 47 | * - @ref mCtrl/menubar.h - Menu bar control 48 | * - @ref mCtrl/treelist.h - Tree-list view control 49 | * 50 | * @subsection toc_data Control Data Models 51 | * - @ref mCtrl/table.h - Table (data model for the grid control) 52 | * 53 | * @subsection toc_util Utility Headers 54 | * - @ref mctrl.h - All-in-one header 55 | * - @ref mCtrl/dialog.h - Dialog functions 56 | * - @ref mCtrl/version.h - Retrieving mCtrl version 57 | * - @ref mCtrl/staticlib.h - Helper when using mCtrl built as a static library 58 | * 59 | * @subsection toc_misc Miscellaneous Headers 60 | * (Do not include these directly.) 61 | * - @ref mCtrl/_defs.h - Miscellaneous macros 62 | * - @ref mCtrl/_common.h - Common constants and types 63 | */ 64 | -------------------------------------------------------------------------------- /doxygen/mditab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/doxygen/mditab.png -------------------------------------------------------------------------------- /examples/example-button.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | /* This sample demonstrates basic usage of BUTTON control. */ 7 | 8 | #ifndef EXAMPLE_BUTTON_H 9 | #define EXAMPLE_BUTTON_H 10 | 11 | 12 | /* IDs of dialog and button controls */ 13 | 14 | #define IDD_DIALOG 1000 15 | 16 | #define ID_BUTTON_ICON_1 100 17 | #define ID_BUTTON_ICON_2 101 18 | #define ID_BUTTON_SPLIT_1 102 19 | #define ID_BUTTON_SPLIT_2 103 20 | 21 | 22 | 23 | #endif /* EXAMPLE_BUTTON_H */ 24 | -------------------------------------------------------------------------------- /examples/example-button.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | #include 7 | #include 8 | #include "example-button.h" 9 | 10 | 11 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 12 | #pragma code_page(65001) /* UTF-8 */ 13 | 14 | 15 | /* Manifest enabling XP themes */ 16 | 1 RT_MANIFEST res/manifest.xml 17 | 18 | /* Application icon */ 19 | 2 ICON res/app.ico 20 | 21 | 22 | LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL 23 | 24 | /* Dialog box */ 25 | IDD_DIALOG DIALOG 100, 100, 300, 160 26 | STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME 27 | EXSTYLE WS_EX_DLGMODALFRAME 28 | CAPTION "mCtrl Example: BUTTON Control" 29 | FONT 8, "MS Shell Dlg" 30 | BEGIN 31 | CONTROL "", ID_BUTTON_ICON_1, "BUTTON", WS_TABSTOP | BS_ICON, 5, 5, 35, 35 32 | CONTROL "", ID_BUTTON_ICON_2, MC_WC_BUTTON, WS_TABSTOP | BS_ICON, 5, 45, 35, 35 33 | CONTROL "On left, you can see two buttons with BS_ICON style. The upper one is the standard button (window class 'BUTTON'). If you are running on Windows XP and don't have visual styles disabled you can see its style does not match rest of the window.", -1, "STATIC", 0, 50, 5, 240, 35 34 | CONTROL "The lower button is mCtrl's MC_WC_BUTTON which provides the look and feel consistent with rest of the Windows.", -1, "STATIC", 0, 50, 45, 240, 35 35 | 36 | CONTROL "&Split button", ID_BUTTON_SPLIT_1, MC_WC_BUTTON, WS_TABSTOP | MC_BS_SPLITBUTTON, 5, 90, 70, 25 37 | CONTROL "", ID_BUTTON_SPLIT_2, MC_WC_BUTTON, WS_TABSTOP | BS_ICON | MC_BS_SPLITBUTTON, 5, 120, 70, 35 38 | CONTROL "Microsoft introduced split buttons on Windows Vista's comctl32.dll version 6.0. Some applications implement their own custom control which provide this functionality for compatibility with older Windows versions.", -1, "STATIC", 0, 80, 90, 210, 40 39 | CONTROL "But having each application to reinvent wheel is just bad idea. So mCtrl provides a split button for you.", -1, "STATIC", 0, 80, 130, 210, 20 40 | END 41 | 42 | 43 | -------------------------------------------------------------------------------- /examples/example-chart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | /* This sample demonstrates basic usage of CHART control. */ 7 | 8 | #ifndef EXAMPLE_CHART_H 9 | #define EXAMPLE_CHART_H 10 | 11 | 12 | /* IDs of resources and controls */ 13 | 14 | #define IDD_DIALOG 1000 15 | 16 | #define IDC_CHART_PIE 100 17 | #define IDC_CHART_SCATTER 101 18 | #define IDC_CHART_LINE 102 19 | #define IDC_CHART_AREA 103 20 | #define IDC_CHART_COLUMN 104 21 | #define IDC_CHART_BAR 105 22 | #define IDC_CHART_STACKEDAREA 106 23 | #define IDC_CHART_STACKEDCOLUMN 107 24 | #define IDC_CHART_STACKEDBAR 108 25 | 26 | 27 | #endif /* EXAMPLE_CHART_H */ 28 | -------------------------------------------------------------------------------- /examples/example-chart.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | #include 7 | #include 8 | #include "example-chart.h" 9 | 10 | 11 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 12 | #pragma code_page(65001) /* UTF-8 */ 13 | 14 | 15 | /* Manifest enabling XP themes */ 16 | 1 RT_MANIFEST res/manifest.xml 17 | 18 | /* Application icon */ 19 | 2 ICON res/app.ico 20 | 21 | 22 | LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL 23 | 24 | /* Dialog box */ 25 | IDD_DIALOG DIALOG 100, 100, 622, 322 26 | STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME 27 | EXSTYLE WS_EX_DLGMODALFRAME 28 | CAPTION "mCtrl Example: CHART Control" 29 | FONT 8, "MS Shell Dlg" 30 | BEGIN 31 | CONTROL "Pie chart", IDC_CHART_PIE, MC_WC_CHART, MC_CHS_PIE | MC_CHS_DOUBLEBUFFER, 7, 7, 200, 100, WS_EX_STATICEDGE 32 | CONTROL "Scatter chart", IDC_CHART_SCATTER, MC_WC_CHART, MC_CHS_SCATTER | MC_CHS_DOUBLEBUFFER, 211, 7, 200, 100, WS_EX_STATICEDGE 33 | CONTROL "Line chart", IDC_CHART_LINE, MC_WC_CHART, MC_CHS_LINE | MC_CHS_DOUBLEBUFFER, 415, 7, 200, 100, WS_EX_STATICEDGE 34 | 35 | CONTROL "Area chart", IDC_CHART_AREA, MC_WC_CHART, MC_CHS_AREA | MC_CHS_DOUBLEBUFFER, 7, 111, 200, 100, WS_EX_STATICEDGE 36 | CONTROL "Column chart", IDC_CHART_COLUMN, MC_WC_CHART, MC_CHS_COLUMN | MC_CHS_DOUBLEBUFFER, 211, 111, 200, 100, WS_EX_STATICEDGE 37 | CONTROL "Bar chart", IDC_CHART_BAR, MC_WC_CHART, MC_CHS_BAR | MC_CHS_DOUBLEBUFFER, 415, 111, 200, 100, WS_EX_STATICEDGE 38 | 39 | CONTROL "Stacked area chart", IDC_CHART_STACKEDAREA, MC_WC_CHART, MC_CHS_STACKEDAREA | MC_CHS_DOUBLEBUFFER, 7, 215, 200, 100, WS_EX_STATICEDGE 40 | CONTROL "Stacked column chart", IDC_CHART_STACKEDCOLUMN, MC_WC_CHART, MC_CHS_STACKEDCOLUMN | MC_CHS_DOUBLEBUFFER, 211, 215, 200, 100, WS_EX_STATICEDGE 41 | CONTROL "Stacked bar chart", IDC_CHART_STACKEDBAR, MC_WC_CHART, MC_CHS_STACKEDBAR | MC_CHS_DOUBLEBUFFER, 415, 215, 200, 100, WS_EX_STATICEDGE 42 | END 43 | -------------------------------------------------------------------------------- /examples/example-default.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | #include 7 | 8 | 9 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 10 | #pragma code_page(65001) /* UTF-8 */ 11 | 12 | 13 | /* Manifest enabling XP theme on Win XP */ 14 | 1 RT_MANIFEST res/manifest.xml 15 | 16 | /* Application icon */ 17 | 2 ICON res/app.ico 18 | -------------------------------------------------------------------------------- /examples/example-dllgetversion.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | /* This sample demonstrates how to get mCtrl.dll version through the de-facto 7 | * Windowish standard way with DllGetVersion() function. 8 | * 9 | * See MSDN for some more information about DllGetVersion: 10 | * http://msdn.microsoft.com/en-us/library/bb776404%28VS.85%29.aspx 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | int APIENTRY 20 | _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) 21 | { 22 | HMODULE hDll; 23 | DLLGETVERSIONPROC fnDllGetVersion; 24 | DLLVERSIONINFO vi; 25 | TCHAR buffer[64]; 26 | 27 | /* Load mCtrl.dll */ 28 | hDll = LoadLibrary(_T("mCtrl.dll")); 29 | if(hDll == NULL) { 30 | MessageBox(NULL, _T("Cannot load mCtrl.dll library."), 31 | _T("mCtrl Sample: DllGetVersion"), MB_OK | MB_ICONERROR); 32 | return 1; 33 | } 34 | 35 | /* Get DllGetVersion function address */ 36 | fnDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hDll, "DllGetVersion"); 37 | if(fnDllGetVersion == NULL) { 38 | MessageBox(NULL, _T("Cannot get DllGetVersion function."), 39 | _T("mCtrl Sample: DllGetVersion"), MB_OK | MB_ICONERROR); 40 | FreeLibrary(hDll); 41 | return 1; 42 | } 43 | 44 | /* Call the function to get the version */ 45 | vi.cbSize = sizeof(DLLVERSIONINFO); 46 | if(fnDllGetVersion(&vi) != S_OK) { 47 | MessageBox(NULL, _T("DllGetVersion failed."), _T("Error"), 48 | MB_OK | MB_ICONERROR); 49 | FreeLibrary(hDll); 50 | return 1; 51 | } 52 | 53 | /* Show the results */ 54 | _sntprintf(buffer, 64, _T("Detected mCtrl.dll version %u.%u.%u"), 55 | vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber); 56 | MessageBox(NULL, buffer, _T("mCtrl Sample: DllGetVersion"), MB_OK); 57 | 58 | FreeLibrary(hDll); 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /examples/example-expand.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | /* This sample demonstrates basic usage of EXPAND control. */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include "example-expand.h" 16 | 17 | 18 | static HINSTANCE hInst; 19 | 20 | 21 | /* Main window procedure */ 22 | static INT_PTR CALLBACK 23 | DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) 24 | { 25 | switch(uMsg) { 26 | case WM_INITDIALOG: 27 | SendDlgItemMessage(hwndDlg, IDC_EXPAND, MC_EXM_EXPAND, FALSE, MC_EXE_NOANIMATE); 28 | return TRUE; 29 | 30 | case WM_CLOSE: 31 | EndDialog(hwndDlg, 0); 32 | break; 33 | 34 | default: 35 | return FALSE; 36 | } 37 | 38 | return TRUE; 39 | } 40 | 41 | 42 | int APIENTRY 43 | _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) 44 | { 45 | hInst = hInstance; 46 | 47 | /* Initialize mCtrl control */ 48 | mcExpand_Initialize(); 49 | 50 | /* Load and show a dialog. */ 51 | mcDialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG), NULL, DlgProc, MC_DF_DEFAULTFONT); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /examples/example-expand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | /* This sample demonstrates basic usage of MDITAB control. */ 7 | 8 | #ifndef EXAMPLE_EXPAND_H 9 | #define EXAMPLE_EXPAND_H 10 | 11 | 12 | /* IDs of resources and controls */ 13 | 14 | #define IDD_DIALOG 1000 15 | 16 | #define IDC_EXPAND 100 17 | 18 | 19 | #endif /* EXAMPLE_EXPAND_H */ 20 | -------------------------------------------------------------------------------- /examples/example-expand.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | #include 7 | #include 8 | #include "example-expand.h" 9 | 10 | 11 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 12 | #pragma code_page(65001) /* UTF-8 */ 13 | 14 | 15 | /* Manifest enabling XP themes */ 16 | 1 RT_MANIFEST res/manifest.xml 17 | 18 | /* Application icon */ 19 | 2 ICON res/app.ico 20 | 21 | 22 | LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL 23 | 24 | /* Dialog box */ 25 | IDD_DIALOG DIALOG 100, 100, 300, 88 26 | STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME 27 | EXSTYLE WS_EX_DLGMODALFRAME 28 | CAPTION "mCtrl Example: EXPAND Control" 29 | FONT 8, "MS Shell Dlg" 30 | BEGIN 31 | CONTROL "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi fermentum, libero at tincidunt ultricies, turpis purus cursus lorem, at tempor erat purus sit amet quam. Nulla et ante massa. Integer pretium eros sed lectus scelerisque eu dictum orci.", -1, "STATIC", 0, 7, 7, 286, 24 32 | CONTROL "", IDC_EXPAND, MC_WC_EXPAND, WS_TABSTOP | MC_EXS_CACHESIZES | MC_EXS_ANIMATE, 7, 38, 100, 12 33 | CONTROL "Vivamus neque dui, dictum sit amet gravida nec, aliquet et elit. Aenean pretium auctor leo at commodo. Quisque nec eros diam. Suspendisse potenti. Nam quis nisl metus. Praesent eros orci, interdum ut sagittis ut, vulputate et ante. Nullam non leo.", -1, "STATIC", 0, 7, 57, 286, 24 34 | END 35 | -------------------------------------------------------------------------------- /examples/example-grid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | #ifndef EXAMPLE_GRID_H 7 | #define EXAMPLE_GRID_H 8 | 9 | 10 | /* IDs of resources and controls */ 11 | #define IDI_BEAR 1000 12 | #define IDC_GRID 100 13 | 14 | 15 | #endif /* EXAMPLE_GRID_H */ 16 | -------------------------------------------------------------------------------- /examples/example-grid.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | #include 7 | #include "example-grid.h" 8 | 9 | 10 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 11 | #pragma code_page(65001) /* UTF-8 */ 12 | 13 | 14 | /* Manifest enabling XP theme on Win XP */ 15 | 1 RT_MANIFEST res/manifest.xml 16 | 17 | /* Application icon */ 18 | 2 ICON res/app.ico 19 | 20 | 21 | /* Some icon we show in one of the grid cells */ 22 | IDI_BEAR ICON res/bear.ico 23 | -------------------------------------------------------------------------------- /examples/example-html.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | #include 7 | 8 | 9 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 10 | #pragma code_page(65001) /* UTF-8 */ 11 | 12 | 13 | /* Manifest enabling XP themes */ 14 | 1 RT_MANIFEST res/manifest.xml 15 | 16 | /* Application icon */ 17 | 2 ICON res/app.ico 18 | 19 | 20 | /* Misc. resources */ 21 | toolbar BITMAP res/history.bmp /* Image list for toolbar */ 22 | 23 | 24 | LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL 25 | 26 | /* HTML resources */ 27 | doc.html HTML res/doc.html /* Initial HTML page */ 28 | style.css HTML res/style.css /* CSS linked from doc.html */ 29 | image.png HTML res/image.png /* An image linked from doc.html */ 30 | -------------------------------------------------------------------------------- /examples/example-imgview.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | /* This sample demonstrates basic usage of IMGVIEW control. */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include "example-imgview.h" 16 | 17 | 18 | static HINSTANCE hInst; 19 | 20 | 21 | /* Main window procedure */ 22 | static INT_PTR CALLBACK 23 | DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) 24 | { 25 | switch(uMsg) { 26 | case WM_CLOSE: 27 | EndDialog(hwndDlg, 0); 28 | break; 29 | 30 | case WM_INITDIALOG: 31 | return TRUE; 32 | 33 | default: 34 | return FALSE; 35 | } 36 | 37 | return TRUE; 38 | } 39 | 40 | 41 | int APIENTRY 42 | _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) 43 | { 44 | hInst = hInstance; 45 | 46 | /* Initialize mCtrl control */ 47 | mcImgView_Initialize(); 48 | 49 | /* Load and show a dialog. */ 50 | mcDialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG), NULL, DlgProc, MC_DF_DEFAULTFONT); 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /examples/example-imgview.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | /* This sample demonstrates basic usage of IMGVIEW control. */ 7 | 8 | #ifndef EXAMPLE_IMGVIEW_H 9 | #define EXAMPLE_IMGVIEW_H 10 | 11 | 12 | /* IDs of resources and controls */ 13 | 14 | #define IDD_DIALOG 1000 15 | 16 | 17 | #endif /* EXAMPLE_IMGVIEW_H */ 18 | -------------------------------------------------------------------------------- /examples/example-imgview.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | #include 7 | #include 8 | #include "example-imgview.h" 9 | 10 | 11 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 12 | #pragma code_page(65001) /* UTF-8 */ 13 | 14 | 15 | /* Manifest enabling XP themes */ 16 | 1 RT_MANIFEST res/manifest.xml 17 | 18 | /* Application icon */ 19 | 2 ICON res/app.ico 20 | 21 | 22 | /* PNG image */ 23 | 50 RCDATA res/lenna.bmp 24 | 51 RCDATA res/lenna.png 25 | 52 RCDATA res/lenna.jpg 26 | 53 RCDATA res/lenna.gif 27 | 28 | 29 | LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL 30 | 31 | /* Dialog box */ 32 | IDD_DIALOG DIALOG 100, 100, 324, 255 33 | STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME 34 | EXSTYLE WS_EX_DLGMODALFRAME 35 | CAPTION "mCtrl Example: IMGVIEW Control" 36 | FONT 8, "MS Shell Dlg" 37 | BEGIN 38 | /* Several image view controls, each referring to different image format 39 | * and different control style and size to show possible scaling options. */ 40 | CONTROL "BMP:", -1, "STATIC", 0, 7, 7, 30, 10 41 | CONTROL 50, -1, MC_WC_IMGVIEW, 0, 7, 17, 100, 100, WS_EX_STATICEDGE 42 | CONTROL "PNG:", -1, "STATIC", 0, 112, 7, 30, 10 43 | CONTROL 51, -1, MC_WC_IMGVIEW, MC_IVS_REALSIZEIMAGE, 112, 17, 100, 100, WS_EX_STATICEDGE 44 | CONTROL "JPG:", -1, "STATIC", 0, 7, 123, 30, 10 45 | CONTROL 52, -1, MC_WC_IMGVIEW, MC_IVS_REALSIZECONTROL, 7, 133, 205, 100, WS_EX_STATICEDGE 46 | CONTROL "GIF:", -1, "STATIC", 0, 217, 7, 30, 10 47 | CONTROL 53, -1, MC_WC_IMGVIEW, MC_IVS_REALSIZECONTROL, 217, 17, 100, 216, WS_EX_STATICEDGE 48 | CONTROL "Image view controls with images in several formats, with various scaling styles.", -1, "STATIC", SS_CENTER, 7, 239, 310, 10 49 | END 50 | -------------------------------------------------------------------------------- /examples/example-mditab-dwm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | /* This sample demonstrates basic usage of MDITAB control with style 7 | * MC_MTS_EXTENDWINDOWFRAME. */ 8 | 9 | #ifndef EXAMPLE_MDITAB_DWM_H 10 | #define EXAMPLE_MDITAB_DWM_H 11 | 12 | 13 | /* IDs of resources and controls */ 14 | 15 | #define IDL_IMGLIST 1000 16 | 17 | #define IDC_MDITAB 100 18 | #define IDC_BUTTON_NEW 101 19 | 20 | 21 | #endif /* EXAMPLE_MDITAB_DWM_H */ 22 | -------------------------------------------------------------------------------- /examples/example-mditab-dwm.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | #include 7 | #include "example-mditab-dwm.h" 8 | 9 | 10 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 11 | #pragma code_page(65001) /* UTF-8 */ 12 | 13 | 14 | /* Manifest enabling XP themes */ 15 | 1 RT_MANIFEST res/manifest.xml 16 | 17 | /* Application icon */ 18 | 2 ICON res/app.ico 19 | 20 | 21 | /* Image list */ 22 | IDL_IMGLIST BITMAP res/img_list.bmp 23 | -------------------------------------------------------------------------------- /examples/example-mditab.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | /* This sample demonstrates basic usage of MDITAB control. */ 7 | 8 | #ifndef EXAMPLE_MDITAB_H 9 | #define EXAMPLE_MDITAB_H 10 | 11 | 12 | /* IDs of resources and controls */ 13 | 14 | #define IDL_IMGLIST 1000 15 | 16 | #define IDC_MDITAB 100 17 | #define IDC_BUTTON_NEW 101 18 | 19 | 20 | #endif /* EXAMPLE_MDITAB_H */ 21 | -------------------------------------------------------------------------------- /examples/example-mditab.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | #include 7 | #include "example-mditab.h" 8 | 9 | 10 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 11 | #pragma code_page(65001) /* UTF-8 */ 12 | 13 | 14 | /* Manifest enabling XP themes */ 15 | 1 RT_MANIFEST res/manifest.xml 16 | 17 | /* Application icon */ 18 | 2 ICON res/app.ico 19 | 20 | 21 | /* Image list */ 22 | IDL_IMGLIST BITMAP res/img_list.bmp 23 | -------------------------------------------------------------------------------- /examples/example-mdview.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | /* This sample demonstrates basic usage of MENUBAR control. */ 7 | 8 | #ifndef EXAMPLE_MDVIEW_H 9 | #define EXAMPLE_MDVIEW_H 10 | 11 | 12 | 13 | #endif /* EXAMPLE_MDVIEW_H */ 14 | -------------------------------------------------------------------------------- /examples/example-mdview.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | #include 7 | #include "example-mdview.h" 8 | 9 | 10 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 11 | #pragma code_page(65001) /* UTF-8 */ 12 | 13 | 14 | /* Manifest enabling XP themes */ 15 | 1 RT_MANIFEST res/manifest.xml 16 | 17 | /* Application icon */ 18 | 2 ICON res/app.ico 19 | 20 | 21 | LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL 22 | 23 | /* Markdown resources. 24 | * 25 | * Note that we use RT_HTML resource type, as it is semantically close to 26 | * what we do. But you could use other resource type (e.g. RT_RCDATA or 27 | * custom one >= 256) if you prefer. 28 | * 29 | * The control does not enforce any type. Application just has to specify 30 | * in argument of the message MC_MDM_LOADRESOURCE. 31 | */ 32 | 33 | doc.md HTML res/doc.md 34 | -------------------------------------------------------------------------------- /examples/example-menubar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | /* This sample demonstrates basic usage of MENUBAR control. */ 7 | 8 | #ifndef EXAMPLE_MENUBAR_H 9 | #define EXAMPLE_MENUBAR_H 10 | 11 | 12 | /* IDs of resources and controls */ 13 | 14 | #define ID_MENU 1000 15 | #define ID_MENU_SM 1001 16 | #define ID_IMGLIST 1002 17 | 18 | 19 | #endif /* EXAMPLE_MDITAB_H */ 20 | -------------------------------------------------------------------------------- /examples/example-menubar.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | #include 7 | #include "example-menubar.h" 8 | 9 | 10 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 11 | #pragma code_page(65001) /* UTF-8 */ 12 | 13 | 14 | /* Manifest enabling XP themes */ 15 | 1 RT_MANIFEST res/manifest.xml 16 | 17 | /* Application icon */ 18 | 2 ICON res/app.ico 19 | 20 | 21 | LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL 22 | 23 | /* Menu */ 24 | ID_MENU MENU 25 | BEGIN 26 | POPUP "&File" 27 | BEGIN 28 | MENUITEM "&New", 100 29 | MENUITEM "&Open...", 101 30 | MENUITEM "&Close", 102 31 | MENUITEM "Clos&e All", 103 32 | MENUITEM SEPARATOR 33 | MENUITEM "&Save", 104 34 | MENUITEM "Save &As...", 105 35 | MENUITEM "Save A&ll", 106 36 | MENUITEM SEPARATOR 37 | MENUITEM "E&xit", 107 38 | END 39 | 40 | POPUP "&Edit" 41 | BEGIN 42 | MENUITEM "&Undo", 108 43 | MENUITEM "&Redo", 109 44 | MENUITEM SEPARATOR 45 | MENUITEM "Cu&t", 110 46 | MENUITEM "&Copy", 111 47 | MENUITEM "&Paste", 112 48 | MENUITEM SEPARATOR 49 | MENUITEM "Select &All", 113 50 | END 51 | 52 | POPUP "&Search" 53 | BEGIN 54 | MENUITEM "&Find...", 114 55 | MENUITEM "Find &Next", 115, GRAYED 56 | MENUITEM "Find &Previous", 116, GRAYED 57 | MENUITEM "&Replace...", 117 58 | END 59 | 60 | POPUP "&Popup" 61 | BEGIN 62 | POPUP "Deep &1" GRAYED 63 | BEGIN 64 | MENUITEM "&Aaaa", 118 65 | MENUITEM "&Bbbb", 119 66 | END 67 | 68 | POPUP "Deep &2" 69 | BEGIN 70 | MENUITEM "&Cccc", 120, GRAYED 71 | MENUITEM "&Dddd", 121 72 | END 73 | 74 | POPUP "Deep &3" 75 | BEGIN 76 | MENUITEM "&Eeee", 122 77 | MENUITEM "&Ffff", 123 78 | END 79 | END 80 | 81 | POPUP "&Help" 82 | BEGIN 83 | MENUITEM "&About...", 124 84 | END 85 | END 86 | 87 | 88 | /* Smaller menu */ 89 | ID_MENU_SM MENU 90 | BEGIN 91 | POPUP "F&oo" 92 | BEGIN 93 | MENUITEM "Foo &1", 200 94 | MENUITEM "Foo &2", 201 95 | END 96 | POPUP "&Bar" 97 | BEGIN 98 | MENUITEM "Bar &1", 202 99 | MENUITEM "Bar &2", 203 100 | MENUITEM "Bar &3", 204 101 | END 102 | END 103 | 104 | 105 | /* Image list */ 106 | ID_IMGLIST BITMAP res/img_list.bmp 107 | -------------------------------------------------------------------------------- /examples/example-treelist-ownerdata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | /* This sample demonstrates usage of dynamically populated TREELIST control. 7 | * The technique allows to have huge tree hiearchies without eating enormous 8 | * amounts of memory. 9 | * 10 | * The example implements a viewer into the system registry, allocating 11 | * data only for items for registry keys and values of expanded nodes only. 12 | */ 13 | 14 | #ifndef EXAMPLE_TREELIST2_H 15 | #define EXAMPLE_TREELIST2_H 16 | 17 | 18 | /* IDs of resources */ 19 | 20 | #define IDI_REG_KEY 1000 21 | #define IDI_REG_VALUE_STR 1001 22 | #define IDI_REG_VALUE_BIN 1002 23 | 24 | 25 | #endif /* EXAMPLE_TREELIST2_H */ 26 | -------------------------------------------------------------------------------- /examples/example-treelist-ownerdata.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains example code for mCtrl library. Code of this example 3 | * (but not the library itself) has been released into the public domain. 4 | */ 5 | 6 | #include 7 | #include "example-treelist-ownerdata.h" 8 | 9 | 10 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 11 | #pragma code_page(65001) /* UTF-8 */ 12 | 13 | 14 | /* Manifest enabling XP theme on Win XP */ 15 | 1 RT_MANIFEST res/manifest.xml 16 | 17 | /* Application icon */ 18 | 2 ICON res/app.ico 19 | 20 | 21 | /* Icons used in the treelist */ 22 | IDI_REG_KEY ICON res/folder.ico 23 | IDI_REG_VALUE_STR ICON res/string.ico 24 | IDI_REG_VALUE_BIN ICON res/binary.ico 25 | -------------------------------------------------------------------------------- /examples/res/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/examples/res/app.ico -------------------------------------------------------------------------------- /examples/res/bear.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/examples/res/bear.ico -------------------------------------------------------------------------------- /examples/res/binary.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/examples/res/binary.ico -------------------------------------------------------------------------------- /examples/res/folder.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/examples/res/folder.ico -------------------------------------------------------------------------------- /examples/res/history.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/examples/res/history.bmp -------------------------------------------------------------------------------- /examples/res/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/examples/res/image.png -------------------------------------------------------------------------------- /examples/res/img_list.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/examples/res/img_list.bmp -------------------------------------------------------------------------------- /examples/res/lenna.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/examples/res/lenna.bmp -------------------------------------------------------------------------------- /examples/res/lenna.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/examples/res/lenna.gif -------------------------------------------------------------------------------- /examples/res/lenna.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/examples/res/lenna.jpg -------------------------------------------------------------------------------- /examples/res/lenna.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/examples/res/lenna.png -------------------------------------------------------------------------------- /examples/res/manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | mCtrl Sample 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /examples/res/string.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/examples/res/string.ico -------------------------------------------------------------------------------- /examples/res/style.css: -------------------------------------------------------------------------------- 1 | 2 | BODY { 3 | margin: 2em; 4 | font-family: sans-serif; 5 | } 6 | 7 | A { 8 | font-weight: bold; 9 | } 10 | 11 | .img { 12 | float: right; 13 | } 14 | 15 | .big { 16 | font-weight: bold; 17 | font-size: 300%; 18 | text-align: center; 19 | } 20 | -------------------------------------------------------------------------------- /include/mCtrl/_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2008-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MCTRL_DEFS_H 24 | #define MCTRL_DEFS_H 25 | 26 | #include 27 | #include 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | 34 | /** 35 | * @file 36 | * @brief Common definitions 37 | * 38 | * @warning You should not include this header directly. It is included by all 39 | * public mCtrl headers. 40 | * 41 | * This helper header file provides some macro definitions shared by other 42 | * public mCtrl headers. 43 | */ 44 | 45 | 46 | /** 47 | * Helper macro specifying the calling convention of functions exported 48 | * by @c MCTRL.DLL. You should not use it directly. 49 | */ 50 | #define MCTRL_API __stdcall 51 | 52 | 53 | #ifdef UNICODE 54 | /** Helper macro for unicode resolution. You should not use it directly. */ 55 | #define MCTRL_NAME_AW(name) name##W 56 | #else 57 | #define MCTRL_NAME_AW(name) name##A 58 | #endif 59 | 60 | 61 | #ifdef __cplusplus 62 | } /* extern "C" */ 63 | #endif 64 | 65 | #endif /* MCTRL_DEFS_H */ 66 | -------------------------------------------------------------------------------- /include/mCtrl/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2008-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MCTRL_VERSION_H 24 | #define MCTRL_VERSION_H 25 | 26 | #include 27 | #include 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | 34 | /** 35 | * @file 36 | * @brief Retrieving mCtrl version. 37 | * 38 | * This header provides a functions to retrieve mCtrl version. 39 | * 40 | * A simpler and very straightforward way is to call the function @ref 41 | * mcVersion. 42 | * 43 | * More generic way is to use a de-facto standard way by calling the function 44 | * @c DllGetVersion. @c MCTRL.DLL exports this function, as a lot of standard 45 | * DLLs distributed by Microsoft does. Note this function has no declaration 46 | * in any mCtrl public header, as it is intended to be used with @c LoadLibrary 47 | * only. Prototype of the function looks like this: 48 | * 49 | * @code 50 | * HRESULT MCTRL_API DllGetVersion(DLLVERSIONINFO* pdvi); 51 | * @endcode 52 | * 53 | * The function supports @c DLLVERSIONINFO as well as @c DLLVERSIONINFO2 54 | * structure. See documentation of the function on MSDN for further info 55 | * about the function:\n 56 | * http://msdn.microsoft.com/en-us/library/bb776404%28VS.85%29.aspx 57 | */ 58 | 59 | 60 | /** 61 | * @name Structures 62 | */ 63 | /*@{*/ 64 | 65 | /** 66 | * @brief Structure describing @c MCTRL.DLL version. 67 | * @sa @ref mcVersion 68 | */ 69 | typedef struct MC_VERSION_tag { 70 | /** Major version number. */ 71 | DWORD dwMajor; 72 | /** Minor version number. */ 73 | DWORD dwMinor; 74 | /** Release version number. */ 75 | DWORD dwRelease; 76 | } MC_VERSION; 77 | 78 | /*@}*/ 79 | 80 | 81 | /** 82 | * @name Functions 83 | */ 84 | /*@{*/ 85 | 86 | /** 87 | * @brief Retrieve @c MCTRL.DLL version. 88 | * @param[out] lpVersion Pointer to the version structure. 89 | */ 90 | void MCTRL_API mcVersion(MC_VERSION* lpVersion); 91 | 92 | /*@}*/ 93 | 94 | 95 | #ifdef __cplusplus 96 | } /* extern "C" */ 97 | #endif 98 | 99 | #endif /* #define MCTRL_VERSION_H */ 100 | -------------------------------------------------------------------------------- /include/mctrl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2011-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MCTRL_H 24 | #define MCTRL_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | 43 | /** 44 | * @file 45 | * 46 | * This header is provided only for convenience. It just includes all the 47 | * other mCtrl headers, so application developers have the option to include 48 | * just one header file instead of many. 49 | */ 50 | 51 | 52 | #endif /* MCTRL_H */ 53 | -------------------------------------------------------------------------------- /lib/acutest/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/mity/acutest 8 | branch = master 9 | commit = 8881ad41b2ed84c5c3658319ec54b20563fb263c 10 | parent = f1d0cdaec5f5b6d3ee84d3643dde60a613705f6a 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /lib/acutest/.travis.yml: -------------------------------------------------------------------------------- 1 | # YAML definition for travis-ci.com continuous integration. 2 | # See https://docs.travis-ci.com/user/languages/c 3 | 4 | # Container-based infrastructure (Linux) 5 | # * https://docs.travis-ci.com/user/migrating-from-legacy/#How-can-I-use-container-based-infrastructure%3F 6 | sudo: 7 | - false 8 | 9 | language: c++ 10 | 11 | compiler: 12 | - gcc 13 | - clang 14 | 15 | env: 16 | - CFLAGS="-std=c99 -pedantic" CONFIG=Debug # C99 17 | - CFLAGS="-std=c99 -pedantic" CONFIG=Release 18 | - CFLAGS="-std=c11 -pedantic" CONFIG=Debug # C11 19 | - CFLAGS="-std=c11 -pedantic" CONFIG=Release 20 | - CXXFLAGS="-std=c++11 -pedantic" CONFIG=Debug # C++11 21 | - CXXFLAGS="-std=c++11 -pedantic" CONFIG=Release 22 | # Too old compilers on travis-ci.org for these: 23 | #- CXXFLAGS="-std=c++14 -pedantic" CONFIG=Debug # C++14 24 | #- CXXFLAGS="-std=c++14 -pedantic" CONFIG=Release 25 | #- CXXFLAGS="-std=c++17 -pedantic" CONFIG=Debug # C++17 26 | #- CXXFLAGS="-std=c++17 -pedantic" CONFIG=Release 27 | 28 | before_script: 29 | - mkdir build 30 | - cd build 31 | - cmake -DCMAKE_BUILD_TYPE=$CONFIG -G 'Unix Makefiles' .. 32 | 33 | script: 34 | - make VERBOSE=1 35 | -------------------------------------------------------------------------------- /lib/acutest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 2.8) 3 | project(Acutest C CXX) 4 | 5 | 6 | set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo MinSizeRel) 7 | if("${CMAKE_BUILD_TYPE}" STREQUAL "") 8 | set(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE}) 9 | 10 | if("${CMAKE_BUILD_TYPE}" STREQUAL "") 11 | set(CMAKE_BUILD_TYPE "Release") 12 | endif() 13 | endif() 14 | 15 | 16 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) 17 | 18 | 19 | if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") 20 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") 21 | elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") 22 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") 23 | elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") 24 | # Specify proper C runtime library: 25 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") 26 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") 27 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} /MT") 28 | set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_RELEASE} /MT") 29 | endif() 30 | 31 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") 32 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") 33 | elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") 34 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") 35 | elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") 36 | # Specify proper C runtime library: 37 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") 38 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") 39 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} /MT") 40 | set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELEASE} /MT") 41 | endif() 42 | 43 | 44 | add_subdirectory(examples) 45 | -------------------------------------------------------------------------------- /lib/acutest/LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | # The MIT License (MIT) 3 | 4 | Copyright © 2013-2019 Martin Mitáš 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a 7 | copy of this software and associated documentation files (the “Software”), 8 | to deal in the Software without restriction, including without limitation 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | and/or sell copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /lib/acutest/appveyor.yml: -------------------------------------------------------------------------------- 1 | # YAML definition for Appveyor.com continuous integration. 2 | # See http://www.appveyor.com/docs/appveyor-yml 3 | 4 | version: '{branch}-{build}' 5 | 6 | before_build: 7 | - 'cmake --version' 8 | - 'if "%PLATFORM%"=="x64" cmake -G "Visual Studio 12 Win64" .' 9 | - 'if not "%PLATFORM%"=="x64" cmake -G "Visual Studio 12" .' 10 | 11 | build: 12 | project: Acutest.sln 13 | verbosity: minimal 14 | 15 | skip_tags: true 16 | 17 | os: 18 | - Windows Server 2012 R2 19 | 20 | configuration: 21 | - Debug 22 | - Release 23 | 24 | platform: 25 | - x64 # 64-bit build 26 | - win32 # 32-bit build 27 | -------------------------------------------------------------------------------- /lib/acutest/examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories("${PROJECT_SOURCE_DIR}/include") 3 | 4 | add_executable(c-example c-example.c ../include/acutest.h) 5 | add_executable(cpp-example cpp-example.cc ../include/acutest.h) 6 | -------------------------------------------------------------------------------- /lib/acutest/examples/c-example.c: -------------------------------------------------------------------------------- 1 | 2 | #include "acutest.h" 3 | 4 | 5 | void test_tutorial(void) 6 | { 7 | void* mem; 8 | 9 | mem = malloc(10); 10 | TEST_CHECK(mem != NULL); 11 | 12 | mem = realloc(mem, 20); 13 | TEST_CHECK(mem != NULL); 14 | 15 | free(mem); 16 | } 17 | 18 | void 19 | test_fail(void) 20 | { 21 | int a, b; 22 | 23 | /* This condition is designed to fail so you can see how the failed test 24 | * output looks like. */ 25 | a = 1; 26 | b = 2; 27 | TEST_CHECK(a + b == 5); 28 | 29 | /* Also show TEST_CHECK_ in action */ 30 | TEST_CHECK_(a + b == 5, "%d + %d == 5", a, b); 31 | 32 | /* We may also show more information about the failure. */ 33 | if(!TEST_CHECK(a + b == 5)) { 34 | TEST_MSG("a: %d", a); 35 | TEST_MSG("b: %d", b); 36 | } 37 | 38 | /* The macros TEST_MSG() do write down something only when the precedin 39 | * condition fails, so we can avoid the 'if'. */ 40 | TEST_CHECK(a + b == 3); 41 | TEST_MSG("a: %d", a); 42 | TEST_MSG("b: %d", b); 43 | } 44 | 45 | 46 | 47 | static void 48 | helper(void) 49 | { 50 | /* Kill the current test with a condition which is never true. */ 51 | TEST_ASSERT(1 == 2); 52 | 53 | /* This never happens because the test is aborted above. */ 54 | TEST_CHECK(1 + 2 == 2 + 1); 55 | } 56 | 57 | void 58 | test_abort(void) 59 | { 60 | helper(); 61 | 62 | /* This never happens because the test is aborted inside the helper(). */ 63 | TEST_CHECK(1 * 2 == 2 * 1); 64 | } 65 | 66 | void 67 | test_crash(void) 68 | { 69 | int* invalid = ((int*)NULL) + 0xdeadbeef; 70 | 71 | *invalid = 42; 72 | TEST_CHECK_(1 == 1, "We should never get here, due to the write into " 73 | "the invalid address."); 74 | } 75 | 76 | 77 | TEST_LIST = { 78 | { "tutorial", test_tutorial }, 79 | { "fail", test_fail }, 80 | { "abort", test_abort }, 81 | { "crash", test_crash }, 82 | { NULL, NULL } 83 | }; 84 | -------------------------------------------------------------------------------- /lib/c-reusables/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/mity/c-reusables 8 | branch = master 9 | commit = d99b32e13a225127da55bc27b51d7888f14773f9 10 | parent = 51e1b38d2836429dbad84f2a9c42bfe2415510c7 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /lib/c-reusables/.travis.yml: -------------------------------------------------------------------------------- 1 | # YAML definition for travis-ci.com continuous integration. 2 | # See https://docs.travis-ci.com/user/languages/c 3 | 4 | language: c 5 | 6 | compiler: 7 | - gcc 8 | 9 | addons: 10 | apt: 11 | packages: 12 | - lcov # for generating code coverage report 13 | 14 | before_script: 15 | - mkdir build 16 | - cd build 17 | - CFLAGS='--coverage -g -O0' cmake -DCMAKE_BUILD_TYPE=Debug -G 'Unix Makefiles' .. 18 | 19 | script: 20 | - make VERBOSE=1 21 | 22 | after_success: 23 | # Run tests 24 | - for testsuite in test-*; do echo "Running $testsuite:"; ./$testsuite; done 25 | # Create coverage data 26 | - lcov --directory . --capture --output-file coverage.info # capture coverage info 27 | - lcov --remove coverage.info '/usr/*' --output-file coverage.info # filter out system 28 | - lcov --remove coverage.info 'tests/*' --output-file coverage.info # filter out unit test suites 29 | - lcov --list coverage.info # debug info 30 | # Upload coverage data to CodeCov 31 | - bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports" 32 | -------------------------------------------------------------------------------- /lib/c-reusables/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.1) 3 | project(C-Reusables C) 4 | 5 | set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo MinSizeRel) 6 | if("${CMAKE_BUILD_TYPE}" STREQUAL "") 7 | set(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE}) 8 | 9 | if("${CMAKE_BUILD_TYPE}" STREQUAL "") 10 | set(CMAKE_BUILD_TYPE "Release") 11 | endif() 12 | endif() 13 | 14 | set(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}") 15 | 16 | add_subdirectory(tests) 17 | -------------------------------------------------------------------------------- /lib/c-reusables/LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | # The MIT License (MIT) 3 | 4 | Copyright © 2016-2020 Martin Mitáš 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a 7 | copy of this software and associated documentation files (the “Software”), 8 | to deal in the Software without restriction, including without limitation 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | and/or sell copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /lib/c-reusables/appveyor.yml: -------------------------------------------------------------------------------- 1 | # YAML definition for Appveyor.com continuous integration. 2 | # See http://www.appveyor.com/docs/appveyor-yml 3 | 4 | version: '{branch}-{build}' 5 | 6 | before_build: 7 | - 'cmake --version' 8 | - 'if "%PLATFORM%"=="x64" cmake -G "Visual Studio 12 Win64" .' 9 | - 'if not "%PLATFORM%"=="x64" cmake -G "Visual Studio 12" .' 10 | 11 | build: 12 | project: c-reusables.sln 13 | verbosity: minimal 14 | 15 | skip_tags: true 16 | 17 | os: 18 | - Windows Server 2012 R2 19 | 20 | configuration: 21 | - Debug 22 | - Release 23 | 24 | platform: 25 | - x64 # 64-bit build 26 | - win32 # 32-bit build 27 | 28 | artifacts: 29 | - path: '**\test-*.exe' 30 | -------------------------------------------------------------------------------- /lib/c-reusables/codecov.yml: -------------------------------------------------------------------------------- 1 | # YAML definition for codecov.io code coverage reports. 2 | 3 | ignore: 4 | - "tests" 5 | -------------------------------------------------------------------------------- /lib/c-reusables/coverity.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This scripts attempts to build the project via cov-build utility, and prepare 4 | # a package for uploading to the coverity scan service. 5 | # 6 | # (See http://scan.coverity.com for more info.) 7 | 8 | set -e 9 | 10 | # Check presence of coverity static analyzer. 11 | if ! which cov-build; then 12 | echo "Utility cov-build not found in PATH." 13 | exit 1 14 | fi 15 | 16 | # Choose a build system (ninja or GNU make). 17 | if which ninja; then 18 | BUILD_TOOL=ninja 19 | GENERATOR=Ninja 20 | elif which make; then 21 | BUILD_TOOL=make 22 | GENERATOR="MSYS Makefiles" 23 | else 24 | echo "No suitable build system found." 25 | exit 1 26 | fi 27 | 28 | # Choose a zip tool. 29 | if which 7za; then 30 | MKZIP="7za a -r -mx9" 31 | elif which 7z; then 32 | MKZIP="7z a -r -mx9" 33 | elif which zip; then 34 | MKZIP="zip -r" 35 | else 36 | echo "No suitable zip utility found" 37 | exit 1 38 | fi 39 | 40 | CWD=`pwd` 41 | ROOT_DIR="$CWD" 42 | BUILD_DIR="$CWD/coverity" 43 | OUTPUT="$CWD/cov-int.zip" 44 | 45 | # Sanity checks. 46 | if [ ! -x "$ROOT_DIR/coverity.sh" ]; then 47 | echo "There is some path mismatch." 48 | exit 1 49 | fi 50 | if [ -e "$BUILD_DIR" ]; then 51 | echo "Path $BUILD_DIR already exists. Delete it and retry." 52 | exit 1 53 | fi 54 | if [ -e "$OUTPUT" ]; then 55 | echo "Path $OUTPUT already exists. Delete it and retry." 56 | exit 1 57 | fi 58 | 59 | # Build the project with the Coverity analyzes enabled. 60 | mkdir -p "$BUILD_DIR" 61 | cd "$BUILD_DIR" 62 | cmake -G "$GENERATOR" "$ROOT_DIR" 63 | cov-build --dir cov-int "$BUILD_TOOL" 64 | $MKZIP "$OUTPUT" "cov-int" 65 | cd "$ROOT_DIR" 66 | rm -rf "$BUILD_DIR" 67 | 68 | -------------------------------------------------------------------------------- /lib/c-reusables/data/buffer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * C Reusables 3 | * 4 | * 5 | * Copyright (c) 2018-2019 Martin Mitas 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | * IN THE SOFTWARE. 24 | */ 25 | 26 | #include "buffer.h" 27 | 28 | 29 | int 30 | buffer_realloc(BUFFER* buf, size_t alloc) 31 | { 32 | void* tmp; 33 | 34 | tmp = realloc(buf->data, alloc); 35 | if(tmp == NULL && alloc > 0) 36 | return -1; 37 | 38 | buf->data = tmp; 39 | buf->alloc = alloc; 40 | if(buf->size > alloc) 41 | buf->size = alloc; 42 | return 0; 43 | } 44 | 45 | int 46 | buffer_reserve(BUFFER* buf, size_t extra_alloc) 47 | { 48 | if(buf->size + extra_alloc > buf->alloc) 49 | return buffer_realloc(buf, buf->size + extra_alloc); 50 | else 51 | return 0; 52 | } 53 | 54 | void 55 | buffer_shrink(BUFFER* buf) 56 | { 57 | /* Avoid realloc() if the potential memory gain is negligible. */ 58 | if(buf->alloc / 11 > buf->size / 10) 59 | buffer_realloc(buf, buf->size); 60 | } 61 | 62 | void* 63 | buffer_insert_raw(BUFFER* buf, size_t pos, size_t n) 64 | { 65 | if(buf->size + n > buf->alloc) { 66 | if(buffer_realloc(buf, buf->size + n + buf->size / 2) != 0) 67 | return NULL; 68 | } 69 | 70 | if(buf->size > pos) 71 | memmove((uint8_t*)buf->data + pos + n, (uint8_t*)buf->data + pos, buf->size - pos); 72 | 73 | buf->size += n; 74 | return buffer_data_at(buf, pos); 75 | } 76 | 77 | int 78 | buffer_insert(BUFFER* buf, size_t pos, const void* data, size_t n) 79 | { 80 | void* ptr; 81 | 82 | ptr = buffer_insert_raw(buf, pos, n); 83 | if(ptr == NULL) 84 | return -1; 85 | 86 | memcpy(ptr, data, n); 87 | return 0; 88 | } 89 | 90 | void 91 | buffer_remove(BUFFER* buf, size_t pos, size_t n) 92 | { 93 | if(pos + n < buf->size) { 94 | memmove((uint8_t*)buf->data + pos, (uint8_t*)buf->data + pos + n, n); 95 | buf->size -= n; 96 | } else { 97 | buf->size = pos; 98 | } 99 | } 100 | 101 | -------------------------------------------------------------------------------- /lib/c-reusables/encode/hex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * C Reusables 3 | * 4 | * 5 | * Copyright (c) 2016 Martin Mitas 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | * IN THE SOFTWARE. 24 | */ 25 | 26 | #ifndef CRE_HEX_H 27 | #define CRE_HEX_H 28 | 29 | #include 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | 36 | /* Encodes the BLOB in_buf into the trivial hexadecimal notation: Two 37 | * hexadecimal digits per every byte of in_buf. 38 | * 39 | * If there is enough space in out_buf (out_size >= in_size * 2 + 1), 40 | * the output is zero-terminated. 41 | * 42 | * If the output buffer is too small, the function returns -1. 43 | * If out_buf is NULL, the function returns ideal size of output buffer 44 | * (in_size * 2 + 1). 45 | * If out_buf is not NULL, it returns the number of written hexadecimal digits. 46 | */ 47 | int hex_encode(const void* in_buf, unsigned in_size, 48 | char* out_buf, unsigned out_size, int lowercase); 49 | 50 | /* Decodes string of hexadecimal notation (even count of digits) to a memory 51 | * pointed by out_buf. The function accepts both lowercase and uppercase 52 | * hexadecimal digits on input. 53 | * 54 | * If out_buf is NULL, the function returns ideal size of output buffer 55 | * (in_size / 2). 56 | * If out_buf is not NULL, it returns the number of written bytes or -1 57 | * in case of error (e.g. parsing error or too small output buffer). 58 | */ 59 | int hex_decode(const char* in_buf, unsigned in_size, 60 | void* out_buf, unsigned out_size); 61 | 62 | 63 | #ifdef __cplusplus 64 | } /* extern "C" { */ 65 | #endif 66 | 67 | #endif /* CRE_HEX_H */ 68 | -------------------------------------------------------------------------------- /lib/c-reusables/hash/crc32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * C Reusables 3 | * 4 | * 5 | * Copyright (c) 2017 Martin Mitas 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | * IN THE SOFTWARE. 24 | */ 25 | 26 | #ifndef CRE_CRC32_H 27 | #define CRE_CRC32_H 28 | 29 | #include 30 | #include 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | 37 | /* 38 | * Compute CRC-32 of the given data. 39 | * Note there is no real CRC-32 standard. Some applications use different 40 | * flavors. 41 | * 42 | * This implementation is based on the appendix of this paper: 43 | * http://stigge.org/martin/pub/SAR-PR-2006-05.pdf 44 | */ 45 | 46 | 47 | uint32_t crc32(const void* data, size_t n); 48 | 49 | 50 | #ifdef __cplusplus 51 | } /* extern "C" { */ 52 | #endif 53 | 54 | #endif /* CRE_CRC32_H */ 55 | -------------------------------------------------------------------------------- /lib/c-reusables/hash/fnv1a.c: -------------------------------------------------------------------------------- 1 | /* 2 | * C Reusables 3 | * 4 | * 5 | * Copyright (c) 2016 Martin Mitas 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | * IN THE SOFTWARE. 24 | */ 25 | 26 | #include "fnv1a.h" 27 | 28 | 29 | #define FNV1A_PRIME_32 16777619 30 | #define FNV1A_PRIME_64 1099511628211 31 | 32 | 33 | uint32_t 34 | fnv1a_32(uint32_t fnv1a, const void* data, size_t n) 35 | { 36 | const uint8_t* bytes = (const uint8_t*) data; 37 | size_t i; 38 | 39 | for(i = 0; i < n; i++) { 40 | fnv1a ^= bytes[i]; 41 | fnv1a *= FNV1A_PRIME_32; 42 | } 43 | 44 | return fnv1a; 45 | } 46 | 47 | uint64_t 48 | fnv1a_64(uint64_t fnv1a, const void* data, size_t n) 49 | { 50 | const uint8_t* bytes = (const uint8_t*) data; 51 | size_t i; 52 | 53 | for(i = 0; i < n; i++) { 54 | fnv1a ^= bytes[i]; 55 | fnv1a *= FNV1A_PRIME_64; 56 | } 57 | 58 | return fnv1a; 59 | } 60 | -------------------------------------------------------------------------------- /lib/c-reusables/hash/fnv1a.h: -------------------------------------------------------------------------------- 1 | /* 2 | * C Reusables 3 | * 4 | * 5 | * Copyright (c) 2016 Martin Mitas 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | * IN THE SOFTWARE. 24 | */ 25 | 26 | #ifndef CRE_FNV_H 27 | #define CRE_FNV_H 28 | 29 | #include 30 | #include 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | 37 | /* Fowler–Noll–Vo hash implementation. 38 | * (http://www.isthe.com/chongo/tech/comp/fnv/) 39 | * 40 | * We implement 1a variant of the function as it is generally recommended 41 | * and preferred over the original variant 1. 42 | */ 43 | 44 | #define FNV1A_BASE_32 2166136261U 45 | #define FNV1A_BASE_64 14695981039346656037U 46 | 47 | uint32_t fnv1a_32(uint32_t fnv1a, const void* data, size_t n); 48 | uint64_t fnv1a_64(uint64_t fnv1a, const void* data, size_t n); 49 | 50 | 51 | #ifdef __cplusplus 52 | } /* extern "C" { */ 53 | #endif 54 | 55 | #endif /* CRE_FNV_H */ 56 | -------------------------------------------------------------------------------- /lib/c-reusables/mem/memchunk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * C Reusables 3 | * 4 | * 5 | * Copyright (c) 2020 Martin Mitas 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | * IN THE SOFTWARE. 24 | */ 25 | 26 | #ifndef CRE_MEMCHUNK_H 27 | #define CRE_MEMCHUNK_H 28 | 29 | #include "stdlib.h" 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | 36 | /* Implementation of a chunk memory allocator. 37 | * 38 | * Often, programs need to incrementally allocate many small pieces of memory 39 | * which shall eventually all be freed at the same time. 40 | * 41 | * In such cases. using `malloc()` individually for each such allocation may be 42 | * quite expensive, both in terms of memory (due the general heap allocator 43 | * bookkeeping) as well as in terms of CPU cycles. 44 | * 45 | * The chunk allocator, as provided here, solves this by `malloc`ing larger 46 | * block of memory and satisfying then the individual small allocations from 47 | * that block. When the block gets exhausted, a new block is allocated to 48 | * satisfy more requests. 49 | * 50 | * With this allocator there is no memory overhead per individual allocation 51 | * but only per the larger block. 52 | */ 53 | 54 | 55 | typedef struct MEMCHUNK_BLOCK MEMCHUNK_BLOCK; 56 | 57 | 58 | /* The allocator structure. Treat as opaque. */ 59 | typedef struct MEMCHUNK { 60 | MEMCHUNK_BLOCK* head; 61 | size_t block_size; 62 | size_t free_off; 63 | } MEMCHUNK; 64 | 65 | 66 | /* Initialize the chunk allocator. 67 | * 68 | * The block_size specifies the size of the larger blocks allocated under the 69 | * hood. Using zero means a default block size (currently 1 kB). 70 | */ 71 | void memchunk_init(MEMCHUNK* chunk, size_t block_size); 72 | 73 | /* Allocate a (small) memory from the chunk allocator. 74 | * 75 | * It will only be released when memchunk_fini() is called (alongside all other 76 | * memory pieces allocated by the same allocator). 77 | */ 78 | void* memchunk_alloc(MEMCHUNK* chunk, size_t size); 79 | 80 | /* Free all the memory used by the given chunk allocator. 81 | */ 82 | void memchunk_fini(MEMCHUNK* chunk); 83 | 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /* CRE_MEMCHUNK_H */ 90 | -------------------------------------------------------------------------------- /lib/c-reusables/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | if(CMAKE_COMPILER_IS_GNUCC) 3 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") 4 | if(WIN32) 5 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mconsole -static-libgcc") 6 | endif() 7 | elseif(MSVC) 8 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MT") 9 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO /SUBSYSTEM:CONSOLE") 10 | add_definitions(/D_CRT_SECURE_NO_WARNINGS) 11 | endif() 12 | 13 | 14 | add_definitions(-DCRE_TEST) 15 | 16 | 17 | add_executable(test-buffer acutest.h test-buffer.c ../data/buffer.h ../data/buffer.c) 18 | target_include_directories(test-buffer PRIVATE ../data) 19 | 20 | add_executable(test-list acutest.h test-list.c ../data/list.h) 21 | target_include_directories(test-list PRIVATE ../data) 22 | 23 | add_executable(test-rbtree acutest.h test-rbtree.c ../data/rbtree.h ../data/rbtree.c) 24 | target_include_directories(test-rbtree PRIVATE ../data) 25 | 26 | add_executable(test-value acutest.h test-value.c ../data/value.h ../data/value.c) 27 | target_include_directories(test-value PRIVATE ../data) 28 | 29 | add_executable(test-base64 acutest.h test-base64.c ../encode/base64.h ../encode/base64.c) 30 | target_include_directories(test-base64 PRIVATE ../encode) 31 | 32 | add_executable(test-hex acutest.h test-hex.c ../encode/hex.h ../encode/hex.c) 33 | target_include_directories(test-hex PRIVATE ../encode) 34 | 35 | add_executable(test-crc32 acutest.h test-crc32.c ../hash/crc32.h ../hash/crc32.c) 36 | target_include_directories(test-crc32 PRIVATE ../hash) 37 | 38 | add_executable(test-fnv1a acutest.h test-fnv1a.c ../hash/fnv1a.h ../hash/fnv1a.c) 39 | target_include_directories(test-fnv1a PRIVATE ../hash) 40 | 41 | add_executable(test-cmdline acutest.h test-cmdline.c ../misc/cmdline.h ../misc/cmdline.c) 42 | target_include_directories(test-cmdline PRIVATE ../misc) 43 | 44 | add_executable(test-defs acutest.h test-defs.c ../misc/defs.h) 45 | target_include_directories(test-defs PRIVATE ../misc) 46 | 47 | add_executable(test-malloca acutest.h test-malloca.c ../mem/malloca.h) 48 | target_include_directories(test-malloca PRIVATE ../mem) 49 | 50 | if(WIN32) 51 | add_executable(test-memstream acutest.h test-memstream.c ../win32/memstream.h ../win32/memstream.c) 52 | target_include_directories(test-memstream PRIVATE ../win32) 53 | endif() 54 | -------------------------------------------------------------------------------- /lib/c-reusables/tests/test-crc32.c: -------------------------------------------------------------------------------- 1 | /* 2 | * C Reusables 3 | * 4 | * 5 | * Copyright (c) 2017 Martin Mitas 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | * IN THE SOFTWARE. 24 | */ 25 | 26 | #include "acutest.h" 27 | #include "crc32.h" 28 | 29 | 30 | typedef struct TEST_VECTOR { 31 | const char* str; 32 | size_t n; 33 | uint32_t crc32; 34 | } TEST_VECTOR; 35 | 36 | #define LEN(x) (sizeof(x)-1) 37 | #define TEST(x) x, LEN(x) 38 | 39 | /* The test vector has been taken here: 40 | * http://reveng.sourceforge.net/crc-catalogue/17plus.htm#crc.cat-bits.32 41 | */ 42 | static const TEST_VECTOR test_vectrors[] = { 43 | { TEST("123456789"), 0xcbf43926U }, 44 | { 0 } 45 | }; 46 | 47 | 48 | static void 49 | test_crc32(void) 50 | { 51 | int i; 52 | 53 | for(i = 0; test_vectrors[i].str != NULL; i++) { 54 | const char* str = test_vectrors[i].str; 55 | size_t n = test_vectrors[i].n; 56 | uint32_t expected = test_vectrors[i].crc32; 57 | uint32_t produced; 58 | 59 | produced = crc32(str, n); 60 | if(!TEST_CHECK_(produced == expected, "vector '%.*s'", (int)n, str)) { 61 | TEST_MSG("Expected: %x", (unsigned) expected); 62 | TEST_MSG("Produced: %x", (unsigned) produced); 63 | } 64 | } 65 | } 66 | 67 | 68 | TEST_LIST = { 69 | { "crc32", test_crc32 }, 70 | { 0 } 71 | }; 72 | -------------------------------------------------------------------------------- /lib/c-reusables/tests/test-hex.c: -------------------------------------------------------------------------------- 1 | /* 2 | * C Reusables 3 | * 4 | * 5 | * Copyright (c) 2016 Martin Mitas 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | * IN THE SOFTWARE. 24 | */ 25 | 26 | #include "acutest.h" 27 | #include "hex.h" 28 | 29 | #include 30 | 31 | 32 | static void 33 | test_hex_encode(void) 34 | { 35 | char blob[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0xff }; 36 | char buffer[256]; 37 | char expect_lower[] = "000102030405060708090a0b0c0d0e0fff"; 38 | char expect_upper[] = "000102030405060708090A0B0C0D0E0FFF"; 39 | 40 | TEST_CHECK(hex_encode(blob, sizeof(blob), buffer, sizeof(buffer), 1) == strlen(expect_lower)); 41 | TEST_CHECK(strcmp(buffer, expect_lower) == 0); 42 | 43 | TEST_CHECK(hex_encode(blob, sizeof(blob), buffer, sizeof(buffer), 0) == strlen(expect_upper)); 44 | TEST_CHECK(strcmp(buffer, expect_upper) == 0); 45 | } 46 | 47 | static void 48 | test_hex_decode(void) 49 | { 50 | /* Keep the visually ugly mixed lower and upper case here. */ 51 | char hex[] = "000102030405060708090a0B0c0D0e0fFf"; 52 | char buffer[256]; 53 | char expect[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0xff }; 54 | 55 | TEST_CHECK(hex_decode(hex, strlen(hex), buffer, sizeof(buffer)) == sizeof(expect)); 56 | TEST_CHECK(memcmp(buffer, expect, sizeof(expect)) == 0); 57 | } 58 | 59 | TEST_LIST = { 60 | { "hex-encode", test_hex_encode }, 61 | { "hex-decode", test_hex_decode }, 62 | { 0 } 63 | }; 64 | -------------------------------------------------------------------------------- /lib/c-reusables/win32/memstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * C Reusables 3 | * 4 | * 5 | * Copyright (c) 2015-2020 Martin Mitas 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | * IN THE SOFTWARE. 24 | */ 25 | 26 | #ifndef CRE_MEMSTREAM_H 27 | #define CRE_MEMSTREAM_H 28 | 29 | #include 30 | #include 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | 37 | /* Trivial read-only IStream implementation. 38 | * 39 | * This is more lightweight alternative to SHCreateMemStream() from SHLWAPI.DLL. 40 | * 41 | * This implementation provides these main benefits: 42 | * (1) We do not copy the data. 43 | * (2) Application does not need SHLWAPI.DLL. 44 | * 45 | * (Note that caller is responsible the data in the provided buffer remain 46 | * valid and immutable for the life time of the IStream.) 47 | * 48 | * When not needed anymore, the caller should release the stream as a standard 49 | * COM object, i.e. via method IStream::Release(). 50 | */ 51 | 52 | HRESULT memstream_create(const BYTE* buffer, ULONG size, IStream** p_stream); 53 | 54 | HRESULT memstream_create_from_resource(HINSTANCE instance, 55 | const WCHAR* res_type, const WCHAR* res_name, 56 | IStream** p_stream); 57 | 58 | 59 | #ifdef __cplusplus 60 | } /* extern "C" { */ 61 | #endif 62 | 63 | #endif /* CRE_MEMSTREAM_H */ 64 | -------------------------------------------------------------------------------- /lib/c-win32/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/mity/c-win32 8 | branch = master 9 | commit = c1f444005b8f3bf1ac6fb37b7343bf427d543599 10 | parent = f39c72b8cce8557941705660a549ec6a84947e71 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /lib/c-win32/LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | # The MIT License (MIT) 3 | 4 | Copyright © 2017-2019 Martin Mitáš 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a 7 | copy of this software and associated documentation files (the “Software”), 8 | to deal in the Software without restriction, including without limitation 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | and/or sell copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /lib/c-win32/include/.gitattributes: -------------------------------------------------------------------------------- 1 | # The nature of these headers is quite atypical and GitHub tends to mis-detect 2 | # them as different languages. So lets tell explicitly. 3 | # 4 | # See https://github.com/github/linguist#overrides 5 | 6 | *.h linguist-language=C 7 | -------------------------------------------------------------------------------- /lib/hsluv-c/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | CMakeCache.txt 3 | *.cmake 4 | CMakeFiles 5 | /tests/test_hsluv -------------------------------------------------------------------------------- /lib/hsluv-c/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/hsluv/hsluv-c 8 | branch = master 9 | commit = 498de4d9ce7a33933e9252fd3c87b75244215005 10 | parent = 62378a3da4d78258d10bd4370f2dd069c8859f69 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /lib/hsluv-c/.travis.yml: -------------------------------------------------------------------------------- 1 | # YAML definition for travis-ci.com continuous integration. 2 | # (See https://docs.travis-ci.com/user/languages/c) 3 | 4 | language: c 5 | 6 | compiler: 7 | - gcc 8 | - clang 9 | 10 | env: 11 | - CONFIG=Debug 12 | - CONFIG=Release 13 | 14 | before_script: 15 | - mkdir build 16 | - cd build 17 | - cmake -DCMAKE_BUILD_TYPE=$CONFIG -G 'Unix Makefiles' .. 18 | 19 | script: 20 | - make VERBOSE=1 21 | 22 | after_success: 23 | - ./tests/test_hsluv 24 | -------------------------------------------------------------------------------- /lib/hsluv-c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.1) 3 | project(hsluv-c C) 4 | 5 | 6 | set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo MinSizeRel) 7 | if("${CMAKE_BUILD_TYPE}" STREQUAL "") 8 | set(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE}) 9 | 10 | if("${CMAKE_BUILD_TYPE}" STREQUAL "") 11 | set(CMAKE_BUILD_TYPE "Release") 12 | endif() 13 | endif() 14 | 15 | 16 | if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") 17 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") 18 | elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") 19 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") 20 | elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") 21 | # Disable warnings about the so-called unsecured functions: 22 | add_definitions(/D_CRT_SECURE_NO_WARNINGS) 23 | 24 | # Specify proper C runtime library: 25 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") 26 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") 27 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} /MT") 28 | set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_RELEASE} /MT") 29 | endif() 30 | 31 | OPTION(HSLUV_C_TESTS "Enable/disable building of hsluv-c tests" ON) 32 | 33 | add_subdirectory(src) 34 | if(HSLUV_C_TESTS) 35 | add_subdirectory(tests) 36 | endif() 37 | -------------------------------------------------------------------------------- /lib/hsluv-c/LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | # The MIT License (MIT) 3 | 4 | Copyright © 2015 Alexei Boronine (original idea, JavaScript implementation) 5 | Copyright © 2015 Roger Tallada (Obj-C implementation) 6 | Copyright © 2017 Martin Mitáš (C implementation, based on Obj-C implementation) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the “Software”), 10 | to deal in the Software without restriction, including without limitation 11 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | and/or sell copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included 16 | in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 24 | IN THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /lib/hsluv-c/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/hsluv/hsluv-c.svg?branch=master)](https://travis-ci.org/hsluv/hsluv-c) 2 | 3 | # HSLuv-C: Human-friendly HSL 4 | 5 | ## Introduction 6 | 7 | This is C implementation of [HSLuv](http://www.hsluv.org/) (revision 4). 8 | 9 | 10 | ## Using HSLuv-C 11 | 12 | Just copy `src/hsluv.h` and `src/hsluv.c` into your project. 13 | 14 | Refer to `src/hsluv.h` for API description. 15 | 16 | 17 | ## Reporting Bugs 18 | 19 | If you encounter any bug, please be so kind and report it. Unheard bugs cannot 20 | get fixed. You can submit bug reports here: 21 | 22 | * http://github.com/hsluv/hsluv-c/issues 23 | 24 | 25 | ## License 26 | 27 | HSLuv-C is covered with MIT license, see the file `LICENSE.md`. 28 | -------------------------------------------------------------------------------- /lib/hsluv-c/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_library(hsluv-c STATIC hsluv.h hsluv.c) 3 | 4 | # In Windows SDK, math functions are part of C runtime lib. 5 | if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") 6 | target_link_libraries(hsluv-c m) 7 | endif() 8 | -------------------------------------------------------------------------------- /lib/hsluv-c/tests/.gitattributes: -------------------------------------------------------------------------------- 1 | # See https://github.com/github/linguist#overrides 2 | acutest.h linguist-language=C 3 | snapshot.h linguist-language=C 4 | snapshot.h linguist-generated=true 5 | -------------------------------------------------------------------------------- /lib/hsluv-c/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories("${PROJECT_SOURCE_DIR}/src") 3 | 4 | add_executable(test_hsluv acutest.h test_hsluv.c snapshot.h) 5 | target_link_libraries(test_hsluv hsluv-c) 6 | -------------------------------------------------------------------------------- /lib/hsluv-c/tests/scripts/snapshot-json2c.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | import json 5 | 6 | snapshot_file_path = 'snapshot-rev4.json' 7 | 8 | with open(snapshot_file_path) as data_file: 9 | data = json.load(data_file) 10 | 11 | 12 | 13 | sys.stdout.write("""/* Do not touch this file manually. 14 | * It is generated from '{0}' using 'snapshot-json2c.py`. 15 | */ 16 | 17 | """.format(snapshot_file_path)); 18 | 19 | sys.stdout.write(""" 20 | typedef struct TestVector_tag TestVector; 21 | struct TestVector_tag { 22 | const char hex_str[8]; 23 | double rgb_r; 24 | double rgb_g; 25 | double rgb_b; 26 | double xyz_x; 27 | double xyz_y; 28 | double xyz_z; 29 | double luv_l; 30 | double luv_u; 31 | double luv_v; 32 | double lch_l; 33 | double lch_c; 34 | double lch_h; 35 | double hsluv_h; 36 | double hsluv_s; 37 | double hsluv_l; 38 | double hpluv_h; 39 | double hpluv_s; 40 | double hpluv_l; 41 | }; 42 | 43 | static const TestVector snapshot[] = { 44 | """) 45 | 46 | for hex_str in sorted(data): 47 | record = data[hex_str] 48 | 49 | sys.stdout.write(' {\n') 50 | sys.stdout.write(' "{0}",\n'.format(hex_str)) 51 | for space in [ "rgb", "xyz", "luv", "lch", "hsluv", "hpluv" ]: 52 | a = str(record[space][0]) 53 | b = str(record[space][1]) 54 | c = str(record[space][2]) 55 | 56 | if "." not in a: 57 | a += ".0" 58 | if "." not in b: 59 | b += ".0" 60 | if "." not in c: 61 | c += ".0" 62 | 63 | sys.stdout.write(' {1}, {2}, {3}, /* {0} */\n'.format(space, a, b, c)) 64 | sys.stdout.write(' },\n') 65 | 66 | sys.stdout.write("""}; 67 | 68 | static const int snapshot_n = (int)(sizeof(snapshot) / sizeof(TestVector)); 69 | """) 70 | -------------------------------------------------------------------------------- /lib/hsluv-c/tests/test_hsluv.c: -------------------------------------------------------------------------------- 1 | 2 | #include "acutest.h" 3 | #include "hsluv.h" 4 | #include "snapshot.h" 5 | 6 | 7 | #define MAX_DIFF 0.00000001 8 | 9 | #define ABS(x) ((x) >= 0 ? (x) : -(x)) 10 | 11 | #define CHECK_EQ(a, b) \ 12 | TEST_CHECK_(ABS((a) - (b)) < MAX_DIFF, \ 13 | "%s: Mismatch in channel '" #a "' (%f versus %f).", \ 14 | snapshot[i].hex_str, (double)a, (double)b) 15 | 16 | 17 | static void 18 | test_hsluv2rgb(void) 19 | { 20 | int i; 21 | 22 | for(i = 0; i < snapshot_n; i++) { 23 | double r, g, b; 24 | 25 | hsluv2rgb(snapshot[i].hsluv_h, snapshot[i].hsluv_s, snapshot[i].hsluv_l, &r, &g, &b); 26 | 27 | CHECK_EQ(r, snapshot[i].rgb_r); 28 | CHECK_EQ(g, snapshot[i].rgb_g); 29 | CHECK_EQ(b, snapshot[i].rgb_b); 30 | } 31 | } 32 | 33 | static void 34 | test_rgb2hsluv(void) 35 | { 36 | int i; 37 | 38 | for(i = 0; i < snapshot_n; i++) { 39 | double h, s, l; 40 | 41 | rgb2hsluv(snapshot[i].rgb_r, snapshot[i].rgb_g, snapshot[i].rgb_b, &h, &s, &l); 42 | 43 | CHECK_EQ(h, snapshot[i].hsluv_h); 44 | CHECK_EQ(s, snapshot[i].hsluv_s); 45 | CHECK_EQ(l, snapshot[i].hsluv_l); 46 | } 47 | } 48 | 49 | static void 50 | test_hpluv2rgb(void) 51 | { 52 | int i; 53 | 54 | for(i = 0; i < snapshot_n; i++) { 55 | double r, g, b; 56 | 57 | hpluv2rgb(snapshot[i].hpluv_h, snapshot[i].hpluv_s, snapshot[i].hpluv_l, &r, &g, &b); 58 | 59 | CHECK_EQ(r, snapshot[i].rgb_r); 60 | CHECK_EQ(g, snapshot[i].rgb_g); 61 | CHECK_EQ(b, snapshot[i].rgb_b); 62 | } 63 | } 64 | 65 | static void 66 | test_rgb2hpluv(void) 67 | { 68 | int i; 69 | 70 | for(i = 0; i < snapshot_n; i++) { 71 | double h, s, l; 72 | 73 | rgb2hpluv(snapshot[i].rgb_r, snapshot[i].rgb_g, snapshot[i].rgb_b, &h, &s, &l); 74 | 75 | CHECK_EQ(h, snapshot[i].hpluv_h); 76 | CHECK_EQ(s, snapshot[i].hpluv_s); 77 | CHECK_EQ(l, snapshot[i].hpluv_l); 78 | } 79 | } 80 | 81 | 82 | TEST_LIST = { 83 | { "hsluv2rgb", test_hsluv2rgb }, 84 | { "rgb2hsluv", test_rgb2hsluv }, 85 | { "hpluv2rgb", test_hpluv2rgb }, 86 | { "rgb2hpluv", test_rgb2hpluv }, 87 | { NULL, NULL } 88 | }; 89 | -------------------------------------------------------------------------------- /lib/md4c-utf16/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_definitions(-DUNICODE -D_UNICODE) 3 | add_definitions(-D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0600 -DWINVER=_WIN32_WINNT) 4 | 5 | # Tell to not include everything. We include what we need anyway 6 | # and this saves compiler a lot of work in the parsing stage, so compilation 7 | # is faster. 8 | add_definitions(-DWIN32_LEAN_AND_MEAN) 9 | 10 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG") 11 | 12 | if(CMAKE_COMPILER_IS_GNUCC) 13 | # Enable many warnings: 14 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wdouble-promotion") 15 | elseif(MSVC) 16 | # Disable warnings about the so-called unsecured functions: 17 | add_definitions(/D_CRT_SECURE_NO_WARNINGS) 18 | endif() 19 | 20 | include_directories("${PROJECT_SOURCE_DIR}") 21 | add_library(md4c-utf16 STATIC md4c-utf16.h md4c-utf16.c) 22 | -------------------------------------------------------------------------------- /lib/md4c-utf16/README.md: -------------------------------------------------------------------------------- 1 | 2 | This directory is a workaround for the fact that MD4C currently does not easily 3 | allow building with UTF-16 support enabled. Hopefully we get rid of this hack 4 | in some foreseeable future. 5 | -------------------------------------------------------------------------------- /lib/md4c-utf16/md4c-utf16.c: -------------------------------------------------------------------------------- 1 | 2 | #ifdef UNICODE 3 | #define MD4C_USE_UTF16 4 | #endif 5 | 6 | #include "../md4c/md4c/md4c.c" 7 | -------------------------------------------------------------------------------- /lib/md4c-utf16/md4c-utf16.h: -------------------------------------------------------------------------------- 1 | 2 | #ifdef UNICODE 3 | #define MD4C_USE_UTF16 4 | #endif 5 | 6 | #include "../md4c/md4c/md4c.h" 7 | -------------------------------------------------------------------------------- /lib/md4c/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/mity/md4c 8 | branch = master 9 | commit = 6709a869d4703b57e738a0456741b009f3942508 10 | parent = 2a50b89afdcffa4c2deb407a5f892cf7b13243b1 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /lib/md4c/.travis.yml: -------------------------------------------------------------------------------- 1 | # YAML definition for travis-ci.com continuous integration. 2 | # See https://docs.travis-ci.com/user/languages/c 3 | 4 | language: c 5 | 6 | compiler: 7 | - gcc 8 | 9 | addons: 10 | apt: 11 | packages: 12 | - python3 # for running tests 13 | - lcov # for generating code coverage report 14 | 15 | before_script: 16 | - mkdir build 17 | - cd build 18 | - CFLAGS='--coverage -g -O0' cmake -DCMAKE_BUILD_TYPE=Debug -G 'Unix Makefiles' .. 19 | 20 | script: 21 | - make VERBOSE=1 22 | 23 | after_success: 24 | - ../scripts/run-tests.sh 25 | # Creating report 26 | - lcov --directory . --capture --output-file coverage.info # capture coverage info 27 | - lcov --remove coverage.info '/usr/*' --output-file coverage.info # filter out system 28 | - lcov --list coverage.info # debug info 29 | # Uploading report to CodeCov 30 | - bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports" 31 | -------------------------------------------------------------------------------- /lib/md4c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.4) 3 | project(MD4C C) 4 | 5 | set(MD_VERSION_MAJOR 0) 6 | set(MD_VERSION_MINOR 4) 7 | set(MD_VERSION_RELEASE 2) 8 | set(MD_VERSION "${MD_VERSION_MAJOR}.${MD_VERSION_MINOR}.${MD_VERSION_RELEASE}") 9 | 10 | if(WIN32) 11 | # On Windows, given there is no standard lib install dir etc., we rather 12 | # by default build static lib. 13 | option(BUILD_SHARED_LIBS "help string describing option" OFF) 14 | else() 15 | # On Linux, MD4C is slowly being adding into some distros which prefer 16 | # shared lib. 17 | option(BUILD_SHARED_LIBS "help string describing option" ON) 18 | endif() 19 | 20 | add_definitions( 21 | -DMD_VERSION_MAJOR=${MD_VERSION_MAJOR} 22 | -DMD_VERSION_MINOR=${MD_VERSION_MINOR} 23 | -DMD_VERSION_RELEASE=${MD_VERSION_RELEASE} 24 | ) 25 | 26 | set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo MinSizeRel) 27 | if("${CMAKE_BUILD_TYPE}" STREQUAL "") 28 | set(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE}) 29 | 30 | if("${CMAKE_BUILD_TYPE}" STREQUAL "") 31 | set(CMAKE_BUILD_TYPE "Release") 32 | endif() 33 | endif() 34 | 35 | 36 | if(${CMAKE_C_COMPILER_ID} MATCHES GNU|Clang) 37 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") 38 | elseif(MSVC) 39 | # Disable warnings about the so-called unsecured functions: 40 | add_definitions(/D_CRT_SECURE_NO_WARNINGS) 41 | 42 | # Specify proper C runtime library: 43 | string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") 44 | string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") 45 | string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_RELWITHDEBINFO "{$CMAKE_C_FLAGS_RELWITHDEBINFO}") 46 | string(REGEX REPLACE "/M[DT]d?" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}") 47 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") 48 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") 49 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} /MT") 50 | set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_RELEASE} /MT") 51 | endif() 52 | 53 | include(GNUInstallDirs) 54 | 55 | add_subdirectory(md4c) 56 | add_subdirectory(md2html) 57 | -------------------------------------------------------------------------------- /lib/md4c/LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | # The MIT License (MIT) 3 | 4 | Copyright © 2016-2020 Martin Mitáš 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a 7 | copy of this software and associated documentation files (the “Software”), 8 | to deal in the Software without restriction, including without limitation 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | and/or sell copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /lib/md4c/appveyor.yml: -------------------------------------------------------------------------------- 1 | # YAML definition for Appveyor.com continuous integration. 2 | # See http://www.appveyor.com/docs/appveyor-yml 3 | 4 | version: '{branch}-{build}' 5 | 6 | before_build: 7 | - 'cmake --version' 8 | - 'if "%PLATFORM%"=="x64" cmake -G "Visual Studio 12 Win64" .' 9 | - 'if not "%PLATFORM%"=="x64" cmake -G "Visual Studio 12" .' 10 | 11 | build: 12 | project: md4c.sln 13 | verbosity: detailed 14 | 15 | skip_tags: true 16 | 17 | os: 18 | - Windows Server 2012 R2 19 | 20 | configuration: 21 | - Debug 22 | - Release 23 | 24 | platform: 25 | - x64 # 64-bit build 26 | - win32 # 32-bit build 27 | 28 | artifacts: 29 | - path: $(configuration)/md2html/md2html.exe 30 | -------------------------------------------------------------------------------- /lib/md4c/codecov.yml: -------------------------------------------------------------------------------- 1 | # YAML definition for codecov.io code coverage reports. 2 | 3 | ignore: 4 | - "md2html" 5 | -------------------------------------------------------------------------------- /lib/md4c/md2html/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories("${PROJECT_SOURCE_DIR}/md4c") 3 | 4 | add_executable(md2html cmdline.c cmdline.h entity.c entity.h md2html.c render_html.c render_html.h) 5 | target_link_libraries(md2html md4c) 6 | 7 | install( 8 | TARGETS md2html 9 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 10 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 11 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 12 | PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 13 | ) 14 | 15 | install(FILES "md2html.1" DESTINATION "${CMAKE_INSTALL_MANDIR}/man1") 16 | -------------------------------------------------------------------------------- /lib/md4c/md2html/entity.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MD4C: Markdown parser for C 3 | * (http://github.com/mity/md4c) 4 | * 5 | * Copyright (c) 2016-2017 Martin Mitas 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | * IN THE SOFTWARE. 24 | */ 25 | 26 | #ifndef MD2HTML_ENTITY_H 27 | #define MD2HTML_ENTITY_H 28 | 29 | #include 30 | 31 | 32 | /* Most entities are formed by single Unicode codepoint, few by two codepoints. 33 | * Single-codepoint entities have codepoints[1] set to zero. */ 34 | struct entity { 35 | const char* name; 36 | unsigned codepoints[2]; 37 | }; 38 | 39 | const struct entity* entity_lookup(const char* name, size_t name_size); 40 | 41 | 42 | #endif /* MD2HTML_ENTITY_H */ 43 | -------------------------------------------------------------------------------- /lib/md4c/md2html/md2html.1: -------------------------------------------------------------------------------- 1 | .TH MD2HTML 1 "June 2019" "" "General Commands Manual" 2 | .nh 3 | .ad l 4 | . 5 | .SH NAME 6 | . 7 | md2html \- convert Markdown to HTML 8 | . 9 | .SH SYNOPSIS 10 | . 11 | .B md2html 12 | .RI [ OPTION ]...\& 13 | .RI [ FILE ] 14 | . 15 | .SH OPTIONS 16 | . 17 | .SS General options: 18 | . 19 | .TP 20 | .BR -o ", " --output= \fIOUTFILE\fR 21 | Write output to \fIOUTFILE\fR instead of \fBstdout\fR(3) 22 | . 23 | .TP 24 | .BR -f ", " --full-html 25 | Generate full HTML document, including header 26 | . 27 | .TP 28 | .BR -s ", " --stat 29 | Measure time of input parsing 30 | . 31 | .TP 32 | .BR -h ", " --help 33 | Display help and exit 34 | . 35 | .TP 36 | .BR -v ", " --version 37 | Display version and exit 38 | . 39 | .SS Markdown dialect options: 40 | . 41 | .TP 42 | .B --commonmark 43 | CommonMark (the default) 44 | . 45 | .TP 46 | .B --github 47 | Github Flavored Markdown 48 | . 49 | .PP 50 | Note: dialect options are equivalent to some combination of flags below. 51 | . 52 | .SS Markdown extension options: 53 | . 54 | .TP 55 | .B --fcollapse-whitespace 56 | Collapse non-trivial whitespace 57 | . 58 | .TP 59 | .B --fverbatim-entities 60 | Do not translate entities 61 | . 62 | .TP 63 | .B --fpermissive-atx-headers 64 | Allow ATX headers without delimiting space 65 | . 66 | .TP 67 | .B --fpermissive-url-autolinks 68 | Allow URL autolinks without "<" and ">" delimiters 69 | . 70 | .TP 71 | .B --fpermissive-www-autolinks 72 | Allow WWW autolinks without any scheme (e.g. "www.example.com") 73 | . 74 | .TP 75 | .B --fpermissive-email-autolinks 76 | Allow e-mail autolinks without "<", ">" and "mailto:" 77 | . 78 | .TP 79 | .B --fpermissive-autolinks 80 | Enable all 3 of the above permissive autolinks options 81 | . 82 | .TP 83 | .B --fno-indented-code 84 | Disable indented code blocks 85 | . 86 | .TP 87 | .B --fno-html-blocks 88 | Disable raw HTML blocks 89 | . 90 | .TP 91 | .B --fno-html-spans 92 | Disable raw HTML spans 93 | . 94 | .TP 95 | .B --fno-html 96 | Same as \fB--fno-html-blocks --fno-html-spans\fR 97 | . 98 | .TP 99 | .B --ftables 100 | Enable tables 101 | . 102 | .TP 103 | .B --fstrikethrough 104 | Enable strikethrough spans 105 | . 106 | .TP 107 | .B --ftasklists 108 | Enable task lists 109 | . 110 | .SH SEE ALSO 111 | . 112 | https://github.com/mity/md4c 113 | . 114 | -------------------------------------------------------------------------------- /lib/md4c/md2html/render_html.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MD4C: Markdown parser for C 3 | * (http://github.com/mity/md4c) 4 | * 5 | * Copyright (c) 2016-2017 Martin Mitas 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | * IN THE SOFTWARE. 24 | */ 25 | 26 | #ifndef MD4C_RENDER_HTML_H 27 | #define MD4C_RENDER_HTML_H 28 | 29 | #include "md4c.h" 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | 36 | /* If set, debug output from md_parse() is sent to stderr. */ 37 | #define MD_RENDER_FLAG_DEBUG 0x0001 38 | #define MD_RENDER_FLAG_VERBATIM_ENTITIES 0x0002 39 | 40 | 41 | /* Render Markdown into HTML. 42 | * 43 | * Note only contents of tag is generated. Caller must generate 44 | * HTML header/footer manually before/after calling md_render_html(). 45 | * 46 | * Params input and input_size specify the Markdown input. 47 | * Callback process_output() gets called with chunks of HTML output. 48 | * (Typical implementation may just output the bytes to file or append to 49 | * some buffer). 50 | * Param userdata is just propgated back to process_output() callback. 51 | * Param parser_flags are flags from md4c.h propagated to md_parse(). 52 | * Param render_flags is bitmask of MD_RENDER_FLAG_xxxx. 53 | * 54 | * Returns -1 on error (if md_parse() fails.) 55 | * Returns 0 on success. 56 | */ 57 | int md_render_html(const MD_CHAR* input, MD_SIZE input_size, 58 | void (*process_output)(const MD_CHAR*, MD_SIZE, void*), 59 | void* userdata, unsigned parser_flags, unsigned renderer_flags); 60 | 61 | 62 | #ifdef __cplusplus 63 | } /* extern "C" { */ 64 | #endif 65 | 66 | #endif /* MD4C_RENDER_HTML_H */ 67 | -------------------------------------------------------------------------------- /lib/md4c/md4c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Be sure to export all symbols in Windows. 2 | set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS 1) 3 | 4 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG") 5 | 6 | set(md4c_src 7 | md4c.c 8 | ) 9 | 10 | add_library(md4c ${md4c_src}) 11 | 12 | set_target_properties(md4c PROPERTIES 13 | VERSION ${MD_VERSION} 14 | SOVERSION ${MD_VERSION_MAJOR} 15 | PUBLIC_HEADER md4c.h 16 | ) 17 | 18 | install( 19 | TARGETS md4c 20 | EXPORT md4cConfig 21 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 22 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 23 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 24 | PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 25 | ) 26 | 27 | # Create a pkg-config file 28 | configure_file(md4c.pc.in md4c.pc @ONLY) 29 | install(FILES ${CMAKE_BINARY_DIR}/md4c/md4c.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) 30 | 31 | # And a CMake file 32 | install(EXPORT md4cConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/md4c/) 33 | -------------------------------------------------------------------------------- /lib/md4c/md4c/md4c.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=@CMAKE_INSTALL_PREFIX@ 3 | libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ 4 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 5 | 6 | Name: @PROJECT_NAME@ 7 | Description: @PROJECT_DESCRIPTION@ 8 | Version: @PROJECT_VERSION@ 9 | 10 | Requires: 11 | Libs: -L${libdir} -lmd4c 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /lib/md4c/scripts/build_punct_map.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import sys 5 | import textwrap 6 | 7 | 8 | self_path = os.path.dirname(os.path.realpath(__file__)); 9 | f = open(self_path + "/unicode/DerivedGeneralCategory.txt", "r") 10 | 11 | codepoint_list = [] 12 | category_list = [ "Pc", "Pd", "Pe", "Pf", "Pi", "Po", "Ps" ] 13 | 14 | # Filter codepoints falling in the right category: 15 | for line in f: 16 | comment_off = line.find("#") 17 | if comment_off >= 0: 18 | line = line[:comment_off] 19 | line = line.strip() 20 | if not line: 21 | continue 22 | 23 | char_range, category = line.split(";") 24 | char_range = char_range.strip() 25 | category = category.strip() 26 | 27 | if not category in category_list: 28 | continue 29 | 30 | delim_off = char_range.find("..") 31 | if delim_off >= 0: 32 | codepoint0 = int(char_range[:delim_off], 16) 33 | codepoint1 = int(char_range[delim_off+2:], 16) 34 | for codepoint in range(codepoint0, codepoint1 + 1): 35 | codepoint_list.append(codepoint) 36 | else: 37 | codepoint = int(char_range, 16) 38 | codepoint_list.append(codepoint) 39 | f.close() 40 | 41 | 42 | codepoint_list.sort() 43 | 44 | 45 | index0 = 0 46 | count = len(codepoint_list) 47 | 48 | records = list() 49 | while index0 < count: 50 | index1 = index0 + 1 51 | while index1 < count and codepoint_list[index1] == codepoint_list[index1-1] + 1: 52 | index1 += 1 53 | 54 | if index1 - index0 > 1: 55 | # Range of codepoints 56 | records.append("R(0x{:04x},0x{:04x})".format(codepoint_list[index0], codepoint_list[index1-1])) 57 | else: 58 | # Single codepoint 59 | records.append("S(0x{:04x})".format(codepoint_list[index0])) 60 | 61 | index0 = index1 62 | 63 | sys.stdout.write("static const unsigned PUNCT_MAP[] = {\n") 64 | sys.stdout.write("\n".join(textwrap.wrap(", ".join(records), 110, 65 | initial_indent = " ", subsequent_indent=" "))) 66 | sys.stdout.write("\n};\n\n") 67 | -------------------------------------------------------------------------------- /lib/md4c/scripts/build_whitespace_map.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import sys 5 | import textwrap 6 | 7 | 8 | self_path = os.path.dirname(os.path.realpath(__file__)); 9 | f = open(self_path + "/unicode/DerivedGeneralCategory.txt", "r") 10 | 11 | codepoint_list = [] 12 | category_list = [ "Zs" ] 13 | 14 | # Filter codepoints falling in the right category: 15 | for line in f: 16 | comment_off = line.find("#") 17 | if comment_off >= 0: 18 | line = line[:comment_off] 19 | line = line.strip() 20 | if not line: 21 | continue 22 | 23 | char_range, category = line.split(";") 24 | char_range = char_range.strip() 25 | category = category.strip() 26 | 27 | if not category in category_list: 28 | continue 29 | 30 | delim_off = char_range.find("..") 31 | if delim_off >= 0: 32 | codepoint0 = int(char_range[:delim_off], 16) 33 | codepoint1 = int(char_range[delim_off+2:], 16) 34 | for codepoint in range(codepoint0, codepoint1 + 1): 35 | codepoint_list.append(codepoint) 36 | else: 37 | codepoint = int(char_range, 16) 38 | codepoint_list.append(codepoint) 39 | f.close() 40 | 41 | 42 | codepoint_list.sort() 43 | 44 | 45 | index0 = 0 46 | count = len(codepoint_list) 47 | 48 | records = list() 49 | while index0 < count: 50 | index1 = index0 + 1 51 | while index1 < count and codepoint_list[index1] == codepoint_list[index1-1] + 1: 52 | index1 += 1 53 | 54 | if index1 - index0 > 1: 55 | # Range of codepoints 56 | records.append("R(0x{:04x},0x{:04x})".format(codepoint_list[index0], codepoint_list[index1-1])) 57 | else: 58 | # Single codepoint 59 | records.append("S(0x{:04x})".format(codepoint_list[index0])) 60 | 61 | index0 = index1 62 | 63 | sys.stdout.write("static const unsigned WHITESPACE_MAP[] = {\n") 64 | sys.stdout.write("\n".join(textwrap.wrap(", ".join(records), 110, 65 | initial_indent = " ", subsequent_indent=" "))) 66 | sys.stdout.write("\n};\n\n") 67 | -------------------------------------------------------------------------------- /lib/md4c/scripts/coverity.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This scripts attempts to build the project via cov-build utility, and prepare 4 | # a package for uploading to the coverity scan service. 5 | # 6 | # (See http://scan.coverity.com for more info.) 7 | 8 | set -e 9 | 10 | # Check presence of coverity static analyzer. 11 | if ! which cov-build; then 12 | echo "Utility cov-build not found in PATH." 13 | exit 1 14 | fi 15 | 16 | # Choose a build system (ninja or GNU make). 17 | if which ninja; then 18 | BUILD_TOOL=ninja 19 | GENERATOR=Ninja 20 | elif which make; then 21 | BUILD_TOOL=make 22 | GENERATOR="MSYS Makefiles" 23 | else 24 | echo "No suitable build system found." 25 | exit 1 26 | fi 27 | 28 | # Choose a zip tool. 29 | if which 7za; then 30 | MKZIP="7za a -r -mx9" 31 | elif which 7z; then 32 | MKZIP="7z a -r -mx9" 33 | elif which zip; then 34 | MKZIP="zip -r" 35 | else 36 | echo "No suitable zip utility found" 37 | exit 1 38 | fi 39 | 40 | # Change dir to project root. 41 | cd `dirname "$0"`/.. 42 | 43 | CWD=`pwd` 44 | ROOT_DIR="$CWD" 45 | BUILD_DIR="$CWD/coverity" 46 | OUTPUT="$CWD/cov-int.zip" 47 | 48 | # Sanity checks. 49 | if [ ! -x "$ROOT_DIR/scripts/coverity.sh" ]; then 50 | echo "There is some path mismatch." 51 | exit 1 52 | fi 53 | if [ -e "$BUILD_DIR" ]; then 54 | echo "Path $BUILD_DIR already exists. Delete it and retry." 55 | exit 1 56 | fi 57 | if [ -e "$OUTPUT" ]; then 58 | echo "Path $OUTPUT already exists. Delete it and retry." 59 | exit 1 60 | fi 61 | 62 | # Build the project with the Coverity analyzes enabled. 63 | mkdir -p "$BUILD_DIR" 64 | cd "$BUILD_DIR" 65 | cmake -G "$GENERATOR" "$ROOT_DIR" 66 | cov-build --dir cov-int "$BUILD_TOOL" 67 | $MKZIP "$OUTPUT" "cov-int" 68 | cd "$ROOT_DIR" 69 | rm -rf "$BUILD_DIR" 70 | 71 | -------------------------------------------------------------------------------- /lib/md4c/scripts/run-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Run this script from build directory. 4 | 5 | #set -e 6 | 7 | SELF_DIR=`dirname $0` 8 | PROJECT_DIR="$SELF_DIR/.." 9 | TEST_DIR="$PROJECT_DIR/test" 10 | 11 | 12 | PROGRAM="md2html/md2html" 13 | if [ ! -x "$PROGRAM" ]; then 14 | echo "Cannot find the $PROGRAM." >&2 15 | echo "You have to run this script from the build directory." >&2 16 | exit 1 17 | fi 18 | 19 | if which py >>/dev/null 2>&1; then 20 | PYTHON=py 21 | elif which python3 >>/dev/null 2>&1; then 22 | PYTHON=python3 23 | elif which python >>/dev/null 2>&1; then 24 | if [ `python --version | awk '{print $2}' | cut -d. -f1` -ge 3 ]; then 25 | PYTHON=python 26 | fi 27 | fi 28 | 29 | echo 30 | echo "CommonMark specification:" 31 | $PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/spec.txt" -p "$PROGRAM" 32 | 33 | echo 34 | echo "Code coverage & regressions:" 35 | $PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/coverage.txt" -p "$PROGRAM" 36 | 37 | echo 38 | echo "Permissive e-mail autolinks extension:" 39 | $PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/permissive-email-autolinks.txt" -p "$PROGRAM --fpermissive-email-autolinks" 40 | 41 | echo 42 | echo "Permissive URL autolinks extension:" 43 | $PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/permissive-url-autolinks.txt" -p "$PROGRAM --fpermissive-url-autolinks" 44 | 45 | echo 46 | echo "WWW autolinks extension:" 47 | $PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/permissive-www-autolinks.txt" -p "$PROGRAM --fpermissive-www-autolinks" 48 | 49 | echo 50 | echo "Tables extension:" 51 | $PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/tables.txt" -p "$PROGRAM --ftables" 52 | 53 | echo 54 | echo "Strikethrough extension:" 55 | $PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/strikethrough.txt" -p "$PROGRAM --fstrikethrough" 56 | 57 | echo 58 | echo "Task lists extension:" 59 | $PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/tasklists.txt" -p "$PROGRAM --ftasklists" 60 | 61 | echo 62 | echo "LaTeX extension:" 63 | $PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/latex-math.txt" -p "$PROGRAM --flatex-math" 64 | 65 | echo 66 | echo "Wiki links extension:" 67 | $PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/wiki-links.txt" -p "$PROGRAM --fwiki-links --ftables" 68 | 69 | echo 70 | echo "Underline extension:" 71 | $PYTHON "$TEST_DIR/spec_tests.py" -s "$TEST_DIR/underline.txt" -p "$PROGRAM --funderline" 72 | 73 | echo 74 | echo "Pathological input:" 75 | $PYTHON "$TEST_DIR/pathological_tests.py" -p "$PROGRAM" 76 | -------------------------------------------------------------------------------- /lib/md4c/test/LICENSE: -------------------------------------------------------------------------------- 1 | The CommonMark spec (spec.txt) and DTD (CommonMark.dtd) are 2 | 3 | Copyright (C) 2014-16 John MacFarlane 4 | 5 | Released under the Creative Commons CC-BY-SA 4.0 license: 6 | . 7 | 8 | --- 9 | 10 | The test software in test/ and the programs in tools/ are 11 | 12 | Copyright (c) 2014, John MacFarlane 13 | 14 | All rights reserved. 15 | 16 | Redistribution and use in source and binary forms, with or without 17 | modification, are permitted provided that the following conditions are met: 18 | 19 | * Redistributions of source code must retain the above copyright 20 | notice, this list of conditions and the following disclaimer. 21 | 22 | * Redistributions in binary form must reproduce the above 23 | copyright notice, this list of conditions and the following 24 | disclaimer in the documentation and/or other materials provided 25 | with the distribution. 26 | 27 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | 39 | --- 40 | 41 | The normalization code in runtests.py was derived from the 42 | markdowntest project, Copyright 2013 Karl Dubost: 43 | 44 | The MIT License (MIT) 45 | 46 | Copyright (c) 2013 Karl Dubost 47 | 48 | Permission is hereby granted, free of charge, to any person obtaining a copy 49 | of this software and associated documentation files (the "Software"), to deal 50 | in the Software without restriction, including without limitation the rights 51 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 52 | copies of the Software, and to permit persons to whom the Software is 53 | furnished to do so, subject to the following conditions: 54 | 55 | The above copyright notice and this permission notice shall be included in 56 | all copies or substantial portions of the Software. 57 | 58 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 59 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 60 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 61 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 62 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 63 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 64 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 65 | -------------------------------------------------------------------------------- /lib/md4c/test/cmark.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | from ctypes import CDLL, c_char_p, c_long 5 | from subprocess import * 6 | import platform 7 | import os 8 | 9 | def pipe_through_prog(prog, text): 10 | p1 = Popen(prog.split(), stdout=PIPE, stdin=PIPE, stderr=PIPE) 11 | [result, err] = p1.communicate(input=text.encode('utf-8')) 12 | return [p1.returncode, result.decode('utf-8'), err] 13 | 14 | def use_library(lib, text): 15 | textbytes = text.encode('utf-8') 16 | textlen = len(textbytes) 17 | return [0, lib(textbytes, textlen, 0).decode('utf-8'), ''] 18 | 19 | class CMark: 20 | def __init__(self, prog=None, library_dir=None): 21 | self.prog = prog 22 | if prog: 23 | self.to_html = lambda x: pipe_through_prog(prog, x) 24 | else: 25 | sysname = platform.system() 26 | if sysname == 'Darwin': 27 | libname = "libcmark.dylib" 28 | elif sysname == 'Windows': 29 | libname = "cmark.dll" 30 | else: 31 | libname = "libcmark.so" 32 | if library_dir: 33 | libpath = os.path.join(library_dir, libname) 34 | else: 35 | libpath = os.path.join("build", "src", libname) 36 | cmark = CDLL(libpath) 37 | markdown = cmark.cmark_markdown_to_html 38 | markdown.restype = c_char_p 39 | markdown.argtypes = [c_char_p, c_long] 40 | self.to_html = lambda x: use_library(markdown, x) 41 | -------------------------------------------------------------------------------- /lib/md4c/test/latex-math.txt: -------------------------------------------------------------------------------- 1 | 2 | # LaTeX Math 3 | 4 | With the flag `MD_FLAG_LATEXMATHSPANS`, MD4C enables extension for recognition 5 | of LaTeX style math spans. 6 | 7 | A math span is is any text wrapped in dollars or double dollars (`$...$` or 8 | `$$...$$`). 9 | 10 | ```````````````````````````````` example 11 | $a+b=c$ Hello, world! 12 | . 13 |

a+b=c Hello, world!

14 | ```````````````````````````````` 15 | 16 | If the double dollar sign is used, the math span is a display math span. 17 | 18 | ```````````````````````````````` example 19 | This is a display equation: $$\int_a^b x dx$$. 20 | . 21 |

This is a display equation: \int_a^b x dx.

22 | ```````````````````````````````` 23 | 24 | Math spans may span multiple lines as they are normal spans: 25 | 26 | ```````````````````````````````` example 27 | $$ 28 | \int_a^b 29 | f(x) dx 30 | $$ 31 | . 32 |

\int_a^b f(x) dx

33 | ```````````````````````````````` 34 | 35 | Note though that many (simple) renderers may output the math spans just as a 36 | verbatim text. (This includes the HTML renderer used by the `md2html` utility.) 37 | 38 | Only advanced renderers which implement LaTeX math syntax can be expected to 39 | provide better results. 40 | -------------------------------------------------------------------------------- /lib/md4c/test/permissive-email-autolinks.txt: -------------------------------------------------------------------------------- 1 | 2 | # Permissive E-mail Autolinks 3 | 4 | With the flag `MD_FLAG_PERMISSIVEEMAILAUTOLINKS`, MD4C enables more permissive 5 | recognition of e-mail addresses and transforms them to autolinks, even if they 6 | do not exactly follow the syntax of autolink as specified in CommonMark 7 | specification. 8 | 9 | This is standard CommonMark e-mail autolink: 10 | 11 | ```````````````````````````````` example 12 | E-mail: 13 | . 14 |

E-mail: mailto:john.doe@gmail.com

15 | ```````````````````````````````` 16 | 17 | With the permissive autolinks enabled, this is sufficient: 18 | 19 | ```````````````````````````````` example 20 | E-mail: john.doe@gmail.com 21 | . 22 |

E-mail: john.doe@gmail.com

23 | ```````````````````````````````` 24 | 25 | `+` can occur before the `@`, but not after. 26 | 27 | ```````````````````````````````` example 28 | hello@mail+xyz.example isn't valid, but hello+xyz@mail.example is. 29 | . 30 |

hello@mail+xyz.example isn't valid, but hello+xyz@mail.example is.

31 | ```````````````````````````````` 32 | 33 | `.`, `-`, and `_` can occur on both sides of the `@`, but only `.` may occur at 34 | the end of the email address, in which case it will not be considered part of 35 | the address: 36 | 37 | ```````````````````````````````` example 38 | a.b-c_d@a.b 39 | 40 | a.b-c_d@a.b. 41 | 42 | a.b-c_d@a.b- 43 | 44 | a.b-c_d@a.b_ 45 | . 46 |

a.b-c_d@a.b

47 |

a.b-c_d@a.b.

48 |

a.b-c_d@a.b-

49 |

a.b-c_d@a.b_

50 | ```````````````````````````````` 51 | -------------------------------------------------------------------------------- /lib/md4c/test/permissive-url-autolinks.txt: -------------------------------------------------------------------------------- 1 | 2 | # Permissive URL Autolinks 3 | 4 | With the flag `MD_FLAG_PERMISSIVEURLAUTOLINKS`, MD4C enables more permissive recognition 5 | of URLs and transform them to autolinks, even if they do not exactly follow the syntax 6 | of autolink as specified in CommonMark specification. 7 | 8 | This is standard CommonMark autolink: 9 | 10 | ```````````````````````````````` example 11 | Homepage: 12 | . 13 |

Homepage: https://github.com/mity/md4c

14 | ```````````````````````````````` 15 | 16 | With the permissive autolinks enabled, this is sufficient: 17 | 18 | ```````````````````````````````` example 19 | Homepage: https://github.com/mity/md4c 20 | . 21 |

Homepage: https://github.com/mity/md4c

22 | ```````````````````````````````` 23 | 24 | But this permissive autolink feature can work only for very widely used URL 25 | schemes, in alphabetical order `ftp:`, `http:`, `https:`. 26 | 27 | That's why this is not a permissive autolink: 28 | 29 | ```````````````````````````````` example 30 | ssh://root@example.com 31 | . 32 |

ssh://root@example.com

33 | ```````````````````````````````` 34 | 35 | The same rules for path validation as for permissivve WWW autolinks apply. 36 | Therefore the final question mark here is not part of the autolink: 37 | 38 | ```````````````````````````````` example 39 | Have you ever visited http://www.zombo.com? 40 | . 41 |

Have you ever visited http://www.zombo.com?

42 | ```````````````````````````````` 43 | 44 | But in contrast, in this example it is: 45 | 46 | ```````````````````````````````` example 47 | http://www.bing.com/search?q=md4c 48 | . 49 |

http://www.bing.com/search?q=md4c

50 | ```````````````````````````````` 51 | 52 | And finally one complex example: 53 | 54 | ```````````````````````````````` example 55 | http://commonmark.org 56 | 57 | (Visit https://encrypted.google.com/search?q=Markup+(business)) 58 | 59 | Anonymous FTP is available at ftp://foo.bar.baz. 60 | . 61 |

http://commonmark.org

62 |

(Visit https://encrypted.google.com/search?q=Markup+(business))

63 |

Anonymous FTP is available at ftp://foo.bar.baz.

64 | ```````````````````````````````` 65 | 66 | 67 | ## GitHub Issues 68 | 69 | ### [Issue 53](https://github.com/mity/md4c/issues/53) 70 | 71 | ```````````````````````````````` example 72 | This is [link](http://github.com/). 73 | . 74 |

This is link.

75 | ```````````````````````````````` 76 | 77 | ```````````````````````````````` example 78 | This is [link](http://github.com/)X 79 | . 80 |

This is linkX

81 | ```````````````````````````````` 82 | 83 | 84 | ## [Issue 76](https://github.com/mity/md4c/issues/76) 85 | 86 | ```````````````````````````````` example 87 | *(http://example.com)* 88 | . 89 |

(http://example.com)

90 | ```````````````````````````````` 91 | 92 | 93 | -------------------------------------------------------------------------------- /lib/md4c/test/strikethrough.txt: -------------------------------------------------------------------------------- 1 | 2 | # Strike-Through 3 | 4 | With the flag `MD_FLAG_STRIKETHROUGH`, MD4C enables extension for recognition 5 | of strike-through spans. 6 | 7 | Strike-through text is any text wrapped in one or two tildes (`~`). 8 | 9 | ```````````````````````````````` example 10 | ~Hi~ Hello, world! 11 | . 12 |

Hi Hello, world!

13 | ```````````````````````````````` 14 | 15 | If the length of the opener and closer doesn't match, the strike-through is 16 | not recognized. 17 | 18 | ```````````````````````````````` example 19 | This ~text~~ is curious. 20 | . 21 |

This ~text~~ is curious.

22 | ```````````````````````````````` 23 | 24 | Too long tilde sequence won't be recognized: 25 | 26 | ```````````````````````````````` example 27 | foo ~~~bar~~~ 28 | . 29 |

foo ~~~bar~~~

30 | ```````````````````````````````` 31 | 32 | Also note the markers cannot open a strike-through span if they are followed 33 | with a whitespace; and similarly, then cannot close the span if they are 34 | preceded with a whitespace: 35 | 36 | ```````````````````````````````` example 37 | ~foo ~bar 38 | . 39 |

~foo ~bar

40 | ```````````````````````````````` 41 | 42 | 43 | As with regular emphasis delimiters, a new paragraph will cause the cessation 44 | of parsing a strike-through: 45 | 46 | ```````````````````````````````` example 47 | This ~~has a 48 | 49 | new paragraph~~. 50 | . 51 |

This ~~has a

52 |

new paragraph~~.

53 | ```````````````````````````````` 54 | 55 | 56 | ## GitHub Issues 57 | 58 | ### [Issue 69](https://github.com/mity/md4c/issues/69) 59 | ```````````````````````````````` example 60 | ~`foo`~ 61 | . 62 |

foo

63 | ```````````````````````````````` 64 | 65 | ```````````````````````````````` example 66 | ~*foo*~ 67 | . 68 |

foo

69 | ```````````````````````````````` 70 | 71 | ```````````````````````````````` example 72 | *~foo~* 73 | . 74 |

foo

75 | ```````````````````````````````` 76 | -------------------------------------------------------------------------------- /lib/md4c/test/underline.txt: -------------------------------------------------------------------------------- 1 | 2 | # Underline 3 | 4 | With the flag `MD_FLAG_UNDERLINE`, MD4C sees underscore `_` rather as a mark 5 | denoting an underlined span rather then an ordinary emphasis (or a strong 6 | emphasis). 7 | 8 | ```````````````````````````````` example 9 | _foo_ 10 | . 11 |

foo

12 | ```````````````````````````````` 13 | 14 | In sequences of multiple underscores, each single one translates into an 15 | underline span mark. 16 | 17 | ```````````````````````````````` example 18 | ___foo___ 19 | . 20 |

foo

21 | ```````````````````````````````` 22 | 23 | Intra-word underscores are not recognized as underline marks: 24 | 25 | ```````````````````````````````` example 26 | foo_bar_baz 27 | . 28 |

foo_bar_baz

29 | ```````````````````````````````` 30 | 31 | Also the parser follows the standard understanding when the underscore can 32 | or cannot open or close a span. Therefore there is no underline in the following 33 | example because no underline can be seen as a closing mark. 34 | 35 | ```````````````````````````````` example 36 | _foo _bar 37 | . 38 |

_foo _bar

39 | ```````````````````````````````` 40 | -------------------------------------------------------------------------------- /misc/coverity-scan-model.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014 Martin Mitas 3 | * 4 | * Model file to eliminate various false positives, when performing static 5 | * code analyzes of mCtrl source code with Coverity scan. 6 | * (See http://scan.coverity.com) 7 | */ 8 | 9 | 10 | /******************************* 11 | *** _malloca() and _freea() *** 12 | *******************************/ 13 | 14 | /* Convince Coverity _malloca() is same as malloc() 15 | * (However _malloca() is a macro so we have to redefine inline functions 16 | * it is based on) */ 17 | void* _MarkAllocaS(void* ptr, unsigned int marker) { return ptr; } 18 | void* alloca(size_t size) { return __coverity_alloc__(size); } 19 | 20 | /* Convince Coverity _freea() is same as free() */ 21 | void _freea(void* ptr) { __coverity_free__(ptr); } 22 | 23 | 24 | /************************ 25 | *** Unreachable code *** 26 | ************************/ 27 | 28 | /* These are done when an assertion fails (MC_ASSERT). */ 29 | void DebugBreak(void) { __coverity_panic__(); } 30 | void exit(int exitcode) { __coverity_panic__(); } 31 | 32 | /* This is gcc way to mark unreachable code path (MC_UNREACHABLE). */ 33 | void __builtin_unreachable() { __coverity_panic__(); } 34 | -------------------------------------------------------------------------------- /scripts/coverity.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This scripts attempts to build the project via cov-build utility, and prepare 4 | # a package for uploading to the coverity scan service. 5 | # 6 | # (See http://scan.coverity.com for more info.) 7 | 8 | set -e 9 | 10 | # Check presence of coverity static analyzer. 11 | if ! which cov-build; then 12 | echo "Utility cov-build not found in PATH." 13 | exit 1 14 | fi 15 | 16 | # Choose a build system (ninja or GNU make). 17 | if which ninja; then 18 | BUILD_TOOL=ninja 19 | GENERATOR=Ninja 20 | elif which make; then 21 | BUILD_TOOL=make 22 | GENERATOR="MSYS Makefiles" 23 | else 24 | echo "No suitable build system found." 25 | exit 1 26 | fi 27 | 28 | # Choose a zip tool. 29 | if which 7za; then 30 | MKZIP="7za a -r -mx9" 31 | elif which 7z; then 32 | MKZIP="7z a -r -mx9" 33 | elif which zip; then 34 | MKZIP="zip -r" 35 | else 36 | echo "No suitable zip utility found" 37 | exit 1 38 | fi 39 | 40 | # Change dir to project root. 41 | cd `dirname "$0"`/.. 42 | 43 | CWD=`pwd` 44 | ROOT_DIR="$CWD" 45 | BUILD_DIR="$CWD/coverity" 46 | OUTPUT="$CWD/cov-int.zip" 47 | 48 | # Sanity checks. 49 | if [ ! -x "$ROOT_DIR/scripts/coverity.sh" ]; then 50 | echo "There is some path mismatch." 51 | exit 1 52 | fi 53 | if [ -e "$BUILD_DIR" ]; then 54 | echo "Path $BUILD_DIR already exists. Delete it and retry." 55 | exit 1 56 | fi 57 | if [ -e "$OUTPUT" ]; then 58 | echo "Path $OUTPUT already exists. Delete it and retry." 59 | exit 1 60 | fi 61 | 62 | # Build the project with the coverity analyzes enabled. 63 | mkdir -p "$BUILD_DIR" 64 | cd "$BUILD_DIR" 65 | cmake -G "$GENERATOR" "$ROOT_DIR" 66 | cov-build --dir cov-int "$BUILD_TOOL" 67 | $MKZIP "$OUTPUT" "cov-int" 68 | cd "$ROOT_DIR" 69 | rm -rf "$BUILD_DIR" 70 | 71 | -------------------------------------------------------------------------------- /src/anim.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2015-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #include "anim.h" 24 | 25 | 26 | static inline int 27 | anim_time_cmp(DWORD t1, DWORD t2) 28 | { 29 | return (int32_t) t1 - (int32_t) t2; 30 | } 31 | 32 | 33 | anim_t* anim_start_ex(HWND win, DWORD duration, DWORD freq, 34 | void* extra_bytes, size_t extra_size) 35 | { 36 | anim_t* anim; 37 | 38 | anim = (anim_t*) malloc(sizeof(anim_t) + extra_size); 39 | if(MC_ERR(anim == NULL)) { 40 | MC_TRACE("anim_start_ex: malloc() failed."); 41 | return NULL; 42 | } 43 | 44 | anim->win = win; 45 | if(extra_size > 0) 46 | memcpy(anim+1, extra_bytes, extra_size); 47 | 48 | anim->time_start = GetTickCount(); 49 | anim->time_prev_frame = anim->time_start; 50 | anim->time_curr_frame = anim->time_start; 51 | anim->time_end = anim->time_start + duration; 52 | 53 | if(MC_ERR(SetTimer(win, (UINT_PTR) anim, 1000 / freq, NULL) == 0)) { 54 | MC_TRACE_ERR("anim_start_ex: SetTimer() failed."); 55 | free(anim); 56 | return NULL; 57 | } 58 | 59 | return anim; 60 | } 61 | 62 | BOOL 63 | anim_step(anim_t* anim) 64 | { 65 | BOOL check_end = (anim->time_start != anim->time_end); 66 | DWORD now; 67 | 68 | now = GetTickCount(); 69 | if(check_end && anim_time_cmp(now, anim->time_end) > 0) 70 | now = anim->time_end; 71 | 72 | anim->time_prev_frame = anim->time_curr_frame; 73 | anim->time_curr_frame = now; 74 | 75 | if(check_end) 76 | return (anim_time_cmp(now, anim->time_end) < 0); 77 | else 78 | return TRUE; 79 | } 80 | 81 | BOOL 82 | anim_is_done(anim_t* anim) 83 | { 84 | return (anim_time_cmp(anim->time_curr_frame, anim->time_end) >= 0); 85 | } 86 | 87 | void 88 | anim_stop(anim_t* anim) 89 | { 90 | KillTimer(anim->win, (UINT_PTR) anim); 91 | free(anim); 92 | } 93 | -------------------------------------------------------------------------------- /src/button.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2009-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_BUTTON_H 24 | #define MC_BUTTON_H 25 | 26 | #include "mCtrl/button.h" 27 | #include "misc.h" 28 | 29 | 30 | #endif /* MC_BUTTON_H */ 31 | -------------------------------------------------------------------------------- /src/chart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_CHART_H 24 | #define MC_CHART_H 25 | 26 | #include "mCtrl/chart.h" 27 | #include "misc.h" 28 | 29 | 30 | #endif /* MC_CHART_H */ 31 | -------------------------------------------------------------------------------- /src/color.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2012-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #include "color.h" 24 | #include "hsluv.h" 25 | 26 | #include 27 | 28 | 29 | COLORREF 30 | color_seq(UINT index) 31 | { 32 | double h, s, l; 33 | double r, g, b; 34 | 35 | /* We generate hue by a method of pie cutting. Initially we cut 3 times 36 | * (red, green and blue), and then in N-th round we cut 3*(2^N) times, 37 | * just between each two neighbor cuts from the set of all cuts already 38 | * made in previous rounds. 39 | * 40 | * We also mix up the cuts of each round by cycling between 3 segments 41 | * of the color cycle (0-120, 120-240 and 240-360 degrees). 42 | */ 43 | if(index < 3) { 44 | h = 120.0 * index; 45 | } else { 46 | int base, i; 47 | 48 | base = 3 * mc_round_down_to_power_of_two_32((int32_t)(index / 3)); 49 | i = index - base; 50 | h = 180.0 / base + (double)(i/3) * (360.0/base) + (double)(i%3) * 120.0; 51 | } 52 | 53 | s = 80.0 + 20.0 * cos(index / 4.2); 54 | l = 50.0 + 30.0 * sin(index / 3.2); 55 | 56 | hsluv2rgb(h, s, l, &r, &g, &b); 57 | return RGB(255.0 * r, 255.0 * g, 255.0 * b); 58 | } 59 | 60 | COLORREF 61 | color_hint(COLORREF color) 62 | { 63 | double r, g, b; 64 | double h, s, l; 65 | 66 | r = GetRValue(color) / 255.0; 67 | g = GetGValue(color) / 255.0; 68 | b = GetBValue(color) / 255.0; 69 | 70 | rgb2hsluv(r, g, b, &h, &s, &l); 71 | l = (l + 100.0) / 2.0; 72 | s = s / 2.0; 73 | hsluv2rgb(h, s, l, &r, &g, &b); 74 | return RGB(255.0 * r, 255.0 * g, 255.0 * b); 75 | } 76 | -------------------------------------------------------------------------------- /src/color.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2012-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_COLOR_H 24 | #define MC_COLOR_H 25 | 26 | #include "misc.h" 27 | 28 | 29 | COLORREF color_seq(UINT index); 30 | 31 | COLORREF color_hint(COLORREF color); 32 | 33 | 34 | #endif /* MC_COLOR_H */ 35 | -------------------------------------------------------------------------------- /src/comua.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_COMUA_H 24 | #define MC_COMUA_H 25 | 26 | #include "misc.h" 27 | #include "c-reusables/data/buffer.h" 28 | 29 | 30 | /* COMUA == Compressed UINTs Array 31 | * 32 | * Sometimes we need to store many UINTs (e.g. some offsets) which generally 33 | * tend to be rather small, but we need to be ready even for the case when they 34 | * are big. 35 | * 36 | * This is a specialized storage for some data. 37 | * 38 | * When building the storage, we use BUFFER. When done, caller may then use 39 | * e.g. buffer_acquire() or copy the data elsewhere, so the reading functions 40 | * take a pointer to the data instead. 41 | */ 42 | 43 | /* Use this to mark "main" or "first" mumbers in multi-number records. 44 | * comua_bsearch() considers only these. */ 45 | #define COMUA_FLAG_RECORD_LEADER 0x1 46 | 47 | int comua_append(BUFFER* buffer, uint64_t num, DWORD flags); 48 | 49 | /* Read a number at the given offsets. Caller is responsible to make sure 50 | * the data points into the COMUA-compatible buffer, to the first byte of 51 | * an encoded integer. */ 52 | uint64_t comua_read(const void* data, size_t size, size_t offset, size_t* p_end_offset); 53 | 54 | /* Binary search in COMUA of the given size. Note the function considers 55 | * only numbers which where marked with COMUA_FLAG_IS_LEADER as potential 56 | * candidates of the search. 57 | * 58 | * Note the function can iterate back byte by byte to find the nearest leader, 59 | * therefore: 60 | * (1) All the "records" should be reasonably short if you want to use this. 61 | * (2) The very 1st number in the COMUA must be leader. 62 | * 63 | * On success, the return value is an offset of the matching record. 64 | * On failure, ((size_t) -1) is returned. 65 | */ 66 | size_t comua_bsearch(const void* data, size_t size, const void* key, 67 | int (*cmp_func)(const void* /*key*/, const void* /*data*/, 68 | size_t /*data_len*/, size_t /*offset*/)); 69 | 70 | 71 | #endif /* MC_COMUA_H */ 72 | -------------------------------------------------------------------------------- /src/dialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2012-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_DIALOG_H 24 | #define MC_DIALOG_H 25 | 26 | #include "misc.h" 27 | #include "mCtrl/dialog.h" 28 | 29 | 30 | 31 | 32 | 33 | #endif /* MC_DIALOG_H */ 34 | -------------------------------------------------------------------------------- /src/doublebuffer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2015-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #include "doublebuffer.h" 24 | 25 | 26 | void 27 | doublebuffer_init(void) 28 | { 29 | BufferedPaintInit(); 30 | } 31 | 32 | void 33 | doublebuffer_fini(void) 34 | { 35 | BufferedPaintUnInit(); 36 | } 37 | 38 | void 39 | doublebuffer(void* control, PAINTSTRUCT* ps, doublebuffer_callback_t callback) 40 | { 41 | BP_PAINTPARAMS params = { sizeof(BP_PAINTPARAMS), BPPF_NOCLIP, NULL, NULL }; 42 | HPAINTBUFFER paint_buffer; 43 | HDC dc; 44 | 45 | paint_buffer = BeginBufferedPaint(ps->hdc, &ps->rcPaint, BPBF_TOPDOWNDIB, ¶ms, &dc); 46 | if(paint_buffer != NULL) { 47 | callback(control, dc, &ps->rcPaint, TRUE); 48 | EndBufferedPaint(paint_buffer, TRUE); 49 | } else { 50 | MC_TRACE("doublebuffer: BeginBufferedPaint() failed."); 51 | /* We shall painting directly, without the double-buffering. */ 52 | callback(control, ps->hdc, &ps->rcPaint, ps->fErase); 53 | } 54 | } 55 | 56 | -------------------------------------------------------------------------------- /src/doublebuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2015-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_DOUBLEBUFFER_H 24 | #define MC_DOUBLEBUFFER_H 25 | 26 | #include "misc.h" 27 | 28 | 29 | typedef struct doublebuffer_tag doublebuffer_t; 30 | struct doublebuffer_tag { 31 | HPAINTBUFFER uxtheme_buf; 32 | }; 33 | 34 | /* Every thread using double buffering should call this. 35 | * (Usually we do this by calling doublebuffer_init() from control's 36 | * WM_NCCREATE and doublebuffer_fini() from WM_NCDESTROY). */ 37 | void doublebuffer_init(void); 38 | void doublebuffer_fini(void); 39 | 40 | /* Simple wrapper for double-buffering controls */ 41 | typedef void (*doublebuffer_callback_t)(void* /*control_data*/, HDC /*dc*/, 42 | RECT* /*dirty_rect*/, BOOL /*erase*/); 43 | 44 | void doublebuffer(void* control, PAINTSTRUCT* ps, doublebuffer_callback_t callback); 45 | 46 | 47 | #endif /* MC_DOUBLEBUFFER_H */ 48 | -------------------------------------------------------------------------------- /src/dsa.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2011-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_DSA_H 24 | #define MC_DSA_H 25 | 26 | #include "misc.h" 27 | 28 | 29 | typedef struct dsa_tag dsa_t; 30 | struct dsa_tag { 31 | void* buffer; 32 | WORD item_size; 33 | WORD size; 34 | WORD capacity; 35 | }; 36 | 37 | /* destructor */ 38 | typedef void (*dsa_dtor_t)(dsa_t*, void*); 39 | 40 | 41 | static inline WORD 42 | dsa_size(dsa_t* dsa) 43 | { 44 | return dsa->size; 45 | } 46 | 47 | static inline WORD 48 | dsa_index(dsa_t* dsa, const void* item) 49 | { 50 | return (int) (((BYTE*)item - (BYTE*)dsa->buffer) / dsa->item_size); 51 | } 52 | 53 | static inline void* 54 | dsa_item(dsa_t* dsa, WORD index) 55 | { 56 | return (void*)&((BYTE*)dsa->buffer)[index * dsa->item_size]; 57 | } 58 | 59 | /* This is harder to use, but it should lead to better optimization. 60 | * (Assuming item_size is a constant known at compile time.) */ 61 | static inline void* 62 | dsa_item_(dsa_t* dsa, WORD index, WORD item_size) 63 | { 64 | return (void*)&((BYTE*)dsa->buffer)[index * item_size]; 65 | } 66 | 67 | #define DSA_ITEM(dsa, index, type) \ 68 | ((type*) dsa_item_((dsa), (index), sizeof(type))) 69 | 70 | 71 | void dsa_init(dsa_t* dsa, WORD item_size); 72 | void dsa_fini(dsa_t* dsa, dsa_dtor_t dtor_func); 73 | 74 | int dsa_reserve(dsa_t* dsa, WORD size); 75 | 76 | void* dsa_insert_raw(dsa_t* dsa, WORD index); 77 | int dsa_insert(dsa_t* dsa, WORD index, void* item); 78 | void dsa_remove(dsa_t* dsa, WORD index, dsa_dtor_t dtor_func); 79 | void dsa_clear(dsa_t* dsa, dsa_dtor_t dtor_func); 80 | 81 | /* Move an item to the new position. */ 82 | void dsa_move(dsa_t* dsa, WORD old_index, WORD new_index); 83 | 84 | 85 | #endif /* MC_DSA_H */ 86 | -------------------------------------------------------------------------------- /src/entity.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_ENTITY_H 24 | #define MC_ENTITY_H 25 | 26 | #include "misc.h" 27 | 28 | 29 | typedef struct entity_tag entity_t; 30 | struct entity_tag { 31 | WCHAR buffer[8]; 32 | size_t len; 33 | }; 34 | 35 | 36 | /* Note: the name should point to the 1st letter after '&'. The string does not 37 | * need to be zero-terminated but its last character has to be semicolon. */ 38 | int entity_decode(const TCHAR* name, entity_t* ent); 39 | 40 | 41 | #endif /* MC_ENTITY_H */ 42 | -------------------------------------------------------------------------------- /src/expand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2012-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_EXPAND_H 24 | #define MC_EXPAND_H 25 | 26 | #include "mCtrl/expand.h" 27 | #include "misc.h" 28 | 29 | 30 | #endif /* MC_EXPAND_H */ 31 | -------------------------------------------------------------------------------- /src/generic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2014-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_GENERIC_H 24 | #define MC_GENERIC_H 25 | 26 | #include "misc.h" 27 | #include "doublebuffer.h" 28 | 29 | 30 | /* "Generic" implementations of some standard control messages. */ 31 | 32 | static inline LRESULT 33 | generic_paint(HWND win, BOOL no_redraw, BOOL do_doublebuffer, 34 | void (*func_paint)(void*, HDC, RECT*, BOOL), 35 | void* ctrl) 36 | { 37 | PAINTSTRUCT ps; 38 | 39 | BeginPaint(win, &ps); 40 | if(!no_redraw) { 41 | if(do_doublebuffer) 42 | doublebuffer(ctrl, &ps, func_paint); 43 | else 44 | func_paint(ctrl, ps.hdc, &ps.rcPaint, ps.fErase); 45 | } 46 | EndPaint(win, &ps); 47 | return 0; 48 | } 49 | 50 | static inline LRESULT 51 | generic_printclient(HWND win, HDC dc, 52 | void (*func_paint)(void*, HDC, RECT*, BOOL), void* ctrl) 53 | { 54 | RECT rect; 55 | 56 | GetClientRect(win, &rect); 57 | func_paint(ctrl, dc, &rect, TRUE); 58 | return 0; 59 | } 60 | 61 | LRESULT generic_ncpaint(HWND win, HTHEME theme, HRGN orig_clip); 62 | LRESULT generic_erasebkgnd(HWND win, HTHEME theme, HDC dc); 63 | 64 | LRESULT generic_settooltips(HWND win, HWND* tooltip_storage, HWND tooltip_win, BOOL tracking); 65 | 66 | 67 | #endif /* MC_GENERIC_H */ 68 | -------------------------------------------------------------------------------- /src/grid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2010-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_GRID_H 24 | #define MC_GRID_H 25 | 26 | #include "mCtrl/grid.h" 27 | #include "misc.h" 28 | 29 | 30 | #endif /* MC_GRID_H */ 31 | -------------------------------------------------------------------------------- /src/html.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2008-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_HTML_H 24 | #define MC_HTML_H 25 | 26 | #include "mCtrl/html.h" 27 | #include "misc.h" 28 | 29 | 30 | #endif /* MC_HTML_H */ 31 | -------------------------------------------------------------------------------- /src/imgview.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2013-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_IMGVIEW_H 24 | #define MC_IMGVIEW_H 25 | 26 | #include "mCtrl/imgview.h" 27 | #include "misc.h" 28 | 29 | 30 | #endif /* MC_IMGVIEW_H */ 31 | -------------------------------------------------------------------------------- /src/labeledit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2015-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_LABELEDIT_H 24 | #define MC_LABELEDIT_H 25 | 26 | #include "misc.h" 27 | 28 | 29 | typedef void (*labeledit_callback_t)(void* /*data*/, const TCHAR* /*text*/, BOOL /*save*/); 30 | 31 | 32 | HWND labeledit_start(HWND parent_win, const TCHAR* text, labeledit_callback_t callback, void* callback_data); 33 | void labeledit_end(HWND parent_win, BOOL save); 34 | 35 | HWND labeledit_win(HWND parent_win); 36 | 37 | 38 | #endif /* MC_LABELEDIT_H */ 39 | -------------------------------------------------------------------------------- /src/mCtrl.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | DllGetVersion 3 | mcButton_Initialize 4 | mcButton_Terminate 5 | mcChart_Initialize 6 | mcChart_Terminate 7 | mcCreateDialogIndirectParamA 8 | mcCreateDialogIndirectParamW 9 | mcCreateDialogParamA 10 | mcCreateDialogParamW 11 | mcDialogBoxIndirectParamA 12 | mcDialogBoxIndirectParamW 13 | mcDialogBoxParamA 14 | mcDialogBoxParamW 15 | mcExpand_Initialize 16 | mcExpand_Terminate 17 | mcGrid_Initialize 18 | mcGrid_Terminate 19 | mcHtml_Initialize 20 | mcHtml_Terminate 21 | mcImgView_Initialize 22 | mcImgView_Terminate 23 | mcIsMenubarMessage 24 | mcMditab_DefWindowProc 25 | mcMditab_Initialize 26 | mcMditab_Terminate 27 | mcMdView_Initialize 28 | mcMdView_Terminate 29 | mcMenubar_HandleRebarChevronPushed 30 | mcMenubar_Initialize 31 | mcMenubar_Terminate 32 | mcTable_AddRef 33 | mcTable_Clear 34 | mcTable_ColumnCount 35 | mcTable_Create 36 | mcTable_GetCellA 37 | mcTable_GetCellW 38 | mcTable_Release 39 | mcTable_Resize 40 | mcTable_RowCount 41 | mcTable_SetCellA 42 | mcTable_SetCellW 43 | mcTreeList_Initialize 44 | mcTreeList_Terminate 45 | mcVersion 46 | -------------------------------------------------------------------------------- /src/mditab.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2008-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_MDITAB_H 24 | #define MC_MDITAB_H 25 | 26 | #include "mCtrl/mditab.h" 27 | #include "misc.h" 28 | 29 | 30 | #endif /* MC_MDITAB_H */ 31 | -------------------------------------------------------------------------------- /src/mdtext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2019-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_MDTEXT_H 24 | #define MC_MDTEXT_H 25 | 26 | #include "misc.h" 27 | #include "xd2d.h" 28 | #include "xdwrite.h" 29 | 30 | 31 | typedef struct mdtext_tag mdtext_t; 32 | 33 | 34 | #define MDTEXT_FLAG_NOJUSTIFY 0x0001 35 | 36 | mdtext_t* mdtext_create(c_IDWriteTextFormat* text_fmt, const TCHAR* text, UINT text_len, UINT width, DWORD flags); 37 | void mdtext_destroy(mdtext_t* mdtext); 38 | 39 | void mdtext_set_width(mdtext_t* mdtext, UINT width); 40 | 41 | UINT mdtext_min_width(mdtext_t* mdtext); 42 | void mdtext_size(mdtext_t* mdtext, SIZE* size); 43 | 44 | void mdtext_paint(mdtext_t* mdtext, c_ID2D1RenderTarget* rt, 45 | int x_offset, int y_offset, 46 | int portview_y0, int portview_y1); 47 | 48 | 49 | typedef struct mdtext_hittest_info_tag mdtext_hittest_info_t; 50 | struct mdtext_hittest_info_tag { 51 | BOOL in_text; 52 | 53 | BOOL in_link; 54 | const TCHAR* link_href; 55 | const TCHAR* link_title; 56 | }; 57 | 58 | 59 | void mdtext_hit_test(mdtext_t* mdtext, int x, int y, mdtext_hittest_info_t* info); 60 | 61 | 62 | #endif /* MC_MDTEXT_H */ 63 | -------------------------------------------------------------------------------- /src/mdview.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2019-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_MDVIEW_H 24 | #define MC_MDVIEW_H 25 | 26 | #include "mCtrl/mdview.h" 27 | #include "misc.h" 28 | 29 | 30 | #endif /* MC_MDVIEW_H */ 31 | -------------------------------------------------------------------------------- /src/menubar.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2012-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_MENUBAR_H 24 | #define MC_MENUBAR_H 25 | 26 | #include "mCtrl/menubar.h" 27 | #include "misc.h" 28 | 29 | 30 | #endif /* MC_MENUBAR_H */ 31 | -------------------------------------------------------------------------------- /src/module.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2009-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_MODULE_H 24 | #define MC_MODULE_H 25 | 26 | #include "misc.h" 27 | 28 | 29 | 30 | #endif /* MC_MODULE_H */ 31 | -------------------------------------------------------------------------------- /src/mousewheel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2015-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_MOUSEWHEEL_H 24 | #define MC_MOUSEWHEEL_H 25 | 26 | #include "misc.h" 27 | 28 | 29 | int mousewheel_scroll(HWND win, int delta, int page, BOOL is_vertical); 30 | 31 | 32 | #endif /* MC_MOUSEWHEEL_H */ 33 | -------------------------------------------------------------------------------- /src/res/divider-h.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/src/res/divider-h.cur -------------------------------------------------------------------------------- /src/res/divider-v.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/src/res/divider-v.cur -------------------------------------------------------------------------------- /src/res/divopen-h.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/src/res/divopen-h.cur -------------------------------------------------------------------------------- /src/res/divopen-v.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/src/res/divopen-v.cur -------------------------------------------------------------------------------- /src/res/expand-19x19.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/src/res/expand-19x19.bmp -------------------------------------------------------------------------------- /src/res/expand-24x24.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/src/res/expand-24x24.bmp -------------------------------------------------------------------------------- /src/res/expand-29x29.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mity/mctrl/db87aecc14ab912f681ef7c5b22f939e53957b6a/src/res/expand-29x29.bmp -------------------------------------------------------------------------------- /src/res/lang-cs.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Martin Mitas 3 | * 4 | * This library is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2.1 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this library; if not, write to the Free Software Foundation, 16 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | LANGUAGE LANG_CZECH, SUBLANG_NEUTRAL 20 | #pragma code_page(65001) /* UTF-8 */ 21 | 22 | STRINGTABLE 23 | BEGIN 24 | IDS_EXPAND_MOREDETAILS "Další podrobnosti\0" 25 | IDS_EXPAND_FEWERDETAILS "Méně podrobností\0" 26 | END 27 | -------------------------------------------------------------------------------- /src/res/lang-en.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Martin Mitas 3 | * 4 | * This library is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2.1 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this library; if not, write to the Free Software Foundation, 16 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL 20 | #pragma code_page(65001) /* UTF-8 */ 21 | 22 | STRINGTABLE 23 | BEGIN 24 | IDS_EXPAND_MOREDETAILS "More details\0" 25 | IDS_EXPAND_FEWERDETAILS "Less details\0" 26 | END 27 | -------------------------------------------------------------------------------- /src/res/lang-fr.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Martin Mitas 3 | * 4 | * This library is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2.1 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this library; if not, write to the Free Software Foundation, 16 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL 20 | #pragma code_page(65001) /* UTF-8 */ 21 | 22 | STRINGTABLE 23 | BEGIN 24 | IDS_EXPAND_MOREDETAILS "Afficher les détails\0" 25 | IDS_EXPAND_FEWERDETAILS "Masquer les détails\0" 26 | END 27 | -------------------------------------------------------------------------------- /src/res/lang-it.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Martin Mitas 3 | * Copyright (c) 2016 Carlo Bramini 4 | * 5 | * This library is free software; you can redistribute it and/or modify it 6 | * under the terms of the GNU Lesser General Public License as published by 7 | * the Free Software Foundation; either version 2.1 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this library; if not, write to the Free Software Foundation, 17 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL 21 | #pragma code_page(65001) /* UTF-8 */ 22 | 23 | STRINGTABLE 24 | BEGIN 25 | IDS_EXPAND_MOREDETAILS "Mostra i dettagli\0" 26 | IDS_EXPAND_FEWERDETAILS "Nascondi i dettagli\0" 27 | END 28 | -------------------------------------------------------------------------------- /src/resource.h: -------------------------------------------------------------------------------- 1 | /* This file is generated automatically from 'resource.h.in' by script 'mkres.sh'. 2 | * Do not edit this file manually. 3 | */ 4 | 5 | /* 6 | * mCtrl: Additional Win32 controls 7 | * 8 | * 9 | * 10 | * Copyright (c) 2008-2020 Martin Mitas 11 | * 12 | * This library is free software; you can redistribute it and/or modify it 13 | * under the terms of the GNU Lesser General Public License as published by 14 | * the Free Software Foundation; either version 2.1 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public License 23 | * along with this library; if not, write to the Free Software Foundation, 24 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | 27 | #ifndef MC_RESOURCE_H 28 | #define MC_RESOURCE_H 29 | 30 | 31 | /******************** 32 | *** Resource IDs *** 33 | *********************/ 34 | 35 | #define IDR_EXPAND_GLYPHS_19 100 36 | #define IDR_EXPAND_GLYPHS_24 101 37 | #define IDR_EXPAND_GLYPHS_29 102 38 | 39 | #define IDR_CURSOR_DIVIDER_H 103 40 | #define IDR_CURSOR_DIVIDER_V 104 41 | #define IDR_CURSOR_DIVOPEN_H 105 42 | #define IDR_CURSOR_DIVOPEN_V 106 43 | 44 | 45 | /****************** 46 | *** String IDs *** 47 | ******************/ 48 | 49 | #define IDS_EXPAND_MOREDETAILS 0 50 | #define IDS_EXPAND_FEWERDETAILS 1 51 | 52 | 53 | #endif /* MC_RESOURCE_H */ 54 | -------------------------------------------------------------------------------- /src/resource.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2008-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_RESOURCE_H 24 | #define MC_RESOURCE_H 25 | 26 | 27 | /******************** 28 | *** Resource IDs *** 29 | *********************/ 30 | 31 | #define IDR_EXPAND_GLYPHS_19 @RESOURCE_ID@ 32 | #define IDR_EXPAND_GLYPHS_24 @RESOURCE_ID@ 33 | #define IDR_EXPAND_GLYPHS_29 @RESOURCE_ID@ 34 | 35 | #define IDR_CURSOR_DIVIDER_H @RESOURCE_ID@ 36 | #define IDR_CURSOR_DIVIDER_V @RESOURCE_ID@ 37 | #define IDR_CURSOR_DIVOPEN_H @RESOURCE_ID@ 38 | #define IDR_CURSOR_DIVOPEN_V @RESOURCE_ID@ 39 | 40 | 41 | /****************** 42 | *** String IDs *** 43 | ******************/ 44 | 45 | #define IDS_EXPAND_MOREDETAILS @STRING_ID@ 46 | #define IDS_EXPAND_FEWERDETAILS @STRING_ID@ 47 | 48 | 49 | #endif /* MC_RESOURCE_H */ 50 | -------------------------------------------------------------------------------- /src/resource.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2008-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #include 24 | #include "version.h" 25 | #include "resource.h" 26 | 27 | 28 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL 29 | #pragma code_page(65001) /* UTF-8 */ 30 | 31 | 32 | 33 | /********************************** 34 | *** Language neutral resources *** 35 | **********************************/ 36 | 37 | IDR_EXPAND_GLYPHS_19 BITMAP "res/expand-19x19.bmp" 38 | IDR_EXPAND_GLYPHS_24 BITMAP "res/expand-24x24.bmp" 39 | IDR_EXPAND_GLYPHS_29 BITMAP "res/expand-29x29.bmp" 40 | 41 | IDR_CURSOR_DIVIDER_H CURSOR "res/divider-h.cur" 42 | IDR_CURSOR_DIVIDER_V CURSOR "res/divider-v.cur" 43 | IDR_CURSOR_DIVOPEN_H CURSOR "res/divopen-h.cur" 44 | IDR_CURSOR_DIVOPEN_V CURSOR "res/divopen-v.cur" 45 | 46 | 47 | /******************** 48 | *** Version info *** 49 | ********************/ 50 | 51 | VS_VERSION_INFO VERSIONINFO 52 | FILEVERSION MC_VERSION_MAJOR, MC_VERSION_MINOR, MC_VERSION_RELEASE, 0 53 | PRODUCTVERSION MC_VERSION_MAJOR, MC_VERSION_MINOR, MC_VERSION_RELEASE, 0 54 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 55 | #ifndef DEBUG 56 | FILEFLAGS 0 57 | #else 58 | FILEFLAGS VS_FF_DEBUG 59 | #endif 60 | FILEOS VOS_NT_WINDOWS32 61 | FILETYPE VFT_DLL 62 | FILESUBTYPE 0 63 | BEGIN 64 | BLOCK "StringFileInfo" 65 | BEGIN 66 | BLOCK "000004b0" /* language: 0 (neutral); charset: 0x04b0 == 1200 (unicode) */ 67 | BEGIN 68 | VALUE "ProductName", "mCtrl Library" 69 | VALUE "FileDescription", "Additional User Experience Controls Library" 70 | VALUE "OriginalFilename", "mCtrl.dll" 71 | VALUE "InternalName", "mCtrl" 72 | VALUE "CompanyName", "morous.org" 73 | VALUE "FileVersion", MC_VERSION_STR 74 | VALUE "ProductVersion", MC_VERSION_STR 75 | VALUE "LegalCopyright", "© 2008-2019 Martin Mitáš" 76 | VALUE "WWW", "http://mctrl.org" 77 | END 78 | END 79 | BLOCK "VarFileInfo" 80 | BEGIN 81 | VALUE "Translation", 0, 1200 82 | END 83 | END 84 | 85 | 86 | /****************************** 87 | *** Per-language resources *** 88 | ******************************/ 89 | 90 | #include "res/lang-cs.rc" /* Czech */ 91 | #include "res/lang-en.rc" /* English */ 92 | #include "res/lang-fr.rc" /* French */ 93 | #include "res/lang-it.rc" /* Italian */ 94 | 95 | -------------------------------------------------------------------------------- /src/tooltip.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2015-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_TOOLTIP_H 24 | #define MC_TOOLTIP_H 25 | 26 | #include "misc.h" 27 | 28 | 29 | /* Notes: 30 | * - tooltip_create() calls tooltip_install() automatically. 31 | * - notify_win (if not NULL), it gets NM_TOOLTIPSCREATED) but all 32 | * notifications from the tooltip itself are sent to the control_win. 33 | */ 34 | HWND tooltip_create(HWND control_win, HWND notify_win, BOOL tracking); 35 | void tooltip_destroy(HWND tooltip_win); 36 | 37 | /* Add/remove a tooltip tool for complete control_win. */ 38 | void tooltip_install(HWND tooltip_win, HWND control_win, BOOL tracking); 39 | void tooltip_uninstall(HWND tooltip_win, HWND control_win); 40 | 41 | /* Functions to be used only for tracking tooltip. */ 42 | void tooltip_show_tracking(HWND tooltip_win, HWND control_win, BOOL show); 43 | void tooltip_move_tracking(HWND tooltip_win, HWND control_win, int x, int y); 44 | 45 | /* str may be LPSTR_TEXTCALLBACK if control_win handles TTN_GETDISPINFO. */ 46 | void tooltip_update_text(HWND tooltip_win, HWND control_win, const TCHAR* str); 47 | 48 | /* Get current tooltip window size. */ 49 | void tooltip_size(HWND tooltip_win, SIZE* size); 50 | 51 | 52 | #endif /* MC_TOOLTIP_H */ 53 | -------------------------------------------------------------------------------- /src/treelist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_TREELIST_H 24 | #define MC_TREELIST_H 25 | 26 | #include "mCtrl/treelist.h" 27 | #include "misc.h" 28 | 29 | 30 | #endif /* MC_TREELIST_H */ 31 | -------------------------------------------------------------------------------- /src/url.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2019-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #include "url.h" 24 | 25 | 26 | #define DECODE_IS_XDIGIT(ch) ((_T('0') <= (ch) && (ch) <= _T('9')) || \ 27 | (_T('a') <= (ch) && (ch) <= _T('f')) || \ 28 | (_T('A') <= (ch) && (ch) <= _T('F'))) 29 | 30 | #define DECODE_XDIGIT_VAL(ch) \ 31 | ((_T('0') <= (ch) && (ch) <= _T('9')) ? (ch) - _T('0') : \ 32 | (_T('a') <= (ch) && (ch) <= _T('f')) ? 10 + (ch) - _T('a') : \ 33 | 10 + (ch) - _T('A')) 34 | 35 | void 36 | url_decode(TCHAR* str) 37 | { 38 | TCHAR* in = str; 39 | TCHAR* out; 40 | 41 | /* Fast path for any prefix without any percents. */ 42 | while(*in != _T('\0') && *in != _T('%')) 43 | in++; 44 | out = in; 45 | 46 | /* Slow path if we encounter any percent(s). */ 47 | while(*in != _T('\0')) { 48 | if(*in == _T('%') && DECODE_IS_XDIGIT(*(in+1)) && DECODE_IS_XDIGIT(*(in+2))) { 49 | *out = (DECODE_XDIGIT_VAL(*(in+1)) << 4) | DECODE_XDIGIT_VAL(*(in+2)); 50 | in += 3; 51 | out++; 52 | } else { 53 | *in = *out; 54 | in++; 55 | out++; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/url.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2019-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_URL_H 24 | #define MC_URL_H 25 | 26 | #include "misc.h" 27 | 28 | 29 | /* Decode (in-place) URL percent notation. */ 30 | void url_decode(TCHAR* str); 31 | 32 | 33 | #endif /* MC_URL_H */ 34 | -------------------------------------------------------------------------------- /src/version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2008-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #include "version.h" 24 | #include "mCtrl/version.h" 25 | #include "misc.h" 26 | 27 | 28 | void MCTRL_API 29 | mcVersion(MC_VERSION* version) 30 | { 31 | version->dwMajor = MC_VERSION_MAJOR; 32 | version->dwMinor = MC_VERSION_MINOR; 33 | version->dwRelease = MC_VERSION_RELEASE; 34 | } 35 | 36 | 37 | /* DllGetVersion accepts pointer to structure determined in runtime 38 | * by first DWORD (cbSize). */ 39 | typedef union dllgetversioninfo_tag dllgetversioninfo_t; 40 | union dllgetversioninfo_tag { 41 | DWORD cbSize; 42 | DLLVERSIONINFO info1; 43 | DLLVERSIONINFO2 info2; 44 | }; 45 | 46 | HRESULT MCTRL_API 47 | DllGetVersion(dllgetversioninfo_t* dvi) 48 | { 49 | switch(dvi->cbSize) { 50 | case sizeof(DLLVERSIONINFO2): 51 | dvi->info2.dwFlags = 0; 52 | dvi->info2.ullVersion = MAKEDLLVERULL(MC_VERSION_MAJOR, 53 | MC_VERSION_MINOR, MC_VERSION_RELEASE, 0); 54 | /* no break, fall through */ 55 | 56 | case sizeof(DLLVERSIONINFO): 57 | dvi->info1.dwMajorVersion = MC_VERSION_MAJOR; 58 | dvi->info1.dwMinorVersion = MC_VERSION_MINOR; 59 | dvi->info1.dwBuildNumber = MC_VERSION_RELEASE; 60 | dvi->info1.dwPlatformID = DLLVER_PLATFORM_NT; 61 | return S_OK; 62 | 63 | default: 64 | MC_TRACE("DllGetVersion: unsupported cbSize"); 65 | return E_INVALIDARG; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2008-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_VERSION_H 24 | #define MC_VERSION_H 25 | 26 | 27 | #define MC_VERSION_MAJOR @MCTRL_MAJOR_VERSION@ 28 | #define MC_VERSION_MINOR @MCTRL_MINOR_VERSION@ 29 | #define MC_VERSION_RELEASE @MCTRL_PATCH_VERSION@ 30 | 31 | 32 | /* Stringize given expression */ 33 | #define MC_STRINGIZE_HELPER(a) #a 34 | #define MC_STRINGIZE(a) MC_STRINGIZE_HELPER(a) 35 | 36 | 37 | #ifdef DEBUG 38 | #define MC_VERSION_STR \ 39 | MC_STRINGIZE(MC_VERSION_MAJOR.MC_VERSION_MINOR.MC_VERSION_RELEASE-dbg(DEBUG)) 40 | #else 41 | #define MC_VERSION_STR \ 42 | MC_STRINGIZE(MC_VERSION_MAJOR.MC_VERSION_MINOR.MC_VERSION_RELEASE) 43 | #endif 44 | 45 | 46 | #endif /* MC_VERSION_H */ 47 | -------------------------------------------------------------------------------- /src/viewlist.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2010-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #include "viewlist.h" 24 | 25 | 26 | int 27 | view_list_install_view(view_list_t* vlist, void* view, view_refresh_t refresh) 28 | { 29 | view_node_t* node; 30 | 31 | node = dsa_insert_raw(&vlist->dsa, dsa_size(&vlist->dsa)); 32 | if(MC_ERR(node == NULL)) { 33 | MC_TRACE("view_install: dsa_insert_raw() failed."); 34 | return -1; 35 | } 36 | 37 | node->view = view; 38 | node->refresh = refresh; 39 | return 0; 40 | } 41 | 42 | void 43 | view_list_uninstall_view(view_list_t* vlist, void* view) 44 | { 45 | int i, n; 46 | 47 | n = dsa_size(&vlist->dsa); 48 | for(i = 0; i < n; i++) { 49 | view_node_t* node = DSA_ITEM(&vlist->dsa, i, view_node_t); 50 | if(view == node->view) { 51 | dsa_remove(&vlist->dsa, i, NULL); 52 | return; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/viewlist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2010-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_VIEWLIST_H 24 | #define MC_VIEWLIST_H 25 | 26 | #include "misc.h" 27 | #include "dsa.h" 28 | 29 | 30 | /* The models (as in model-view-controller paradigm) must be aware of their 31 | * views so the views are notified to be refreshed whenever the model state 32 | * changes. 33 | * 34 | * The view list is just such a container for the views reused in the various 35 | * models. 36 | */ 37 | 38 | 39 | typedef void (*view_refresh_t)(void* /*view*/, void* /*detail*/); 40 | 41 | 42 | typedef struct view_node_tag view_node_t; 43 | struct view_node_tag { 44 | void* view; 45 | view_refresh_t refresh; 46 | }; 47 | 48 | typedef struct view_list_tag view_list_t; 49 | struct view_list_tag { 50 | dsa_t dsa; 51 | }; 52 | 53 | 54 | static inline void 55 | view_list_init(view_list_t* vlist) 56 | { 57 | dsa_init(&vlist->dsa, sizeof(view_node_t)); 58 | } 59 | 60 | static inline void 61 | view_list_fini(view_list_t* vlist) 62 | { 63 | MC_ASSERT(dsa_size(&vlist->dsa) == 0); 64 | dsa_fini(&vlist->dsa, NULL); 65 | } 66 | 67 | int view_list_install_view(view_list_t* vlist, void* view, view_refresh_t refresh); 68 | void view_list_uninstall_view(view_list_t* vlist, void* view); 69 | 70 | static inline void 71 | view_list_refresh(view_list_t* vlist, void* detail) 72 | { 73 | int i, n; 74 | n = dsa_size(&vlist->dsa); 75 | for(i = 0; i < n; i++) { 76 | view_node_t* node = DSA_ITEM(&vlist->dsa, i, view_node_t); 77 | node->refresh(node->view, detail); 78 | } 79 | } 80 | 81 | 82 | #endif /* MC_VIEWLIST_H */ 83 | -------------------------------------------------------------------------------- /src/xcom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2015-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_XCOM_H 24 | #define MC_XCOM_H 25 | 26 | #include "misc.h" 27 | 28 | 29 | /* The purpose of this is to not force COM-unaware applications to initialize 30 | * COM just for MCTRL.DLL, yet to not stand in a way if the application does so. 31 | * (See http://blogs.msdn.com/b/larryosterman/archive/2004/05/12/130541.aspx) 32 | * 33 | * The function ensures COM is initialized (if not it calls CoInitialize() 34 | * or some of its friends), and then it just calls CoCreateInstance(). 35 | */ 36 | void* xcom_init_create(const CLSID* clsid, DWORD context, const IID* iid); 37 | 38 | /* Calls CoUninitialize() if it was initialized in previous xcom_create_init(). 39 | * Otherwise noop. */ 40 | void xcom_uninit(void); 41 | 42 | 43 | #endif /* MC_XCOM_H */ 44 | -------------------------------------------------------------------------------- /src/xdwm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2015-2020 Martin Mitas 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This library 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 Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef MC_XDWM_H 24 | #define MC_XDWM_H 25 | 26 | #include "misc.h" 27 | 28 | 29 | BOOL xdwm_is_composition_enabled(void); 30 | 31 | void xdwm_extend_frame(HWND win, int margin_left, int margin_top, 32 | int margin_right, int margin_bottom); 33 | 34 | BOOL xdwm_def_window_proc(HWND win, UINT msg, WPARAM wp, LPARAM lp, LRESULT* res); 35 | 36 | 37 | #endif /* MC_XDWM_H */ 38 | -------------------------------------------------------------------------------- /src/xwic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mCtrl: Additional Win32 controls 3 | * 4 | * 5 | * 6 | * Copyright (c) 2019-2020 Martin Mitas 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a 9 | * copy of this software and associated documentation files (the "Software"), 10 | * to deal in the Software without restriction, including without limitation 11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 | * and/or sell copies of the Software, and to permit persons to whom the 13 | * Software is furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 24 | * IN THE SOFTWARE. 25 | */ 26 | 27 | #ifndef MC_XWIC_H 28 | #define MC_XWIC_H 29 | 30 | #include "misc.h" 31 | #include 32 | 33 | 34 | IWICBitmapSource* xwic_from_HICON(HICON icon); 35 | IWICBitmapSource* xwic_from_HBITMAP(HBITMAP bmp, WICBitmapAlphaChannelOption alpha_mode); 36 | IWICBitmapSource* xwic_from_file(const TCHAR* path); 37 | IWICBitmapSource* xwic_from_resource(HINSTANCE instance, const TCHAR* res_type, const TCHAR* res_name); 38 | 39 | 40 | #endif /* MC_XWIC_H */ 41 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | if(CMAKE_COMPILER_IS_GNUCC) 4 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") 5 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc") 6 | elseif(MSVC) 7 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MT") 8 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") 9 | add_definitions(/D_CRT_SECURE_NO_WARNINGS) 10 | endif() 11 | 12 | 13 | add_executable(test-build test-build.c) 14 | # (test-build.exe uses LoadLibrary. Do not link with the mCtrl lib.) 15 | 16 | add_executable(test-grid test-grid.c) 17 | target_link_libraries(test-grid mCtrl) 18 | 19 | add_executable(test-table test-table.c) 20 | target_link_libraries(test-table mCtrl) 21 | -------------------------------------------------------------------------------- /tests/test-grid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Unit tests verifying grid control 3 | * Copyright (c) 2016 Martin Mitas 4 | */ 5 | 6 | #include "acutest.h" 7 | #include 8 | #include 9 | 10 | 11 | static void 12 | init_test(void) 13 | { 14 | TEST_CHECK(mcGrid_Initialize()); 15 | mcGrid_Terminate(); 16 | } 17 | 18 | 19 | /***************** 20 | *** Test List *** 21 | *****************/ 22 | 23 | TEST_LIST = { 24 | { "initialization", init_test }, 25 | { 0 } 26 | }; 27 | --------------------------------------------------------------------------------