Merge branch 'develop'

This commit is contained in:
Jinhao 2017-07-27 02:51:53 +08:00
commit 3a45ecaefb
29 changed files with 785 additions and 2351 deletions

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@
<ProjectGuid>{42D0520F-EFA5-4831-84FE-2B9085301C5D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>nana</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -163,6 +163,8 @@
<ClCompile Include="..\..\source\detail\platform_abstraction.cpp" />
<ClCompile Include="..\..\source\detail\platform_spec_windows.cpp" />
<ClCompile Include="..\..\source\filesystem\filesystem.cpp" />
<ClCompile Include="..\..\source\gui\animation.cpp" />
<ClCompile Include="..\..\source\gui\basis.cpp" />
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp" />
<ClCompile Include="..\..\source\gui\detail\bedrock_pi.cpp" />
<ClCompile Include="..\..\source\gui\detail\bedrock_windows.cpp" />
@ -173,6 +175,20 @@
<ClCompile Include="..\..\source\gui\detail\native_window_interface.cpp" />
<ClCompile Include="..\..\source\gui\detail\window_layout.cpp" />
<ClCompile Include="..\..\source\gui\detail\window_manager.cpp" />
<ClCompile Include="..\..\source\gui\dragger.cpp" />
<ClCompile Include="..\..\source\gui\drawing.cpp" />
<ClCompile Include="..\..\source\gui\effects.cpp" />
<ClCompile Include="..\..\source\gui\element.cpp" />
<ClCompile Include="..\..\source\gui\filebox.cpp" />
<ClCompile Include="..\..\source\gui\layout_utility.cpp" />
<ClCompile Include="..\..\source\gui\msgbox.cpp" />
<ClCompile Include="..\..\source\gui\notifier.cpp" />
<ClCompile Include="..\..\source\gui\place.cpp" />
<ClCompile Include="..\..\source\gui\programming_interface.cpp" />
<ClCompile Include="..\..\source\gui\screen.cpp" />
<ClCompile Include="..\..\source\gui\state_cursor.cpp" />
<ClCompile Include="..\..\source\gui\timer.cpp" />
<ClCompile Include="..\..\source\gui\tooltip.cpp" />
<ClCompile Include="..\..\source\gui\widgets\button.cpp" />
<ClCompile Include="..\..\source\gui\widgets\categorize.cpp" />
<ClCompile Include="..\..\source\gui\widgets\checkbox.cpp" />
@ -199,6 +215,7 @@
<ClCompile Include="..\..\source\gui\widgets\toolbar.cpp" />
<ClCompile Include="..\..\source\gui\widgets\treebox.cpp" />
<ClCompile Include="..\..\source\gui\widgets\widget.cpp" />
<ClCompile Include="..\..\source\gui\wvl.cpp" />
<ClCompile Include="..\..\source\internationalization.cpp" />
<ClCompile Include="..\..\source\paint\detail\image_process_provider.cpp" />
<ClCompile Include="..\..\source\paint\detail\native_paint_interface.cpp" />

View File

@ -1,244 +1,287 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<Filter Include="Sources">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="源文件\audio">
<Filter Include="Sources\audio">
<UniqueIdentifier>{81850bad-7436-405a-beb5-357c5e34f039}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\audio\detail">
<Filter Include="Sources\audio\detail">
<UniqueIdentifier>{44582b36-4575-4663-ac02-e80417f95d05}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\detail">
<Filter Include="Sources\detail">
<UniqueIdentifier>{b7e3cdb7-99ac-473d-86c8-53dddce70480}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\filesystem">
<Filter Include="Sources\filesystem">
<UniqueIdentifier>{02fa693c-edc1-4e04-bf1d-ec3c2a89182a}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\gui">
<Filter Include="Sources\gui">
<UniqueIdentifier>{cffe7506-b96c-42aa-a747-41b5115d9580}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\gui\detail">
<Filter Include="Sources\gui\detail">
<UniqueIdentifier>{b6b2c032-c6a4-4884-8c14-eca4aa69ef0c}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\gui\widgets">
<Filter Include="Sources\gui\widgets">
<UniqueIdentifier>{58f2e0f8-4d63-40db-807d-d7adf71c4ebe}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\gui\widgets\skeletons">
<Filter Include="Sources\gui\widgets\skeletons">
<UniqueIdentifier>{f288a25d-3ce8-4c2e-a86f-9aeda44bc557}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\paint">
<Filter Include="Sources\paint">
<UniqueIdentifier>{90b2da01-605d-489b-b6c5-2af8d3c2d8a6}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\paint\detail">
<Filter Include="Sources\paint\detail">
<UniqueIdentifier>{430feed0-e1d9-45cb-8d59-e1a48a04d19f}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\system">
<Filter Include="Sources\system">
<UniqueIdentifier>{dcf62634-a658-453b-a58d-f1a96a12a8b8}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\threads">
<Filter Include="Sources\threads">
<UniqueIdentifier>{c1cdf46a-519f-422a-947f-39e173045414}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\source\any.cpp">
<Filter>源文件</Filter>
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="..\..\source\basic_types.cpp">
<Filter>源文件</Filter>
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="..\..\source\charset.cpp">
<Filter>源文件</Filter>
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="..\..\source\datetime.cpp">
<Filter>源文件</Filter>
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="..\..\source\deploy.cpp">
<Filter>源文件</Filter>
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="..\..\source\internationalization.cpp">
<Filter>源文件</Filter>
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="..\..\source\stdc++.cpp">
<Filter>源文件</Filter>
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="..\..\source\unicode_bidi.cpp">
<Filter>源文件</Filter>
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="..\..\source\audio\detail\audio_device.cpp">
<Filter>源文件\audio\detail</Filter>
<Filter>Sources\audio\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\audio\detail\audio_stream.cpp">
<Filter>源文件\audio\detail</Filter>
<Filter>Sources\audio\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\audio\detail\buffer_preparation.cpp">
<Filter>源文件\audio\detail</Filter>
<Filter>Sources\audio\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\audio\player.cpp">
<Filter>源文件\audio</Filter>
<Filter>Sources\audio</Filter>
</ClCompile>
<ClCompile Include="..\..\source\detail\platform_spec_windows.cpp">
<Filter>源文件\detail</Filter>
<Filter>Sources\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\filesystem\filesystem.cpp">
<Filter>源文件\filesystem</Filter>
<Filter>Sources\filesystem</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp">
<Filter>源文件\gui\detail</Filter>
<Filter>Sources\gui\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\detail\bedrock_pi.cpp">
<Filter>源文件\gui\detail</Filter>
<Filter>Sources\gui\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\detail\bedrock_windows.cpp">
<Filter>源文件\gui\detail</Filter>
<Filter>Sources\gui\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\detail\color_schemes.cpp">
<Filter>源文件\gui\detail</Filter>
<Filter>Sources\gui\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\detail\drawer.cpp">
<Filter>源文件\gui\detail</Filter>
<Filter>Sources\gui\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\detail\element_store.cpp">
<Filter>源文件\gui\detail</Filter>
<Filter>Sources\gui\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\detail\events_operation.cpp">
<Filter>源文件\gui\detail</Filter>
<Filter>Sources\gui\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\detail\native_window_interface.cpp">
<Filter>源文件\gui\detail</Filter>
<Filter>Sources\gui\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\detail\window_layout.cpp">
<Filter>源文件\gui\detail</Filter>
<Filter>Sources\gui\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\detail\window_manager.cpp">
<Filter>源文件\gui\detail</Filter>
<Filter>Sources\gui\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\skeletons\content_view.cpp">
<Filter>源文件\gui\widgets\skeletons</Filter>
<Filter>Sources\gui\widgets\skeletons</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\skeletons\text_editor.cpp">
<Filter>源文件\gui\widgets\skeletons</Filter>
<Filter>Sources\gui\widgets\skeletons</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\button.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\categorize.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\checkbox.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\combox.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\date_chooser.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\float_listbox.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\form.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\frame.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\group.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\label.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\listbox.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\menu.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\menubar.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\panel.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\picture.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\progress.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\scroll.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\slider.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\spinbox.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\tabbar.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\textbox.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\toolbar.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\treebox.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\widgets\widget.cpp">
<Filter>源文件\gui\widgets</Filter>
<Filter>Sources\gui\widgets</Filter>
</ClCompile>
<ClCompile Include="..\..\source\paint\detail\image_process_provider.cpp">
<Filter>源文件\paint\detail</Filter>
<Filter>Sources\paint\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\paint\detail\native_paint_interface.cpp">
<Filter>源文件\paint\detail</Filter>
<Filter>Sources\paint\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\paint\graphics.cpp">
<Filter>源文件\paint</Filter>
<Filter>Sources\paint</Filter>
</ClCompile>
<ClCompile Include="..\..\source\paint\image.cpp">
<Filter>源文件\paint</Filter>
<Filter>Sources\paint</Filter>
</ClCompile>
<ClCompile Include="..\..\source\paint\image_process_selector.cpp">
<Filter>源文件\paint</Filter>
<Filter>Sources\paint</Filter>
</ClCompile>
<ClCompile Include="..\..\source\paint\pixel_buffer.cpp">
<Filter>源文件\paint</Filter>
<Filter>Sources\paint</Filter>
</ClCompile>
<ClCompile Include="..\..\source\paint\text_renderer.cpp">
<Filter>源文件\paint</Filter>
<Filter>Sources\paint</Filter>
</ClCompile>
<ClCompile Include="..\..\source\system\dataexch.cpp">
<Filter>源文件\system</Filter>
<Filter>Sources\system</Filter>
</ClCompile>
<ClCompile Include="..\..\source\system\platform.cpp">
<Filter>源文件\system</Filter>
<Filter>Sources\system</Filter>
</ClCompile>
<ClCompile Include="..\..\source\system\shared_wrapper.cpp">
<Filter>源文件\system</Filter>
<Filter>Sources\system</Filter>
</ClCompile>
<ClCompile Include="..\..\source\system\timepiece.cpp">
<Filter>源文件\system</Filter>
<Filter>Sources\system</Filter>
</ClCompile>
<ClCompile Include="..\..\source\threads\pool.cpp">
<Filter>源文件\threads</Filter>
<Filter>Sources\threads</Filter>
</ClCompile>
<ClCompile Include="..\..\source\detail\platform_abstraction.cpp">
<Filter>源文件\detail</Filter>
<Filter>Sources\detail</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\animation.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\basis.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\dragger.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\drawing.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\effects.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\element.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\filebox.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\layout_utility.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\msgbox.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\notifier.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\place.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\programming_interface.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\screen.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\state_cursor.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\timer.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\tooltip.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
<ClCompile Include="..\..\source\gui\wvl.cpp">
<Filter>Sources\gui</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -36,7 +36,7 @@
* - STD_TO_STRING_NOT_SUPPORTED (MinGW with GCC < 4.8)
* - STD_FILESYSTEM_NOT_SUPPORTED (GCC < 5.3) ....
* - CXX_NO_INLINE_NAMESPACE (Visual C++ < 2015)
* - _enable_std_make_unique (GCC < 4.9)
* - _enable_std_make_unique (__cpluscplus < 201402)
* - _enable_std_put_time (GCC < 5)
* - _enable_std_clamp (Visual C++ < 2017)
*/
@ -118,13 +118,6 @@
#if defined(__GLIBCPP__) || defined(__GLIBCXX__)
//<codecvt> is a known issue on libstdc++, it works on libc++
#define STD_CODECVT_NOT_SUPPORTED
#if !defined(__cpp_lib_make_unique) || (__cpp_lib_make_unique != 201304)
#ifndef _enable_std_make_unique
#define _enable_std_make_unique
#endif
#endif
#endif
#elif defined(__GNUC__) //GCC
@ -149,20 +142,15 @@
# define _enable_std_put_time
# endif
#if ((__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3 ) ) )
# undef STD_FILESYSTEM_NOT_SUPPORTED
/// \todo define the namespace ????
#endif
# if ((__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3 ) ) )
# undef STD_FILESYSTEM_NOT_SUPPORTED
# endif
#if (__GNUC__ == 4)
#if ((__GNUC_MINOR__ < 8) || (__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 1))
#define STD_THREAD_NOT_SUPPORTED
#endif
#if (__GNUC_MINOR__ < 9)
#define _enable_std_make_unique
#endif
#if defined(NANA_MINGW)
#ifndef __MINGW64_VERSION_MAJOR
//It's a knonwn issue under MinGW(except MinGW-W64)
@ -191,20 +179,23 @@
# endif
#endif
//Detects the feature std::make_unique
//std::make_unique has been provided by Visual C++ 2013 and later
#undef _enable_std_make_unique
#if (defined(__clang__) && (__cplusplus < 201305L || (__cplusplus == 201305L && (__clang_major__ * 100 + __clang_minor__ < 304 )))) \
|| ((!defined(__clang__)) && defined(__GNUC__) && __cplusplus < 201300L)
# define _enable_std_make_unique
#endif
//Detects the feature std::clamp
//Visual C++ 2017 with /std:c++latest provides the std::clamp
#if !defined(_MSVC_LANG) || (_MSVC_LANG < 201403L)
// std::clamp's feature test macro is defined inside <algorithm>
// But nana still avoids introducing <algorithm> on MSVC.
# ifndef _MSC_VER
# include <algorithm>
# endif
# if ((!defined(__cpp_lib_clamp)) || (__cpp_lib_clamp < 201603)) && (!defined(_enable_std_clamp))
# define _enable_std_clamp
# endif
#undef _enable_std_clamp
#if (defined(_MSC_VER) && ((!defined(_MSVC_LANG)) || _MSVC_LANG < 201403L)) \
|| (defined(__clang__) && (__cplusplus < 201406L)) \
|| (defined(__GNUC__) && (!defined(__clang__)) && (__cplusplus < 201703))
# define _enable_std_clamp
#endif

View File

@ -65,14 +65,14 @@ namespace std {
} // std
#else
#undef NANA_USING_STD_FILESYSTEM
#define NANA_USING_STD_FILESYSTEM 1
# include <experimental/filesystem>
# undef NANA_USING_STD_FILESYSTEM
# define NANA_USING_STD_FILESYSTEM 1
# include <experimental/filesystem>
#endif
#ifndef __cpp_lib_experimental_filesystem
# define __cpp_lib_experimental_filesystem 1
# define __cpp_lib_experimental_filesystem 201406
#endif
#if NANA_USING_NANA_FILESYSTEM

View File

@ -1,6 +1,6 @@
/*
* Window Layout Implementation
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@ -72,9 +72,17 @@ namespace detail
static void make_bground(core_window_t* const);
private:
//_m_paste_children
//@brief:paste children window to the root graphics directly. just paste the visual rectangle
static void _m_paste_children(core_window_t*, bool have_refreshed, bool request_refresh_children, const nana::rectangle& parent_rect, nana::paint::graphics& graph, const nana::point& graph_rpos);
/// _m_paste_children
/**
* Pastes children window to the root graphics directly. just paste the visual rectangle
* @param window A handle to the window whose child windows will be pasted to the graph.
* @param has_refreshed Indicates whethere the window has been refreshed.
* @param request_refresh_children A flag indicates whether to refresh its child windows.
* @param parent_rect The child windows which are overlapped with the rectangle will be pasted
* @param graph A graphics object to which the child windows are pasted.
* @param graph_rpos The reference point to the graph.
*/
static void _m_paste_children(core_window_t* window, bool has_refreshed, bool request_refresh_children, const nana::rectangle& parent_rect, nana::paint::graphics& graph, const nana::point& graph_rpos);
static void _m_paint_glass_window(core_window_t*, bool is_redraw, bool is_child_refreshed, bool called_by_notify, bool notify_other);

View File

@ -1,7 +1,7 @@
/*
* A Message Box Class
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@ -109,6 +109,24 @@ namespace nana
virtual unsigned fixed_pixels() const;
};
public:
class boolean
: public abstract_content
{
struct implement;
public:
boolean(::std::string label, bool initial_value);
~boolean();
bool value() const;
private:
//Implementation of abstract_content
const ::std::string& label() const override;
window create(window, unsigned label_px) override;
unsigned fixed_pixels() const override;
private:
std::unique_ptr<implement> impl_;
};
class integer
: public abstract_content
{
@ -122,6 +140,7 @@ namespace nana
//Implementation of abstract_content
const ::std::string& label() const override;
window create(window, unsigned label_px) override;
unsigned fixed_pixels() const override;
private:
std::unique_ptr<implement> impl_;
};
@ -139,6 +158,7 @@ namespace nana
//Implementation of abstract_content
const ::std::string& label() const override;
window create(window, unsigned label_px) override;
unsigned fixed_pixels() const override;
private:
std::unique_ptr<implement> impl_;
};
@ -166,6 +186,7 @@ namespace nana
//Implementation of abstract_content
const ::std::string& label() const override;
window create(window, unsigned label_px) override;
unsigned fixed_pixels() const override;
private:
std::unique_ptr<implement> impl_;
};

View File

@ -1052,6 +1052,19 @@ namespace nana
cat_proxy & select(bool);
bool selected() const;
/// Enables/disables the number of items in the category to be displayed behind the category title
cat_proxy& display_number(bool display);
/// Determines whether the category is expanded.
bool expanded() const;
/// Expands/collapses the category
/**
* @param expand Indicates whether to expand or collapse the category. If this parameter is true, it expands the category. If the parameter is false, it collapses the category.
* @return the reference of *this.
*/
cat_proxy& expanded(bool expand);
/// Behavior of a container
void push_back(std::string text_utf8);
@ -1484,6 +1497,22 @@ the nana::detail::basic_window member pointer scheme
void enable_single(bool for_selection, bool category_limited);
void disable_single(bool for_selection);
export_options& def_export_options();
/// Sets a renderer for category icon
/**
* @param icon_renderer The renderer of category icon
* @return the reference of *this.
*/
listbox& category_icon(std::function<void(paint::graphics& graph, const rectangle& rt_icon, bool expanded)> icon_renderer);
/// Sets category icons
/**
* @param img_expanded An icon displayed in front of category title when the category is expanded.
* @param img_collapsed An icon displayed in front of category title when the category is collapsed.
* @return the reference of *this.
*/
listbox& category_icon(const paint::image& img_expanded, const paint::image&& img_collapsed);
private:
drawerbase::listbox::essence & _m_ess() const;
nana::any* _m_anyobj(size_type cat, size_type index, bool allocate_if_empty) const override;

View File

@ -86,6 +86,7 @@ namespace nana{ namespace widgets
~text_editor();
size caret_size() const;
const point& content_origin() const;
void set_highlight(const ::std::string& name, const ::nana::color&, const ::nana::color&);
void erase_highlight(const ::std::string& name);
@ -149,12 +150,13 @@ namespace nana{ namespace widgets
void text(std::wstring, bool end_caret);
std::wstring text() const;
/// Sets caret position through text coordinate.
/// Moves the caret at specified position
/**
* @param pos the text position
* @param reset indicates whether to reset the text position by the pos. If this parameter is true, the text position is set by pos. If the parameter is false, it only moves the UI caret to the specified position.
* @param stay_in_view Indicates whether to adjust the view to make the caret in view. This parameter is ignored if the caret is already in view.
* @return true indicates a refresh is required.
*/
bool move_caret(const upoint& pos, bool reset = false);
bool move_caret(upoint pos, bool stay_in_view = false);
void move_caret_end(bool update);
void reset_caret_pixels() const;
void reset_caret(bool stay_in_view = false);
@ -211,6 +213,7 @@ namespace nana{ namespace widgets
bool mouse_enter(bool entering);
bool mouse_move(bool left_button, const point& screen_pos);
void mouse_pressed(const arg_mouse& arg);
bool select_word(const arg_mouse& arg);
skeletons::textbase<char_type>& textbase();
const skeletons::textbase<char_type>& textbase() const;

View File

@ -80,6 +80,7 @@ namespace nana
void mouse_up(graph_reference, const arg_mouse&) override;
void mouse_enter(graph_reference, const arg_mouse&) override;
void mouse_leave(graph_reference, const arg_mouse&) override;
void dbl_click(graph_reference, const arg_mouse&) override;
void key_press(graph_reference, const arg_keyboard&)override;
void key_char(graph_reference, const arg_keyboard&) override;
void mouse_wheel(graph_reference, const arg_wheel&) override;
@ -139,6 +140,8 @@ namespace nana
colored_area_access_interface* colored_area_access();
point content_origin() const;
/// Enables/disables the textbox to indent a line. Idents a new line when it is created by pressing enter.
/// @param generator generates text for identing a line. If it is empty, textbox indents the line according to last line.
textbox& indention(bool, std::function<std::string()> generator = {});
@ -174,6 +177,9 @@ namespace nana
/// Returns true if the caret is in the area of display, false otherwise.
bool caret_pos(point& pos, bool text_coordinate) const;
/// Gets the caret position, in text coordinate
upoint caret_pos() const;
/// Sets the caret position with a text position
textbox& caret_pos(const upoint&);

View File

@ -94,6 +94,7 @@ namespace nana
void enable(size_type index, bool enable_state);
void scale(unsigned s); ///< Sets the scale of control button.
/// Enable to place buttons at right part. After calling it, every new button is right aligned.
void go_right();
bool detached() { return detached_; };

View File

@ -140,6 +140,7 @@ namespace nana
private:
//Overrides drawer_trigger methods
void attached(widget_reference, graph_reference) override;
void detached() override;
void refresh(graph_reference) override;
void dbl_click(graph_reference, const arg_mouse&) override;
void mouse_down(graph_reference, const arg_mouse&) override;

View File

@ -91,7 +91,11 @@ namespace nana
const void* pixmap() const;
const void* context() const;
void make(const ::nana::size&); ///< Creates a bitmap resource that size is width by height in pixel
/// Creates a graphics/drawable resource
/**
* @param sz The dimension of the graphics to be requested. If sz is empty, it performs as release().
*/
void make(const ::nana::size& sz);
void resize(const ::nana::size&);
void typeface(const font&); ///< Selects a specified font type into the graphics object.
font typeface() const;

View File

@ -3,6 +3,11 @@
#include "../paint/truetype.hpp"
#ifdef NANA_WINDOWS
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif
# include <windows.h>
///////////////////////////////////////////////////////////////////////////////////////////////////////
@ -50,6 +55,19 @@ IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServiceP
return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
}
#ifndef _WIN32_WINNT_WINXP
# define _WIN32_WINNT_WINXP 0x0501
#endif // _WIN32_WINNT_WINXP
#ifndef _WIN32_WINNT_VISTA
# define _WIN32_WINNT_VISTA 0x0600
#endif // _WIN32_WINNT_VISTA
#ifndef _WIN32_WINNT_WIN7
# define _WIN32_WINNT_WIN7 0x0601
#endif // _WIN32_WINNT_WIN7
VERSIONHELPERAPI
IsWindowsXPOrGreater()
{
@ -119,20 +137,6 @@ IsWindows8OrGreater()
#define _WIN32_WINNT_WINBLUE (0x0602)
#endif // _WIN32_WINNT_WINBLUE (0x0602)
VERSIONHELPERAPI
IsWindows8Point1OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), LOBYTE(_WIN32_WINNT_WINBLUE), 0);
}
VERSIONHELPERAPI
IsWindowsServer()
{
OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, { 0 }, 0, 0, 0, VER_NT_WORKSTATION };
DWORDLONG const dwlConditionMask = VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL);
return !VerifyVersionInfoW(&osvi, VER_PRODUCT_TYPE, dwlConditionMask);
}
#endif // NTDDI_VERSION

View File

@ -24,170 +24,6 @@
#include <shellapi.h>
///////////////////////////////////////////////////////////////////////////////////////////////////////
/******************************************************************
* *
* VersionHelpers.h -- This module defines helper functions to *
* promote version check with proper *
* comparisons. *
* *
* Copyright (c) Microsoft Corp. All rights reserved. *
* *
******************************************************************/
#include <specstrings.h> // for _In_, etc.
#if !defined(__midl) && !defined(SORTPP_PASS)
#if (NTDDI_VERSION >= NTDDI_WINXP)
#ifdef __cplusplus
#define VERSIONHELPERAPI inline bool
#else // __cplusplus
#define VERSIONHELPERAPI FORCEINLINE BOOL
#endif // __cplusplus
VERSIONHELPERAPI
IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
{
OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0,{ 0 }, 0, 0 };
DWORDLONG const dwlConditionMask = VerSetConditionMask(
VerSetConditionMask(
VerSetConditionMask(
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
VER_MINORVERSION, VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
osvi.dwMajorVersion = wMajorVersion;
osvi.dwMinorVersion = wMinorVersion;
osvi.wServicePackMajor = wServicePackMajor;
return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
}
VERSIONHELPERAPI
IsWindowsXPOrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0);
}
VERSIONHELPERAPI
IsWindowsXPSP1OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 1);
}
VERSIONHELPERAPI
IsWindowsXPSP2OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 2);
}
VERSIONHELPERAPI
IsWindowsXPSP3OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 3);
}
VERSIONHELPERAPI
IsWindowsVistaOrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0);
}
VERSIONHELPERAPI
IsWindowsVistaSP1OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 1);
}
VERSIONHELPERAPI
IsWindowsVistaSP2OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 2);
}
VERSIONHELPERAPI
IsWindows7OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0);
}
VERSIONHELPERAPI
IsWindows7SP1OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 1);
}
#ifndef _WIN32_WINNT_WIN8 // (0x0602)
#define _WIN32_WINNT_WIN8 (0x0602)
#endif // _WIN32_WINNT_WIN8(0x0602)
VERSIONHELPERAPI
IsWindows8OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0);
}
#ifndef _WIN32_WINNT_WINBLUE // (0x0602)
#define _WIN32_WINNT_WINBLUE (0x0602)
#endif // _WIN32_WINNT_WINBLUE (0x0602)
VERSIONHELPERAPI
IsWindows8Point1OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), LOBYTE(_WIN32_WINNT_WINBLUE), 0);
}
VERSIONHELPERAPI
IsWindowsServer()
{
OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0,{ 0 }, 0, 0, 0, VER_NT_WORKSTATION };
DWORDLONG const dwlConditionMask = VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL);
return !VerifyVersionInfoW(&osvi, VER_PRODUCT_TYPE, dwlConditionMask);
}
#endif // NTDDI_VERSION
#endif // defined(__midl)
////////////////////////////////////////////////////////////////////////////////////////////////////
//#if defined(_MSC_VER)
////#include <VersionHelpers.h>
//bool IsWindowsVistaOrGreater() { return false; }
//bool //VERSIONHELPERAPI
//IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
//{
// OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0,{ 0 }, 0, 0 };
// DWORDLONG const dwlConditionMask = VerSetConditionMask(
// VerSetConditionMask(
// VerSetConditionMask(
// 0, VER_MAJORVERSION, VER_GREATER_EQUAL),
// VER_MINORVERSION, VER_GREATER_EQUAL),
// VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
//
// osvi.dwMajorVersion = wMajorVersion;
// osvi.dwMinorVersion = wMinorVersion;
// osvi.wServicePackMajor = wServicePackMajor;
//
// return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
//}
//
//
//
//#endif // _MSVC
namespace nana
{

View File

@ -1,7 +1,7 @@
/*
* Window Layout Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@ -266,8 +266,6 @@ namespace nana
wd->effect.bground->take_effect(reinterpret_cast<window>(wd), glass_buffer);
}
//_m_paste_children
//@brief:paste children window to the root graphics directly. just paste the visual rectangle
void window_layout::_m_paste_children(core_window_t* wd, bool have_refreshed, bool req_refresh_children, const nana::rectangle& parent_rect, nana::paint::graphics& graph, const nana::point& graph_rpos)
{
nana::rectangle rect;
@ -287,12 +285,10 @@ namespace nana
{
if (overlap(nana::rectangle{ child->pos_root, child->dimension }, parent_rect, rect))
{
bool have_child_refreshed = false;
if (category::flags::lite_widget != child->other.category)
{
if (req_refresh_children && (false == child->flags.refreshing))
{
have_child_refreshed = true;
child->flags.refreshing = true;
child->drawer.refresh();
child->flags.refreshing = false;
@ -301,7 +297,9 @@ namespace nana
graph.bitblt(nana::rectangle(rect.x - graph_rpos.x, rect.y - graph_rpos.y, rect.width, rect.height),
child->drawer.graphics, nana::point(rect.x - child->pos_root.x, rect.y - child->pos_root.y));
}
_m_paste_children(child, req_refresh_children, have_child_refreshed, rect, graph, graph_rpos);
//req_refresh_children determines whether the child has been refreshed, and also determines whether
//the children of child to be refreshed.
_m_paste_children(child, req_refresh_children, req_refresh_children, rect, graph, graph_rpos);
}
}
else

View File

@ -1,7 +1,7 @@
/*
* A Message Box Class
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@ -14,11 +14,11 @@
#include <nana/gui/widgets/label.hpp>
#include <nana/gui/widgets/button.hpp>
#include <nana/gui/widgets/spinbox.hpp>
#include <nana/gui/widgets/checkbox.hpp>
#include <nana/gui/widgets/combox.hpp>
#include <nana/gui/widgets/textbox.hpp>
#include <nana/gui/widgets/panel.hpp>
#include <nana/gui/widgets/picture.hpp>
#include <nana/gui/place.hpp>
#include <nana/datetime.hpp>
#include <nana/internationalization.hpp>
#include <nana/gui/filebox.hpp>
@ -511,7 +511,6 @@ namespace nana
unsigned height = 20 + desc_extent.height + 10 + 38;
place_.bind(*this);
std::stringstream ss_content;
ss_content << "<margin=10 vert <desc weight=" << desc_extent.height << "><vert margin=[10]";
@ -521,15 +520,15 @@ namespace nana
if (each_height[i] > 27)
px = each_height[i];
ss_content << "<weight=" << px << " margin=[3] input_" << i << ">";
ss_content << "<weight=" << (px + 3) << " margin=[3] input_" << i << ">";
height += px + 1;
}
ss_content << "><margin=[15] weight=38<><buttons arrange=80 gap=10 weight=170>>>";
if (desc_extent.width < 170)
desc_extent.width = 170;
if (desc_extent.width < 200)
desc_extent.width = 200;
//Make sure the complete display of input extent
if (desc_extent.width < fixed_pixels)
@ -598,9 +597,10 @@ namespace nana
std::stringstream ss;
ss << "vert<img_top weight="<<img_sz[0].height<<"><<img_left weight="<<img_sz[2].width<<">"<<ss_content.str()<<"<img_right weight="<<img_sz[3].width<<">><img_bottom weight="<<img_sz[1].height<<">";
place_.div(ss.str().data());
place_["desc"] << desc_;
place_["buttons"] << btn_ok_ << btn_cancel_;
auto& place = this->get_place();
place.div(ss.str().c_str());
place["desc"] << desc_;
place["buttons"] << btn_ok_ << btn_cancel_;
const char * img_fields[4] = {"img_top", "img_bottom", "img_left", "img_right"};
@ -611,11 +611,10 @@ namespace nana
images_[i].create(*this, true);
images_[i].load(imgs[i], valid_areas[i]);
images_[i].stretchable(0, 0, 0, 0);
place_[img_fields[i]] << images_[i];
place_.field_display(img_fields[i], true);
place[img_fields[i]] << images_[i];
}
else
place_.field_display(img_fields[i], false);
place.field_display(img_fields[i], imgs[i]);
}
move(API::make_center(this->owner(), desc_extent.width, height));
@ -626,14 +625,14 @@ namespace nana
{
verifier_ = std::move(verifier);
std::size_t index = 0;
unsigned index = 0;
for (auto wd : inputs)
{
std::stringstream ss;
ss << "input_" << index++;
place_[ss.str().data()] << wd;
this->operator[](ss.str().data()) << wd;
}
place_.collocate();
this->collocate();
show();
}
@ -646,7 +645,6 @@ namespace nana
::nana::button btn_ok_;
::nana::button btn_cancel_;
bool valid_input_{ false };
::nana::place place_;
std::function<bool(window)> verifier_;
::nana::picture images_[4];
};
@ -656,6 +654,70 @@ namespace nana
return 0;
}
//class boolean
struct inputbox::boolean::implement
{
bool value;
::std::string empty_label_text;
::std::string label_text;
::nana::panel<false> dock;
::nana::checkbox checkbox;
};
inputbox::boolean::boolean(::std::string label, bool initial_value)
: impl_(new implement)
{
impl_->value = initial_value;
impl_->label_text = std::move(label);
impl_->empty_label_text = " ";
}
inputbox::boolean::~boolean()
{}
bool inputbox::boolean::value() const
{
return (impl_->checkbox.empty() ? impl_->value : impl_->checkbox.checked());
}
//Implementation of abstract_content
const ::std::string& inputbox::boolean::label() const
{
return impl_->empty_label_text;
}
window inputbox::boolean::create(window owner, unsigned label_px)
{
auto impl = impl_.get();
impl->dock.create(owner);
paint::graphics graph{ ::nana::size{ 10, 10 } };
auto value_px = graph.text_extent_size(impl->label_text).width + 20;
impl->checkbox.create(impl->dock, rectangle{ (std::max)(static_cast<int>(label_px) - 18, 0), 0, value_px, 0 });
impl->checkbox.check(impl->value);
impl->checkbox.caption(impl->label_text);
impl->dock.events().resized.connect_unignorable([impl, value_px](const ::nana::arg_resized&)
{
impl->checkbox.size({ value_px, 24 });
});
impl->checkbox.events().destroy.connect_unignorable([impl](const arg_destroy&)
{
impl->value = impl->checkbox.checked();
});
return impl->dock;
}
unsigned inputbox::boolean::fixed_pixels() const
{
paint::graphics graph{ ::nana::size{ 10, 10 } };
return graph.text_extent_size(impl_->label_text).width;
}
//class integer
struct inputbox::integer::implement
{
@ -708,20 +770,17 @@ namespace nana
impl->label.caption(impl->label_text);
impl->label.format(true);
//get the longest value
int longest = (std::abs(static_cast<int>(impl->begin < 0 ? impl->begin * 10 : impl->begin)) < std::abs(static_cast<int>(impl->last < 0 ? impl->last * 10 : impl->last)) ? impl->last : impl->begin);
paint::graphics graph{ ::nana::size{ 10, 10 } };
auto value_px = graph.text_extent_size(std::to_wstring(longest)).width + 34;
auto const value_px = fixed_pixels();
impl->spinbox.create(impl->dock, rectangle{ static_cast<int>(label_px + 10), 0, value_px, 0 });
impl->spinbox.range(impl->begin, impl->last, impl->step);
impl->spinbox.value(std::to_string(impl->value));
impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized&)
impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized& arg)
{
impl->label.size({ label_px, 24 });
impl->spinbox.size({ value_px, 24 });
impl->label.size({ label_px, arg.height });
impl->spinbox.move({static_cast<int>(label_px + 10), (static_cast<int>(arg.height) - 25) / 2, value_px, 24 });
});
impl->spinbox.events().destroy.connect_unignorable([impl](const arg_destroy&)
@ -731,6 +790,14 @@ namespace nana
return impl->dock;
}
unsigned inputbox::integer::fixed_pixels() const
{
//get the longest value
int longest = (std::abs(static_cast<int>(impl_->begin < 0 ? impl_->begin * 10 : impl_->begin)) < std::abs(static_cast<int>(impl_->last < 0 ? impl_->last * 10 : impl_->last)) ? impl_->last : impl_->begin);
paint::graphics graph{ ::nana::size{ 10, 10 } };
return graph.text_extent_size(std::to_wstring(longest)).width + 34;
}
//end class integer
@ -786,20 +853,17 @@ namespace nana
impl->label.caption(impl->label_text);
impl->label.format(true);
//get the longest value
auto longest = (std::abs(static_cast<int>(impl->begin < 0 ? impl->begin * 10 : impl->begin)) < std::abs(static_cast<int>(impl->last < 0 ? impl->last * 10 : impl->last)) ? impl->last : impl->begin);
paint::graphics graph{ ::nana::size{ 10, 10 } };
auto value_px = graph.text_extent_size(std::to_wstring(longest)).width + 34;
auto value_px = fixed_pixels();
impl->spinbox.create(impl->dock, rectangle{ static_cast<int>(label_px + 10), 0, value_px, 0 });
impl->spinbox.range(impl->begin, impl->last, impl->step);
impl->spinbox.value(std::to_string(impl->value));
impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized&)
impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized& arg)
{
impl->label.size(::nana::size{ label_px, 24 });
impl->spinbox.size(::nana::size{ value_px, 24 });
impl->label.size({ label_px, arg.height });
impl->spinbox.move({ static_cast<int>(label_px + 10), (static_cast<int>(arg.height) - 25) / 2, value_px, 24 });
});
impl->spinbox.events().destroy.connect_unignorable([impl](const arg_destroy&)
@ -809,6 +873,14 @@ namespace nana
return impl->dock;
}
unsigned inputbox::real::fixed_pixels() const
{
//get the longest value
auto longest = (std::abs(static_cast<int>(impl_->begin < 0 ? impl_->begin * 10 : impl_->begin)) < std::abs(static_cast<int>(impl_->last < 0 ? impl_->last * 10 : impl_->last)) ? impl_->last : impl_->begin);
paint::graphics graph{ ::nana::size{ 10, 10 } };
return graph.text_extent_size(std::to_wstring(longest)).width + 34;
}
//end class real
@ -890,7 +962,7 @@ namespace nana
impl->label.caption(impl->label_text);
impl->label.format(true);
unsigned value_px = 0;
unsigned const value_px = fixed_pixels();
if (impl->options.empty())
{
impl->textbox.create(impl->dock, rectangle{ static_cast<int>(label_px + 10), 0, 0, 0 });
@ -901,16 +973,6 @@ namespace nana
}
else
{
//get the longest value
paint::graphics graph{ ::nana::size{ 10, 10 } };
for (auto & s : impl->options)
{
auto px = graph.text_extent_size(s).width;
if (px > value_px)
value_px = px;
}
value_px += 34;
impl->combox.create(impl->dock, rectangle{ static_cast<int>(label_px + 10), 0, value_px, 0 });
for (auto & s : impl->options)
@ -922,10 +984,10 @@ namespace nana
impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized& arg)
{
impl->label.size({ label_px, arg.height });
if (value_px)
impl->combox.size({ value_px, 24 });
if (impl->textbox.empty())
impl->combox.move({static_cast<int>(label_px + 10), (static_cast<int>(arg.height) - 25) / 2, value_px, 24 });
else
impl->textbox.size({arg.width - label_px - 10, 24});
impl->textbox.move({ static_cast<int>(label_px + 10), (static_cast<int>(arg.height) - 25) / 2, arg.width - label_px - 10, 24 });
});
auto & wdg = (value_px ? static_cast<widget&>(impl->combox) : static_cast<widget&>(impl->textbox));
@ -935,6 +997,24 @@ namespace nana
});
return impl->dock;
}
unsigned inputbox::text::fixed_pixels() const
{
if (impl_->options.empty())
return 0;
paint::graphics graph{ ::nana::size{ 10, 10 } };
unsigned long_px = 0;
//get the longest value
for (auto & s : impl_->options)
{
auto px = graph.text_extent_size(s).width;
if (px > long_px)
long_px = px;
}
return long_px + 34;
}
//end class text
@ -1031,17 +1111,18 @@ namespace nana
impl->dock.events().resized.connect_unignorable([impl, label_px](const ::nana::arg_resized& arg)
{
impl->label.size({ label_px, arg.height });
auto sz = impl->wdg_month.size();
sz.height = 24;
impl->wdg_month.size(sz);
sz = impl->wdg_day.size();
sz.height = 24;
impl->wdg_day.size(sz);
rectangle rt{static_cast<int>(label_px + 10), (static_cast<int>(arg.height) - 25) / 2, 94, 24};
sz = impl->wdg_year.size();
sz.height = 24;
impl->wdg_year.size(sz);
impl->wdg_month.move(rt);
rt.x += 104;
rt.width = 38;
impl->wdg_day.move(rt);
rt.x += 48;
rt.width = 50;
impl->wdg_year.move(rt);
});
auto destroy_fn = [impl](const arg_destroy& arg)
@ -1155,8 +1236,13 @@ namespace nana
impl->dock.events().resized.connect_unignorable([impl, label_px](const ::nana::arg_resized& arg)
{
impl->label.size({ label_px, arg.height });
impl->path_edit.size({arg.width - label_px - 75, arg.height});
impl->browse.move({static_cast<int>(arg.width - 60), 0, 60, arg.height});
rectangle rt{ static_cast<int>(label_px)+10, (static_cast<int>(arg.height) - 25), arg.width - label_px - 75, 24};
impl->path_edit.move(rt);
rt.x = static_cast<int>(arg.width - 60);
rt.width = 60;
impl->browse.move(rt);
});
impl->path_edit.events().destroy.connect_unignorable([impl](const arg_destroy&)
@ -1202,6 +1288,8 @@ namespace nana
std::vector<unsigned> each_pixels;
unsigned label_px = 0, fixed_px = 0;
paint::graphics graph({ 5, 5 });
bool has_0_fixed_px = false;
for (auto p : contents)
{
auto px = label::measure(graph, p->label(), 150, true, align::right, align_v::center);
@ -1209,12 +1297,17 @@ namespace nana
label_px = px.width;
px.width = p->fixed_pixels();
has_0_fixed_px |= (px.width == 0);
if (px.width > fixed_px)
fixed_px = px.width;
each_pixels.push_back(px.height);
}
//Adjust the fixed_px for good looking
if (has_0_fixed_px && (fixed_px < 100))
fixed_px = 100;
inputbox_window input_wd(owner_, images_, valid_areas_, description_, title_, contents.size(), label_px + 10 + fixed_px, each_pixels);
std::vector<window> inputs;

View File

@ -557,7 +557,10 @@ namespace nana
}value_;
};//end class number_t
/// Margin attribute
/**
* Definition at https://github.com/cnjinhao/nana/wiki/Div-Text#margin
*/
class margin
{
public:
@ -598,7 +601,7 @@ namespace nana
{
case 0: break;
case 1: //top
il = ir = it = ib = 0;
it = 0;
break;
case 2://top,bottom and left,right
it = ib = 0;
@ -624,7 +627,7 @@ namespace nana
case 3: //left
pos = il; break;
default:
return number_t{};
return {};
}
return (-1 == pos ? number_t{} : margins_[pos]);
@ -652,7 +655,7 @@ namespace nana
{
case 0: break;
case 1: //top
il = ir = it = ib = 0;
it = 0;
break;
case 2://top,bottom and left,right
it = ib = 0;

View File

@ -100,7 +100,7 @@ namespace nana
tmp.swap(displays);
}
static BOOL __stdcall enum_proc(HMONITOR handle, HDC context, LPRECT r, LPARAM self_ptr)
static BOOL __stdcall enum_proc(HMONITOR handle, HDC /*context*/, LPRECT /*r*/, LPARAM self_ptr)
{
auto disp_cont = reinterpret_cast<std::vector<real_display>*>(self_ptr);
MONITORINFOEX mi;

View File

@ -142,7 +142,7 @@ namespace nana
}; //end class timer_core
#if defined(NANA_WINDOWS)
void __stdcall timer_driver::_m_timer_proc(HWND hwnd, UINT uMsg, UINT_PTR id, DWORD dwTime)
void __stdcall timer_driver::_m_timer_proc(HWND /*hwnd*/, UINT /*uMsg*/, UINT_PTR id, DWORD /*dwTime*/)
#else
void timer_driver::_m_timer_proc(std::size_t id)
#endif

View File

@ -659,7 +659,8 @@ namespace nana
std::unique_ptr<model_interface> model_ptr;
bool expand{true};
bool expand{ true };
bool display_number{ true };
//A cat may have a key object to identify the category
std::shared_ptr<nana::detail::key_interface> key_ptr;
@ -1434,7 +1435,8 @@ namespace nana
bool expand(size_type cat, bool exp) noexcept
{
if(good(cat) && cat)
//It is allowed to expand the 1st category.
if(good(cat) && (cat || exp))
{
auto & expanded = get(cat)->expand;
if(expanded != exp)
@ -1937,6 +1939,8 @@ namespace nana
std::unique_ptr<widgets::skeletons::content_view> content_view;
std::function<void(paint::graphics&, const rectangle&, bool)> ctg_icon_renderer; ///< Renderer for the category icon
struct mouse_selection_part
{
bool started{ false };
@ -2848,8 +2852,37 @@ namespace nana
this->expand(pos.cat, true);
ess_->calc_content_size();
}
else if (!ess_->auto_draw)
{
//force a update of content size and scrollbar status when auto_draw is false to make
//sure that the scroll function works fine.
ess_->calc_content_size();
}
ess_->content_view->turn_page(to_bottom, false);
auto origin = ess_->content_view->origin();
origin.y = 0;
auto off = this->distance(this->first(), pos) * ess_->item_height();
auto screen_px = ess_->content_view->view_area().height;
if (to_bottom)
{
off += ess_->item_height();
if (off >= screen_px)
origin.y = static_cast<int>(off - screen_px);
}
else
{
auto last_off = this->distance(this->first(), this->last()) * ess_->item_height();
if (last_off - off >= screen_px)
origin.y = static_cast<int>(off);
else if (last_off >= screen_px)
origin.y = static_cast<int>(last_off - screen_px);
}
if(ess_->content_view->move_origin(origin - ess_->content_view->origin()))
ess_->content_view->sync(false);
}
void es_lister::erase(const index_pair& pos)
@ -3514,27 +3547,36 @@ namespace nana
color txt_color{ static_cast<color_rgb>(0x3399) };
facade<element::arrow> arrow("double");
arrow.direction(categ.expand ? ::nana::direction::north : ::nana::direction::south);
arrow.draw( *graph, {}, txt_color,
{ x + 5, y + static_cast<int>(item_height - 16) / 2, 16, 16 },
element_state::normal);
//Area of category icon
rectangle rt_ctg_icon{ x + 5, y + static_cast<int>(item_height - 16) / 2, 16, 16 };
if (essence_->ctg_icon_renderer)
{
essence_->ctg_icon_renderer(*graph, rt_ctg_icon, categ.expand);
}
else
{
facade<element::arrow> arrow("double");
arrow.direction(categ.expand ? ::nana::direction::south : ::nana::direction::east);
arrow.draw(*graph, {}, txt_color, rt_ctg_icon, element_state::normal);
}
graph->string({ x + 20, y + txtoff }, categ.text, txt_color);
native_string_type str = to_nstring('(' + std::to_string(categ.items.size()) + ')');
auto text_s = graph->text_extent_size(categ.text).width;
auto extend_text_w = text_s + graph->text_extent_size(str).width;
graph->string({ x + 25 + static_cast<int>(text_s), y + txtoff }, str);
if (35 + extend_text_w < width)
auto text_px = graph->text_extent_size(categ.text).width;
if (categ.display_number)
{
::nana::point pos{ x + 30 + static_cast<int>(extend_text_w), y + static_cast<int>(item_height) / 2 };
//Display the number of items in the category
native_string_type str = to_nstring('(' + std::to_string(categ.items.size()) + ')');
graph->string({ x + 25 + static_cast<int>(text_px), y + txtoff }, str);
text_px += graph->text_extent_size(str).width;
}
graph->line(pos, { x + static_cast<int>(width) - 5, pos.y },
txt_color);
if (35 + text_px < width)
{
::nana::point pos{ x + 30 + static_cast<int>(text_px), y + static_cast<int>(item_height) / 2 };
graph->line(pos, { x + static_cast<int>(width) - 5, pos.y }, txt_color);
}
//Draw selecting inner rectangle
@ -4488,8 +4530,10 @@ namespace nana
//pos_ never represents a category if this item_proxy is available.
auto & m = cat_->items.at(pos_.item); // a ref to the real item
//ignore if no change
if(m.flags.selected == s)
return *this; // ignore if no change
return *this;
m.flags.selected = s; // actually change selection
@ -4503,14 +4547,8 @@ namespace nana
else if (ess_->lister.latest_selected_abs == pos_)
ess_->lister.latest_selected_abs.set_both(npos);
if (scroll_view)
{
if (ess_->lister.get(pos_.cat)->expand)
ess_->lister.get(pos_.cat)->expand = false;
if (!this->displayed())
ess_->lister.scroll(pos_, !(ess_->first_display() > this->to_display()));
}
if (scroll_view && (!this->displayed()))
ess_->lister.scroll(pos_, !(ess_->first_display() > this->to_display()));
ess_->update();
return *this;
@ -4788,6 +4826,32 @@ namespace nana
return true;
}
cat_proxy& cat_proxy::display_number(bool display)
{
if (cat_->display_number != display)
{
cat_->display_number = display;
ess_->update();
}
return *this;
}
bool cat_proxy::expanded() const
{
return cat_->expand;
}
cat_proxy& cat_proxy::expanded(bool expand)
{
//The first category isn't allowed to be collapsed
if ((expand != cat_->expand) && pos_)
{
cat_->expand = expand;
ess_->update();
}
return *this;
}
auto cat_proxy::columns() const -> size_type
{
return ess_->header.cont().size();
@ -5559,6 +5623,32 @@ namespace nana
return _m_ess().def_exp_options;
}
listbox& listbox::category_icon(std::function<void(paint::graphics& graph, const rectangle& rt_icon, bool expanded)> icon_renderer)
{
_m_ess().ctg_icon_renderer.swap(icon_renderer);
_m_ess().update();
return *this;
}
listbox& listbox::category_icon(const paint::image& img_expanded, const paint::image&& img_collapsed)
{
_m_ess().ctg_icon_renderer = [img_expanded, img_collapsed](paint::graphics& graph, const rectangle& rt_icon, bool expanded)
{
if (expanded)
{
img_expanded.stretch(rectangle{ img_expanded.size() }, graph, rt_icon);
}
else
{
img_collapsed.stretch(rectangle{ img_collapsed.size() }, graph, rt_icon);
}
};
_m_ess().update();
return *this;
}
drawerbase::listbox::essence & listbox::_m_ess() const
{
return get_drawer_trigger().ess();

View File

@ -35,6 +35,7 @@ namespace nana {
bool drag_started{ false };
point origin;
scrolls enabled_scrolls{scrolls::both};
nana::scroll<false> horz;
nana::scroll<true> vert;
@ -193,7 +194,10 @@ namespace nana {
this->passive = passive;
if (imd_area.width != disp_area.width)
bool const vert_allowed = (enabled_scrolls == scrolls::vert || enabled_scrolls == scrolls::both);
bool const horz_allowed = (enabled_scrolls == scrolls::horz || enabled_scrolls == scrolls::both);
if ((imd_area.width != disp_area.width) && vert_allowed)
{
if (vert.empty())
{
@ -217,10 +221,14 @@ namespace nana {
else
{
vert.close();
origin.y = 0;
//If vert is allowed, it indicates the vertical origin is not moved
//Make sure the v origin is zero
if (vert_allowed)
origin.y = 0;
}
if (imd_area.height != disp_area.height)
if ((imd_area.height != disp_area.height) && horz_allowed)
{
if (horz.empty())
{
@ -244,7 +252,10 @@ namespace nana {
else
{
horz.close();
origin.x = 0;
//If horz is allowed, it indicates the horzontal origin is not moved
//Make sure the x origin is zero
if (horz_allowed)
origin.x = 0;
}
this->passive = true;
@ -266,6 +277,16 @@ namespace nana {
return impl_->events;
}
bool content_view::enable_scrolls(scrolls which)
{
if (impl_->enabled_scrolls == which)
return false;
impl_->enabled_scrolls = which;
impl_->size_changed(false);
return true;
}
void content_view::step(unsigned step_value, bool horz)
{
if (horz)
@ -383,7 +404,7 @@ namespace nana {
void content_view::draw_corner(graph_reference graph)
{
auto r = corner();
if(!r.empty())
if ((!r.empty()) && (scrolls::both == impl_->enabled_scrolls))
graph.rectangle(r, true, colors::button_face);
}
@ -394,8 +415,11 @@ namespace nana {
rectangle content_view::view_area(const size& alt_content_size) const
{
unsigned extra_horz = (impl_->disp_area.width < alt_content_size.width ? space() : 0);
unsigned extra_vert = (impl_->disp_area.height < alt_content_size.height + extra_horz ? space() : 0);
bool const vert_allowed = (impl_->enabled_scrolls == scrolls::vert || impl_->enabled_scrolls == scrolls::both);
bool const horz_allowed = (impl_->enabled_scrolls == scrolls::horz || impl_->enabled_scrolls == scrolls::both);
unsigned extra_horz = (horz_allowed && (impl_->disp_area.width < alt_content_size.width) ? space() : 0);
unsigned extra_vert = (vert_allowed && (impl_->disp_area.height < alt_content_size.height + extra_horz) ? space() : 0);
if ((0 == extra_horz) && extra_vert)
extra_horz = (impl_->disp_area.width < alt_content_size.width + extra_vert ? space() : 0);

View File

@ -40,6 +40,11 @@ namespace skeletons
public:
using graph_reference = paint::graphics&;
enum class scrolls
{
none, horz, vert, both
};
struct events_type
{
::std::function<void(const point&)> hover_outside;
@ -51,6 +56,8 @@ namespace skeletons
events_type& events();
bool enable_scrolls(scrolls which);
void step(unsigned step_value, bool horz);
bool scroll(bool forwards, bool horz);
bool turn_page(bool forwards, bool horz);

View File

@ -8,7 +8,7 @@
* http://www.boost.org/LICENSE_1_0.txt)
*
* @file: nana/gui/widgets/skeletons/text_editor.cpp
* @contributors: Ariel Vina-Rodriguez
* @contributors: Ariel Vina-Rodriguez, Oleg Smolsky
*/
#include <nana/gui/widgets/skeletons/text_editor.hpp>
#include <nana/gui/widgets/skeletons/textbase_export_interface.hpp>
@ -234,7 +234,7 @@ namespace nana{ namespace widgets
}
}
editor_.move_caret(editor_.points_.caret);
editor_.reset_caret();
}
};
@ -302,7 +302,7 @@ namespace nana{ namespace widgets
editor_.select_.b = sel_b_;
}
}
editor_.move_caret(editor_.points_.caret);
editor_.reset_caret();
}
private:
std::wstring text_;
@ -497,6 +497,7 @@ namespace nana{ namespace widgets
undoable<command> undo; //undo command
renderers customized_renderers;
std::vector<upoint> text_position; //positions of text since last rendering.
int text_position_origin{ -1 }; //origin when last text_exposed
skeletons::textbase<wchar_t> textbase;
@ -1083,6 +1084,11 @@ namespace nana{ namespace widgets
return { 1, line_height() };
}
const point& text_editor::content_origin() const
{
return impl_->cview->origin();
}
void text_editor::set_highlight(const std::string& name, const ::nana::color& fgcolor, const ::nana::color& bgcolor)
{
if (fgcolor.invisible() && bgcolor.invisible())
@ -1273,7 +1279,7 @@ namespace nana{ namespace widgets
if (impl_->cview->content_size().empty() || this->attributes_.line_wrapped)
_m_reset_content_size(true);
move_caret(points_.caret);
reset_caret();
return true;
}
@ -1337,6 +1343,10 @@ namespace nana{ namespace widgets
line_wrapped(false);
_m_reset_content_size();
impl_->cview->enable_scrolls(ml ? content_view::scrolls::both : content_view::scrolls::none);
impl_->cview->move_origin(point{} -impl_->cview->origin());
impl_->try_refresh = sync_graph::refresh;
return true;
}
@ -1564,7 +1574,6 @@ namespace nana{ namespace widgets
{
//no move occurs
select(false);
move_caret(_m_coordinate_to_caret(arg.pos));
}
@ -1580,6 +1589,45 @@ namespace nana{ namespace widgets
}
}
//Added Windows-style mouse double-click to the textbox(https://github.com/cnjinhao/nana/pull/229)
//Oleg Smolsky
bool text_editor::select_word(const arg_mouse& arg)
{
if(!attributes_.enable_caret)
return false;
auto is_whitespace = [](wchar_t c) {
switch (c) {
case L' ':
case L'\t':
case L'\n':
case L'\r':
return true;
default:
return false;
}
};
// Set caret pos by screen point and get the caret pos.
mouse_caret(arg.pos, true);
// Set the initial selection: it is an empty range.
select_.a = select_.b = points_.caret;
const auto& line = impl_->textbase.getline(select_.b.y);
// Expand the selection forward to the word's end.
while (select_.b.x < line.size() && !is_whitespace(line[select_.b.x]))
++select_.b.x;
// Expand the selection backward to the word's start.
while (select_.a.x > 0 && !is_whitespace(line[select_.a.x - 1]))
--select_.a.x;
select_.mode_selection = selection::mode::method_selected;
impl_->try_refresh = sync_graph::refresh;
return true;
}
textbase<text_editor::char_type> & text_editor::textbase()
{
return impl_->textbase;
@ -1638,6 +1686,7 @@ namespace nana{ namespace widgets
//_m_put calcs the lines
_m_reset_content_size(false);
impl_->cview->sync(false);
}
}
else
@ -1660,10 +1709,29 @@ namespace nana{ namespace widgets
return str;
}
bool text_editor::move_caret(const upoint& crtpos, bool reset_caret)
bool text_editor::move_caret(upoint crtpos, bool stay_in_view)
{
const unsigned line_pixels = line_height();
if (crtpos != points_.caret)
{
//Check and make the crtpos available
if (crtpos.y < impl_->textbase.lines())
{
crtpos.x = (std::min)(static_cast<decltype(crtpos.x)>(impl_->textbase.getline(crtpos.y).size()), crtpos.x);
}
else
{
crtpos.y = static_cast<unsigned>(impl_->textbase.lines());
if (crtpos.y > 0)
--crtpos.y;
crtpos.x = static_cast<unsigned>(impl_->textbase.getline(crtpos.y).size());
}
points_.caret = crtpos;
}
//The coordinate of caret
auto coord = _m_caret_to_coordinate(crtpos);
@ -1694,9 +1762,11 @@ namespace nana{ namespace widgets
caret->position(coord);
//Adjust the caret into screen when the caret position is modified by this function
if (reset_caret && (!hit_text_area(coord)))
if (stay_in_view && (!hit_text_area(coord)))
{
this->_m_adjust_view();
if (_m_adjust_view())
impl_->cview->sync(false);
impl_->try_refresh = sync_graph::refresh;
caret->visible(true);
return true;
@ -1711,7 +1781,7 @@ namespace nana{ namespace widgets
points_.caret.x = static_cast<unsigned>(impl_->textbase.getline(points_.caret.y).size());
if (update)
this->move_caret(points_.caret, false);
this->reset_caret();
}
void text_editor::reset_caret_pixels() const
@ -1918,8 +1988,9 @@ namespace nana{ namespace widgets
if (text_pos.empty())
text_pos.emplace_back(upoint{});
if (text_pos != impl_->text_position)
if ((impl_->text_position_origin != impl_->cview->origin().y) || (text_pos != impl_->text_position))
{
impl_->text_position_origin = impl_->cview->origin().y;
impl_->text_position.swap(text_pos);
if (event_handler_)
event_handler_->text_exposed(impl_->text_position);
@ -1959,7 +2030,8 @@ namespace nana{ namespace widgets
if(graph_)
{
this->_m_adjust_view();
if(this->_m_adjust_view())
impl_->cview->sync(false);
reset_caret();
impl_->try_refresh = sync_graph::refresh;
@ -2424,7 +2496,7 @@ namespace nana{ namespace widgets
if (stay_in_view && this->_m_adjust_view())
impl_->try_refresh = sync_graph::refresh;
move_caret(points_.caret);
reset_caret();
return points_.caret;
}
@ -3289,26 +3361,37 @@ namespace nana{ namespace widgets
line_px_( editor.line_height() )
{}
color selection_color(bool fgcolor, bool focused) const
{
if (fgcolor)
return (focused ? editor_.scheme_->selection_text : editor_.scheme_->foreground).get_color();
return (focused ? editor_.scheme_->selection : editor_.scheme_->selection_unfocused).get_color();
}
void write_selection(const point& text_pos, unsigned text_px, const wchar_t* text, std::size_t len, bool has_focused)
{
graph_.palette(true, editor_.scheme_->selection_text.get_color());
graph_.palette(true, selection_color(true, has_focused));
graph_.rectangle(::nana::rectangle{ text_pos, { text_px, line_px_ } }, true,
has_focused ? editor_.scheme_->selection.get_color() : editor_.scheme_->selection_unfocused.get_color());
selection_color(false, has_focused));
graph_.string(text_pos, text, len);
}
void rtl_string(point strpos, const wchar_t* str, std::size_t len, std::size_t str_px, unsigned glyph_front, unsigned glyph_selected, bool has_focused)
{
editor_._m_draw_parse_string(parser_, true, strpos, editor_.scheme_->selection_text.get_color(), str, len);
editor_._m_draw_parse_string(parser_, true, strpos, selection_color(true, has_focused), str, len);
//Draw selected part
paint::graphics graph({ glyph_selected, line_px_ });
graph.typeface(this->graph_.typeface());
graph.rectangle(true, (has_focused ? editor_.scheme_->selection.get_color() : editor_.scheme_->selection_unfocused.get_color()));
graph.rectangle(true, selection_color(false, has_focused));
int sel_xpos = static_cast<int>(str_px - (glyph_front + glyph_selected));
graph.palette(true, editor_.scheme_->selection_text.get_color());
graph.palette(true, selection_color(true, has_focused));
graph.string({ -sel_xpos, 0 }, str, len);
graph_.bitblt(nana::rectangle(strpos.x + sel_xpos, strpos.y, glyph_selected, line_px_), graph);
};
@ -3396,9 +3479,11 @@ namespace nana{ namespace widgets
//A text editor feature, it draws an extra block at end of line if the end of line is in range of selection.
bool extra_space = false;
//Create a flag for indicating whether the whole line is selected
const bool text_selected = (sbegin == text_ptr && send == text_ptr+ text_len);
//The text is not selected or the whole line text is selected
if (!focused || (!sbegin || !send) || text_selected || !attributes_.enable_caret)
if ((!sbegin || !send) || text_selected)
{
for (auto & ent : reordered)
{

View File

@ -282,8 +282,10 @@ namespace nana
reset_text();
//Spinbox doesn't process the tabstop unlike other text editors.
//Otherwise it would bring a weird user experience.
//Issued by jk.
API::tabstop(wd);
API::eat_tabstop(wd, true);
API::effects_edge_nimbus(wd, effects::edge_nimbus::active);
API::effects_edge_nimbus(wd, effects::edge_nimbus::over);
reset_text_area();

View File

@ -8,6 +8,7 @@
* http://www.boost.org/LICENSE_1_0.txt)
*
* @file: nana/gui/widgets/textbox.hpp
* @contributors: Oleg Smolsky
*/
#include <nana/gui/widgets/textbox.hpp>
@ -143,6 +144,14 @@ namespace drawerbase {
API::dev::lazy_refresh();
}
//Added Windows-style mouse double-click to the textbox(https://github.com/cnjinhao/nana/pull/229)
//Oleg Smolsky
void drawer::dbl_click(graph_reference, const arg_mouse& arg)
{
if(editor_->select_word(arg))
API::dev::lazy_refresh();
}
void drawer::key_press(graph_reference, const arg_keyboard& arg)
{
editor_->respond_key(arg);
@ -260,6 +269,15 @@ namespace drawerbase {
return nullptr;
}
point textbox::content_origin() const
{
auto editor = get_drawer_trigger().editor();
if (editor)
return editor->content_origin();
return{};
}
/// Enables/disables the textbox to indent a line. Idents a new line when it is created by pressing enter.
/// @param generator generates text for identing a line. If it is empty, textbox indents the line according to last line.
textbox& textbox::indention(bool enb, std::function<std::string()> generator)
@ -381,6 +399,16 @@ namespace drawerbase {
return editor->hit_text_area(scr_pos);
}
upoint textbox::caret_pos() const
{
auto editor = get_drawer_trigger().editor();
internal_scope_guard lock;
if (editor)
return editor->caret();
return{};
}
textbox& textbox::caret_pos(const upoint& pos)
{
auto editor = get_drawer_trigger().editor();

View File

@ -1781,6 +1781,11 @@ namespace nana
widget.caption("nana treebox");
}
void trigger::detached()
{
impl_->data.graph = nullptr;
}
void trigger::refresh(graph_reference)
{
//Don't reset the scroll and update the window

View File

@ -291,6 +291,12 @@ namespace paint
{
if(impl_->handle == nullptr || impl_->size != sz)
{
if (sz.empty())
{
release();
return;
}
//The object will be delete while dwptr_ is performing a release.
drawable_type dw = new nana::detail::drawable_impl_type;
//Reuse the old font
@ -342,7 +348,7 @@ namespace paint
Display* disp = spec.open_display();
int screen = DefaultScreen(disp);
Window root = ::XRootWindow(disp, screen);
dw->pixmap = ::XCreatePixmap(disp, root, (sz.width ? sz.width : 1), (sz.height ? sz.height : 1), DefaultDepth(disp, screen));
dw->pixmap = ::XCreatePixmap(disp, root, sz.width, sz.height, DefaultDepth(disp, screen));
dw->context = ::XCreateGC(disp, dw->pixmap, 0, 0);
#if defined(NANA_USE_XFT)
dw->xftdraw = ::XftDrawCreate(disp, dw->pixmap, spec.screen_visual(), spec.colormap());

View File

@ -15,6 +15,8 @@
//Implement workarounds for GCC/MinGW which version is below 4.8.2
#if defined(STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED)
#include <sstream>
#include <cstdlib>
#include <stdexcept>
namespace std
{
int stoi(const std::string& str, std::size_t * pos, int base)