├── .gitattributes ├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── appveyor.yml ├── build ├── bakefile │ ├── nana.bkl │ └── readme.md ├── cmake │ ├── Modules │ │ └── FindFontconfig.cmake │ ├── OS.cmake │ ├── compilers.cmake │ ├── enable_audio.cmake │ ├── enable_jpeg.cmake │ ├── enable_png.cmake │ ├── install_nana.cmake │ ├── select_filesystem.cmake │ ├── shared_libs.cmake │ └── verbose.cmake ├── codeblocks │ └── nana.cbp ├── makefile │ ├── makefile │ └── readme.md ├── vc2013 │ ├── nana.sln │ ├── nana.vcxproj │ └── nana.vcxproj.filters ├── vc2015 │ ├── nana.sln │ ├── nana.vcxproj │ └── nana.vcxproj.filters ├── vc2017 │ ├── nana.sln │ ├── nana.vcxproj │ └── nana.vcxproj.filters └── vc2019 │ ├── nana.sln │ ├── nana.vcxproj │ └── nana.vcxproj.filters ├── extrlib └── readme.txt ├── how-to-install.txt ├── include └── nana │ ├── any.hpp │ ├── audio │ ├── detail │ │ ├── audio_device.hpp │ │ ├── audio_stream.hpp │ │ └── buffer_preparation.hpp │ └── player.hpp │ ├── basic_types.hpp │ ├── c++defines.hpp │ ├── charset.hpp │ ├── concepts.hpp │ ├── config.hpp │ ├── datetime.hpp │ ├── deploy.hpp │ ├── filesystem │ ├── filesystem.hpp │ └── filesystem_ext.hpp │ ├── fwd.hpp │ ├── gui.hpp │ ├── gui │ ├── animation.hpp │ ├── basis.hpp │ ├── compact.hpp │ ├── detail │ │ ├── bedrock.hpp │ │ ├── color_schemes.hpp │ │ ├── drawer.hpp │ │ ├── element_store.hpp │ │ ├── event_code.hpp │ │ ├── events_holder.hpp │ │ ├── events_operation.hpp │ │ ├── general_events.hpp │ │ ├── inner_fwd.hpp │ │ ├── internal_scope_guard.hpp │ │ ├── native_window_interface.hpp │ │ ├── widget_content_measurer_interface.hpp │ │ ├── widget_geometrics.hpp │ │ ├── widget_notifier_interface.hpp │ │ ├── window_layout.hpp │ │ └── window_manager.hpp │ ├── dragdrop.hpp │ ├── dragger.hpp │ ├── drawing.hpp │ ├── effects.hpp │ ├── element.hpp │ ├── filebox.hpp │ ├── layout_utility.hpp │ ├── msgbox.hpp │ ├── notifier.hpp │ ├── place.hpp │ ├── programming_interface.hpp │ ├── screen.hpp │ ├── state_cursor.hpp │ ├── timer.hpp │ ├── tooltip.hpp │ └── widgets │ │ ├── button.hpp │ │ ├── categorize.hpp │ │ ├── checkbox.hpp │ │ ├── combox.hpp │ │ ├── date_chooser.hpp │ │ ├── detail │ │ ├── compset.hpp │ │ ├── inline_widget.hpp │ │ ├── inline_widget_manager.hpp │ │ ├── tree_cont.hpp │ │ └── widget_iterator.hpp │ │ ├── float_listbox.hpp │ │ ├── form.hpp │ │ ├── group.hpp │ │ ├── label.hpp │ │ ├── listbox.hpp │ │ ├── menu.hpp │ │ ├── menubar.hpp │ │ ├── panel.hpp │ │ ├── picture.hpp │ │ ├── progress.hpp │ │ ├── scroll.hpp │ │ ├── skeletons │ │ ├── text_editor.hpp │ │ ├── text_editor_part.hpp │ │ ├── text_token_stream.hpp │ │ ├── textbase.hpp │ │ └── textbase_export_interface.hpp │ │ ├── slider.hpp │ │ ├── spinbox.hpp │ │ ├── tabbar.hpp │ │ ├── textbox.hpp │ │ ├── toolbar.hpp │ │ ├── treebox.hpp │ │ └── widget.hpp │ ├── internationalization.hpp │ ├── key_type.hpp │ ├── optional.hpp │ ├── paint │ ├── detail │ │ ├── image_impl_interface.hpp │ │ ├── image_process_provider.hpp │ │ ├── native_paint_interface.hpp │ │ └── ptdefs.hpp │ ├── graphics.hpp │ ├── image.hpp │ ├── image_process_interface.hpp │ ├── image_process_selector.hpp │ ├── pixel_buffer.hpp │ └── text_renderer.hpp │ ├── pat │ ├── abstract_factory.hpp │ └── cloneable.hpp │ ├── pop_ignore_diagnostic │ ├── push_ignore_diagnostic │ ├── std_condition_variable.hpp │ ├── std_mutex.hpp │ ├── std_thread.hpp │ ├── stdc++.hpp │ ├── system │ ├── dataexch.hpp │ ├── platform.hpp │ ├── shared_wrapper.hpp │ └── timepiece.hpp │ ├── threads │ └── pool.hpp │ ├── traits.hpp │ ├── unicode_bidi.hpp │ └── verbose_preprocessor.hpp └── source ├── any.cpp ├── audio ├── detail │ ├── audio_device.cpp │ ├── audio_stream.cpp │ └── buffer_preparation.cpp └── player.cpp ├── basic_types.cpp ├── charset.cpp ├── datetime.cpp ├── deploy.cpp ├── detail ├── mswin │ └── platform_spec.hpp ├── platform_abstraction.cpp ├── platform_abstraction.hpp ├── platform_abstraction_types.hpp ├── platform_spec_posix.cpp ├── platform_spec_selector.hpp ├── platform_spec_windows.cpp ├── posix │ ├── msg_dispatcher.hpp │ ├── msg_packet.hpp │ ├── platform_spec.hpp │ ├── theme.cpp │ ├── theme.hpp │ └── xdnd_protocol.hpp └── text_reshaping.hpp ├── filesystem └── filesystem.cpp ├── gui ├── animation.cpp ├── basis.cpp ├── detail │ ├── basic_window.cpp │ ├── basic_window.hpp │ ├── bedrock_pi.cpp │ ├── bedrock_posix.cpp │ ├── bedrock_types.hpp │ ├── bedrock_windows.cpp │ ├── color_schemes.cpp │ ├── drawer.cpp │ ├── dynamic_drawing_object.hpp │ ├── effects_renderer.hpp │ ├── element_store.cpp │ ├── events_operation.cpp │ ├── inner_fwd_implement.hpp │ ├── native_window_interface.cpp │ ├── window_layout.cpp │ ├── window_manager.cpp │ └── window_register.hpp ├── dragdrop.cpp ├── dragger.cpp ├── drawing.cpp ├── effects.cpp ├── element.cpp ├── filebox.cpp ├── layout_utility.cpp ├── msgbox.cpp ├── notifier.cpp ├── place.cpp ├── place_parts.hpp ├── programming_interface.cpp ├── screen.cpp ├── state_cursor.cpp ├── timer.cpp ├── tooltip.cpp ├── widgets │ ├── button.cpp │ ├── categorize.cpp │ ├── checkbox.cpp │ ├── combox.cpp │ ├── date_chooser.cpp │ ├── float_listbox.cpp │ ├── form.cpp │ ├── group.cpp │ ├── label.cpp │ ├── listbox.cpp │ ├── menu.cpp │ ├── menubar.cpp │ ├── panel.cpp │ ├── picture.cpp │ ├── progress.cpp │ ├── scroll.cpp │ ├── skeletons │ │ ├── content_view.cpp │ │ ├── content_view.hpp │ │ └── text_editor.cpp │ ├── slider.cpp │ ├── spinbox.cpp │ ├── tabbar.cpp │ ├── textbox.cpp │ ├── toolbar.cpp │ ├── treebox.cpp │ └── widget.cpp └── wvl.cpp ├── internationalization.cpp ├── paint ├── detail │ ├── image_bmp.hpp │ ├── image_ico.hpp │ ├── image_ico_resource.hpp │ ├── image_jpeg.hpp │ ├── image_pixbuf.hpp │ ├── image_png.hpp │ ├── image_process_provider.cpp │ ├── image_processor.hpp │ └── native_paint_interface.cpp ├── graphics.cpp ├── image.cpp ├── image_accessor.hpp ├── image_process_selector.cpp ├── pixel_buffer.cpp ├── text_renderer.cpp └── truetype.hpp ├── stdc++.cpp ├── system ├── dataexch.cpp ├── platform.cpp ├── shared_wrapper.cpp ├── split_string.cpp ├── split_string.hpp └── timepiece.cpp ├── threads └── pool.cpp └── unicode_bidi.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sln text eol=crlf 2 | *.vcxproj text eol=crlf 3 | *.vcxproj.filters text eol=crlf 4 | *.vcxproj.user text eol=crlf 5 | *.bat text eol=crlf 6 | Makefile text eolf=lf 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #This .gitignore created by Ariel Vina-Rodriguez 2 | #ignore thumbnails created by windows 3 | Thumbs.db 4 | #Ignore files build by Visual Studio 5 | bii/build/* 6 | bii/cmake/* 7 | bii/deps/* 8 | build/vc2013-bkl/* 9 | build/makefile-bkl/* 10 | build/compile_commands.json 11 | build/install_manifest.txt 12 | *.obj 13 | *.exe 14 | *.pdb 15 | *.user 16 | *.aps 17 | *.pch 18 | *.vspscc 19 | *_i.c 20 | *_p.c 21 | *.ncb 22 | *.tlb 23 | *.tlh 24 | *.bak 25 | *.cache 26 | *.ilk 27 | *.log 28 | [Bb]in 29 | [Bb]in/ 30 | [Dd]ebug*/ 31 | *.lib 32 | *.a 33 | *.sbr 34 | obj/ 35 | [Rr]elease*/ 36 | _ReSharper*/ 37 | [Tt]est[Rr]esult* 38 | *.suo 39 | *.sdf 40 | lib/ 41 | *.ninja* 42 | CMakeCache.txt 43 | CMakeFiles/ 44 | cmake-build-debug/ 45 | cmake-build-*/ 46 | .idea/ 47 | cmake_install.cmake 48 | *.DS_Store 49 | 50 | *.db 51 | *.opendb 52 | .vscode 53 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: generic 3 | 4 | cache: 5 | apt: true 6 | directories: 7 | - /tmp/tools 8 | 9 | matrix: 10 | include: 11 | - env: CXX=g++-8 12 | addons: 13 | apt: 14 | packages: 15 | - g++-8 16 | - libjpeg8-dev 17 | - libpng-dev 18 | - libasound2-dev 19 | - alsa-utils 20 | - alsa-oss 21 | - libx11-dev 22 | - libxft-dev 23 | - libxcursor-dev 24 | sources: 25 | - ubuntu-toolchain-r-test 26 | 27 | allow_failures: 28 | - env: CXX=clang++-3.8 CC=clang-3.8 29 | addons: 30 | apt: 31 | packages: 32 | - clang-3.8 33 | - libjpeg8-dev 34 | - libpng-dev 35 | - libasound2-dev 36 | - alsa-utils 37 | - alsa-oss 38 | - libx11-dev 39 | - libxft-dev 40 | - libxcursor-dev 41 | sources: 42 | - ubuntu-toolchain-r-test 43 | - llvm-toolchain-precise 44 | 45 | before_install: 46 | # donwload nana-demo first 47 | # we are in: 'user'/nana/ 48 | - cd .. 49 | # we are in: 'user'/ 50 | - git clone --depth=1 --branch=master https://github.com/qPCR4vir/nana-demo.git nana-demo 51 | # now we have 'user'/nana-demo, 'user'/nana/ and we are in: 'user'/ 52 | - export PATH="$HOME/bin:$PATH" 53 | - wget --no-check-certificate --no-clobber -O /tmp/tools/cmake https://cmake.org/files/v3.12/cmake-3.12.0-rc3-Linux-x86_64.sh || true 54 | - chmod -R +x /tmp/tools 55 | 56 | install: 57 | - /tmp/tools/cmake --prefix="$HOME" --exclude-subdir 58 | 59 | before_script : 60 | - mkdir demo-build 61 | - cd demo-build 62 | # now we have 'user'/nana-demo, 'user'/nana/ , 'user'/demo-build/ and we are in: 'user'/demo-build/ 63 | 64 | services: 65 | # travis don't have a physical monitor. We need to install an emulator: 66 | # https://docs.travis-ci.com/user/gui-and-headless-browsers/ 67 | - xvfb 68 | 69 | script: 70 | - cmake -G"Unix Makefiles" ../nana-demo -DCMAKE_INSTALL_PREFIX=.. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON -DNANA_CMAKE_INSTALL=OFF 71 | - make install 72 | - ctest --verbose # todo set correct working directory, and show output 73 | # we have installed in 'user'/ ('user'/demo-build/..), and cmake created 'user'/nana-test/ 74 | # todo: separate resources from sources (a directory for images) 75 | - ls 76 | # we were still in: 'user'/demo-build/ 77 | - cd ../nana-test/bin 78 | - ls -lh 79 | 80 | 81 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nana C++ Library 2 | 3 | [![Licence](https://img.shields.io/badge/license-BSL-blue.svg?style=flat)](LICENSE) 4 | 5 | 6 | Nana is a C++ standard-like GUI library designed to allow developers to easily create cross-platform GUI applications with modern C++ style. Currently it is regularly tested on Linux(X11) and Windows, and experimentally on macOS and FreeBSD. The [nana repository](https://github.com/cnjinhao/nana) contains the entire source of the library. You can browse the source code and submit your pull request for contributing. 7 | 8 | ## License 9 | 10 | Nana is licensed under the [Boost Software License](http://www.boost.org/LICENSE_1_0.txt) 11 | 12 | ## Members 13 | 14 | Jinhao, [Ariel Viña Rodríguez]. 15 | 16 | [Ariel Viña Rodríguez]: http://qpcr4vir.github.io/ 17 | 18 | ## Documentation 19 | 20 | The best way to get help with Nana library is by visiting https://nana.acemind.cn/documentation 21 | 22 | ## Examples 23 | 24 | Here are some examples to give you an idea how to use the Nana C++ Library. 25 | 26 | ### Create a window 27 | 28 | The `form` class provides methods to manipulating a window. 29 | ```C++ 30 | #include 31 | 32 | int main() 33 | { 34 | nana::form fm; 35 | fm.show(); 36 | nana::exec(); 37 | } 38 | ``` 39 | 40 | 41 | ## Sending a Pull Request ? 42 | 43 | This project encourage you to contribute through sending a pull request! There is a simple rule: please **don't** directly commit your contributions to the **master** branch. According to your commits, please choose the **hotfixes** branch or the **develop** branch. Thank you! 44 | 45 | ## Introduction to the Repository 46 | 47 | There are two main branches with an infinite lifetime: 48 | * **master** is the main branch and it is marked as every version release. 49 | * **develop** is also another main branch where the source code reflects a state with the lastest delivered developement changes for the next release. 50 | 51 | Other branches: 52 | * **features** are used to develop new features for the upcoming or a distant future release. Feature branches are named as 'feature-FEATURENAME'. 53 | * **hotfix** is meant to prepare for a new release, and fixes some bugs from the corresponding tag on the master branch. 54 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | image: 3 | - Visual Studio 2017 4 | build: 5 | project: build\vc2017\nana.sln 6 | verbosity: minimal -------------------------------------------------------------------------------- /build/bakefile/nana.bkl: -------------------------------------------------------------------------------- 1 | srcdir ../../source; 2 | 3 | toolsets = gnu vs2013; 4 | 5 | gnu.makefile = ../build/makefile/makefile; 6 | vs2013.solutionfile = ../build/vc2013/nana.sln; 7 | 8 | library nana { 9 | includedirs = ../include; 10 | 11 | if ($(toolset) == gnu) 12 | cxx-compiler-options = "-std=c++0x `pkg-config --cflags freetype2`"; 13 | 14 | sources { 15 | any.cpp 16 | basic_types.cpp 17 | charset.cpp 18 | datetime.cpp 19 | deploy.cpp 20 | exceptions.cpp 21 | internationalization.cpp 22 | traits.cpp 23 | unicode_bidi.cpp 24 | filesystem/file_iterator.cpp 25 | filesystem/fs_utility.cpp 26 | audio/player.cpp 27 | audio/detail/audio_device.cpp 28 | audio/detail/audio_stream.cpp 29 | audio/detail/buffer_preparation.cpp 30 | detail/platform_spec_selector.cpp 31 | gui/animation.cpp 32 | gui/basis.cpp 33 | gui/dragdrop.cpp 34 | gui/dragger.cpp 35 | gui/drawing.cpp 36 | gui/effects.cpp 37 | gui/element.cpp 38 | gui/filebox.cpp 39 | gui/layout_utility.cpp 40 | gui/msgbox.cpp 41 | gui/notifier.cpp 42 | gui/place.cpp 43 | gui/programming_interface.cpp 44 | gui/screen.cpp 45 | gui/state_cursor.cpp 46 | gui/timer.cpp 47 | gui/tooltip.cpp 48 | gui/wvl.cpp 49 | gui/detail/basic_window.cpp 50 | gui/detail/bedrock_pi.cpp 51 | gui/detail/bedrock_selector.cpp 52 | gui/detail/color_schemes.cpp 53 | gui/detail/drawer.cpp 54 | gui/detail/element_store.cpp 55 | gui/detail/events_operation.cpp 56 | gui/detail/native_window_interface.cpp 57 | gui/detail/window_layout.cpp 58 | gui/detail/window_manager.cpp 59 | gui/widgets/button.cpp 60 | gui/widgets/categorize.cpp 61 | gui/widgets/checkbox.cpp 62 | gui/widgets/combox.cpp 63 | gui/widgets/date_chooser.cpp 64 | gui/widgets/float_listbox.cpp 65 | gui/widgets/form.cpp 66 | gui/widgets/label.cpp 67 | gui/widgets/listbox.cpp 68 | gui/widgets/menubar.cpp 69 | gui/widgets/menu.cpp 70 | gui/widgets/panel.cpp 71 | gui/widgets/picture.cpp 72 | gui/widgets/progress.cpp 73 | gui/widgets/scroll.cpp 74 | gui/widgets/slider.cpp 75 | gui/widgets/spinbox.cpp 76 | gui/widgets/tabbar.cpp 77 | gui/widgets/textbox.cpp 78 | gui/widgets/toolbar.cpp 79 | gui/widgets/treebox.cpp 80 | gui/widgets/widget.cpp 81 | gui/widgets/skeletons/text_editor.cpp 82 | paint/gadget.cpp 83 | paint/graphics.cpp 84 | paint/image.cpp 85 | paint/image_process_selector.cpp 86 | paint/pixel_buffer.cpp 87 | paint/text_renderer.cpp 88 | paint/detail/image_process_provider.cpp 89 | paint/detail/native_paint_interface.cpp 90 | system/dataexch.cpp 91 | system/platform.cpp 92 | system/shared_wrapper.cpp 93 | system/timepiece.cpp 94 | threads/pool.cpp 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /build/bakefile/readme.md: -------------------------------------------------------------------------------- 1 | ## Instructions: 2 | 1. 3 | 2. 4 | 5 | -------------------------------------------------------------------------------- /build/cmake/Modules/FindFontconfig.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find the Fontconfig 2 | # Once done this will define 3 | # 4 | # FONTCONFIG_FOUND - system has Fontconfig 5 | # FONTCONFIG_INCLUDE_DIR - The include directory to use for the fontconfig headers 6 | # FONTCONFIG_LIBRARIES - Link these to use FONTCONFIG 7 | # FONTCONFIG_DEFINITIONS - Compiler switches required for using FONTCONFIG 8 | 9 | # Copyright (c) 2006,2007 Laurent Montel, 10 | # 11 | # Redistribution and use in source and binary forms, with or without 12 | # modification, are permitted provided that the following conditions 13 | # are met: 14 | # 15 | # 1. Redistributions of source code must retain the copyright 16 | # notice, this list of conditions and the following disclaimer. 17 | # 2. Redistributions in binary form must reproduce the copyright 18 | # notice, this list of conditions and the following disclaimer in the 19 | # documentation and/or other materials provided with the distribution. 20 | # 3. The name of the author may not be used to endorse or promote products 21 | # derived from this software without specific prior written permission. 22 | # 23 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | # 34 | 35 | if (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR) 36 | 37 | # in cache already 38 | set(FONTCONFIG_FOUND TRUE) 39 | 40 | else (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR) 41 | 42 | if (NOT WIN32) 43 | # use pkg-config to get the directories and then use these values 44 | # in the FIND_PATH() and FIND_LIBRARY() calls 45 | find_package(PkgConfig) 46 | pkg_check_modules(PC_FONTCONFIG fontconfig) 47 | 48 | set(FONTCONFIG_DEFINITIONS ${PC_FONTCONFIG_CFLAGS_OTHER}) 49 | endif (NOT WIN32) 50 | 51 | find_path(FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h 52 | PATHS 53 | ${PC_FONTCONFIG_INCLUDEDIR} 54 | ${PC_FONTCONFIG_INCLUDE_DIRS} 55 | /usr/X11/include 56 | ) 57 | 58 | find_library(FONTCONFIG_LIBRARIES NAMES fontconfig 59 | PATHS 60 | ${PC_FONTCONFIG_LIBDIR} 61 | ${PC_FONTCONFIG_LIBRARY_DIRS} 62 | ) 63 | 64 | include(FindPackageHandleStandardArgs) 65 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Fontconfig DEFAULT_MSG FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR ) 66 | 67 | mark_as_advanced(FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR) 68 | 69 | endif (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR) 70 | -------------------------------------------------------------------------------- /build/cmake/OS.cmake: -------------------------------------------------------------------------------- 1 | ########### OS 2 | # https://blog.kowalczyk.info/article/j/guide-to-predefined-macros-in-c-compilers-gcc-clang-msvc-etc..html 3 | # http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system 4 | 5 | if(WIN32) 6 | target_compile_definitions(nana PUBLIC WIN32) # todo: why not simple test for _WIN32 in code?? 7 | set(CMAKE_DEBUG_POSTFIX "_d") # ?? 8 | # Global MSVC definitions. You may prefer the hand-tuned sln and projects from the nana repository. 9 | if(MSVC) 10 | option(MSVC_USE_MP "Set to ON to build nana with the /MP option (Visual Studio 2005 and above)." ON) 11 | option(MSVC_USE_STATIC_RUNTIME "Set to ON to build nana with the /MT(d) option." ON) 12 | 13 | # Change the MSVC Compiler flags 14 | if(MSVC_USE_MP) 15 | target_compile_options(nana PUBLIC "/MP" ) 16 | endif() 17 | 18 | if(MSVC_USE_STATIC_RUNTIME) 19 | foreach(flag 20 | CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE 21 | CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO 22 | CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE 23 | CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) 24 | if(${flag} MATCHES "/MD") 25 | string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}") 26 | endif() 27 | endforeach() 28 | endif() 29 | endif() 30 | 31 | if(MINGW) 32 | if(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ) # deprecated ????? 33 | target_compile_definitions(nana PUBLIC STD_THREAD_NOT_SUPPORTED 34 | PUBLIC NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ ) 35 | endif() 36 | endif() 37 | endif() 38 | 39 | if(APPLE) 40 | target_compile_definitions(nana PUBLIC APPLE) # ??? not added by compilers? use __APPLE__ ? 41 | target_include_directories(nana PUBLIC /opt/X11/include/) 42 | target_link_libraries(nana PRIVATE iconv) 43 | set(ENABLE_AUDIO OFF) 44 | endif() 45 | 46 | if(UNIX) 47 | 48 | find_package(X11 REQUIRED) # X11 - todo test PRIVATE 49 | target_link_libraries(nana 50 | PUBLIC ${X11_LIBRARIES} 51 | PUBLIC ${X11_Xft_LIB} 52 | ) 53 | target_include_directories(nana SYSTEM 54 | PUBLIC ${X11_Xft_INCLUDE_PATH} 55 | PUBLIC ${X11_INCLUDE_DIR} 56 | ) 57 | 58 | find_package(Freetype) # Freetype - todo test PRIVATE 59 | if (FREETYPE_FOUND) 60 | find_package(Fontconfig REQUIRED) 61 | target_include_directories(nana SYSTEM 62 | PUBLIC ${FREETYPE_INCLUDE_DIRS} 63 | PUBLIC ${FONTCONFIG_INCLUDE_DIR} 64 | ) 65 | target_link_libraries(nana 66 | PUBLIC ${FREETYPE_LIBRARIES} 67 | PUBLIC ${FONTCONFIG_LIBRARIES} 68 | ) 69 | endif(FREETYPE_FOUND) 70 | endif(UNIX) 71 | -------------------------------------------------------------------------------- /build/cmake/compilers.cmake: -------------------------------------------------------------------------------- 1 | 2 | ########### Compilers 3 | # 4 | # Using gcc: gcc 4.8 don't support C++14 and make_unique. You may want to update at least to 4.9. 5 | # gcc 5.3 and 5.4 include filesytem, but you need to add the link flag: -lstdc++fs 6 | # 7 | # In Windows, with CLion Allways check in File/Settings.../toolchains 8 | # You could install MinGW-w64 from the TDM-GCC Compiler Suite for Windows which will update you to gcc 5.1. 9 | # It is posible to follow https://computingabdn.com/softech/mingw-howto-install-gcc-for-windows/ 10 | # and install MinGW with gcc 7.1 with has STD_THREADS and fs, from: https://sourceforge.net/projects/mingw-w64/files/ 11 | # 12 | # see at end of: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dynamic_or_shared.html 13 | # 14 | 15 | if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW?? 16 | 17 | target_compile_options(nana PRIVATE -Wall) 18 | 19 | # todo: set in target property of nana 20 | set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -mtune=native -DNDEBUG") 21 | 22 | set(THREADS_PREFER_PTHREAD_FLAG ON) # todo - test this 23 | find_package(Threads REQUIRED) 24 | target_link_libraries(nana PRIVATE Threads::Threads) 25 | # target_compile_options(nana PUBLIC -pthread) 26 | 27 | 28 | if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") 29 | if("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD") 30 | target_compile_options(nana PUBLIC -I/usr/local/include) 31 | endif() 32 | endif() 33 | 34 | 35 | # target_link_libraries(nana PRIVATE stdc++fs) # ?? 36 | 37 | 38 | endif() 39 | 40 | 41 | 42 | if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") 43 | target_compile_options(nana PRIVATE -fmax-errors=3) 44 | endif() 45 | -------------------------------------------------------------------------------- /build/cmake/enable_audio.cmake: -------------------------------------------------------------------------------- 1 | option(NANA_CMAKE_ENABLE_AUDIO "Enable class audio::play for PCM playback." OFF) 2 | 3 | # todo: decide - PUBLIC vs PRIVATE 4 | if(NANA_CMAKE_ENABLE_AUDIO) 5 | target_compile_definitions(nana PUBLIC NANA_ENABLE_AUDIO) 6 | if(UNIX) 7 | find_package(ASOUND) # ? https://github.com/hintjens/demidi/blob/master/Findasound.cmake 8 | if(ASOUND_FOUND) 9 | target_include_directories(nana PUBLIC ${ASOUND_INCLUDE_DIRS}) 10 | target_link_libraries(nana PUBLIC ${ASOUND_LIBRARIES}) 11 | else() 12 | message(FATAL_ERROR "libasound is not found") 13 | endif() 14 | endif() 15 | endif() -------------------------------------------------------------------------------- /build/cmake/enable_jpeg.cmake: -------------------------------------------------------------------------------- 1 | option(NANA_CMAKE_ENABLE_JPEG "Enable the use of JPEG" OFF) 2 | option(NANA_CMAKE_LIBJPEG_FROM_OS "Use libjpeg from operating system." ON) 3 | option(JPEG_HAVE_BOOLEAN "Defining HAVE_BOOLEAN before including jpeglib.h" OFF) 4 | 5 | # todo: decide - PUBLIC vs PRIVATE 6 | 7 | if(NANA_CMAKE_ENABLE_JPEG) 8 | target_compile_definitions(nana PUBLIC NANA_ENABLE_JPEG) 9 | if(NANA_CMAKE_LIBJPEG_FROM_OS) 10 | find_package(JPEG) 11 | if(JPEG_FOUND) 12 | target_include_directories(nana PUBLIC ${JPEG_INCLUDE_DIRS}) 13 | target_link_libraries (nana PUBLIC ${JPEG_LIBRARIES}) 14 | target_compile_definitions(nana PUBLIC USE_LIBJPEG_FROM_OS) 15 | endif() 16 | else() 17 | target_compile_definitions(nana PUBLIC -ljpeg) 18 | endif() 19 | if(JPEG_HAVE_BOOLEAN) 20 | # ... Defining HAVE_BOOLEAN before including jpeglib.h should make it work... 21 | target_compile_definitions(nana PUBLIC HAVE_BOOLEAN) 22 | endif() 23 | 24 | endif() -------------------------------------------------------------------------------- /build/cmake/enable_png.cmake: -------------------------------------------------------------------------------- 1 | option(NANA_CMAKE_ENABLE_PNG "Enable the use of PNG" OFF) 2 | option(NANA_CMAKE_LIBPNG_FROM_OS "Use libpng from operating system." ON) 3 | 4 | # todo: decide - PUBLIC vs PRIVATE 5 | 6 | if(NANA_CMAKE_ENABLE_PNG) 7 | target_compile_definitions(nana PUBLIC NANA_ENABLE_PNG) 8 | if(NANA_CMAKE_LIBPNG_FROM_OS) 9 | find_package(PNG) 10 | if(PNG_FOUND) 11 | target_include_directories(nana PUBLIC ${PNG_INCLUDE_DIRS}) 12 | target_link_libraries (nana PUBLIC ${PNG_LIBRARIES}) 13 | target_compile_definitions(nana PUBLIC USE_LIBPNG_FROM_OS ${PNG_DEFINITIONS}) 14 | # target_include_directories (nana SYSTEM PUBLIC PNG::PNG) # ?? 15 | # target_compile_definitions (nana PUBLIC USE_LIBPNG_FROM_OS) 16 | endif() 17 | else() 18 | target_link_libraries(nana PUBLIC png) # provided by nana? 19 | endif() 20 | endif() -------------------------------------------------------------------------------- /build/cmake/install_nana.cmake: -------------------------------------------------------------------------------- 1 | option(NANA_CMAKE_INSTALL "Install nana after compiling the library (to be consumed WITHOUT cmake!!)" OFF) 2 | 3 | # Install the include directories too. 4 | if(NANA_CMAKE_INSTALL) 5 | # This is a method to consume nana with a bulid system not directly supported by nana. 6 | # Is your responsability to ensure all compiler options are compatible with the compilation 7 | # of the project linking to the nana lib here generated 8 | target_sources(nana PRIVATE ${HEADERS}) 9 | message("The compiled Nana library will be installed in ${CMAKE_INSTALL_PREFIX}/lib") 10 | message("WARNING !!! You are using the 'installed' nana! Not recommended! ") 11 | message("If this was not your intention, please tern OFF option NANA_CMAKE_INSTALL ") 12 | message("for example by adding: -DNANA_CMAKE_INSTALL=OFF to your call to cmake. ") 13 | 14 | # Actually in DESTDIR/CMAKE_INSTALL_PREFIX/lib but in windows there is no DESTDIR/ part. 15 | install(TARGETS nana 16 | ARCHIVE DESTINATION lib 17 | LIBRARY DESTINATION lib 18 | RUNTIME DESTINATION bin) 19 | install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include) # in ${CMAKE_INSTALL_PREFIX}/include/nana 20 | message("The Nana include files will be installed in ${CMAKE_INSTALL_PREFIX}/include") 21 | target_include_directories(nana PUBLIC $ 22 | $ ) 23 | else() 24 | # this is the prefered method to consume nana with cmake 25 | message("You are using nana directly from original sources. (Recommended!) " 26 | "If this was not your intention, and what you want is to install precomplied nana first, then " 27 | "please tern ON option NANA_CMAKE_INSTALL ") 28 | target_sources(nana PUBLIC ${HEADERS}) 29 | target_include_directories(nana PUBLIC ${NANA_INCLUDE_DIR}) 30 | endif() 31 | 32 | -------------------------------------------------------------------------------- /build/cmake/shared_libs.cmake: -------------------------------------------------------------------------------- 1 | 2 | option(BUILD_SHARED_LIBS "Compile nana as a shared library." OFF) 3 | option(NANA_STATIC_STDLIB "Link nana statically to C++ standard library" ON) 4 | 5 | if(BUILD_SHARED_LIBS) # todo test 6 | 7 | if(WIN32) 8 | set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) 9 | if(MSVC) 10 | set(DLLTOOL OFF) 11 | else() 12 | # mingw: If dlltool is found the def and lib file will be created 13 | find_program (DLLTOOL dlltool) 14 | if(NOT DLLTOOL) 15 | message(WARNING "dlltool not found. Skipping import library generation.") 16 | endif() 17 | endif() 18 | if(DLLTOOL) 19 | #generate the lib and def files needed by msvc 20 | set_target_properties (nana PROPERTIES 21 | OUTPUT_NAME nana 22 | ARCHIVE_OUTPUT_NAME nana 23 | LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} -Wl,--output-def=${CMAKE_CURRENT_BINARY_DIR}/libnana.def" 24 | ) 25 | 26 | add_custom_command(TARGET nana POST_BUILD 27 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" 28 | COMMAND echo " Generating import library" 29 | COMMAND "${DLLTOOL}" --dllname "libnana.dll" 30 | --input-def "libnana.def" 31 | --output-lib "libnana.lib") 32 | 33 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnana.def" 34 | "${CMAKE_CURRENT_BINARY_DIR}/libnana.lib" DESTINATION lib) 35 | endif() 36 | endif() 37 | endif() 38 | 39 | if(NANA_STATIC_STDLIB) 40 | target_link_libraries(nana 41 | PUBLIC 42 | $<$:-static-libgcc -static-libstdc++> 43 | $<$:-static-libgcc -static-libstdc++> 44 | ) 45 | endif() 46 | 47 | -------------------------------------------------------------------------------- /build/cmake/verbose.cmake: -------------------------------------------------------------------------------- 1 | option(NANA_CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." OFF) 2 | option(NANA_CMAKE_STOP_VERBOSE_PREPROCESSOR "Stop compilation after showing the annoying debug messages." OFF) 3 | 4 | 5 | if (NANA_CMAKE_VERBOSE_PREPROCESSOR) 6 | 7 | target_compile_definitions(nana PRIVATE VERBOSE_PREPROCESSOR) 8 | 9 | ### Just for information: ######################################## 10 | include(CMakePrintHelpers) 11 | # see: https://cmake.org/cmake/help/v3.12/manual/cmake-properties.7.html#properties-on-targets 12 | cmake_print_properties(TARGETS nana PROPERTIES 13 | COMPILE_DEFINITIONS COMPILE_OPTIONS COMPILE_FLAGS LINK_LIBRARIES 14 | INCLUDE_DIRECTORIES INSTALL_NAME_DIR LINK_FLAGS VERSION 15 | ) 16 | 17 | #message ("") 18 | # cmake_print_variables(SOURCES) 19 | cmake_print_variables(HEADERS) 20 | cmake_print_variables(PUBLIC_HEADERS) 21 | cmake_print_variables(NANA_CMAKE_INSTALL) 22 | 23 | cmake_print_variables(Boost_INCLUDE_DIR) 24 | cmake_print_variables(Boost_LIBRARIES) 25 | cmake_print_variables(Boost::filesystem) 26 | 27 | cmake_print_variables(PNG_INCLUDE_DIRS) 28 | cmake_print_variables(PNG_LIBRARIES) 29 | cmake_print_variables(PNG::PNG) 30 | 31 | cmake_print_variables(CMAKE_BUILD_TYPE) 32 | cmake_print_variables(CMAKE_CONFIGURATION_TYPES) 33 | cmake_print_variables(CMAKE_CXX_FLAGS_RELEASE) 34 | 35 | message ( "CMAKE_CXX_COMPILER_ID = " ${CMAKE_CXX_COMPILER_ID}) 36 | message ( "COMPILER_IS_CLANG = " ${COMPILER_IS_CLANG}) 37 | message ( "CMAKE_COMPILER_IS_GNUCXX = " ${CMAKE_COMPILER_IS_GNUCXX}) 38 | message ( "CMAKE_CXX_FLAGS = " ${CMAKE_CXX_FLAGS}) 39 | message ( "CMAKE_EXE_LINKER_FLAGS = " ${CMAKE_EXE_LINKER_FLAGS}) 40 | message ( "CMAKE_STATIC_LINKER_FLAGS = " ${CMAKE_STATIC_LINKER_FLAGS}) 41 | 42 | message ( "DESTDIR = " ${DESTDIR}) 43 | message ( "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX}) 44 | message ( "NANA_INCLUDE_DIR = " ${NANA_INCLUDE_DIR}) 45 | message ( "CMAKE_CURRENT_SOURCE_DIR = " ${CMAKE_CURRENT_SOURCE_DIR}) 46 | message ( "NANA_CMAKE_ENABLE_AUDIO = " ${NANA_CMAKE_ENABLE_AUDIO}) 47 | message ( "NANA_CMAKE_SHARED_LIB = " ${NANA_CMAKE_SHARED_LIB}) 48 | message ( "CMAKE_MAKE_PROGRAM = " ${CMAKE_MAKE_PROGRAM}) 49 | message ( "CMAKE_CXX_COMPILER_VERSION = " ${CMAKE_CXX_COMPILER_VERSION}) 50 | 51 | message ( "NANA_CMAKE_NANA_FILESYSTEM_FORCE = " ${NANA_CMAKE_NANA_FILESYSTEM_FORCE}) 52 | message ( "NANA_CMAKE_FIND_BOOST_FILESYSTEM = " ${NANA_CMAKE_FIND_BOOST_FILESYSTEM}) 53 | message ( "NANA_CMAKE_BOOST_FILESYSTEM_FORCE = " ${NANA_CMAKE_BOOST_FILESYSTEM_FORCE}) 54 | message ( "NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT = " ${NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT}) 55 | message ( "NANA_CMAKE_BOOST_FILESYSTEM_LIB = " ${NANA_CMAKE_BOOST_FILESYSTEM_LIB}) 56 | message ( "NANA_CMAKE_AUTOMATIC_GUI_TESTING = " ${NANA_CMAKE_AUTOMATIC_GUI_TESTING}) 57 | message ( "NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING = " ${NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING}) 58 | 59 | endif(NANA_CMAKE_VERBOSE_PREPROCESSOR) -------------------------------------------------------------------------------- /build/makefile/makefile: -------------------------------------------------------------------------------- 1 | #Nana C++ Library 2 | # 3 | #Makefile created by sarrow104(sarrow104@gmail.com) 4 | 5 | GCC = g++ 6 | INCROOT = ../../include 7 | SRCROOT = ../../source 8 | EXTRLIB = ../../extrlib 9 | NANA_INC= $(INCROOT)/nana 10 | OUTROOT = out 11 | CXXFLAGS= -g -fexceptions -std=c++11 -Wall -Wextra -Wunused-variable -Wfatal-errors 12 | 13 | INCS = -I$(INCROOT) -I/usr/include/freetype2 -I$(EXTRLIB) 14 | 15 | BIN = libnana.a 16 | 17 | TARGET = ../bin/$(BIN) 18 | 19 | .PHONY: all clean install print 20 | 21 | all: $(TARGET) 22 | 23 | define walk 24 | $(wildcard $(1)) $(foreach e, $(wildcard $(1)/*), $(call walk, $(e))) 25 | endef 26 | 27 | SRCFILES := $(filter %.cpp,$(patsubst ./%,%,$(filter-out .,$(call walk, $(SRCROOT))))) 28 | 29 | LINKOBJ = $(patsubst $(SRCROOT)/%.cpp,$(OUTROOT)/objs/%.o,$(SRCFILES)) 30 | 31 | print: 32 | @echo $(LINKOBJ) 33 | 34 | $(TARGET): $(LINKOBJ) 35 | mkdir -p $(dir $@) 36 | ar rus $@ $? 37 | ranlib $@ 38 | 39 | $(OUTROOT)/objs/%.o: $(SRCROOT)/%.cpp 40 | @mkdir -p $(dir $@) 41 | $(GCC) -o $@ -c $< $(INCS) $(CXXFLAGS) 42 | 43 | clean: 44 | rm -f $(LINKOBJ) 45 | rm -f $(TARGET) 46 | 47 | install: 48 | @mkdir -p $(INSTALL_PREFIX)/include 49 | @mkdir -p $(INSTALL_PREFIX)/bin 50 | @mkdir -p $(INSTALL_PREFIX)/lib 51 | cp -rfl $(INCROOT)/* $(INSTALL_PREFIX)/include 52 | cp -rfl $(TARGET) $(INSTALL_PREFIX)/lib/ 53 | -------------------------------------------------------------------------------- /build/makefile/readme.md: -------------------------------------------------------------------------------- 1 | # Building Nana C++ Library directly with make 2 | If you are using make directly, it require: 3 | X11, pthread, Xpm, rt, dl, freetype2, Xft, fontconfig, ALSA 4 | 5 | Example of writing a makefile for creating applications with Nana C++ Library 6 | ------------------- 7 | ``` 8 | GCC = g++ 9 | NANAPATH = [The folder of Nana C++ Library] 10 | BIN = [The bin file what you want to create.] 11 | SOURCES = [The source file of your application.] 12 | 13 | NANAINC = $(NANAPATH)/include 14 | NANALIB = $(NANAPATH)/build/bin 15 | 16 | INCS = -I$(NANAINC) 17 | LIBS = -L$(NANALIB) -lnana -lX11 -lpthread -lrt -lXft -lpng -lasound -lfontconfig 18 | 19 | LINKOBJ = $(SOURCES:.cpp=.o) 20 | 21 | $(BIN): $(LINKOBJ) $(NANALIB)/libnana.a 22 | $(GCC) $(LINKOBJ) $(INCS) $(LIBS) -o $(BIN) -std=c++0x 23 | 24 | .cpp.o: 25 | $(GCC) -g -c $< -o $@ $(INCS) -std=c++0x 26 | 27 | $(NANALIB): 28 | make -f $(NANAPATH)/build/makefile/makefile 29 | 30 | clean: 31 | rm -f $(LINKOBJ) 32 | ``` 33 | ------------------- 34 | -------------------------------------------------------------------------------- /build/vc2013/nana.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2013 for Windows Desktop 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nana", "nana.vcxproj", "{25B21068-491B-4A9F-B99F-6C27BF31BAAD}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Debug|Win32.Build.0 = Debug|Win32 18 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Debug|x64.ActiveCfg = Debug|x64 19 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Debug|x64.Build.0 = Debug|x64 20 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Release|Win32.ActiveCfg = Release|Win32 21 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Release|Win32.Build.0 = Release|Win32 22 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Release|x64.ActiveCfg = Release|x64 23 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /build/vc2015/nana.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nana", "nana.vcxproj", "{25B21068-491B-4A9F-B99F-6C27BF31BAAD}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Debug|x64.ActiveCfg = Debug|x64 17 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Debug|x64.Build.0 = Debug|x64 18 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Debug|x86.ActiveCfg = Debug|Win32 19 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Debug|x86.Build.0 = Debug|Win32 20 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Release|x64.ActiveCfg = Release|x64 21 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Release|x64.Build.0 = Release|x64 22 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Release|x86.ActiveCfg = Release|Win32 23 | {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /build/vc2017/nana.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26228.4 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nana", "nana.vcxproj", "{42D0520F-EFA5-4831-84FE-2B9085301C5D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Debug|x64.ActiveCfg = Debug|x64 17 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Debug|x64.Build.0 = Debug|x64 18 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Debug|x86.ActiveCfg = Debug|Win32 19 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Debug|x86.Build.0 = Debug|Win32 20 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Release|x64.ActiveCfg = Release|x64 21 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Release|x64.Build.0 = Release|x64 22 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Release|x86.ActiveCfg = Release|Win32 23 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /build/vc2019/nana.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26228.4 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nana", "nana.vcxproj", "{42D0520F-EFA5-4831-84FE-2B9085301C5D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Debug|x64.ActiveCfg = Debug|x64 17 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Debug|x64.Build.0 = Debug|x64 18 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Debug|x86.ActiveCfg = Debug|Win32 19 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Debug|x86.Build.0 = Debug|Win32 20 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Release|x64.ActiveCfg = Release|x64 21 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Release|x64.Build.0 = Release|x64 22 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Release|x86.ActiveCfg = Release|Win32 23 | {42D0520F-EFA5-4831-84FE-2B9085301C5D}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /extrlib/readme.txt: -------------------------------------------------------------------------------- 1 | You can download the precompiled external libraries at http://sourceforge.net/projects/nanapro/files/extrlib/ 2 | Extract the ZIP file to the directory nana/extrlib. Then modify the marco switch defined in nana/include/config.hpp header file and rebuild the nana library. 3 | 4 | A method to configure the 3rd party libraries 5 | https://github.com/cnjinhao/nana/wiki/Configuration-of-Third-Party-Libraries-for-Nana 6 | 7 | 8 | 您可以下载预先编译的外部程序库,下载地址http://sourceforge.net/projects/nanapro/files/extrlib/ 9 | 将ZIP文件释放到nana/extrlib目录。然后修改nana/include/config.hpp文件中对应的标志,重新编译Nana库即可。 10 | 11 | 配置第三方库的方法 12 | https://github.com/cnjinhao/nana/wiki/Configuration-of-Third-Party-Libraries-for-Nana -------------------------------------------------------------------------------- /how-to-install.txt: -------------------------------------------------------------------------------- 1 | Please refer to the Library Installation Documentation for the detailed installation instructions. 2 | https://github.com/qPCR4vir/nana-docs/wiki/Installation 3 | NOTE: The method of library installation for VC2003/2005/2008/2010/2012 is only for the version older than 0.8. Since version 0.8, the library only works in VC2013 and later. If you have not VC2013 installed, please choose the latest Codeblocks instead. 4 | 5 | Using Clang 6 | https://github.com/cnjinhao/nana/wiki/Compiling-Nana-with-Clang-8.0 7 | 8 | 请参考库安装文档获取详细的安装步骤。 9 | https://github.com/qPCR4vir/nana-docs/wiki/Installation 10 | 注意: 针对VC2003/2005/2008/2010/2012的安装方法只适用于低于0.8的版本。从0.8版起,该库对Visual C++的最低版本要求是2013。如果您没有安装VC2013,可以使用最新版的CodeBlocks代替。 11 | 12 | 13 | 使用 Clang 14 | https://github.com/cnjinhao/nana/wiki/Compiling-Nana-with-Clang-8.0 -------------------------------------------------------------------------------- /include/nana/audio/detail/audio_device.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_AUDIO_DETAIL_AUDIO_DEVICE_HPP 2 | #define NANA_AUDIO_DETAIL_AUDIO_DEVICE_HPP 3 | 4 | #include 5 | 6 | #ifdef NANA_ENABLE_AUDIO 7 | 8 | #include 9 | #include 10 | #if defined(NANA_WINDOWS) 11 | #include 12 | #elif defined(NANA_LINUX) 13 | #include 14 | #elif defined(NANA_POSIX) 15 | #include 16 | #endif 17 | 18 | namespace nana{ namespace audio 19 | { 20 | namespace detail 21 | { 22 | class audio_device 23 | { 24 | public: 25 | audio_device(); 26 | ~audio_device(); 27 | 28 | bool empty() const; 29 | bool open(std::size_t channels, std::size_t rate, std::size_t bits_per_sample); 30 | void close(); 31 | void prepare(buffer_preparation & buf_prep); 32 | void write(buffer_preparation::meta * m); 33 | void wait_for_drain() const; 34 | private: 35 | #if defined(NANA_WINDOWS) 36 | static void __stdcall _m_dev_callback(HWAVEOUT handle, UINT msg, audio_device * self, DWORD_PTR, DWORD_PTR); 37 | #endif 38 | 39 | #if defined(NANA_WINDOWS) 40 | HWAVEOUT handle_; 41 | std::recursive_mutex queue_lock_; 42 | std::vector done_queue_; 43 | #elif defined(NANA_LINUX) 44 | snd_pcm_t * handle_; 45 | std::size_t rate_; 46 | std::size_t channels_; 47 | std::size_t bytes_per_sample_; 48 | std::size_t bytes_per_frame_; 49 | #elif defined(NANA_POSIX) 50 | int handle_; 51 | int rate_; 52 | int channels_; 53 | int bytes_per_sample_; 54 | int bytes_per_frame_; 55 | #endif 56 | buffer_preparation * buf_prep_; 57 | }; 58 | 59 | }//end namespace detail 60 | }//end namespace audio 61 | }//end namespace nana 62 | 63 | #endif //NANA_ENABLE_AUDIO 64 | #endif 65 | -------------------------------------------------------------------------------- /include/nana/audio/detail/audio_stream.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_AUDIO_DETAIL_AUDIO_STREAM_HPP 2 | #define NANA_AUDIO_DETAIL_AUDIO_STREAM_HPP 3 | 4 | #include 5 | 6 | #ifdef NANA_ENABLE_AUDIO 7 | 8 | #include 9 | 10 | namespace nana{ namespace audio{ 11 | namespace detail 12 | { 13 | namespace wave_spec 14 | { 15 | #if defined(NANA_WINDOWS) 16 | #pragma pack(1) 17 | struct master_riff_chunk 18 | { 19 | unsigned ckID; //"RIFF" 20 | unsigned cksize; 21 | unsigned waveID; //"WAVE" 22 | }; 23 | 24 | struct format_chunck 25 | { 26 | unsigned ckID; //"fmt " 27 | unsigned cksize; 28 | unsigned short wFormatTag; 29 | unsigned short nChannels; 30 | unsigned nSamplePerSec; 31 | unsigned nAvgBytesPerSec; 32 | unsigned short nBlockAlign; 33 | unsigned short wBitsPerSample; 34 | }; 35 | #pragma pack() 36 | #elif defined(NANA_POSIX) 37 | struct master_riff_chunk 38 | { 39 | unsigned ckID; //"RIFF" 40 | unsigned cksize; 41 | unsigned waveID; //"WAVE" 42 | }__attribute__((packed)); 43 | 44 | struct format_chunck 45 | { 46 | unsigned ckID; //"fmt " 47 | unsigned cksize; 48 | unsigned short wFormatTag; 49 | unsigned short nChannels; 50 | unsigned nSamplePerSec; 51 | unsigned nAvgBytesPerSec; 52 | unsigned short nBlockAlign; 53 | unsigned short wBitsPerSample; 54 | }__attribute__((packed)); 55 | #endif 56 | } 57 | 58 | class audio_stream 59 | { 60 | struct chunck 61 | { 62 | unsigned ckID; 63 | unsigned cksize; 64 | }; 65 | public: 66 | bool open(const std::string& file); 67 | void close(); 68 | bool empty() const; 69 | const wave_spec::format_chunck & format() const; 70 | std::size_t data_length() const; 71 | void locate(); 72 | std::size_t read(void * buf, std::size_t len); 73 | private: 74 | std::size_t _m_locate_chunck(unsigned ckID); 75 | private: 76 | std::ifstream fs_; 77 | wave_spec::format_chunck ck_format_; 78 | std::size_t pcm_data_pos_; 79 | std::size_t pcm_data_size_; 80 | std::size_t data_size_; 81 | }; //end class audio_stream 82 | } 83 | }//end namespace audio 84 | }//end namespace nana 85 | #endif //NANA_ENABLE_AUDIO 86 | #endif 87 | -------------------------------------------------------------------------------- /include/nana/audio/detail/buffer_preparation.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_AUDIO_DETAIL_BUFFER_PREPARATION_HPP 2 | #define NANA_AUDIO_DETAIL_BUFFER_PREPARATION_HPP 3 | #include 4 | 5 | #ifdef NANA_ENABLE_AUDIO 6 | 7 | #include 8 | 9 | #if defined(STD_THREAD_NOT_SUPPORTED) 10 | #include 11 | #include 12 | #include 13 | #else 14 | #include 15 | #include 16 | #include 17 | #endif 18 | 19 | #include 20 | #include 21 | 22 | #if defined(NANA_WINDOWS) 23 | #include 24 | #endif 25 | 26 | #include 27 | 28 | namespace nana{ namespace audio 29 | { 30 | namespace detail 31 | { 32 | class buffer_preparation 33 | { 34 | public: 35 | #if defined(NANA_WINDOWS) 36 | typedef WAVEHDR meta; 37 | #elif defined(NANA_POSIX) 38 | struct meta 39 | { 40 | char * buf; 41 | std::size_t bufsize; 42 | }; 43 | #endif 44 | 45 | public: 46 | buffer_preparation(audio_stream& as, std::size_t seconds); 47 | 48 | ~buffer_preparation(); 49 | 50 | meta * read(); 51 | //Revert the meta that returned by read() 52 | void revert(meta * m); 53 | bool data_finished() const; 54 | private: 55 | void _m_prepare_routine(); 56 | private: 57 | std::atomic running_; 58 | std::atomic wait_for_buffer_; 59 | std::thread thr_; 60 | mutable std::mutex token_buffer_, token_prepared_; 61 | mutable std::condition_variable cond_buffer_, cond_prepared_; 62 | 63 | std::vector buffer_, prepared_; 64 | std::size_t block_size_; 65 | audio_stream & as_; 66 | }; 67 | }//end namespace detail 68 | }//end namespace audio 69 | }//end namespace nana 70 | #endif //NANA_ENABLE_AUDIO 71 | #endif 72 | -------------------------------------------------------------------------------- /include/nana/audio/player.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_AUDIO_PLAYER_HPP 2 | #define NANA_AUDIO_PLAYER_HPP 3 | #include 4 | #include 5 | 6 | #ifdef NANA_ENABLE_AUDIO 7 | 8 | #include 9 | 10 | namespace nana{ namespace audio 11 | { /// class player 12 | /// \brief play an audio file in PCM Windows WAV format 13 | /// 14 | /// \include audio_player.cpp 15 | class player 16 | : private nana::noncopyable 17 | { 18 | struct implementation; 19 | public: 20 | player(); 21 | player(const std::string& file); 22 | ~player(); 23 | 24 | bool open(const std::string& file); 25 | void play(); 26 | void close(); 27 | private: 28 | implementation* impl_; 29 | }; 30 | }//end namespace audio 31 | }//end namespace nana 32 | 33 | #endif //NANA_ENABLE_AUDIO 34 | 35 | #include 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/nana/datetime.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A Date Time Implementation 3 | * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/datetime.hpp 10 | */ 11 | 12 | #ifndef NANA_DATETIME_HPP 13 | #define NANA_DATETIME_HPP 14 | #include 15 | 16 | namespace nana 17 | { 18 | /// A date operation class. \see nana::date_chooser 19 | class date 20 | { 21 | public: 22 | struct value 23 | { 24 | unsigned year; ///< 1601 - 30827 25 | unsigned month; ///< 1-12 26 | unsigned day; ///< 1-31 27 | }; 28 | 29 | date(); ///< the initialized date is today. 30 | explicit date(const std::tm&); 31 | date(int year, int month, int day); 32 | 33 | date operator - (int off) const; 34 | date operator + (int off) const; 35 | bool operator==(const date&) const; 36 | bool operator!=(const date&) const; 37 | bool operator<(const date&) const; 38 | bool operator>(const date&) const; 39 | bool operator<=(const date&) const; 40 | bool operator>=(const date&) const; 41 | 42 | int day_of_week() const; 43 | const value & read() const; 44 | void set(const std::tm&); 45 | 46 | static int day_of_week(int year, int month, int day); 47 | static unsigned year_days(const unsigned year); ///< the number of days in the specified year. 48 | static unsigned month_days(const unsigned year, const unsigned month); ///< the number of days in the specified month. 49 | static unsigned day_in_year(unsigned y, unsigned m, unsigned d); ///< Returns the index of the specified day in this year, at range[1, 365] or [1, 366] 50 | private: 51 | date _m_add(unsigned x) const; 52 | date _m_sub(unsigned x) const; 53 | private: 54 | value value_; 55 | }; //end class date 56 | 57 | class time 58 | { 59 | public: 60 | struct value 61 | { 62 | unsigned hour; ///<[0-23] 63 | unsigned minute; ///<[0-59] 64 | unsigned second; ///<[0-61], the range of [60, 61] is used for leap seconds 65 | }; 66 | 67 | time(); 68 | time(const std::tm&); 69 | time(unsigned hour, unsigned minute, unsigned second); 70 | const value& read() const; 71 | void set(const std::tm&); 72 | private: 73 | value value_; 74 | };//end class time 75 | }//end namespace nana 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /include/nana/fwd.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Forward Declarations 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/fwd.hpp 11 | * 12 | */ 13 | 14 | #ifndef NANA_FWD_HPP 15 | #define NANA_FWD_HPP 16 | 17 | namespace nana 18 | { 19 | class filebox; 20 | class msgbox; 21 | }//end namespace nana 22 | #endif //NANA_FWD_HPP 23 | -------------------------------------------------------------------------------- /include/nana/gui.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Nana GUI Header 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file nana/gui.hpp 11 | * @description 12 | * the header file contains the files required for running of Nana.GUI 13 | */ 14 | 15 | #ifndef NANA_GUI_HPP 16 | #define NANA_GUI_HPP 17 | 18 | #include "gui/compact.hpp" 19 | #include "gui/screen.hpp" 20 | #include "gui/widgets/form.hpp" 21 | #include "gui/drawing.hpp" 22 | #include "gui/msgbox.hpp" 23 | #include "gui/place.hpp" 24 | 25 | 26 | namespace nana 27 | { 28 | #ifdef NANA_AUTOMATIC_GUI_TESTING 29 | 30 | /// @brief Take control of the GUI and optionally automatically tests it. 31 | /// 32 | /// @detail It transfers to nana the program flow control, which begin pumping messages 33 | /// from the underlying OS, interpreting and sending it with suitable arguments 34 | /// to the nana widgets that registered a response in the corresponding event. 35 | /// It also accept arguments to be used in case of automatic GUI testing. 36 | /// Other Way the arguments are ignored. 37 | void exec( 38 | unsigned wait = 1, ///< for the GUI to be constructed, in seconds 39 | unsigned wait_end = 1, ///< for the GUI to be destructed, in seconds 40 | std::function = {} ///< emit events to mimics user actions and may assert results 41 | ); 42 | 43 | /// send a click message to this widget - useful in GUI testing 44 | void click(widget& w); 45 | 46 | /// in seconds 47 | void Wait(unsigned wait = 0); 48 | #else 49 | void exec(); 50 | #endif 51 | 52 | 53 | }//end namespace nana 54 | #endif 55 | -------------------------------------------------------------------------------- /include/nana/gui/animation.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * An Animation Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2020 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/animation.hpp 11 | */ 12 | 13 | #ifndef NANA_GUI_ANIMATION_HPP 14 | #define NANA_GUI_ANIMATION_HPP 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | 22 | namespace nana 23 | { 24 | class animation; 25 | /// Holds the frames and frame builders. Have reference semantics for efficiency. 26 | class frameset 27 | { 28 | friend class animation; 29 | public: 30 | /// function which builds frames. 31 | using framebuilder = std::function; 32 | public: 33 | frameset(); 34 | void push_back(paint::image); ///< Inserts frames at the end. 35 | void push_back(framebuilder fb, std::size_t length); ///< Inserts a framebuilder and the number of frames that it generates. 36 | private: 37 | struct impl; 38 | std::shared_ptr impl_; 39 | }; 40 | /// Easy way to display an animation or create an animated GUI 41 | class animation 42 | { 43 | struct branch_t 44 | { 45 | frameset frames; 46 | std::function condition; 47 | }; 48 | 49 | struct impl; 50 | class performance_manager; 51 | 52 | /// Non-copyable 53 | animation(const animation&) = delete; 54 | animation& operator=(const animation&) = delete; 55 | public: 56 | animation(std::size_t fps = 23); 57 | ~animation(); 58 | 59 | animation(animation&&); 60 | animation& operator=(animation&&); 61 | 62 | void push_back(frameset frms); 63 | 64 | void looped(bool enable); ///< Enables or disables the animation repeating playback. 65 | 66 | void play(); 67 | 68 | void pause(); 69 | 70 | /// Renders the animation at a fixed position 71 | void output(window wd, const nana::point& pos); 72 | 73 | /// Renders the animation at a rectangle 74 | /** 75 | * If the size of rectangle is not equal to the size of frame, it stretches the frame for the size of rectangle. 76 | * @param wd Output window. 77 | * @param r Generator of the rectangle. The generator gets called every time rendering occurs. 78 | */ 79 | void output(window wd, std::function r); 80 | 81 | void fps(std::size_t n); 82 | std::size_t fps() const; 83 | private: 84 | std::unique_ptr impl_; 85 | }; 86 | } //end namespace nana 87 | #include 88 | #endif //NANA_GUI_ANIMATION_HPP 89 | -------------------------------------------------------------------------------- /include/nana/gui/compact.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Nana GUI Library Definition 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file nana/gui/compact.hpp 11 | * @description 12 | * the header file contains the files required for running of Nana.GUI 13 | */ 14 | 15 | #ifndef NANA_GUI_WVL_HPP 16 | #define NANA_GUI_WVL_HPP 17 | 18 | #include "programming_interface.hpp" 19 | 20 | namespace nana 21 | { 22 | namespace detail 23 | { 24 | struct form_loader_private 25 | { 26 | template friend class form_loader; 27 | private: 28 | static void insert_form(::nana::widget*); 29 | }; 30 | 31 | template 32 | class form_loader 33 | { 34 | public: 35 | template 36 | Form & operator()(Args &&... args) const 37 | { 38 | auto p = new Form(std::forward(args)...); 39 | 40 | if (p->empty()) 41 | throw std::runtime_error("form_loader failed to create the form"); 42 | 43 | 44 | detail::form_loader_private::insert_form(p); 45 | if (IsVisible) 46 | p->show(); 47 | 48 | return *p; 49 | } 50 | 51 | }; 52 | } 53 | 54 | template 55 | using form_loader = detail::form_loader; 56 | }//end namespace nana 57 | #endif 58 | -------------------------------------------------------------------------------- /include/nana/gui/detail/color_schemes.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Color Schemes 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/color_schemes.hpp 11 | * @description: 12 | */ 13 | #ifndef NANA_DETAIL_COLOR_SCHEMES_HPP 14 | #define NANA_DETAIL_COLOR_SCHEMES_HPP 15 | 16 | #include "widget_geometrics.hpp" 17 | 18 | namespace nana 19 | { 20 | namespace detail 21 | { 22 | class scheme_factory_interface 23 | { 24 | public: 25 | struct factory_identifier{}; 26 | virtual ~scheme_factory_interface() = default; 27 | 28 | virtual factory_identifier* get_id() const = 0; 29 | virtual widget_geometrics* create() = 0; 30 | virtual widget_geometrics* create(widget_geometrics&) = 0; 31 | }; 32 | 33 | 34 | template 35 | class scheme_factory 36 | : public scheme_factory_interface 37 | { 38 | private: 39 | factory_identifier* get_id() const override 40 | { 41 | return &fid_; 42 | } 43 | 44 | widget_geometrics* create() override 45 | { 46 | return (new Scheme); 47 | } 48 | 49 | widget_geometrics* create(widget_geometrics& other) override 50 | { 51 | return (new Scheme(static_cast(other))); 52 | } 53 | private: 54 | static factory_identifier fid_; 55 | }; 56 | 57 | template 58 | scheme_factory_interface::factory_identifier scheme_factory::fid_; 59 | 60 | class color_schemes 61 | { 62 | struct implement; 63 | color_schemes(const color_schemes&) = delete; 64 | color_schemes(color_schemes&&) = delete; 65 | color_schemes& operator=(const color_schemes&) = delete; 66 | color_schemes& operator=(color_schemes&&) = delete; 67 | public: 68 | using scheme = widget_geometrics; 69 | 70 | color_schemes(); 71 | ~color_schemes(); 72 | 73 | scheme& scheme_template(scheme_factory_interface&&); 74 | scheme* create(scheme_factory_interface&&); 75 | private: 76 | implement * impl_; 77 | }; 78 | }//end namespace detail; 79 | }//end namespace nana 80 | #endif -------------------------------------------------------------------------------- /include/nana/gui/detail/element_store.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The Store for the Storage Of Elements 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/detail/element_store.hpp 11 | */ 12 | 13 | #ifndef NANA_GUI_DETAIL_ELEMENT_STORE_HPP 14 | #define NANA_GUI_DETAIL_ELEMENT_STORE_HPP 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | 23 | namespace nana 24 | { 25 | namespace detail 26 | { 27 | class element_store 28 | { 29 | using element_interface = ::nana::element::element_interface; 30 | using cloneable_element = pat::cloneable< ::nana::element::element_interface>; 31 | 32 | struct data; 33 | public: 34 | element_store(); 35 | ~element_store(); 36 | 37 | element_interface * const * bground(const std::string&); 38 | void bground(const std::string&, const pat::cloneable&); 39 | void bground(const std::string&, pat::cloneable&&); 40 | private: 41 | struct implementation; 42 | std::unique_ptr impl_; 43 | }; 44 | }//end namespace detail 45 | } 46 | #include 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /include/nana/gui/detail/event_code.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions of General Events Code 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/detail/event_code.hpp 11 | * 12 | */ 13 | 14 | #ifndef NANA_DETAIL_EVENT_CODE_HPP 15 | #define NANA_DETAIL_EVENT_CODE_HPP 16 | 17 | namespace nana 18 | { 19 | enum class event_code 20 | { 21 | click, ///< A mouse click event. 22 | dbl_click, ///< A mouse double click event. 23 | mouse_enter, ///< A mouse enters a widget. 24 | mouse_move, ///< A mouse moves over a widget. 25 | mouse_leave, ///< A mouse leaves a widget. 26 | mouse_down, ///< A mouse button is pressed on a widget. 27 | mouse_up, ///< A mouse button is released on a widget. 28 | mouse_wheel, ///< A mouse scrolls the wheel on a widget. 29 | mouse_drop, ///< A mouse release over a window that is registered as recipient of drag and drop. 30 | expose, ///< 31 | resizing, ///< A widget's size is sizing. In this event, A widget's size can be overridden with a new size. 32 | resized, ///< A widget's size is changing. 33 | move, ///< 34 | unload, ///< A form is closed by clicking the X button, only works for root widget. 35 | destroy, ///< A widget is about to be destroyed. 36 | focus, ///< A widget's focus is changed. 37 | key_ime, 38 | key_press, ///< A keyboard is pressed on a focus widget. 39 | key_char, ///< The focus widget received a character. 40 | key_release, ///< A keyboard is released on a focus widget. 41 | shortkey, ///< The widgets received a shortkey message. 42 | 43 | elapse, ///< Unoperational events? . A widget received a tick that is sended by timer. 44 | 45 | end ///< End indicator, it's not an event. 46 | }; 47 | }//end namespace nana 48 | 49 | #endif -------------------------------------------------------------------------------- /include/nana/gui/detail/events_holder.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_DETAIL_EVENTS_HOLDER_HPP 2 | #define NANA_DETAIL_EVENTS_HOLDER_HPP 3 | #include 4 | 5 | namespace nana 6 | { 7 | struct general_events; 8 | 9 | namespace detail 10 | { 11 | class events_holder 12 | { 13 | public: 14 | virtual ~events_holder(){} 15 | virtual bool set_events(const std::shared_ptr&) = 0; 16 | virtual general_events* get_events() const = 0; 17 | }; 18 | }//end namespace detail 19 | }//end namespace nana 20 | #endif 21 | -------------------------------------------------------------------------------- /include/nana/gui/detail/events_operation.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_DETAIL_EVENTS_OPERATION_HPP 2 | #define NANA_DETAIL_EVENTS_OPERATION_HPP 3 | 4 | #include 5 | #include 6 | 7 | #if defined(STD_THREAD_NOT_SUPPORTED) 8 | #include 9 | #else 10 | #include 11 | #endif 12 | 13 | namespace nana 14 | { 15 | namespace detail 16 | { 17 | class events_operation 18 | { 19 | public: 20 | void register_evt(event_handle); 21 | void cancel(event_handle); 22 | void erase(event_handle); 23 | private: 24 | std::recursive_mutex mutex_; 25 | std::unordered_set handles_; 26 | }; 27 | }//end namespace detail 28 | }//end namespace nana 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/nana/gui/detail/inner_fwd.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Inner Forward Declaration 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/detail/inner_fwd.hpp 11 | * 12 | */ 13 | 14 | #ifndef NANA_GUI_INNER_FWD_HPP 15 | #define NANA_GUI_INNER_FWD_HPP 16 | 17 | #include 18 | 19 | namespace nana{ 20 | namespace detail 21 | { 22 | } 23 | } 24 | #endif //NANA_GUI_INNER_FWD_HPP 25 | -------------------------------------------------------------------------------- /include/nana/gui/detail/internal_scope_guard.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Forward Declaration of Internal Scope Guard 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/detail/internal_scope_guard.hpp 11 | */ 12 | #ifndef NANA_GUI_DETAIL_INTERNAL_SCOPE_GUARD_HPP 13 | #define NANA_GUI_DETAIL_INTERNAL_SCOPE_GUARD_HPP 14 | 15 | namespace nana 16 | { 17 | //Implemented in bedrock 18 | class internal_scope_guard 19 | { 20 | internal_scope_guard(const internal_scope_guard&) = delete; 21 | internal_scope_guard(internal_scope_guard&&) = delete; 22 | 23 | internal_scope_guard& operator=(const internal_scope_guard&) = delete; 24 | internal_scope_guard& operator=(internal_scope_guard&&) = delete; 25 | public: 26 | internal_scope_guard(); 27 | ~internal_scope_guard(); 28 | }; 29 | 30 | class internal_revert_guard 31 | { 32 | internal_revert_guard(const internal_revert_guard&) = delete; 33 | internal_revert_guard(internal_revert_guard&&) = delete; 34 | 35 | internal_revert_guard& operator=(const internal_revert_guard&) = delete; 36 | internal_revert_guard& operator=(internal_revert_guard&&) = delete; 37 | public: 38 | internal_revert_guard(); 39 | ~internal_revert_guard(); 40 | }; 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /include/nana/gui/detail/widget_content_measurer_interface.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Widget Content Measurer Interface 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/detail/widget_content_measurer_interface.hpp 11 | */ 12 | 13 | #ifndef NANA_WIDGET_CONTENT_MEASURER_INTERFACE_HEADER_INCLUDED 14 | #define NANA_WIDGET_CONTENT_MEASURER_INTERFACE_HEADER_INCLUDED 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | namespace nana 21 | { 22 | namespace dev 23 | { 24 | /// An interface for measuring content of the widget 25 | class widget_content_measurer_interface 26 | { 27 | public: 28 | using graph_reference = paint::graphics&; 29 | virtual ~widget_content_measurer_interface() = default; 30 | 31 | /// Measures content 32 | /** 33 | * @param graph The graphics for the operation. 34 | * @param limit_pixels The number of pixels of the limited edge. If this parameter is zero, it is ignored. 35 | * @param limit_width True if limits the width, false if limits the height. 36 | * @return the size of content. 37 | */ 38 | virtual ::std::optional measure(graph_reference graph, unsigned limit_pixels, bool limit_width) const = 0; 39 | 40 | /// Returns the extension to the size of widget from content extent 41 | /** 42 | * @return the width and height of extension to the widget size. 43 | */ 44 | virtual size extension() const = 0; 45 | }; 46 | } 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /include/nana/gui/detail/widget_geometrics.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Widget Geometrics 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/widget_geometrics.hpp 11 | * @description: 12 | */ 13 | #ifndef NANA_DETAIL_WIDGET_GEOMETRICS_HPP 14 | #define NANA_DETAIL_WIDGET_GEOMETRICS_HPP 15 | 16 | #include 17 | #include 18 | namespace nana 19 | { 20 | /// a tool to share and set a color common to many uses 21 | class color_proxy 22 | { 23 | public: 24 | color_proxy(const color_proxy&); 25 | color_proxy(color_rgb); 26 | color_proxy(color_argb); 27 | color_proxy(color_rgba); 28 | color_proxy(colors); 29 | color_proxy& operator=(const color_proxy&); 30 | color_proxy& operator=(const ::nana::color&); 31 | color_proxy& operator=(color_rgb); 32 | color_proxy& operator=(color_argb); 33 | color_proxy& operator=(color_rgba); 34 | color_proxy& operator=(colors); 35 | color get_color() const; 36 | color get(const color& default_color) const; 37 | operator color() const; 38 | private: 39 | std::shared_ptr color_; 40 | };//end namespace color_proxy 41 | 42 | /// define common color and geometrical properties 43 | struct widget_geometrics 44 | { 45 | virtual ~widget_geometrics() = default; 46 | 47 | color_proxy activated{ static_cast(0x60C8FD) }; 48 | color_proxy background{colors::button_face}; 49 | color_proxy foreground{colors::black}; 50 | }; 51 | } 52 | 53 | #endif -------------------------------------------------------------------------------- /include/nana/gui/detail/widget_notifier_interface.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Widget Notifier Interface 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/detail/widget_notifier_interface.hpp 11 | */ 12 | 13 | #ifndef NANA_GUI_DETAIL_WIDGET_NOTIFIER_INTERFACE_HEADER 14 | #define NANA_GUI_DETAIL_WIDGET_NOTIFIER_INTERFACE_HEADER 15 | #include 16 | #include 17 | 18 | namespace nana 19 | { 20 | class widget; //forward declaration 21 | 22 | namespace detail 23 | { 24 | class widget_notifier_interface 25 | { 26 | public: 27 | virtual ~widget_notifier_interface() = default; 28 | 29 | static std::unique_ptr get_notifier(widget*); //defined in nana/gui/widgets/widget.cpp 30 | 31 | virtual widget* widget_ptr() const = 0; 32 | virtual void destroy() = 0; 33 | virtual ::nana::detail::native_string_type caption() = 0; 34 | virtual void caption(::nana::detail::native_string_type) = 0; 35 | }; 36 | } 37 | } 38 | 39 | #endif -------------------------------------------------------------------------------- /include/nana/gui/detail/window_layout.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Window Layout Implementation 3 | * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/gui/detail/window_layout.hpp 10 | * 11 | */ 12 | 13 | #ifndef NANA_GUI_DETAIL_WINDOW_LAYOUT_HPP 14 | #define NANA_GUI_DETAIL_WINDOW_LAYOUT_HPP 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | namespace nana 21 | { 22 | namespace paint 23 | { 24 | class image; 25 | class graphics; 26 | } 27 | } 28 | 29 | namespace nana{ 30 | namespace detail 31 | { 32 | struct basic_window; 33 | 34 | //class window_layout 35 | class window_layout 36 | { 37 | public: 38 | struct wd_rectangle 39 | { 40 | basic_window * window; 41 | rectangle r; 42 | }; 43 | 44 | enum class paint_operation { 45 | none, 46 | have_refreshed, 47 | try_refresh 48 | }; 49 | public: 50 | static void paint(basic_window*, paint_operation, bool request_refresh_children); 51 | 52 | static bool maproot(basic_window*, bool have_refreshed, bool request_refresh_children); 53 | 54 | static void paste_children_to_graphics(basic_window*, nana::paint::graphics& graph); 55 | 56 | //read_visual_rectangle 57 | //@brief: Reads the visual rectangle of a window, the visual rectangle's reference frame is to root widget, 58 | // the visual rectangle is a rectangular block that a window should be displayed on screen. 59 | // The result is a rectangle that is a visible area for its ancesters. 60 | static bool read_visual_rectangle(basic_window*, nana::rectangle& visual); 61 | 62 | //read_overlaps 63 | // reads the overlaps that are overlapped a rectangular block 64 | static bool read_overlaps(basic_window*, const nana::rectangle& vis_rect, std::vector& blocks); 65 | 66 | static bool enable_effects_bground(basic_window *, bool enabled); 67 | 68 | //make_bground 69 | // update the glass buffer of a glass window. 70 | static void make_bground(basic_window* const); 71 | private: 72 | 73 | /// _m_paste_children 74 | /** 75 | * Pastes children window to the root graphics directly. just paste the visual rectangle 76 | * @param window A handle to the window whose child windows will be pasted to the graph. 77 | * @param has_refreshed Indicates whethere the window has been refreshed. 78 | * @param request_refresh_children A flag indicates whether to refresh its child windows. 79 | * @param parent_rect The child windows which are overlapped with the rectangle will be pasted 80 | * @param graph A graphics object to which the child windows are pasted. 81 | * @param graph_rpos The reference point to the graph. 82 | */ 83 | static void _m_paste_children(basic_window* window, bool has_refreshed, bool request_refresh_children, const nana::rectangle& parent_rect, nana::paint::graphics& graph, const nana::point& graph_rpos); 84 | 85 | static void _m_paint_glass_window(basic_window*, bool is_redraw, bool is_child_refreshed, bool called_by_notify, bool notify_other); 86 | 87 | //Notify the windows which have brground to update their background buffer. 88 | static void _m_notify_glasses(basic_window* const sigwd); 89 | private: 90 | struct data_section 91 | { 92 | std::vector effects_bground_windows; 93 | }; 94 | static data_section data_sect; 95 | };//end class window_layout 96 | }//end namespace detail 97 | }//end namespace nana 98 | 99 | #include 100 | 101 | #endif //NANA_GUI_DETAIL_WINDOW_LAYOUT_HPP 102 | 103 | -------------------------------------------------------------------------------- /include/nana/gui/dragger.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A Dragger Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/dragger.hpp 11 | */ 12 | 13 | #ifndef NANA_GUI_DRAGGER_HPP 14 | #define NANA_GUI_DRAGGER_HPP 15 | #include 16 | #include "basis.hpp" 17 | #include "../basic_types.hpp" 18 | #include "../traits.hpp" 19 | 20 | namespace nana 21 | { 22 | /// \brief Helper class that allows the user to drag windows. 23 | /// 24 | /// If a user presses the mouse on the specified window and moves the mouse, the specified window is dragged. 25 | /// The drag target window and trigger window can be set more than once. 26 | /// See [Is it possible to make event inside event handler?](https://nanapro.codeplex.com/discussions/444121) 27 | /// and [How to make widget movable by mouse the best way](https://nanapro.codeplex.com/discussions/444058) 28 | 29 | class dragger 30 | : nana::noncopyable 31 | { 32 | class dragger_impl_t; 33 | public: 34 | dragger(); 35 | ~dragger(); 36 | 37 | dragger(dragger&&); 38 | dragger& operator=(dragger&&); 39 | 40 | void target(window); 41 | void target(window, const rectangle& restrict_area, nana::arrange); 42 | void remove_target(window); 43 | void trigger(window); 44 | private: 45 | dragger_impl_t * impl_; 46 | }; 47 | }//end namespace nana 48 | #include 49 | #endif 50 | -------------------------------------------------------------------------------- /include/nana/gui/drawing.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A Drawing Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/drawing.hpp 11 | */ 12 | #ifndef NANA_GUI_DRAWING_HPP 13 | #define NANA_GUI_DRAWING_HPP 14 | 15 | #include 16 | #include "widgets/widget.hpp" 17 | #include "../traits.hpp" 18 | namespace nana 19 | { 20 | /// \brief Draw pictures on a widget by specifying a drawing method that will be employed every time the widget refreshes. 21 | /// By the end of drawing, the picture may not be displayed immediately. 22 | /// If a picture need to be displayed immediately call nana::gui::API::refresh_window() . 23 | class drawing 24 | :private nana::noncopyable 25 | { 26 | struct draw_fn_handle; 27 | public: 28 | using diehard_t = draw_fn_handle * ; ///< A handle to a drawing method 29 | using draw_fn_t = std::function; ///< A function to draw 30 | 31 | drawing(window w); ///< Create a drawing object for a widget w 32 | 33 | virtual ~drawing(); ///< Just for polymorphism 34 | 35 | bool empty() const; ///< Returns true if the drawing object is invalid. 36 | void update() const; 37 | 38 | void draw(const draw_fn_t&); ///< Draws things that are defined by draw_fn_t. 39 | void draw(draw_fn_t&&); ///< Draws things that are defined by draw_fn_t. 40 | 41 | /// Draws things that are defined by draw_fn_t but will not be deleted when clear() is called. 42 | diehard_t draw_diehard(const draw_fn_t&); 43 | /// Draws things that are defined by draw_fn_t but will not be deleted when clear() is called. 44 | diehard_t draw_diehard(draw_fn_t&&); 45 | void erase(diehard_t); ///< Erases a diehard drawing method. 46 | 47 | void clear(); ///< Erases all. 48 | private: 49 | window handle_; 50 | };//end class drawing 51 | }//end namespace nana 52 | 53 | #include 54 | #endif 55 | -------------------------------------------------------------------------------- /include/nana/gui/effects.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Background Effects Implementation 3 | * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/gui/effects.hpp 10 | * 11 | */ 12 | #ifndef NANA_GUI_EFFECTS_HPP 13 | #define NANA_GUI_EFFECTS_HPP 14 | #include 15 | #include 16 | 17 | namespace nana 18 | { 19 | namespace effects 20 | { 21 | enum class edge_nimbus 22 | { 23 | none, active = 0x1, over = 0x2 24 | }; 25 | 26 | class bground_interface 27 | { 28 | public: 29 | typedef paint::graphics & graph_reference; 30 | 31 | virtual ~bground_interface() = 0; 32 | virtual void take_effect(window, graph_reference) const = 0; 33 | }; 34 | 35 | class bground_factory_interface 36 | { 37 | friend class effects_accessor; 38 | public: 39 | virtual ~bground_factory_interface() = 0; 40 | private: 41 | virtual bground_interface * create() const = 0; 42 | }; 43 | 44 | class bground_transparent 45 | : public bground_factory_interface 46 | { 47 | public: 48 | explicit bground_transparent(std::size_t percent); 49 | private: 50 | bground_interface* create() const override; 51 | private: 52 | std::size_t percent_; 53 | }; 54 | 55 | class bground_blur 56 | : public bground_factory_interface 57 | { 58 | public: 59 | bground_blur(std::size_t radius); 60 | private: 61 | bground_interface * create() const override; 62 | private: 63 | std::size_t radius_; 64 | }; 65 | } 66 | }//end namespace nana 67 | #endif 68 | -------------------------------------------------------------------------------- /include/nana/gui/layout_utility.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Utility Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/layout_utility.hpp 11 | */ 12 | 13 | #ifndef NANA_GUI_LAYOUT_UTILITY_HPP 14 | #define NANA_GUI_LAYOUT_UTILITY_HPP 15 | 16 | #include "basis.hpp" 17 | 18 | namespace nana 19 | { 20 | //overlap test if overlapped between r1 and r2 21 | bool overlapped(const rectangle& r1, const rectangle& r2); 22 | 23 | // overlap, compute the overlapping area between r1 and r2. the r is for root 24 | bool overlap(const rectangle& r1, const rectangle& r2, rectangle& r); 25 | 26 | bool overlap(const rectangle& ir, const size& valid_input_area, const rectangle & dr, const size& valid_dst_area, rectangle& output_src_r, rectangle& output_dst_r); 27 | 28 | bool intersection(const rectangle & r, point pos_beg, point pos_end, point& good_pos_beg, point& good_pos_end); 29 | 30 | /// Zoom the input_s to fit for ref_s 31 | void fit_zoom(const size& input_s, const size& ref_s, size& result_s); 32 | size fit_zoom(const size& input_s, size ref_s); 33 | 34 | //zoom 35 | //@brief: Calculate the scaled rectangle by refer dst rectangle, that scale factor is same as that between scaled and refer. 36 | void zoom(const rectangle& refer, const rectangle& scaled, const rectangle& refer_dst, rectangle& r); 37 | 38 | //covered 39 | //@brief: Tests a rectangle whether it is wholly covered by another. 40 | bool covered(const rectangle& underlying, // 1st rectangle must be placed under 2nd rectangle 41 | const rectangle& cover); 42 | }//end namespace nana 43 | #endif 44 | -------------------------------------------------------------------------------- /include/nana/gui/notifier.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Definition of Notifier 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/notifier.hpp 11 | */ 12 | 13 | #ifndef NANA_GUI_NOTIFIER_HPP 14 | #define NANA_GUI_NOTIFIER_HPP 15 | #include 16 | #include 17 | #include 18 | 19 | namespace nana 20 | { 21 | class notifier; 22 | 23 | struct arg_notifier 24 | : public event_arg 25 | { 26 | event_code evt_code; 27 | notifier* notifier_ptr; 28 | nana::point pos; 29 | bool left_button; 30 | bool mid_button; 31 | bool right_button; 32 | 33 | operator arg_mouse() const; 34 | }; 35 | 36 | namespace detail 37 | { 38 | struct notifier_events 39 | { 40 | basic_event mouse_move; 41 | basic_event mouse_down; 42 | basic_event mouse_up; 43 | basic_event mouse_leave; 44 | basic_event dbl_click; 45 | }; 46 | } 47 | 48 | class notifier 49 | { 50 | struct implement; 51 | notifier(const notifier&) = delete; 52 | notifier(notifier&&) = delete; 53 | notifier& operator=(const notifier&) = delete; 54 | notifier& operator=(notifier&&) = delete; 55 | public: 56 | notifier(window); 57 | ~notifier(); 58 | void close(); 59 | void text(const ::std::string&); 60 | void icon(const ::std::string& icon_file); 61 | void insert_icon(const ::std::string& icon_file); 62 | void period(std::chrono::milliseconds time); 63 | detail::notifier_events& events(); 64 | window handle() const; 65 | private: 66 | implement * impl_; 67 | }; 68 | }//end namespace nana 69 | #include 70 | #endif 71 | -------------------------------------------------------------------------------- /include/nana/gui/screen.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Screen Informations 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/screen.hpp 11 | */ 12 | 13 | #ifndef NANA_GUI_SCREEN_HPP 14 | #define NANA_GUI_SCREEN_HPP 15 | #include "basis.hpp" 16 | #include 17 | #include 18 | 19 | namespace nana 20 | { 21 | /// The monitor display metrics 22 | class display 23 | { 24 | public: 25 | virtual ~display() = default; 26 | 27 | /// The index of monitor. 28 | virtual std::size_t get_index() const = 0; 29 | 30 | virtual bool is_primary_monitor() const = 0; 31 | 32 | /// Returns the positional coordinates and size of the display device in reference to the desktop area 33 | virtual const ::nana::rectangle& area() const = 0; 34 | virtual const ::nana::rectangle& workarea() const = 0; 35 | }; 36 | 37 | /// Provides some functions to get the metrics of the monitors \include screen.cpp 38 | class screen 39 | { 40 | struct implement; 41 | public: 42 | /// gets the size in pixel of the whole virtual desktop 43 | static ::nana::size desktop_size(); 44 | 45 | /// gets the resolution in pixel of the primary monitor, 46 | /// if there is only one monitor installed in the system, 47 | /// the return value of primary_monitor_size is equal to desktop_size's. 48 | static ::nana::size primary_monitor_size(); 49 | 50 | 51 | screen(); 52 | 53 | /// Reload has no preconditions, it's safe to call on moved-from 54 | void reload(); 55 | 56 | /// Returns the number of display monitors installed in the system 57 | std::size_t count() const; 58 | 59 | /// gets the display monitor that contains the specified point 60 | display& from_point(const point&); 61 | 62 | /// gets the display monitor that contains the specified window 63 | display& from_window(window); 64 | 65 | display& get_display(std::size_t index) const; 66 | display& get_primary() const; 67 | 68 | /// applies a given function to all display monitors 69 | void for_each(std::function) const; 70 | private: 71 | std::shared_ptr impl_; 72 | }; 73 | }//end namespace nana 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /include/nana/gui/state_cursor.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * State Cursor 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/state_cursor.hpp 11 | */ 12 | 13 | #include 14 | namespace nana 15 | { 16 | class state_cursor 17 | { 18 | state_cursor(const state_cursor&) = delete; 19 | state_cursor& operator=(const state_cursor&) = delete; 20 | public: 21 | state_cursor(window, cursor); 22 | state_cursor(state_cursor&&); 23 | state_cursor& operator=(state_cursor&&); 24 | ~state_cursor(); 25 | private: 26 | window handle_; 27 | }; 28 | } -------------------------------------------------------------------------------- /include/nana/gui/timer.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A Timer Implementation 3 | * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/gui/timer.hpp 10 | * @description: 11 | * A timer can repeatedly call a piece of code. The duration between 12 | * calls is specified in milliseconds. Timer is different from other graphics 13 | * controls, it has no graphics interface. 14 | * 15 | * @contributors: rbrugo(#417) 16 | */ 17 | 18 | #ifndef NANA_GUI_TIMER_HPP 19 | #define NANA_GUI_TIMER_HPP 20 | #include 21 | #include 22 | 23 | namespace nana 24 | { 25 | 26 | class timer; 27 | 28 | struct arg_elapse 29 | : public event_arg 30 | { 31 | timer* sender; //indicates which timer emitted this notification 32 | }; 33 | 34 | /// Can repeatedly call a piece of code. 35 | class timer 36 | { 37 | struct implement; 38 | 39 | timer(const timer&) = delete; 40 | timer& operator=(const timer&) = delete; 41 | timer(timer&&) = delete; 42 | timer& operator=(timer&&) = delete; 43 | public: 44 | timer(); 45 | explicit timer(std::chrono::milliseconds ms); 46 | ~timer(); 47 | 48 | template 49 | void elapse(Function && fn) 50 | { 51 | elapse_->connect(std::forward(fn)); 52 | } 53 | 54 | void reset(); 55 | void start(); 56 | bool started() const; 57 | void stop(); 58 | 59 | void interval(std::chrono::milliseconds ms); 60 | 61 | template 62 | inline Duration interval() const 63 | { 64 | return std::chrono::duration_cast(std::chrono::milliseconds{ _m_interval() }); 65 | } 66 | private: 67 | unsigned _m_interval() const; 68 | private: 69 | std::shared_ptr> elapse_; 70 | implement * const impl_; 71 | }; 72 | }//end namespace nana 73 | #include 74 | #endif 75 | -------------------------------------------------------------------------------- /include/nana/gui/tooltip.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A Tooltip Implementation 3 | * Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/gui/widgets/tooltip.hpp 10 | */ 11 | 12 | #ifndef NANA_GUI_WIDGETS_TOOLTIP_HPP 13 | #define NANA_GUI_WIDGETS_TOOLTIP_HPP 14 | #include "widgets/widget.hpp" 15 | 16 | namespace nana 17 | { 18 | ///tooltip_interface 19 | ///An interface for user-defined tooltip window. 20 | class tooltip_interface 21 | { 22 | public: 23 | virtual ~tooltip_interface(){} 24 | 25 | virtual bool tooltip_empty() const = 0; 26 | virtual nana::size tooltip_size() const = 0; 27 | virtual void tooltip_text(const ::std::string&) = 0; 28 | virtual void tooltip_move(const nana::point& screen_pos, bool ignore_pos) = 0; 29 | virtual void duration(std::size_t) = 0; 30 | }; 31 | 32 | class tooltip 33 | { 34 | class factory_interface 35 | { 36 | public: 37 | virtual ~factory_interface(){} 38 | virtual tooltip_interface* create() = 0; 39 | virtual void destroy(tooltip_interface*) = 0; 40 | }; 41 | 42 | template 43 | class factory 44 | : public factory_interface 45 | { 46 | tooltip_interface * create() override 47 | { 48 | return new TooltipWindow; 49 | } 50 | 51 | void destroy(tooltip_interface* p) override 52 | { 53 | delete p; 54 | } 55 | }; 56 | public: 57 | typedef factory_interface factory_if_type; 58 | 59 | template 60 | static void make_factory() 61 | { 62 | _m_hold_factory(new factory); 63 | } 64 | 65 | tooltip() = default; 66 | tooltip(window w, const ::std::string &tip){set(w,tip);} 67 | 68 | 69 | static void set(window, const ::std::string&); 70 | static void show(window, point pos, const ::std::string&, std::size_t duration); 71 | static void close(); 72 | private: 73 | static void _m_hold_factory(factory_interface*); 74 | };//class tooltip 75 | }//namespace nana 76 | #endif 77 | -------------------------------------------------------------------------------- /include/nana/gui/widgets/date_chooser.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * A date chooser Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/widgets/date_chooser.hpp 11 | */ 12 | 13 | #ifndef NANA_GUI_WIDGETS_DATE_CHOOSER_HPP 14 | #define NANA_GUI_WIDGETS_DATE_CHOOSER_HPP 15 | #include 16 | #include "widget.hpp" 17 | #include 18 | 19 | namespace nana 20 | { 21 | class date_chooser; 22 | 23 | struct arg_datechooser 24 | : public event_arg 25 | { 26 | date_chooser * const widget; 27 | 28 | arg_datechooser(date_chooser* wdg) 29 | : widget(wdg) 30 | {} 31 | }; 32 | 33 | namespace drawerbase 34 | { 35 | namespace date_chooser 36 | { 37 | struct date_chooser_events 38 | : public general_events 39 | { 40 | 41 | basic_event date_changed; 42 | }; 43 | 44 | class trigger : public drawer_trigger 45 | { 46 | class model; 47 | public: 48 | static const int topbar_height = 34; 49 | static const int border_size = 3; 50 | 51 | trigger(); 52 | ~trigger(); 53 | model* get_model() const; 54 | private: 55 | void refresh(graph_reference) override; 56 | void mouse_move(graph_reference, const arg_mouse&) override; 57 | void mouse_leave(graph_reference, const arg_mouse&) override; 58 | void mouse_up(graph_reference, const arg_mouse&) override; 59 | void key_press(graph_reference, const arg_keyboard&) override; 60 | private: 61 | model * model_; 62 | }; 63 | 64 | }//end namespace date_chooser 65 | 66 | }//end namespace drawerbase 67 | 68 | /// \see nana::date 69 | class date_chooser 70 | : public widget_object 71 | { 72 | public: 73 | date_chooser(); 74 | date_chooser(window, bool visible); 75 | date_chooser(window, const nana::rectangle& r = rectangle(), bool visible = true); 76 | 77 | bool chose() const; 78 | nana::date read() const; 79 | void weekstr(unsigned index, ::std::string);/// 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /include/nana/gui/widgets/detail/compset.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Concept of Component Set 3 | * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/gui/widgets/detail/compset.hpp 10 | */ 11 | 12 | #ifndef NANA_GUI_WIDGETS_DETAIL_COMPSET_HPP 13 | #define NANA_GUI_WIDGETS_DETAIL_COMPSET_HPP 14 | 15 | #include 16 | 17 | namespace nana{ namespace widgets{ namespace detail 18 | { 19 | /// A component set used for accessing the components of items of a widget. 20 | template 21 | class compset 22 | { 23 | public: 24 | /// A type of widget-defined components. 25 | typedef Component component_t; 26 | 27 | /// A type of widget-defined item attribute. 28 | typedef ItemAttribute item_attribute_t; 29 | 30 | /// A type of a componenet state for rendering. 31 | struct comp_attribute_t 32 | { 33 | nana::rectangle area; 34 | bool mouse_pointed; 35 | }; 36 | 37 | public: 38 | /// The destrcutor 39 | virtual ~compset(){} 40 | 41 | /// Access the widget-defined item attribute. 42 | virtual const item_attribute_t& item_attribute() const = 0; 43 | 44 | /// Access a specified component of the item. 45 | virtual bool comp_attribute(component_t, comp_attribute_t &) const = 0; 46 | }; 47 | 48 | /// A component set placer used for specifying component position and size. 49 | template 50 | class compset_placer 51 | { 52 | public: 53 | typedef ::nana::paint::graphics & graph_reference; 54 | /// A type of widget-defined components. 55 | typedef Component component_t; 56 | 57 | /// A type of widget-defined item attribute. 58 | typedef ItemAttribute item_attribute_t; 59 | 60 | /// Widget scheme. 61 | typedef WidgetScheme widget_scheme_t; 62 | public: 63 | /// The destructor. 64 | virtual ~compset_placer(){} 65 | 66 | /// Enable/Disable the specified component. 67 | virtual void enable(component_t, bool) = 0; 68 | virtual bool enabled(component_t) const = 0; 69 | 70 | /// Height of an item, in pixels. 71 | // this method is content-indepented, this feature is easy for implementation. 72 | virtual unsigned item_height(graph_reference) const = 0; 73 | 74 | /// Width of an item, in pixels 75 | virtual unsigned item_width(graph_reference, const item_attribute_t&) const = 0; 76 | 77 | /// Locate a component through the specified coordinate. 78 | /// @param comp the component of the item. 79 | /// @param attr the attribute of the item. 80 | /// @param r the pointer refers to a rectangle for receiving the position and size of the component. 81 | /// @returns the true when the component is located by the locator. 82 | virtual bool locate(component_t comp, const item_attribute_t& attr, rectangle * r) const = 0; 83 | }; 84 | }//end namespace detail 85 | }//end namespace widgets 86 | }//end namespace nana 87 | #endif 88 | -------------------------------------------------------------------------------- /include/nana/gui/widgets/detail/inline_widget.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * A Inline Widget Interface Definition 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/widgets/detail/inline_widget.hpp 11 | * 12 | */ 13 | 14 | #ifndef NANA_GUI_INLINE_WIDGETS_HPP 15 | #define NANA_GUI_INLINE_WIDGETS_HPP 16 | #include "../../basis.hpp" 17 | 18 | namespace nana 19 | { 20 | namespace detail 21 | { 22 | template 23 | class inline_widget_indicator 24 | { 25 | public: 26 | /// A type to index a item 27 | using index_type = Index; 28 | 29 | /// A type to the value of the item 30 | using value_type = Value; 31 | 32 | /// The destructor 33 | virtual ~inline_widget_indicator() = default; 34 | 35 | /// Returns the host widget of the indicator 36 | virtual ::nana::widget& host() const = 0; 37 | 38 | /// Returns the position of column 39 | virtual std::size_t column() const = 0; 40 | 41 | /// Modifies the value of a item specified by pos 42 | virtual void modify(index_type pos, const value_type&) const = 0; 43 | 44 | /// Sends a signal that a specified item is selected 45 | virtual void selected(index_type) = 0; 46 | 47 | /// Sends a signal that a specified item is hovered 48 | virtual void hovered(index_type) = 0; 49 | }; 50 | 51 | template 52 | class inline_widget_notifier_interface 53 | { 54 | public: 55 | /// A type to index a item 56 | using index_type = Index; 57 | 58 | /// A type to the value of the item 59 | using value_type = Value; 60 | 61 | /// A type to the status 62 | using status_type = Status; 63 | 64 | /// A typedef name of a inline widget indicator 65 | using inline_indicator = inline_widget_indicator; 66 | 67 | /// A type to the notifier interface that will be refered by the abstract factory pattern 68 | using factory_interface = inline_widget_notifier_interface; 69 | 70 | /// The destructor 71 | virtual ~inline_widget_notifier_interface() = default; 72 | 73 | /// A message to create the inline widget 74 | virtual void create(window) = 0; 75 | 76 | /// A message to activate the inline widget to attach a specified item 77 | virtual void activate(inline_indicator&, index_type) = 0; 78 | 79 | /// A message to change the status 80 | virtual void notify_status(status_type, bool) = 0; 81 | 82 | /// A message to resize the inline widget 83 | virtual void resize(const size&) = 0; 84 | 85 | /// A message to set the value from the item 86 | virtual void set(const value_type&) = 0; 87 | 88 | /// Determines whether to draw the background of the widget 89 | virtual bool whether_to_draw() const = 0; 90 | }; //end class inline_widget_notifier_interface 91 | } 92 | } 93 | 94 | #endif -------------------------------------------------------------------------------- /include/nana/gui/widgets/detail/inline_widget_manager.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * A Inline Widget Manager Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/widgets/detail/inline_widget_manager.hpp 11 | * 12 | */ 13 | 14 | #ifndef NANA_GUI_INLINE_WIDGET_MANAGER_HPP 15 | #define NANA_GUI_INLINE_WIDGET_MANAGER_HPP 16 | #include "inline_widget.hpp" 17 | #include 18 | #include "../panel.hpp" 19 | 20 | #include 21 | 22 | namespace nana 23 | { 24 | namespace detail 25 | { 26 | 27 | template 28 | class inline_widget_manager 29 | { 30 | using index_type = Index; 31 | using value_type = Value; 32 | using indicator_type = inline_widget_indicator; 33 | using inline_widget = inline_widget_interface; 34 | using factory = pat::abstract_factory; 35 | 36 | struct widget_holder 37 | { 38 | panel docker; 39 | std::unique_ptr widget_ptr; 40 | }; 41 | public: 42 | void set_window(window wd) 43 | { 44 | window_handle_ = wd; 45 | } 46 | 47 | void set_factory(std::unique_ptr fac) 48 | { 49 | factory_.swap(fac); 50 | } 51 | 52 | void place(point pos, const size& dimension, const size & visible_size, const indicator_type& indicator, index_type index) 53 | { 54 | auto holder = _m_append(); 55 | holder->docker.move({ pos, visible_size }); 56 | holder->widget_ptr->move({ point(), dimension }); 57 | 58 | holder->widget_ptr->activate(indicator, index); 59 | } 60 | private: 61 | widget_holder* _m_append() 62 | { 63 | if (swap_widgets_.empty()) 64 | { 65 | widgets_.emplace_back(); 66 | widgets_.back().swap(swap_widgets_.back()); 67 | swap_widgets_.pop_back(); 68 | } 69 | else 70 | { 71 | 72 | widgets_.emplace_back(new widget_holder); 73 | auto & holder = widgets_.back(); 74 | holder->docker.create(window_handle_, false); 75 | holder->widget_ptr.swap(factory_->create()); 76 | holder->widget_ptr->create(holder->docker->handle()); 77 | } 78 | return widgets_.back().get(); 79 | } 80 | private: 81 | window window_handle_{nullptr}; 82 | std::unique_ptr factory_; 83 | std::vector> widgets_; 84 | std::vector> swap_widgets_; 85 | }; 86 | } 87 | } 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /include/nana/gui/widgets/detail/widget_iterator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A Widget Iterator Template 3 | * Copyright(C) 2017-2018 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/gui/widgets/detail/widget_iterator.hpp 10 | * @description: widget_iterator is the base class provided to simplify definitions of the required types for widget iterators. 11 | * It is provided because of deprecation of std::iterator in C++17 12 | */ 13 | #ifndef NANA_GUI_WIDGET_ITERATOR_INCLUDED 14 | #define NANA_GUI_WIDGET_ITERATOR_INCLUDED 15 | 16 | #include //provides std::ptrdiff_t 17 | 18 | 19 | namespace nana { 20 | namespace widgets { 21 | namespace detail 22 | { 23 | template 24 | class widget_iterator 25 | { 26 | public: 27 | using iterator_category = Category; 28 | using value_type = T; 29 | using difference_type = std::ptrdiff_t; 30 | using pointer = T * ; 31 | using reference = T & ; 32 | }; 33 | } 34 | } 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /include/nana/gui/widgets/form.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * A Form Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file nana/gui/widgets/form.hpp 11 | */ 12 | 13 | #ifndef NANA_GUI_WIDGET_FORM_HPP 14 | #define NANA_GUI_WIDGET_FORM_HPP 15 | 16 | #include "widget.hpp" 17 | #include 18 | 19 | namespace nana 20 | { 21 | class place; 22 | 23 | namespace drawerbase 24 | { 25 | namespace form 26 | { 27 | class trigger: public drawer_trigger 28 | { 29 | public: 30 | void attached(widget_reference, graph_reference) override; 31 | void refresh(graph_reference) override; 32 | private: 33 | widget* wd_{nullptr}; 34 | }; 35 | 36 | class form_base 37 | : public widget_object 38 | { 39 | public: 40 | form_base(window owner, bool nested, const rectangle&, const appearance&); 41 | 42 | //place methods 43 | 44 | place & get_place(); 45 | void div(std::string div_text); 46 | place::field_reference operator[](const char* field_name); 47 | void collocate() noexcept; 48 | private: 49 | std::unique_ptr place_; 50 | }; 51 | }//end namespace form 52 | }//end namespace drawerbase 53 | 54 | /// The form widget represents a popup window. 55 | /// 56 | /// Overall it is a root widget (\see: Overview of widgets) which attaches the OS/Windowing system's native window. 57 | /// It is different from other window widgets in that its default constructor creates the window. 58 | /// \see nana::appearance 59 | class form 60 | : public drawerbase::form::form_base 61 | { 62 | public: 63 | /// helper template class for creating the appearance of the form. 64 | using appear = ::nana::appear; 65 | 66 | /// Creates a window form owned by the desktop, at the point and size specified by rect, and with the specified appearance. 67 | explicit form(const rectangle& = API::make_center(300, 200), const appearance& = {}); //Default constructor 68 | /// Creates a window always floating above its owner at the point and size specified by rect, with the specified appearance. This window is always floating above its owner. 69 | explicit form(window owner, const ::nana::size& = { 300, 200 }, const appearance& = {}); 70 | explicit form(window owner, const rectangle&, const appearance& = {}); 71 | form(const form&, const ::nana::size& = { 300, 200 }, const appearance& = {}); //Copy constructor 72 | 73 | /// Blocks the execution and other windows' messages until this window is closed. 74 | void modality() const; 75 | 76 | /// Blocks the execution until this window is closed. 77 | void wait_for_this(); 78 | 79 | void keyboard_accelerator(const accel_key&, const std::function& fn); 80 | }; 81 | 82 | class nested_form 83 | : public drawerbase::form::form_base 84 | { 85 | public: 86 | using appear = ::nana::appear; 87 | 88 | nested_form(const form&, const rectangle& = {}, const appearance& = {}); 89 | nested_form(const nested_form&, const rectangle& = {}, const appearance& = {}); 90 | 91 | nested_form(window, const appearance&); 92 | nested_form(window, const rectangle& = {}, const appearance& = {}); 93 | }; 94 | }//end namespace nana 95 | #endif 96 | -------------------------------------------------------------------------------- /include/nana/gui/widgets/label.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * A Label Control Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/widgets/label.hpp 11 | */ 12 | 13 | #ifndef NANA_GUI_WIDGET_LABEL_HPP 14 | #define NANA_GUI_WIDGET_LABEL_HPP 15 | 16 | #include "widget.hpp" 17 | #include 18 | 19 | namespace nana 20 | { 21 | namespace drawerbase 22 | { 23 | namespace label 24 | { 25 | enum class command /// Defines the event type for format listener. 26 | { 27 | enter, leave, click 28 | }; 29 | 30 | /// draw the label 31 | class trigger: public drawer_trigger 32 | { 33 | public: 34 | struct implement; 35 | 36 | trigger(); 37 | ~trigger(); 38 | implement * impl() const; 39 | private: 40 | void attached(widget_reference, graph_reference) override; 41 | void refresh(graph_reference) override; 42 | void mouse_move(graph_reference, const arg_mouse&) override; 43 | void mouse_leave(graph_reference, const arg_mouse&) override; 44 | void click(graph_reference, const arg_click&) override; 45 | private: 46 | implement * impl_; 47 | }; 48 | 49 | }//end namespace label 50 | }//end namespace drawerbase 51 | 52 | class label 53 | : public widget_object 54 | { 55 | label(const label&) = delete; 56 | label(label&&) = delete; 57 | public: 58 | typedef drawerbase::label::command command; 59 | label(); 60 | label(window, bool visible); 61 | label(window, const std::string& text, bool visible = true); 62 | label(window parent, const char* text, bool visible = true) :label(parent, std::string(text),visible) {}; 63 | label(window, const rectangle& = {}, bool visible = true); 64 | label& transparent(bool); ///< Switchs the label widget to the transparent background mode. 65 | bool transparent() const noexcept; 66 | label& format(bool); ///< Switches the format mode of the widget. 67 | label& add_format_listener(std::function); 68 | 69 | /// as same as the HTML "for" attribute of a label 70 | label& click_for(window associated_window) noexcept; 71 | 72 | /// Returns the size of the text. If *allowed_width_in_pixel* is not zero, returns a 73 | /// "corrected" size that changes lines to fit the text into the specified width 74 | nana::size measure(unsigned allowed_width_in_pixel) const; 75 | 76 | static ::nana::size measure(::nana::paint::graphics&, const ::std::string&, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align); 77 | 78 | label& text_align(align horizontal_align, align_v vertical_align= align_v::top); 79 | private: 80 | //Overrides widget's virtual function 81 | void _m_caption(native_string_type&&) override; 82 | }; 83 | }//end namespace nana 84 | #include 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /include/nana/gui/widgets/menubar.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A Menubar implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2009-2018 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/widgets/menubar.hpp 11 | */ 12 | 13 | #ifndef NANA_GUI_WIDGETS_MENUBAR_HPP 14 | #define NANA_GUI_WIDGETS_MENUBAR_HPP 15 | #include "widget.hpp" 16 | #include "menu.hpp" 17 | #include 18 | 19 | namespace nana 20 | { 21 | namespace drawerbase 22 | { 23 | namespace menubar 24 | { 25 | using native_string_type = ::nana::detail::native_string_type; 26 | 27 | struct scheme 28 | : public widget_geometrics 29 | { 30 | color_proxy text_fgcolor{ colors::black }; 31 | color_proxy body_highlight{ static_cast(0xc0ddfc) }; 32 | color_proxy body_selected{ colors::white }; 33 | color_proxy border_selected{ colors::dark_border }; 34 | color_proxy border_highlight{ colors::highlight }; 35 | }; 36 | 37 | class trigger 38 | : public drawer_trigger 39 | { 40 | struct essence; 41 | public: 42 | trigger(); 43 | ~trigger(); 44 | essence& ess() const; 45 | private: 46 | void attached(widget_reference, graph_reference) override; 47 | void refresh(graph_reference) override; 48 | void mouse_move(graph_reference, const arg_mouse&) override; 49 | void mouse_leave(graph_reference, const arg_mouse&) override; 50 | void mouse_down(graph_reference, const arg_mouse&) override; 51 | void mouse_up(graph_reference, const arg_mouse&) override; 52 | void focus(graph_reference, const arg_focus&) override; 53 | void key_press(graph_reference, const arg_keyboard&) override; 54 | void key_release(graph_reference, const arg_keyboard&) override; 55 | void shortkey(graph_reference, const arg_keyboard&) override; 56 | private: 57 | void _m_move(graph_reference, bool to_left); 58 | private: 59 | essence * const ess_; 60 | }; 61 | }//end namespace menubar 62 | }//end namespace drawerbase 63 | 64 | /// \brief A toolbar at the top of window for pop-upping menus. 65 | /// 66 | /// The widget sets as shortkey the character behind the first of & in the text, for the item. e.g. "File(&F)" or "&File". 67 | class menubar 68 | : public widget_object 69 | { 70 | public: 71 | menubar() = default; ///< The default constructor delay creation. 72 | menubar(window); ///< Create a menubar at the top of the specified window. 73 | ~menubar(); 74 | void create(window); ///< Create a menubar at the top of the specified window. 75 | menu& push_back(const std::string&); ///< Appends a new (empty) menu. 76 | menu& at(size_t index) const; ///< Gets the menu specified by index. 77 | std::size_t length() const; ///< Number of menus. 78 | void clear(); ///< Removes all the menus. 79 | 80 | /// Deselects the menu 81 | /** 82 | * If a menu is popped up, the menu deselects the item and close the pop-upped menu. 83 | * @return true if an item is deselected, false otherwise. 84 | */ 85 | bool cancel(); 86 | 87 | /// Determines the mouse is hovered on the menubar or its popped menu. 88 | bool hovered() const; 89 | private: 90 | ::nana::event_handle evt_resized_{nullptr}; 91 | };//end class menubar 92 | }//end namespace nana 93 | #include 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /include/nana/gui/widgets/panel.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * A Panel Implementation 3 | * Nana C++ Library(http://www.nanaro.org) 4 | * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/widgets/panel.hpp 11 | * @author: Jinhao 12 | * @contributors: Ariel Vina-Rodriguez 13 | * 14 | * @brief panel is a widget used for placing some widgets. 15 | */ 16 | 17 | #ifndef NANA_GUI_WIDGETS_PANEL_HPP 18 | #define NANA_GUI_WIDGETS_PANEL_HPP 19 | #include "widget.hpp" 20 | #include 21 | 22 | namespace nana 23 | { 24 | namespace drawerbase 25 | { 26 | namespace panel 27 | { 28 | class drawer: public drawer_trigger 29 | { 30 | void attached(widget_reference, graph_reference) override; 31 | void refresh(graph_reference) override; 32 | private: 33 | window window_{nullptr}; 34 | }; 35 | }// end namespace panel 36 | }//end namespace drawerbase 37 | /// For placing other widgets, where the bool template parameter determines if it is widget or lite_widget, which in actual use makes no difference. 38 | template 39 | class panel 40 | : public widget_object::type, 41 | drawerbase::panel::drawer> 42 | { 43 | public: 44 | panel(){} 45 | 46 | panel(window wd, bool visible) 47 | { 48 | this->create(wd, rectangle(), visible); 49 | this->bgcolor(API::bgcolor(wd)); 50 | } 51 | 52 | panel(window wd, const nana::rectangle& r = rectangle(), bool visible = true) 53 | { 54 | this->create(wd, r, visible); 55 | this->bgcolor(API::bgcolor(wd)); 56 | } 57 | 58 | bool transparent() const 59 | { 60 | return API::is_transparent_background(*this); 61 | } 62 | 63 | void transparent(bool tr) 64 | { 65 | if(tr) 66 | API::effects_bground(*this, effects::bground_transparent(0), 0); 67 | else 68 | API::effects_bground_remove(*this); 69 | } 70 | }; 71 | }//end namespace nana 72 | #endif 73 | -------------------------------------------------------------------------------- /include/nana/gui/widgets/picture.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * A Picture Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/widgets/picture.hpp 11 | * 12 | * @brief Used for showing a picture 13 | */ 14 | #ifndef NANA_GUI_WIDGET_PICTURE_HPP 15 | #define NANA_GUI_WIDGET_PICTURE_HPP 16 | #include 17 | 18 | #include "widget.hpp" 19 | 20 | namespace nana 21 | { 22 | class picture; 23 | 24 | namespace drawerbase 25 | { 26 | namespace picture 27 | { 28 | struct implement; 29 | 30 | class drawer : public drawer_trigger 31 | { 32 | friend class ::nana::picture; 33 | public: 34 | drawer(); 35 | ~drawer(); 36 | void attached(widget_reference, graph_reference) override; 37 | private: 38 | void refresh(graph_reference) override; 39 | private: 40 | implement * const impl_; 41 | }; 42 | }//end namespace picture 43 | }//end namespace drawerbase 44 | 45 | /// Rectangle area for displaying a bitmap file 46 | class picture 47 | : public widget_object 48 | { 49 | public: 50 | picture() = default; 51 | picture(window, bool visible); 52 | picture(window, const rectangle& ={}, bool visible = true); 53 | 54 | void load(::nana::paint::image, const rectangle& valid_area = {}); 55 | 56 | /// Sets the align of image. 57 | void align(align, align_v); 58 | 59 | /// Enables the image to be stretched to the widget size. 60 | void stretchable(unsigned left, unsigned top, unsigned right, unsigned bottom); 61 | 62 | /// Enables/disables the image to be stretched without changing aspect ratio. 63 | void stretchable(bool); 64 | 65 | /// Fills a gradual-change color in background. If one of colors is invisible or clr_from is equal to clr_to, it draws background in bgcolor. 66 | void set_gradual_background(const color& clr_from, const color& clr_to, bool horizontal); 67 | void transparent(bool); 68 | bool transparent() const; 69 | }; 70 | }//end namespace nana 71 | #include 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /include/nana/gui/widgets/progress.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * A Progress Indicator Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/widgets/progress.hpp 11 | */ 12 | 13 | #ifndef NANA_GUI_WIDGET_PROGRESS_HPP 14 | #define NANA_GUI_WIDGET_PROGRESS_HPP 15 | #include "widget.hpp" 16 | 17 | namespace nana 18 | { 19 | namespace drawerbase 20 | { 21 | namespace progress 22 | { 23 | struct scheme 24 | : public widget_geometrics 25 | { 26 | scheme(); 27 | 28 | color_proxy gradient_bgcolor{ colors::button_face_shadow_start }; 29 | color_proxy gradient_fgcolor{ static_cast(0x6FFFA8) }; 30 | }; 31 | 32 | class substance; 33 | 34 | class trigger 35 | : public drawer_trigger 36 | { 37 | public: 38 | trigger(); 39 | ~trigger(); 40 | 41 | substance* progress() const; 42 | private: 43 | void attached(widget_reference, graph_reference) override; 44 | void refresh(graph_reference) override; 45 | private: 46 | substance* const progress_; 47 | }; 48 | } 49 | }//end namespace drawerbase 50 | /// \brief A progressbar widget with two styles: know, and unknown amount value (goal). 51 | /// In unknown style the amount is ignored and the bar is scrolled when value change. 52 | class progress 53 | : public widget_object 54 | { 55 | public: 56 | progress(); 57 | progress(window, bool visible); 58 | progress(window, const rectangle & = rectangle(), bool visible = true); 59 | 60 | unsigned value() const; 61 | unsigned value(unsigned val); 62 | unsigned inc(); 63 | unsigned amount() const; 64 | unsigned amount(unsigned value); 65 | void unknown(bool); 66 | bool unknown() const; 67 | }; 68 | }//end namespace nana 69 | #endif 70 | -------------------------------------------------------------------------------- /include/nana/gui/widgets/skeletons/text_editor_part.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef NANA_WIDGETS_SKELETONS_TEXT_EDITOR_SCHEME_HPP 3 | #define NANA_WIDGETS_SKELETONS_TEXT_EDITOR_SCHEME_HPP 4 | 5 | #include "../../detail/widget_geometrics.hpp" 6 | #include 7 | 8 | namespace nana 9 | { 10 | namespace widgets 11 | { 12 | namespace skeletons 13 | { 14 | enum class text_focus_behavior 15 | { 16 | none, 17 | select, 18 | select_if_tabstop, 19 | select_if_click, 20 | select_if_tabstop_or_click 21 | }; 22 | 23 | //forward declaration 24 | class text_editor; 25 | 26 | struct text_editor_scheme 27 | : public ::nana::widget_geometrics 28 | { 29 | color_proxy selection{ static_cast(0x3399FF) }; 30 | color_proxy selection_unfocused{ static_cast(0xF0F0F0) }; 31 | color_proxy selection_text{colors::white}; 32 | 33 | parameters::mouse_wheel mouse_wheel; ///< The number of lines/characters to scroll when the vertical/horizontal mouse wheel is moved. 34 | }; 35 | 36 | class text_editor_event_interface 37 | { 38 | public: 39 | virtual ~text_editor_event_interface() = default; 40 | 41 | virtual void text_exposed(const std::vector&) = 0; 42 | }; 43 | 44 | struct colored_area_type 45 | { 46 | const ::std::size_t begin; ///< The begin line position 47 | ::std::size_t count; ///< The number of lines 48 | 49 | ::nana::color bgcolor; 50 | ::nana::color fgcolor; 51 | }; 52 | 53 | class colored_area_access_interface 54 | { 55 | public: 56 | using colored_area_type = skeletons::colored_area_type; 57 | 58 | virtual ~colored_area_access_interface(); 59 | 60 | virtual std::shared_ptr get(std::size_t line_pos) = 0; 61 | virtual bool clear() = 0; 62 | virtual bool remove(std::size_t line_pos) = 0; 63 | virtual std::size_t size() const = 0; 64 | virtual std::shared_ptr at(std::size_t index) = 0; 65 | }; 66 | } 67 | } 68 | } 69 | #endif -------------------------------------------------------------------------------- /include/nana/gui/widgets/skeletons/textbase_export_interface.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions of textbase export interfaces 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/widgets/skeletons/textbase_export_interface.hpp 11 | * @description: It is defined outside, some headers like textbox should not include a whole textbase for its ext_evtbase 12 | * 13 | */ 14 | 15 | #ifndef NANA_GUI_WIDGET_TEXTBASE_EXPORT_INTERFACE_HPP 16 | #define NANA_GUI_WIDGET_TEXTBASE_EXPORT_INTERFACE_HPP 17 | 18 | namespace nana{ namespace widgets 19 | { 20 | namespace skeletons 21 | { 22 | class textbase_event_agent_interface 23 | { 24 | public: 25 | virtual ~textbase_event_agent_interface() = default; 26 | 27 | virtual void first_change() = 0; ///< An event for the text first change after text has been opened or stored. 28 | virtual void text_changed() = 0; ///< An event for the change of text. 29 | }; 30 | }//end namespace skeletons 31 | }//end namespace widgets 32 | }//end namespace nana 33 | #endif //NANA_GUI_WIDGET_TEXTBASE_EXPORT_INTERFACE_HPP 34 | -------------------------------------------------------------------------------- /include/nana/key_type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A Key Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/key_type.hpp 11 | */ 12 | #ifndef NANA_KEY_TYPE_HPP 13 | #define NANA_KEY_TYPE_HPP 14 | 15 | namespace nana 16 | { 17 | namespace detail 18 | { 19 | class key_interface 20 | { 21 | public: 22 | virtual ~key_interface(){} 23 | 24 | virtual bool same_type(const key_interface*) const noexcept = 0; 25 | virtual bool compare(const key_interface*) const noexcept = 0; ///< is this key less than right key? [call it less(rk), less_than(rk) or compare_less(rk)?: if (lk.less_than(rk )) ] 26 | }; //end class key_interface 27 | 28 | //Use less compare for equal compare [call it equal_by_less()?] 29 | inline bool pred_equal(const key_interface * left, const key_interface* right) noexcept 30 | { 31 | return (left->same_type(right) && (left->compare(right) == false) && (right->compare(left) == false)); 32 | } 33 | 34 | template 35 | struct type_escape 36 | { 37 | using type = T; 38 | }; 39 | 40 | template<> 41 | struct type_escape 42 | { 43 | using type = ::std::string; 44 | }; 45 | 46 | template<> 47 | struct type_escape 48 | { 49 | using type = ::std::string; 50 | }; 51 | 52 | template 53 | struct type_escape 54 | { 55 | using type = ::std::string; 56 | }; 57 | 58 | template 59 | struct type_escape 60 | { 61 | using type = ::std::string; 62 | }; 63 | 64 | template<> 65 | struct type_escape 66 | { 67 | using type = ::std::wstring; 68 | }; 69 | 70 | template<> 71 | struct type_escape 72 | { 73 | using type = ::std::wstring; 74 | }; 75 | 76 | template 77 | struct type_escape 78 | { 79 | using type = ::std::wstring; 80 | }; 81 | 82 | template 83 | struct type_escape 84 | { 85 | using type = ::std::wstring; 86 | }; 87 | } 88 | 89 | template 90 | class key 91 | : public detail::key_interface 92 | { 93 | public: 94 | typedef detail::key_interface key_interface; 95 | typedef T key_type; 96 | 97 | key(const key_type& k) 98 | : key_object_(k) 99 | {} 100 | 101 | key(key_type&& k) 102 | : key_object_(std::move(k)) 103 | { 104 | } 105 | public: 106 | //implement key_interface methods 107 | bool same_type(const key_interface * p) const noexcept override 108 | { 109 | return (nullptr != dynamic_cast(p)); 110 | } 111 | 112 | bool compare(const key_interface* p) const noexcept override 113 | { 114 | auto rhs = dynamic_cast(p); 115 | return rhs && compare_(key_object_, rhs->key_object_); 116 | } 117 | private: 118 | Compare compare_; 119 | key_type key_object_; 120 | }; 121 | } 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /include/nana/paint/detail/image_impl_interface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_PAINT_DETAIL_IMAGE_IMPL_INTERFACE_HPP 2 | #define NANA_PAINT_DETAIL_IMAGE_IMPL_INTERFACE_HPP 3 | 4 | #include "../image.hpp" 5 | #include 6 | 7 | namespace nana{ namespace paint{ 8 | 9 | // class image::image_impl_interface 10 | // the nana::image refers to an object of image::image_impl_interface by nana::refer. Employing nana::refer to refer the image::implement_t object indirectly is used 11 | // for saving the memory that sharing the same image resource with many nana::image objects. 12 | class image::image_impl_interface 13 | : private nana::noncopyable 14 | { 15 | image_impl_interface& operator=(const image_impl_interface& rhs); 16 | public: 17 | using graph_reference = nana::paint::graphics&; 18 | virtual ~image_impl_interface() = 0; //The destructor is defined in ../image.cpp 19 | virtual bool open(const std::filesystem::path& file) = 0; 20 | virtual bool open(const void* data, std::size_t bytes) = 0; // reads image from memory 21 | virtual bool alpha_channel() const = 0; 22 | virtual bool empty() const = 0; 23 | virtual void close() = 0; 24 | virtual nana::size size() const = 0; 25 | virtual void paste(const nana::rectangle& src_r, graph_reference dst, const point& p_dst) const = 0; 26 | virtual void stretch(const nana::rectangle& src_r, graph_reference dst, const nana::rectangle& r) const = 0; 27 | };//end class image::image_impl_interface 28 | }//end namespace paint 29 | }//end namespace nana 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /include/nana/paint/detail/native_paint_interface.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Platform Implementation 3 | * Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/paint/detail/native_paint_interface.hpp 10 | */ 11 | 12 | #ifndef NANA_PAINT_DETAIL_PLATFORM_HPP 13 | #define NANA_PAINT_DETAIL_PLATFORM_HPP 14 | #include 15 | 16 | namespace nana 17 | { 18 | namespace paint 19 | { 20 | namespace detail 21 | { 22 | nana::size drawable_size(drawable_type); 23 | 24 | std::unique_ptr alloc_fade_table(double fade_rate); 25 | void free_fade_table(const unsigned char*); 26 | 27 | //color = bgcolor * fade_rate + fgcolor * (1 - fade_rate); 28 | nana::pixel_color_t fade_color(nana::pixel_color_t bgcolor, nana::pixel_color_t fgcolor, const unsigned char* const fade_table); 29 | nana::pixel_color_t fade_color_intermedia(pixel_color_t fgcolor, const unsigned char* fade_table); 30 | nana::pixel_color_t fade_color_by_intermedia(pixel_color_t bgcolor, nana::pixel_color_t fgcolor_intermedia, const unsigned char* const fade_table); 31 | 32 | //dw color = dw color * fade_rate + bdcolor * (1 - fade_rate) 33 | void blend(drawable_type dw, const nana::rectangle& r, pixel_color_t bdcolor, double fade_rate); 34 | 35 | nana::size real_text_extent_size(drawable_type, const char*, std::size_t len); 36 | nana::size real_text_extent_size(drawable_type, const wchar_t*, std::size_t len); 37 | nana::size text_extent_size(drawable_type, const char*, std::size_t len); 38 | nana::size text_extent_size(drawable_type, const wchar_t*, std::size_t len); 39 | 40 | void draw_string(drawable_type, const nana::point&, const wchar_t *, std::size_t len); 41 | }//end namespace detail 42 | }//end namespace paint 43 | }//end namespace nana 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/nana/paint/detail/ptdefs.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_PAINT_PTDEFS_INCLUDED 2 | #define NANA_PAINT_PTDEFS_INCLUDED 3 | 4 | namespace nana 5 | { 6 | namespace detail 7 | { 8 | struct native_font_signature; 9 | 10 | 11 | struct font_style 12 | { 13 | unsigned weight{ 400 }; //normal 14 | bool italic{ false }; 15 | bool underline{ false }; 16 | bool strike_out{ false }; 17 | 18 | font_style() = default; 19 | font_style(unsigned weight, bool italic = false, bool underline = false, bool strike_out = false); 20 | }; 21 | }//end namespace detail 22 | 23 | namespace paint 24 | { 25 | using native_font_type = ::nana::detail::native_font_signature*; 26 | } 27 | } 28 | 29 | #endif -------------------------------------------------------------------------------- /include/nana/paint/image.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Paint Image Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/paint/image.hpp 11 | * @description: class image is used for load an image file into memory. 12 | */ 13 | 14 | #ifndef NANA_PAINT_IMAGE_HPP 15 | #define NANA_PAINT_IMAGE_HPP 16 | 17 | #include "graphics.hpp" 18 | 19 | namespace nana 20 | { 21 | namespace paint 22 | { 23 | /// load a picture file 24 | class image 25 | { 26 | friend class image_accessor; 27 | typedef bool (image::* unspecified_bool_t)() const; 28 | public: 29 | class image_impl_interface; 30 | 31 | image() noexcept; 32 | image(const image&); 33 | image(image&&); 34 | explicit image(const ::std::string& file); 35 | explicit image(const ::std::wstring& file); 36 | 37 | ~image(); 38 | image& operator=(const image& rhs); 39 | image& operator=(image&&); 40 | bool open(const ::std::string& file); 41 | bool open(const ::std::wstring& file); 42 | 43 | /// Opens an icon from a specified buffer 44 | bool open(const void* data, std::size_t bytes); 45 | bool empty() const noexcept; 46 | operator unspecified_bool_t() const; 47 | void close() noexcept; 48 | 49 | bool alpha() const noexcept; 50 | nana::size size() const noexcept; 51 | void paste(graphics& dst, const point& p_dst) const; 52 | void paste(const nana::rectangle& r_src, graphics& dst, const point& p_dst) const;///< Paste the area of picture specified by r_src into the destination graphics specified by dst at position p_dst. 53 | void stretch(const nana::rectangle& r_src, graphics& dst, const nana::rectangle& r_dst) const;/// image_ptr_; 56 | };//end class image 57 | 58 | }//end namespace paint 59 | }//end namespace nana 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /include/nana/paint/image_process_selector.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_PAINT_IMAGE_PROCESS_SELECTOR_HPP 2 | #define NANA_PAINT_IMAGE_PROCESS_SELECTOR_HPP 3 | #include "detail/image_process_provider.hpp" 4 | 5 | namespace nana 6 | { 7 | namespace paint 8 | { 9 | namespace image_process 10 | { /// Configure the image processing algorithms. 11 | class selector 12 | { 13 | public: 14 | /// Selects an image processor through a specified name. 15 | /*! if users give a non-existing name for choosing an image processor, 16 | the call succeed, but no image processor would be replaced. 17 | */ 18 | void stretch(const std::string& name); 19 | /// Inserts a new user-defined image processor for stretch. 20 | template 21 | void add_stretch(const std::string& name) 22 | { 23 | detail::image_process_provider & p = detail::image_process_provider::instance(); 24 | p.add(p.ref_stretch_tag(), name); 25 | } 26 | 27 | /// Selects an image process through a specified name. 28 | void alpha_blend(const std::string& name); 29 | /// Inserts a new user defined image process for alpha blend. 30 | template 31 | void add_alpha_blend(const std::string& name) 32 | { 33 | detail::image_process_provider& p = detail::image_process_provider::instance(); 34 | p.add(p.ref_alpha_blend_tag(), name); 35 | } 36 | 37 | /// Selects an image processor blend through a specified name. 38 | void blend(const std::string& name); 39 | /// Inserts a new user-defined image processor for blend. 40 | template 41 | void add_blend(const std::string& name) 42 | { 43 | detail::image_process_provider& p = detail::image_process_provider::instance(); 44 | p.add(p.ref_blend_tag(), name); 45 | } 46 | 47 | /// Selects an image processor through a specified name. 48 | void line(const std::string& name); 49 | /// Inserts a new user-defined image processor for line. 50 | template 51 | void add_line(const std::string& name) 52 | { 53 | detail::image_process_provider & p = detail::image_process_provider::instance(); 54 | p.add(p.ref_line_tag(), name); 55 | } 56 | 57 | /// blur - Selects an image procssor through a specified name. 58 | void blur(const std::string& name); 59 | /// Inserts a new user-defined image process for blur. 60 | template 61 | void add_blur(const std::string& name) 62 | { 63 | detail::image_process_provider & p = detail::image_process_provider::instance(); 64 | p.add(p.ref_blur_tag(), name); 65 | } 66 | }; 67 | } 68 | } 69 | } 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /include/nana/paint/pixel_buffer.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Pixel Buffer Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/paint/pixel_buffer.hpp 11 | */ 12 | 13 | #ifndef NANA_PAINT_PIXEL_BUFFER_HPP 14 | #define NANA_PAINT_PIXEL_BUFFER_HPP 15 | 16 | #include 17 | #include 18 | 19 | namespace nana{ namespace paint 20 | { 21 | class pixel_buffer 22 | { 23 | struct pixel_buffer_storage; 24 | typedef bool (pixel_buffer:: * unspecified_bool_t)() const; 25 | public: 26 | pixel_buffer() = default; 27 | pixel_buffer(drawable_type, const nana::rectangle& want_rectangle); 28 | pixel_buffer(drawable_type, std::size_t top, std::size_t lines); 29 | pixel_buffer(std::size_t width, std::size_t height); 30 | 31 | ~pixel_buffer(); 32 | 33 | void attach(drawable_type, const nana::rectangle& want_rectangle); 34 | 35 | bool open(drawable_type); 36 | bool open(drawable_type, const nana::rectangle& want_rectangle); 37 | bool open(std::size_t width, std::size_t height); 38 | 39 | void alpha_channel(bool enabled); 40 | bool alpha_channel() const; 41 | 42 | void close(); 43 | 44 | bool empty() const; 45 | 46 | operator unspecified_bool_t() const; 47 | 48 | std::size_t bytes() const; 49 | std::size_t bytes_per_line() const; 50 | nana::size size() const; 51 | 52 | pixel_color_t * at(const point& pos) const; 53 | pixel_color_t * raw_ptr(std::size_t row) const; 54 | pixel_color_t * operator[](std::size_t row) const; 55 | 56 | void fill_row(std::size_t row, const unsigned char* buffer, std::size_t bytes, unsigned bits_per_pixel); 57 | 58 | void put(const unsigned char* rawbits, std::size_t width, std::size_t height, std::size_t bits_per_pixel, std::size_t bytes_per_line, bool is_negative); 59 | 60 | void line(const std::string& name); 61 | void line(const ::nana::point& pos_beg, const ::nana::point& pos_end, const ::nana::color&, double fade_rate); 62 | 63 | void rectangle(const nana::rectangle&, const ::nana::color&, double fade_rate, bool solid); 64 | void gradual_rectangle(const ::nana::rectangle&, const ::nana::color& from, const ::nana::color& to, double fade_rate, bool vertical); 65 | 66 | pixel_color_t pixel(int x, int y) const; 67 | void pixel(int x, int y, pixel_color_t); 68 | 69 | void paste(drawable_type, const point& p_dst) const; 70 | void paste(const nana::rectangle& s_r, drawable_type, const point& p_dst) const; 71 | void paste(native_window_type, const point& p_dst) const; 72 | void stretch(const std::string& name); 73 | void stretch(const nana::rectangle& s_r, drawable_type, const nana::rectangle& r) const; 74 | void blend(const std::string& name); 75 | void blend(const nana::rectangle& s_r, drawable_type dw_dst, const nana::point& d_pos, double fade_rate) const; 76 | void blur(const nana::rectangle& r, std::size_t radius); 77 | 78 | pixel_buffer rotate(double angle, const color& extend_color); 79 | private: 80 | std::shared_ptr storage_; 81 | }; 82 | }//end namespace paint 83 | }//end namespace nana 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /include/nana/paint/text_renderer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_PAINT_TEXT_RENDERER_HPP 2 | #define NANA_PAINT_TEXT_RENDERER_HPP 3 | #include 4 | 5 | namespace nana 6 | { 7 | namespace paint 8 | { 9 | class text_renderer 10 | { 11 | public: 12 | using graph_reference = graphics &; 13 | 14 | enum class mode 15 | { 16 | truncate_with_ellipsis, 17 | truncate_letter_with_ellipsis, 18 | word_wrap 19 | }; 20 | 21 | text_renderer(graph_reference graph, align = align::left); 22 | 23 | nana::size extent_size(int x, int y, const wchar_t*, std::size_t len, unsigned space_pixels) const; 24 | 25 | void render(const point&, const wchar_t*, std::size_t len); 26 | void render(const point&, const wchar_t*, std::size_t len, unsigned space_pixels, mode); 27 | private: 28 | graph_reference graph_; 29 | align text_align_; 30 | }; 31 | 32 | /// Draw aligned string 33 | class aligner 34 | { 35 | public: 36 | using graph_reference = graphics&; 37 | 38 | /// Constructor 39 | /** 40 | * @param graph Reference to a graphics object 41 | * @param text_align Alignment of text 42 | * @param text_align_if_too_long Alignment of text if the pixels of string is larger than text area 43 | */ 44 | aligner(graph_reference graph, align text_align = align::left); 45 | aligner(graph_reference graph, align text_align, align text_align_if_too_long); 46 | 47 | /// Draws a text with specified text alignment. 48 | /** 49 | * @param text Text to draw 50 | * @param pos Postion where the text to draw 51 | * @param width The width of text area. If the pixels of text is larger than this parameter, it draws ellipsis 52 | */ 53 | void draw(const std::string& text, point pos, unsigned width); 54 | void draw(const std::wstring& text, point pos, unsigned width); 55 | private: 56 | graph_reference graph_; 57 | align text_align_; 58 | align text_align_ex_; 59 | }; 60 | } 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /include/nana/pat/abstract_factory.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A Generic Abstract Factory Pattern Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/pat/abstract_factory.hpp 11 | * @description: A generic easy-to-use abstract factory pattern implementation 12 | */ 13 | 14 | #ifndef NANA_PAT_ABSFACTORY_HPP 15 | #define NANA_PAT_ABSFACTORY_HPP 16 | #include "cloneable.hpp" 17 | #include 18 | #include 19 | #include 20 | 21 | namespace nana 22 | { 23 | namespace pat 24 | { 25 | namespace detail 26 | { 27 | //A Base class for abstract factory, avoids decorated name length exceeding for a class template. 28 | class abstract_factory_base 29 | { 30 | public: 31 | virtual ~abstract_factory_base() = default; 32 | }; 33 | } 34 | 35 | template 36 | class abstract_factory 37 | : public detail::abstract_factory_base 38 | { 39 | public: 40 | using interface_type = Interface; 41 | 42 | virtual ~abstract_factory() = default; 43 | virtual std::unique_ptr create() = 0; 44 | }; 45 | 46 | namespace detail 47 | { 48 | template 49 | struct pack{ 50 | using type = pack; 51 | }; 52 | 53 | template 54 | struct make_pack_helper 55 | { // explodes gracefully below 0 56 | static_assert(!Negative, 57 | "make_integer_sequence requires N to be non-negative."); 58 | }; 59 | 60 | template 61 | struct make_pack_helper, 63 | pack > 64 | : pack 65 | { // ends recursion at 0 66 | }; 67 | 68 | template 69 | struct make_pack_helper, 71 | pack > 72 | : make_pack_helper, 74 | pack > 75 | { // counts down to 0 76 | }; 77 | 78 | template 79 | using make_pack = typename make_pack_helper, pack >::type; 80 | 81 | template 82 | class abs_factory 83 | : public abstract_factory 84 | { 85 | std::unique_ptr create() override 86 | { 87 | constexpr auto const Size = std::tuple_size::value; 88 | return std::unique_ptr{ _m_new(make_pack{}) }; 89 | } 90 | 91 | template 92 | Interface* _m_new(const pack &) 93 | { 94 | return new T(std::get(args_)...); 95 | } 96 | public: 97 | abs_factory(const Args&... args) 98 | : args_(args...) 99 | { 100 | } 101 | private: 102 | std::tuple args_; 103 | }; 104 | }//end namespace detail 105 | 106 | template 107 | pat::cloneable> make_factory(Args &&... args) 108 | { 109 | return detail::abs_factory::type...>(std::forward(args)...); 110 | } 111 | }//end namespace pat 112 | }//end namespace nana 113 | #endif 114 | -------------------------------------------------------------------------------- /include/nana/pop_ignore_diagnostic: -------------------------------------------------------------------------------- 1 | 2 | #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) 3 | # pragma GCC diagnostic pop 4 | #endif 5 | 6 | -------------------------------------------------------------------------------- /include/nana/push_ignore_diagnostic: -------------------------------------------------------------------------------- 1 | #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) 2 | # pragma GCC diagnostic push 3 | # pragma GCC diagnostic ignored "-Weffc++" 4 | #endif 5 | -------------------------------------------------------------------------------- /include/nana/std_condition_variable.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_STD_CONDITION_VARIABLE_HPP 2 | #define NANA_STD_CONDITION_VARIABLE_HPP 3 | #include 4 | 5 | #if defined(STD_THREAD_NOT_SUPPORTED) 6 | #if defined(NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ) 7 | #include 8 | #else 9 | #include 10 | namespace std 11 | { 12 | typedef boost::condition_variable condition_variable; 13 | } 14 | #endif // (NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ) 15 | #endif // (STD_THREAD_NOT_SUPPORTED) 16 | #endif // NANA_STD_CONDITION_VARIABLE_HPP 17 | -------------------------------------------------------------------------------- /include/nana/std_mutex.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_STD_MUTEX_HPP 2 | #define NANA_STD_MUTEX_HPP 3 | #include 4 | 5 | #if defined(STD_THREAD_NOT_SUPPORTED) 6 | 7 | #if defined(NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ) 8 | #include 9 | #include 10 | #include 11 | //#include 12 | //#include 13 | #include 14 | #include 15 | // http://lxr.free-electrons.com/source/include/uapi/asm-generic/errno.h#L53 16 | //#define EPROTO 71 /* Protocol error */ 17 | #ifdef _GLIBCXX_HAS_GTHREADS 18 | # include 19 | #else 20 | #include 21 | #include 22 | #endif 23 | #else 24 | #include 25 | #include 26 | #include 27 | 28 | namespace std 29 | { 30 | template 31 | using lock_guard = boost::lock_guard; 32 | 33 | template 34 | using unique_lock = boost::unique_lock; 35 | 36 | typedef boost::mutex mutex; 37 | typedef boost::recursive_mutex recursive_mutex; 38 | } 39 | #endif // (NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ) 40 | #endif // (STD_THREAD_NOT_SUPPORTED) 41 | #endif // NANA_STD_MUTEX_HPP 42 | -------------------------------------------------------------------------------- /include/nana/std_thread.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_STD_THREAD_HPP 2 | #define NANA_STD_THREAD_HPP 3 | #include 4 | 5 | #if defined(STD_THREAD_NOT_SUPPORTED) 6 | 7 | #if defined(NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ) 8 | 9 | #ifdef _GLIBCXX_HAS_GTHREADS 10 | # include 11 | #else 12 | # include 13 | #endif 14 | #else 15 | #include 16 | namespace std 17 | { 18 | typedef boost::thread thread; 19 | } 20 | #endif // (NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ) 21 | 22 | #else 23 | 24 | #include 25 | 26 | #endif // (STD_THREAD_NOT_SUPPORTED) 27 | 28 | #endif // NANA_STD_THREAD_HPP 29 | -------------------------------------------------------------------------------- /include/nana/system/dataexch.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Data Exchanger Implementation 3 | * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/system/dataexch.hpp 10 | * @description: An implementation of a data exchange mechanism through Windows Clipboard, X11 Selection. 11 | */ 12 | 13 | #ifndef NANA_SYSTEM_DATAEXCH_HPP 14 | #define NANA_SYSTEM_DATAEXCH_HPP 15 | #include 16 | 17 | namespace nana{ 18 | 19 | namespace paint{ 20 | class graphics; 21 | } 22 | 23 | namespace system{ 24 | 25 | /// a data exchange mechanism through Windows Clipboard, X11 Selection. 26 | class dataexch 27 | { 28 | public: 29 | enum class format 30 | { 31 | text, pixmap 32 | }; 33 | 34 | void set(const std::string & text_utf8, native_window_type owner = nullptr); 35 | void set(const std::wstring& text, native_window_type owner = nullptr); 36 | 37 | bool set(const nana::paint::graphics& g, native_window_type owner = nullptr); 38 | 39 | void get(std::string& text_utf8); 40 | void get(std::wstring& text); 41 | 42 | std::wstring wget(); 43 | private: 44 | bool _m_set(format, const void* buf, std::size_t size, native_window_type); 45 | void* _m_get(format, size_t& size); 46 | }; 47 | 48 | }//end namespace system 49 | }//end namespace nana 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/nana/system/platform.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A platform API implementation 3 | * Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/system/platform.hpp 10 | * @description: 11 | * this implements some API for platform-independent programming 12 | */ 13 | 14 | #ifndef NANA_SYSTEM_PLATFORM_HPP 15 | #define NANA_SYSTEM_PLATFORM_HPP 16 | #include 17 | 18 | namespace nana 19 | { 20 | namespace system 21 | { 22 | //sleep 23 | //@brief: suspend current thread for a specified milliseconds. 24 | //its precision is depended on hardware. 25 | void sleep(unsigned milliseconds); 26 | 27 | //this_thread_id 28 | //@brief: get the identifier of calling thread. 29 | thread_t this_thread_id(); 30 | 31 | //timestamp 32 | //@brief: it retrieves the timestamp at the time the function is called. 33 | // it is easy for get the number of milliseconds between calls. 34 | unsigned long timestamp(); 35 | 36 | //get_async_mouse_state 37 | //@brief: it determines whether a mouse button was pressed at the time the function is called. 38 | bool get_async_mouse_state(int button); 39 | 40 | //open an url through a default browser 41 | void open_url(const std::string& url); 42 | 43 | }//end namespace system 44 | }//end namespace nana 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /include/nana/system/shared_wrapper.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Operation System Shared Linkage Library Wrapper Implementation 3 | * Copyright(C) 2003-2016 Jinhao 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/system/shared_wrapper.hpp 10 | * @description: 11 | */ 12 | #ifndef NANA_SYSTEM_SHARED_WRAPPER_HPP 13 | #define NANA_SYSTEM_SHARED_WRAPPER_HPP 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | namespace nana 21 | { 22 | namespace system 23 | { 24 | 25 | namespace detail 26 | { 27 | namespace shared_helper 28 | { 29 | 30 | typedef void* module_t; 31 | void* symbols(module_t handle, const char* symbol); 32 | 33 | } //end namespace shared_helper 34 | }//end namespace detail 35 | 36 | class shared_wrapper 37 | { 38 | typedef detail::shared_helper::module_t module_t; 39 | 40 | 41 | template 42 | struct function_ptr 43 | { 44 | typedef typename std::conditional::value, 45 | Function*, 46 | typename std::conditional::value && std::is_pointer::value, Function, int>::type 47 | >::type type; 48 | }; 49 | 50 | struct impl_type 51 | { 52 | module_t handle; 53 | std::string symbol; 54 | void* proc_address; 55 | 56 | impl_type(); 57 | }; 58 | public: 59 | shared_wrapper(); 60 | shared_wrapper(const char* filename); 61 | ~shared_wrapper(); 62 | 63 | bool open(const char* filename); 64 | void close(); 65 | bool empty() const; 66 | 67 | template 68 | typename function_ptr::type symbols(const char* symbol) 69 | { 70 | typedef typename function_ptr::type fptr_type; 71 | 72 | //if(nana::traits::is_function_pointer::value == false) 73 | if (::std::is_function::type>::value == false) 74 | throw std::invalid_argument("shared_wrapper::symbols, template<_Function> is not a function type or a function pointer type"); 75 | 76 | if(symbol == 0) 77 | throw std::invalid_argument("shared_wrapper::symbols, symbol is null string"); 78 | 79 | if(impl_.handle == 0) 80 | throw std::logic_error("shared_wrapper::symbols, empty handle"); 81 | 82 | if(impl_.symbol != symbol) 83 | { 84 | void *result = detail::shared_helper::symbols(impl_.handle, symbol); 85 | if(result == 0) 86 | throw std::logic_error("shared_wrapper::symbols, empty proc address"); 87 | 88 | impl_.proc_address = result; 89 | impl_.symbol = symbol; 90 | } 91 | return (fptr_type)(this->impl_.proc_address); 92 | } 93 | 94 | private: 95 | impl_type impl_; 96 | }; 97 | }//end namespace system 98 | }//end namespace nana 99 | 100 | #endif 101 | 102 | -------------------------------------------------------------------------------- /include/nana/system/timepiece.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Timepiece Implementation 3 | * Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/system/timepiece.hpp 10 | * @description: a time counter 11 | */ 12 | 13 | #ifndef NANA_SYSTEM_TIMEPIECE_HPP 14 | #define NANA_SYSTEM_TIMEPIECE_HPP 15 | 16 | #include "../c++defines.hpp" 17 | 18 | namespace nana 19 | { 20 | namespace system 21 | { /// used for measuring and signaling the end of time intervals. 22 | class timepiece 23 | { 24 | public: 25 | timepiece(); 26 | timepiece(const timepiece&); 27 | ~timepiece(); 28 | timepiece & operator=(const timepiece &); 29 | void start() noexcept; ///< Set the begin time. 30 | double calc() const noexcept; ///< Get the intervals from the begin time. 31 | private: 32 | struct impl_t; 33 | impl_t * impl_; 34 | }; 35 | 36 | }//end namespace system 37 | }//end namespace nana 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /include/nana/traits.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Traits Implementation 3 | * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * @file: nana/traits.hpp 6 | */ 7 | 8 | #ifndef NANA_TRAITS_HPP 9 | #define NANA_TRAITS_HPP 10 | #include 11 | 12 | namespace nana 13 | { 14 | class null_type{}; 15 | 16 | /// Prevent a class to be copyable 17 | class noncopyable 18 | { 19 | noncopyable(const noncopyable&) = delete; 20 | noncopyable& operator=(const noncopyable&) = delete; 21 | protected: 22 | noncopyable() = default; 23 | }; 24 | 25 | /// Prevent a class to be movable 26 | class nonmovable 27 | { 28 | nonmovable(nonmovable&&) = delete; 29 | nonmovable& operator=(nonmovable&&) = delete; 30 | protected: 31 | nonmovable() = default; 32 | }; 33 | 34 | namespace meta 35 | { 36 | template< typename Param0 = null_type, typename Param1 = null_type, 37 | typename Param2 = null_type, typename Param3 = null_type, 38 | typename Param4 = null_type, typename Param5 = null_type, 39 | typename Param6 = null_type, typename Param7 = null_type, 40 | typename Param8 = null_type, typename Param9 = null_type> 41 | struct fixed_type_set 42 | { 43 | template 44 | struct count 45 | { 46 | enum{value = std::is_same::value + 47 | std::is_same::value + 48 | std::is_same::value + 49 | std::is_same::value + 50 | std::is_same::value + 51 | std::is_same::value + 52 | std::is_same::value + 53 | std::is_same::value + 54 | std::is_same::value + 55 | std::is_same::value}; 56 | }; 57 | }; 58 | }//end namespace meta 59 | }//end namespace nana 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /include/nana/unicode_bidi.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_UNICODE_BIDI_HPP 2 | #define NANA_UNICODE_BIDI_HPP 3 | #include 4 | #include 5 | 6 | 7 | namespace nana 8 | { 9 | class unicode_bidi 10 | { 11 | public: 12 | typedef wchar_t char_type; 13 | 14 | enum class directional_override_status 15 | { 16 | neutral, right_to_left, left_to_right 17 | }; 18 | 19 | enum class bidi_char 20 | { 21 | L, LRE, LRO, R, AL, RLE, RLO, 22 | PDF = 0x1000, EN, ES, ET, AN, CS, NSM, BN, 23 | B = 0x2000, S, WS, ON 24 | }; 25 | 26 | enum class bidi_category 27 | { 28 | strong, weak = 0x1000, neutral = 0x2000 29 | }; 30 | 31 | const static char_type LRE = 0x202A; 32 | const static char_type RLE = 0x202B; 33 | const static char_type PDF = 0x202C; 34 | const static char_type LRO = 0x202D; 35 | const static char_type RLO = 0x202E; 36 | const static char_type LRM = 0x200E; 37 | const static char_type RLM = 0x200F; 38 | 39 | struct remember 40 | { 41 | unsigned level; 42 | directional_override_status directional_override; 43 | }; 44 | 45 | struct entity 46 | { 47 | const wchar_t * begin, * end; 48 | bidi_char bidi_char_type; 49 | unsigned level; 50 | }; 51 | 52 | std::vector reorder(const char_type*, std::size_t len); 53 | static bool is_text_right(const entity&); 54 | private: 55 | static unsigned _m_paragraph_level(const char_type * begin, const char_type * end); 56 | 57 | void _m_push_entity(const char_type * begin, const char_type *end, unsigned level, bidi_char); 58 | 59 | std::vector::iterator _m_search_first_character(); 60 | 61 | bidi_char _m_eor(std::vector::iterator); 62 | 63 | void _m_resolve_weak_types(); 64 | void _m_resolve_neutral_types(); 65 | void _m_resolve_implicit_levels(); 66 | void _m_reordering_resolved_levels(std::vector & reordered); 67 | static bidi_category _m_bidi_category(bidi_char); 68 | static bidi_char _m_char_dir(char_type); 69 | private: 70 | std::vector levels_; 71 | }; 72 | 73 | std::vector unicode_reorder(const wchar_t* text, std::size_t length); 74 | 75 | bool unicode_wordbreak(wchar_t left, wchar_t right); 76 | } 77 | #include 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /source/any.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Any 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file nana/any.cpp 11 | * 12 | * @brief An implementation of experimental library any of C++ standard(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4480.html#any) 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace nana 19 | { 20 | //constructors and destructor 21 | any::any() noexcept 22 | : content_(nullptr) 23 | { 24 | } 25 | 26 | any::any(const any& other) 27 | : content_(other.content_ ? other.content_->clone() : nullptr) 28 | {} 29 | 30 | any::any(any && other) noexcept 31 | : content_(other.content_) 32 | { 33 | other.content_ = nullptr; 34 | } 35 | 36 | any::~any() 37 | { 38 | delete content_; 39 | } 40 | 41 | //assignments 42 | any& any::operator=(const any& other) 43 | { 44 | if (this != &other) 45 | any(other).swap(*this); 46 | 47 | return *this; 48 | } 49 | 50 | any& any::operator=(any&& other) noexcept 51 | { 52 | if (this != &other) 53 | { 54 | other.swap(*this); 55 | other.clear(); 56 | } 57 | return *this; 58 | } 59 | 60 | //modifiers 61 | void any::clear() noexcept 62 | { 63 | if (content_) 64 | { 65 | auto cnt = content_; 66 | content_ = nullptr; 67 | delete cnt; 68 | } 69 | } 70 | 71 | void any::swap(any& other) noexcept 72 | { 73 | std::swap(content_, other.content_); 74 | } 75 | 76 | //observers 77 | bool any::empty() const noexcept 78 | { 79 | return (nullptr == content_); 80 | } 81 | 82 | const std::type_info& any::type() const noexcept 83 | { 84 | return (content_ ? content_->type() : typeid(void)); 85 | } 86 | }//end namespace nana 87 | 88 | -------------------------------------------------------------------------------- /source/audio/detail/audio_stream.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #ifdef NANA_ENABLE_AUDIO 3 | 4 | #include 5 | 6 | namespace nana{ namespace audio 7 | { 8 | namespace detail 9 | { 10 | //class audio_stream 11 | bool audio_stream::open(const std::string& file) 12 | { 13 | fs_.open(to_osmbstr(file), std::ios::binary); 14 | if(fs_) 15 | { 16 | wave_spec::master_riff_chunk riff; 17 | fs_.read(reinterpret_cast(&riff), sizeof(riff)); 18 | if(riff.ckID == *reinterpret_cast("RIFF") && riff.waveID == *reinterpret_cast("WAVE")) 19 | { 20 | fs_.read(reinterpret_cast(&ck_format_), sizeof(ck_format_)); 21 | if(ck_format_.ckID == *reinterpret_cast("fmt ") && ck_format_.wFormatTag == 1) //Only support PCM format 22 | { 23 | if (ck_format_.cksize > 16) 24 | fs_.seekg(ck_format_.cksize - 16, std::ios::cur); 25 | 26 | std::size_t cksize = _m_locate_chunck(*reinterpret_cast("data")); 27 | if(cksize) 28 | { 29 | pcm_data_pos_ = static_cast(fs_.tellg()); 30 | pcm_data_size_ = cksize; 31 | return true; 32 | } 33 | } 34 | } 35 | } 36 | return false; 37 | } 38 | 39 | void audio_stream::close() 40 | { 41 | fs_.close(); 42 | } 43 | 44 | bool audio_stream::empty() const 45 | { 46 | return (!fs_); 47 | } 48 | 49 | const wave_spec::format_chunck & audio_stream::format() const 50 | { 51 | return ck_format_; 52 | } 53 | 54 | std::size_t audio_stream::data_length() const 55 | { 56 | return data_size_; 57 | } 58 | 59 | void audio_stream::locate() 60 | { 61 | fs_.clear(); 62 | fs_.seekg(pcm_data_pos_, std::ios::beg); 63 | data_size_ = pcm_data_size_; 64 | } 65 | 66 | std::size_t audio_stream::read(void * buf, std::size_t len) 67 | { 68 | fs_.read(reinterpret_cast(buf), static_cast(len <= data_size_ ? len : data_size_)); 69 | std::size_t read_bytes = static_cast(fs_.gcount()); 70 | data_size_ -= read_bytes; 71 | return read_bytes; 72 | } 73 | 74 | std::size_t audio_stream::_m_locate_chunck(unsigned ckID) 75 | { 76 | chunck ck; 77 | while(true) 78 | { 79 | fs_.read(reinterpret_cast(&ck), sizeof(ck)); 80 | if(fs_.gcount() != sizeof(ck)) 81 | break; 82 | 83 | if(ck.ckID == ckID) 84 | return ck.cksize; 85 | if(ck.ckID == *reinterpret_cast("data")) 86 | fs_.seekg(ck.cksize + (ck.cksize & 1 ? 1 : 0), std::ios::cur); 87 | else 88 | fs_.seekg(ck.cksize, std::ios::cur); 89 | } 90 | return 0; 91 | } 92 | //end class audio_stream 93 | }//end namespace detail 94 | 95 | }//end namespace audio 96 | }//end namespace nana 97 | #endif //NANA_ENABLE_AUDIO 98 | -------------------------------------------------------------------------------- /source/audio/player.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | 6 | #ifdef NANA_ENABLE_AUDIO 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace nana{ namespace audio 14 | { 15 | //class player 16 | struct player::implementation 17 | { 18 | detail::audio_stream stream; 19 | detail::audio_device dev; 20 | }; 21 | 22 | player::player() 23 | : impl_(new implementation) 24 | {} 25 | 26 | player::player(const std::string& file) 27 | : impl_(new implementation) 28 | { 29 | open(file); 30 | } 31 | 32 | player::~player() 33 | { 34 | delete impl_; 35 | } 36 | 37 | bool player::open(const std::string& file) 38 | { 39 | if(impl_->stream.open(file)) 40 | { 41 | const detail::wave_spec::format_chunck & ck = impl_->stream.format(); 42 | return impl_->dev.open(ck.nChannels, ck.nSamplePerSec, ck.wBitsPerSample); 43 | } 44 | return false; 45 | } 46 | 47 | void player::play() 48 | { 49 | if(impl_->dev.empty() || impl_->stream.empty()) return; 50 | 51 | //Locate the PCM 52 | impl_->stream.locate(); 53 | const std::size_t seconds = 5; 54 | 55 | detail::buffer_preparation buffer(impl_->stream, seconds); 56 | impl_->dev.prepare(buffer); 57 | detail::buffer_preparation::meta * meta; 58 | while((meta = buffer.read())) 59 | { 60 | impl_->dev.write(meta); 61 | } 62 | impl_->dev.wait_for_drain(); 63 | } 64 | 65 | void player::close() 66 | { 67 | impl_->dev.close(); 68 | impl_->stream.close(); 69 | } 70 | }//end namespace audio 71 | }//end namespace nana 72 | 73 | #endif //NANA_ENABLE_AUDIO 74 | -------------------------------------------------------------------------------- /source/detail/platform_abstraction.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Platform Abstraction 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2017-2019 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/detail/platform_spec.hpp 11 | * 12 | * The platform_abstraction provides some functions and types for the abstract 13 | * system platform. 14 | */ 15 | #ifndef NANA_DETAIL_PLATFORM_ABSTRACTION_HEADER_INCLUDED 16 | #define NANA_DETAIL_PLATFORM_ABSTRACTION_HEADER_INCLUDED 17 | 18 | #include "platform_abstraction_types.hpp" 19 | #include 20 | #include 21 | 22 | namespace nana 23 | { 24 | 25 | 26 | class platform_abstraction 27 | { 28 | public: 29 | using font = font_interface; 30 | 31 | using path_type = ::std::filesystem::path; 32 | 33 | static void initialize(); 34 | /// Shutdown before destruction of platform_spec 35 | static void shutdown(); 36 | static double font_default_pt(); 37 | static void font_languages(const std::string&); 38 | static ::std::shared_ptr default_font(const ::std::shared_ptr&); 39 | static ::std::shared_ptr make_font(const ::std::string& font_family, double size_pt, const font::font_style& fs); 40 | static ::std::shared_ptr make_font_from_ttf(const path_type& ttf, double size_pt, const font::font_style& fs); 41 | static void font_resource(bool try_add, const path_type& ttf); 42 | 43 | static unsigned screen_dpi(bool x_requested); 44 | }; 45 | } 46 | 47 | #endif -------------------------------------------------------------------------------- /source/detail/platform_abstraction_types.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_DETAIL_PLATFORM_ABSTRACTION_TYPES_HEADER_INCLUDED 2 | #define NANA_DETAIL_PLATFORM_ABSTRACTION_TYPES_HEADER_INCLUDED 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #ifdef NANA_X11 9 | # define NANA_USE_XFT 10 | #endif 11 | 12 | namespace nana 13 | { 14 | class font_interface 15 | { 16 | public: 17 | using font_style = detail::font_style; 18 | using native_font_type = paint::native_font_type; 19 | 20 | virtual ~font_interface() = default; 21 | 22 | virtual const std::string& family() const = 0; 23 | virtual double size() const = 0; 24 | virtual const font_style & style() const = 0; 25 | virtual native_font_type native_handle() const = 0; 26 | }; 27 | } 28 | 29 | #endif -------------------------------------------------------------------------------- /source/detail/platform_spec_selector.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Selector of Platform Specification 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file nana/detail/platform_spec_selector.hpp 11 | * 12 | * @brief Selects the proper platform_spec header file for the current platform 13 | */ 14 | 15 | #include 16 | 17 | #if defined(NANA_WINDOWS) 18 | #include "mswin/platform_spec.hpp" 19 | #elif defined(NANA_POSIX) 20 | #include "posix/platform_spec.hpp" 21 | #endif 22 | -------------------------------------------------------------------------------- /source/detail/posix/msg_packet.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_DETAIL_MSG_PACKET_HPP 2 | #define NANA_DETAIL_MSG_PACKET_HPP 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace nana 9 | { 10 | namespace detail 11 | { 12 | enum class propagation_chain 13 | { 14 | exit, //Exit the chain 15 | stop, //Stop propagating 16 | pass //propagate 17 | }; 18 | 19 | struct msg_packet_tag 20 | { 21 | enum class pkt_family{xevent, mouse_drop, cleanup}; 22 | pkt_family kind; 23 | union 24 | { 25 | XEvent xevent; 26 | 27 | Window packet_window; //Avaiable if the packet is not kind_xevent 28 | struct mouse_drop_tag 29 | { 30 | Window window; 31 | int x; 32 | int y; 33 | std::vector * files; 34 | }mouse_drop; 35 | }u; 36 | }; 37 | }//end namespace detail 38 | }//end namespace nana 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /source/detail/posix/theme.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_DETAIL_THEME_INCLUDED 2 | #define NANA_DETAIL_THEME_INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace nana 10 | { 11 | namespace detail 12 | { 13 | class theme 14 | { 15 | public: 16 | theme(); 17 | 18 | std::string cursor(const std::string& name) const; 19 | std::string icon(const std::string& name, std::size_t size_wanted) const; 20 | private: 21 | std::string path_; 22 | mutable std::ifstream ifs_; 23 | 24 | mutable std::map>> iconcache_; 25 | }; 26 | 27 | }//end namespace detail 28 | 29 | }//end namespace nana 30 | 31 | #endif -------------------------------------------------------------------------------- /source/gui/basis.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Basis Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/basis.cpp 11 | * 12 | * This file provides basis class and data structrue that required by gui 13 | */ 14 | 15 | #include 16 | 17 | using namespace nana; 18 | using namespace nana::parameters; 19 | 20 | //struct appearance 21 | appearance::appearance() 22 | :taskbar(true), floating(false), no_activate(false), 23 | minimize(true), maximize(true), sizable(true), 24 | decoration(true) 25 | {} 26 | 27 | appearance::appearance(bool has_decorate, bool taskbar, bool is_float, bool no_activate, bool min, bool max, bool sizable) 28 | : taskbar(taskbar), floating(is_float), no_activate(no_activate), 29 | minimize(min), maximize(max), sizable(sizable), 30 | decoration(has_decorate) 31 | {} 32 | //end struct appearance 33 | 34 | #if defined(NANA_WINDOWS) 35 | # include 36 | #endif 37 | 38 | mouse_wheel::mouse_wheel() 39 | : lines(3), characters(3) 40 | { 41 | #if defined(NANA_WINDOWS) 42 | // https://msdn.microsoft.com/en-us/library/ms997498.aspx 43 | //#define SPI_SETWHEELSCROLLCHARS 0x006D 44 | # ifndef SPI_GETWHEELSCROLLCHARS 45 | # define SPI_GETWHEELSCROLLCHARS 0x006C 46 | # endif 47 | ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &lines, 0); 48 | ::SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &characters, 0); 49 | #endif 50 | } 51 | 52 | -------------------------------------------------------------------------------- /source/gui/detail/bedrock_types.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_GUI_DETAIL_BEDROCK_TYPES_INCLUDED 2 | #define NANA_GUI_DETAIL_BEDROCK_TYPES_INCLUDED 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace nana 13 | { 14 | namespace detail 15 | { 16 | struct bedrock::pi_data 17 | { 18 | color_schemes scheme; 19 | events_operation evt_operation; 20 | window_manager wd_manager; 21 | std::set auto_form_set; 22 | bool shortkey_occurred{ false }; 23 | 24 | struct menu_rep 25 | { 26 | basic_window* taken_window{ nullptr }; 27 | bool delay_restore{ false }; 28 | native_window_type window{ nullptr }; 29 | native_window_type owner{ nullptr }; 30 | bool has_keyboard{ false }; 31 | }menu; 32 | }; 33 | 34 | 35 | #ifdef NANA_WINDOWS 36 | struct bedrock::thread_context 37 | { 38 | unsigned event_pump_ref_count{0}; 39 | int window_count{0}; //The number of windows 40 | basic_window* event_window{nullptr}; 41 | 42 | struct platform_detail_tag 43 | { 44 | wchar_t keychar; 45 | }platform; 46 | 47 | struct cursor_tag 48 | { 49 | basic_window * window; 50 | native_window_type native_handle; 51 | nana::cursor predef_cursor; 52 | HCURSOR handle; 53 | }cursor; 54 | 55 | thread_context() 56 | { 57 | cursor.window = nullptr; 58 | cursor.native_handle = nullptr; 59 | cursor.predef_cursor = nana::cursor::arrow; 60 | cursor.handle = nullptr; 61 | } 62 | }; 63 | #else 64 | struct bedrock::thread_context 65 | { 66 | unsigned event_pump_ref_count{0}; 67 | 68 | int window_count{0}; //The number of windows 69 | basic_window* event_window{nullptr}; 70 | bool is_alt_pressed{false}; 71 | bool is_ctrl_pressed{false}; 72 | 73 | struct platform_detail_tag 74 | { 75 | native_window_type motion_window; 76 | nana::point motion_pointer_pos; 77 | }platform; 78 | 79 | struct cursor_tag 80 | { 81 | basic_window * window; 82 | native_window_type native_handle; 83 | nana::cursor predef_cursor; 84 | Cursor handle; 85 | }cursor; 86 | 87 | thread_context() 88 | { 89 | cursor.window = nullptr; 90 | cursor.native_handle = nullptr; 91 | cursor.predef_cursor = nana::cursor::arrow; 92 | cursor.handle = 0; 93 | } 94 | }; 95 | #endif 96 | } 97 | } 98 | 99 | #include 100 | 101 | #endif -------------------------------------------------------------------------------- /source/gui/detail/color_schemes.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Color Schemes 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/color_schemes.cpp 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | namespace nana 17 | { 18 | //class color_proxy 19 | color_proxy::color_proxy(const color_proxy& other) 20 | : color_(other.color_) 21 | {} 22 | 23 | color_proxy::color_proxy(color_rgb clr) 24 | : color_(std::make_shared(clr)) 25 | {} 26 | 27 | color_proxy::color_proxy(color_argb clr) 28 | : color_(std::make_shared(clr)) 29 | {} 30 | 31 | color_proxy::color_proxy(color_rgba clr) 32 | : color_(std::make_shared(clr)) 33 | {} 34 | 35 | color_proxy::color_proxy(colors clr) 36 | : color_(std::make_shared(clr)) 37 | {} 38 | 39 | color_proxy& color_proxy::operator=(const color_proxy& other) 40 | { 41 | if (this != &other) 42 | color_ = other.color_; 43 | return *this; 44 | } 45 | 46 | color_proxy& color_proxy::operator=(const ::nana::color& clr) 47 | { 48 | color_ = std::make_shared<::nana::color>(clr); 49 | return *this; 50 | } 51 | 52 | color_proxy& color_proxy::operator = (color_rgb clr) 53 | { 54 | color_ = std::make_shared<::nana::color>(clr); 55 | return *this; 56 | } 57 | 58 | color_proxy& color_proxy::operator = (color_argb clr) 59 | { 60 | color_ = std::make_shared<::nana::color>(clr); 61 | return *this; 62 | } 63 | 64 | color_proxy& color_proxy::operator = (color_rgba clr) 65 | { 66 | color_ = std::make_shared<::nana::color>(clr); 67 | return *this; 68 | } 69 | 70 | color_proxy& color_proxy::operator = (colors clr) 71 | { 72 | color_ = std::make_shared<::nana::color>(clr); 73 | return *this; 74 | } 75 | 76 | color color_proxy::get_color() const 77 | { 78 | return *color_; 79 | } 80 | 81 | color color_proxy::get(const color& default_color) const 82 | { 83 | if (color_ && !color_->invisible()) 84 | return *color_; 85 | return default_color; 86 | } 87 | 88 | color_proxy::operator color() const 89 | { 90 | return (color_ ? *color_ : color{}); 91 | } 92 | //end class color_proxy 93 | 94 | namespace detail 95 | { 96 | //class color_schemes 97 | struct color_schemes::implement 98 | { 99 | std::map> scheme_template; 100 | }; 101 | 102 | color_schemes::color_schemes() 103 | : impl_(new implement) 104 | { 105 | } 106 | 107 | color_schemes::~color_schemes() 108 | { 109 | delete impl_; 110 | } 111 | 112 | auto color_schemes::scheme_template(scheme_factory_interface&& factory) -> scheme& 113 | { 114 | auto & tmpl_scheme = impl_->scheme_template[factory.get_id()]; 115 | 116 | //Creates a scheme template if no template 117 | if (!tmpl_scheme) 118 | tmpl_scheme.reset(factory.create()); 119 | 120 | return *tmpl_scheme.get(); 121 | } 122 | 123 | widget_geometrics* color_schemes::create(scheme_factory_interface&& factory) 124 | { 125 | return factory.create(scheme_template(std::move(factory))); 126 | } 127 | //end class color_system 128 | }//end namespace detail 129 | }//end namespace nana -------------------------------------------------------------------------------- /source/gui/detail/dynamic_drawing_object.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Dynamic Drawing Object Implementation 3 | * Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/gui/detail/dynamic_drawing_object.hpp 10 | * 11 | * !DON'T INCLUDE THIS HEADER FILE IN YOUR SOURCE CODE 12 | */ 13 | 14 | #ifndef NANA_GUI_DETAIL_DYNAMIC_DRAWING_OBJECT_HPP 15 | #define NANA_GUI_DETAIL_DYNAMIC_DRAWING_OBJECT_HPP 16 | 17 | #include 18 | #include 19 | 20 | namespace nana 21 | { 22 | namespace detail 23 | { 24 | namespace dynamic_drawing 25 | { 26 | class object 27 | { 28 | object(const object&) = delete; 29 | object& operator=(const object&) = delete; 30 | public: 31 | object(){} 32 | virtual ~object(){} 33 | 34 | virtual bool diehard() const 35 | { 36 | return false; 37 | } 38 | 39 | virtual void draw(nana::paint::graphics&) const = 0; 40 | }; 41 | 42 | //user_draw_function 43 | class user_draw_function 44 | : public object 45 | { 46 | public: 47 | user_draw_function(std::function && f, bool diehard) 48 | : diehard_(diehard), fn_(std::move(f)) 49 | {} 50 | 51 | void draw(paint::graphics& graph) const 52 | { 53 | fn_(graph); 54 | } 55 | 56 | bool diehard() const 57 | { 58 | return diehard_; 59 | } 60 | private: 61 | bool diehard_; 62 | std::function fn_; 63 | }; 64 | }//end namespace dynamic_drawing 65 | } 66 | }//end namespace nana 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /source/gui/detail/effects_renderer.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Effects Renderer 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/detail/effects_renderer.cpp 11 | */ 12 | 13 | #ifndef NANA_GUI_DETAIL_EFFECTS_RENDERER_HPP 14 | #define NANA_GUI_DETAIL_EFFECTS_RENDERER_HPP 15 | #include "basic_window.hpp" 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | namespace nana{ 23 | namespace detail 24 | { 25 | /// Effect edige nimbus renderer 26 | class edge_nimbus_renderer 27 | { 28 | edge_nimbus_renderer() = default; 29 | public: 30 | using window_layer = ::nana::detail::window_layout; 31 | using graph_reference = ::nana::paint::graphics&; 32 | 33 | static edge_nimbus_renderer& instance(); 34 | 35 | constexpr unsigned weight() const 36 | { 37 | return 2; 38 | } 39 | 40 | void erase(basic_window* wd); 41 | 42 | void render(basic_window* wd, bool forced, const rectangle* update_area = nullptr); 43 | private: 44 | /// Determines whether the effect will be rendered for the given window. 45 | static bool _m_edge_nimbus(basic_window * const wd, basic_window * const focused_wd); 46 | 47 | void _m_render_edge_nimbus(basic_window* wd, const nana::rectangle & visual); 48 | }; 49 | } 50 | }//end namespace nana 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /source/gui/detail/element_store.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The Store for the Storage Of Elements 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/detail/element_store.cpp 11 | */ 12 | #include 13 | 14 | #include 15 | 16 | namespace nana 17 | { 18 | namespace detail 19 | { 20 | //class element_store 21 | 22 | struct element_store::data 23 | { 24 | cloneable_element entity; 25 | ::nana::element::element_interface * fast_ptr{ nullptr }; 26 | }; 27 | 28 | struct element_store::implementation 29 | { 30 | std::map table; 31 | }; 32 | 33 | element_store::element_store() 34 | : impl_(new implementation) 35 | {} 36 | 37 | //Empty destructor for instance of impl 38 | element_store::~element_store() 39 | {} 40 | 41 | nana::element::element_interface * const * element_store::bground(const std::string& name) 42 | { 43 | element_interface * const * addr = &(impl_->table[name].fast_ptr); 44 | return addr; 45 | } 46 | 47 | void element_store::bground(const std::string& name, const pat::cloneable& rhs) 48 | { 49 | auto & store = impl_->table[name]; 50 | 51 | store.entity = rhs; 52 | store.fast_ptr = store.entity.get(); 53 | } 54 | 55 | void element_store::bground(const std::string& name, pat::cloneable&& rv) 56 | { 57 | auto & store = impl_->table[name]; 58 | 59 | store.entity = std::move(rv); 60 | store.fast_ptr = store.entity.get(); 61 | } 62 | }//end namespace detail 63 | } 64 | -------------------------------------------------------------------------------- /source/gui/detail/inner_fwd_implement.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Implementations of Inner Forward Declaration 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/detail/inner_fwd_implement.hpp 11 | * 12 | */ 13 | 14 | #ifndef NANA_GUI_INNER_FWD_IMPLEMENT_HPP 15 | #define NANA_GUI_INNER_FWD_IMPLEMENT_HPP 16 | 17 | #include 18 | #include "basic_window.hpp" 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #ifdef NANA_X11 25 | # include 26 | #endif 27 | 28 | namespace nana{ 29 | namespace detail 30 | { 31 | class shortkey_container 32 | { 33 | struct item_type; 34 | 35 | //Noncopyable 36 | shortkey_container(const shortkey_container&) = delete; 37 | shortkey_container& operator=(const shortkey_container&) = delete; 38 | 39 | shortkey_container& operator=(shortkey_container&&) = delete; 40 | public: 41 | shortkey_container(); 42 | 43 | shortkey_container(shortkey_container&&); 44 | 45 | ~shortkey_container(); 46 | 47 | void clear(); 48 | 49 | bool make(window wd, unsigned long key); 50 | 51 | void umake(window wd); 52 | 53 | const std::vector* keys(window wd) const; 54 | 55 | window find(unsigned long key) const; 56 | private: 57 | struct implementation; 58 | implementation * impl_; 59 | }; 60 | 61 | struct window_platform_assoc; 62 | 63 | struct root_misc 64 | { 65 | basic_window * window; 66 | window_platform_assoc * wpassoc{ nullptr }; 67 | 68 | nana::paint::graphics root_graph; 69 | shortkey_container shortkeys; 70 | 71 | struct condition_rep 72 | { 73 | bool ignore_tab; //ignore tab when the focus is changed by TAB key. 74 | basic_window* pressed; //The handle to a window which has been pressed by mouse left button. 75 | basic_window* pressed_by_space; //The handle to a window which has been pressed by SPACEBAR key. 76 | basic_window* hovered; //the latest window that mouse moved 77 | }condition; 78 | 79 | root_misc(root_misc&&); 80 | root_misc(basic_window * wd, unsigned width, unsigned height); 81 | ~root_misc(); 82 | 83 | #ifdef NANA_X11 84 | struct x11msg_confirm 85 | { 86 | std::atomic config{ 0 }; 87 | std::atomic map{ 0 }; 88 | std::atomic unmap{ 0 }; 89 | }x11msg; 90 | #endif 91 | private: 92 | root_misc(const root_misc&) = delete; 93 | root_misc& operator=(const root_misc&) = delete; 94 | };//end struct root_misc 95 | 96 | 97 | 98 | class root_register 99 | { 100 | //Noncopyable 101 | root_register(const root_register&) = delete; 102 | root_register& operator=(const root_register&) = delete; 103 | 104 | //Nonmovable 105 | root_register(root_register&&) = delete; 106 | root_register& operator=(root_register&&) = delete; 107 | public: 108 | root_register(); 109 | ~root_register(); 110 | 111 | root_misc* insert(native_window_type, root_misc&&); 112 | 113 | root_misc * find(native_window_type); 114 | 115 | void erase(native_window_type); 116 | private: 117 | struct implementation; 118 | implementation * const impl_; 119 | }; 120 | } 121 | }//end namespace nana 122 | 123 | #include 124 | 125 | #endif //NANA_GUI_INNER_FWD_IMPLEMENT_HPP 126 | -------------------------------------------------------------------------------- /source/gui/drawing.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A Drawing Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/drawing.cpp 11 | */ 12 | 13 | #include "detail/basic_window.hpp" 14 | #include 15 | #include 16 | 17 | namespace nana 18 | { 19 | //restrict 20 | //@brief: This name is only visible for this compiling-unit 21 | namespace restrict 22 | { 23 | namespace 24 | { 25 | inline detail::drawer& get_drawer(window wd) 26 | { 27 | return wd->drawer; 28 | } 29 | } 30 | } 31 | 32 | //class drawing 33 | drawing::drawing(window wd) 34 | :handle_(wd) 35 | { 36 | if (!API::is_window(wd)) 37 | throw std::invalid_argument("drawing: invalid window parameter"); 38 | 39 | if (wd->is_draw_through()) 40 | throw std::invalid_argument("drawing: the window is draw_through enabled"); 41 | } 42 | 43 | drawing::~drawing(){} //Just for polymorphism 44 | 45 | bool drawing::empty() const 46 | { 47 | return API::empty_window(handle_) || handle_->root_graph->empty(); 48 | } 49 | 50 | void drawing::update() const 51 | { 52 | API::refresh_window(handle_); 53 | } 54 | 55 | void drawing::draw(const draw_fn_t& f) 56 | { 57 | if(API::empty_window(handle_)) return; 58 | restrict::get_drawer(handle_).draw(draw_fn_t(f), false); 59 | } 60 | 61 | void drawing::draw(draw_fn_t&& f) 62 | { 63 | if(API::empty_window(handle_)) return; 64 | restrict::get_drawer(handle_).draw(std::move(f), false); 65 | } 66 | 67 | drawing::diehard_t drawing::draw_diehard(const draw_fn_t& f) 68 | { 69 | if(API::empty_window(handle_)) return nullptr; 70 | return reinterpret_cast(restrict::get_drawer(handle_).draw(draw_fn_t(f), true)); 71 | } 72 | 73 | drawing::diehard_t drawing::draw_diehard(draw_fn_t&& f) 74 | { 75 | if(API::empty_window(handle_)) return nullptr; 76 | return reinterpret_cast(restrict::get_drawer(handle_).draw(std::move(f), true)); 77 | } 78 | 79 | void drawing::erase(diehard_t d) 80 | { 81 | //Fixed by Tumiz 82 | //https://github.com/cnjinhao/nana/issues/153 83 | if(!API::empty_window(handle_)) 84 | restrict::get_drawer(handle_).erase(d); 85 | } 86 | 87 | void drawing::clear() 88 | { 89 | if(API::empty_window(handle_)) return; 90 | restrict::get_drawer(handle_).clear(); 91 | } 92 | //end class drawing 93 | }//end namespace nana 94 | 95 | -------------------------------------------------------------------------------- /source/gui/effects.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace nana 5 | { 6 | namespace effects 7 | { 8 | bground_interface::~bground_interface() 9 | {} 10 | 11 | bground_factory_interface::~bground_factory_interface() 12 | {} 13 | 14 | //Here defines some effect implementations. 15 | namespace impl 16 | { 17 | class transparent 18 | : public bground_interface 19 | { 20 | public: 21 | transparent(std::size_t percent) 22 | : fade_rate_( percent <= 100 ? double(percent) / 100.0 : 0) 23 | {} 24 | 25 | void take_effect(window wd, graph_reference graph) const 26 | { 27 | if(fade_rate_ < 0.001) 28 | return; 29 | graph.blend(::nana::rectangle{ graph.size() }, API::bgcolor(wd), fade_rate_); 30 | } 31 | private: 32 | const double fade_rate_; 33 | }; 34 | 35 | class blur 36 | : public bground_interface 37 | { 38 | public: 39 | blur(std::size_t radius) 40 | :radius_(radius) 41 | {} 42 | 43 | void take_effect(window, graph_reference graph) const 44 | { 45 | graph.blur(::nana::rectangle{ graph.size() }, radius_); 46 | } 47 | private: 48 | const std::size_t radius_; 49 | }; 50 | }//end namespace impl 51 | 52 | 53 | 54 | //class bground_transparent 55 | bground_transparent::bground_transparent(std::size_t percent) 56 | : percent_(percent) 57 | {} 58 | 59 | bground_interface* bground_transparent::create() const 60 | { 61 | return new impl::transparent(percent_); 62 | } 63 | //end class bgroun_transparent 64 | 65 | //class bground_blur 66 | bground_blur::bground_blur(std::size_t radius) 67 | : radius_(radius) 68 | {} 69 | 70 | bground_interface * bground_blur::create() const 71 | { 72 | return new impl::blur(radius_); 73 | } 74 | //end class bground_blur 75 | } 76 | }//end namespace nana -------------------------------------------------------------------------------- /source/gui/state_cursor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * State Cursor 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/state_cursor.cpp 11 | */ 12 | 13 | #include "detail/basic_window.hpp" 14 | #include 15 | #include 16 | #include 17 | 18 | namespace nana 19 | { 20 | state_cursor::state_cursor(window wd, cursor cur) 21 | : handle_(wd) 22 | { 23 | auto & brock = detail::bedrock::instance(); 24 | if (brock.wd_manager().available(wd)) 25 | brock.define_state_cursor(wd, cur, nullptr); 26 | else 27 | handle_ = nullptr; 28 | } 29 | 30 | state_cursor::state_cursor(state_cursor&& rhs) 31 | : handle_(rhs.handle_) 32 | { 33 | rhs.handle_ = nullptr; 34 | } 35 | 36 | state_cursor& state_cursor::operator = (state_cursor&& rhs) 37 | { 38 | if (this != &rhs) 39 | { 40 | if (handle_) 41 | { 42 | nana::internal_scope_guard lock; 43 | auto & brock = detail::bedrock::instance(); 44 | brock.undefine_state_cursor(handle_, nullptr); 45 | } 46 | handle_ = rhs.handle_; 47 | rhs.handle_ = nullptr; 48 | } 49 | return *this; 50 | } 51 | 52 | state_cursor::~state_cursor() 53 | { 54 | if (handle_) 55 | { 56 | nana::internal_scope_guard lock; 57 | auto & brock = detail::bedrock::instance(); 58 | brock.undefine_state_cursor(handle_, nullptr); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /source/gui/widgets/panel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A Panel Implementation 3 | * Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: source/gui/widgets/panel.cpp 10 | * 11 | * @brief: panel is a widget used for placing some widgets. 12 | */ 13 | 14 | #include 15 | 16 | namespace nana 17 | { 18 | namespace drawerbase 19 | { 20 | namespace panel 21 | { 22 | //class drawer 23 | void drawer::attached(widget_reference wdg, graph_reference) 24 | { 25 | wdg.caption("panel widget"); 26 | window_ = wdg.handle(); 27 | 28 | API::ignore_mouse_focus(wdg, true); 29 | 30 | } 31 | 32 | void drawer::refresh(graph_reference graph) 33 | { 34 | if (!API::dev::copy_transparent_background(window_, graph)) 35 | graph.rectangle(true, API::bgcolor(window_)); 36 | } 37 | //end class drawer 38 | }//end namespace panel 39 | 40 | }//end namespace drawerbase 41 | }//end namespace nana 42 | -------------------------------------------------------------------------------- /source/gui/widgets/skeletons/content_view.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * A Content View Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2017-2018 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/gui/widgets/skeletons/content_view.hpp 11 | * @author: Jinhao 12 | */ 13 | 14 | #ifndef NANA_WIDGETS_SKELETONS_CONTENT_VIEW_INCLUDED 15 | #define NANA_WIDGETS_SKELETONS_CONTENT_VIEW_INCLUDED 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | namespace nana 22 | { 23 | namespace paint 24 | { 25 | class graphics; 26 | } 27 | } 28 | 29 | namespace nana { namespace widgets { 30 | namespace skeletons 31 | { 32 | class content_view 33 | { 34 | struct implementation; 35 | 36 | content_view(const content_view&) = delete; 37 | content_view& operator=(const content_view&) = delete; 38 | 39 | content_view(content_view&&) = delete; 40 | content_view& operator=(content_view&&) = delete; 41 | public: 42 | using graph_reference = paint::graphics&; 43 | 44 | enum class scrolls 45 | { 46 | none, horz, vert, both 47 | }; 48 | 49 | struct events_type 50 | { 51 | ::std::function hover_outside; 52 | ::std::function scrolled; 53 | }; 54 | 55 | content_view(window handle); 56 | ~content_view(); 57 | 58 | events_type& events(); 59 | 60 | bool enable_scrolls(scrolls which); 61 | 62 | std::shared_ptr scroll_operation() const; 63 | 64 | void step(unsigned step_value, bool horz); 65 | bool scroll(bool forwards, bool horz); 66 | bool turn_page(bool forwards, bool horz); 67 | 68 | void disp_area(const rectangle& da, const point& skew_horz_bar, const point& skew_vert_bar, const size& extra_px, bool try_update = true); 69 | 70 | void content_size(const size& sz, bool try_update = true); 71 | const size& content_size() const; 72 | 73 | const point& origin() const; 74 | rectangle corner() const; 75 | void draw_corner(graph_reference); 76 | 77 | rectangle view_area() const; 78 | rectangle view_area(const size& alt_content_size) const; 79 | 80 | unsigned extra_space(bool horz) const; 81 | 82 | void change_position(int pos, bool aligned, bool horz); 83 | 84 | /// Returns true if the origin is moved 85 | bool move_origin(const point& skew); 86 | 87 | void sync(bool passive); 88 | 89 | void pursue(const point& cursor); 90 | 91 | void set_wheel_speed(std::function fn); 92 | 93 | static constexpr unsigned space() 94 | { 95 | return 16; 96 | } 97 | private: 98 | implementation* const impl_; 99 | }; 100 | } 101 | } 102 | } 103 | 104 | #endif -------------------------------------------------------------------------------- /source/gui/wvl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Nana GUI Library Definition 3 | * Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com) 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/gui/wvl.cpp 10 | * @description: 11 | * the file contains the files required for running of Nana.GUI 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef STD_THREAD_NOT_SUPPORTED 21 | # include 22 | #else 23 | # include 24 | #endif 25 | 26 | //#define NANA_AUTOMATIC_GUI_TESTING 27 | namespace nana 28 | { 29 | namespace detail 30 | { 31 | void form_loader_private::insert_form(::nana::widget* p) 32 | { 33 | bedrock::instance().manage_form_loader(p->handle(), true); 34 | } 35 | } 36 | 37 | #ifdef NANA_AUTOMATIC_GUI_TESTING 38 | 39 | void click(widget& w) 40 | { 41 | std::cout << "Automatically clicking widget "<f // = {} ///< emit events to mimics user actions and may assert results 70 | ) 71 | { 72 | 73 | std::cout << "Will wait " << wait << " sec...\n"; 74 | 75 | std::thread t([wait, &f, wait_end]() 76 | { 77 | Wait( wait ); 78 | std::cout << "running... \n" ; 79 | if (f) 80 | { 81 | f(); 82 | std::cout << "\nCongratulations, this was not trivial !" << std::endl; 83 | }else 84 | { 85 | std::cout << "\nJust a trivial test." << std::endl; 86 | } 87 | std::cout << "Done... \n"; 88 | std::cout << "Now again "; 89 | Wait(wait_end); 90 | std::cout << "Done... Now API::exit all ...\n"; 91 | API::exit_all(); 92 | }); 93 | 94 | pump(); 95 | if (t.joinable()) 96 | t.join(); 97 | } 98 | #else 99 | void exec() 100 | { 101 | internal_scope_guard lock; 102 | detail::bedrock::instance().pump_event(nullptr, false); 103 | } 104 | #endif 105 | }//end namespace nana 106 | -------------------------------------------------------------------------------- /source/paint/detail/image_ico_resource.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Icon Resource 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2017 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/paint/detail/image_ico_resource.hpp 11 | */ 12 | 13 | #ifndef NANA_PAINT_DETAIL_IMAGE_ICO_RESOURCE_INCLUDED 14 | #define NANA_PAINT_DETAIL_IMAGE_ICO_RESOURCE_INCLUDED 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #if defined(NANA_WINDOWS) 21 | # include 22 | #endif 23 | 24 | namespace nana{ namespace paint 25 | { 26 | namespace detail 27 | { 28 | class image_ico_resource 29 | :public image::image_impl_interface 30 | { 31 | public: 32 | bool open(const std::filesystem::path& filename) override 33 | { 34 | #if defined(NANA_WINDOWS) 35 | SHFILEINFO sfi; 36 | ::SHGetFileInfo(filename.c_str(), 0, &sfi, sizeof sfi, SHGFI_ICON); 37 | 38 | native_handle_ = sfi.hIcon; 39 | #else 40 | static_cast(filename); //eliminate unused parameter compiler warnings 41 | #endif 42 | return (nullptr != native_handle_); 43 | } 44 | 45 | bool open(const void* /*data*/, std::size_t /*bytes*/) override 46 | { 47 | return false; 48 | } 49 | 50 | bool alpha_channel() const override 51 | { 52 | return false; 53 | } 54 | 55 | bool empty() const override 56 | { 57 | return !native_handle_; 58 | } 59 | 60 | void close() override 61 | { 62 | #if defined(NANA_WINDOWS) 63 | if (native_handle_) 64 | ::DestroyIcon(reinterpret_cast(native_handle_)); 65 | #endif 66 | } 67 | 68 | nana::size size() const override 69 | { 70 | #if defined(NANA_WINDOWS) 71 | ICONINFO info; 72 | if ((!native_handle_) || !::GetIconInfo(reinterpret_cast(native_handle_), &info)) 73 | return{}; 74 | 75 | ::nana::size sz{ 76 | info.xHotspot << 1, 77 | info.yHotspot << 1 78 | }; 79 | 80 | ::DeleteObject(info.hbmColor); 81 | ::DeleteObject(info.hbmMask); 82 | return sz; 83 | #else 84 | return{}; 85 | #endif 86 | } 87 | 88 | virtual void paste(const nana::rectangle& src_r, graph_reference graph, const point& p_dst) const override 89 | { 90 | if (!native_handle_) 91 | return; 92 | 93 | #if defined(NANA_WINDOWS) 94 | ::DrawIconEx(graph.handle()->context, p_dst.x, p_dst.y, reinterpret_cast(native_handle_), src_r.width, src_r.height, 0, 0, DI_NORMAL); 95 | #else 96 | static_cast(src_r); //eliminate unused parameter compiler warning. 97 | static_cast(graph); 98 | static_cast(p_dst); 99 | #endif 100 | 101 | } 102 | 103 | virtual void stretch(const nana::rectangle&, graph_reference graph, const nana::rectangle& r) const override 104 | { 105 | if (!native_handle_) 106 | return; 107 | 108 | #if defined(NANA_WINDOWS) 109 | ::DrawIconEx(graph.handle()->context, r.x, r.y, reinterpret_cast(native_handle_), r.width, r.height, 0, 0, DI_NORMAL); 110 | #else 111 | static_cast(graph); //eliminate unused parameter compiler warning. 112 | static_cast(r); 113 | #endif 114 | } 115 | 116 | void* native_handle() 117 | { 118 | return native_handle_; 119 | } 120 | private: 121 | void* native_handle_; 122 | };//end class image_ico 123 | } 124 | }//end namespace paint 125 | }//end namespace nana 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /source/paint/detail/image_jpeg.hpp: -------------------------------------------------------------------------------- 1 | #ifndef NANA_PAINT_DETAIL_IMAGE_JPEG_HPP 2 | #define NANA_PAINT_DETAIL_IMAGE_JPEG_HPP 3 | 4 | #include "image_pixbuf.hpp" 5 | 6 | //Separate the libjpeg from the package that system provides. 7 | #if defined(NANA_LIBJPEG) 8 | #include 9 | #else 10 | #include 11 | #endif 12 | 13 | #include 14 | #include 15 | 16 | namespace nana 17 | { 18 | namespace paint{ namespace detail{ 19 | 20 | class image_jpeg 21 | : public basic_image_pixbuf 22 | { 23 | struct error_mgr 24 | { 25 | struct ::jpeg_error_mgr pub; 26 | std::jmp_buf setjmp_buf; 27 | }; 28 | 29 | void _m_read_jpg(jpeg_decompress_struct& jdstru) 30 | { 31 | ::jpeg_read_header(&jdstru, true); //Reject a tables-only JPEG file as an error 32 | 33 | ::jpeg_start_decompress(&jdstru); 34 | 35 | //JSAMPLEs per row in output buffer 36 | auto row_stride = jdstru.output_width * jdstru.output_components; 37 | 38 | pixbuf_.open(jdstru.output_width, jdstru.output_height); 39 | 40 | auto row_buf = jdstru.mem->alloc_sarray(reinterpret_cast(&jdstru), JPOOL_IMAGE, row_stride, 1); 41 | 42 | while (jdstru.output_scanline < jdstru.output_height) 43 | { 44 | ::jpeg_read_scanlines(&jdstru, row_buf, 1); 45 | 46 | pixbuf_.fill_row(jdstru.output_scanline - 1, reinterpret_cast(*row_buf), row_stride, jdstru.output_components * 8); 47 | } 48 | } 49 | public: 50 | bool open(const std::filesystem::path& jpeg_file) override 51 | { 52 | auto fp = ::fopen(to_osmbstr(to_utf8(jpeg_file.native())).c_str(), "rb"); 53 | if(nullptr == fp) return false; 54 | 55 | bool is_opened = false; 56 | 57 | struct ::jpeg_decompress_struct jdstru; 58 | error_mgr jerr; 59 | 60 | jdstru.err = ::jpeg_std_error(&jerr.pub); 61 | jerr.pub.error_exit = _m_error_handler; 62 | 63 | if (!setjmp(jerr.setjmp_buf)) 64 | { 65 | ::jpeg_create_decompress(&jdstru); 66 | 67 | ::jpeg_stdio_src(&jdstru, fp); 68 | 69 | _m_read_jpg(jdstru); 70 | 71 | jpeg_finish_decompress(&jdstru); 72 | is_opened = true; 73 | } 74 | 75 | ::jpeg_destroy_decompress(&jdstru); 76 | ::fclose(fp); 77 | return is_opened; 78 | } 79 | 80 | bool open(const void* data, std::size_t bytes) override 81 | { 82 | bool is_opened = false; 83 | 84 | struct ::jpeg_decompress_struct jdstru; 85 | error_mgr jerr; 86 | 87 | jdstru.err = ::jpeg_std_error(&jerr.pub); 88 | jerr.pub.error_exit = _m_error_handler; 89 | 90 | if (!setjmp(jerr.setjmp_buf)) 91 | { 92 | ::jpeg_create_decompress(&jdstru); 93 | 94 | ::jpeg_mem_src(&jdstru, const_cast(reinterpret_cast(data)), static_cast(bytes)); 95 | _m_read_jpg(jdstru); 96 | 97 | jpeg_finish_decompress(&jdstru); 98 | is_opened = true; 99 | } 100 | 101 | ::jpeg_destroy_decompress(&jdstru); 102 | return is_opened; 103 | } 104 | private: 105 | static void _m_error_handler(::j_common_ptr jdstru) 106 | { 107 | auto err_ptr = reinterpret_cast(jdstru->err); 108 | 109 | err_ptr->pub.output_message(jdstru); 110 | longjmp(err_ptr->setjmp_buf, 1); 111 | } 112 | }; 113 | }//end namespace detail 114 | }//end namespace paint 115 | }//end namespace nana 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /source/paint/detail/image_pixbuf.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Basic Image PixelBuffer Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/paint/detail/image_pixbuf.hpp 11 | */ 12 | 13 | #ifndef NANA_PAINT_DETAIL_IMAGE_PIXBUF_HPP 14 | #define NANA_PAINT_DETAIL_IMAGE_PIXBUF_HPP 15 | 16 | #include 17 | #include 18 | 19 | namespace nana 20 | { 21 | namespace paint{ namespace detail{ 22 | 23 | class basic_image_pixbuf 24 | : public image::image_impl_interface 25 | { 26 | public: 27 | bool alpha_channel() const override 28 | { 29 | return pixbuf_.alpha_channel(); 30 | } 31 | 32 | bool empty() const override 33 | { 34 | return pixbuf_.empty(); 35 | } 36 | 37 | void close() override 38 | { 39 | pixbuf_.close(); 40 | } 41 | 42 | ::nana::size size() const override 43 | { 44 | return pixbuf_.size(); 45 | } 46 | 47 | void paste(const ::nana::rectangle& src_r, graph_reference graph, const point& p_dst) const override 48 | { 49 | pixbuf_.paste(src_r, graph.handle(), p_dst); 50 | } 51 | 52 | void stretch(const ::nana::rectangle& src_r, graph_reference dst, const nana::rectangle& r) const override 53 | { 54 | pixbuf_.stretch(src_r, dst.handle(), r); 55 | } 56 | protected: 57 | pixel_buffer pixbuf_; 58 | }; 59 | }//end namespace detail 60 | }//end namespace paint 61 | }//end namespace nana 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /source/paint/detail/image_process_provider.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "image_processor.hpp" 5 | 6 | namespace nana 7 | { 8 | namespace paint 9 | { 10 | namespace detail 11 | { 12 | //class image_process_provider 13 | image_process_provider& image_process_provider::instance() 14 | { 15 | static image_process_provider obj; 16 | return obj; 17 | } 18 | 19 | image_process_provider::image_process_provider() 20 | { 21 | add(stretch_, "bilinear interpolation"); 22 | add(stretch_, "proximal interpolation"); 23 | add(alpha_blend_, "alpha_blend"); 24 | add(blend_, "blend"); 25 | add(line_, "bresenham_line"); 26 | add(blur_, "superfast_blur"); 27 | } 28 | 29 | image_process_provider::stretch_tag& image_process_provider::ref_stretch_tag() 30 | { 31 | return stretch_; 32 | } 33 | 34 | paint::image_process::stretch_interface * const * image_process_provider::stretch() const 35 | { 36 | return &stretch_.employee; 37 | } 38 | 39 | paint::image_process::stretch_interface * image_process_provider::ref_stretch(const std::string& name) const 40 | { 41 | return _m_read(stretch_, name); 42 | } 43 | 44 | //alpha_blend 45 | image_process_provider::alpha_blend_tag& image_process_provider::ref_alpha_blend_tag() 46 | { 47 | return alpha_blend_; 48 | } 49 | 50 | paint::image_process::alpha_blend_interface * const * image_process_provider::alpha_blend() const 51 | { 52 | return &alpha_blend_.employee; 53 | } 54 | 55 | paint::image_process::alpha_blend_interface * image_process_provider::ref_alpha_blend(const std::string& name) const 56 | { 57 | return _m_read(alpha_blend_, name); 58 | } 59 | 60 | //blend 61 | image_process_provider::blend_tag& image_process_provider::ref_blend_tag() 62 | { 63 | return blend_; 64 | } 65 | 66 | paint::image_process::blend_interface * const * image_process_provider::blend() const 67 | { 68 | return &blend_.employee; 69 | } 70 | 71 | paint::image_process::blend_interface * image_process_provider::ref_blend(const std::string& name) const 72 | { 73 | return _m_read(blend_, name); 74 | } 75 | 76 | //line 77 | image_process_provider::line_tag & image_process_provider::ref_line_tag() 78 | { 79 | return line_; 80 | } 81 | 82 | paint::image_process::line_interface * const * image_process_provider::line() const 83 | { 84 | return &line_.employee; 85 | } 86 | 87 | paint::image_process::line_interface * image_process_provider::ref_line(const std::string& name) const 88 | { 89 | return _m_read(line_, name); 90 | } 91 | 92 | //Blur 93 | image_process_provider::blur_tag & image_process_provider::ref_blur_tag() 94 | { 95 | return blur_; 96 | } 97 | 98 | paint::image_process::blur_interface * const * image_process_provider::blur() const 99 | { 100 | return &blur_.employee; 101 | } 102 | 103 | paint::image_process::blur_interface * image_process_provider::ref_blur(const std::string& name) const 104 | { 105 | return _m_read(blur_, name); 106 | } 107 | //end class image_process_provider 108 | } 109 | } 110 | }//end namespace nana 111 | -------------------------------------------------------------------------------- /source/paint/image_accessor.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Paint Image Accessor 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file nana/paint/image_accessor.hpp 11 | * @brief A declaration of class image_accessor. It is used to access image private data, internal use. 12 | */ 13 | #ifndef NANA_PAINT_IMAGE_ACCESS_HEADER_INCLUDED 14 | #define NANA_PAINT_IMAGE_ACCESS_HEADER_INCLUDED 15 | namespace nana 16 | { 17 | namespace paint 18 | { 19 | class image_accessor 20 | { 21 | public: 22 | #if defined(NANA_WINDOWS) 23 | static HICON icon(const image&); 24 | #else 25 | static int icon(const image&); 26 | #endif 27 | }; 28 | } 29 | } 30 | #endif -------------------------------------------------------------------------------- /source/paint/image_process_selector.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace nana 5 | { 6 | namespace paint 7 | { 8 | namespace image_process 9 | { 10 | //class selector 11 | void selector::stretch(const std::string& name) 12 | { 13 | detail::image_process_provider & p = detail::image_process_provider::instance(); 14 | p.set(p.ref_stretch_tag(), name); 15 | } 16 | 17 | void selector::alpha_blend(const std::string& name) 18 | { 19 | detail::image_process_provider & p = detail::image_process_provider::instance(); 20 | p.set(p.ref_alpha_blend_tag(), name); 21 | } 22 | 23 | void selector::blend(const std::string& name) 24 | { 25 | detail::image_process_provider & p = detail::image_process_provider::instance(); 26 | p.set(p.ref_blend_tag(), name); 27 | } 28 | 29 | void selector::line(const std::string& name) 30 | { 31 | detail::image_process_provider & p = detail::image_process_provider::instance(); 32 | p.set(p.ref_line_tag(), name); 33 | } 34 | 35 | void selector::blur(const std::string& name) 36 | { 37 | detail::image_process_provider & p = detail::image_process_provider::instance(); 38 | p.set(p.ref_blur_tag(), name); 39 | } 40 | //end class selector 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /source/system/shared_wrapper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Operation System Shared Linkage Library Wrapper Implementation 3 | * Copyright(C) 2003-2018 Jinhao 4 | * 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * @file: nana/system/shared_wrapper.cpp 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #if defined(NANA_POSIX) 16 | #include 17 | #else 18 | #include 19 | #endif 20 | 21 | namespace nana 22 | { 23 | namespace system 24 | { 25 | 26 | namespace detail 27 | { 28 | namespace shared_helper 29 | { 30 | 31 | module_t open(const char* filename) 32 | { 33 | #if defined(NANA_POSIX) 34 | return ::dlopen(filename, RTLD_LAZY); 35 | #else 36 | return ::LoadLibraryA(filename); 37 | #endif 38 | } 39 | 40 | void* symbols(module_t handle, const char* symbol) 41 | { 42 | #if defined(NANA_POSIX) 43 | return ::dlsym(handle, const_cast(symbol)); 44 | #else 45 | return (void*)(::GetProcAddress(reinterpret_cast(handle), symbol)); 46 | #endif 47 | } 48 | 49 | void close(module_t handle) 50 | { 51 | #if defined(NANA_POSIX) 52 | ::dlclose(handle); 53 | #else 54 | ::FreeLibrary(reinterpret_cast(handle)); 55 | #endif 56 | } 57 | } //end namespace shared_helper 58 | }//end namespace detail 59 | 60 | 61 | shared_wrapper::impl_type::impl_type() 62 | {} 63 | 64 | //class shared_wrapper 65 | shared_wrapper::shared_wrapper() 66 | {} 67 | 68 | shared_wrapper::shared_wrapper(const char* filename) 69 | { 70 | this->open(filename); 71 | } 72 | 73 | shared_wrapper::~shared_wrapper() 74 | { 75 | this->close(); 76 | } 77 | 78 | bool shared_wrapper::open(const char* filename) 79 | { 80 | this->close(); 81 | 82 | if(filename) 83 | { 84 | std::string file; 85 | std::string ofn = filename; 86 | std::string::size_type length = ofn.length(); 87 | 88 | if(length > 13) 89 | { 90 | std::transform(filename + length - 13, filename + length , std::back_inserter(file), tolower); 91 | if(file == ".nana_shared") 92 | { 93 | #if defined(NANA_POSIX) 94 | ofn.replace(length - 13, 13, ".so"); 95 | #else 96 | ofn.replace(length - 13, 13, ".DLL"); 97 | #endif 98 | filename = ofn.c_str(); 99 | } 100 | } 101 | 102 | impl_.handle = detail::shared_helper::open(filename); 103 | } 104 | 105 | return (impl_.handle != 0); 106 | } 107 | 108 | void shared_wrapper::close() 109 | { 110 | if(impl_.handle) 111 | { 112 | detail::shared_helper::close(impl_.handle); 113 | impl_.symbol = ""; 114 | impl_.proc_address = 0; 115 | impl_.handle = 0; 116 | } 117 | } 118 | 119 | bool shared_wrapper::empty() const 120 | { 121 | return (impl_.handle == 0); 122 | } 123 | //end class shared_wrapper 124 | }//end namespace system 125 | }//end namespace nana 126 | -------------------------------------------------------------------------------- /source/system/split_string.cpp: -------------------------------------------------------------------------------- 1 | #include "split_string.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | namespace nana 7 | { 8 | namespace system { 9 | std::vector split_string (const split_string_type& text, char sep) 10 | { 11 | std::vector retval; 12 | const auto estimated_size = std::count(text.begin(), text.end(), sep) + 1; 13 | retval.reserve(estimated_size); 14 | 15 | std::size_t sep_pos = 0; 16 | while (sep_pos != text.size()) { 17 | const std::size_t start = sep_pos; 18 | sep_pos = text.find(sep, sep_pos); 19 | sep_pos = (text.npos == sep_pos ? text.size() : sep_pos); 20 | const std::size_t end = sep_pos; 21 | while (sep_pos < text.size() and sep == text[sep_pos]) { 22 | ++sep_pos; 23 | } 24 | 25 | retval.push_back(text.substr(start, end - start)); 26 | } 27 | 28 | return retval; 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /source/system/split_string.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * The Deploy Implementation 3 | * Nana C++ Library(http://www.nanapro.org) 4 | * Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com) 5 | * 6 | * Distributed under the Boost Software License, Version 1.0. 7 | * (See accompanying file LICENSE_1_0.txt or copy at 8 | * http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | * @file: nana/system/split_string.hpp 11 | * 12 | * What follows is dependent on what defined in nana/config.hpp 13 | */ 14 | 15 | #ifndef NANA_SYSTEM_SPLITSTRING_HPP 16 | #define NANA_SYSTEM_SPLITSTRING_HPP 17 | 18 | #include 19 | #include 20 | #ifdef _nana_std_has_string_view 21 | # include 22 | #else 23 | # include 24 | #endif 25 | 26 | namespace nana 27 | { 28 | namespace system 29 | { 30 | #ifdef _nana_std_has_string_view 31 | typedef std::string_view split_string_type; 32 | #else 33 | typedef std::string split_string_type; 34 | #endif 35 | 36 | std::vector split_string (const split_string_type& text, char sep); 37 | 38 | } 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /source/system/timepiece.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #ifdef NANA_WINDOWS 4 | #include 5 | #elif defined(NANA_POSIX) 6 | #include 7 | #endif 8 | 9 | namespace nana 10 | { 11 | namespace system 12 | { 13 | //class timepiece 14 | struct timepiece::impl_t 15 | { 16 | #if defined(NANA_WINDOWS) 17 | LARGE_INTEGER beg_timestamp; 18 | #elif defined(NANA_POSIX) 19 | struct timeval beg_timestamp; 20 | #endif 21 | }; 22 | 23 | timepiece::timepiece() 24 | : impl_(new impl_t) 25 | {} 26 | 27 | timepiece::timepiece(const timepiece& rhs) 28 | : impl_(new impl_t(*rhs.impl_)) 29 | {} 30 | 31 | timepiece::~timepiece() 32 | { 33 | delete impl_; 34 | } 35 | 36 | timepiece & timepiece::operator=(const timepiece & rhs) 37 | { 38 | if(this != &rhs) 39 | *impl_ = *rhs.impl_; 40 | 41 | return *this; 42 | } 43 | 44 | void timepiece::start() noexcept 45 | { 46 | #if defined(NANA_WINDOWS) 47 | ::QueryPerformanceCounter(&impl_->beg_timestamp); 48 | #elif defined(NANA_POSIX) 49 | struct timezone tz; 50 | ::gettimeofday(&impl_->beg_timestamp, &tz); 51 | #endif 52 | } 53 | 54 | double timepiece::calc() const noexcept 55 | { 56 | #if defined(NANA_WINDOWS) 57 | LARGE_INTEGER li; 58 | ::QueryPerformanceCounter(&li); 59 | 60 | __int64 diff = li.QuadPart - impl_->beg_timestamp.QuadPart; 61 | 62 | LARGE_INTEGER freq; 63 | ::QueryPerformanceFrequency(&freq); 64 | 65 | return double(diff)/double(freq.QuadPart) * 1000; 66 | #elif defined(NANA_POSIX) 67 | struct timeval tv; 68 | struct timezone tz; 69 | gettimeofday(&tv, &tz); 70 | return static_cast(tv.tv_sec - impl_->beg_timestamp.tv_sec) * 1000 + static_cast(tv.tv_usec - impl_->beg_timestamp.tv_usec) / 1000; 71 | #endif 72 | } 73 | //end class timepiece 74 | 75 | }//end namespace system 76 | }//end namespace nana 77 | --------------------------------------------------------------------------------