Merge branch 'develop'
This commit is contained in:
50
build/cmake/CMakeLists.txt
Normal file
50
build/cmake/CMakeLists.txt
Normal file
@@ -0,0 +1,50 @@
|
||||
# CMake configuration for Nana
|
||||
# Author: ierofant(https://github.com/ierofant)
|
||||
|
||||
project(nana)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
string(REGEX REPLACE "/[^/]*$" "" CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR})
|
||||
string(REGEX REPLACE "/[^/]*$" "" CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR})
|
||||
|
||||
set(NANA_SOURCE_DIR ${CMAKE_SOURCE_DIR}/source)
|
||||
set(NANA_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
include_directories(${NANA_INCLUDE_DIR})
|
||||
aux_source_directory(${NANA_SOURCE_DIR} NANA_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/detail NANA_DETAIL_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/filesystem NANA_FILESYSTEM_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/audio NANA_AUDIO_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/audio/detail NANA_AUDIO_DETAIL_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/gui NANA_GUI_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/gui/detail NANA_GUI_DETAIL_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/gui/widgets NANA_GUI_WIDGETS_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/gui/widgets/skeletons NANA_GUI_WIDGETS_SKELETONS_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/paint NANA_PAINT_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/paint/detail NANA_PAINT_DETAIL_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/system NANA_SYSTEM_SOURCE)
|
||||
aux_source_directory(${NANA_SOURCE_DIR}/threads NANA_THREADS_SOURCE)
|
||||
|
||||
add_library(${PROJECT_NAME} ${NANA_SOURCE}
|
||||
${NANA_DETAIL_SOURCE}
|
||||
${NANA_FILESYSTEM_SOURCE}
|
||||
${NANA_AUDIO_SOURCE}
|
||||
${NANA_AUDIO_DETAIL_SOURCE}
|
||||
${NANA_GUI_SOURCE}
|
||||
${NANA_GUI_DETAIL_SOURCE}
|
||||
${NANA_GUI_WIDGETS_SOURCE}
|
||||
${NANA_GUI_WIDGETS_SKELETONS_SOURCE}
|
||||
${NANA_PAINT_SOURCE}
|
||||
${NANA_PAINT_DETAIL_SOURCE}
|
||||
${NANA_SYSTEM_SOURCE}
|
||||
${NANA_THREADS_SOURCE})
|
||||
|
||||
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib)
|
||||
install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include)
|
||||
@@ -52,6 +52,7 @@
|
||||
<Unit filename="../../source/gui/detail/basic_window.cpp" />
|
||||
<Unit filename="../../source/gui/detail/bedrock_pi.cpp" />
|
||||
<Unit filename="../../source/gui/detail/bedrock_selector.cpp" />
|
||||
<Unit filename="../../source/gui/detail/color_schemes.cpp" />
|
||||
<Unit filename="../../source/gui/detail/drawer.cpp" />
|
||||
<Unit filename="../../source/gui/detail/element_store.cpp" />
|
||||
<Unit filename="../../source/gui/detail/events_operation.cpp" />
|
||||
@@ -68,6 +69,7 @@
|
||||
<Unit filename="../../source/gui/notifier.cpp" />
|
||||
<Unit filename="../../source/gui/place.cpp" />
|
||||
<Unit filename="../../source/gui/programming_interface.cpp" />
|
||||
<Unit filename="../../source/gui/screen.cpp" />
|
||||
<Unit filename="../../source/gui/state_cursor.cpp" />
|
||||
<Unit filename="../../source/gui/timer.cpp" />
|
||||
<Unit filename="../../source/gui/tooltip.cpp" />
|
||||
@@ -89,6 +91,7 @@
|
||||
<Unit filename="../../source/gui/widgets/scroll.cpp" />
|
||||
<Unit filename="../../source/gui/widgets/skeletons/text_editor.cpp" />
|
||||
<Unit filename="../../source/gui/widgets/slider.cpp" />
|
||||
<Unit filename="../../source/gui/widgets/spinbox.cpp" />
|
||||
<Unit filename="../../source/gui/widgets/tabbar.cpp" />
|
||||
<Unit filename="../../source/gui/widgets/textbox.cpp" />
|
||||
<Unit filename="../../source/gui/widgets/toolbar.cpp" />
|
||||
|
||||
@@ -1,39 +1,79 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<ActiveTarget name="Debug" />
|
||||
<File name="..\..\source\gui\programming_interface.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="5022" topLine="159" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\tooltip.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="4739" topLine="194" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\button.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="7080" topLine="291" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\paint\graphics.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="30961" topLine="1020" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\filesystem\fs_utility.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1562" topLine="57" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\categorize.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="6160" topLine="196" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\paint\image.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="3714" topLine="168" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\animation.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1164" topLine="43" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\checkbox.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="6998" topLine="275" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\combox.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="16572" topLine="610" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\date_chooser.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="457" topLine="3" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\audio\detail\buffer_preparation.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="..\..\source\paint\text_renderer.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1924" topLine="62" />
|
||||
<Cursor1 position="5894" topLine="205" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\tabbar.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="..\..\source\gui\widgets\listbox.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="18615" topLine="760" />
|
||||
<Cursor1 position="12428" topLine="532" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\textbox.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="..\..\source\threads\pool.cpp" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="11188" topLine="459" />
|
||||
<Cursor1 position="5569" topLine="249" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\audio\detail\audio_device.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="..\..\source\gui\widgets\menu.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="6256" topLine="215" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\toolbar.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2244" topLine="84" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\treebox.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="15535" topLine="539" />
|
||||
<Cursor1 position="27717" topLine="1044" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\detail\native_window_interface.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
@@ -41,6 +81,11 @@
|
||||
<Cursor1 position="4901" topLine="171" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\audio\detail\buffer_preparation.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1924" topLine="62" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\detail\window_layout.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="5198" topLine="161" />
|
||||
@@ -56,9 +101,9 @@
|
||||
<Cursor1 position="1316" topLine="59" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\paint\graphics.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="..\..\source\charset.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="30961" topLine="1020" />
|
||||
<Cursor1 position="412" topLine="15" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\element.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
@@ -66,9 +111,9 @@
|
||||
<Cursor1 position="20890" topLine="542" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\paint\image.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="..\..\source\detail\platform_spec_selector.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="3714" topLine="168" />
|
||||
<Cursor1 position="587" topLine="2" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\filebox.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
@@ -76,79 +121,34 @@
|
||||
<Cursor1 position="22934" topLine="871" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\tabbar.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="18615" topLine="760" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\textbox.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="11188" topLine="459" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\msgbox.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="48249" topLine="407" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\paint\text_renderer.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="..\..\source\gui\widgets\toolbar.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="5894" topLine="205" />
|
||||
<Cursor1 position="2244" topLine="84" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\programming_interface.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="..\..\source\gui\widgets\treebox.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="5022" topLine="159" />
|
||||
<Cursor1 position="15535" topLine="539" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\charset.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="..\..\source\audio\detail\audio_device.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="412" topLine="15" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\listbox.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="12428" topLine="532" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\threads\pool.cpp" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="5569" topLine="249" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\tooltip.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="4739" topLine="194" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\menu.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="27717" topLine="1044" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\detail\platform_spec_selector.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="587" topLine="2" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\button.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="7080" topLine="291" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\categorize.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="6160" topLine="196" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\checkbox.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="6998" topLine="275" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\filesystem\fs_utility.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1562" topLine="57" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\combox.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="16572" topLine="610" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\animation.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1164" topLine="43" />
|
||||
<Cursor1 position="6256" topLine="215" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
||||
@@ -99,6 +99,7 @@
|
||||
<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\color_schemes.cpp" />
|
||||
<ClCompile Include="..\..\source\gui\detail\drawer.cpp" />
|
||||
<ClCompile Include="..\..\source\gui\detail\element_store.cpp" />
|
||||
<ClCompile Include="..\..\source\gui\detail\events_operation.cpp" />
|
||||
@@ -116,6 +117,7 @@
|
||||
<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" />
|
||||
@@ -137,6 +139,7 @@
|
||||
<ClCompile Include="..\..\source\gui\widgets\scroll.cpp" />
|
||||
<ClCompile Include="..\..\source\gui\widgets\skeletons\text_editor.cpp" />
|
||||
<ClCompile Include="..\..\source\gui\widgets\slider.cpp" />
|
||||
<ClCompile Include="..\..\source\gui\widgets\spinbox.cpp" />
|
||||
<ClCompile Include="..\..\source\gui\widgets\tabbar.cpp" />
|
||||
<ClCompile Include="..\..\source\gui\widgets\textbox.cpp" />
|
||||
<ClCompile Include="..\..\source\gui\widgets\toolbar.cpp" />
|
||||
|
||||
@@ -291,5 +291,14 @@
|
||||
<ClCompile Include="..\..\source\internationalization.cpp">
|
||||
<Filter>Source Files\nana</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\source\gui\detail\color_schemes.cpp">
|
||||
<Filter>Source Files\nana\gui\detail</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\source\gui\screen.cpp">
|
||||
<Filter>Source Files\nana\gui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\source\gui\widgets\spinbox.cpp">
|
||||
<Filter>Source Files\nana\gui\widgets</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Basic Types definition
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -14,6 +14,7 @@
|
||||
#define NANA_BASIC_TYPES_HPP
|
||||
|
||||
#include <nana/deploy.hpp>
|
||||
#include <cctype>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
@@ -98,27 +99,251 @@ namespace nana
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned long uint32_t;
|
||||
typedef unsigned uint_t;
|
||||
typedef unsigned color_t;
|
||||
typedef long long long_long_t;
|
||||
|
||||
const color_t null_color = 0xFFFFFFFF;
|
||||
|
||||
struct pixel_rgb_t
|
||||
union pixel_argb_t
|
||||
{
|
||||
union
|
||||
struct element_tag
|
||||
{
|
||||
struct element_tag
|
||||
{
|
||||
unsigned int blue:8;
|
||||
unsigned int green:8;
|
||||
unsigned int red:8;
|
||||
unsigned int alpha_channel:8;
|
||||
}element;
|
||||
|
||||
color_t color;
|
||||
}u;
|
||||
unsigned char blue;
|
||||
unsigned char green;
|
||||
unsigned char red;
|
||||
unsigned char alpha_channel;
|
||||
}element;
|
||||
unsigned value;
|
||||
};
|
||||
|
||||
union pixel_rgba_t
|
||||
{
|
||||
struct element_tag
|
||||
{
|
||||
unsigned char alpha_channel;
|
||||
unsigned char blue;
|
||||
unsigned char green;
|
||||
unsigned char red;
|
||||
}element;
|
||||
unsigned value;
|
||||
};
|
||||
|
||||
using pixel_color_t = pixel_argb_t;
|
||||
|
||||
//http://www.w3.org/TR/2011/REC-css3-color-20110607/
|
||||
//4.3. Extended color keywords
|
||||
enum class colors
|
||||
{
|
||||
alice_blue = 0xf0f8ff,
|
||||
antique_white = 0xfaebd7,
|
||||
aqua = 0xFFFF,
|
||||
aquamarine = 0x7fffd4,
|
||||
azure = 0xf0ffff,
|
||||
beige = 0xf5f5dc,
|
||||
bisque = 0xffe4ce,
|
||||
black = 0x0,
|
||||
blanched_almond = 0xffebcd,
|
||||
blue = 0x0000FF,
|
||||
blue_violet = 0x8a2be2,
|
||||
brown = 0xa52a2a,
|
||||
burly_wood = 0xdeb887,
|
||||
cadet_blue = 0x5f9ea0,
|
||||
chartreuse = 0x7fff00,
|
||||
chocolate = 0xd2691e,
|
||||
coral = 0xff7f50,
|
||||
cornflower_blue = 0x6495ed,
|
||||
cornsilk = 0xfff8dc,
|
||||
crimson = 0xdc143c,
|
||||
cyan = 0xffff,
|
||||
dark_blue = 0x8b,
|
||||
dark_cyan = 0x8b8b,
|
||||
dark_goldenrod = 0xb8860b,
|
||||
dark_gray = 0xa9a9a9,
|
||||
dark_green = 0x6400,
|
||||
dark_grey = dark_gray,
|
||||
dark_khaki = 0xbdb76b,
|
||||
dark_magenta = 0x8b008b,
|
||||
dark_olive_green = 0x556b2f,
|
||||
dark_orange = 0xff8c00,
|
||||
dark_orchid = 0x9932cc,
|
||||
dark_red = 0x8b0000,
|
||||
dark_salmon = 0xe9976a,
|
||||
dark_sea_green = 0x8fbc8f,
|
||||
dark_slate_blue = 0x483d8b,
|
||||
dark_slate_gray = 0x2f4f4f,
|
||||
dark_slate_grey = 0x2f4f4f,
|
||||
dark_turquoise = 0xced1,
|
||||
dark_violet = 0x9400d3,
|
||||
deep_pink = 0xff1493,
|
||||
deep_sky_blue = 0xbfff,
|
||||
dim_gray = 0x696969,
|
||||
dim_grey = dim_gray,
|
||||
dodger_blue = 0x1e90ff,
|
||||
firebrick = 0xb22222,
|
||||
floral_white = 0xfffaf0,
|
||||
forest_green = 0x228b22,
|
||||
fuchsia = 0xFF00FF,
|
||||
gainsboro = 0xdcdcdc,
|
||||
ghost_white = 0xf8f8ff,
|
||||
gold = 0xffd700,
|
||||
goldenrod = 0xdaa520,
|
||||
gray = 0x808080,
|
||||
green = 0x008000,
|
||||
green_yellow = 0xadff2f,
|
||||
grey = gray,
|
||||
honeydew = 0xf0fff0,
|
||||
hot_pink = 0xff69b4,
|
||||
indian_red = 0xcd5c5c,
|
||||
indigo = 0x4b0082,
|
||||
ivory = 0xfffff0,
|
||||
khaki = 0xf0e68c,
|
||||
lavendar = 0xe6e6fa,
|
||||
lavender_blush = 0xfff0f5,
|
||||
lawn_green = 0x7cfc00,
|
||||
lemon_chiffon = 0xfffacd,
|
||||
light_blue = 0xadd8e6,
|
||||
light_coral = 0xf08080,
|
||||
light_cyan = 0xe0ffff,
|
||||
light_goldenrod_yellow = 0xfafad2,
|
||||
light_gray = 0xd3d3d3,
|
||||
light_green = 0x90ee90,
|
||||
light_grey = light_gray,
|
||||
light_pink = 0xffb6c1,
|
||||
light_salmon = 0xffa07a,
|
||||
light_sea_green = 0x20b2aa,
|
||||
light_sky_blue = 0x87cefa,
|
||||
light_slate_gray = 0x778899,
|
||||
light_slate_grey = light_slate_gray,
|
||||
light_steel_blue = 0xb0c4de,
|
||||
light_yellow = 0xffffe0,
|
||||
lime = 0x00FF00,
|
||||
lime_green = 0x32cd32,
|
||||
linen = 0xfaf0e6,
|
||||
magenta = 0xff00ff,
|
||||
maroon = 0x800000,
|
||||
medium_aquamarine = 0x66cdaa,
|
||||
medium_blue = 0xcd,
|
||||
medium_orchid = 0xba55d3,
|
||||
medium_purple = 0x9370db,
|
||||
medium_sea_green = 0x3cb371,
|
||||
medium_slate_blue = 0x7b68ee,
|
||||
medium_spring_green = 0xfa9a,
|
||||
medium_turquoise = 0x48d1cc,
|
||||
medium_violet_red = 0xc71585,
|
||||
midnight_blue = 0x191970,
|
||||
mint_cream = 0xf5fffa,
|
||||
|
||||
misty_rose = 0xffe4e1,
|
||||
moccasin = 0xffe4b5,
|
||||
navajo_white = 0xffdead,
|
||||
navy = 0x000080,
|
||||
old_lace = 0xfdf5e6,
|
||||
olive = 0x808000,
|
||||
olive_drab = 0x6b8e23,
|
||||
orange = 0xffa500,
|
||||
orange_red = 0xff4500,
|
||||
orchid = 0xda70d6,
|
||||
pale_goldenrod = 0xeee8aa,
|
||||
pale_green = 0x98fb98,
|
||||
pale_turquoise = 0xafeeee,
|
||||
pale_violet_red = 0xdb7093,
|
||||
papaya_whip = 0xffefd5,
|
||||
peach_puff = 0xffdab9,
|
||||
peru = 0xcd853f,
|
||||
pink = 0xffc0cb,
|
||||
plum = 0xdda0dd,
|
||||
powder_blue = 0xb0e0e6,
|
||||
purple = 0x800080,
|
||||
red = 0xFF0000,
|
||||
rosy_brown = 0xbc8f8f,
|
||||
royal_blue = 0x4169e1,
|
||||
saddle_brown = 0x8b4513,
|
||||
salmon = 0xfa8072,
|
||||
sandy_brown = 0xf4a460,
|
||||
sea_green = 0x2e8b57,
|
||||
sea_shell = 0xfff5ee,
|
||||
sienna = 0xa0522d,
|
||||
silver = 0xc0c0c0,
|
||||
sky_blue = 0x87ceeb,
|
||||
slate_blue = 0x6a5acd,
|
||||
slate_gray = 0x708090,
|
||||
slate_grey = 0x708090,
|
||||
snow = 0xfffafa,
|
||||
spring_green = 0xff7f,
|
||||
steel_blue = 0x4682b4,
|
||||
tan = 0xd2b48c,
|
||||
teal = 0x008080,
|
||||
thistle = 0xd8bfd8,
|
||||
tomato = 0xff6347,
|
||||
turquoise = 0x40e0d0,
|
||||
violet = 0xee82ee,
|
||||
wheat = 0xf5deb3,
|
||||
white = 0xFFFFFF,
|
||||
white_smoke = 0xf5f5f5,
|
||||
yellow = 0xFFFF00,
|
||||
yellow_green = 0x9acd32,
|
||||
|
||||
//temporary defintions, these will be replaced by color schema
|
||||
button_face_shadow_start = 0xF5F4F2,
|
||||
button_face_shadow_end = 0xD5D2CA,
|
||||
button_face = 0xD4D0C8,
|
||||
dark_border = 0x404040,
|
||||
gray_border = 0x808080,
|
||||
highlight = 0x1CC4F7
|
||||
};
|
||||
|
||||
//Some helper types to identify an integer as color.
|
||||
enum class color_rgb : unsigned{};
|
||||
enum class color_argb: unsigned{};
|
||||
enum class color_rgba : unsigned{};
|
||||
|
||||
class color
|
||||
{
|
||||
public:
|
||||
color() = default;
|
||||
color(colors);
|
||||
color(colors, double alpha);
|
||||
color(color_rgb);
|
||||
color(color_argb);
|
||||
color(color_rgba);
|
||||
color(unsigned red, unsigned green, unsigned blue);
|
||||
color(unsigned red, unsigned green, unsigned blue, double alpha);
|
||||
|
||||
/// Initializes the color with a CSS-like rgb string.
|
||||
color(std::string css_rgb);
|
||||
|
||||
color& alpha(double); ///< Sets alpha channel
|
||||
color& from_rgb(unsigned red, unsigned green, unsigned blue); ///< immutable alpha channel
|
||||
|
||||
/// Sets color with a HSL value.
|
||||
/// @param hue in range of [0, 360]
|
||||
/// @param saturation in range of [0, 1]
|
||||
/// @param lightness in range of [0, 1]
|
||||
color& from_hsl(double hue, double saturation, double lightness); ///< immutable alpha channel
|
||||
|
||||
color blend(const color& bgcolor, bool ignore_bgcolor_alpha) const;
|
||||
|
||||
///< Blends two colors with the specified alpha, and the alpha values that come with these two colors are both ignored.
|
||||
color blend(const color& bgcolor, double alpha) const;
|
||||
|
||||
///< Determines whether the color is completely transparent.
|
||||
bool invisible() const;
|
||||
pixel_color_t px_color() const;
|
||||
pixel_argb_t argb() const;
|
||||
pixel_rgba_t rgba() const;
|
||||
|
||||
const double& r() const;
|
||||
const double& g() const;
|
||||
const double& b() const;
|
||||
const double& a() const;
|
||||
|
||||
bool operator==(const color& other) const;
|
||||
bool operator!=(const color& other) const;
|
||||
private:
|
||||
double r_;
|
||||
double g_;
|
||||
double b_;
|
||||
double a_{ 0.0 }; //invisible
|
||||
};
|
||||
|
||||
|
||||
struct rectangle;
|
||||
|
||||
struct point
|
||||
@@ -163,8 +388,9 @@ namespace nana
|
||||
|
||||
struct size
|
||||
{
|
||||
using value_type = unsigned;
|
||||
size();
|
||||
size(unsigned width, unsigned height);
|
||||
size(value_type width, value_type height);
|
||||
size(const rectangle&);
|
||||
|
||||
size& operator=(const rectangle&);
|
||||
@@ -175,8 +401,8 @@ namespace nana
|
||||
bool operator!=(const size& rhs) const;
|
||||
size operator+(const size&) const;
|
||||
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
value_type width;
|
||||
value_type height;
|
||||
};
|
||||
|
||||
struct rectangle
|
||||
@@ -247,6 +473,16 @@ namespace nana
|
||||
{
|
||||
top, center, bottom
|
||||
};
|
||||
|
||||
///The definition of the four corners of the world
|
||||
enum class direction
|
||||
{
|
||||
north,
|
||||
south,
|
||||
east,
|
||||
west,
|
||||
southeast
|
||||
};
|
||||
}//end namespace nana
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
//Windows:
|
||||
#define NANA_WINDOWS 1
|
||||
#define PLATFORM_SPEC_HPP <nana/detail/win32/platform_spec.hpp>
|
||||
#define GUI_BEDROCK_HPP <nana/gui/detail/bedrock.hpp>
|
||||
|
||||
//Test if it is MINGW
|
||||
#if defined(__MINGW32__)
|
||||
@@ -31,8 +30,6 @@
|
||||
#define NANA_LINUX 1
|
||||
#define NANA_X11 1
|
||||
#define PLATFORM_SPEC_HPP <nana/detail/linux_X11/platform_spec.hpp>
|
||||
#define GUI_BEDROCK_HPP <nana/gui/detail/bedrock.hpp>
|
||||
|
||||
#define STD_CODECVT_NOT_SUPPORTED
|
||||
#endif
|
||||
|
||||
|
||||
@@ -42,6 +42,14 @@ namespace nana
|
||||
std::size_t strlen(const char_t* str);
|
||||
double strtod(const char_t* str, char_t** endptr);
|
||||
char_t* strcpy(char_t* dest, const char_t* source);
|
||||
|
||||
//Workaround for no implemenation of std::stoi in MinGW.
|
||||
int stoi(const std::string&, std::size_t * pos = nullptr, int base = 10);
|
||||
int stoi(const std::wstring&, std::size_t* pos = nullptr, int base = 10);
|
||||
|
||||
//Workaround for no implemenation of std::stod in MinGW.
|
||||
double stod(const std::string&, std::size_t * pos = nullptr);
|
||||
double stod(const std::wstring&, std::size_t* pos = nullptr);
|
||||
}
|
||||
|
||||
#if defined(NANA_WINDOWS)
|
||||
|
||||
@@ -85,11 +85,6 @@ namespace detail
|
||||
{
|
||||
typedef std::shared_ptr<font_tag> font_ptr_t;
|
||||
|
||||
drawable_impl_type();
|
||||
~drawable_impl_type();
|
||||
|
||||
void fgcolor(unsigned color);
|
||||
|
||||
Pixmap pixmap;
|
||||
GC context;
|
||||
font_ptr_t font;
|
||||
@@ -107,8 +102,20 @@ namespace detail
|
||||
XftColor xft_fgcolor;
|
||||
const std::string charset(const nana::string& str, const std::string& strcode);
|
||||
#endif
|
||||
drawable_impl_type();
|
||||
~drawable_impl_type();
|
||||
|
||||
void fgcolor(const ::nana::color&); //deprecated
|
||||
void set_color(const ::nana::color&);
|
||||
void set_text_color(const ::nana::color&);
|
||||
|
||||
void update_color();
|
||||
void update_text_color();
|
||||
private:
|
||||
unsigned fgcolor_{0xFFFFFFFF};
|
||||
unsigned current_color_{ 0xFFFFFF };
|
||||
unsigned color_{ 0xFFFFFFFF };
|
||||
unsigned text_color_{ 0xFFFFFFFF };
|
||||
|
||||
#if defined(NANA_UNICODE)
|
||||
struct conv_tag
|
||||
{
|
||||
@@ -217,9 +224,9 @@ namespace detail
|
||||
void read_keystate(XKeyEvent&);
|
||||
|
||||
XIC caret_input_context(native_window_type) const;
|
||||
void caret_open(native_window_type, unsigned width, unsigned height);
|
||||
void caret_open(native_window_type, const ::nana::size&);
|
||||
void caret_close(native_window_type);
|
||||
void caret_pos(native_window_type, int x, int y);
|
||||
void caret_pos(native_window_type, const ::nana::point&);
|
||||
void caret_visible(native_window_type, bool);
|
||||
void caret_flash(caret_tag&);
|
||||
bool caret_update(native_window_type, nana::paint::graphics& root_graph, bool is_erase_caret_from_root_graph);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Platform Specification Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -91,8 +92,8 @@ namespace detail
|
||||
|
||||
HDC context;
|
||||
HBITMAP pixmap;
|
||||
pixel_rgb_t* pixbuf_ptr;
|
||||
std::size_t bytes_per_line;
|
||||
pixel_argb_t* pixbuf_ptr{nullptr};
|
||||
std::size_t bytes_per_line{0};
|
||||
font_ptr_t font;
|
||||
|
||||
struct pen_spec
|
||||
@@ -102,7 +103,7 @@ namespace detail
|
||||
int style;
|
||||
int width;
|
||||
|
||||
void set(HDC context, int style, int width, nana::color_t color);
|
||||
void set(HDC context, int style, int width,unsigned color);
|
||||
}pen;
|
||||
|
||||
struct brush_spec
|
||||
@@ -111,9 +112,9 @@ namespace detail
|
||||
|
||||
HBRUSH handle;
|
||||
t style;
|
||||
nana::color_t color;
|
||||
unsigned color;
|
||||
|
||||
void set(HDC context, t style, nana::color_t color);
|
||||
void set(HDC context, t style, unsigned color);
|
||||
}brush;
|
||||
|
||||
struct round_region_spec
|
||||
@@ -136,9 +137,16 @@ namespace detail
|
||||
drawable_impl_type();
|
||||
~drawable_impl_type();
|
||||
|
||||
void fgcolor(nana::color_t);
|
||||
void fgcolor(const ::nana::color&); //deprecated
|
||||
unsigned get_color() const;
|
||||
void set_color(const ::nana::color&);
|
||||
void set_text_color(const ::nana::color&);
|
||||
|
||||
void update_pen();
|
||||
void update_brush();
|
||||
private:
|
||||
unsigned fgcolor_;
|
||||
unsigned color_{ 0xffffffff };
|
||||
unsigned text_color_{0xffffffff};
|
||||
};
|
||||
|
||||
class platform_spec
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Basis Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -25,6 +25,7 @@ namespace nana
|
||||
struct native_window_handle_impl{};
|
||||
struct window_handle_impl{};
|
||||
struct event_handle_impl{};
|
||||
struct native_drawable_impl{};
|
||||
}
|
||||
|
||||
enum class checkstate
|
||||
@@ -63,56 +64,39 @@ namespace nana
|
||||
struct frame_tag: widget_tag{ static const flags value = flags::frame; };
|
||||
}// end namespace category
|
||||
|
||||
typedef detail::native_window_handle_impl * native_window_type;
|
||||
|
||||
typedef detail::window_handle_impl* window; ///< \see [What is window class ](https://sourceforge.net/p/nanapro/discussion/general/thread/bd0fabfb/)
|
||||
typedef detail::event_handle_impl* event_handle;
|
||||
using native_window_type = detail::native_window_handle_impl*;
|
||||
using window = detail::window_handle_impl*; ///< \see [What is window class ](https://sourceforge.net/p/nanapro/discussion/general/thread/bd0fabfb/)
|
||||
using event_handle = detail::event_handle_impl*;
|
||||
using native_drawable_type = detail::native_drawable_impl*;
|
||||
|
||||
|
||||
struct keyboard
|
||||
{
|
||||
enum t{
|
||||
enum{
|
||||
//Control Code for ASCII
|
||||
select_all = 0x1,
|
||||
end_of_text = 0x3, //Ctrl+C
|
||||
backspace = 0x8, tab = 0x9,
|
||||
enter_n = 0xA, enter = 0xD, enter_r = 0xD,
|
||||
alt = 0x12,
|
||||
sync_idel = 0x16, //Ctrl+V
|
||||
cancel = 0x18, //Ctrl+X
|
||||
end_of_medium = 0x19, //Ctrl+Y
|
||||
substitute = 0x1A, //Ctrl+Z
|
||||
escape = 0x1B,
|
||||
start_of_headline = 0x1, //Ctrl+A
|
||||
end_of_text = 0x3, //Ctrl+C
|
||||
backspace = 0x8, tab = 0x9,
|
||||
enter_n = 0xA, enter = 0xD, enter_r = 0xD,
|
||||
alt = 0x12,
|
||||
sync_idel = 0x16, //Ctrl+V
|
||||
cancel = 0x18, //Ctrl+X
|
||||
end_of_medium = 0x19, //Ctrl+Y
|
||||
substitute = 0x1A, //Ctrl+Z
|
||||
escape = 0x1B,
|
||||
|
||||
//The following names are intuitive name of ASCII control codes
|
||||
copy = 0x3, //end_of_text
|
||||
paste = 0x16, //sync_idel
|
||||
cut = 0x18, //cancel
|
||||
redo = 0x19, //end_of_medium
|
||||
undo = 0x1A, //substitue
|
||||
select_all = start_of_headline,
|
||||
copy = end_of_text,
|
||||
paste = sync_idel,
|
||||
cut = cancel,
|
||||
redo = end_of_medium,
|
||||
undo = substitute,
|
||||
|
||||
//System Code for OS
|
||||
os_pageup = 0x21, os_pagedown,
|
||||
os_arrow_left = 0x25, os_arrow_up, os_arrow_right, os_arrow_down,
|
||||
os_insert = 0x2D, os_del
|
||||
};
|
||||
};
|
||||
|
||||
namespace color
|
||||
{
|
||||
enum
|
||||
{
|
||||
white = 0xFFFFFF,
|
||||
blue = 0x0000FF,
|
||||
green = 0x00FF00,
|
||||
red = 0xFF0000,
|
||||
|
||||
button_face_shadow_start = 0xF5F4F2,
|
||||
button_face_shadow_end = 0xD5D2CA,
|
||||
button_face = 0xD4D0C8,
|
||||
dark_border = 0x404040,
|
||||
gray_border = 0x808080,
|
||||
highlight = 0x1CC4F7
|
||||
os_pageup = 0x21, os_pagedown,
|
||||
os_arrow_left = 0x25, os_arrow_up, os_arrow_right, os_arrow_down,
|
||||
os_insert = 0x2D, os_del
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Basic Window Widget Definition
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -14,7 +14,7 @@
|
||||
#define NANA_GUI_DETAIL_BASIC_WINDOW_HPP
|
||||
#include "drawer.hpp"
|
||||
#include "events_holder.hpp"
|
||||
#include "../basis.hpp"
|
||||
#include "widget_colors.hpp"
|
||||
#include <nana/basic_types.hpp>
|
||||
#include <nana/system/platform.hpp>
|
||||
#include <nana/gui/effects.hpp>
|
||||
@@ -74,7 +74,7 @@ namespace detail
|
||||
struct basic_window
|
||||
: public events_holder
|
||||
{
|
||||
typedef std::vector<basic_window*> container;
|
||||
using container = std::vector<basic_window*>;
|
||||
|
||||
struct root_context
|
||||
{
|
||||
@@ -119,6 +119,8 @@ namespace detail
|
||||
bool is_ancestor_of(const basic_window* wd) const;
|
||||
bool visible_parents() const;
|
||||
bool belong_to_lazy() const;
|
||||
|
||||
bool is_draw_through() const; ///< Determines whether it is a draw-through window.
|
||||
public:
|
||||
//Override event_holder
|
||||
bool set_events(const std::shared_ptr<general_events>&) override;
|
||||
@@ -155,7 +157,7 @@ namespace detail
|
||||
{
|
||||
bool enabled :1;
|
||||
bool dbl_click :1;
|
||||
bool capture :1; //if mouse button is down, it always receive mouse move even the mouse is out of its rectangle
|
||||
bool captured :1; //if mouse button is down, it always receive mouse move even the mouse is out of its rectangle
|
||||
bool modal :1;
|
||||
bool take_active:1; //If take_active is false, other.active_window still keeps the focus.
|
||||
bool refreshing :1;
|
||||
@@ -163,7 +165,8 @@ namespace detail
|
||||
bool dropable :1; //Whether the window has make mouse_drop event.
|
||||
bool fullscreen :1; //When the window is maximizing whether it fit for fullscreen.
|
||||
bool borderless :1;
|
||||
unsigned Reserved :22;
|
||||
bool make_bground_declared : 1; //explicitly make bground for bground effects
|
||||
unsigned Reserved :21;
|
||||
unsigned char tab; //indicate a window that can receive the keyboard TAB
|
||||
mouse_action action;
|
||||
}flags;
|
||||
@@ -174,13 +177,8 @@ namespace detail
|
||||
std::shared_ptr<general_events> events_ptr;
|
||||
general_events* attached_events;
|
||||
}together;
|
||||
|
||||
struct
|
||||
{
|
||||
color_t foreground;
|
||||
color_t background;
|
||||
color_t active;
|
||||
}color;
|
||||
|
||||
widget_colors* scheme{ nullptr };
|
||||
|
||||
struct
|
||||
{
|
||||
@@ -211,6 +209,8 @@ namespace detail
|
||||
#endif
|
||||
cursor state_cursor{nana::cursor::arrow};
|
||||
basic_window* state_cursor_window{ nullptr };
|
||||
|
||||
std::function<void()> draw_through; ///< A draw through renderer for root widgets.
|
||||
};
|
||||
|
||||
const category::flags category;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Bedrock Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "events_operation.hpp"
|
||||
#include "runtime_manager.hpp"
|
||||
#include "general_events.hpp"
|
||||
#include "color_schemes.hpp"
|
||||
#include "internal_scope_guard.hpp"
|
||||
|
||||
namespace nana
|
||||
@@ -41,7 +42,7 @@ namespace detail
|
||||
|
||||
~bedrock();
|
||||
void pump_event(window, bool is_modal);
|
||||
void map_thread_root_buffer(core_window_t* );
|
||||
void map_thread_root_buffer(core_window_t*, bool forced);
|
||||
static int inc_window(unsigned tid = 0);
|
||||
thread_context* open_thread_context(unsigned tid = 0);
|
||||
thread_context* get_thread_context(unsigned tid = 0);
|
||||
@@ -66,6 +67,7 @@ namespace detail
|
||||
bool whether_keyboard_shortkey() const;
|
||||
|
||||
element_store& get_element_store() const;
|
||||
void map_through_widgets(core_window_t*, native_drawable_type);
|
||||
public:
|
||||
void event_expose(core_window_t *, bool exposed);
|
||||
void event_move(core_window_t*, int x, int y);
|
||||
@@ -76,22 +78,27 @@ namespace detail
|
||||
void set_cursor(core_window_t*, nana::cursor, thread_context*);
|
||||
void define_state_cursor(core_window_t*, nana::cursor, thread_context*);
|
||||
void undefine_state_cursor(core_window_t*, thread_context*);
|
||||
|
||||
widget_colors& get_scheme_template(scheme_factory_base&&);
|
||||
std::unique_ptr<widget_colors> make_scheme(scheme_factory_base&&);
|
||||
public:
|
||||
window_manager_t wd_manager;
|
||||
events_operation evt_operation;
|
||||
window_manager_t wd_manager;
|
||||
|
||||
runtime_manager<core_window_t*, bedrock> rt_manager;
|
||||
|
||||
bool emit(event_code, core_window_t*, const arg_mouse&, bool ask_update, thread_context*);
|
||||
bool emit(event_code, core_window_t*, const event_arg_interface&, bool ask_update, thread_context*);
|
||||
bool emit_drawer(event_code, core_window_t*, const event_arg_interface&, thread_context*);
|
||||
bool emit(event_code, core_window_t*, const event_arg&, bool ask_update, thread_context*);
|
||||
bool emit_drawer(event_code, core_window_t*, const event_arg&, thread_context*);
|
||||
private:
|
||||
void _m_emit_core(event_code, core_window_t*, bool draw_only, const event_arg_interface&);
|
||||
void _m_emit_core(event_code, core_window_t*, bool draw_only, const event_arg&);
|
||||
void _m_event_filter(event_code, core_window_t*, thread_context*);
|
||||
void _m_except_handler();
|
||||
private:
|
||||
static bedrock bedrock_object;
|
||||
|
||||
struct pi_data;
|
||||
pi_data* pi_data_;
|
||||
struct private_impl;
|
||||
private_impl *impl_;
|
||||
};//end class bedrock
|
||||
|
||||
18
include/nana/gui/detail/bedrock_pi_data.hpp
Normal file
18
include/nana/gui/detail/bedrock_pi_data.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef NANA_DETAIL_BEDROCK_PI_DATA_HPP
|
||||
#define NANA_DETAIL_BEDROCK_PI_DATA_HPP
|
||||
|
||||
#include <nana/gui/detail/bedrock.hpp>
|
||||
#include "color_schemes.hpp"
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
struct bedrock::pi_data
|
||||
{
|
||||
color_schemes scheme;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
80
include/nana/gui/detail/color_schemes.hpp
Normal file
80
include/nana/gui/detail/color_schemes.hpp
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Color Schemes
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/color_schemes.hpp
|
||||
* @description:
|
||||
*/
|
||||
#ifndef NANA_DETAIL_COLOR_SCHEMES_HPP
|
||||
#define NANA_DETAIL_COLOR_SCHEMES_HPP
|
||||
|
||||
#include "widget_colors.hpp"
|
||||
#include <nana/pat/cloneable.hpp>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
class scheme_factory_base
|
||||
{
|
||||
public:
|
||||
struct factory_identifier{};
|
||||
virtual ~scheme_factory_base() = default;
|
||||
|
||||
virtual factory_identifier* get_id() const = 0;
|
||||
virtual std::unique_ptr<widget_colors> create() = 0;
|
||||
virtual std::unique_ptr<widget_colors> create(widget_colors&) = 0;
|
||||
};
|
||||
|
||||
template<typename Scheme>
|
||||
class scheme_factory
|
||||
: public scheme_factory_base
|
||||
{
|
||||
private:
|
||||
factory_identifier* get_id() const override
|
||||
{
|
||||
return &fid_;
|
||||
}
|
||||
|
||||
std::unique_ptr<widget_colors> create() override
|
||||
{
|
||||
return std::unique_ptr<widget_colors>(new Scheme);
|
||||
}
|
||||
|
||||
std::unique_ptr<widget_colors> create(widget_colors& other) override
|
||||
{
|
||||
return std::unique_ptr<widget_colors>{new Scheme(static_cast<Scheme&>(other))};
|
||||
}
|
||||
private:
|
||||
static factory_identifier fid_;
|
||||
};
|
||||
|
||||
template<typename Scheme>
|
||||
scheme_factory_base::factory_identifier scheme_factory<Scheme>::fid_;
|
||||
|
||||
class color_schemes
|
||||
{
|
||||
struct implement;
|
||||
color_schemes(const color_schemes&) = delete;
|
||||
color_schemes(color_schemes&&) = delete;
|
||||
color_schemes& operator=(const color_schemes&) = delete;
|
||||
color_schemes& operator=(color_schemes&&) = delete;
|
||||
public:
|
||||
using scheme = widget_colors;
|
||||
|
||||
color_schemes();
|
||||
~color_schemes();
|
||||
|
||||
scheme& scheme_template(scheme_factory_base&&);
|
||||
std::unique_ptr<scheme> create(scheme_factory_base&&);
|
||||
private:
|
||||
implement * impl_;
|
||||
};
|
||||
}//end namespace detail;
|
||||
}//end namespace nana
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Drawer Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -110,7 +110,7 @@ namespace nana
|
||||
void key_char(const arg_keyboard&);
|
||||
void key_release(const arg_keyboard&);
|
||||
void shortkey(const arg_keyboard&);
|
||||
void map(window); //Copy the root buffer to screen
|
||||
void map(window, bool forced); //Copy the root buffer to screen
|
||||
void refresh();
|
||||
drawer_trigger* realizer() const;
|
||||
void attached(widget&, drawer_trigger&);
|
||||
@@ -123,7 +123,7 @@ namespace nana
|
||||
void _m_bground_pre();
|
||||
void _m_bground_end();
|
||||
void _m_draw_dynamic_drawing_object();
|
||||
void _m_use_refresh();
|
||||
bool _m_lazy_decleared() const;
|
||||
|
||||
template<typename Arg, typename Mfptr>
|
||||
void _m_emit(event_code evt_code, const Arg& arg, Mfptr mfptr)
|
||||
@@ -139,14 +139,20 @@ namespace nana
|
||||
{
|
||||
realizer_->_m_reset_overrided();
|
||||
(realizer_->*mfptr)(graphics, arg);
|
||||
mth_state_[pos] = (realizer_->_m_overrided() ? method_state::overrided : method_state::not_overrided);
|
||||
|
||||
//Check realizer, when the window is closed in that event handler, the drawer will be
|
||||
//detached and realizer will be a nullptr
|
||||
if(realizer_)
|
||||
mth_state_[pos] = (realizer_->_m_overrided() ? method_state::overrided : method_state::not_overrided);
|
||||
}
|
||||
else
|
||||
(realizer_->*mfptr)(graphics, arg);
|
||||
|
||||
_m_use_refresh();
|
||||
_m_draw_dynamic_drawing_object();
|
||||
_m_bground_end();
|
||||
if (_m_lazy_decleared())
|
||||
{
|
||||
_m_draw_dynamic_drawing_object();
|
||||
_m_bground_end();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <nana/gui/effects.hpp>
|
||||
#include <nana/paint/graphics.hpp>
|
||||
#include <nana/paint/pixel_buffer.hpp>
|
||||
|
||||
#include <nana/gui/layout_utility.hpp>
|
||||
|
||||
namespace nana{
|
||||
@@ -12,7 +11,7 @@ namespace nana{
|
||||
template<typename CoreWindow>
|
||||
class edge_nimbus_renderer
|
||||
{
|
||||
edge_nimbus_renderer(){}
|
||||
edge_nimbus_renderer() = default;
|
||||
public:
|
||||
typedef CoreWindow core_window_t;
|
||||
typedef window_layout window_layer;
|
||||
@@ -29,7 +28,7 @@ namespace nana{
|
||||
return 2;
|
||||
}
|
||||
|
||||
bool render(core_window_t * wd)
|
||||
bool render(core_window_t * wd, bool forced)
|
||||
{
|
||||
bool rendered = false;
|
||||
core_window_t * root_wd = wd->root_widget;
|
||||
@@ -44,7 +43,7 @@ namespace nana{
|
||||
auto graph = root_wd->root_graph;
|
||||
|
||||
std::vector<core_window_t*> erase;
|
||||
std::vector<rectangle> r_set;
|
||||
std::vector<std::pair<rectangle,core_window_t*>> rd_set;
|
||||
nana::rectangle r;
|
||||
for(auto & action : nimbus)
|
||||
{
|
||||
@@ -53,8 +52,12 @@ namespace nana{
|
||||
if(action.window == wd)
|
||||
rendered = true;
|
||||
|
||||
r_set.push_back(r);
|
||||
action.rendered = true;
|
||||
//Avoiding duplicated rendering. If the window is declared to lazy refresh, it should be rendered.
|
||||
if ((forced && (action.window == wd)) || !action.rendered || (action.window->other.upd_state == core_window_t::update_state::refresh))
|
||||
{
|
||||
rd_set.emplace_back(r, action.window);
|
||||
action.rendered = true;
|
||||
}
|
||||
}
|
||||
else if(action.rendered)
|
||||
{
|
||||
@@ -77,13 +80,9 @@ namespace nana{
|
||||
graph->paste(native, r, r.x, r.y);
|
||||
}
|
||||
|
||||
auto visual_iterator = r_set.begin();
|
||||
//Render
|
||||
for(auto & action : nimbus)
|
||||
{
|
||||
if(action.rendered)
|
||||
_m_render_edge_nimbus(action.window, *(visual_iterator++));
|
||||
}
|
||||
for (auto & rd : rd_set)
|
||||
_m_render_edge_nimbus(rd.second, rd.first);
|
||||
}
|
||||
return rendered;
|
||||
}
|
||||
@@ -102,7 +101,7 @@ namespace nana{
|
||||
nana::rectangle r(visual);
|
||||
r.pare_off(-static_cast<int>(weight()));
|
||||
nana::rectangle good_r;
|
||||
if(overlap(r, nana::rectangle(wd->root_graph->size()), good_r))
|
||||
if(overlap(r, wd->root_graph->size(), good_r))
|
||||
{
|
||||
if( (good_r.x < wd->pos_root.x) || (good_r.y < wd->pos_root.y) ||
|
||||
(good_r.x + good_r.width > visual.x + visual.width) || (good_r.y + good_r.height > visual.y + visual.height))
|
||||
@@ -110,7 +109,7 @@ namespace nana{
|
||||
auto graph = wd->root_graph;
|
||||
nana::paint::pixel_buffer pixbuf(graph->handle(), r);
|
||||
|
||||
pixel_rgb_t px0, px1, px2, px3;
|
||||
pixel_argb_t px0, px1, px2, px3;
|
||||
|
||||
px0 = pixbuf.pixel(0, 0);
|
||||
px1 = pixbuf.pixel(r.width - 1, 0);
|
||||
@@ -120,12 +119,12 @@ namespace nana{
|
||||
good_r.x = good_r.y = 1;
|
||||
good_r.width = r.width - 2;
|
||||
good_r.height = r.height - 2;
|
||||
pixbuf.rectangle(good_r, wd->color.active, 0.95, false);
|
||||
pixbuf.rectangle(good_r, wd->scheme->activated.get_color(), 0.95, false);
|
||||
|
||||
good_r.x = good_r.y = 0;
|
||||
good_r.width = r.width;
|
||||
good_r.height = r.height;
|
||||
pixbuf.rectangle(good_r, wd->color.active, 0.4, false);
|
||||
pixbuf.rectangle(good_r, wd->scheme->activated.get_color(), 0.4, false);
|
||||
|
||||
pixbuf.pixel(0, 0, px0);
|
||||
pixbuf.pixel(r.width - 1, 0, px1);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Definition of General Events
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -28,27 +28,32 @@ namespace nana
|
||||
class event_interface
|
||||
{
|
||||
public:
|
||||
virtual ~event_interface(){}
|
||||
virtual ~event_interface() = default;
|
||||
virtual void remove(event_handle) = 0;
|
||||
};
|
||||
|
||||
class docker_interface
|
||||
{
|
||||
public:
|
||||
virtual ~docker_interface(){}
|
||||
virtual ~docker_interface() = default;
|
||||
virtual event_interface* get_event() const = 0;
|
||||
};
|
||||
|
||||
class event_arg_interface
|
||||
{
|
||||
public:
|
||||
virtual ~event_arg_interface(){}
|
||||
};
|
||||
|
||||
void events_operation_register(event_handle);
|
||||
void events_operation_cancel(event_handle);
|
||||
}//end namespace detail
|
||||
|
||||
class event_arg
|
||||
{
|
||||
public:
|
||||
virtual ~event_arg();
|
||||
|
||||
void stop_propagation() const;
|
||||
bool propagation_stopped() const;
|
||||
private:
|
||||
mutable bool stop_propagation_{ false };
|
||||
};
|
||||
|
||||
struct general_events;
|
||||
|
||||
template<typename Arg>
|
||||
@@ -62,15 +67,16 @@ namespace nana
|
||||
{
|
||||
basic_event * const event_ptr;
|
||||
std::function<void(arg_reference)> invoke;
|
||||
bool flag_entered = false;
|
||||
bool flag_deleted = false;
|
||||
bool flag_entered{ false };
|
||||
bool flag_deleted{ false };
|
||||
bool unignorable{false};
|
||||
|
||||
docker(basic_event * s, std::function<void(arg_reference)> && ivk)
|
||||
: event_ptr(s), invoke(std::move(ivk))
|
||||
docker(basic_event * s, std::function<void(arg_reference)> && ivk, bool unignorable_flag)
|
||||
: event_ptr(s), invoke(std::move(ivk)), unignorable(unignorable_flag)
|
||||
{}
|
||||
|
||||
docker(basic_event * s, const std::function<void(arg_reference)> & ivk)
|
||||
: event_ptr(s), invoke(ivk)
|
||||
docker(basic_event * s, const std::function<void(arg_reference)> & ivk, bool unignorable_flag)
|
||||
: event_ptr(s), invoke(ivk), unignorable(unignorable_flag)
|
||||
{}
|
||||
|
||||
~docker()
|
||||
@@ -91,8 +97,8 @@ namespace nana
|
||||
if (nullptr == dockers_)
|
||||
dockers_.reset(new std::vector<std::unique_ptr<docker>>);
|
||||
|
||||
typedef typename std::remove_reference<Function>::type prototype;
|
||||
std::unique_ptr<docker> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn))));
|
||||
using prototype = typename std::remove_reference<Function>::type;
|
||||
std::unique_ptr<docker> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
|
||||
auto evt = reinterpret_cast<event_handle>(static_cast<detail::docker_interface*>(dck.get()));
|
||||
dockers_->emplace(dockers_->begin(), std::move(dck));
|
||||
detail::events_operation_register(evt);
|
||||
@@ -113,8 +119,8 @@ namespace nana
|
||||
if (nullptr == dockers_)
|
||||
dockers_.reset(new std::vector<std::unique_ptr<docker>>);
|
||||
|
||||
typedef typename std::remove_reference<Function>::type prototype;
|
||||
std::unique_ptr<docker> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn))));
|
||||
using prototype = typename std::remove_reference<Function>::type;
|
||||
std::unique_ptr<docker> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
|
||||
auto evt = reinterpret_cast<event_handle>(static_cast<detail::docker_interface*>(dck.get()));
|
||||
dockers_->emplace_back(std::move(dck));
|
||||
detail::events_operation_register(evt);
|
||||
@@ -127,6 +133,24 @@ namespace nana
|
||||
return connect(std::forward<Function>(fn));
|
||||
}
|
||||
|
||||
template<typename Function>
|
||||
event_handle connect_unignorable(Function && fn, bool in_front = false)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
if (nullptr == dockers_)
|
||||
dockers_.reset(new std::vector<std::unique_ptr<docker>>);
|
||||
|
||||
using prototype = typename std::remove_reference<Function>::type;
|
||||
std::unique_ptr<docker> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), true));
|
||||
auto evt = reinterpret_cast<event_handle>(static_cast<detail::docker_interface*>(dck.get()));
|
||||
if (in_front)
|
||||
dockers_->emplace(dockers_->begin(), std::move(dck));
|
||||
else
|
||||
dockers_->emplace_back(std::move(dck));
|
||||
detail::events_operation_register(evt);
|
||||
return evt;
|
||||
}
|
||||
|
||||
std::size_t length() const
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
@@ -158,20 +182,30 @@ namespace nana
|
||||
(*output++) = dck.get();
|
||||
}
|
||||
|
||||
bool stop_propagation = false;
|
||||
for (; transitory != output; ++transitory)
|
||||
{
|
||||
std::unique_ptr<docker> p(*transitory);
|
||||
auto i = std::find(dockers.begin(), dockers.end(), p);
|
||||
auto docker_ptr = *transitory;
|
||||
if (stop_propagation && !docker_ptr->unignorable)
|
||||
continue;
|
||||
|
||||
auto i = std::find_if(dockers.begin(), dockers.end(), [docker_ptr](std::unique_ptr<docker>& p){
|
||||
return (docker_ptr == p.get());
|
||||
});
|
||||
|
||||
if (i != dockers.end())
|
||||
{
|
||||
(*transitory)->flag_entered = true;
|
||||
(*transitory)->invoke(arg);
|
||||
(*transitory)->flag_entered = false;
|
||||
docker_ptr->flag_entered = true;
|
||||
docker_ptr->invoke(arg);
|
||||
|
||||
if ((*transitory)->flag_deleted)
|
||||
if (arg.propagation_stopped())
|
||||
stop_propagation = true;
|
||||
|
||||
docker_ptr->flag_entered = false;
|
||||
|
||||
if (docker_ptr->flag_deleted)
|
||||
dockers.erase(i);
|
||||
}
|
||||
p.release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +216,7 @@ namespace nana
|
||||
dockers_.reset();
|
||||
}
|
||||
|
||||
void remove(event_handle evt)
|
||||
void remove(event_handle evt) override
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
if (dockers_)
|
||||
@@ -362,7 +396,7 @@ namespace nana
|
||||
};
|
||||
|
||||
struct arg_mouse
|
||||
: public detail::event_arg_interface
|
||||
: public event_arg
|
||||
{
|
||||
event_code evt_code;
|
||||
::nana::window window_handle;
|
||||
@@ -386,27 +420,27 @@ namespace nana
|
||||
unsigned distance; //expressed in multiples or divisions of 120
|
||||
};
|
||||
|
||||
struct arg_dropfiles : public detail::event_arg_interface
|
||||
struct arg_dropfiles : public event_arg
|
||||
{
|
||||
::nana::window window_handle;
|
||||
::nana::point pos;
|
||||
std::vector<nana::string> files;
|
||||
};
|
||||
|
||||
struct arg_expose : public detail::event_arg_interface
|
||||
struct arg_expose : public event_arg
|
||||
{
|
||||
::nana::window window_handle;
|
||||
bool exposed;
|
||||
};
|
||||
|
||||
struct arg_focus : public detail::event_arg_interface
|
||||
struct arg_focus : public event_arg
|
||||
{
|
||||
::nana::window window_handle;
|
||||
::nana::native_window_type receiver;
|
||||
bool getting;
|
||||
};
|
||||
|
||||
struct arg_keyboard : public detail::event_arg_interface
|
||||
struct arg_keyboard : public event_arg
|
||||
{
|
||||
event_code evt_code;
|
||||
::nana::window window_handle;
|
||||
@@ -416,21 +450,21 @@ namespace nana
|
||||
bool shift;
|
||||
};
|
||||
|
||||
struct arg_move : public detail::event_arg_interface
|
||||
struct arg_move : public event_arg
|
||||
{
|
||||
::nana::window window_handle;
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
struct arg_resized : public detail::event_arg_interface
|
||||
struct arg_resized : public event_arg
|
||||
{
|
||||
::nana::window window_handle;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
};
|
||||
|
||||
struct arg_resizing : public detail::event_arg_interface
|
||||
struct arg_resizing : public event_arg
|
||||
{
|
||||
::nana::window window_handle;
|
||||
window_border border;
|
||||
@@ -438,13 +472,13 @@ namespace nana
|
||||
mutable unsigned height;
|
||||
};
|
||||
|
||||
struct arg_unload : public detail::event_arg_interface
|
||||
struct arg_unload : public event_arg
|
||||
{
|
||||
::nana::window window_handle;
|
||||
mutable bool cancel;
|
||||
};
|
||||
|
||||
struct arg_destroy : public detail::event_arg_interface
|
||||
struct arg_destroy : public event_arg
|
||||
{
|
||||
::nana::window window_handle;
|
||||
};
|
||||
@@ -471,6 +505,7 @@ namespace nana
|
||||
basic_event<arg_move> move;
|
||||
basic_event<arg_resizing> resizing;
|
||||
basic_event<arg_resized> resized;
|
||||
|
||||
basic_event<arg_destroy> destroy;
|
||||
};
|
||||
|
||||
@@ -482,16 +517,6 @@ namespace nana
|
||||
basic_event<arg_unload> unload;
|
||||
};
|
||||
}//end namespace detail
|
||||
|
||||
namespace dev
|
||||
{
|
||||
template<typename Widget>
|
||||
struct event_mapping
|
||||
{
|
||||
typedef general_events type;
|
||||
};
|
||||
}//end namespace dev
|
||||
|
||||
}//end namespace nana
|
||||
|
||||
#endif
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace nana{
|
||||
|
||||
root_misc(core_window_t * wd, unsigned width, unsigned height)
|
||||
: window(wd),
|
||||
root_graph(width, height)
|
||||
root_graph({ width, height })
|
||||
{}
|
||||
};//end struct root_misc
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Platform Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -33,7 +34,7 @@ namespace detail
|
||||
unsigned extra_height; //extra border size, it is useful in Windows, ignore in X11 always 0
|
||||
};
|
||||
|
||||
static nana::size screen_size();
|
||||
static nana::size primary_monitor_size();
|
||||
static rectangle screen_area_from_point(const point&);
|
||||
static window_result create_window(native_window_type, bool nested, const rectangle&, const appearance&);
|
||||
static native_window_type create_child_window(native_window_type, const rectangle&);
|
||||
@@ -58,7 +59,7 @@ namespace detail
|
||||
static nana::point window_position(native_window_type);
|
||||
static void move_window(native_window_type, int x, int y);
|
||||
static void move_window(native_window_type, const rectangle&);
|
||||
static void bring_to_top(native_window_type);
|
||||
static void bring_top(native_window_type, bool activated);
|
||||
static void set_window_z_order(native_window_type, native_window_type wd_after, z_order_action action_if_no_wd_after);
|
||||
|
||||
static void window_size(native_window_type, const size&);
|
||||
@@ -69,9 +70,9 @@ namespace detail
|
||||
static nana::point cursor_position();
|
||||
static native_window_type get_owner_window(native_window_type);
|
||||
//For Caret
|
||||
static void caret_create(native_window_type, unsigned width, unsigned height);
|
||||
static void caret_create(native_window_type, const ::nana::size&);
|
||||
static void caret_destroy(native_window_type);
|
||||
static void caret_pos(native_window_type, int x, int y);
|
||||
static void caret_pos(native_window_type, const ::nana::point&);
|
||||
static void caret_visible(native_window_type, bool);
|
||||
|
||||
static void set_focus(native_window_type);
|
||||
|
||||
46
include/nana/gui/detail/widget_colors.hpp
Normal file
46
include/nana/gui/detail/widget_colors.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Color Schemes
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/widget_colors.hpp
|
||||
* @description:
|
||||
*/
|
||||
#ifndef NANA_DETAIL_WIDGET_COLORS_HPP
|
||||
#define NANA_DETAIL_WIDGET_COLORS_HPP
|
||||
|
||||
#include <nana/gui/basis.hpp>
|
||||
#include <memory>
|
||||
namespace nana
|
||||
{
|
||||
class color_proxy
|
||||
{
|
||||
public:
|
||||
color_proxy(const color_proxy&);
|
||||
color_proxy(color_rgb);
|
||||
color_proxy(colors);
|
||||
color_proxy& operator=(const color_proxy&);
|
||||
color_proxy& operator=(const ::nana::color&);
|
||||
color_proxy& operator=(color_rgb);
|
||||
color_proxy& operator=(colors);
|
||||
color get_color() const;
|
||||
operator color() const;
|
||||
private:
|
||||
std::shared_ptr<color> color_;
|
||||
};//end namespace color_proxy
|
||||
|
||||
struct widget_colors
|
||||
{
|
||||
virtual ~widget_colors() = default;
|
||||
|
||||
color_proxy activated{ static_cast<color_rgb>(0x60C8FD) };
|
||||
color_proxy background{colors::button_face};
|
||||
color_proxy foreground{colors::black};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -150,7 +150,7 @@ namespace detail
|
||||
core_window_t* root(native_window_type) const;
|
||||
|
||||
//Copy the root buffer that wnd specified into DeviceContext
|
||||
void map(core_window_t*);
|
||||
void map(core_window_t*, bool forced);
|
||||
|
||||
bool update(core_window_t*, bool redraw, bool force);
|
||||
void refresh_tree(core_window_t*);
|
||||
|
||||
@@ -30,19 +30,17 @@ namespace nana
|
||||
class element_interface
|
||||
{
|
||||
public:
|
||||
typedef paint::graphics & graph_reference;
|
||||
using graph_reference = paint::graphics&;
|
||||
|
||||
virtual ~element_interface()
|
||||
{}
|
||||
|
||||
virtual bool draw(graph_reference, nana::color_t bgcolor, nana::color_t fgcolor, const nana::rectangle&, element_state) = 0;
|
||||
virtual ~element_interface() = default;
|
||||
virtual bool draw(graph_reference, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle&, element_state) = 0;
|
||||
};
|
||||
|
||||
class crook_interface
|
||||
{
|
||||
public:
|
||||
typedef paint::graphics & graph_reference;
|
||||
typedef checkstate state;
|
||||
using graph_reference = paint::graphics&;
|
||||
using state = checkstate;
|
||||
|
||||
struct data
|
||||
{
|
||||
@@ -50,10 +48,25 @@ namespace nana
|
||||
bool radio;
|
||||
};
|
||||
|
||||
virtual ~crook_interface()
|
||||
{}
|
||||
virtual ~crook_interface() = default;
|
||||
virtual bool draw(graph_reference, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle&, element_state, const data&) = 0;
|
||||
};
|
||||
|
||||
virtual bool draw(graph_reference, nana::color_t bgcolor, nana::color_t fgcolor, const nana::rectangle&, element_state, const data&) = 0;
|
||||
class border_interface
|
||||
{
|
||||
public:
|
||||
using graph_reference = paint::graphics&;
|
||||
|
||||
virtual ~border_interface() = default;
|
||||
virtual bool draw(graph_reference, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle&, element_state, unsigned weight) = 0;
|
||||
};
|
||||
|
||||
class arrow_interface
|
||||
{
|
||||
public:
|
||||
using graph_reference = paint::graphics&;
|
||||
virtual ~arrow_interface() = default;
|
||||
virtual bool draw(graph_reference, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle&, element_state, direction) = 0;
|
||||
};
|
||||
|
||||
class provider
|
||||
@@ -87,16 +100,48 @@ namespace nana
|
||||
|
||||
void add_crook(const std::string& name, const pat::cloneable<factory_interface<crook_interface>>&);
|
||||
crook_interface* const * keeper_crook(const std::string& name);
|
||||
|
||||
void add_border(const std::string&, const pat::cloneable<factory_interface<border_interface>>&);
|
||||
border_interface* const * keeper_border(const std::string&);
|
||||
|
||||
void add_arrow(const std::string&, const pat::cloneable<factory_interface<arrow_interface>>&);
|
||||
arrow_interface* const * keeper_arrow(const std::string&);
|
||||
|
||||
void add_button(const std::string&, const pat::cloneable<factory_interface<element_interface>>&);
|
||||
element_interface* const* keeper_button(const std::string&);
|
||||
};
|
||||
|
||||
class crook;
|
||||
template<typename UserElement>
|
||||
void add_crook(const std::string& name)
|
||||
{
|
||||
typedef provider::factory<UserElement, crook_interface> factory_t;
|
||||
using factory_t = provider::factory<UserElement, crook_interface>;
|
||||
provider().add_crook(name, pat::cloneable<typename factory_t::interface_type>(factory_t()));
|
||||
}
|
||||
|
||||
class crook;
|
||||
class border;
|
||||
template<typename BorderElement>
|
||||
void add_border(const std::string& name)
|
||||
{
|
||||
using factory_t = provider::factory<BorderElement, border_interface>;
|
||||
provider().add_border(name, pat::cloneable<typename factory_t::interface_type>(factory_t()));
|
||||
}
|
||||
|
||||
class arrow;
|
||||
template<typename ArrowElement>
|
||||
void add_arrow(const std::string& name)
|
||||
{
|
||||
using factory_t = provider::factory<ArrowElement, arrow_interface>;
|
||||
provider().add_arrow(name, pat::cloneable<typename factory_t::interface_type>(factory_t()));
|
||||
}
|
||||
|
||||
class button;
|
||||
template<typename ButtonElement>
|
||||
void add_button(const std::string& name)
|
||||
{
|
||||
using factory_t = provider::factory<ButtonElement, element_interface>;
|
||||
provider().add_button(name, pat::cloneable<typename factory_t::interface_type>(factory_t()));
|
||||
}
|
||||
}//end namespace element
|
||||
|
||||
template<typename Element> class facade;
|
||||
@@ -106,11 +151,10 @@ namespace nana
|
||||
: public element::element_interface
|
||||
{
|
||||
public:
|
||||
typedef ::nana::paint::graphics & graph_reference;
|
||||
typedef element::crook_interface::state state;
|
||||
using graph_reference = ::nana::paint::graphics &;
|
||||
using state = element::crook_interface::state;
|
||||
|
||||
facade();
|
||||
facade(const char* name);
|
||||
facade(const char* name = nullptr);
|
||||
|
||||
facade & reverse();
|
||||
facade & check(state);
|
||||
@@ -122,11 +166,65 @@ namespace nana
|
||||
void switch_to(const char*);
|
||||
public:
|
||||
//Implement element_interface
|
||||
bool draw(graph_reference, nana::color_t bgcolor, nana::color_t fgcolor, const nana::rectangle& r, element_state) override;
|
||||
bool draw(graph_reference, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle& r, element_state) override;
|
||||
private:
|
||||
element::crook_interface::data data_;
|
||||
element::crook_interface* const * keeper_;
|
||||
};
|
||||
}; //end class facade<element::crook>
|
||||
|
||||
template<>
|
||||
class facade<element::border>
|
||||
: public element::element_interface
|
||||
{
|
||||
using graph_reference = ::nana::paint::graphics &;
|
||||
public:
|
||||
facade(const char* name = nullptr);
|
||||
|
||||
void switch_to(const char*);
|
||||
public:
|
||||
//Implement element_interface
|
||||
bool draw(graph_reference, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle&, element_state) override;
|
||||
private:
|
||||
element::border_interface* const * keeper_;
|
||||
};//end class facade<element::border>
|
||||
|
||||
template<>
|
||||
class facade<element::arrow>
|
||||
: public element::element_interface
|
||||
{
|
||||
using graph_reference = ::nana::paint::graphics &;
|
||||
public:
|
||||
enum class style
|
||||
{
|
||||
solid
|
||||
};
|
||||
|
||||
facade(const char* name = nullptr);
|
||||
|
||||
void switch_to(const char*);
|
||||
void direction(::nana::direction);
|
||||
public:
|
||||
//Implement element_interface
|
||||
bool draw(graph_reference, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle&, element_state) override;
|
||||
private:
|
||||
element::arrow_interface* const * keeper_;
|
||||
::nana::direction dir_{::nana::direction::north};
|
||||
};//end class facade<element::arrow>
|
||||
|
||||
template<>
|
||||
class facade<element::button>
|
||||
: public element::element_interface
|
||||
{
|
||||
public:
|
||||
facade(const char* name = nullptr);
|
||||
void switch_to(const char*);
|
||||
public:
|
||||
//Implement element_interface
|
||||
bool draw(graph_reference, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle&, element_state) override;
|
||||
private:
|
||||
element::element_interface* const * keeper_;
|
||||
};//end class facade<element::button>
|
||||
|
||||
|
||||
namespace element
|
||||
{
|
||||
@@ -144,7 +242,7 @@ namespace nana
|
||||
void set(const cloneable_element&);
|
||||
void set(const char*);
|
||||
|
||||
bool draw(graph_reference, nana::color_t bgcolor, nana::color_t fgcolor, const nana::rectangle&, element_state);
|
||||
bool draw(graph_reference, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle&, element_state);
|
||||
private:
|
||||
cloneable_element holder_;
|
||||
element_interface * place_ptr_;
|
||||
@@ -174,7 +272,7 @@ namespace nana
|
||||
void stretch_parts(unsigned left, unsigned top, unsigned right, unsigned bottom);
|
||||
|
||||
//Implement the methods of element_interface.
|
||||
virtual bool draw(graph_reference, nana::color_t bgcolor, nana::color_t fgcolor, const nana::rectangle&, element_state);
|
||||
virtual bool draw(graph_reference, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle&, element_state);
|
||||
private:
|
||||
struct draw_method;
|
||||
struct draw_image;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Message Box Class
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -91,6 +91,141 @@ namespace nana
|
||||
button_t button_;
|
||||
icon_t icon_;
|
||||
};
|
||||
|
||||
class inputbox
|
||||
{
|
||||
struct abstract_content
|
||||
{
|
||||
virtual ~abstract_content() = default;
|
||||
|
||||
virtual const ::nana::string& label() const = 0;
|
||||
virtual window create(window, unsigned label_px) = 0;
|
||||
virtual unsigned fixed_pixels() const = 0;
|
||||
};
|
||||
public:
|
||||
class integer
|
||||
: public abstract_content
|
||||
{
|
||||
struct implement;
|
||||
public:
|
||||
integer(::nana::string label, int init_value, int begin, int last, int step);
|
||||
~integer();
|
||||
|
||||
int value() const;
|
||||
private:
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& label() const override;
|
||||
window create(window, unsigned label_px) override;
|
||||
unsigned fixed_pixels() const override;
|
||||
private:
|
||||
std::unique_ptr<implement> impl_;
|
||||
};
|
||||
|
||||
class real
|
||||
: public abstract_content
|
||||
{
|
||||
struct implement;
|
||||
public:
|
||||
real(::nana::string label, double init_value, double begin, double last, double step);
|
||||
~real();
|
||||
|
||||
double value() const;
|
||||
private:
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& label() const override;
|
||||
window create(window, unsigned label_px) override;
|
||||
unsigned fixed_pixels() const override;
|
||||
private:
|
||||
std::unique_ptr<implement> impl_;
|
||||
};
|
||||
|
||||
class text
|
||||
: public abstract_content
|
||||
{
|
||||
struct implement;
|
||||
public:
|
||||
text(::nana::string label);
|
||||
text(::nana::string label, std::vector<::nana::string>);
|
||||
|
||||
~text();
|
||||
|
||||
::nana::string value() const;
|
||||
private:
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& label() const override;
|
||||
window create(window, unsigned label_px) override;
|
||||
unsigned fixed_pixels() const override;
|
||||
private:
|
||||
std::unique_ptr<implement> impl_;
|
||||
};
|
||||
|
||||
class date
|
||||
: public abstract_content
|
||||
{
|
||||
struct implement;
|
||||
public:
|
||||
date(::nana::string label);
|
||||
|
||||
~date();
|
||||
|
||||
::nana::string value() const;
|
||||
int year() const;
|
||||
int month() const; //[1, 12]
|
||||
int day() const; //[1, 31]
|
||||
unsigned fixed_pixels() const override;
|
||||
private:
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& label() const override;
|
||||
window create(window, unsigned label_px) override;
|
||||
private:
|
||||
std::unique_ptr<implement> impl_;
|
||||
};
|
||||
|
||||
inputbox(window, ::nana::string description, ::nana::string title = ::nana::string());
|
||||
|
||||
template<typename ...Args>
|
||||
bool show(Args&& ... args)
|
||||
{
|
||||
std::vector<abstract_content*> contents;
|
||||
_m_fetch_args(contents, std::forward<Args>(args)...);
|
||||
|
||||
if (contents.empty())
|
||||
return false;
|
||||
|
||||
return _m_open(contents, false);
|
||||
}
|
||||
|
||||
template<typename ...Args>
|
||||
bool show_modal(Args&& ... args)
|
||||
{
|
||||
std::vector<abstract_content*> contents;
|
||||
_m_fetch_args(contents, std::forward<Args>(args)...);
|
||||
|
||||
if (contents.empty())
|
||||
return false;
|
||||
|
||||
return _m_open(contents, true);
|
||||
}
|
||||
|
||||
/// Sets a verifier to verify the user input.
|
||||
void verify(std::function<bool(window)> verifier);
|
||||
private:
|
||||
void _m_fetch_args(std::vector<abstract_content*>&);
|
||||
|
||||
template<typename ...Args>
|
||||
void _m_fetch_args(std::vector<abstract_content*>& contents, abstract_content& content, Args&&... args)
|
||||
{
|
||||
contents.push_back(&content);
|
||||
_m_fetch_args(contents, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
bool _m_open(std::vector<abstract_content*>&, bool modal);
|
||||
private:
|
||||
window owner_;
|
||||
::nana::string description_;
|
||||
::nana::string title_;
|
||||
std::function<bool(window)> verifier_;
|
||||
};
|
||||
}//end namespace nana
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Definition of Notifier
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -20,6 +20,7 @@ namespace nana
|
||||
class notifier;
|
||||
|
||||
struct arg_notifier
|
||||
: public event_arg
|
||||
{
|
||||
event_code evt_code;
|
||||
notifier* notifier_ptr;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Nana GUI Programming Interface Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -13,7 +13,7 @@
|
||||
#ifndef NANA_GUI_PROGRAMMING_INTERFACE_HPP
|
||||
#define NANA_GUI_PROGRAMMING_INTERFACE_HPP
|
||||
#include <nana/config.hpp>
|
||||
#include GUI_BEDROCK_HPP
|
||||
#include "detail/bedrock.hpp"
|
||||
#include "effects.hpp"
|
||||
#include "detail/general_events.hpp"
|
||||
#include <nana/paint/image.hpp>
|
||||
@@ -24,6 +24,17 @@ namespace nana
|
||||
class drawer_trigger;
|
||||
class widget;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
/// Traits for widget classes
|
||||
template<typename Widget>
|
||||
struct widget_traits
|
||||
{
|
||||
using event_type = ::nana::general_events;
|
||||
using scheme_type = ::nana::widget_colors;
|
||||
};
|
||||
}
|
||||
|
||||
namespace API
|
||||
{
|
||||
void effects_edge_nimbus(window, effects::edge_nimbus);
|
||||
@@ -45,6 +56,16 @@ namespace API
|
||||
}
|
||||
|
||||
bool set_events(window, const std::shared_ptr<general_events>&);
|
||||
|
||||
template<typename Scheme>
|
||||
std::unique_ptr<Scheme> make_scheme()
|
||||
{
|
||||
return std::unique_ptr<Scheme>(
|
||||
static_cast<Scheme*>(::nana::detail::bedrock::instance().make_scheme(::nana::detail::scheme_factory<Scheme>()).release()));
|
||||
}
|
||||
|
||||
void set_scheme(window, widget_colors*);
|
||||
widget_colors* get_scheme(window);
|
||||
|
||||
void attach_drawer(widget&, drawer_trigger&);
|
||||
nana::string window_caption(window);
|
||||
@@ -70,8 +91,6 @@ namespace API
|
||||
bool register_shortkey(window, unsigned long);
|
||||
void unregister_shortkey(window);
|
||||
|
||||
nana::size screen_size();
|
||||
rectangle screen_area_from_point(const point&);
|
||||
nana::point cursor_position();
|
||||
rectangle make_center(unsigned width, unsigned height); ///< Retrieves a rectangle which is in the center of the screen.
|
||||
rectangle make_center(window, unsigned width, unsigned height); ///< Retrieves a rectangle which is in the center of the window
|
||||
@@ -100,7 +119,8 @@ namespace API
|
||||
|
||||
void window_icon_default(const paint::image&);
|
||||
void window_icon(window, const paint::image&);
|
||||
bool empty_window(window); ///< Determines whether a window is existing.
|
||||
bool empty_window(window); ///< Determines whether a window is existing.
|
||||
bool is_window(window); ///< Determines whether a window is existing, equal to !empty_window.
|
||||
void enable_dropfiles(window, bool);
|
||||
|
||||
/// \brief Retrieves the native window of a Nana.GUI window.
|
||||
@@ -127,16 +147,16 @@ namespace API
|
||||
bool set_parent_window(window, window new_parent);
|
||||
|
||||
template<typename Widget=::nana::widget>
|
||||
typename ::nana::dev::event_mapping<Widget>::type & events(window wd)
|
||||
typename ::nana::dev::widget_traits<Widget>::event_type & events(window wd)
|
||||
{
|
||||
typedef typename ::nana::dev::event_mapping<Widget>::type event_type;
|
||||
using event_type = typename ::nana::dev::widget_traits<Widget>::event_type;
|
||||
|
||||
internal_scope_guard lock;
|
||||
auto * general_evt = detail::get_general_events(wd);
|
||||
if (nullptr == general_evt)
|
||||
throw std::invalid_argument("API::events(): bad parameter window handle, no events object or invalid window handle.");
|
||||
|
||||
if (std::is_same<decltype(*general_evt), event_type>::value)
|
||||
if (std::is_same<::nana::general_events, event_type>::value)
|
||||
return *static_cast<event_type*>(general_evt);
|
||||
|
||||
auto * widget_evt = dynamic_cast<event_type*>(general_evt);
|
||||
@@ -145,7 +165,7 @@ namespace API
|
||||
return *widget_evt;
|
||||
}
|
||||
|
||||
template<typename EventArg, typename std::enable_if<std::is_base_of< ::nana::detail::event_arg_interface, EventArg>::value>::type* = nullptr>
|
||||
template<typename EventArg, typename std::enable_if<std::is_base_of< ::nana::event_arg, EventArg>::value>::type* = nullptr>
|
||||
bool emit_event(event_code evt_code, window wd, const EventArg& arg)
|
||||
{
|
||||
auto & brock = ::nana::detail::bedrock::instance();
|
||||
@@ -154,13 +174,35 @@ namespace API
|
||||
|
||||
void umake_event(event_handle);
|
||||
|
||||
template<typename Widget = ::nana::widget>
|
||||
typename ::nana::dev::widget_traits<Widget>::scheme_type & scheme(window wd)
|
||||
{
|
||||
using scheme_type = typename ::nana::dev::widget_traits<Widget>::scheme_type;
|
||||
|
||||
internal_scope_guard lock;
|
||||
auto * wdg_colors = dev::get_scheme(wd);
|
||||
if (nullptr == wdg_colors)
|
||||
throw std::invalid_argument("API::scheme(): bad parameter window handle, no events object or invalid window handle.");
|
||||
|
||||
if (std::is_same<::nana::widget_colors, scheme_type>::value)
|
||||
return *static_cast<scheme_type*>(wdg_colors);
|
||||
|
||||
auto * comp_wdg_colors = dynamic_cast<scheme_type*>(wdg_colors);
|
||||
if (nullptr == comp_wdg_colors)
|
||||
throw std::invalid_argument("API::scheme(): bad template parameter Widget, the widget type and window handle do not match.");
|
||||
return *comp_wdg_colors;
|
||||
}
|
||||
|
||||
nana::point window_position(window);
|
||||
void move_window(window, int x, int y);
|
||||
void move_window(window wd, const rectangle&);
|
||||
|
||||
void bring_to_top(window);
|
||||
void bring_top(window, bool activated);
|
||||
bool set_window_z_order(window wd, window wd_after, z_order_action action_if_no_wd_after);
|
||||
|
||||
void draw_through(window, std::function<void()>);
|
||||
void map_through_widgets(window, native_drawable_type);
|
||||
|
||||
nana::size window_size(window);
|
||||
void window_size(window, const size&);
|
||||
bool window_rectangle(window, rectangle&);
|
||||
@@ -185,6 +227,7 @@ namespace API
|
||||
void refresh_window_tree(window); ///< Refreshs the specified window and all it<69>s children windows, then display it immediately
|
||||
void update_window(window); ///< Copies the off-screen buffer to the screen for immediate display.
|
||||
|
||||
void window_caption(window, const std::string& title_utf8);
|
||||
void window_caption(window, const nana::string& title);
|
||||
nana::string window_caption(window);
|
||||
|
||||
@@ -201,17 +244,18 @@ namespace API
|
||||
void capture_ignore_children(bool ignore); ///< Enables or disables the captured window whether redirects the mouse input to its children if the mouse is over its children.
|
||||
void modal_window(window); ///< Blocks the routine til the specified window is closed.
|
||||
void wait_for(window);
|
||||
color_t foreground(window);
|
||||
color_t foreground(window, color_t);
|
||||
color_t background(window);
|
||||
color_t background(window, color_t);
|
||||
color_t active(window);
|
||||
color_t active(window, color_t);
|
||||
|
||||
color fgcolor(window);
|
||||
color fgcolor(window, const color&);
|
||||
color bgcolor(window);
|
||||
color bgcolor(window, const color&);
|
||||
color activated_color(window);
|
||||
color activated_color(window, const color&);
|
||||
|
||||
void create_caret(window, unsigned width, unsigned height);
|
||||
void destroy_caret(window);
|
||||
void caret_effective_range(window, const rectangle&);
|
||||
void caret_pos(window, int x, int y);
|
||||
void caret_pos(window, const ::nana::point&);
|
||||
nana::point caret_pos(window);
|
||||
nana::size caret_size(window);
|
||||
void caret_size(window, const size&);
|
||||
|
||||
52
include/nana/gui/screen.hpp
Normal file
52
include/nana/gui/screen.hpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Screen Informations
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/screen.hpp
|
||||
*/
|
||||
|
||||
#ifndef NANA_GUI_SCREEN_HPP
|
||||
#define NANA_GUI_SCREEN_HPP
|
||||
#include "basis.hpp"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
/// The monitor display metrics
|
||||
class display
|
||||
{
|
||||
public:
|
||||
virtual ~display() = default;
|
||||
|
||||
/// The index of monitor.
|
||||
virtual std::size_t get_index() const = 0;
|
||||
|
||||
/// Returns the positional coordinates and size of the display device in reference to the desktop area
|
||||
virtual const ::nana::rectangle& area() const = 0;
|
||||
};
|
||||
|
||||
class screen
|
||||
{
|
||||
public:
|
||||
static ::nana::size desktop_size();
|
||||
static ::nana::size primary_monitor_size();
|
||||
static std::shared_ptr<display> from_point(const point&);
|
||||
static std::shared_ptr<display> from_window(window);
|
||||
|
||||
/// Returns the number of display monitors
|
||||
std::size_t count() const;
|
||||
|
||||
std::shared_ptr<display> get_display(std::size_t index) const;
|
||||
std::shared_ptr<display> get_primary() const;
|
||||
|
||||
void for_each(std::function<void(display&)>) const;
|
||||
};
|
||||
}//end namespace nana
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* A Timer Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -22,6 +22,7 @@ namespace nana
|
||||
/// Can repeatedly call a piece of code.
|
||||
|
||||
struct arg_elapse
|
||||
: public event_arg
|
||||
{
|
||||
long long id; //timer identifier;
|
||||
};
|
||||
|
||||
@@ -53,10 +53,10 @@ namespace nana{
|
||||
void _m_draw_background(graph_reference);
|
||||
void _m_draw_border(graph_reference);
|
||||
private:
|
||||
widget* widget_;
|
||||
paint::graphics* graph_;
|
||||
widget* wdg_{nullptr};
|
||||
paint::graphics* graph_{nullptr};
|
||||
|
||||
element::cite_bground cite_;
|
||||
element::cite_bground cite_{"button"};
|
||||
|
||||
struct attr_tag
|
||||
{
|
||||
@@ -68,8 +68,8 @@ namespace nana{
|
||||
bool enable_pushed;
|
||||
bool focus_color;
|
||||
paint::image * icon;
|
||||
color_t bgcolor;
|
||||
color_t fgcolor;
|
||||
::nana::color bgcolor;
|
||||
::nana::color fgcolor;
|
||||
}attr_;
|
||||
};
|
||||
}//end namespace button
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Categorize Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -23,6 +23,7 @@ namespace nana
|
||||
|
||||
template<typename ValueType>
|
||||
struct arg_categorize
|
||||
: public event_arg
|
||||
{
|
||||
categorize<ValueType> & widget;
|
||||
ValueType & value;
|
||||
@@ -164,7 +165,7 @@ namespace nana
|
||||
|
||||
categorize(window wd, const rectangle& r = rectangle(), bool visible = true)
|
||||
{
|
||||
this->get_drawer_trigger().template create_event_agent(*this);
|
||||
this->get_drawer_trigger().create_event_agent(*this);
|
||||
this->create(wd, r, visible);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ namespace drawerbase
|
||||
private:
|
||||
static const int interval = 4;
|
||||
widget* widget_;
|
||||
unsigned state_;
|
||||
std::unique_ptr<implement> imptr_;
|
||||
implement * impl_;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Combox Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -14,6 +14,7 @@
|
||||
#define NANA_GUI_WIDGETS_COMBOX_HPP
|
||||
#include "widget.hpp"
|
||||
#include "float_listbox.hpp"
|
||||
#include "skeletons/text_editor_scheme.hpp"
|
||||
#include <nana/key_type.hpp>
|
||||
#include <nana/concepts.hpp>
|
||||
#include <functional>
|
||||
@@ -21,15 +22,13 @@
|
||||
namespace nana
|
||||
{
|
||||
/// A list box combined with a textbox - the list box should drop down when the user selects the arrow next to the control
|
||||
class combox;
|
||||
class combox;
|
||||
|
||||
struct arg_combox
|
||||
: public event_arg
|
||||
{
|
||||
combox & widget;
|
||||
|
||||
arg_combox(combox& wdg)
|
||||
: widget(wdg)
|
||||
{}
|
||||
arg_combox(combox&);
|
||||
};
|
||||
|
||||
namespace drawerbase
|
||||
@@ -39,7 +38,8 @@ namespace nana
|
||||
struct combox_events
|
||||
: public general_events
|
||||
{
|
||||
basic_event<arg_combox> selected;
|
||||
basic_event<arg_combox> selected;
|
||||
basic_event<arg_combox> text_changed;
|
||||
};
|
||||
|
||||
class drawer_impl;
|
||||
@@ -51,8 +51,6 @@ namespace nana
|
||||
trigger();
|
||||
~trigger();
|
||||
|
||||
void set_accept(std::function<bool(nana::char_t)>&&);
|
||||
|
||||
drawer_impl& get_drawer_impl();
|
||||
const drawer_impl& get_drawer_impl() const;
|
||||
private:
|
||||
@@ -69,7 +67,6 @@ namespace nana
|
||||
void key_press(graph_reference, const arg_keyboard&) override;
|
||||
void key_char(graph_reference, const arg_keyboard&) override;
|
||||
private:
|
||||
std::function<bool(nana::char_t)> pred_acceptive_;
|
||||
drawer_impl * drawer_;
|
||||
};
|
||||
|
||||
@@ -160,7 +157,7 @@ namespace nana
|
||||
}//end namespace drawerbase
|
||||
|
||||
class combox
|
||||
: public widget_object<category::widget_tag, drawerbase::combox::trigger, drawerbase::combox::combox_events>,
|
||||
: public widget_object<category::widget_tag, drawerbase::combox::trigger, drawerbase::combox::combox_events, ::nana::widgets::skeletons::text_editor_scheme>,
|
||||
public nana::concepts::any_objective<std::size_t, 1>
|
||||
{
|
||||
public:
|
||||
@@ -169,15 +166,15 @@ namespace nana
|
||||
|
||||
combox();
|
||||
combox(window, bool visible);
|
||||
combox(window, const nana::string& text, bool visible = true);
|
||||
combox(window, const nana::char_t* text, bool visible = true);
|
||||
combox(window, nana::string, bool visible = true);
|
||||
combox(window, const nana::char_t*, bool visible = true);
|
||||
combox(window, const rectangle& r = rectangle(), bool visible = true);
|
||||
|
||||
void clear();
|
||||
void editable(bool);
|
||||
bool editable() const;
|
||||
void set_accept(std::function<bool(nana::char_t)>);
|
||||
combox& push_back(const nana::string&);
|
||||
combox& push_back(nana::string);
|
||||
std::size_t the_number_of_options() const;
|
||||
std::size_t option() const; ///< Index of the last selected, from drop-down list, item.
|
||||
void option(std::size_t); ///< Select the text specified by index
|
||||
@@ -223,11 +220,23 @@ namespace nana
|
||||
private:
|
||||
item_proxy _m_at_key(std::shared_ptr<nana::detail::key_interface>&&);
|
||||
void _m_erase(nana::detail::key_interface*);
|
||||
drawerbase::combox::drawer_impl & _m_impl();
|
||||
const drawerbase::combox::drawer_impl& _m_impl() const;
|
||||
private:
|
||||
//Overrides widget's virtual functions
|
||||
nana::string _m_caption() const override;
|
||||
void _m_caption(nana::string&&) override;
|
||||
nana::any * _m_anyobj(std::size_t pos, bool alloc_if_empty) const override;
|
||||
};
|
||||
|
||||
namespace dev
|
||||
{
|
||||
template<>
|
||||
struct widget_traits<combox>
|
||||
{
|
||||
using event_type = drawerbase::combox::combox_events;
|
||||
using scheme_type = ::nana::widgets::skeletons::text_editor_scheme;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A date chooser Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -43,10 +43,8 @@ namespace nana
|
||||
bool chose() const;
|
||||
nana::date read() const;
|
||||
void week_name(unsigned index, const nana::string&);
|
||||
void month_name(unsigned index, const nana::string&);
|
||||
private:
|
||||
void _m_init_color();
|
||||
where _m_pos_where(graph_reference, int x, int y);
|
||||
where _m_pos_where(graph_reference, const ::nana::point& pos);
|
||||
void _m_draw(graph_reference);
|
||||
void _m_draw_topbar(graph_reference);
|
||||
void _m_make_drawing_basis(drawing_basis&, graph_reference, const nana::point& refpos);
|
||||
@@ -58,14 +56,13 @@ namespace nana
|
||||
bool _m_get_trace(point, int & res);
|
||||
void _m_perf_transform(transform_action tfid, graph_reference, graph_reference dirtybuf, graph_reference newbuf, const nana::point& refpos);
|
||||
private:
|
||||
void refresh(graph_reference);
|
||||
void refresh(graph_reference) override;
|
||||
void attached(widget_reference, graph_reference) override;
|
||||
void mouse_move(graph_reference, const arg_mouse&) override;
|
||||
void mouse_leave(graph_reference, const arg_mouse&) override;
|
||||
void mouse_up(graph_reference, const arg_mouse&) override;
|
||||
private:
|
||||
nana::string weekstr_[7];
|
||||
nana::string monthstr_[12];
|
||||
|
||||
widget * widget_;
|
||||
|
||||
@@ -91,10 +88,10 @@ namespace nana
|
||||
|
||||
struct color_tag
|
||||
{
|
||||
nana::color_t highlight;
|
||||
nana::color_t selected;
|
||||
nana::color_t normal;
|
||||
nana::color_t bkcolor;
|
||||
::nana::color highlight;
|
||||
::nana::color selected;
|
||||
::nana::color normal;
|
||||
::nana::color bgcolor;
|
||||
}color_;
|
||||
};
|
||||
|
||||
@@ -116,7 +113,6 @@ namespace nana
|
||||
bool chose() const;
|
||||
nana::date read() const;
|
||||
void weekstr(unsigned index, const nana::string&);///<Set the week strings which will be displayed for day, index is in range of [0, 6]
|
||||
void monthstr(unsigned index, const nana::string&);///<Set the month strings which will be displayed for month. index is in range of [0, 11]
|
||||
};
|
||||
}//end namespace nana
|
||||
|
||||
|
||||
@@ -37,11 +37,9 @@ namespace nana
|
||||
{
|
||||
std::vector<std::shared_ptr<item_interface>> items;
|
||||
|
||||
std::size_t max_items; // the number of items display.
|
||||
mutable std::size_t index; // the result of the selection.
|
||||
std::size_t max_items{10}; // the number of items display.
|
||||
mutable std::size_t index{::nana::npos}; // the result of the selection.
|
||||
mutable bool have_selected;
|
||||
|
||||
module_def();
|
||||
};
|
||||
|
||||
class item_renderer
|
||||
@@ -51,7 +49,7 @@ namespace nana
|
||||
typedef paint::graphics& graph_reference;
|
||||
enum state_t{StateNone, StateHighlighted};
|
||||
|
||||
virtual ~item_renderer() = 0;
|
||||
virtual ~item_renderer() = default;
|
||||
virtual void image(bool enabled, unsigned pixels) = 0;
|
||||
virtual void render(widget_reference, graph_reference, const nana::rectangle&, const item_interface*, state_t) = 0;
|
||||
virtual unsigned item_pixels(graph_reference) const = 0;
|
||||
|
||||
@@ -24,12 +24,10 @@ namespace nana
|
||||
class trigger: public drawer_trigger
|
||||
{
|
||||
public:
|
||||
trigger();
|
||||
void attached(widget_reference, graph_reference) override;
|
||||
void refresh(graph_reference) override;
|
||||
void resized(graph_reference, const arg_resized&) override;
|
||||
private:
|
||||
widget* wd_;
|
||||
widget* wd_{nullptr};
|
||||
};
|
||||
}//end namespace form
|
||||
}//end namespace drawerbase
|
||||
@@ -47,6 +45,9 @@ namespace nana
|
||||
form(window, const ::nana::size& = { 300, 200 }, const appearance& = {});
|
||||
/// Creates a window at the point and size specified by rect, with the specified appearance. This window is always floating above its owner.
|
||||
form(window, const rectangle&, const appearance& = {});
|
||||
|
||||
void modality() const;
|
||||
void wait_for_this();
|
||||
};
|
||||
|
||||
class nested_form : public widget_object<category::root_tag, drawerbase::form::trigger, detail::events_root_extension>
|
||||
|
||||
@@ -69,6 +69,8 @@ namespace nana
|
||||
/// "corrected" size that changes lines to fit the text into the specified width
|
||||
nana::size measure(unsigned allowed_width_in_pixel) const;
|
||||
|
||||
static ::nana::size measure(::nana::paint::graphics&, const ::nana::string&, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align);
|
||||
|
||||
label& text_align(align horizontal_align, align_v vertical_align= align_v::top);
|
||||
private:
|
||||
//Overrides widget's virtual function
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A List Box Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -33,10 +33,11 @@ namespace nana
|
||||
{
|
||||
struct format
|
||||
{
|
||||
::nana::color_t bgcolor;
|
||||
::nana::color_t fgcolor;
|
||||
::nana::color bgcolor;
|
||||
::nana::color fgcolor;
|
||||
|
||||
format(color_t bgcolor = 0xFF000000, color_t fgcolor = 0xFF000000);
|
||||
format() = default;
|
||||
format(const ::nana::color& bgcolor, const ::nana::color& fgcolor);
|
||||
};
|
||||
|
||||
using format_ptr = std::unique_ptr < format > ;
|
||||
@@ -49,7 +50,7 @@ namespace nana
|
||||
cell(cell&&);
|
||||
cell(nana::string);
|
||||
cell(nana::string, const format&);
|
||||
cell(nana::string, color_t bgcolor, color_t fgcolor);
|
||||
cell(nana::string, const ::nana::color& bgcolor, const ::nana::color& fgcolor);
|
||||
|
||||
cell& operator=(const cell&);
|
||||
cell& operator=(cell&&);
|
||||
@@ -212,11 +213,11 @@ namespace nana
|
||||
item_proxy & select(bool);
|
||||
bool selected() const;
|
||||
|
||||
item_proxy & bgcolor(nana::color_t);
|
||||
nana::color_t bgcolor() const;
|
||||
item_proxy & bgcolor(const nana::color&);
|
||||
nana::color bgcolor() const;
|
||||
|
||||
item_proxy& fgcolor(nana::color_t);
|
||||
nana::color_t fgcolor() const;
|
||||
item_proxy& fgcolor(const nana::color&);
|
||||
nana::color fgcolor() const;
|
||||
|
||||
index_pair pos() const;
|
||||
|
||||
@@ -415,9 +416,12 @@ namespace nana
|
||||
}//end namespace drawerbase
|
||||
|
||||
struct arg_listbox
|
||||
: public event_arg
|
||||
{
|
||||
mutable drawerbase::listbox::item_proxy item;
|
||||
bool selected;
|
||||
|
||||
arg_listbox(const drawerbase::listbox::item_proxy&, bool selected);
|
||||
};
|
||||
|
||||
namespace drawerbase
|
||||
@@ -430,6 +434,15 @@ namespace nana
|
||||
basic_event<arg_listbox> checked;
|
||||
basic_event<arg_listbox> selected;
|
||||
};
|
||||
|
||||
struct scheme
|
||||
: public widget_colors
|
||||
{
|
||||
color_proxy header_bgcolor{static_cast<color_rgb>(0xf1f2f4)};
|
||||
color_proxy header_grabbed{ static_cast<color_rgb>(0x8BD6F6)};
|
||||
color_proxy header_floated{ static_cast<color_rgb>(0xBABBBC)};
|
||||
color_proxy item_selected{ static_cast<color_rgb>(0xD5EFFC) };
|
||||
};
|
||||
}
|
||||
}//end namespace drawerbase
|
||||
|
||||
@@ -441,7 +454,7 @@ The user can \a drag the header to \a reisize it or to \a reorganize it.
|
||||
By \a clicking on a header the list get \a reordered, first up, and then down alternatively,
|
||||
*/
|
||||
class listbox
|
||||
: public widget_object<category::widget_tag, drawerbase::listbox::trigger, drawerbase::listbox::listbox_events>,
|
||||
: public widget_object<category::widget_tag, drawerbase::listbox::trigger, drawerbase::listbox::listbox_events, drawerbase::listbox::scheme>,
|
||||
public concepts::any_objective<drawerbase::listbox::size_type, 2>
|
||||
{
|
||||
public:
|
||||
@@ -471,8 +484,8 @@ By \a clicking on a header the list get \a reordered, first up, and then down al
|
||||
template<typename Key>
|
||||
cat_proxy operator[](const Key & ck)
|
||||
{
|
||||
typedef typename nana::detail::type_escape<Key>::type key_t;
|
||||
std::shared_ptr<nana::detail::key_interface> p(new nana::key<key_t, std::less<key_t>>(ck), [](nana::detail::key_interface* p)
|
||||
using catkey = typename ::nana::detail::type_escape<Key>::type;
|
||||
std::shared_ptr<nana::detail::key_interface> p(new nana::key<catkey, std::less<catkey>>(ck), [](nana::detail::key_interface* p)
|
||||
{
|
||||
delete p;
|
||||
});
|
||||
@@ -483,8 +496,8 @@ By \a clicking on a header the list get \a reordered, first up, and then down al
|
||||
template<typename Key>
|
||||
cat_proxy operator[](Key && ck)
|
||||
{
|
||||
typedef typename nana::detail::type_escape<Key>::type key_t;
|
||||
std::shared_ptr<nana::detail::key_interface> p(new nana::key<key_t, std::less<key_t>>(std::move(ck)), [](nana::detail::key_interface* p)
|
||||
using catkey = typename ::nana::detail::type_escape<Key>::type;
|
||||
std::shared_ptr<nana::detail::key_interface> p(new nana::key<catkey, std::less<catkey>>(std::move(ck)), [](nana::detail::key_interface* p)
|
||||
{
|
||||
delete p;
|
||||
});
|
||||
@@ -539,6 +552,9 @@ By \a clicking on a header the list get \a reordered, first up, and then down al
|
||||
size_type size_categ() const; ///<Get the number of categories
|
||||
size_type size_item() const; ///<The number of items in the default category
|
||||
size_type size_item(size_type cat) const; ///<The number of items in category "cat"
|
||||
|
||||
void enable_single(bool for_selection, bool category_limited);
|
||||
void disable_single(bool for_selection);
|
||||
private:
|
||||
drawerbase::listbox::essence_t & _m_ess() const;
|
||||
nana::any* _m_anyobj(size_type cat, size_type index, bool allocate_if_empty) const;
|
||||
@@ -546,5 +562,15 @@ By \a clicking on a header the list get \a reordered, first up, and then down al
|
||||
drawerbase::listbox::category_t* _m_at_key(std::shared_ptr<nana::detail::key_interface>);
|
||||
void _m_ease_key(nana::detail::key_interface*);
|
||||
};
|
||||
|
||||
namespace dev
|
||||
{
|
||||
template<>
|
||||
struct widget_traits<listbox>
|
||||
{
|
||||
using event_type = drawerbase::listbox::listbox_events;
|
||||
using scheme_type = drawerbase::listbox::scheme;
|
||||
};
|
||||
}
|
||||
}//end namespace nana
|
||||
#endif
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace nana
|
||||
checks check_style;
|
||||
};
|
||||
|
||||
virtual ~renderer_interface() = 0;
|
||||
virtual ~renderer_interface() = default;
|
||||
|
||||
virtual void background(graph_reference, window) = 0;
|
||||
virtual void item(graph_reference, const nana::rectangle&, const attr&) = 0;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Panel Implementation
|
||||
* Nana C++ Library(http://www.nanaro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -25,13 +25,10 @@ namespace nana
|
||||
{
|
||||
class drawer: public drawer_trigger
|
||||
{
|
||||
public:
|
||||
drawer();
|
||||
private:
|
||||
void attached(widget_reference, graph_reference) override;
|
||||
void refresh(graph_reference) override;
|
||||
private:
|
||||
window window_;
|
||||
window window_{nullptr};
|
||||
};
|
||||
}// end namespace panel
|
||||
}//end namespace drawerbase
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Picture Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -26,7 +26,7 @@ namespace nana
|
||||
void attached(widget_reference, graph_reference) override;
|
||||
void load(const nana::char_t* file);
|
||||
void load(const nana::paint::image&);
|
||||
void set_shadow_background(unsigned begin_color, unsigned end_color, bool horizontal);
|
||||
void set_shadow_background(const ::nana::color& from, const ::nana::color& to, bool horizontal);
|
||||
bool bgstyle(bool is_stretch, nana::arrange, int beg, int end);
|
||||
private:
|
||||
void refresh(graph_reference) override;
|
||||
@@ -35,13 +35,12 @@ namespace nana
|
||||
widget* widget_;
|
||||
nana::paint::graphics* graph_;
|
||||
|
||||
struct runtime_type
|
||||
struct
|
||||
{
|
||||
runtime_type();
|
||||
unsigned background_shadow_start;
|
||||
unsigned background_shadow_end;
|
||||
::nana::color gradual_from;
|
||||
::nana::color gradual_to;
|
||||
bool horizontal;
|
||||
}runtime_;
|
||||
}bground_;
|
||||
|
||||
struct back_image_tag
|
||||
{
|
||||
@@ -72,8 +71,8 @@ namespace nana
|
||||
int end ///< specify the stretchy area of image.
|
||||
);
|
||||
|
||||
/// Fills a gradual change color in background.
|
||||
void set_shadow_background(unsigned begin_color, unsigned end_color, bool horizontal);
|
||||
/// 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.
|
||||
void set_gradual_background(const ::nana::color& clr_from, const ::nana::color& clr_to, bool horizontal);
|
||||
void transparent(bool);
|
||||
bool transparent() const;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Progress Indicator Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -23,7 +23,6 @@ namespace nana
|
||||
class trigger: public drawer_trigger
|
||||
{
|
||||
public:
|
||||
trigger();
|
||||
unsigned value() const;
|
||||
unsigned value(unsigned);
|
||||
unsigned inc();
|
||||
@@ -41,13 +40,14 @@ namespace nana
|
||||
bool _m_check_changing(unsigned) const;
|
||||
private:
|
||||
static const unsigned border = 2;
|
||||
widget * widget_;
|
||||
nana::paint::graphics* graph_;
|
||||
unsigned draw_width_;
|
||||
bool has_value_;
|
||||
bool unknown_;
|
||||
unsigned max_;
|
||||
unsigned value_;
|
||||
|
||||
widget * widget_{nullptr};
|
||||
nana::paint::graphics* graph_{nullptr};
|
||||
unsigned draw_width_{static_cast<unsigned>(-1)};
|
||||
//bool has_value_{true}; //deprecated
|
||||
bool unknown_{false};
|
||||
unsigned max_{100};
|
||||
unsigned value_{0};
|
||||
}; //end class drawer
|
||||
}
|
||||
}//end namespace drawerbase
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Scroll Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -22,8 +22,13 @@ namespace nana
|
||||
|
||||
template<bool Vert>
|
||||
struct arg_scroll
|
||||
: public event_arg
|
||||
{
|
||||
scroll<Vert> & widget;
|
||||
|
||||
arg_scroll(scroll<Vert> & wdg)
|
||||
: widget(wdg)
|
||||
{}
|
||||
};
|
||||
|
||||
namespace drawerbase
|
||||
@@ -81,9 +86,9 @@ namespace nana
|
||||
bool _m_check() const;
|
||||
void _m_adjust_scroll(graph_reference);
|
||||
void _m_background(graph_reference);
|
||||
void _m_button_frame(graph_reference, int x, int y, unsigned width, unsigned height, int state);
|
||||
void _m_button_frame(graph_reference, ::nana::rectangle, int state);
|
||||
void _m_draw_scroll(graph_reference, int state);
|
||||
void _m_draw_button(graph_reference, int x, int y, unsigned width, unsigned height, buttons what, int state);
|
||||
void _m_draw_button(graph_reference, ::nana::rectangle, buttons what, int state);
|
||||
private:
|
||||
metrics_type &metrics_;
|
||||
bool vertical_;
|
||||
@@ -180,7 +185,7 @@ namespace nana
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
void attached(widget_reference widget, graph_reference graph)
|
||||
void attached(widget_reference widget, graph_reference graph) override
|
||||
{
|
||||
graph_ = &graph;
|
||||
widget_ = static_cast< ::nana::scroll<Vertical>*>(&widget);
|
||||
@@ -190,12 +195,12 @@ namespace nana
|
||||
timer_.elapse(std::bind(&trigger::_m_tick, this));
|
||||
}
|
||||
|
||||
void detached()
|
||||
void detached() override
|
||||
{
|
||||
graph_ = nullptr;
|
||||
}
|
||||
|
||||
void refresh(graph_reference graph)
|
||||
void refresh(graph_reference graph) override
|
||||
{
|
||||
drawer_.draw(graph, metrics_.what);
|
||||
}
|
||||
@@ -213,7 +218,7 @@ namespace nana
|
||||
API::lazy_refresh();
|
||||
}
|
||||
|
||||
void mouse_move(graph_reference graph, const ::nana::arg_mouse& arg)
|
||||
void mouse_move(graph_reference graph, const ::nana::arg_mouse& arg) override
|
||||
{
|
||||
bool redraw = false;
|
||||
if(metrics_.pressed && (metrics_.what == buttons::scroll))
|
||||
@@ -240,7 +245,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void mouse_down(graph_reference graph, const arg_mouse& arg)
|
||||
void mouse_down(graph_reference graph, const arg_mouse& arg) override
|
||||
{
|
||||
if(arg.left_button)
|
||||
{
|
||||
@@ -275,7 +280,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void mouse_up(graph_reference graph, const arg_mouse& arg)
|
||||
void mouse_up(graph_reference graph, const arg_mouse& arg) override
|
||||
{
|
||||
timer_.stop();
|
||||
|
||||
@@ -287,7 +292,7 @@ namespace nana
|
||||
API::lazy_refresh();
|
||||
}
|
||||
|
||||
void mouse_leave(graph_reference graph, const arg_mouse&)
|
||||
void mouse_leave(graph_reference graph, const arg_mouse&) override
|
||||
{
|
||||
if(metrics_.pressed) return;
|
||||
|
||||
@@ -296,7 +301,7 @@ namespace nana
|
||||
API::lazy_refresh();
|
||||
}
|
||||
|
||||
void mouse_wheel(graph_reference graph, const arg_wheel& arg)
|
||||
void mouse_wheel(graph_reference graph, const arg_wheel& arg) override
|
||||
{
|
||||
if(make_step(arg.upwards == false, 3))
|
||||
{
|
||||
@@ -307,7 +312,7 @@ namespace nana
|
||||
private:
|
||||
void _m_emit_value_changed()
|
||||
{
|
||||
widget_->events().value_changed.emit(::nana::arg_scroll<Vertical>({*widget_}));
|
||||
widget_->events().value_changed.emit(::nana::arg_scroll<Vertical>(*widget_));
|
||||
}
|
||||
|
||||
void _m_tick()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A text editor implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -14,9 +14,9 @@
|
||||
#ifndef NANA_GUI_SKELETONS_TEXT_EDITOR_HPP
|
||||
#define NANA_GUI_SKELETONS_TEXT_EDITOR_HPP
|
||||
#include "textbase.hpp"
|
||||
#include "text_editor_scheme.hpp"
|
||||
#include <nana/gui/widgets/scroll.hpp>
|
||||
#include <nana/unicode_bidi.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace nana{ namespace widgets
|
||||
{
|
||||
@@ -127,22 +127,37 @@ namespace nana{ namespace widgets
|
||||
class undo_backspace;
|
||||
class undo_input_text;
|
||||
class undo_move_text;
|
||||
public:
|
||||
typedef nana::char_t char_type;
|
||||
typedef textbase<char_type>::size_type size_type;
|
||||
typedef textbase<char_type>::string_type string_type;
|
||||
|
||||
typedef nana::paint::graphics & graph_reference;
|
||||
struct keywords;
|
||||
class keyword_parser;
|
||||
public:
|
||||
using char_type = ::nana::char_t;
|
||||
using size_type = textbase<char_type>::size_type;
|
||||
using string_type = textbase<char_type>::string_type;
|
||||
|
||||
using graph_reference = ::nana::paint::graphics&;
|
||||
|
||||
struct ext_renderer_tag
|
||||
{
|
||||
std::function<void(graph_reference, const nana::rectangle& text_area, nana::color_t)> background;
|
||||
std::function<void(graph_reference, const nana::rectangle& text_area, const ::nana::color&)> background;
|
||||
};
|
||||
|
||||
text_editor(window, graph_reference);
|
||||
enum class accepts
|
||||
{
|
||||
no_restrict, integer, real
|
||||
};
|
||||
|
||||
text_editor(window, graph_reference, const text_editor_scheme*);
|
||||
~text_editor();
|
||||
|
||||
bool respone_keyboard(nana::char_t, bool enterable);
|
||||
void set_highlight(const std::string& name, const ::nana::color&, const ::nana::color&);
|
||||
void erase_highlight(const std::string& name);
|
||||
void set_keyword(const ::nana::string& kw, const std::string& name, bool case_sensitive, bool whole_word_matched);
|
||||
void erase_keyword(const ::nana::string& kw);
|
||||
|
||||
void set_accept(std::function<bool(char_type)>);
|
||||
void set_accept(accepts);
|
||||
bool respone_keyboard(char_type);
|
||||
|
||||
void typeface_changed();
|
||||
|
||||
@@ -151,12 +166,12 @@ namespace nana{ namespace widgets
|
||||
/// Set the text_editor whether it is line wrapped, it returns false if the state is not changed.
|
||||
bool line_wrapped(bool);
|
||||
|
||||
void border_renderer(std::function<void(graph_reference, nana::color_t bgcolor)>);
|
||||
void border_renderer(std::function<void(graph_reference, const ::nana::color& bgcolor)>);
|
||||
|
||||
bool load(const nana::char_t*);
|
||||
|
||||
//text_area
|
||||
//@return: Returns true if the area of text is changed.
|
||||
/// Sets the text area.
|
||||
/// @return true if the area is changed with the new value.
|
||||
bool text_area(const nana::rectangle&);
|
||||
bool tip_string(nana::string&&);
|
||||
|
||||
@@ -180,8 +195,7 @@ namespace nana{ namespace widgets
|
||||
void text(nana::string);
|
||||
nana::string text() const;
|
||||
|
||||
//move_caret
|
||||
//@brief: Set caret position through text coordinate
|
||||
/// Sets caret position through text coordinate.
|
||||
void move_caret(const upoint&);
|
||||
void move_caret_end();
|
||||
void reset_caret_height() const;
|
||||
@@ -190,7 +204,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
bool selected() const;
|
||||
bool select(bool);
|
||||
//Set the end position of a selected string
|
||||
/// Sets the end position of a selected string.
|
||||
void set_end_caret();
|
||||
bool hit_text_area(const point&) const;
|
||||
bool hit_select_area(nana::upoint pos) const;
|
||||
@@ -199,6 +213,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
/// Returns width of text area excluding the vscroll size.
|
||||
unsigned width_pixels() const;
|
||||
window window_handle() const;
|
||||
public:
|
||||
void draw_scroll_rectangle();
|
||||
void render(bool focused);
|
||||
@@ -227,46 +242,43 @@ namespace nana{ namespace widgets
|
||||
skeletons::textbase<nana::char_t>& textbase();
|
||||
const skeletons::textbase<nana::char_t>& textbase() const;
|
||||
private:
|
||||
nana::color_t _m_bgcolor() const;
|
||||
bool _m_accepts(char_type) const;
|
||||
::nana::color _m_bgcolor() const;
|
||||
bool _m_scroll_text(bool vertical);
|
||||
void _m_on_scroll(const arg_mouse&);
|
||||
void _m_scrollbar();
|
||||
nana::size _m_text_area() const;
|
||||
::nana::size _m_text_area() const;
|
||||
void _m_get_scrollbar_size();
|
||||
void _m_reset();
|
||||
nana::upoint _m_put(nana::string);
|
||||
nana::upoint _m_erase_select();
|
||||
::nana::upoint _m_put(nana::string);
|
||||
::nana::upoint _m_erase_select();
|
||||
|
||||
bool _m_make_select_string(nana::string&) const;
|
||||
static bool _m_resolve_text(const nana::string&, std::vector<std::pair<std::size_t, std::size_t>> & lines);
|
||||
|
||||
bool _m_cancel_select(int align);
|
||||
unsigned _m_tabs_pixels(size_type tabs) const;
|
||||
nana::size _m_text_extent_size(const char_type*) const;
|
||||
nana::size _m_text_extent_size(const char_type*, size_type n) const;
|
||||
|
||||
//_m_move_offset_x_while_over_border
|
||||
//@brief: Moves the view window
|
||||
/// Moves the view of window.
|
||||
bool _m_move_offset_x_while_over_border(int many);
|
||||
bool _m_move_select(bool record_undo);
|
||||
|
||||
int _m_text_top_base() const;
|
||||
//_m_endx
|
||||
//@brief: Gets the right point of text area
|
||||
|
||||
/// Returns the right point of text area.
|
||||
int _m_endx() const;
|
||||
//_m_endy
|
||||
//@brief: Get the bottom point of text area
|
||||
/// Returns the bottom point of text area.
|
||||
int _m_endy() const;
|
||||
|
||||
void _m_draw_tip_string() const;
|
||||
|
||||
void _m_draw_parse_string(const keyword_parser&, bool rtl, ::nana::point pos, const ::nana::color& fgcolor, const ::nana::char_t*, std::size_t len) const;
|
||||
//_m_draw_string
|
||||
//@brief: Draw a line of string
|
||||
void _m_draw_string(int top, nana::color_t color, const nana::upoint& str_pos, const nana::string&, bool if_mask) const;
|
||||
//_m_draw
|
||||
//@brief: Draw a character at a position specified by caret pos.
|
||||
//@return: true if beyond the border
|
||||
bool _m_draw(nana::char_t, std::size_t secondary_before);
|
||||
void _m_draw_string(int top, const ::nana::color&, const nana::upoint& str_pos, const nana::string&, bool if_mask) const;
|
||||
//_m_update_caret_line
|
||||
//@brief: redraw whole line specified by caret pos.
|
||||
//@return: true if caret overs the border
|
||||
bool _m_update_caret_line(std::size_t secondary_before);
|
||||
bool _m_get_sort_select_points(nana::upoint&, nana::upoint&) const;
|
||||
|
||||
void _m_offset_y(int y);
|
||||
@@ -279,6 +291,9 @@ namespace nana{ namespace widgets
|
||||
undoable<command> undo_;
|
||||
nana::window window_;
|
||||
graph_reference graph_;
|
||||
const text_editor_scheme* scheme_;
|
||||
std::unique_ptr<keywords> keywords_;
|
||||
|
||||
skeletons::textbase<nana::char_t> textbase_;
|
||||
nana::char_t mask_char_{0};
|
||||
|
||||
@@ -286,6 +301,9 @@ namespace nana{ namespace widgets
|
||||
|
||||
struct attributes
|
||||
{
|
||||
accepts acceptive{ accepts::no_restrict };
|
||||
std::function<bool(char_type)> pred_acceptive;
|
||||
|
||||
nana::string tip_string;
|
||||
|
||||
bool line_wrapped{false};
|
||||
@@ -308,7 +326,7 @@ namespace nana{ namespace widgets
|
||||
unsigned scroll_pixels;
|
||||
unsigned vscroll;
|
||||
unsigned hscroll;
|
||||
std::function<void(nana::paint::graphics&, nana::color_t)> border_renderer;
|
||||
std::function<void(nana::paint::graphics&, const ::nana::color&)> border_renderer;
|
||||
}text_area_;
|
||||
|
||||
struct selection
|
||||
|
||||
22
include/nana/gui/widgets/skeletons/text_editor_scheme.hpp
Normal file
22
include/nana/gui/widgets/skeletons/text_editor_scheme.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
#ifndef NANA_WIDGETS_SKELETONS_TEXT_EDITOR_SCHEME_HPP
|
||||
#define NANA_WIDGETS_SKELETONS_TEXT_EDITOR_SCHEME_HPP
|
||||
|
||||
#include "../../detail/widget_colors.hpp"
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace widgets
|
||||
{
|
||||
namespace skeletons
|
||||
{
|
||||
struct text_editor_scheme
|
||||
: public ::nana::widget_colors
|
||||
{
|
||||
color_proxy selection{static_cast<color_rgb>(0x3399FF)};
|
||||
color_proxy selection_text{colors::white};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -45,9 +45,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
tokenizer(const nana::string& s, bool format_enabled)
|
||||
: iptr_(s.data()),
|
||||
endptr_(s.data() + s.size()),
|
||||
format_enabled_(format_enabled),
|
||||
format_state_(false),
|
||||
revert_token_(token::eof)
|
||||
format_enabled_(format_enabled)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -414,17 +412,14 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
}
|
||||
}
|
||||
private:
|
||||
const nana::char_t * iptr_;
|
||||
const nana::char_t * endptr_;
|
||||
const ::nana::char_t * iptr_;
|
||||
const ::nana::char_t * endptr_;
|
||||
const bool format_enabled_;
|
||||
bool format_state_;
|
||||
bool format_state_{false};
|
||||
|
||||
nana::string idstr_;
|
||||
::nana::string idstr_;
|
||||
std::pair<nana::string, nana::string> binary_;
|
||||
|
||||
std::size_t whspace_size_;
|
||||
|
||||
token revert_token_;
|
||||
token revert_token_{token::eof};
|
||||
};
|
||||
|
||||
//The fblock states a format, and a format from which it is inherted
|
||||
@@ -439,16 +434,16 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
};
|
||||
};
|
||||
|
||||
nana::string font;
|
||||
::nana::string font;
|
||||
std::size_t font_size;
|
||||
bool bold;
|
||||
bool bold_empty; //bold should be ignored if bold_empty is true
|
||||
aligns::t text_align;
|
||||
nana::color_t bgcolor; //If the color is not specified, it will be ignored, and the system will search for its parent.
|
||||
nana::color_t fgcolor; //ditto
|
||||
::nana::color bgcolor; //If the color is not specified, it will be ignored, and the system will search for its parent.
|
||||
::nana::color fgcolor; //ditto
|
||||
|
||||
nana::string target;
|
||||
nana::string url;
|
||||
::nana::string target;
|
||||
::nana::string url;
|
||||
|
||||
fblock * parent;
|
||||
};
|
||||
@@ -528,7 +523,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
{
|
||||
public:
|
||||
data_image(const nana::string& imgpath, const nana::size & sz, std::size_t limited)
|
||||
: image_(imgpath), limited_(limited)
|
||||
: image_(imgpath)//, limited_(limited)
|
||||
{
|
||||
size_ = image_.size();
|
||||
|
||||
@@ -597,7 +592,6 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
nana::string str_;
|
||||
nana::paint::image image_;
|
||||
nana::size size_;
|
||||
std::size_t limited_;
|
||||
};
|
||||
|
||||
class dstream
|
||||
@@ -741,41 +735,45 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
switch(tknizer.read())
|
||||
{
|
||||
case token::number:
|
||||
fp->fgcolor = tknizer.number();
|
||||
{
|
||||
pixel_color_t px;
|
||||
px.value = static_cast<unsigned>(tknizer.number());
|
||||
fp->fgcolor = {px.element.red, px.element.green, px.element.blue};
|
||||
}
|
||||
break;
|
||||
case token::red:
|
||||
fp->fgcolor = 0xFF0000;
|
||||
fp->fgcolor = colors::red;
|
||||
break;
|
||||
case token::green:
|
||||
fp->fgcolor = 0xFF00;
|
||||
fp->fgcolor = colors::green;
|
||||
break;
|
||||
case token::blue:
|
||||
fp->fgcolor = 0xFF;
|
||||
fp->fgcolor = colors::blue;
|
||||
break;
|
||||
case token::white:
|
||||
fp->fgcolor = 0xFFFFFF;
|
||||
fp->fgcolor = colors::white;
|
||||
break;
|
||||
case token::black:
|
||||
fp->fgcolor = 0x0;
|
||||
fp->fgcolor = colors::black;
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("");
|
||||
}
|
||||
break;
|
||||
case token::red: //support the omitting of color.
|
||||
fp->fgcolor = 0xFF0000;
|
||||
fp->fgcolor = colors::red;
|
||||
break;
|
||||
case token::green: //support the omitting of color.
|
||||
fp->fgcolor = 0xFF00;
|
||||
fp->fgcolor = colors::green;
|
||||
break;
|
||||
case token::blue: //support the omitting of color.
|
||||
fp->fgcolor = 0xFF;
|
||||
fp->fgcolor = colors::blue;
|
||||
break;
|
||||
case token::white: //support the omitting of color.
|
||||
fp->fgcolor = 0xFFFFFF;
|
||||
fp->fgcolor = colors::white;
|
||||
break;
|
||||
case token::black: //support the omitting of color.
|
||||
fp->fgcolor = 0x0;
|
||||
fp->fgcolor = colors::black;
|
||||
break;
|
||||
case token::baseline:
|
||||
fp->text_align = fblock::aligns::baseline;
|
||||
@@ -867,10 +865,6 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
fbp->bold_empty = true;
|
||||
fbp->text_align = fblock::aligns::baseline;
|
||||
|
||||
//Refer to the definition for the color specification.
|
||||
fbp->bgcolor = 0xFFFFFFFF;
|
||||
fbp->fgcolor = 0xFFFFFFFF;
|
||||
|
||||
fbp->parent = nullptr;
|
||||
|
||||
fblocks_.push_back(fbp);
|
||||
@@ -910,8 +904,7 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
v.data_ptr = new data_text(idstr);
|
||||
break;
|
||||
default:
|
||||
int * debug = 0; //for debug
|
||||
*debug = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
line.push_back(v);
|
||||
@@ -928,7 +921,6 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
}
|
||||
|
||||
private:
|
||||
bool format_enabled_;
|
||||
std::vector<fblock*> fblocks_;
|
||||
std::list<std::deque<value> > lines_;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A textbase class implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -511,6 +511,9 @@ namespace skeletons
|
||||
_m_first_change();
|
||||
changed_ = true;
|
||||
}
|
||||
|
||||
if (evt_agent_)
|
||||
evt_agent_->text_changed();
|
||||
}
|
||||
private:
|
||||
std::deque<string_type> text_cont_;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Definitions of textbase export interfaces
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -25,6 +25,7 @@ namespace nana{ namespace widgets
|
||||
virtual ~textbase_event_agent_interface() = default;
|
||||
|
||||
virtual void first_change() = 0; ///< An event for the text first change after text has been opened or stored.
|
||||
virtual void text_changed() = 0; ///< An event for the change of text.
|
||||
};
|
||||
}//end namespace skeletons
|
||||
}//end namespace widgets
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Slider Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -19,8 +19,11 @@ namespace nana
|
||||
class slider;
|
||||
|
||||
struct arg_slider
|
||||
: public event_arg
|
||||
{
|
||||
slider & widget;
|
||||
|
||||
arg_slider(slider&);
|
||||
};
|
||||
|
||||
namespace drawerbase
|
||||
@@ -41,7 +44,7 @@ namespace nana
|
||||
class provider
|
||||
{
|
||||
public:
|
||||
virtual ~provider() = 0;
|
||||
virtual ~provider() = default;
|
||||
virtual nana::string adorn_trace(unsigned vmax, unsigned vadorn) const = 0;
|
||||
};
|
||||
|
||||
@@ -74,7 +77,7 @@ namespace nana
|
||||
unsigned vcur_scale; //pixels of vcur scale.
|
||||
};
|
||||
|
||||
virtual ~renderer() = 0;
|
||||
virtual ~renderer() = default;
|
||||
|
||||
virtual void background(window, graph_reference, bool isglass) = 0;
|
||||
virtual void adorn(window, graph_reference, const adorn_t&) = 0;
|
||||
|
||||
124
include/nana/gui/widgets/spinbox.hpp
Normal file
124
include/nana/gui/widgets/spinbox.hpp
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* A Spin box widget
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/widgets/spinbox.hpp
|
||||
*/
|
||||
|
||||
#ifndef NANA_GUI_WIDGET_SPINBOX_HPP
|
||||
#define NANA_GUI_WIDGET_SPINBOX_HPP
|
||||
#include "widget.hpp"
|
||||
#include "skeletons/text_editor_scheme.hpp"
|
||||
|
||||
namespace nana
|
||||
{
|
||||
class spinbox;
|
||||
|
||||
struct arg_spinbox
|
||||
: public event_arg
|
||||
{
|
||||
spinbox & widget;
|
||||
arg_spinbox(spinbox&);
|
||||
};
|
||||
|
||||
namespace drawerbase
|
||||
{
|
||||
namespace spinbox
|
||||
{
|
||||
struct spinbox_events
|
||||
: public general_events
|
||||
{
|
||||
basic_event<arg_spinbox> text_changed;
|
||||
};
|
||||
|
||||
/// Declaration of internal spinbox implementation
|
||||
class implementation;
|
||||
|
||||
/// Drawer of spinbox
|
||||
class drawer
|
||||
: public ::nana::drawer_trigger
|
||||
{
|
||||
drawer(const drawer&) = delete;
|
||||
drawer(drawer&&) = delete;
|
||||
drawer& operator=(const drawer&) = delete;
|
||||
drawer& operator=(drawer&&) = delete;
|
||||
public:
|
||||
drawer();
|
||||
~drawer();
|
||||
implementation * impl() const;
|
||||
private:
|
||||
//Overrides drawer_trigger
|
||||
void attached(widget_reference, graph_reference) override;
|
||||
void refresh(graph_reference) override;
|
||||
|
||||
void focus(graph_reference, const arg_focus&) override;
|
||||
void mouse_wheel(graph_reference, const arg_wheel&) override;
|
||||
void mouse_down(graph_reference, const arg_mouse&) override;
|
||||
void mouse_move(graph_reference, const arg_mouse&) override;
|
||||
void mouse_up(graph_reference, const arg_mouse& arg) override;
|
||||
void mouse_leave(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 resized(graph_reference, const arg_resized&) override;
|
||||
private:
|
||||
implementation * const impl_;
|
||||
};
|
||||
};
|
||||
}//end namespace drawerbase
|
||||
|
||||
/// Spinbox Widget
|
||||
class spinbox
|
||||
: public widget_object <category::widget_tag, drawerbase::spinbox::drawer, drawerbase::spinbox::spinbox_events, ::nana::widgets::skeletons::text_editor_scheme>
|
||||
{
|
||||
public:
|
||||
/// Constructs a spinbox.
|
||||
spinbox();
|
||||
spinbox(window, bool visible);
|
||||
spinbox(window, const nana::rectangle& = {}, bool visible = true);
|
||||
|
||||
/// Sets the widget whether it accepts user keyboard input.
|
||||
/// @param accept Set to indicate whether it accepts uesr keyboard input.
|
||||
void editable(bool accept);
|
||||
|
||||
/// Determines whether the widget accepts user keyboard input.
|
||||
bool editable() const;
|
||||
|
||||
/// Sets the numeric spin values and step.
|
||||
void range(int begin, int last, int step);
|
||||
void range(double begin, double last, double step);
|
||||
|
||||
/// Sets the string spin values.
|
||||
void range(std::initializer_list<std::string> values_utf8);
|
||||
void range(std::initializer_list<std::wstring> values);
|
||||
|
||||
/// Gets the spined value
|
||||
::nana::string value() const;
|
||||
void value(const ::nana::string&);
|
||||
int to_int() const;
|
||||
double to_double() const;
|
||||
|
||||
/// Sets the modifiers
|
||||
void modifier(std::wstring prefix, std::wstring suffix);
|
||||
void modifier(const std::string & prefix_utf8, const std::string& suffix_utf8);
|
||||
private:
|
||||
::nana::string _m_caption() const;
|
||||
void _m_caption(::nana::string&&);
|
||||
}; //end class spinbox
|
||||
|
||||
namespace dev
|
||||
{
|
||||
template<>
|
||||
struct widget_traits<spinbox>
|
||||
{
|
||||
using event_type = drawerbase::spinbox::spinbox_events;
|
||||
using scheme_type = ::nana::widgets::skeletons::text_editor_scheme;
|
||||
};
|
||||
}
|
||||
}//end namespace nana
|
||||
|
||||
#endif //NANA_GUI_WIDGET_SPINBOX_HPP
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Tabbar implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -24,9 +24,14 @@ namespace nana
|
||||
|
||||
template<typename T>
|
||||
struct arg_tabbar
|
||||
: public event_arg
|
||||
{
|
||||
tabbar<T> & widget;
|
||||
T & value;
|
||||
|
||||
arg_tabbar(tabbar<T>& wdg, T& v)
|
||||
: widget{ wdg }, value{ v }
|
||||
{}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@@ -57,7 +62,7 @@ namespace nana
|
||||
class event_agent_interface
|
||||
{
|
||||
public:
|
||||
virtual ~event_agent_interface() = 0;
|
||||
virtual ~event_agent_interface() = default;
|
||||
virtual void added(std::size_t) = 0;
|
||||
virtual void activated(std::size_t) = 0;
|
||||
virtual bool removed(std::size_t) = 0;
|
||||
@@ -67,18 +72,18 @@ namespace nana
|
||||
{
|
||||
public:
|
||||
typedef item_renderer item_renderer_type;
|
||||
typedef nana::paint::graphics & graph_reference;
|
||||
typedef ::nana::paint::graphics & graph_reference;
|
||||
enum state_t{disable, normal, highlight, press};
|
||||
|
||||
struct item_t
|
||||
{
|
||||
nana::rectangle r;
|
||||
nana::color_t bgcolor;
|
||||
nana::color_t fgcolor;
|
||||
::nana::rectangle r;
|
||||
::nana::color bgcolor;
|
||||
::nana::color fgcolor;
|
||||
};
|
||||
|
||||
virtual ~item_renderer() = 0;
|
||||
virtual void background(graph_reference, const nana::rectangle& r, nana::color_t bgcolor) = 0;
|
||||
virtual ~item_renderer() = default;
|
||||
virtual void background(graph_reference, const nana::rectangle& r, const ::nana::color& bgcolor) = 0;
|
||||
virtual void item(graph_reference, const item_t&, bool active, state_t) = 0;
|
||||
virtual void close_fly(graph_reference, const nana::rectangle&, bool active, state_t) = 0;
|
||||
|
||||
@@ -150,7 +155,7 @@ namespace nana
|
||||
std::size_t length() const;
|
||||
bool close_fly(bool);
|
||||
void relate(size_t, window);
|
||||
void tab_color(std::size_t, bool is_bgcolor, nana::color_t);
|
||||
void tab_color(std::size_t, bool is_bgcolor, const ::nana::color&);
|
||||
void tab_image(size_t, const nana::paint::image&);
|
||||
void text(std::size_t, const nana::string&);
|
||||
nana::string text(std::size_t) const;
|
||||
@@ -278,14 +283,14 @@ namespace nana
|
||||
this->get_drawer_trigger().relate(pos, wd);
|
||||
}
|
||||
|
||||
void tab_bgcolor(std::size_t i, nana::color_t color)
|
||||
void tab_bgcolor(std::size_t i, const ::nana::color& clr)
|
||||
{
|
||||
this->get_drawer_trigger().tab_color(i, true, color);
|
||||
this->get_drawer_trigger().tab_color(i, true, clr);
|
||||
}
|
||||
|
||||
void tab_fgcolor(std::size_t i, nana::color_t color)
|
||||
void tab_fgcolor(std::size_t i, const ::nana::color& clr)
|
||||
{
|
||||
this->get_drawer_trigger().tab_color(i, false, color);
|
||||
this->get_drawer_trigger().tab_color(i, false, clr);
|
||||
}
|
||||
|
||||
void tab_image(std::size_t i, const nana::paint::image& img)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Textbox Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -13,14 +13,18 @@
|
||||
#define NANA_GUI_WIDGET_TEXTBOX_HPP
|
||||
#include <nana/gui/widgets/widget.hpp>
|
||||
#include "skeletons/textbase_export_interface.hpp"
|
||||
#include "skeletons/text_editor_scheme.hpp"
|
||||
|
||||
namespace nana
|
||||
{
|
||||
class textbox;
|
||||
|
||||
struct arg_textbox
|
||||
: public event_arg
|
||||
{
|
||||
textbox& widget;
|
||||
|
||||
arg_textbox(textbox&);
|
||||
};
|
||||
|
||||
namespace widgets
|
||||
@@ -39,14 +43,16 @@ namespace nana
|
||||
: public general_events
|
||||
{
|
||||
basic_event<arg_textbox> first_change;
|
||||
basic_event<arg_textbox> text_changed;
|
||||
};
|
||||
|
||||
class event_agent
|
||||
: public widgets::skeletons::textbase_event_agent_interface
|
||||
{
|
||||
public:
|
||||
event_agent(::nana::textbox& wdg);
|
||||
event_agent(::nana::textbox&);
|
||||
void first_change() override;
|
||||
void text_changed() override;
|
||||
private:
|
||||
::nana::textbox & widget_;
|
||||
};
|
||||
@@ -56,12 +62,11 @@ namespace nana
|
||||
: public drawer_trigger
|
||||
{
|
||||
public:
|
||||
typedef widgets::skeletons::text_editor text_editor;
|
||||
using text_editor = widgets::skeletons::text_editor;
|
||||
|
||||
drawer();
|
||||
text_editor * editor();
|
||||
const text_editor * editor() const;
|
||||
void set_accept(std::function<bool(nana::char_t)> &&);
|
||||
private:
|
||||
void attached(widget_reference, graph_reference) override;
|
||||
void detached() override;
|
||||
@@ -79,15 +84,8 @@ namespace nana
|
||||
void typeface_changed(graph_reference) override;
|
||||
private:
|
||||
void _m_text_area(unsigned width, unsigned height);
|
||||
void _m_draw_border(graph_reference, nana::color_t bgcolor);
|
||||
private:
|
||||
widget* widget_;
|
||||
struct status_type
|
||||
{
|
||||
bool has_focus; //Indicates whether it has the keyboard focus
|
||||
}status_;
|
||||
|
||||
std::function<bool(nana::char_t)> pred_acceptive_;
|
||||
widgets::skeletons::text_editor * editor_;
|
||||
std::unique_ptr<event_agent> evt_agent_;
|
||||
};
|
||||
@@ -96,7 +94,7 @@ namespace nana
|
||||
|
||||
/// Allow users to enter and edit text by typing on the keyboard.
|
||||
class textbox
|
||||
:public widget_object<category::widget_tag, drawerbase::textbox::drawer, drawerbase::textbox::textbox_events>
|
||||
:public widget_object<category::widget_tag, drawerbase::textbox::drawer, drawerbase::textbox::textbox_events, ::nana::widgets::skeletons::text_editor_scheme>
|
||||
{
|
||||
public:
|
||||
/// The default constructor without creating the widget.
|
||||
@@ -181,11 +179,28 @@ namespace nana
|
||||
double to_double() const;
|
||||
textbox& from(int);
|
||||
textbox& from(double);
|
||||
|
||||
void set_highlight(const std::string& name, const ::nana::color& fgcolor, const ::nana::color& bgcolor);
|
||||
void erase_highlight(const std::string& name);
|
||||
void set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<nana::string> kw_list);
|
||||
void set_keywords(const std::string& name, bool case_sensitive, bool whole_word_match, std::initializer_list<std::string> kw_list_utf8);
|
||||
void erase_keyword(const nana::string& kw);
|
||||
protected:
|
||||
//Overrides widget's virtual functions
|
||||
::nana::string _m_caption() const override;
|
||||
void _m_caption(::nana::string&&) override;
|
||||
void _m_typeface(const paint::font&) override;
|
||||
};
|
||||
|
||||
namespace dev
|
||||
{
|
||||
/// Traits for widget classes
|
||||
template<>
|
||||
struct widget_traits<textbox>
|
||||
{
|
||||
using event_type = drawerbase::textbox::textbox_events;
|
||||
using scheme_type = ::nana::widgets::skeletons::text_editor_scheme;
|
||||
};
|
||||
}
|
||||
}//end namespace nana
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Toolbar Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -21,9 +21,12 @@ namespace nana
|
||||
class toolbar;
|
||||
|
||||
struct arg_toolbar
|
||||
: public event_arg
|
||||
{
|
||||
toolbar& widget;
|
||||
std::size_t button;
|
||||
|
||||
arg_toolbar(toolbar&, std::size_t);
|
||||
};
|
||||
|
||||
namespace drawerbase
|
||||
@@ -67,7 +70,7 @@ namespace nana
|
||||
void mouse_up(graph_reference, const arg_mouse&) override;
|
||||
private:
|
||||
size_type _m_which(int x, int y, bool want_if_disabled) const;
|
||||
void _m_draw_background(nana::color_t);
|
||||
void _m_draw_background(const ::nana::color&);
|
||||
void _m_draw();
|
||||
void _m_owner_sized(const arg_resized&);
|
||||
private:
|
||||
@@ -87,7 +90,7 @@ namespace nana
|
||||
public:
|
||||
typedef std::size_t size_type; ///< A type to count the number of elements.
|
||||
|
||||
toolbar();
|
||||
toolbar() = default;
|
||||
toolbar(window, bool visible);
|
||||
toolbar(window, const rectangle& = rectangle(), bool visible = true);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Tree Box Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -74,11 +74,13 @@ namespace nana
|
||||
virtual ~renderer_interface()
|
||||
{}
|
||||
|
||||
virtual void bground(graph_reference, nana::color_t bgcolor, nana::color_t fgcolor, const compset_interface *) const = 0;
|
||||
virtual void expander(graph_reference, nana::color_t bgcolor, nana::color_t fgcolor, const compset_interface *) const = 0;
|
||||
virtual void crook(graph_reference, nana::color_t bgcolor, nana::color_t fgcolor, const compset_interface *) const = 0;
|
||||
virtual void icon(graph_reference, nana::color_t bgcolor, nana::color_t fgcolor, const compset_interface *) const = 0;
|
||||
virtual void text(graph_reference, nana::color_t bgcolor, nana::color_t fgcolor, const compset_interface *) const = 0;
|
||||
virtual void set_color(const nana::color& bgcolor, const nana::color& fgcolor) = 0;
|
||||
|
||||
virtual void bground(graph_reference, const compset_interface *) const = 0;
|
||||
virtual void expander(graph_reference, const compset_interface *) const = 0;
|
||||
virtual void crook(graph_reference, const compset_interface *) const = 0;
|
||||
virtual void icon(graph_reference, const compset_interface *) const = 0;
|
||||
virtual void text(graph_reference, const compset_interface *) const = 0;
|
||||
};
|
||||
|
||||
class item_proxy;
|
||||
@@ -331,10 +333,13 @@ namespace nana
|
||||
}//end namespace drawerbase
|
||||
|
||||
struct arg_treebox
|
||||
: public event_arg
|
||||
{
|
||||
treebox& widget;
|
||||
drawerbase::treebox::item_proxy & item;
|
||||
bool operated;
|
||||
|
||||
arg_treebox(treebox&, drawerbase::treebox::item_proxy&, bool operated);
|
||||
};
|
||||
|
||||
namespace drawerbase
|
||||
@@ -411,8 +416,6 @@ namespace nana
|
||||
/// Determinte whether the checkbox is enabled.
|
||||
bool checkable() const;
|
||||
|
||||
treebox& icon(const nana::string& id, const node_image_type& node_img);
|
||||
|
||||
node_image_type& icon(const nana::string& id) const;
|
||||
|
||||
void icon_erase(const nana::string& id);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* The fundamental widget class implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -22,15 +22,13 @@
|
||||
|
||||
namespace nana
|
||||
{
|
||||
class drawer_trigger;
|
||||
|
||||
/// Abstract class for defining the capacity interface.
|
||||
/// Abstract class for defining the capacity interface.
|
||||
class widget
|
||||
: nana::noncopyable, nana::nonmovable
|
||||
{
|
||||
typedef void(*dummy_bool_type)(widget* (*)(const widget&));
|
||||
public:
|
||||
virtual ~widget();
|
||||
virtual ~widget() = default;
|
||||
virtual window handle() const = 0; ///< Returns the handle of window, returns 0 if window is not created.
|
||||
bool empty() const; ///< Determines whether the manipulator is handling a window.
|
||||
void close();
|
||||
@@ -38,6 +36,7 @@ namespace nana
|
||||
window parent() const;
|
||||
|
||||
nana::string caption() const;
|
||||
void caption(std::string utf8);
|
||||
void caption(nana::string);
|
||||
|
||||
template<typename ...Args>
|
||||
@@ -73,14 +72,18 @@ namespace nana
|
||||
void move(int x, int y);
|
||||
void move(const rectangle&);
|
||||
|
||||
void foreground(nana::color_t);
|
||||
nana::color_t foreground() const;
|
||||
void background(nana::color_t);
|
||||
nana::color_t background() const;
|
||||
void fgcolor(const nana::color&);
|
||||
nana::color fgcolor() const;
|
||||
void bgcolor(const nana::color&);
|
||||
nana::color bgcolor() const;
|
||||
|
||||
general_events& events() const;
|
||||
|
||||
void umake_event(event_handle eh) const; ///< Deletes an event callback by a handle.
|
||||
|
||||
widget& register_shortkey(char_t); ///< Registers a shortkey. To remove a registered key, pass 0.
|
||||
|
||||
widget& take_active(bool activated, window take_if_not_activated);
|
||||
widget& tooltip(const nana::string&);
|
||||
|
||||
operator dummy_bool_type() const;
|
||||
@@ -106,21 +109,24 @@ namespace nana
|
||||
virtual void _m_typeface(const nana::paint::font& font);
|
||||
virtual nana::paint::font _m_typeface() const;
|
||||
|
||||
virtual void _m_foreground(nana::color_t);
|
||||
virtual nana::color_t _m_foreground() const;
|
||||
virtual void _m_background(nana::color_t);
|
||||
virtual nana::color_t _m_background() const;
|
||||
virtual void _m_fgcolor(const nana::color&);
|
||||
virtual nana::color _m_fgcolor() const;
|
||||
virtual void _m_bgcolor(const nana::color&);
|
||||
virtual nana::color _m_bgcolor() const;
|
||||
};
|
||||
|
||||
/// Base class of all the classes defined as a widget window. Defaultly a widget_tag
|
||||
template<typename Category, typename DrawerTrigger, typename Events = nana::general_events>
|
||||
template<typename Category, typename DrawerTrigger, typename Events = ::nana::general_events, typename Scheme = ::nana::widget_colors>
|
||||
class widget_object: public widget
|
||||
{
|
||||
protected:
|
||||
typedef DrawerTrigger drawer_trigger_t;
|
||||
public:
|
||||
using scheme_type = Scheme;
|
||||
|
||||
widget_object()
|
||||
: events_(std::make_shared<Events>())
|
||||
: events_{ std::make_shared<Events>() },
|
||||
scheme_{ API::dev::make_scheme<Scheme>() }
|
||||
{}
|
||||
|
||||
~widget_object()
|
||||
@@ -139,12 +145,13 @@ namespace nana
|
||||
return create(parent_wd, rectangle(), visible);
|
||||
}
|
||||
|
||||
bool create(window parent_wd, const rectangle & r = rectangle(), bool visible = true) ///< in a widget/root window specified by parent_wd.
|
||||
bool create(window parent_wd, const rectangle & r = {}, bool visible = true) ///< in a widget/root window specified by parent_wd.
|
||||
{
|
||||
if(parent_wd && this->empty())
|
||||
{
|
||||
handle_ = API::dev::create_widget(parent_wd, r, this);
|
||||
API::dev::set_events(handle_, events_);
|
||||
API::dev::set_scheme(handle_, scheme_.get());
|
||||
API::dev::attach_signal(handle_, *this, &widget_object::signal);
|
||||
API::dev::attach_drawer(*this, trigger_);
|
||||
if(visible)
|
||||
@@ -170,6 +177,11 @@ namespace nana
|
||||
{
|
||||
return API::widget_borderless(handle_);
|
||||
}
|
||||
|
||||
scheme_type& scheme() const
|
||||
{
|
||||
return *scheme_;
|
||||
}
|
||||
protected:
|
||||
DrawerTrigger& get_drawer_trigger()
|
||||
{
|
||||
@@ -200,7 +212,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
general_events& _m_get_general_events() const
|
||||
general_events& _m_get_general_events() const override
|
||||
{
|
||||
return *events_;
|
||||
}
|
||||
@@ -208,18 +220,20 @@ namespace nana
|
||||
window handle_{nullptr};
|
||||
DrawerTrigger trigger_;
|
||||
std::shared_ptr<Events> events_;
|
||||
std::unique_ptr<scheme_type> scheme_;
|
||||
};//end class widget_object
|
||||
|
||||
/// Base class of all the classes defined as a non-graphics-buffer widget window. The second template parameter DrawerTrigger is always ignored.\see nana::panel
|
||||
template<typename DrawerTrigger, typename Events>
|
||||
class widget_object<category::lite_widget_tag, DrawerTrigger, Events>: public widget
|
||||
template<typename DrawerTrigger, typename Events, typename Scheme>
|
||||
class widget_object<category::lite_widget_tag, DrawerTrigger, Events, Scheme>: public widget
|
||||
{
|
||||
protected:
|
||||
typedef DrawerTrigger drawer_trigger_t;
|
||||
public:
|
||||
using scheme_type = Scheme;
|
||||
|
||||
widget_object()
|
||||
: events_(std::make_shared<Events>())
|
||||
: events_{ std::make_shared<Events>() }, scheme_{ API::dev::make_scheme<scheme_type>() }
|
||||
{}
|
||||
|
||||
~widget_object()
|
||||
@@ -244,6 +258,7 @@ namespace nana
|
||||
{
|
||||
handle_ = API::dev::create_lite_widget(parent_wd, r, this);
|
||||
API::dev::set_events(handle_, events_);
|
||||
API::dev::set_scheme(handle_, scheme_.get());
|
||||
if(visible)
|
||||
API::show_window(handle_, true);
|
||||
this->_m_complete_creation();
|
||||
@@ -251,10 +266,15 @@ namespace nana
|
||||
return (this->empty() == false);
|
||||
}
|
||||
|
||||
window handle() const
|
||||
window handle() const override
|
||||
{
|
||||
return handle_;
|
||||
}
|
||||
|
||||
scheme_type& scheme() const
|
||||
{
|
||||
return *scheme_;
|
||||
}
|
||||
private:
|
||||
void signal(detail::signals::code code, const detail::signals& sig)
|
||||
{
|
||||
@@ -275,23 +295,25 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
general_events& _m_get_general_events() const
|
||||
general_events& _m_get_general_events() const override
|
||||
{
|
||||
return *events_;
|
||||
}
|
||||
private:
|
||||
window handle_{nullptr};
|
||||
std::shared_ptr<Events> events_;
|
||||
std::unique_ptr<scheme_type> scheme_;
|
||||
};//end class widget_object
|
||||
|
||||
|
||||
/// Base class of all the classes defined as a root window. \see nana::form
|
||||
template<typename DrawerTrigger, typename Events>
|
||||
class widget_object<category::root_tag, DrawerTrigger, Events>: public widget
|
||||
template<typename DrawerTrigger, typename Events, typename Scheme>
|
||||
class widget_object<category::root_tag, DrawerTrigger, Events, Scheme>: public widget
|
||||
{
|
||||
protected:
|
||||
typedef DrawerTrigger drawer_trigger_t;
|
||||
public:
|
||||
using scheme_type = Scheme;
|
||||
|
||||
widget_object()
|
||||
{
|
||||
@@ -299,13 +321,13 @@ namespace nana
|
||||
_m_bind_and_attach();
|
||||
}
|
||||
|
||||
widget_object(const rectangle& r, const appearance& apr = appearance())
|
||||
widget_object(const rectangle& r, const appearance& apr = {})
|
||||
{
|
||||
handle_ = API::dev::create_window(nullptr, false, r, apr, this);
|
||||
_m_bind_and_attach();
|
||||
}
|
||||
|
||||
widget_object(window owner, bool nested, const rectangle& r = rectangle(), const appearance& apr = appearance())
|
||||
widget_object(window owner, bool nested, const rectangle& r = {}, const appearance& apr = {})
|
||||
{
|
||||
handle_ = API::dev::create_window(owner, nested, r, apr, this);
|
||||
_m_bind_and_attach();
|
||||
@@ -327,12 +349,7 @@ namespace nana
|
||||
API::activate_window(handle_);
|
||||
}
|
||||
|
||||
void bring_to_top()
|
||||
{
|
||||
API::bring_to_top(handle_);
|
||||
}
|
||||
|
||||
window handle() const
|
||||
window handle() const override
|
||||
{
|
||||
return handle_;
|
||||
}
|
||||
@@ -342,6 +359,11 @@ namespace nana
|
||||
return API::root(handle_);
|
||||
}
|
||||
|
||||
void bring_top(bool activated)
|
||||
{
|
||||
API::bring_top(handle(), activated);
|
||||
}
|
||||
|
||||
window owner() const
|
||||
{
|
||||
return API::get_owner_window(handle_);
|
||||
@@ -362,9 +384,30 @@ namespace nana
|
||||
API::zoom_window(handle_, ask_for_max);
|
||||
}
|
||||
|
||||
bool is_zoomed(bool ask_for_max) const
|
||||
bool is_zoomed(bool check_maximized) const
|
||||
{
|
||||
return API::is_window_zoomed(handle_, ask_for_max);
|
||||
return API::is_window_zoomed(handle_, check_maximized);
|
||||
}
|
||||
|
||||
widget_object& z_order(window wd_after, z_order_action action_if_no_wd_after)
|
||||
{
|
||||
API::set_window_z_order(handle_, wd_after, action_if_no_wd_after);
|
||||
return *this;
|
||||
}
|
||||
|
||||
scheme_type& scheme() const
|
||||
{
|
||||
return *scheme_;
|
||||
}
|
||||
|
||||
void draw_through(std::function<void()> draw_fn)
|
||||
{
|
||||
API::draw_through(handle(), draw_fn);
|
||||
}
|
||||
|
||||
void map_through_widgets(native_drawable_type drawable)
|
||||
{
|
||||
API::map_through_widgets(handle(), drawable);
|
||||
}
|
||||
protected:
|
||||
DrawerTrigger& get_drawer_trigger()
|
||||
@@ -400,11 +443,14 @@ namespace nana
|
||||
{
|
||||
events_ = std::make_shared<Events>();
|
||||
API::dev::set_events(handle_, events_);
|
||||
|
||||
scheme_ = API::dev::make_scheme<scheme_type>();
|
||||
API::dev::set_scheme(handle_, scheme_.get());
|
||||
API::dev::attach_signal(handle_, *this, &widget_object::signal);
|
||||
API::dev::attach_drawer(*this, trigger_);
|
||||
}
|
||||
|
||||
general_events& _m_get_general_events() const
|
||||
general_events& _m_get_general_events() const override
|
||||
{
|
||||
return *events_;
|
||||
}
|
||||
@@ -412,21 +458,24 @@ namespace nana
|
||||
window handle_;
|
||||
DrawerTrigger trigger_;
|
||||
std::shared_ptr<Events> events_;
|
||||
std::unique_ptr<scheme_type> scheme_;
|
||||
};//end class widget_object<root_tag>
|
||||
|
||||
/// Base class of all the classes defined as a frame window. \see nana::frame
|
||||
template<typename Drawer, typename Events>
|
||||
class widget_object<category::frame_tag, Drawer, Events>: public widget{};
|
||||
template<typename Drawer, typename Events, typename Scheme>
|
||||
class widget_object<category::frame_tag, Drawer, Events, Scheme>: public widget{};
|
||||
|
||||
/// Especialization. Base class of all the classes defined as a frame window. \see nana::frame
|
||||
template<typename Events>
|
||||
class widget_object<category::frame_tag, int, Events>: public widget
|
||||
template<typename Events, typename Scheme>
|
||||
class widget_object<category::frame_tag, int, Events, Scheme>: public widget
|
||||
{
|
||||
protected:
|
||||
typedef int drawer_trigger_t;
|
||||
public:
|
||||
using scheme_type = Scheme;
|
||||
|
||||
widget_object()
|
||||
: events_(std::make_shared<Events>())
|
||||
: events_{ std::make_shared<Events>() }, scheme_{ API::dev::make_scheme<scheme_type>() }
|
||||
{}
|
||||
|
||||
~widget_object()
|
||||
@@ -451,6 +500,7 @@ namespace nana
|
||||
{
|
||||
handle_ = API::dev::create_frame(parent_wd, r, this);
|
||||
API::dev::set_events(handle_, events_);
|
||||
API::dev::set_scheme(handle_, scheme_.get());
|
||||
API::dev::attach_signal(handle_, *this, &widget_object::signal);
|
||||
API::show_window(handle_, visible);
|
||||
this->_m_complete_creation();
|
||||
@@ -458,10 +508,15 @@ namespace nana
|
||||
return (this->empty() == false);
|
||||
}
|
||||
|
||||
window handle() const
|
||||
window handle() const override
|
||||
{
|
||||
return handle_;
|
||||
}
|
||||
|
||||
scheme_type& scheme() const
|
||||
{
|
||||
return *scheme_;
|
||||
}
|
||||
private:
|
||||
virtual drawer_trigger* get_drawer_trigger()
|
||||
{
|
||||
@@ -487,13 +542,14 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
general_events& _m_get_general_events() const
|
||||
general_events& _m_get_general_events() const override
|
||||
{
|
||||
return *events_;
|
||||
}
|
||||
private:
|
||||
window handle_{nullptr};
|
||||
std::shared_ptr<Events> events_;
|
||||
std::unique_ptr<scheme_type> scheme_;
|
||||
};//end class widget_object<category::frame_tag>
|
||||
}//end namespace nana
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Nana GUI Library Definition
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -15,6 +16,7 @@
|
||||
#define NANA_GUI_WVL_HPP
|
||||
|
||||
#include "programming_interface.hpp"
|
||||
#include "screen.hpp"
|
||||
#include "widgets/form.hpp"
|
||||
#include "drawing.hpp"
|
||||
#include "msgbox.hpp"
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace nana
|
||||
class arg_eval;
|
||||
|
||||
template<typename Return>
|
||||
class arg_function
|
||||
class arg_function: public eval_arg
|
||||
{
|
||||
public:
|
||||
arg_function(std::function<Return()> fn)
|
||||
@@ -208,4 +208,4 @@ namespace nana
|
||||
};//end class i18n_eval;
|
||||
}
|
||||
|
||||
#endif//NANA_I18N_HPP
|
||||
#endif//NANA_I18N_HPP
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace nana{ namespace paint
|
||||
|
||||
pixbuf_.open(info->bmiHeader.biWidth, height_pixels);
|
||||
|
||||
pixel_rgb_t * d = pixbuf_.raw_ptr(0);
|
||||
auto d = pixbuf_.raw_ptr(0);
|
||||
|
||||
if(16 <= info->bmiHeader.biBitCount)
|
||||
{
|
||||
@@ -110,23 +110,23 @@ namespace nana{ namespace paint
|
||||
}
|
||||
else if(8 == info->bmiHeader.biBitCount)
|
||||
{
|
||||
const pixel_rgb_t * const lend = d + info->bmiHeader.biWidth * height_pixels;
|
||||
const auto lend = d + info->bmiHeader.biWidth * height_pixels;
|
||||
|
||||
if(info->bmiHeader.biHeight < 0)
|
||||
{
|
||||
const unsigned char* s = bits;
|
||||
auto s = bits;
|
||||
while(d < lend)
|
||||
{
|
||||
pixel_rgb_t * d_p = d;
|
||||
pixel_rgb_t * const dpend = d_p + info->bmiHeader.biWidth;
|
||||
const unsigned char * s_p = s;
|
||||
auto d_p = d;
|
||||
auto dpend = d_p + info->bmiHeader.biWidth;
|
||||
auto s_p = s;
|
||||
while(d_p != dpend)
|
||||
{
|
||||
rgb_quad & rgb = info->bmiColors[*s_p++];
|
||||
d_p->u.element.red = rgb.rgbRed;
|
||||
d_p->u.element.green = rgb.rgbGreen;
|
||||
d_p->u.element.blue = rgb.rgbBlue;
|
||||
d_p->u.element.alpha_channel = rgb.rgbReserved;
|
||||
d_p->element.red = rgb.rgbRed;
|
||||
d_p->element.green = rgb.rgbGreen;
|
||||
d_p->element.blue = rgb.rgbBlue;
|
||||
d_p->element.alpha_channel = rgb.rgbReserved;
|
||||
++d_p;
|
||||
}
|
||||
d = dpend;
|
||||
@@ -135,19 +135,19 @@ namespace nana{ namespace paint
|
||||
}
|
||||
else
|
||||
{
|
||||
const unsigned char* s = bits + bytes_per_line * (height_pixels - 1);
|
||||
const auto* s = bits + bytes_per_line * (height_pixels - 1);
|
||||
while(d < lend)
|
||||
{
|
||||
pixel_rgb_t * d_p = d;
|
||||
pixel_rgb_t * const dpend = d_p + info->bmiHeader.biWidth;
|
||||
const unsigned char * s_p = s;
|
||||
auto d_p = d;
|
||||
auto* const dpend = d_p + info->bmiHeader.biWidth;
|
||||
const auto * s_p = s;
|
||||
while(d_p != dpend)
|
||||
{
|
||||
rgb_quad & rgb = info->bmiColors[*s_p++];
|
||||
d_p->u.element.red = rgb.rgbRed;
|
||||
d_p->u.element.green = rgb.rgbGreen;
|
||||
d_p->u.element.blue = rgb.rgbBlue;
|
||||
d_p->u.element.alpha_channel = rgb.rgbReserved;
|
||||
d_p->element.red = rgb.rgbRed;
|
||||
d_p->element.green = rgb.rgbGreen;
|
||||
d_p->element.blue = rgb.rgbBlue;
|
||||
d_p->element.alpha_channel = rgb.rgbReserved;
|
||||
++d_p;
|
||||
}
|
||||
d = dpend;
|
||||
@@ -157,23 +157,23 @@ namespace nana{ namespace paint
|
||||
}
|
||||
else if(4 == info->bmiHeader.biBitCount)
|
||||
{
|
||||
const pixel_rgb_t * const lend = d + info->bmiHeader.biWidth * height_pixels;
|
||||
const auto * const lend = d + info->bmiHeader.biWidth * height_pixels;
|
||||
if(info->bmiHeader.biHeight < 0)
|
||||
{
|
||||
const unsigned char* s = bits;
|
||||
while(d < lend)
|
||||
{
|
||||
pixel_rgb_t * d_p = d;
|
||||
pixel_rgb_t * const dpend = d_p + info->bmiHeader.biWidth;
|
||||
auto d_p = d;
|
||||
auto * const dpend = d_p + info->bmiHeader.biWidth;
|
||||
unsigned index = 0;
|
||||
while(d_p != dpend)
|
||||
{
|
||||
rgb_quad & rgb = info->bmiColors[(index & 1) ? (s[index >> 1] & 0xF) : (s[index >> 1] & 0xF0) >> 4];
|
||||
|
||||
d_p->u.element.red = rgb.rgbRed;
|
||||
d_p->u.element.green = rgb.rgbGreen;
|
||||
d_p->u.element.blue = rgb.rgbBlue;
|
||||
d_p->u.element.alpha_channel = rgb.rgbReserved;
|
||||
d_p->element.red = rgb.rgbRed;
|
||||
d_p->element.green = rgb.rgbGreen;
|
||||
d_p->element.blue = rgb.rgbBlue;
|
||||
d_p->element.alpha_channel = rgb.rgbReserved;
|
||||
++d_p;
|
||||
++index;
|
||||
}
|
||||
@@ -183,21 +183,21 @@ namespace nana{ namespace paint
|
||||
}
|
||||
else
|
||||
{
|
||||
const unsigned char* s = bits + bytes_per_line * (height_pixels - 1);
|
||||
const auto* s = bits + bytes_per_line * (height_pixels - 1);
|
||||
while(d < lend)
|
||||
{
|
||||
pixel_rgb_t * d_p = d;
|
||||
pixel_rgb_t * const dpend = d_p + info->bmiHeader.biWidth;
|
||||
auto d_p = d;
|
||||
auto * const dpend = d_p + info->bmiHeader.biWidth;
|
||||
|
||||
unsigned index = 0;
|
||||
while(d_p != dpend)
|
||||
{
|
||||
rgb_quad & rgb = info->bmiColors[(index & 1) ? (s[index >> 1] & 0xF) : (s[index >> 1] & 0xF0) >> 4];
|
||||
|
||||
d_p->u.element.red = rgb.rgbRed;
|
||||
d_p->u.element.green = rgb.rgbGreen;
|
||||
d_p->u.element.blue = rgb.rgbBlue;
|
||||
d_p->u.element.alpha_channel = rgb.rgbReserved;
|
||||
d_p->element.red = rgb.rgbRed;
|
||||
d_p->element.green = rgb.rgbGreen;
|
||||
d_p->element.blue = rgb.rgbBlue;
|
||||
d_p->element.alpha_channel = rgb.rgbReserved;
|
||||
++d_p;
|
||||
++index;
|
||||
}
|
||||
@@ -208,24 +208,24 @@ namespace nana{ namespace paint
|
||||
}
|
||||
else if(2 == info->bmiHeader.biBitCount)
|
||||
{
|
||||
const pixel_rgb_t * const lend = d + info->bmiHeader.biWidth * height_pixels;
|
||||
const auto * const lend = d + info->bmiHeader.biWidth * height_pixels;
|
||||
if(info->bmiHeader.biHeight < 0)
|
||||
{
|
||||
const unsigned char* s = bits;
|
||||
while(d < lend)
|
||||
{
|
||||
pixel_rgb_t * d_p = d;
|
||||
pixel_rgb_t * const dpend = d_p + info->bmiHeader.biWidth;
|
||||
auto d_p = d;
|
||||
auto * const dpend = d_p + info->bmiHeader.biWidth;
|
||||
unsigned index = 0;
|
||||
while(d_p != dpend)
|
||||
{
|
||||
unsigned shift = (3 - (index & 0x3)) << 1; // (index % 4) * 2
|
||||
rgb_quad& rgb = info->bmiColors[(s[index >> 2] & (0x3 << shift))>>shift];
|
||||
|
||||
d_p->u.element.red = rgb.rgbRed;
|
||||
d_p->u.element.green = rgb.rgbGreen;
|
||||
d_p->u.element.blue = rgb.rgbBlue;
|
||||
d_p->u.element.alpha_channel = rgb.rgbReserved;
|
||||
d_p->element.red = rgb.rgbRed;
|
||||
d_p->element.green = rgb.rgbGreen;
|
||||
d_p->element.blue = rgb.rgbBlue;
|
||||
d_p->element.alpha_channel = rgb.rgbReserved;
|
||||
++d_p;
|
||||
++index;
|
||||
}
|
||||
@@ -235,11 +235,11 @@ namespace nana{ namespace paint
|
||||
}
|
||||
else
|
||||
{
|
||||
const unsigned char* s = bits + bytes_per_line * (height_pixels - 1);
|
||||
const auto* s = bits + bytes_per_line * (height_pixels - 1);
|
||||
while(d < lend)
|
||||
{
|
||||
pixel_rgb_t * d_p = d;
|
||||
pixel_rgb_t * const dpend = d_p + info->bmiHeader.biWidth;
|
||||
auto d_p = d;
|
||||
auto * const dpend = d_p + info->bmiHeader.biWidth;
|
||||
|
||||
unsigned index = 0;
|
||||
while(d_p != dpend)
|
||||
@@ -247,10 +247,10 @@ namespace nana{ namespace paint
|
||||
unsigned shift = (3 - (index & 0x3)) << 1; // (index % 4) * 2
|
||||
rgb_quad& rgb = info->bmiColors[(s[index >> 2] & (0x3 << shift))>>shift];
|
||||
|
||||
d_p->u.element.red = rgb.rgbRed;
|
||||
d_p->u.element.green = rgb.rgbGreen;
|
||||
d_p->u.element.blue = rgb.rgbBlue;
|
||||
d_p->u.element.alpha_channel = rgb.rgbReserved;
|
||||
d_p->element.red = rgb.rgbRed;
|
||||
d_p->element.green = rgb.rgbGreen;
|
||||
d_p->element.blue = rgb.rgbBlue;
|
||||
d_p->element.alpha_channel = rgb.rgbReserved;
|
||||
++d_p;
|
||||
++index;
|
||||
}
|
||||
@@ -261,24 +261,24 @@ namespace nana{ namespace paint
|
||||
}
|
||||
else if(1 == info->bmiHeader.biBitCount)
|
||||
{
|
||||
const pixel_rgb_t * const lend = d + info->bmiHeader.biWidth * height_pixels;
|
||||
const auto * const lend = d + info->bmiHeader.biWidth * height_pixels;
|
||||
if(info->bmiHeader.biHeight < 0)
|
||||
{
|
||||
const unsigned char* s = bits;
|
||||
const auto* s = bits;
|
||||
while(d < lend)
|
||||
{
|
||||
pixel_rgb_t * d_p = d;
|
||||
pixel_rgb_t * const dpend = d_p + info->bmiHeader.biWidth;
|
||||
auto d_p = d;
|
||||
auto * const dpend = d_p + info->bmiHeader.biWidth;
|
||||
unsigned index = 0;
|
||||
while(d_p != dpend)
|
||||
{
|
||||
unsigned bi = (7 - (index & 7)); //(index % 8)
|
||||
rgb_quad & rgb = info->bmiColors[(s[index >> 3] & (1 << bi)) >> bi];
|
||||
|
||||
d_p->u.element.red = rgb.rgbRed;
|
||||
d_p->u.element.green = rgb.rgbGreen;
|
||||
d_p->u.element.blue = rgb.rgbBlue;
|
||||
d_p->u.element.alpha_channel = rgb.rgbReserved;
|
||||
d_p->element.red = rgb.rgbRed;
|
||||
d_p->element.green = rgb.rgbGreen;
|
||||
d_p->element.blue = rgb.rgbBlue;
|
||||
d_p->element.alpha_channel = rgb.rgbReserved;
|
||||
++d_p;
|
||||
++index;
|
||||
}
|
||||
@@ -288,11 +288,11 @@ namespace nana{ namespace paint
|
||||
}
|
||||
else
|
||||
{
|
||||
const unsigned char* s = bits + bytes_per_line * (height_pixels - 1);
|
||||
const auto* s = bits + bytes_per_line * (height_pixels - 1);
|
||||
while(d < lend)
|
||||
{
|
||||
pixel_rgb_t * d_p = d;
|
||||
pixel_rgb_t * const dpend = d_p + info->bmiHeader.biWidth;
|
||||
auto d_p = d;
|
||||
auto * const dpend = d_p + info->bmiHeader.biWidth;
|
||||
|
||||
unsigned index = 0;
|
||||
while(d_p != dpend)
|
||||
@@ -300,10 +300,10 @@ namespace nana{ namespace paint
|
||||
unsigned bi = (7 - (index & 7));
|
||||
rgb_quad & rgb = info->bmiColors[(s[index >> 3] & (1 << bi)) >> bi];
|
||||
|
||||
d_p->u.element.red = rgb.rgbRed;
|
||||
d_p->u.element.green = rgb.rgbGreen;
|
||||
d_p->u.element.blue = rgb.rgbBlue;
|
||||
d_p->u.element.alpha_channel = rgb.rgbReserved;
|
||||
d_p->element.red = rgb.rgbRed;
|
||||
d_p->element.green = rgb.rgbGreen;
|
||||
d_p->element.blue = rgb.rgbBlue;
|
||||
d_p->element.alpha_channel = rgb.rgbReserved;
|
||||
++d_p;
|
||||
++index;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace nana
|
||||
const bool is_alpha_enabled = ((PNG_COLOR_MASK_ALPHA & color_type) != 0);
|
||||
pixbuf_.alpha_channel(is_alpha_enabled);
|
||||
|
||||
if(is_alpha_enabled && (png_rowbytes == png_width * sizeof(pixel_rgb_t)))
|
||||
if(is_alpha_enabled && (png_rowbytes == png_width * sizeof(pixel_argb_t)))
|
||||
{
|
||||
for(int i = 0; i < png_height; ++i)
|
||||
row_ptrs[i] = reinterpret_cast<png_bytep>(pixbuf_.raw_ptr(i));
|
||||
@@ -85,9 +85,9 @@ namespace nana
|
||||
auto p = pixbuf_.raw_ptr(i);
|
||||
for (int u = 0; u < png_width; ++u)
|
||||
{
|
||||
auto t = p[u].u.element.red;
|
||||
p[u].u.element.red = p[u].u.element.blue;
|
||||
p[u].u.element.blue = t;
|
||||
auto t = p[u].element.red;
|
||||
p[u].element.red = p[u].element.blue;
|
||||
p[u].element.blue = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,32 +103,32 @@ namespace nana
|
||||
|
||||
std::size_t png_pixel_bytes = png_rowbytes / png_width;
|
||||
|
||||
pixel_rgb_t * rgb_row_ptr = pixbuf_.raw_ptr(0);
|
||||
pixel_argb_t * rgb_row_ptr = pixbuf_.raw_ptr(0);
|
||||
for(int y = 0; y < png_height; ++y)
|
||||
{
|
||||
png_bytep png_ptr = row_ptrs[y];
|
||||
|
||||
pixel_rgb_t * rgb_end = rgb_row_ptr + png_width;
|
||||
pixel_argb_t * rgb_end = rgb_row_ptr + png_width;
|
||||
|
||||
if(is_alpha_enabled)
|
||||
{
|
||||
for(pixel_rgb_t * i = rgb_row_ptr; i < rgb_end; ++i)
|
||||
for(pixel_argb_t * i = rgb_row_ptr; i < rgb_end; ++i)
|
||||
{
|
||||
i->u.element.red = png_ptr[0];
|
||||
i->u.element.green = png_ptr[1];
|
||||
i->u.element.blue = png_ptr[2];
|
||||
i->u.element.alpha_channel = png_ptr[3];
|
||||
i->element.red = png_ptr[0];
|
||||
i->element.green = png_ptr[1];
|
||||
i->element.blue = png_ptr[2];
|
||||
i->element.alpha_channel = png_ptr[3];
|
||||
png_ptr += png_pixel_bytes;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(pixel_rgb_t * i = rgb_row_ptr; i < rgb_end; ++i)
|
||||
for(pixel_argb_t * i = rgb_row_ptr; i < rgb_end; ++i)
|
||||
{
|
||||
i->u.element.red = png_ptr[0];
|
||||
i->u.element.green = png_ptr[1];
|
||||
i->u.element.blue = png_ptr[2];
|
||||
i->u.element.alpha_channel = 255;
|
||||
i->element.red = png_ptr[0];
|
||||
i->element.green = png_ptr[1];
|
||||
i->element.blue = png_ptr[2];
|
||||
i->element.alpha_channel = 255;
|
||||
png_ptr += png_pixel_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,32 +38,32 @@ namespace detail
|
||||
double rate_x = double(r_src.width) / r_dst.width;
|
||||
double rate_y = double(r_src.height) / r_dst.height;
|
||||
|
||||
pixel_rgb_t * s_raw_pixbuf = s_pixbuf.raw_ptr(0);
|
||||
pixel_argb_t * s_raw_pixbuf = s_pixbuf.raw_ptr(0);
|
||||
|
||||
if(s_pixbuf.alpha_channel())
|
||||
{
|
||||
for(std::size_t row = 0; row < r_dst.height; ++row)
|
||||
{
|
||||
const pixel_rgb_t * s_line = pixel_at(s_raw_pixbuf, (static_cast<int>(row * rate_y) + r_src.y) * bytes_per_line);
|
||||
pixel_rgb_t * i = pixbuf.raw_ptr(r_dst.y + row);
|
||||
const pixel_argb_t * s_line = pixel_at(s_raw_pixbuf, (static_cast<int>(row * rate_y) + r_src.y) * bytes_per_line);
|
||||
pixel_argb_t * i = pixbuf.raw_ptr(r_dst.y + row);
|
||||
|
||||
for(std::size_t x = 0; x < r_dst.width; ++x, ++i)
|
||||
{
|
||||
const pixel_rgb_t * s = s_line + static_cast<int>(x * rate_x) + r_src.x;
|
||||
if(0 == s->u.element.alpha_channel)
|
||||
const pixel_argb_t * s = s_line + static_cast<int>(x * rate_x) + r_src.x;
|
||||
if(0 == s->element.alpha_channel)
|
||||
continue;
|
||||
|
||||
if(s->u.element.alpha_channel != 255)
|
||||
if(s->element.alpha_channel != 255)
|
||||
{
|
||||
i->u.element.red = unsigned(i->u.element.red * (255 - s->u.element.alpha_channel) + s->u.element.red * s->u.element.alpha_channel) / 255;
|
||||
i->u.element.green = unsigned(i->u.element.green * (255 - s->u.element.alpha_channel) + s->u.element.green * s->u.element.alpha_channel) / 255;
|
||||
i->u.element.blue = unsigned(i->u.element.blue * (255 - s->u.element.alpha_channel) + s->u.element.blue * s->u.element.alpha_channel) / 255;
|
||||
i->element.red = unsigned(i->element.red * (255 - s->element.alpha_channel) + s->element.red * s->element.alpha_channel) / 255;
|
||||
i->element.green = unsigned(i->element.green * (255 - s->element.alpha_channel) + s->element.green * s->element.alpha_channel) / 255;
|
||||
i->element.blue = unsigned(i->element.blue * (255 - s->element.alpha_channel) + s->element.blue * s->element.alpha_channel) / 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned alpha_chn = i->u.element.alpha_channel;
|
||||
unsigned alpha_chn = i->element.alpha_channel;
|
||||
*i = *s;
|
||||
i->u.element.alpha_channel = alpha_chn;
|
||||
i->element.alpha_channel = alpha_chn;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,8 +72,8 @@ namespace detail
|
||||
{
|
||||
for(std::size_t row = 0; row < r_dst.height; ++row)
|
||||
{
|
||||
const pixel_rgb_t * s_line = pixel_at(s_raw_pixbuf, (static_cast<int>(row * rate_y) + r_src.y) * bytes_per_line);
|
||||
pixel_rgb_t * i = pixbuf.raw_ptr(r_dst.y + row);
|
||||
const pixel_argb_t * s_line = pixel_at(s_raw_pixbuf, (static_cast<int>(row * rate_y) + r_src.y) * bytes_per_line);
|
||||
pixel_argb_t * i = pixbuf.raw_ptr(r_dst.y + row);
|
||||
|
||||
for(std::size_t x = 0; x < r_dst.width; ++x, ++i)
|
||||
*i = s_line[static_cast<int>(x * rate_x) + r_src.x];
|
||||
@@ -105,7 +105,7 @@ namespace detail
|
||||
|
||||
const int right_bound = static_cast<int>(r_src.width) - 1 + r_src.x;
|
||||
|
||||
const nana::pixel_rgb_t * s_raw_pixel_buffer = s_pixbuf.raw_ptr(0);
|
||||
const nana::pixel_argb_t * s_raw_pixel_buffer = s_pixbuf.raw_ptr(0);
|
||||
|
||||
const int bottom = r_src.y + static_cast<int>(r_src.height - 1);
|
||||
|
||||
@@ -151,15 +151,15 @@ namespace detail
|
||||
std::size_t iv = static_cast<size_t>(v * coef);
|
||||
const std::size_t iv_minus_coef = coef - iv;
|
||||
|
||||
const nana::pixel_rgb_t * s_line = pixel_at(s_raw_pixel_buffer, sy * s_bytes_per_line);
|
||||
const nana::pixel_rgb_t * next_s_line = pixel_at(s_line, (sy < bottom ? s_bytes_per_line : 0));
|
||||
const nana::pixel_argb_t * s_line = pixel_at(s_raw_pixel_buffer, sy * s_bytes_per_line);
|
||||
const nana::pixel_argb_t * next_s_line = pixel_at(s_line, (sy < bottom ? s_bytes_per_line : 0));
|
||||
|
||||
nana::pixel_rgb_t col0;
|
||||
nana::pixel_rgb_t col1;
|
||||
nana::pixel_rgb_t col2;
|
||||
nana::pixel_rgb_t col3;
|
||||
nana::pixel_argb_t col0;
|
||||
nana::pixel_argb_t col1;
|
||||
nana::pixel_argb_t col2;
|
||||
nana::pixel_argb_t col3;
|
||||
|
||||
pixel_rgb_t * i = pixbuf.raw_ptr(row + r_dst.y) + r_dst.x;
|
||||
pixel_argb_t * i = pixbuf.raw_ptr(row + r_dst.y) + r_dst.x;
|
||||
|
||||
if(is_alpha_channel)
|
||||
{
|
||||
@@ -186,24 +186,24 @@ namespace detail
|
||||
std::size_t coef2 = el.iu * iv_minus_coef;
|
||||
std::size_t coef3 = el.iu * iv;
|
||||
|
||||
unsigned alpha_chn = static_cast<unsigned>((coef0 * col0.u.element.alpha_channel + coef1 * col1.u.element.alpha_channel + (coef2 * col2.u.element.alpha_channel + coef3 * col3.u.element.alpha_channel)) >> double_shift_size);
|
||||
unsigned s_red = static_cast<unsigned>((coef0 * col0.u.element.red + coef1 * col1.u.element.red + (coef2 * col2.u.element.red + coef3 * col3.u.element.red)) >> double_shift_size);
|
||||
unsigned s_green = static_cast<unsigned>((coef0 * col0.u.element.green + coef1 * col1.u.element.green + (coef2 * col2.u.element.green + coef3 * col3.u.element.green)) >> double_shift_size);
|
||||
unsigned s_blue = static_cast<unsigned>((coef0 * col0.u.element.blue + coef1 * col1.u.element.blue + (coef2 * col2.u.element.blue + coef3 * col3.u.element.blue)) >> double_shift_size);
|
||||
unsigned alpha_chn = static_cast<unsigned>((coef0 * col0.element.alpha_channel + coef1 * col1.element.alpha_channel + (coef2 * col2.element.alpha_channel + coef3 * col3.element.alpha_channel)) >> double_shift_size);
|
||||
unsigned s_red = static_cast<unsigned>((coef0 * col0.element.red + coef1 * col1.element.red + (coef2 * col2.element.red + coef3 * col3.element.red)) >> double_shift_size);
|
||||
unsigned s_green = static_cast<unsigned>((coef0 * col0.element.green + coef1 * col1.element.green + (coef2 * col2.element.green + coef3 * col3.element.green)) >> double_shift_size);
|
||||
unsigned s_blue = static_cast<unsigned>((coef0 * col0.element.blue + coef1 * col1.element.blue + (coef2 * col2.element.blue + coef3 * col3.element.blue)) >> double_shift_size);
|
||||
|
||||
if(alpha_chn)
|
||||
{
|
||||
if(alpha_chn != 255)
|
||||
{
|
||||
i->u.element.red = unsigned(i->u.element.red * (255 - alpha_chn) + s_red * alpha_chn) / 255;
|
||||
i->u.element.green = unsigned(i->u.element.green * (255 - alpha_chn) + s_green * alpha_chn) / 255;
|
||||
i->u.element.blue = unsigned(i->u.element.blue * (255 - alpha_chn) + s_blue * alpha_chn) / 255;
|
||||
i->element.red = unsigned(i->element.red * (255 - alpha_chn) + s_red * alpha_chn) / 255;
|
||||
i->element.green = unsigned(i->element.green * (255 - alpha_chn) + s_green * alpha_chn) / 255;
|
||||
i->element.blue = unsigned(i->element.blue * (255 - alpha_chn) + s_blue * alpha_chn) / 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
i->u.element.red = s_red;
|
||||
i->u.element.green = s_green;
|
||||
i->u.element.blue = s_blue;
|
||||
i->element.red = s_red;
|
||||
i->element.green = s_green;
|
||||
i->element.blue = s_blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -233,9 +233,9 @@ namespace detail
|
||||
std::size_t coef2 = el.iu * iv_minus_coef;
|
||||
std::size_t coef3 = el.iu * iv;
|
||||
|
||||
i->u.element.red = static_cast<unsigned>((coef0 * col0.u.element.red + coef1 * col1.u.element.red + (coef2 * col2.u.element.red + coef3 * col3.u.element.red)) >> double_shift_size);
|
||||
i->u.element.green = static_cast<unsigned>((coef0 * col0.u.element.green + coef1 * col1.u.element.green + (coef2 * col2.u.element.green + coef3 * col3.u.element.green)) >> double_shift_size);
|
||||
i->u.element.blue = static_cast<unsigned>((coef0 * col0.u.element.blue + coef1 * col1.u.element.blue + (coef2 * col2.u.element.blue + coef3 * col3.u.element.blue)) >> double_shift_size);
|
||||
i->element.red = static_cast<unsigned>((coef0 * col0.element.red + coef1 * col1.element.red + (coef2 * col2.element.red + coef3 * col3.element.red)) >> double_shift_size);
|
||||
i->element.green = static_cast<unsigned>((coef0 * col0.element.green + coef1 * col1.element.green + (coef2 * col2.element.green + coef3 * col3.element.green)) >> double_shift_size);
|
||||
i->element.blue = static_cast<unsigned>((coef0 * col0.element.blue + coef1 * col1.element.blue + (coef2 * col2.element.blue + coef3 * col3.element.blue)) >> double_shift_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,83 +250,83 @@ namespace detail
|
||||
//process
|
||||
virtual void process(const paint::pixel_buffer& s_pixbuf, const nana::rectangle& s_r, paint::pixel_buffer& d_pixbuf, const nana::point& d_pos) const
|
||||
{
|
||||
nana::pixel_rgb_t * d_rgb = d_pixbuf.at(d_pos);
|
||||
nana::pixel_rgb_t * s_rgb = s_pixbuf.raw_ptr(s_r.y) + s_r.x;
|
||||
auto d_rgb = d_pixbuf.at(d_pos);
|
||||
auto s_rgb = s_pixbuf.raw_ptr(s_r.y) + s_r.x;
|
||||
if(d_rgb && s_rgb)
|
||||
{
|
||||
const unsigned rest = s_r.width & 0x3;
|
||||
const unsigned length_align4 = s_r.width - rest;
|
||||
|
||||
std::size_t d_step_bytes = d_pixbuf.bytes_per_line() - (s_r.width - rest) * sizeof(pixel_rgb_t);
|
||||
std::size_t s_step_bytes = s_pixbuf.bytes_per_line() - (s_r.width - rest) * sizeof(pixel_rgb_t);
|
||||
std::size_t d_step_bytes = d_pixbuf.bytes_per_line() - (s_r.width - rest) * sizeof(pixel_argb_t);
|
||||
std::size_t s_step_bytes = s_pixbuf.bytes_per_line() - (s_r.width - rest) * sizeof(pixel_argb_t);
|
||||
for(unsigned line = 0; line < s_r.height; ++line)
|
||||
{
|
||||
pixel_rgb_t* end = d_rgb + length_align4;
|
||||
const auto end = d_rgb + length_align4;
|
||||
for(; d_rgb < end; d_rgb += 4, s_rgb += 4)
|
||||
{
|
||||
//0
|
||||
if(s_rgb->u.element.alpha_channel)
|
||||
if(s_rgb->element.alpha_channel)
|
||||
{
|
||||
if(s_rgb->u.element.alpha_channel != 255)
|
||||
if(s_rgb->element.alpha_channel != 255)
|
||||
{
|
||||
d_rgb->u.element.red = unsigned(d_rgb->u.element.red * (255 - s_rgb[0].u.element.alpha_channel) + s_rgb[0].u.element.red * s_rgb[0].u.element.alpha_channel) / 255;
|
||||
d_rgb->u.element.green = unsigned(d_rgb->u.element.green * (255 - s_rgb[0].u.element.alpha_channel) + s_rgb[0].u.element.green * s_rgb[0].u.element.alpha_channel) / 255;
|
||||
d_rgb->u.element.blue = unsigned(d_rgb->u.element.blue * (255 - s_rgb[0].u.element.alpha_channel) + s_rgb[0].u.element.blue * s_rgb[0].u.element.alpha_channel) / 255;
|
||||
d_rgb->element.red = unsigned(d_rgb->element.red * (255 - s_rgb[0].element.alpha_channel) + s_rgb[0].element.red * s_rgb[0].element.alpha_channel) / 255;
|
||||
d_rgb->element.green = unsigned(d_rgb->element.green * (255 - s_rgb[0].element.alpha_channel) + s_rgb[0].element.green * s_rgb[0].element.alpha_channel) / 255;
|
||||
d_rgb->element.blue = unsigned(d_rgb->element.blue * (255 - s_rgb[0].element.alpha_channel) + s_rgb[0].element.blue * s_rgb[0].element.alpha_channel) / 255;
|
||||
}
|
||||
else
|
||||
*d_rgb = *s_rgb;
|
||||
}
|
||||
|
||||
//1
|
||||
if(s_rgb[1].u.element.alpha_channel)
|
||||
if(s_rgb[1].element.alpha_channel)
|
||||
{
|
||||
if(s_rgb[1].u.element.alpha_channel != 255)
|
||||
if(s_rgb[1].element.alpha_channel != 255)
|
||||
{
|
||||
d_rgb[1].u.element.red = unsigned(d_rgb[1].u.element.red * (255 - s_rgb[1].u.element.alpha_channel) + s_rgb[1].u.element.red * s_rgb[1].u.element.alpha_channel) / 255;
|
||||
d_rgb[1].u.element.green = unsigned(d_rgb[1].u.element.green * (255 - s_rgb[1].u.element.alpha_channel) + s_rgb[1].u.element.green * s_rgb[1].u.element.alpha_channel) / 255;
|
||||
d_rgb[1].u.element.blue = unsigned(d_rgb[1].u.element.blue * (255 - s_rgb[1].u.element.alpha_channel) + s_rgb[1].u.element.blue * s_rgb[1].u.element.alpha_channel) / 255;
|
||||
d_rgb[1].element.red = unsigned(d_rgb[1].element.red * (255 - s_rgb[1].element.alpha_channel) + s_rgb[1].element.red * s_rgb[1].element.alpha_channel) / 255;
|
||||
d_rgb[1].element.green = unsigned(d_rgb[1].element.green * (255 - s_rgb[1].element.alpha_channel) + s_rgb[1].element.green * s_rgb[1].element.alpha_channel) / 255;
|
||||
d_rgb[1].element.blue = unsigned(d_rgb[1].element.blue * (255 - s_rgb[1].element.alpha_channel) + s_rgb[1].element.blue * s_rgb[1].element.alpha_channel) / 255;
|
||||
}
|
||||
else
|
||||
d_rgb[1] = s_rgb[1];
|
||||
}
|
||||
|
||||
//2
|
||||
if(s_rgb[2].u.element.alpha_channel)
|
||||
if(s_rgb[2].element.alpha_channel)
|
||||
{
|
||||
if(s_rgb[2].u.element.alpha_channel != 255)
|
||||
if(s_rgb[2].element.alpha_channel != 255)
|
||||
{
|
||||
d_rgb[2].u.element.red = unsigned(d_rgb[2].u.element.red * (255 - s_rgb[2].u.element.alpha_channel) + s_rgb[2].u.element.red * s_rgb[2].u.element.alpha_channel) / 255;
|
||||
d_rgb[2].u.element.green = unsigned(d_rgb[2].u.element.green * (255 - s_rgb[2].u.element.alpha_channel) + s_rgb[2].u.element.green * s_rgb[2].u.element.alpha_channel) / 255;
|
||||
d_rgb[2].u.element.blue = unsigned(d_rgb[2].u.element.blue * (255 - s_rgb[2].u.element.alpha_channel) + s_rgb[2].u.element.blue * s_rgb[2].u.element.alpha_channel) / 255;
|
||||
d_rgb[2].element.red = unsigned(d_rgb[2].element.red * (255 - s_rgb[2].element.alpha_channel) + s_rgb[2].element.red * s_rgb[2].element.alpha_channel) / 255;
|
||||
d_rgb[2].element.green = unsigned(d_rgb[2].element.green * (255 - s_rgb[2].element.alpha_channel) + s_rgb[2].element.green * s_rgb[2].element.alpha_channel) / 255;
|
||||
d_rgb[2].element.blue = unsigned(d_rgb[2].element.blue * (255 - s_rgb[2].element.alpha_channel) + s_rgb[2].element.blue * s_rgb[2].element.alpha_channel) / 255;
|
||||
}
|
||||
else
|
||||
d_rgb[2] = s_rgb[2];
|
||||
}
|
||||
|
||||
//3
|
||||
if(s_rgb[3].u.element.alpha_channel)
|
||||
if(s_rgb[3].element.alpha_channel)
|
||||
{
|
||||
if(s_rgb[3].u.element.alpha_channel != 255)
|
||||
if(s_rgb[3].element.alpha_channel != 255)
|
||||
{
|
||||
d_rgb[3].u.element.red = unsigned(d_rgb[3].u.element.red * (255 - s_rgb[3].u.element.alpha_channel) + s_rgb[3].u.element.red * s_rgb[3].u.element.alpha_channel) / 255;
|
||||
d_rgb[3].u.element.green = unsigned(d_rgb[3].u.element.green * (255 - s_rgb[3].u.element.alpha_channel) + s_rgb[3].u.element.green * s_rgb[3].u.element.alpha_channel) / 255;
|
||||
d_rgb[3].u.element.blue = unsigned(d_rgb[3].u.element.blue * (255 - s_rgb[3].u.element.alpha_channel) + s_rgb[3].u.element.blue * s_rgb[3].u.element.alpha_channel) / 255;
|
||||
d_rgb[3].element.red = unsigned(d_rgb[3].element.red * (255 - s_rgb[3].element.alpha_channel) + s_rgb[3].element.red * s_rgb[3].element.alpha_channel) / 255;
|
||||
d_rgb[3].element.green = unsigned(d_rgb[3].element.green * (255 - s_rgb[3].element.alpha_channel) + s_rgb[3].element.green * s_rgb[3].element.alpha_channel) / 255;
|
||||
d_rgb[3].element.blue = unsigned(d_rgb[3].element.blue * (255 - s_rgb[3].element.alpha_channel) + s_rgb[3].element.blue * s_rgb[3].element.alpha_channel) / 255;
|
||||
}
|
||||
else
|
||||
d_rgb[3] = s_rgb[3];
|
||||
}
|
||||
}
|
||||
|
||||
const pixel_rgb_t * s_end = s_rgb + rest;
|
||||
const pixel_argb_t * s_end = s_rgb + rest;
|
||||
for(auto i = s_rgb; i != s_end; ++i)
|
||||
{
|
||||
if(i->u.element.alpha_channel)
|
||||
if(i->element.alpha_channel)
|
||||
{
|
||||
if(i->u.element.alpha_channel != 255)
|
||||
if(i->element.alpha_channel != 255)
|
||||
{
|
||||
d_rgb[3].u.element.red = unsigned(d_rgb[3].u.element.red * (255 - i->u.element.alpha_channel) + i->u.element.red * i->u.element.alpha_channel) / 255;
|
||||
d_rgb[3].u.element.green = unsigned(d_rgb[3].u.element.green * (255 - i->u.element.alpha_channel) + i->u.element.green * i->u.element.alpha_channel) / 255;
|
||||
d_rgb[3].u.element.blue = unsigned(d_rgb[3].u.element.blue * (255 - i->u.element.alpha_channel) + i->u.element.blue * i->u.element.alpha_channel) / 255;
|
||||
d_rgb[3].element.red = unsigned(d_rgb[3].element.red * (255 - i->element.alpha_channel) + i->element.red * i->element.alpha_channel) / 255;
|
||||
d_rgb[3].element.green = unsigned(d_rgb[3].element.green * (255 - i->element.alpha_channel) + i->element.green * i->element.alpha_channel) / 255;
|
||||
d_rgb[3].element.blue = unsigned(d_rgb[3].element.blue * (255 - i->element.alpha_channel) + i->element.blue * i->element.alpha_channel) / 255;
|
||||
}
|
||||
else
|
||||
d_rgb[3] = *i;
|
||||
@@ -347,56 +347,56 @@ namespace detail
|
||||
//process
|
||||
virtual void process(const paint::pixel_buffer& s_pixbuf, const nana::rectangle& s_r, paint::pixel_buffer& d_pixbuf, const nana::point& d_pos, double fade_rate) const
|
||||
{
|
||||
nana::pixel_rgb_t * d_rgb = d_pixbuf.raw_ptr(d_pos.y) + d_pos.x;
|
||||
nana::pixel_rgb_t * s_rgb = s_pixbuf.raw_ptr(s_r.y) + s_r.x;
|
||||
auto d_rgb = d_pixbuf.raw_ptr(d_pos.y) + d_pos.x;
|
||||
auto s_rgb = s_pixbuf.raw_ptr(s_r.y) + s_r.x;
|
||||
|
||||
if(d_rgb && s_rgb)
|
||||
{
|
||||
unsigned char* tablebuf = detail::alloc_fade_table(fade_rate);//new unsigned char[0x100 * 2];
|
||||
unsigned char* d_table = tablebuf;
|
||||
auto ptr = detail::alloc_fade_table(fade_rate);//new unsigned char[0x100 * 2];
|
||||
|
||||
unsigned char* d_table = ptr.get();
|
||||
unsigned char* s_table = d_table + 0x100;
|
||||
|
||||
const unsigned rest = s_r.width & 0x3;
|
||||
const unsigned length_align4 = s_r.width - rest;
|
||||
|
||||
std::size_t d_step_bytes = d_pixbuf.bytes_per_line() - (s_r.width - rest) * sizeof(pixel_rgb_t);
|
||||
std::size_t s_step_bytes = s_pixbuf.bytes_per_line() - (s_r.width - rest) * sizeof(pixel_rgb_t);
|
||||
std::size_t d_step_bytes = d_pixbuf.bytes_per_line() - (s_r.width - rest) * sizeof(pixel_argb_t);
|
||||
std::size_t s_step_bytes = s_pixbuf.bytes_per_line() - (s_r.width - rest) * sizeof(pixel_argb_t);
|
||||
for(unsigned line = 0; line < s_r.height; ++line)
|
||||
{
|
||||
pixel_rgb_t* end = d_rgb + length_align4;
|
||||
const auto end = d_rgb + length_align4;
|
||||
for(; d_rgb < end; d_rgb += 4, s_rgb += 4)
|
||||
{
|
||||
//0
|
||||
d_rgb[0].u.element.red = unsigned(d_table[d_rgb[0].u.element.red] + s_table[s_rgb[0].u.element.red]);
|
||||
d_rgb[0].u.element.green = unsigned(d_table[d_rgb[0].u.element.green] + s_table[s_rgb[0].u.element.green]);
|
||||
d_rgb[0].u.element.blue = unsigned(d_table[d_rgb[0].u.element.blue] + s_table[s_rgb[0].u.element.blue]);
|
||||
d_rgb[0].element.red = unsigned(d_table[d_rgb[0].element.red] + s_table[s_rgb[0].element.red]);
|
||||
d_rgb[0].element.green = unsigned(d_table[d_rgb[0].element.green] + s_table[s_rgb[0].element.green]);
|
||||
d_rgb[0].element.blue = unsigned(d_table[d_rgb[0].element.blue] + s_table[s_rgb[0].element.blue]);
|
||||
|
||||
//1
|
||||
d_rgb[1].u.element.red = unsigned(d_table[d_rgb[1].u.element.red] + s_table[s_rgb[1].u.element.red]);
|
||||
d_rgb[1].u.element.green = unsigned(d_table[d_rgb[1].u.element.green] + s_table[s_rgb[1].u.element.green]);
|
||||
d_rgb[1].u.element.blue = unsigned(d_table[d_rgb[1].u.element.blue] + s_table[s_rgb[1].u.element.blue]);
|
||||
d_rgb[1].element.red = unsigned(d_table[d_rgb[1].element.red] + s_table[s_rgb[1].element.red]);
|
||||
d_rgb[1].element.green = unsigned(d_table[d_rgb[1].element.green] + s_table[s_rgb[1].element.green]);
|
||||
d_rgb[1].element.blue = unsigned(d_table[d_rgb[1].element.blue] + s_table[s_rgb[1].element.blue]);
|
||||
|
||||
//2
|
||||
d_rgb[2].u.element.red = unsigned(d_table[d_rgb[2].u.element.red] + s_table[s_rgb[2].u.element.red]);
|
||||
d_rgb[2].u.element.green = unsigned(d_table[d_rgb[2].u.element.green] + s_table[s_rgb[2].u.element.green]);
|
||||
d_rgb[2].u.element.blue = unsigned(d_table[d_rgb[2].u.element.blue] + s_table[s_rgb[2].u.element.blue]);
|
||||
d_rgb[2].element.red = unsigned(d_table[d_rgb[2].element.red] + s_table[s_rgb[2].element.red]);
|
||||
d_rgb[2].element.green = unsigned(d_table[d_rgb[2].element.green] + s_table[s_rgb[2].element.green]);
|
||||
d_rgb[2].element.blue = unsigned(d_table[d_rgb[2].element.blue] + s_table[s_rgb[2].element.blue]);
|
||||
|
||||
//3
|
||||
d_rgb[3].u.element.red = unsigned(d_table[d_rgb[3].u.element.red] + s_table[s_rgb[3].u.element.red]);
|
||||
d_rgb[3].u.element.green = unsigned(d_table[d_rgb[3].u.element.green] + s_table[s_rgb[3].u.element.green]);
|
||||
d_rgb[3].u.element.blue = unsigned(d_table[d_rgb[3].u.element.blue] + s_table[s_rgb[3].u.element.blue]);
|
||||
d_rgb[3].element.red = unsigned(d_table[d_rgb[3].element.red] + s_table[s_rgb[3].element.red]);
|
||||
d_rgb[3].element.green = unsigned(d_table[d_rgb[3].element.green] + s_table[s_rgb[3].element.green]);
|
||||
d_rgb[3].element.blue = unsigned(d_table[d_rgb[3].element.blue] + s_table[s_rgb[3].element.blue]);
|
||||
}
|
||||
|
||||
for(unsigned i = 0; i < rest; ++i)
|
||||
{
|
||||
d_rgb[i].u.element.red = unsigned(d_table[d_rgb[i].u.element.red] + s_table[s_rgb[i].u.element.red]);
|
||||
d_rgb[i].u.element.green = unsigned(d_table[d_rgb[i].u.element.green] + s_table[s_rgb[i].u.element.green]);
|
||||
d_rgb[i].u.element.blue = unsigned(d_table[d_rgb[i].u.element.blue] + s_table[s_rgb[i].u.element.blue]);
|
||||
d_rgb[i].element.red = unsigned(d_table[d_rgb[i].element.red] + s_table[s_rgb[i].element.red]);
|
||||
d_rgb[i].element.green = unsigned(d_table[d_rgb[i].element.green] + s_table[s_rgb[i].element.green]);
|
||||
d_rgb[i].element.blue = unsigned(d_table[d_rgb[i].element.blue] + s_table[s_rgb[i].element.blue]);
|
||||
}
|
||||
d_rgb = pixel_at(d_rgb, d_step_bytes);
|
||||
s_rgb = pixel_at(s_rgb, s_step_bytes);
|
||||
}
|
||||
detail::free_fade_table(tablebuf);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -405,19 +405,23 @@ namespace detail
|
||||
class bresenham_line
|
||||
: public image_process::line_interface
|
||||
{
|
||||
virtual void process(paint::pixel_buffer & pixbuf, const nana::point& pos_beg, const nana::point& pos_end, nana::color_t color, double fade_rate) const
|
||||
virtual void process(paint::pixel_buffer & pixbuf, const nana::point& pos_beg, const nana::point& pos_end, const ::nana::color& clr, double fade_rate) const
|
||||
{
|
||||
auto rgb_color = clr.px_color().value;
|
||||
const std::size_t bytes_pl = pixbuf.bytes_per_line();
|
||||
|
||||
unsigned char * fade_table = nullptr;
|
||||
nana::pixel_rgb_t rgb_imd;
|
||||
std::unique_ptr<unsigned char[]> autoptr;
|
||||
nana::pixel_argb_t rgb_imd;
|
||||
if(fade_rate != 0.0)
|
||||
{
|
||||
fade_table = detail::alloc_fade_table(1 - fade_rate);
|
||||
rgb_imd.u.color = color;
|
||||
autoptr = detail::alloc_fade_table(1 - fade_rate);
|
||||
fade_table = autoptr.get();
|
||||
rgb_imd.value = rgb_color;
|
||||
rgb_imd = detail::fade_color_intermedia(rgb_imd, fade_table);
|
||||
}
|
||||
|
||||
nana::pixel_rgb_t * i = pixel_at(pixbuf.raw_ptr(0), pos_beg.y * bytes_pl) + pos_beg.x;
|
||||
auto i = pixel_at(pixbuf.raw_ptr(0), pos_beg.y * bytes_pl) + pos_beg.x;
|
||||
|
||||
auto delta = pos_end - pos_beg;
|
||||
|
||||
@@ -432,7 +436,7 @@ namespace detail
|
||||
|
||||
if(delta.x == delta.y)
|
||||
{
|
||||
step_bytes += sizeof(pixel_rgb_t);
|
||||
step_bytes += sizeof(pixel_argb_t);
|
||||
++delta.x;
|
||||
|
||||
if(fade_table)
|
||||
@@ -447,7 +451,7 @@ namespace detail
|
||||
{
|
||||
for(int x = 0; x < delta.x; ++x)
|
||||
{
|
||||
i->u.color = color;
|
||||
i->value = rgb_color;
|
||||
i = pixel_at(i, step_bytes);
|
||||
}
|
||||
}
|
||||
@@ -479,7 +483,7 @@ namespace detail
|
||||
{
|
||||
for(int x = 0; x < delta.x; ++x)
|
||||
{
|
||||
i->u.color = color;
|
||||
i->value = rgb_color;
|
||||
if(error >= 0)
|
||||
{
|
||||
error -= dx_2;
|
||||
@@ -513,7 +517,7 @@ namespace detail
|
||||
{
|
||||
for (int y = 0; y < delta.y; ++y)
|
||||
{
|
||||
i->u.color = color;
|
||||
i->value = rgb_color;
|
||||
if(error >= 0)
|
||||
{
|
||||
error -= dy_2;
|
||||
@@ -525,8 +529,6 @@ namespace detail
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
detail::free_fade_table(fade_table);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -579,20 +581,20 @@ namespace detail
|
||||
{
|
||||
for(int i = - radius; i <= radius; ++i)
|
||||
{
|
||||
nana::pixel_rgb_t px = linepix[(i > 0 ? i : 0)];
|
||||
sum_r += px.u.element.red;
|
||||
sum_g += px.u.element.green;
|
||||
sum_b += px.u.element.blue;
|
||||
auto px = linepix[(i > 0 ? i : 0)];
|
||||
sum_r += px.element.red;
|
||||
sum_g += px.element.green;
|
||||
sum_b += px.element.blue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = - radius; i <= radius; ++i)
|
||||
{
|
||||
nana::pixel_rgb_t px = linepix[std::min(wm, (i > 0 ? i : 0))];
|
||||
sum_r += px.u.element.red;
|
||||
sum_g += px.u.element.green;
|
||||
sum_b += px.u.element.blue;
|
||||
auto px = linepix[std::min(wm, (i > 0 ? i : 0))];
|
||||
sum_r += px.element.red;
|
||||
sum_g += px.element.green;
|
||||
sum_b += px.element.blue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,12 +610,12 @@ namespace detail
|
||||
vmax[x] = std::max(x - radius, 0);
|
||||
}
|
||||
|
||||
nana::pixel_rgb_t p1 = linepix[vmin[x]];
|
||||
nana::pixel_rgb_t p2 = linepix[vmax[x]];
|
||||
auto p1 = linepix[vmin[x]];
|
||||
auto p2 = linepix[vmax[x]];
|
||||
|
||||
sum_r += p1.u.element.red - p2.u.element.red;
|
||||
sum_g += p1.u.element.green - p2.u.element.green;
|
||||
sum_b += p1.u.element.blue - p2.u.element.blue;
|
||||
sum_r += p1.element.red - p2.element.red;
|
||||
sum_g += p1.element.green - p2.element.green;
|
||||
sum_b += p1.element.blue - p2.element.blue;
|
||||
++yi;
|
||||
}
|
||||
linepix = pixbuf.raw_ptr(area.y + y) + area.x;
|
||||
@@ -649,7 +651,7 @@ namespace detail
|
||||
|
||||
for(int y = 0; y < h; ++y)
|
||||
{
|
||||
linepix->u.color = 0xFF000000 | (dv[sum_r] << 16) | (dv[sum_g] << 8) | dv[sum_b];
|
||||
linepix->value = 0xFF000000 | (dv[sum_r] << 16) | (dv[sum_g] << 8) | dv[sum_b];
|
||||
if(x == 0)
|
||||
{
|
||||
vmin[y] = std::min(y + radius + 1, hm) * w;
|
||||
|
||||
@@ -21,20 +21,20 @@ namespace detail
|
||||
{
|
||||
nana::size drawable_size(drawable_type);
|
||||
|
||||
unsigned char * alloc_fade_table(double fade_rate);
|
||||
std::unique_ptr<unsigned char[]> alloc_fade_table(double fade_rate);
|
||||
void free_fade_table(const unsigned char*);
|
||||
|
||||
//color = bgcolor * fade_rate + fgcolor * (1 - fade_rate);
|
||||
nana::pixel_rgb_t fade_color(nana::pixel_rgb_t bgcolor, nana::pixel_rgb_t fgcolor, double fade_rate);
|
||||
nana::pixel_rgb_t fade_color(nana::pixel_rgb_t bgcolor, nana::pixel_rgb_t fgcolor, const unsigned char* const fade_table);
|
||||
nana::pixel_rgb_t fade_color_intermedia(nana::pixel_rgb_t fgcolor, const unsigned char* fade_table);
|
||||
nana::pixel_rgb_t fade_color_by_intermedia(nana::pixel_rgb_t bgcolor, nana::pixel_rgb_t fgcolor_intermedia, const unsigned char* const fade_table);
|
||||
//nana::pixel_color_t fade_color(nana::pixel_color_t bgcolor, nana::pixel_color_t fgcolor, double fade_rate); //deprecated
|
||||
nana::pixel_color_t fade_color(nana::pixel_color_t bgcolor, nana::pixel_color_t fgcolor, const unsigned char* const fade_table);
|
||||
nana::pixel_color_t fade_color_intermedia(pixel_color_t fgcolor, const unsigned char* fade_table);
|
||||
nana::pixel_color_t fade_color_by_intermedia(pixel_color_t bgcolor, nana::pixel_color_t fgcolor_intermedia, const unsigned char* const fade_table);
|
||||
|
||||
void blend(drawable_type dw, const nana::rectangle& r, nana::color_t, double fade_rate);
|
||||
void blend(drawable_type dw, const nana::rectangle& r, pixel_color_t, double fade_rate);
|
||||
|
||||
nana::size raw_text_extent_size(drawable_type, const nana::char_t*, std::size_t len);
|
||||
nana::size text_extent_size(drawable_type, const nana::char_t*, std::size_t len);
|
||||
void draw_string(drawable_type, int x, int y, const nana::char_t *, std::size_t len);
|
||||
void draw_string(drawable_type, const nana::point&, const nana::char_t *, std::size_t len);
|
||||
}//end namespace detail
|
||||
}//end namespace paint
|
||||
}//end namespace nana
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Graphics Gadget Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -21,14 +22,8 @@ namespace paint
|
||||
{
|
||||
namespace gadget
|
||||
{
|
||||
struct directions
|
||||
{
|
||||
enum t{to_east, to_southeast, to_south, to_southwest, to_west, to_northwest, to_north, to_northeast};
|
||||
};
|
||||
|
||||
void arrow_16_pixels(nana::paint::graphics&, int x, int y, unsigned color, uint32_t style, directions::t direction);
|
||||
void close_16_pixels(nana::paint::graphics&, int x, int y, uint32_t style, uint32_t color);
|
||||
void cross(nana::paint::graphics&, int x, int y, uint32_t size, uint32_t thickness, nana::color_t color);
|
||||
void close_16_pixels(::nana::paint::graphics&, int x, int y, unsigned style, const color&);
|
||||
void cross(::nana::paint::graphics&, int x, int y, unsigned size, unsigned thickness, const nana::color&);
|
||||
|
||||
}//end namespace gadget
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Paint Graphics Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -73,7 +74,6 @@ namespace nana
|
||||
typedef ::nana::native_window_type native_window_type;
|
||||
|
||||
graphics();
|
||||
graphics(unsigned width, unsigned height); ///< size in pixel
|
||||
graphics(const ::nana::size&); ///< size in pixel
|
||||
graphics(const graphics&); ///< the resource is not copyed, the two graphics objects refer to the *SAME* resource
|
||||
graphics& operator=(const graphics&);
|
||||
@@ -84,9 +84,10 @@ namespace nana
|
||||
drawable_type handle() const;
|
||||
const void* pixmap() const;
|
||||
const void* context() const;
|
||||
void make(unsigned width, unsigned height); ///< Creates a bitmap resource that size is width by height in pixel
|
||||
void resize(unsigned width, unsigned height);
|
||||
void typeface(const font&); ///< Selects a specified font type into the graphics object.
|
||||
|
||||
void make(const ::nana::size&); ///< Creates a bitmap resource that size is width by height in pixel
|
||||
void resize(const ::nana::size&);
|
||||
void typeface(const font&); ///< Selects a specified font type into the graphics object.
|
||||
font typeface() const;
|
||||
::nana::size text_extent_size(const char_t*) const; ///< Computes the width and height of the specified string of text.
|
||||
::nana::size text_extent_size(const string&) const; ///< Computes the width and height of the specified string of text.
|
||||
@@ -99,27 +100,7 @@ namespace nana
|
||||
|
||||
bool text_metrics(unsigned & ascent, unsigned& descent, unsigned& internal_leading) const;
|
||||
|
||||
unsigned bidi_string(int x, int y, color_t, const char_t *, std::size_t len);
|
||||
void string(int x, int y, color_t, const ::nana::string&, std::size_t len);
|
||||
void string(int x, int y, color_t, const ::nana::string&);
|
||||
void string(int x, int y, color_t, const char_t*, std::size_t len);
|
||||
void string(int x, int y, color_t, const char_t*);
|
||||
|
||||
void set_pixel(int x, int y, color_t);
|
||||
void rectangle(int x, int y, unsigned width, unsigned height, color_t, bool solid);
|
||||
void rectangle(color_t, bool solid);
|
||||
void rectangle(const ::nana::rectangle&, color_t, bool solid);
|
||||
void rectangle_line(const ::nana::rectangle&, color_t left, color_t top, color_t right, color_t bottom);
|
||||
void round_rectangle(int x, int y, unsigned width, unsigned height, unsigned radius_x, unsigned radius_y, color_t, bool solid, color_t color_if_solid);
|
||||
void round_rectangle(const ::nana::rectangle&, unsigned radius_x, unsigned radius_y, color_t, bool solid, color_t color_if_solid);
|
||||
void shadow_rectangle(const ::nana::rectangle&, color_t beg_color, color_t end_color, bool vertical);
|
||||
void shadow_rectangle(int x, int y, unsigned width, unsigned height, color_t beg_color, color_t end_color, bool vertical); ///< Draws a width and height rectangle at (x, y) and the color in range of [begin, end]
|
||||
|
||||
void line(int x1, int y1, int x2, int y2, color_t); ///< Draws a line from point (x1, y1) to point (x2, y2) in the specified color.
|
||||
void line(const point& beg, const point& end, color_t);
|
||||
void lines(const point* points, std::size_t n_of_points, color_t);
|
||||
void line_begin(int x, int y);
|
||||
void line_to(int x, int y, color_t);
|
||||
|
||||
void bitblt(int x, int y, const graphics& source); ///< Transfers the source to the specified point.
|
||||
void bitblt(const ::nana::rectangle& r_dst, native_window_type src); ///< Transfers the color data corresponding to r_dst from the src window to this graphics.
|
||||
@@ -128,7 +109,6 @@ namespace nana
|
||||
void bitblt(const ::nana::rectangle& r_dst, const graphics& src, const point& p_src);///< Transfers the color data corresponding to r_dst from the src graphics at point p_src to this graphics.
|
||||
|
||||
void blend(const ::nana::rectangle& s_r, graphics& dst, const point& d_pos, double fade_rate) const;///< blends with the dst object.
|
||||
void blend(const ::nana::rectangle& r, color_t, double fade_rate); ///< blends the specifed block width the specified color.
|
||||
|
||||
void blur(const ::nana::rectangle& r, std::size_t radius); ///< Blur process.
|
||||
|
||||
@@ -140,7 +120,7 @@ namespace nana
|
||||
void rgb_to_wb(); ///< Transform a color graphics into black&white.
|
||||
|
||||
void stretch(const ::nana::rectangle& src_r, graphics& dst, const ::nana::rectangle& r) const;
|
||||
void stretch(graphics& dst, const ::nana::rectangle& r) const;
|
||||
void stretch(graphics& dst, const ::nana::rectangle&) const;
|
||||
|
||||
void flush();
|
||||
|
||||
@@ -151,7 +131,34 @@ namespace nana
|
||||
void release();
|
||||
void save_as_file(const char*);
|
||||
|
||||
static color_t mix(color_t colorX, color_t colorY, double persent);
|
||||
void set_color(const ::nana::color&);
|
||||
void set_text_color(const ::nana::color&);
|
||||
|
||||
unsigned bidi_string(const nana::point&, const char_t *, std::size_t len);
|
||||
|
||||
void blend(const ::nana::rectangle& r, const ::nana::color&, double fade_rate);
|
||||
|
||||
void set_pixel(int x, int y, const ::nana::color&);
|
||||
void set_pixel(int x, int y);
|
||||
|
||||
void string(point, const char_t*, std::size_t len);
|
||||
void string(const point&, const char_t*);
|
||||
void string(const point&, const ::nana::string&);
|
||||
void string(const point&, const ::nana::string&, const color&);
|
||||
|
||||
void line(const point&, const point&);
|
||||
void line(const point&, const point&, const color&);
|
||||
void line_to(const point&, const color&);
|
||||
void line_to(const point&);
|
||||
|
||||
void rectangle(bool solid);
|
||||
void rectangle(bool solid, const color&);
|
||||
void rectangle(const ::nana::rectangle&, bool solid);
|
||||
void rectangle(const ::nana::rectangle&, bool solid, const color&);
|
||||
void frame_rectangle(const ::nana::rectangle&, const color& left, const color& top, const color& right, const color& bottom);
|
||||
|
||||
void gradual_rectangle(const ::nana::rectangle&, const color& from, const color& to, bool vertical);
|
||||
void round_rectangle(const ::nana::rectangle&, unsigned radius_x, unsigned radius_y, const color&, bool solid, const color& color_if_solid);
|
||||
private:
|
||||
std::shared_ptr< ::nana::detail::drawable_impl_type> dwptr_;
|
||||
font font_shadow_;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace nana
|
||||
class stretch_interface
|
||||
{
|
||||
public:
|
||||
virtual ~stretch_interface() = 0;
|
||||
virtual ~stretch_interface() = default;
|
||||
/// Copies the image from a source rectangle into a destination rectangle, stretching or compressing the image to fit the dimensions of the destination rectangle in destination(d_pixbuf).
|
||||
virtual void process(const paint::pixel_buffer & s_pixbuf,
|
||||
const nana::rectangle& source_rectangle,
|
||||
@@ -36,14 +36,14 @@ namespace nana
|
||||
class alpha_blend_interface
|
||||
{
|
||||
public:
|
||||
virtual ~alpha_blend_interface() = 0;
|
||||
virtual ~alpha_blend_interface() = default;
|
||||
virtual void process(const paint::pixel_buffer& s_pixbuf, const nana::rectangle& s_r, paint::pixel_buffer& d_pixbuf, const point& d_pos) const = 0;
|
||||
};
|
||||
/// The interface of a blend algorithm.
|
||||
class blend_interface
|
||||
{
|
||||
public:
|
||||
virtual ~blend_interface() = 0;
|
||||
virtual ~blend_interface() = default;
|
||||
/// \brief Blends two images with specified area and blend rate.
|
||||
///
|
||||
/// Semantics: \code dest_pixbuf = dest_pixbuf * fade_rate + scr_pixbuf * (1 - fade_rate); \endcode
|
||||
@@ -59,16 +59,16 @@ namespace nana
|
||||
class line_interface
|
||||
{
|
||||
public:
|
||||
virtual ~line_interface() = 0;
|
||||
virtual ~line_interface() = default;
|
||||
|
||||
/// \brief Draws a line
|
||||
///
|
||||
/// Semantics: \code pixbuf = pixbuf * (1 - fade_rate) + color * fade_rate \endcode
|
||||
/// The two points are calculated by Nana, they are always valid, and pos_beg.x <= pos_end.x
|
||||
virtual void process(paint::pixel_buffer & pixbuf,
|
||||
const nana::point& pos_beg, ///< left point
|
||||
const nana::point& pos_end, ///< right point
|
||||
nana::color_t color,
|
||||
const point& pos_beg, ///< left point
|
||||
const point& pos_end, ///< right point
|
||||
const ::nana::color&,
|
||||
double fade_rate ///< blend rate in the range of [0, 1] If not 0, the line is blended to the pixbuf
|
||||
) const = 0;
|
||||
};
|
||||
@@ -76,7 +76,7 @@ namespace nana
|
||||
class blur_interface
|
||||
{
|
||||
public:
|
||||
virtual ~blur_interface() = 0;
|
||||
virtual ~blur_interface() = default;
|
||||
virtual void process(paint::pixel_buffer&, const nana::rectangle& r, std::size_t radius) const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Pixel Buffer Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -19,14 +20,14 @@ namespace nana{ namespace paint
|
||||
{
|
||||
///@brief Seek a pixel address by using offset bytes
|
||||
///@return the specified pixel address
|
||||
inline pixel_rgb_t * pixel_at(pixel_rgb_t * p, std::size_t bytes)
|
||||
inline pixel_color_t * pixel_at(pixel_color_t * p, std::size_t bytes)
|
||||
{
|
||||
return reinterpret_cast<pixel_rgb_t*>(reinterpret_cast<char*>(p) + bytes);
|
||||
return reinterpret_cast<pixel_color_t*>(reinterpret_cast<char*>(p)+bytes);
|
||||
}
|
||||
|
||||
inline const pixel_rgb_t * pixel_at(const pixel_rgb_t * p, std::size_t bytes)
|
||||
inline const pixel_color_t * pixel_at(const pixel_color_t * p, std::size_t bytes)
|
||||
{
|
||||
return reinterpret_cast<const pixel_rgb_t*>(reinterpret_cast<const char*>(p) + bytes);
|
||||
return reinterpret_cast<const pixel_color_t*>(reinterpret_cast<const char*>(p)+bytes);
|
||||
}
|
||||
|
||||
class pixel_buffer
|
||||
@@ -34,7 +35,7 @@ namespace nana{ namespace paint
|
||||
struct pixel_buffer_storage;
|
||||
typedef bool (pixel_buffer:: * unspecified_bool_t)() const;
|
||||
public:
|
||||
pixel_buffer();
|
||||
pixel_buffer() = default;
|
||||
pixel_buffer(drawable_type, const nana::rectangle& want_rectangle);
|
||||
pixel_buffer(drawable_type, std::size_t top, std::size_t lines);
|
||||
pixel_buffer(std::size_t width, std::size_t height);
|
||||
@@ -60,20 +61,20 @@ namespace nana{ namespace paint
|
||||
std::size_t bytes_per_line() const;
|
||||
nana::size size() const;
|
||||
|
||||
pixel_rgb_t * at(const point& pos) const;
|
||||
pixel_rgb_t * raw_ptr(std::size_t row) const;
|
||||
pixel_rgb_t * operator[](std::size_t row) const;
|
||||
pixel_color_t * at(const point& pos) const;
|
||||
pixel_color_t * raw_ptr(std::size_t row) const;
|
||||
pixel_color_t * operator[](std::size_t row) const;
|
||||
|
||||
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);
|
||||
|
||||
void line(const std::string& name);
|
||||
void line(const nana::point& pos_beg, const nana::point& pos_end, nana::color_t color, double fade_rate);
|
||||
void line(const ::nana::point& pos_beg, const ::nana::point& pos_end, const ::nana::color&, double fade_rate);
|
||||
|
||||
void rectangle(const nana::rectangle&, nana::color_t, double fade_rate, bool solid);
|
||||
void shadow_rectangle(const nana::rectangle&, nana::color_t beg, nana::color_t end, double fade_rate, bool vertical);
|
||||
void rectangle(const nana::rectangle&, const ::nana::color&, double fade_rate, bool solid);
|
||||
void gradual_rectangle(const ::nana::rectangle&, const ::nana::color& from, const ::nana::color& to, double fade_rate, bool vertical);
|
||||
|
||||
pixel_rgb_t pixel(int x, int y) const;
|
||||
void pixel(int x, int y, pixel_rgb_t);
|
||||
pixel_color_t pixel(int x, int y) const;
|
||||
void pixel(int x, int y, pixel_color_t);
|
||||
|
||||
void paste(drawable_type, int x, int y) const;
|
||||
void paste(const nana::rectangle& s_r, drawable_type, int x, int y) const;
|
||||
|
||||
@@ -13,11 +13,11 @@ namespace nana
|
||||
|
||||
text_renderer(graph_reference graph, align = align::left);
|
||||
|
||||
void render(int x, int y, nana::color_t, const nana::char_t*, std::size_t len);
|
||||
void render(int x, int y, nana::color_t, const nana::char_t*, std::size_t len, unsigned restricted_pixels, bool omitted);
|
||||
|
||||
void render(int x, int y, nana::color_t, const nana::char_t*, std::size_t len, unsigned restricted_pixels);
|
||||
nana::size extent_size(int x, int y, const nana::char_t*, std::size_t len, unsigned restricted_pixels) const;
|
||||
|
||||
void render(const point&, const char_t*, std::size_t len);
|
||||
void render(const point&, const char_t*, std::size_t len, unsigned restricted_pixels, bool omitted);
|
||||
void render(const point&, const char_t*, std::size_t len, unsigned restricted_pixels);
|
||||
private:
|
||||
graph_reference graph_;
|
||||
align text_align_;
|
||||
|
||||
@@ -1,18 +1,390 @@
|
||||
/*
|
||||
* Basic Types definition
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/basic_types.cpp
|
||||
*/
|
||||
|
||||
#include <nana/basic_types.hpp>
|
||||
#include <regex>
|
||||
#include <algorithm>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
//class color
|
||||
color::color(colors clr)
|
||||
: color((static_cast<unsigned>(clr)& 0xFF0000) >> 16, (static_cast<unsigned>(clr)& 0xFF00) >> 8, static_cast<unsigned>(clr)& 0xFF)
|
||||
{}
|
||||
|
||||
color::color(colors clr, double alpha)
|
||||
: color((static_cast<unsigned>(clr)& 0xFF0000) >> 16, (static_cast<unsigned>(clr)& 0xFF00) >> 8, static_cast<unsigned>(clr)& 0xFF, alpha)
|
||||
{}
|
||||
|
||||
color::color(color_rgb rgb)
|
||||
: r_((static_cast<int>(rgb) >> 16) & 0xFF),
|
||||
g_((static_cast<int>(rgb) >> 8) & 0xFF),
|
||||
b_(static_cast<int>(rgb) & 0xFF),
|
||||
a_(1.0)
|
||||
{}
|
||||
|
||||
color::color(color_argb argb)
|
||||
: r_((static_cast<int>(argb) >> 16) & 0xFF),
|
||||
g_((static_cast<int>(argb) >> 8) & 0xFF),
|
||||
b_(static_cast<int>(argb) & 0xFF),
|
||||
a_(((static_cast<int>(argb) >> 24) & 0xFF) / 255.0)
|
||||
{}
|
||||
|
||||
color::color(color_rgba rgba)
|
||||
: r_((static_cast<int>(rgba) >> 24) & 0xFF),
|
||||
g_((static_cast<int>(rgba) >> 16) & 0xFF),
|
||||
b_((static_cast<int>(rgba) >> 8) & 0xFF),
|
||||
a_((static_cast<int>(rgba) & 0xFF) / 255.0)
|
||||
{}
|
||||
|
||||
color::color(unsigned red, unsigned green, unsigned blue)
|
||||
: r_(red), g_(green), b_(blue), a_(1.0)
|
||||
{
|
||||
}
|
||||
|
||||
color::color(unsigned red, unsigned green, unsigned blue, double alpha)
|
||||
: r_(red), g_(green), b_(blue), a_(alpha)
|
||||
{
|
||||
if (alpha < 0.0)
|
||||
a_ = 0.0;
|
||||
else if (alpha > 1.0)
|
||||
a_ = 1.0;
|
||||
}
|
||||
|
||||
//Initializes the color with a CSS-like string
|
||||
//contributor: BigDave(mortis2007 at hotmail co uk)
|
||||
//date: February 3, 2015
|
||||
//maintainor: Jinhao, extended the support of CSS-spec
|
||||
color::color(std::string css_color)
|
||||
: a_(1.0)
|
||||
{
|
||||
const char * excpt_what = "color: invalid rgb format";
|
||||
|
||||
auto pos = css_color.find_first_not_of(' ');
|
||||
if (pos == css_color.npos)
|
||||
throw std::invalid_argument(excpt_what);
|
||||
|
||||
if ('#' == css_color[pos])
|
||||
{
|
||||
if (css_color.size() < pos + 4)
|
||||
throw std::invalid_argument(excpt_what);
|
||||
|
||||
auto endpos = css_color.find_first_not_of("0123456789abcdefABCDEF", pos + 1);
|
||||
if (endpos == css_color.npos)
|
||||
endpos = static_cast<decltype(endpos)>(css_color.size());
|
||||
|
||||
if ((endpos - pos != 4) && (endpos - pos != 7))
|
||||
throw std::invalid_argument(excpt_what);
|
||||
|
||||
auto n = ::nana::stoi(css_color.substr(pos + 1, endpos - pos - 1), nullptr, 16);
|
||||
|
||||
if (endpos - pos == 4)
|
||||
{
|
||||
r_ = ((0xF00 & n) >> 4) | ((0xF00 & n) >> 8);
|
||||
g_ = (0xF0 & n) | ((0xF0 & n) >> 4);
|
||||
b_ = (0xF & n) | ((0xF & n) << 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
r_ = (0xFF0000 & n) >> 16;
|
||||
g_ = (0xFF00 & n) >> 8;
|
||||
b_ = (0xFF & n);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//std::tolower is not allowed because of concept requirements
|
||||
std::transform(css_color.begin(), css_color.end(), css_color.begin(), [](char ch){
|
||||
if('A' <= ch && ch <= 'Z')
|
||||
return static_cast<char>(ch - ('A' - 'a'));
|
||||
return ch;
|
||||
});
|
||||
auto endpos = css_color.find(' ', pos + 1);
|
||||
if (endpos == css_color.npos)
|
||||
endpos = css_color.size();
|
||||
|
||||
if ((endpos - pos == 11) && (css_color.substr(pos, 11) == "transparent"))
|
||||
{
|
||||
r_ = 0;
|
||||
g_ = 0;
|
||||
b_ = 0;
|
||||
a_ = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
auto type_end = css_color.find_first_of(" (", pos + 1);
|
||||
|
||||
if (type_end == css_color.npos || ((type_end - pos != 3) && (type_end - pos != 4))) //rgb/hsl = 3, rgba/hsla = 4
|
||||
throw std::invalid_argument(excpt_what);
|
||||
|
||||
bool has_alpha = false;
|
||||
if (type_end - pos == 4) //maybe rgba/hsla
|
||||
{
|
||||
if (css_color[pos + 3] != 'a')
|
||||
throw std::invalid_argument(excpt_what);
|
||||
has_alpha = true;
|
||||
}
|
||||
|
||||
std::regex pat;
|
||||
std::regex_iterator<std::string::iterator> i, end;
|
||||
auto type_name = css_color.substr(pos, 3);
|
||||
if ("rgb" == type_name)
|
||||
{
|
||||
pat.assign("(\\d*\\.)?\\d+\\%?");
|
||||
i = std::regex_iterator<std::string::iterator>(css_color.begin() + pos, css_color.end(), pat);
|
||||
|
||||
if (i == end)
|
||||
throw std::invalid_argument(excpt_what);
|
||||
|
||||
std::vector<std::string> rgb;
|
||||
|
||||
rgb.emplace_back(i->str());
|
||||
|
||||
const bool is_real = (rgb.back().back() == '%');
|
||||
pat.assign(is_real ? "(\\d*\\.)?\\d+\\%" : "\\d+");
|
||||
|
||||
for (++i; i != end; ++i)
|
||||
{
|
||||
rgb.emplace_back(i->str());
|
||||
if (rgb.size() == 3)
|
||||
break;
|
||||
}
|
||||
|
||||
if (rgb.size() != 3)
|
||||
throw std::invalid_argument(excpt_what);
|
||||
|
||||
if (is_real)
|
||||
{
|
||||
auto pr = ::nana::stod(rgb[0].substr(0, rgb[0].size() - 1));
|
||||
r_ = (pr > 100 ? 255.0 : 2.55 * pr);
|
||||
|
||||
pr = ::nana::stod(rgb[1].substr(0, rgb[1].size() - 1));
|
||||
g_ = (pr > 100 ? 255.0 : 2.55 * pr);
|
||||
|
||||
pr = ::nana::stod(rgb[2].substr(0, rgb[2].size() - 1));
|
||||
b_ = (pr > 100 ? 255.0 : 2.55 * pr);
|
||||
}
|
||||
else
|
||||
{
|
||||
r_ = ::nana::stod(rgb[0]);
|
||||
if (r_ > 255.0) r_ = 255;
|
||||
|
||||
g_ = ::nana::stod(rgb[1]);
|
||||
if (g_ > 255.0) g_ = 255;
|
||||
|
||||
b_ = ::nana::stod(rgb[2]);
|
||||
if (b_ > 255.0) b_ = 255;
|
||||
}
|
||||
}
|
||||
else if ("hsl" == type_name)
|
||||
{
|
||||
pat.assign("(\\d*\\.)?\\d+");
|
||||
i = std::regex_iterator<std::string::iterator>(css_color.begin() + pos, css_color.end(), pat);
|
||||
|
||||
if (i == end)
|
||||
throw std::invalid_argument(excpt_what);
|
||||
|
||||
auto h = ::nana::stod(i->str());
|
||||
|
||||
pat.assign("(\\d*\\.)?\\d+\\%");
|
||||
|
||||
if (++i == end)
|
||||
throw std::invalid_argument(excpt_what);
|
||||
|
||||
auto str = i->str();
|
||||
auto s = ::nana::stod(str.substr(0, str.size() - 1));
|
||||
|
||||
if (++i == end)
|
||||
throw std::invalid_argument(excpt_what);
|
||||
|
||||
str = i->str();
|
||||
auto l = ::nana::stod(str.substr(0, str.size() - 1));
|
||||
|
||||
from_hsl(h, s / 100, l / 100);
|
||||
}
|
||||
else
|
||||
throw std::invalid_argument(excpt_what); //invalid color type
|
||||
|
||||
if (has_alpha)
|
||||
{
|
||||
pat.assign("(\\d*\\.)?\\d+");
|
||||
if (++i == end)
|
||||
throw std::invalid_argument(excpt_what); //invalid alpha value
|
||||
a_ = ::nana::stod(i->str());
|
||||
}
|
||||
}
|
||||
|
||||
color& color::from_rgb(unsigned red, unsigned green, unsigned blue)
|
||||
{
|
||||
r_ = red;
|
||||
g_ = green;
|
||||
b_ = blue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
double rgb_from_hue(double v1, double v2, double h)
|
||||
{
|
||||
if (h < 0.0)
|
||||
h += 1.0;
|
||||
else if (h > 1.0)
|
||||
h -= 1.0;
|
||||
|
||||
if (h < 0.1666666) return v1 + (v2 - v1) * (6.0 * h);
|
||||
if (h < 0.5) return v2;
|
||||
if (h < 0.6666666) return v1 + (v2 - v1) * (4.0 - h * 6.0);
|
||||
return v1;
|
||||
}
|
||||
|
||||
color& color::from_hsl(double hue, double saturation, double lightness)
|
||||
{
|
||||
if (0.0 == saturation)
|
||||
{
|
||||
r_ = lightness * 255.0;
|
||||
g_ = r_;
|
||||
b_ = r_;
|
||||
}
|
||||
else
|
||||
{
|
||||
double var2;
|
||||
if (lightness < 0.5)
|
||||
var2 = lightness * (1.0 + saturation);
|
||||
else
|
||||
var2 = (lightness + saturation) - (saturation * lightness);
|
||||
|
||||
double var1 = 2.0 * lightness - var2;
|
||||
|
||||
hue /= 360;
|
||||
r_ = 255.0 * rgb_from_hue(var1, var2, hue + 0.33333);
|
||||
g_ = 255.0 * rgb_from_hue(var1, var2, hue);
|
||||
b_ = 255.0 * rgb_from_hue(var1, var2, hue - 0.33333);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
color& color::alpha(double al)
|
||||
{
|
||||
if (al < 0.0)
|
||||
a_ = 0.0;
|
||||
else if (al > 1.0)
|
||||
a_ = 1.0;
|
||||
else
|
||||
a_ = al;
|
||||
return *this;
|
||||
}
|
||||
|
||||
color color::blend(const color& bgcolor, bool ignore_bgcolor_alpha) const
|
||||
{
|
||||
if (a_ < 1.0)
|
||||
{
|
||||
color result;
|
||||
if (0.0 < a_)
|
||||
{
|
||||
if (ignore_bgcolor_alpha || (1.0 == bgcolor.b_))
|
||||
{
|
||||
result.r_ = r_ * a_ + bgcolor.r_ * (1.0 - a_);
|
||||
result.g_ = g_ * a_ + bgcolor.g_ * (1.0 - a_);
|
||||
result.b_ = b_ * a_ + bgcolor.b_ * (1.0 - a_);
|
||||
result.a_ = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.r_ = r_ * a_ + bgcolor.r_ * bgcolor.a_ * (1.0 - a_);
|
||||
result.g_ = g_ * a_ + bgcolor.g_ * bgcolor.a_ * (1.0 - a_);
|
||||
result.b_ = b_ * a_ + bgcolor.b_ * bgcolor.a_ * (1.0 - a_);
|
||||
result.a_ = a_ + (bgcolor.a_ * (1.0 - a_));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.r_ = bgcolor.r_;
|
||||
result.g_ = bgcolor.g_;
|
||||
result.b_ = bgcolor.b_;
|
||||
result.a_ = (ignore_bgcolor_alpha ? 1.0 : bgcolor.a_);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
color color::blend(const color& bgcolor, double alpha) const
|
||||
{
|
||||
color result;
|
||||
result.r_ = r_ * alpha + bgcolor.r_ * (1.0 - alpha);
|
||||
result.g_ = g_ * alpha + bgcolor.g_ * (1.0 - alpha);
|
||||
result.b_ = b_ * alpha + bgcolor.b_ * (1.0 - alpha);
|
||||
result.a_ = 1.0;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool color::invisible() const
|
||||
{
|
||||
return (a_ == 0.0);
|
||||
}
|
||||
|
||||
pixel_color_t color::px_color() const
|
||||
{
|
||||
return argb();
|
||||
}
|
||||
|
||||
pixel_argb_t color::argb() const
|
||||
{
|
||||
pixel_argb_t argb;
|
||||
argb.element.red = static_cast<unsigned>(r_);
|
||||
argb.element.green = static_cast<unsigned>(g_);
|
||||
argb.element.blue = static_cast<unsigned>(b_);
|
||||
argb.element.alpha_channel = static_cast<unsigned>(a_ * 255);
|
||||
return argb;
|
||||
}
|
||||
|
||||
pixel_rgba_t color::rgba() const
|
||||
{
|
||||
pixel_rgba_t rgba;
|
||||
rgba.element.red = static_cast<unsigned>(r_);
|
||||
rgba.element.green = static_cast<unsigned>(g_);
|
||||
rgba.element.blue = static_cast<unsigned>(b_);
|
||||
rgba.element.alpha_channel = static_cast<unsigned>(a_ * 255);
|
||||
return rgba;
|
||||
}
|
||||
|
||||
const double& color::r() const
|
||||
{
|
||||
return r_;
|
||||
}
|
||||
const double& color::g() const
|
||||
{
|
||||
return g_;
|
||||
}
|
||||
const double& color::b() const
|
||||
{
|
||||
return b_;
|
||||
}
|
||||
|
||||
const double& color::a() const
|
||||
{
|
||||
return a_;
|
||||
}
|
||||
|
||||
bool color::operator==(const color& other) const
|
||||
{
|
||||
return (px_color().value == other.px_color().value);
|
||||
}
|
||||
bool color::operator!=(const color& other) const
|
||||
{
|
||||
return (px_color().value != other.px_color().value);
|
||||
}
|
||||
|
||||
//end class color
|
||||
//struct point
|
||||
point::point():x(0), y(0){}
|
||||
point::point(int x, int y):x(x), y(y){}
|
||||
@@ -119,7 +491,7 @@ namespace nana
|
||||
|
||||
//struct size
|
||||
size::size():width(0), height(0){}
|
||||
size::size(unsigned width, unsigned height):width(width), height(height){}
|
||||
size::size(value_type width, value_type height) : width(width), height(height){}
|
||||
size::size(const rectangle& r)
|
||||
: width(r.width), height(r.height)
|
||||
{}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/*
|
||||
* The Deploy Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/depoly.cpp
|
||||
@@ -12,7 +13,8 @@
|
||||
*/
|
||||
|
||||
#include <nana/deploy.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
#if defined(NANA_WINDOWS)
|
||||
#include <windows.h>
|
||||
#elif defined(NANA_LINUX)
|
||||
@@ -46,7 +48,89 @@ namespace nana
|
||||
return ::wcscpy(dest, source);
|
||||
#else
|
||||
return ::strcpy(dest, source);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
int stoi(const std::string& str, std::size_t * pos, int base)
|
||||
{
|
||||
#if defined(NANA_MINGW)
|
||||
auto sptr = str.c_str();
|
||||
char *end;
|
||||
errno = 0;
|
||||
auto result = std::strtol(sptr, &end, base);
|
||||
|
||||
if (sptr == end)
|
||||
throw std::invalid_argument("invalid stoi argument");
|
||||
if (errno == ERANGE)
|
||||
throw std::out_of_range("stoi argument out of range");
|
||||
|
||||
if (pos)
|
||||
*pos = (std::size_t)(end - sptr);
|
||||
return ((int)result);
|
||||
#else
|
||||
return std::stoi(str, pos, base);
|
||||
#endif
|
||||
}
|
||||
|
||||
int stoi(const std::wstring& str, std::size_t* pos, int base)
|
||||
{
|
||||
#if defined(NANA_MINGW)
|
||||
auto sptr = str.data();
|
||||
wchar_t *end;
|
||||
errno = 0;
|
||||
auto result = std::wcstol(sptr, &end, base);
|
||||
|
||||
if (sptr == end)
|
||||
throw std::invalid_argument("invalid stoi argument");
|
||||
if (errno == ERANGE)
|
||||
throw std::out_of_range("stoi argument out of range");
|
||||
|
||||
if (pos)
|
||||
*pos = (std::size_t)(end - sptr);
|
||||
return ((int)result);
|
||||
#else
|
||||
return std::stoi(str, pos, base);
|
||||
#endif
|
||||
}
|
||||
|
||||
double stod(const std::string& str, std::size_t * pos)
|
||||
{
|
||||
#ifdef NANA_MINGW
|
||||
auto *ptr = str.data();
|
||||
errno = 0;
|
||||
char *end;
|
||||
auto result = std::strtod(ptr, &end);
|
||||
|
||||
if (ptr == end)
|
||||
throw std::invalid_argument("invalid stod argument");
|
||||
if (errno == ERANGE)
|
||||
throw std::out_of_range("stod argument out of range");
|
||||
if (pos)
|
||||
*pos = (std::size_t)(end - ptr);
|
||||
return result;
|
||||
#else
|
||||
return std::stod(str, pos);
|
||||
#endif
|
||||
}
|
||||
|
||||
double stod(const std::wstring& str, std::size_t* pos)
|
||||
{
|
||||
#ifdef NANA_MINGW
|
||||
auto *ptr = str.data();
|
||||
errno = 0;
|
||||
wchar_t *end;
|
||||
auto result = std::wcstod(ptr, &end);
|
||||
|
||||
if (ptr == end)
|
||||
throw std::invalid_argument("invalid stod argument");
|
||||
if (errno == ERANGE)
|
||||
throw std::out_of_range("stod argument out of range");
|
||||
if (pos)
|
||||
*pos = (std::size_t)(end - ptr);
|
||||
return result;
|
||||
#else
|
||||
return std::stod(str, pos);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool is_incomplete(const nana::string& str, unsigned pos)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include <nana/paint/graphics.hpp>
|
||||
#include GUI_BEDROCK_HPP
|
||||
#include <nana/gui/detail/bedrock.hpp>
|
||||
#include <nana/gui/detail/basic_window.hpp>
|
||||
#include <nana/system/platform.hpp>
|
||||
#include <errno.h>
|
||||
@@ -301,31 +301,95 @@ namespace detail
|
||||
#endif
|
||||
}
|
||||
|
||||
void drawable_impl_type::fgcolor(unsigned color)
|
||||
void drawable_impl_type::set_color(const ::nana::color& clr)
|
||||
{
|
||||
if(color == fgcolor_)
|
||||
return;
|
||||
color_ = clr.px_color().value;
|
||||
}
|
||||
|
||||
auto & spec = nana::detail::platform_spec::instance();
|
||||
platform_scope_guard psg;
|
||||
void drawable_impl_type::set_text_color(const ::nana::color& clr)
|
||||
{
|
||||
text_color_ = clr.px_color().value;
|
||||
update_text_color();
|
||||
}
|
||||
|
||||
fgcolor_ = color;
|
||||
switch(spec.screen_depth())
|
||||
void drawable_impl_type::update_color()
|
||||
{
|
||||
if (color_ != current_color_)
|
||||
{
|
||||
case 16:
|
||||
color = ((((color >> 16) & 0xFF) * 31 / 255) << 11) |
|
||||
((((color >> 8) & 0xFF) * 63 / 255) << 5) |
|
||||
(color & 0xFF) * 31 / 255;
|
||||
break;
|
||||
auto & spec = nana::detail::platform_spec::instance();
|
||||
platform_scope_guard lock;
|
||||
|
||||
current_color_ = color_;
|
||||
auto col = color_;
|
||||
switch (spec.screen_depth())
|
||||
{
|
||||
case 16:
|
||||
col = ((((col >> 16) & 0xFF) * 31 / 255) << 11) |
|
||||
((((col >> 8) & 0xFF) * 63 / 255) << 5) |
|
||||
(col & 0xFF) * 31 / 255;
|
||||
break;
|
||||
}
|
||||
::XSetForeground(spec.open_display(), context, col);
|
||||
::XSetBackground(spec.open_display(), context, col);
|
||||
}
|
||||
::XSetForeground(spec.open_display(), context, color);
|
||||
::XSetBackground(spec.open_display(), context, color);
|
||||
}
|
||||
|
||||
void drawable_impl_type::update_text_color()
|
||||
{
|
||||
if (text_color_ != current_color_)
|
||||
{
|
||||
auto & spec = nana::detail::platform_spec::instance();
|
||||
platform_scope_guard lock;
|
||||
|
||||
current_color_ = text_color_;
|
||||
auto col = text_color_;
|
||||
switch (spec.screen_depth())
|
||||
{
|
||||
case 16:
|
||||
col = ((((col >> 16) & 0xFF) * 31 / 255) << 11) |
|
||||
((((col >> 8) & 0xFF) * 63 / 255) << 5) |
|
||||
(col & 0xFF) * 31 / 255;
|
||||
break;
|
||||
}
|
||||
::XSetForeground(spec.open_display(), context, col);
|
||||
::XSetBackground(spec.open_display(), context, col);
|
||||
|
||||
#if defined(NANA_UNICODE)
|
||||
xft_fgcolor.color.red = ((0xFF0000 & color) >> 16) * 0x101;
|
||||
xft_fgcolor.color.green = ((0xFF00 & color) >> 8) * 0x101;
|
||||
xft_fgcolor.color.blue = (0xFF & color) * 0x101;
|
||||
xft_fgcolor.color.alpha = 0xFFFF;
|
||||
xft_fgcolor.color.red = ((0xFF0000 & col) >> 16) * 0x101;
|
||||
xft_fgcolor.color.green = ((0xFF00 & col) >> 8) * 0x101;
|
||||
xft_fgcolor.color.blue = (0xFF & col) * 0x101;
|
||||
xft_fgcolor.color.alpha = 0xFFFF;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void drawable_impl_type::fgcolor(const ::nana::color& clr)
|
||||
{
|
||||
auto rgb = clr.px_color().value;
|
||||
|
||||
if (rgb != current_color_)
|
||||
{
|
||||
auto & spec = nana::detail::platform_spec::instance();
|
||||
platform_scope_guard psg;
|
||||
|
||||
current_color_ = rgb;
|
||||
switch(spec.screen_depth())
|
||||
{
|
||||
case 16:
|
||||
rgb = ((((rgb >> 16) & 0xFF) * 31 / 255) << 11) |
|
||||
((((rgb >> 8) & 0xFF) * 63 / 255) << 5) |
|
||||
(rgb & 0xFF) * 31 / 255;
|
||||
break;
|
||||
}
|
||||
::XSetForeground(spec.open_display(), context, rgb);
|
||||
::XSetBackground(spec.open_display(), context, rgb);
|
||||
#if defined(NANA_UNICODE)
|
||||
xft_fgcolor.color.red = ((0xFF0000 & rgb) >> 16) * 0x101;
|
||||
xft_fgcolor.color.green = ((0xFF00 & rgb) >> 8) * 0x101;
|
||||
xft_fgcolor.color.blue = (0xFF & rgb) * 0x101;
|
||||
xft_fgcolor.color.alpha = 0xFFFF;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
class font_deleter
|
||||
@@ -652,7 +716,7 @@ namespace detail
|
||||
return 0;
|
||||
}
|
||||
|
||||
void platform_spec::caret_open(native_window_type wd, unsigned width, unsigned height)
|
||||
void platform_spec::caret_open(native_window_type wd, const ::nana::size& caret_sz)
|
||||
{
|
||||
bool is_start_routine = false;
|
||||
platform_scope_guard psg;
|
||||
@@ -731,12 +795,11 @@ namespace detail
|
||||
}
|
||||
|
||||
addr->visible = false;
|
||||
addr->graph.make(width, height);
|
||||
addr->graph.rectangle(0x0, true);
|
||||
addr->rev_graph.make(width, height);
|
||||
addr->graph.make(caret_sz);
|
||||
addr->graph.rectangle(true, colors::black);
|
||||
addr->rev_graph.make(caret_sz);
|
||||
|
||||
addr->size.width = width;
|
||||
addr->size.height = height;
|
||||
addr->size = caret_sz;
|
||||
|
||||
if(addr->input_context && (false == addr->has_input_method_focus))
|
||||
{
|
||||
@@ -809,7 +872,7 @@ namespace detail
|
||||
}
|
||||
}
|
||||
|
||||
void platform_spec::caret_pos(native_window_type wd, int x, int y)
|
||||
void platform_spec::caret_pos(native_window_type wd, const point& pos)
|
||||
{
|
||||
platform_scope_guard psg;
|
||||
auto i = caret_holder_.carets.find(wd);
|
||||
@@ -817,8 +880,7 @@ namespace detail
|
||||
{
|
||||
caret_tag & crt = *i->second;
|
||||
caret_reinstate(crt);
|
||||
crt.pos.x = x;
|
||||
crt.pos.y = y;
|
||||
crt.pos = pos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1066,7 +1128,7 @@ namespace detail
|
||||
const nana::paint::graphics& platform_spec::keep_window_icon(native_window_type wd, const nana::paint::image& img)
|
||||
{
|
||||
nana::paint::graphics & graph = iconbase_[wd];
|
||||
graph.make(img.size().width, img.size().height);
|
||||
graph.make(img.size());
|
||||
img.paste(graph, 0, 0);
|
||||
return graph;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Platform Specification Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -21,17 +22,15 @@ namespace nana
|
||||
namespace detail
|
||||
{
|
||||
drawable_impl_type::drawable_impl_type()
|
||||
: pixbuf_ptr(nullptr), bytes_per_line(0),
|
||||
fgcolor_(0xFFFFFFFF)
|
||||
{
|
||||
pen.handle = nullptr;
|
||||
pen.color = nana::null_color;
|
||||
pen.color = 0xffffffff;
|
||||
pen.style = -1;
|
||||
pen.width = -1;
|
||||
|
||||
brush.handle = nullptr;
|
||||
brush.style = brush_spec::Solid;
|
||||
brush.color = nana::null_color;
|
||||
brush.color = 0xffffffff;
|
||||
|
||||
round_region.handle = nullptr;
|
||||
round_region.radius_x = round_region.radius_y = 0;
|
||||
@@ -50,37 +49,69 @@ namespace detail
|
||||
::DeleteObject(round_region.handle);
|
||||
}
|
||||
|
||||
void drawable_impl_type::fgcolor(nana::color_t col)
|
||||
void drawable_impl_type::fgcolor(const ::nana::color& clr)
|
||||
{
|
||||
if(this->fgcolor_ != col)
|
||||
set_text_color(clr);
|
||||
}
|
||||
|
||||
unsigned drawable_impl_type::get_color() const
|
||||
{
|
||||
return color_;
|
||||
}
|
||||
|
||||
void drawable_impl_type::set_color(const ::nana::color& clr)
|
||||
{
|
||||
color_ = clr.px_color().value;
|
||||
}
|
||||
|
||||
void drawable_impl_type::set_text_color(const ::nana::color& clr)
|
||||
{
|
||||
auto rgb = clr.px_color().value;
|
||||
if (text_color_ != rgb)
|
||||
{
|
||||
::SetTextColor(context, NANA_RGB(col));
|
||||
fgcolor_ = col;
|
||||
::SetTextColor(context, NANA_RGB(rgb));
|
||||
text_color_ = rgb;
|
||||
}
|
||||
}
|
||||
|
||||
void drawable_impl_type::pen_spec::set(HDC context, int style, int width, nana::color_t color)
|
||||
void drawable_impl_type::update_pen()
|
||||
{
|
||||
if(this->color != color || this->width != width || this->style != style)
|
||||
if (pen.color != color_)
|
||||
{
|
||||
this->color = color;
|
||||
pen.handle = ::CreatePen(PS_SOLID, 1, NANA_RGB(color_));
|
||||
::DeleteObject(::SelectObject(context, pen.handle));
|
||||
pen.color = color_;
|
||||
}
|
||||
}
|
||||
|
||||
void drawable_impl_type::update_brush()
|
||||
{
|
||||
if (brush.color != color_)
|
||||
brush.set(context, brush.style, color_);
|
||||
}
|
||||
|
||||
void drawable_impl_type::pen_spec::set(HDC context, int style, int width, unsigned clr)
|
||||
{
|
||||
if (this->color != clr || this->width != width || this->style != style)
|
||||
{
|
||||
this->color = clr;
|
||||
this->width = width;
|
||||
this->style = style;
|
||||
this->handle = ::CreatePen(style, width, NANA_RGB(color));
|
||||
this->handle = ::CreatePen(style, width, NANA_RGB(clr));
|
||||
::DeleteObject(::SelectObject(context, this->handle));
|
||||
}
|
||||
}
|
||||
|
||||
void drawable_impl_type::brush_spec::set(HDC context, drawable_impl_type::brush_spec::t style, nana::color_t color)
|
||||
void drawable_impl_type::brush_spec::set(HDC context, drawable_impl_type::brush_spec::t style, unsigned rgb)
|
||||
{
|
||||
if(this->color != color || this->style != style)
|
||||
if (this->color != rgb || this->style != style)
|
||||
{
|
||||
this->color = color;
|
||||
this->color = rgb;
|
||||
this->style = style;
|
||||
switch(style)
|
||||
{
|
||||
case brush_spec::HatchBDiagonal:
|
||||
this->handle = ::CreateHatchBrush(HS_BDIAGONAL, NANA_RGB(color));
|
||||
this->handle = ::CreateHatchBrush(HS_BDIAGONAL, NANA_RGB(rgb));
|
||||
break;
|
||||
case brush_spec::Solid:
|
||||
default:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Basis Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace nana
|
||||
{
|
||||
if(active)
|
||||
{
|
||||
native_interface::caret_create(wd_->root, size_.width, size_.height);
|
||||
native_interface::caret_create(wd_->root, size_);
|
||||
real_visible_state_ = false;
|
||||
visible_ = false;
|
||||
this->position(point_.x, point_.y);
|
||||
@@ -49,9 +49,7 @@ namespace nana
|
||||
void caret_descriptor::effective_range(nana::rectangle rect)
|
||||
{
|
||||
//Chech rect
|
||||
if( (rect.width && rect.height) &&
|
||||
(rect.x + rect.width > 0) &&
|
||||
(rect.y + rect.height > 0))
|
||||
if (rect.width && rect.height && rect.right() > 0 && rect.bottom() > 0)
|
||||
{
|
||||
if(rect.x < 0)
|
||||
{
|
||||
@@ -132,8 +130,8 @@ namespace nana
|
||||
pos.y += effective_range_.y;
|
||||
}
|
||||
|
||||
if( (pos.x + static_cast<int>(size.width) <= rect.x) || (pos.x >= rect.x + static_cast<int>(rect.width)) ||
|
||||
(pos.y + static_cast<int>(size.height) <= rect.y) || (pos.y >= rect.y + static_cast<int>(rect.height))
|
||||
if( (pos.x + static_cast<int>(size.width) <= rect.x) || (pos.x >= rect.right()) ||
|
||||
(pos.y + static_cast<int>(size.height) <= rect.y) || (pos.y >= rect.bottom())
|
||||
)
|
||||
{//Out of Range without overlap
|
||||
if(false == out_of_range_)
|
||||
@@ -151,9 +149,9 @@ namespace nana
|
||||
size.width -= (rect.x - pos.x);
|
||||
pos.x = rect.x;
|
||||
}
|
||||
else if(pos.x + size.width > rect.x + rect.width)
|
||||
else if(pos.x + static_cast<int>(size.width) > rect.right())
|
||||
{
|
||||
size.width -= pos.x + size.width - (rect.x + rect.width);
|
||||
size.width -= pos.x + size.width - rect.right();
|
||||
}
|
||||
|
||||
if(pos.y < rect.y)
|
||||
@@ -161,8 +159,8 @@ namespace nana
|
||||
size.width -= (rect.y - pos.y);
|
||||
pos.y = rect.y;
|
||||
}
|
||||
else if(pos.y + size.height > rect.y + rect.height)
|
||||
size.height -= pos.y + size.height - (rect.y + rect.height);
|
||||
else if(pos.y + static_cast<int>(size.height) > rect.bottom())
|
||||
size.height -= pos.y + size.height - rect.bottom();
|
||||
|
||||
if(out_of_range_)
|
||||
{
|
||||
@@ -175,7 +173,7 @@ namespace nana
|
||||
if(paint_size_ != size)
|
||||
{
|
||||
native_interface::caret_destroy(wd_->root);
|
||||
native_interface::caret_create(wd_->root, size.width, size.height);
|
||||
native_interface::caret_create(wd_->root, size);
|
||||
real_visible_state_ = false;
|
||||
if(visible_)
|
||||
_m_visible(true);
|
||||
@@ -183,7 +181,7 @@ namespace nana
|
||||
paint_size_ = size;
|
||||
}
|
||||
|
||||
native_interface::caret_pos(wd_->root, wd_->pos_root.x + pos.x, wd_->pos_root.y + pos.y);
|
||||
native_interface::caret_pos(wd_->root, wd_->pos_root + pos);
|
||||
}
|
||||
}
|
||||
//end class caret_descriptor
|
||||
@@ -228,7 +226,7 @@ namespace nana
|
||||
: widget_ptr(wdg), other(category::root_tag::value)
|
||||
{
|
||||
drawer.bind(this);
|
||||
_m_init_pos_and_size(0, rectangle());
|
||||
_m_init_pos_and_size(nullptr, rectangle());
|
||||
this->_m_initialize(owner);
|
||||
}
|
||||
|
||||
@@ -294,16 +292,20 @@ namespace nana
|
||||
return false;
|
||||
}
|
||||
|
||||
bool basic_window::is_draw_through() const
|
||||
{
|
||||
if (::nana::category::flags::root == this->other.category)
|
||||
return static_cast<bool>(other.attribute.root->draw_through);
|
||||
return false;
|
||||
}
|
||||
|
||||
void basic_window::_m_init_pos_and_size(basic_window* parent, const rectangle& r)
|
||||
{
|
||||
pos_owner = pos_root = r;
|
||||
dimension = r;
|
||||
|
||||
if(parent)
|
||||
{
|
||||
pos_root.x += parent->pos_root.x;
|
||||
pos_root.y += parent->pos_root.y;
|
||||
}
|
||||
if (parent)
|
||||
pos_root += parent->pos_root;
|
||||
}
|
||||
|
||||
void basic_window::_m_initialize(basic_window* agrparent)
|
||||
@@ -332,7 +334,7 @@ namespace nana
|
||||
}
|
||||
|
||||
predef_cursor = cursor::arrow;
|
||||
flags.capture = false;
|
||||
flags.captured = false;
|
||||
flags.dbl_click = true;
|
||||
flags.enabled = true;
|
||||
flags.modal = false;
|
||||
@@ -344,13 +346,10 @@ namespace nana
|
||||
flags.refreshing = false;
|
||||
flags.destroying = false;
|
||||
flags.borderless = false;
|
||||
flags.make_bground_declared = false;
|
||||
|
||||
visible = false;
|
||||
|
||||
color.foreground = 0x0;
|
||||
color.background = nana::color::button_face;
|
||||
color.active = 0x60C8FD;
|
||||
|
||||
effect.edge_nimbus = effects::edge_nimbus::none;
|
||||
effect.bground = nullptr;
|
||||
effect.bground_fade_rate = 0;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Bedrock Platform-Independent Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <nana/config.hpp>
|
||||
#include PLATFORM_SPEC_HPP
|
||||
#include GUI_BEDROCK_HPP
|
||||
#include <nana/gui/detail/bedrock_pi_data.hpp>
|
||||
#include <nana/gui/detail/event_code.hpp>
|
||||
#include <nana/system/platform.hpp>
|
||||
#include <sstream>
|
||||
@@ -25,6 +25,20 @@
|
||||
|
||||
namespace nana
|
||||
{
|
||||
//class event_arg
|
||||
event_arg::~event_arg(){}
|
||||
|
||||
void event_arg::stop_propagation() const
|
||||
{
|
||||
stop_propagation_ = true;
|
||||
}
|
||||
|
||||
bool event_arg::propagation_stopped() const
|
||||
{
|
||||
return stop_propagation_;
|
||||
}
|
||||
//end class event_arg
|
||||
|
||||
namespace detail
|
||||
{
|
||||
void events_operation_register(event_handle evt)
|
||||
@@ -63,7 +77,7 @@ namespace nana
|
||||
}
|
||||
|
||||
wd_manager.refresh_tree(wd);
|
||||
wd_manager.map(wd);
|
||||
wd_manager.map(wd, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +134,17 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void bedrock::_m_emit_core(event_code evt_code, core_window_t* wd, bool draw_only, const ::nana::detail::event_arg_interface& event_arg)
|
||||
widget_colors& bedrock::get_scheme_template(scheme_factory_base&& factory)
|
||||
{
|
||||
return pi_data_->scheme.scheme_template(std::move(factory));
|
||||
}
|
||||
|
||||
std::unique_ptr<widget_colors> bedrock::make_scheme(scheme_factory_base&& factory)
|
||||
{
|
||||
return pi_data_->scheme.create(std::move(factory));
|
||||
}
|
||||
|
||||
void bedrock::_m_emit_core(event_code evt_code, core_window_t* wd, bool draw_only, const ::nana::event_arg& event_arg)
|
||||
{
|
||||
switch (evt_code)
|
||||
{
|
||||
|
||||
90
source/gui/detail/color_schemes.cpp
Normal file
90
source/gui/detail/color_schemes.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
#include <nana/gui/detail/color_schemes.hpp>
|
||||
#include <map>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
//class color_proxy
|
||||
color_proxy::color_proxy(const color_proxy& other)
|
||||
: color_(other.color_)
|
||||
{}
|
||||
|
||||
color_proxy::color_proxy(color_rgb clr)
|
||||
: color_(std::make_shared<color>(clr))
|
||||
{}
|
||||
|
||||
color_proxy::color_proxy(colors clr)
|
||||
: color_(std::make_shared<color>(clr))
|
||||
{}
|
||||
|
||||
color_proxy& color_proxy::operator=(const color_proxy& other)
|
||||
{
|
||||
if (this != &other)
|
||||
color_ = other.color_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
color_proxy& color_proxy::operator=(const ::nana::color& clr)
|
||||
{
|
||||
color_ = std::make_shared<::nana::color>(clr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
color_proxy& color_proxy::operator = (color_rgb clr)
|
||||
{
|
||||
color_ = std::make_shared<::nana::color>(clr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
color_proxy& color_proxy::operator = (colors clr)
|
||||
{
|
||||
color_ = std::make_shared<::nana::color>(clr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
color color_proxy::get_color() const
|
||||
{
|
||||
return *color_;
|
||||
}
|
||||
|
||||
color_proxy::operator color() const
|
||||
{
|
||||
return *color_;
|
||||
}
|
||||
//end class color_proxy
|
||||
|
||||
namespace detail
|
||||
{
|
||||
//class color_schemes
|
||||
struct color_schemes::implement
|
||||
{
|
||||
std::map<scheme_factory_base::factory_identifier*, std::unique_ptr<scheme>> scheme_template;
|
||||
};
|
||||
|
||||
color_schemes::color_schemes()
|
||||
: impl_(new implement)
|
||||
{
|
||||
}
|
||||
|
||||
color_schemes::~color_schemes()
|
||||
{
|
||||
delete impl_;
|
||||
}
|
||||
|
||||
auto color_schemes::scheme_template(scheme_factory_base&& factory) -> scheme&
|
||||
{
|
||||
auto & tmpl_scheme = impl_->scheme_template[factory.get_id()];
|
||||
|
||||
//Creates a scheme template if no template
|
||||
if (!tmpl_scheme)
|
||||
factory.create().swap(tmpl_scheme);
|
||||
|
||||
return *tmpl_scheme.get();
|
||||
}
|
||||
|
||||
std::unique_ptr<widget_colors> color_schemes::create(scheme_factory_base&& factory)
|
||||
{
|
||||
return factory.create(scheme_template(std::move(factory)));
|
||||
}
|
||||
//end class color_system
|
||||
}//end namespace detail
|
||||
}//end namespace nana
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
|
||||
#include <nana/config.hpp>
|
||||
#include GUI_BEDROCK_HPP
|
||||
#include <nana/gui/detail/bedrock.hpp>
|
||||
#include <nana/gui/detail/drawer.hpp>
|
||||
#include <nana/gui/detail/dynamic_drawing_object.hpp>
|
||||
#include <nana/gui/detail/effects_renderer.hpp>
|
||||
@@ -242,7 +242,7 @@ namespace nana
|
||||
_m_emit(event_code::shortkey, arg, &drawer_trigger::shortkey);
|
||||
}
|
||||
|
||||
void drawer::map(window wd) //Copy the root buffer to screen
|
||||
void drawer::map(window wd, bool forced) //Copy the root buffer to screen
|
||||
{
|
||||
if(wd)
|
||||
{
|
||||
@@ -264,7 +264,7 @@ namespace nana
|
||||
#endif
|
||||
}
|
||||
|
||||
if(false == edge_nimbus_renderer_t::instance().render(iwd))
|
||||
if (false == edge_nimbus_renderer_t::instance().render(iwd, forced))
|
||||
{
|
||||
nana::rectangle vr;
|
||||
if(bedrock_type::window_manager_t::wndlayout_type::read_visual_rectangle(iwd, vr))
|
||||
@@ -378,11 +378,9 @@ namespace nana
|
||||
dw->draw(graphics);
|
||||
}
|
||||
|
||||
//If the drawer_trigger didn't declear a lazy refresh, then use the refresh().
|
||||
void drawer::_m_use_refresh()
|
||||
bool drawer::_m_lazy_decleared() const
|
||||
{
|
||||
if (basic_window::update_state::refresh != core_window_->other.upd_state)
|
||||
refresh();
|
||||
return (basic_window::update_state::refresh == core_window_->other.upd_state);
|
||||
}
|
||||
}//end namespace detail
|
||||
}//end namespace nana
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Bedrock Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <nana/config.hpp>
|
||||
#include PLATFORM_SPEC_HPP
|
||||
#include GUI_BEDROCK_HPP
|
||||
#include <nana/gui/detail/bedrock_pi_data.hpp>
|
||||
#include <nana/gui/detail/event_code.hpp>
|
||||
#include <nana/system/platform.hpp>
|
||||
#include <nana/gui/detail/inner_fwd_implement.hpp>
|
||||
@@ -165,19 +165,20 @@ namespace detail
|
||||
}
|
||||
|
||||
bedrock::bedrock()
|
||||
: impl_(new private_impl)
|
||||
: pi_data_(new pi_data), impl_(new private_impl)
|
||||
{
|
||||
nana::detail::platform_spec::instance().msg_set(timer_proc, window_proc_dispatcher);
|
||||
}
|
||||
|
||||
bedrock::~bedrock()
|
||||
{
|
||||
delete pi_data_;
|
||||
delete impl_;
|
||||
}
|
||||
|
||||
void bedrock::map_thread_root_buffer(bedrock::core_window_t* wnd)
|
||||
void bedrock::map_thread_root_buffer(core_window_t*, bool forced)
|
||||
{
|
||||
//GUI in X11 is not thread-dependent, so no implementation.
|
||||
//GUI in X11 is thread-independent, so no implementation.
|
||||
}
|
||||
|
||||
//inc_window
|
||||
@@ -376,14 +377,20 @@ namespace detail
|
||||
return impl_->estore;
|
||||
}
|
||||
|
||||
void bedrock::map_through_widgets(core_window_t* wd, native_drawable_type drawable)
|
||||
{
|
||||
//No implementation for Linux
|
||||
}
|
||||
|
||||
|
||||
bool bedrock::emit(event_code evt_code, core_window_t* wd, const arg_mouse& arg, bool ask_update, thread_context* thrd)
|
||||
{
|
||||
if(evt_code != arg.evt_code)
|
||||
throw std::runtime_error("Nana.bedrock: Invalid event arg.");
|
||||
return emit(evt_code, wd, static_cast<const ::nana::detail::event_arg_interface&>(arg), ask_update, thrd);
|
||||
return emit(evt_code, wd, static_cast<const ::nana::event_arg&>(arg), ask_update, thrd);
|
||||
}
|
||||
|
||||
bool bedrock::emit(event_code evt_code, core_window_t* wd, const ::nana::detail::event_arg_interface& arg, bool ask_update, thread_context* thrd)
|
||||
bool bedrock::emit(event_code evt_code, core_window_t* wd, const ::nana::event_arg& arg, bool ask_update, thread_context* thrd)
|
||||
{
|
||||
if(wd_manager.available(wd) == false)
|
||||
return false;
|
||||
@@ -410,7 +417,7 @@ namespace detail
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bedrock::emit_drawer(event_code evt_code, core_window_t* wd, const ::nana::detail::event_arg_interface& arg, thread_context* thrd)
|
||||
bool bedrock::emit_drawer(event_code evt_code, core_window_t* wd, const ::nana::event_arg& arg, thread_context* thrd)
|
||||
{
|
||||
if(wd_manager.available(wd) == false)
|
||||
return false;
|
||||
@@ -618,7 +625,8 @@ namespace detail
|
||||
msgwnd = brock.wd_manager.find_window(native_window, xevent.xcrossing.x, xevent.xcrossing.y);
|
||||
if(msgwnd)
|
||||
{
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
if (mouse_action::pressed != msgwnd->flags.action)
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
hovered_wd = msgwnd;
|
||||
|
||||
arg_mouse arg;
|
||||
@@ -869,7 +877,8 @@ namespace detail
|
||||
else
|
||||
{
|
||||
evt_code = event_code::mouse_enter;
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
if (mouse_action::pressed != msgwnd->flags.action)
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
}
|
||||
arg_mouse arg;
|
||||
assign_arg(arg, msgwnd, message, xevent);
|
||||
@@ -882,7 +891,10 @@ namespace detail
|
||||
{
|
||||
arg_mouse arg;
|
||||
assign_arg(arg, msgwnd, message, xevent);
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
|
||||
if (mouse_action::pressed != msgwnd->flags.action)
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
|
||||
if (hovered_wd != msgwnd)
|
||||
{
|
||||
hovered_wd = msgwnd;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <nana/paint/detail/image_ico.hpp>
|
||||
#elif defined(NANA_X11)
|
||||
#include <nana/system/platform.hpp>
|
||||
#include GUI_BEDROCK_HPP
|
||||
#include <nana/gui/detail/bedrock.hpp>
|
||||
#endif
|
||||
|
||||
namespace nana{
|
||||
@@ -146,7 +146,7 @@ namespace nana{
|
||||
#endif
|
||||
|
||||
//struct native_interface
|
||||
nana::size native_interface::screen_size()
|
||||
nana::size native_interface::primary_monitor_size()
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
return nana::size(::GetSystemMetrics(SM_CXSCREEN), ::GetSystemMetrics(SM_CYSCREEN));
|
||||
@@ -176,13 +176,10 @@ namespace nana{
|
||||
mi.rcWork.right - mi.rcWork.left, mi.rcWork.bottom - mi.rcWork.top);
|
||||
}
|
||||
}
|
||||
#elif defined(NANA_X11)
|
||||
#endif
|
||||
return screen_size();
|
||||
return primary_monitor_size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//platform-dependent
|
||||
native_interface::window_result native_interface::create_window(native_window_type owner, bool nested, const rectangle& r, const appearance& app)
|
||||
{
|
||||
@@ -933,7 +930,7 @@ namespace nana{
|
||||
#endif
|
||||
}
|
||||
|
||||
void native_interface::bring_to_top(native_window_type wd)
|
||||
void native_interface::bring_top(native_window_type wd, bool activated)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
HWND native_wd = reinterpret_cast<HWND>(wd);
|
||||
@@ -944,7 +941,7 @@ namespace nana{
|
||||
HWND fg_wd = ::GetForegroundWindow();
|
||||
DWORD fg_tid = ::GetWindowThreadProcessId(fg_wd, nullptr);
|
||||
::AttachThreadInput(::GetCurrentThreadId(), fg_tid, TRUE);
|
||||
::ShowWindow(native_wd, SW_SHOWNORMAL);
|
||||
::ShowWindow(native_wd, activated ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE);
|
||||
::SetWindowPos(native_wd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
||||
::SetWindowPos(native_wd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
||||
::AttachThreadInput(::GetCurrentThreadId(), fg_tid, FALSE);
|
||||
@@ -1196,13 +1193,13 @@ namespace nana{
|
||||
#endif
|
||||
}
|
||||
|
||||
void native_interface::caret_create(native_window_type wd, unsigned width, unsigned height)
|
||||
void native_interface::caret_create(native_window_type wd, const ::nana::size& caret_sz)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
::CreateCaret(reinterpret_cast<HWND>(wd), 0, int(width), int(height));
|
||||
::CreateCaret(reinterpret_cast<HWND>(wd), 0, int(caret_sz.width), int(caret_sz.height));
|
||||
#elif defined(NANA_X11)
|
||||
nana::detail::platform_scope_guard psg;
|
||||
restrict::spec.caret_open(wd, width, height);
|
||||
restrict::spec.caret_open(wd, caret_sz);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1219,21 +1216,21 @@ namespace nana{
|
||||
#endif
|
||||
}
|
||||
|
||||
void native_interface::caret_pos(native_window_type wd, int x, int y)
|
||||
void native_interface::caret_pos(native_window_type wd, const point& pos)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
if(::GetCurrentThreadId() != ::GetWindowThreadProcessId(reinterpret_cast<HWND>(wd), 0))
|
||||
{
|
||||
auto cp = new nana::detail::messages::caret;
|
||||
cp->x = x;
|
||||
cp->y = y;
|
||||
cp->x = pos.x;
|
||||
cp->y = pos.y;
|
||||
::PostMessage(reinterpret_cast<HWND>(wd), nana::detail::messages::operate_caret, 2, reinterpret_cast<LPARAM>(cp));
|
||||
}
|
||||
else
|
||||
::SetCaretPos(x, y);
|
||||
::SetCaretPos(pos.x, pos.y);
|
||||
#elif defined(NANA_X11)
|
||||
nana::detail::platform_scope_guard psg;
|
||||
restrict::spec.caret_pos(wd, x, y);
|
||||
restrict::spec.caret_pos(wd, pos);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Bedrock Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -13,16 +13,18 @@
|
||||
#include <nana/config.hpp>
|
||||
|
||||
#include PLATFORM_SPEC_HPP
|
||||
#include GUI_BEDROCK_HPP
|
||||
#include <nana/gui/detail/bedrock.hpp>
|
||||
#include <nana/gui/detail/bedrock_pi_data.hpp>
|
||||
#include <nana/gui/detail/event_code.hpp>
|
||||
#include <nana/system/platform.hpp>
|
||||
#include <sstream>
|
||||
#include <nana/system/timepiece.hpp>
|
||||
#include <nana/gui/wvl.hpp>
|
||||
#include <nana/gui.hpp>
|
||||
#include <nana/gui/detail/inner_fwd_implement.hpp>
|
||||
#include <nana/gui/detail/native_window_interface.hpp>
|
||||
#include <nana/gui/layout_utility.hpp>
|
||||
#include <nana/gui/detail/element_store.hpp>
|
||||
#include <nana/gui/detail/color_schemes.hpp>
|
||||
|
||||
#ifndef WM_MOUSEWHEEL
|
||||
#define WM_MOUSEWHEEL 0x020A
|
||||
@@ -175,7 +177,8 @@ namespace detail
|
||||
std::recursive_mutex mutex;
|
||||
thr_context_container thr_contexts;
|
||||
|
||||
element_store estore;
|
||||
color_schemes schemes;
|
||||
element_store estore;
|
||||
|
||||
struct cache_type
|
||||
{
|
||||
@@ -213,7 +216,8 @@ namespace detail
|
||||
static LRESULT WINAPI Bedrock_WIN32_WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
bedrock::bedrock()
|
||||
:impl_(new private_impl)
|
||||
: pi_data_(new pi_data),
|
||||
impl_(new private_impl)
|
||||
{
|
||||
nana::detail::platform_spec::instance(); //to guaranty the platform_spec object is initialized before using.
|
||||
|
||||
@@ -269,6 +273,7 @@ namespace detail
|
||||
::MessageBoxA(0, ss.str().c_str(), ("Nana C++ Library"), MB_OK);
|
||||
}
|
||||
delete impl_;
|
||||
delete pi_data_;
|
||||
}
|
||||
|
||||
//inc_window
|
||||
@@ -337,9 +342,9 @@ namespace detail
|
||||
return bedrock_object;
|
||||
}
|
||||
|
||||
void bedrock::map_thread_root_buffer(core_window_t* wd)
|
||||
void bedrock::map_thread_root_buffer(core_window_t* wd, bool forced)
|
||||
{
|
||||
::PostMessage(reinterpret_cast<HWND>(wd->root), nana::detail::messages::map_thread_root_buffer, reinterpret_cast<WPARAM>(wd), 0);
|
||||
::PostMessage(reinterpret_cast<HWND>(wd->root), nana::detail::messages::map_thread_root_buffer, reinterpret_cast<WPARAM>(wd), static_cast<LPARAM>(forced ? TRUE : FALSE));
|
||||
}
|
||||
|
||||
void interior_helper_for_menu(MSG& msg, native_window_type menu_window)
|
||||
@@ -591,7 +596,7 @@ namespace detail
|
||||
}
|
||||
return true;
|
||||
case nana::detail::messages::map_thread_root_buffer:
|
||||
bedrock.wd_manager.map(reinterpret_cast<bedrock::core_window_t*>(wParam));
|
||||
bedrock.wd_manager.map(reinterpret_cast<bedrock::core_window_t*>(wParam), (TRUE == lParam));
|
||||
::UpdateWindow(wd);
|
||||
return true;
|
||||
case nana::detail::messages::remote_thread_move_window:
|
||||
@@ -1003,7 +1008,7 @@ namespace detail
|
||||
arg.evt_code = event_code::mouse_up;
|
||||
emit_drawer(&drawer::mouse_up, msgwnd, arg, &context);
|
||||
|
||||
auto evt_ptr = msgwnd->together.events_ptr;
|
||||
//auto evt_ptr = msgwnd->together.events_ptr; //deprecated
|
||||
|
||||
if (fire_click)
|
||||
{
|
||||
@@ -1055,7 +1060,10 @@ namespace detail
|
||||
else
|
||||
{
|
||||
evt_code = event_code::mouse_enter;
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
if (pressed_wd == msgwnd)
|
||||
msgwnd->flags.action = mouse_action::pressed;
|
||||
else if (mouse_action::pressed != msgwnd->flags.action)
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
}
|
||||
arg_mouse arg;
|
||||
assign_arg(arg, msgwnd, message, pmdec);
|
||||
@@ -1068,9 +1076,14 @@ namespace detail
|
||||
{
|
||||
arg_mouse arg;
|
||||
assign_arg(arg, msgwnd, message, pmdec);
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
|
||||
if (hovered_wd != msgwnd)
|
||||
{
|
||||
if (pressed_wd == msgwnd)
|
||||
msgwnd->flags.action = mouse_action::pressed;
|
||||
else if (mouse_action::pressed != msgwnd->flags.action)
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
|
||||
hovered_wd = msgwnd;
|
||||
arg.evt_code = event_code::mouse_enter;
|
||||
brock.emit(event_code::mouse_enter, msgwnd, arg, true, &context);
|
||||
@@ -1100,21 +1113,34 @@ namespace detail
|
||||
auto scrolled_wd = brock.wd_manager.find_window(reinterpret_cast<native_window_type>(pointer_wd), scr_pos.x, scr_pos.y);
|
||||
|
||||
def_window_proc = true;
|
||||
while (scrolled_wd)
|
||||
auto evt_wd = scrolled_wd;
|
||||
while (evt_wd)
|
||||
{
|
||||
if (scrolled_wd->together.attached_events->mouse_wheel.length() != 0)
|
||||
if (evt_wd->together.attached_events->mouse_wheel.length() != 0)
|
||||
{
|
||||
def_window_proc = false;
|
||||
nana::point mspos{ scr_pos.x, scr_pos.y };
|
||||
brock.wd_manager.calc_window_point(scrolled_wd, mspos);
|
||||
brock.wd_manager.calc_window_point(evt_wd, mspos);
|
||||
|
||||
arg_wheel arg;
|
||||
arg.which = (WM_MOUSEHWHEEL == message ? arg_wheel::wheel::horizontal : arg_wheel::wheel::vertical);
|
||||
assign_arg(arg, scrolled_wd, pmdec);
|
||||
brock.emit(event_code::mouse_wheel, scrolled_wd, arg, true, &context);
|
||||
assign_arg(arg, evt_wd, pmdec);
|
||||
brock.emit(event_code::mouse_wheel, evt_wd, arg, true, &context);
|
||||
break;
|
||||
}
|
||||
scrolled_wd = scrolled_wd->parent;
|
||||
evt_wd = evt_wd->parent;
|
||||
}
|
||||
|
||||
if (scrolled_wd && (nullptr == evt_wd))
|
||||
{
|
||||
nana::point mspos{ scr_pos.x, scr_pos.y };
|
||||
brock.wd_manager.calc_window_point(scrolled_wd, mspos);
|
||||
|
||||
arg_wheel arg;
|
||||
arg.which = (WM_MOUSEHWHEEL == message ? arg_wheel::wheel::horizontal : arg_wheel::wheel::vertical);
|
||||
assign_arg(arg, scrolled_wd, pmdec);
|
||||
brock.emit_drawer(event_code::mouse_wheel, scrolled_wd, arg, &context);
|
||||
brock.wd_manager.do_lazy_refresh(scrolled_wd, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1260,6 +1286,15 @@ namespace detail
|
||||
brock.event_move(msgwnd, (int)(short) LOWORD(lParam), (int)(short) HIWORD(lParam));
|
||||
break;
|
||||
case WM_PAINT:
|
||||
if (msgwnd->is_draw_through())
|
||||
{
|
||||
msgwnd->other.attribute.root->draw_through();
|
||||
|
||||
::PAINTSTRUCT ps;
|
||||
::BeginPaint(root_window, &ps);
|
||||
::EndPaint(root_window, &ps);
|
||||
}
|
||||
else
|
||||
{
|
||||
::PAINTSTRUCT ps;
|
||||
::HDC dc = ::BeginPaint(root_window, &ps);
|
||||
@@ -1576,15 +1611,35 @@ namespace detail
|
||||
return impl_->estore;
|
||||
}
|
||||
|
||||
void bedrock::map_through_widgets(core_window_t* wd, native_drawable_type drawable)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
auto graph_context = reinterpret_cast<HDC>(wd->root_graph->handle()->context);
|
||||
|
||||
for (auto child : wd->children)
|
||||
{
|
||||
if (!child->visible) continue;
|
||||
|
||||
if (::nana::category::flags::widget == child->other.category)
|
||||
{
|
||||
::BitBlt(reinterpret_cast<HDC>(drawable), child->pos_root.x, child->pos_root.y, static_cast<int>(child->dimension.width), static_cast<int>(child->dimension.height),
|
||||
graph_context, child->pos_root.x, child->pos_root.y, SRCCOPY);
|
||||
}
|
||||
else if (::nana::category::flags::lite_widget == child->other.category)
|
||||
map_through_widgets(child, drawable);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool bedrock::emit(event_code evt_code, core_window_t* wd, const arg_mouse& arg, bool ask_update, thread_context* thrd)
|
||||
{
|
||||
if (evt_code != arg.evt_code)
|
||||
throw std::runtime_error("Nana.bedrock: invalid event arg.");
|
||||
|
||||
return emit(evt_code, wd, static_cast<const ::nana::detail::event_arg_interface&>(arg), ask_update, thrd);
|
||||
return emit(evt_code, wd, static_cast<const ::nana::event_arg&>(arg), ask_update, thrd);
|
||||
}
|
||||
|
||||
bool bedrock::emit(event_code evt_code, core_window_t* wd, const ::nana::detail::event_arg_interface& arg, bool ask_update, thread_context* thrd)
|
||||
bool bedrock::emit(event_code evt_code, core_window_t* wd, const ::nana::event_arg& arg, bool ask_update, thread_context* thrd)
|
||||
{
|
||||
if (wd_manager.available(wd) == false)
|
||||
return false;
|
||||
@@ -1611,7 +1666,7 @@ namespace detail
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bedrock::emit_drawer(event_code evt_code, core_window_t* wd, const ::nana::detail::event_arg_interface& arg, thread_context* thrd)
|
||||
bool bedrock::emit_drawer(event_code evt_code, core_window_t* wd, const ::nana::event_arg& arg, thread_context* thrd)
|
||||
{
|
||||
if (bedrock_object.wd_manager.available(wd) == false)
|
||||
return false;
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace nana
|
||||
|
||||
//Enable the effect.
|
||||
data_sect.effects_bground_windows.push_back(wd);
|
||||
wd->other.glass_buffer.make(wd->dimension.width, wd->dimension.height);
|
||||
wd->other.glass_buffer.make(wd->dimension);
|
||||
make_bground(wd);
|
||||
return true;
|
||||
}
|
||||
@@ -308,8 +308,14 @@ namespace nana
|
||||
{
|
||||
if (is_redraw || called_by_notify)
|
||||
{
|
||||
if (called_by_notify)
|
||||
//The background is made by more than calling by notification(such as redraw of parent,
|
||||
//redraw of siblings which are covered by wd), sometimes it should be remade when an attribute
|
||||
//of the wd is changed(such as its background color is changed).
|
||||
if (called_by_notify || wd->flags.make_bground_declared)
|
||||
{
|
||||
make_bground(wd);
|
||||
wd->flags.make_bground_declared = false;
|
||||
}
|
||||
|
||||
wd->flags.refreshing = true;
|
||||
wd->drawer.refresh();
|
||||
|
||||
@@ -12,12 +12,13 @@
|
||||
*/
|
||||
|
||||
#include <nana/config.hpp>
|
||||
#include GUI_BEDROCK_HPP
|
||||
#include <nana/gui/detail/bedrock.hpp>
|
||||
#include <nana/gui/detail/handle_manager.hpp>
|
||||
#include <nana/gui/detail/window_manager.hpp>
|
||||
#include <nana/gui/detail/native_window_interface.hpp>
|
||||
#include <nana/gui/detail/inner_fwd_implement.hpp>
|
||||
#include <nana/gui/layout_utility.hpp>
|
||||
#include <nana/gui/detail/effects_renderer.hpp>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -320,7 +321,7 @@ namespace detail
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
if (impl_->wd_register.available(parent) == false)
|
||||
return nullptr;
|
||||
throw std::invalid_argument("invalid parent/owner handle");
|
||||
|
||||
core_window_t * wd;
|
||||
if(is_lite)
|
||||
@@ -546,8 +547,8 @@ namespace detail
|
||||
{
|
||||
wd->dimension.width = r.width;
|
||||
wd->dimension.height = r.height;
|
||||
wd->drawer.graphics.make(r.width, r.height);
|
||||
wd->root_graph->make(r.width, r.height);
|
||||
wd->drawer.graphics.make(wd->dimension);
|
||||
wd->root_graph->make(wd->dimension);
|
||||
native_interface::move_window(wd->root, r);
|
||||
|
||||
arg_resized arg;
|
||||
@@ -612,7 +613,7 @@ namespace detail
|
||||
if(category::lite_widget_tag::value != wd->other.category)
|
||||
{
|
||||
bool graph_state = wd->drawer.graphics.empty();
|
||||
wd->drawer.graphics.make(sz.width, sz.height);
|
||||
wd->drawer.graphics.make(sz);
|
||||
|
||||
//It shall make a typeface_changed() call when the graphics state is changing.
|
||||
//Because when a widget is created with zero-size, it may get some wrong result in typeface_changed() call
|
||||
@@ -622,7 +623,7 @@ namespace detail
|
||||
|
||||
if(category::root_tag::value == wd->other.category)
|
||||
{
|
||||
wd->root_graph->make(sz.width, sz.height);
|
||||
wd->root_graph->make(sz);
|
||||
if(false == passive)
|
||||
native_interface::window_size(wd->root, sz + nana::size(wd->extra_width, wd->extra_height));
|
||||
}
|
||||
@@ -637,7 +638,7 @@ namespace detail
|
||||
//update the bground buffer of glass window.
|
||||
if(wd->effect.bground && wd->parent)
|
||||
{
|
||||
wd->other.glass_buffer.make(sz.width, sz.height);
|
||||
wd->other.glass_buffer.make(sz);
|
||||
wndlayout_type::make_bground(wd);
|
||||
}
|
||||
}
|
||||
@@ -670,20 +671,20 @@ namespace detail
|
||||
}
|
||||
|
||||
//Copy the root buffer that wnd specified into DeviceContext
|
||||
void window_manager::map(core_window_t* wd)
|
||||
void window_manager::map(core_window_t* wd, bool forced)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
if (impl_->wd_register.available(wd))
|
||||
if (impl_->wd_register.available(wd) && !wd->is_draw_through())
|
||||
{
|
||||
//Copy the root buffer that wd specified into DeviceContext
|
||||
#if defined(NANA_LINUX)
|
||||
wd->drawer.map(reinterpret_cast<window>(wd));
|
||||
wd->drawer.map(reinterpret_cast<window>(wd), forced);
|
||||
#elif defined(NANA_WINDOWS)
|
||||
if(nana::system::this_thread_id() == wd->thread_id)
|
||||
wd->drawer.map(reinterpret_cast<window>(wd));
|
||||
wd->drawer.map(reinterpret_cast<window>(wd), forced);
|
||||
else
|
||||
bedrock::instance().map_thread_root_buffer(wd);
|
||||
bedrock::instance().map_thread_root_buffer(wd, forced);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -692,7 +693,7 @@ namespace detail
|
||||
//@brief: update is used for displaying the screen-off buffer.
|
||||
// Because of a good efficiency, if it is called in an event procedure and the event procedure window is the
|
||||
// same as update's, update would not map the screen-off buffer and just set the window for lazy refresh
|
||||
bool window_manager::update(core_window_t* wd, bool redraw, bool force)
|
||||
bool window_manager::update(core_window_t* wd, bool redraw, bool forced)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
@@ -700,10 +701,10 @@ namespace detail
|
||||
|
||||
if (wd->visible && wd->visible_parents())
|
||||
{
|
||||
if(force || (false == wd->belong_to_lazy()))
|
||||
if(forced || (false == wd->belong_to_lazy()))
|
||||
{
|
||||
wndlayout_type::paint(wd, redraw, false);
|
||||
this->map(wd);
|
||||
this->map(wd, forced);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -738,14 +739,20 @@ namespace detail
|
||||
if (false == impl_->wd_register.available(wd))
|
||||
return false;
|
||||
|
||||
if(wd->visible)
|
||||
if(wd->visible && (!wd->is_draw_through()))
|
||||
{
|
||||
if (wd->visible_parents())
|
||||
{
|
||||
if ((wd->other.upd_state == core_window_t::update_state::refresh) || force_copy_to_screen)
|
||||
{
|
||||
wndlayout_type::paint(wd, false, false);
|
||||
this->map(wd);
|
||||
this->map(wd, force_copy_to_screen);
|
||||
}
|
||||
else if (effects::edge_nimbus::none != wd->effect.edge_nimbus)
|
||||
{
|
||||
//Update the nimbus effect
|
||||
using nimbus_renderer = detail::edge_nimbus_renderer<core_window_t>;
|
||||
nimbus_renderer::instance().render(wd, force_copy_to_screen);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -767,7 +774,7 @@ namespace detail
|
||||
if (!impl_->wd_register.available(wd))
|
||||
return false;
|
||||
|
||||
result.make(wd->drawer.graphics.width(), wd->drawer.graphics.height());
|
||||
result.make(wd->drawer.graphics.size());
|
||||
result.bitblt(0, 0, wd->drawer.graphics);
|
||||
wndlayout_type::paste_children_to_graphics(wd, result);
|
||||
return true;
|
||||
@@ -928,7 +935,7 @@ namespace detail
|
||||
|
||||
if (impl_->wd_register.available(wd))
|
||||
{
|
||||
wd->flags.capture = true;
|
||||
wd->flags.captured = true;
|
||||
native_interface::capture_window(wd->root, value);
|
||||
auto prev = attr_.capture.window;
|
||||
if(prev && (prev != wd))
|
||||
@@ -946,6 +953,7 @@ namespace detail
|
||||
else if(wd == attr_.capture.window)
|
||||
{
|
||||
attr_.capture.window = nullptr;
|
||||
wd->flags.captured = false;
|
||||
if(attr_cap.size())
|
||||
{
|
||||
std::pair<core_window_t*, bool> last = attr_cap.back();
|
||||
@@ -957,6 +965,7 @@ namespace detail
|
||||
attr_.capture.ignore_children = last.second;
|
||||
native_interface::capture_window(last.first->root, true);
|
||||
native_interface::calc_window_point(last.first->root, pos);
|
||||
last.first->flags.captured = true;
|
||||
attr_.capture.inside = _m_effective(last.first, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Drawing Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -20,19 +20,27 @@ namespace nana
|
||||
//@brief: This name is only visible for this compiling-unit
|
||||
namespace restrict
|
||||
{
|
||||
typedef detail::bedrock::core_window_t core_window_t;
|
||||
extern detail::bedrock& bedrock;
|
||||
|
||||
inline detail::drawer& get_drawer(window wd)
|
||||
namespace
|
||||
{
|
||||
return reinterpret_cast<core_window_t*>(wd)->drawer;
|
||||
using core_window_t = detail::bedrock::core_window_t;
|
||||
|
||||
inline detail::drawer& get_drawer(window wd)
|
||||
{
|
||||
return reinterpret_cast<core_window_t*>(wd)->drawer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//class drawing
|
||||
drawing::drawing(window wd)
|
||||
:handle_(wd)
|
||||
{}
|
||||
{
|
||||
if (!API::is_window(wd))
|
||||
throw std::invalid_argument("drawing: invalid window parameter");
|
||||
|
||||
if (reinterpret_cast<restrict::core_window_t*>(wd)->is_draw_through())
|
||||
throw std::invalid_argument("drawing: the window is draw_through enabled");
|
||||
}
|
||||
|
||||
drawing::~drawing(){} //Just for polymorphism
|
||||
|
||||
|
||||
@@ -26,9 +26,7 @@ namespace nana
|
||||
{
|
||||
if(fade_rate_ < 0.001)
|
||||
return;
|
||||
|
||||
nana::color_t color = API::background(wd);
|
||||
graph.blend(graph.size(), color, fade_rate_);
|
||||
graph.blend(graph.size(), API::bgcolor(wd), fade_rate_);
|
||||
}
|
||||
private:
|
||||
const double fade_rate_;
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
/*
|
||||
* Elements of GUI Gadgets
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/element.cpp
|
||||
*/
|
||||
|
||||
#include <nana/gui/element.hpp>
|
||||
#include <nana/gui/detail/bedrock.hpp>
|
||||
#include <nana/gui/detail/element_store.hpp>
|
||||
@@ -19,7 +31,7 @@ namespace nana
|
||||
class crook
|
||||
: public crook_interface
|
||||
{
|
||||
bool draw(graph_reference graph, nana::color_t bgcolor, nana::color_t fgcolor, const nana::rectangle& r, element_state es, const data& crook_data) override
|
||||
bool draw(graph_reference graph, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle& r, element_state es, const data& crook_data) override
|
||||
{
|
||||
if(crook_data.radio)
|
||||
{
|
||||
@@ -123,27 +135,28 @@ namespace nana
|
||||
for(int left = 0; left < 12; ++left)
|
||||
{
|
||||
if((*colormap)[top][left] != 0xFFFFFF)
|
||||
graph.set_pixel(left + x, top + y, (*colormap)[top][left]);
|
||||
graph.set_pixel(left + x, top + y, static_cast<colors>((*colormap)[top][left]));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const nana::color_t highlighted = 0x5EB6F7;
|
||||
|
||||
::nana::color highlighted(0x5e, 0xb6, 0xf7);
|
||||
auto bld_bgcolor = bgcolor;
|
||||
auto bld_fgcolor = fgcolor;
|
||||
switch(es)
|
||||
{
|
||||
case element_state::hovered:
|
||||
case element_state::focus_hovered:
|
||||
bgcolor = graph.mix(bgcolor, highlighted, 0.8);
|
||||
fgcolor = graph.mix(fgcolor, highlighted, 0.8);
|
||||
bld_bgcolor = bgcolor.blend(highlighted, 0.8);
|
||||
bld_fgcolor = fgcolor.blend(highlighted, 0.8);
|
||||
break;
|
||||
case element_state::pressed:
|
||||
bgcolor = graph.mix(bgcolor, highlighted, 0.4);
|
||||
fgcolor = graph.mix(fgcolor, highlighted, 0.4);
|
||||
bld_bgcolor = bgcolor.blend(highlighted, 0.4);
|
||||
bld_fgcolor = fgcolor.blend(highlighted, 0.4);
|
||||
break;
|
||||
case element_state::disabled:
|
||||
bgcolor = fgcolor = 0xB2B7BC;
|
||||
bld_bgcolor = bld_fgcolor = nana::color(0xb2, 0xb7, 0xbc);
|
||||
break;
|
||||
default:
|
||||
//Leave things as they are
|
||||
@@ -152,8 +165,11 @@ namespace nana
|
||||
const int x = r.x + 1;
|
||||
const int y = r.y + 1;
|
||||
|
||||
graph.rectangle(x, y, 13, 13, fgcolor, false);
|
||||
graph.rectangle(x + 1, y + 1, 11, 11, bgcolor, true);
|
||||
graph.set_color(bld_bgcolor);
|
||||
graph.rectangle(rectangle{ x + 1, y + 1, 11, 11 }, true);
|
||||
|
||||
graph.set_color(bld_fgcolor);
|
||||
graph.rectangle(rectangle{ x, y, 13, 13 }, false);
|
||||
|
||||
switch(crook_data.check_state)
|
||||
{
|
||||
@@ -166,19 +182,19 @@ namespace nana
|
||||
{
|
||||
sx++;
|
||||
sy++;
|
||||
graph.line(sx, sy, sx, sy + 3, fgcolor);
|
||||
graph.line(point{ sx, sy }, point{ sx, sy + 3 });
|
||||
}
|
||||
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
sx++;
|
||||
sy--;
|
||||
graph.line(sx, sy, sx, sy + 3, fgcolor);
|
||||
graph.line(point{ sx, sy }, point{ sx, sy + 3 });
|
||||
}
|
||||
}
|
||||
break;
|
||||
case state::partial:
|
||||
graph.rectangle(x + 2, y + 2, 9, 9, fgcolor, true);
|
||||
graph.rectangle(rectangle{ x + 2, y + 2, 9, 9 }, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -191,7 +207,7 @@ namespace nana
|
||||
class menu_crook
|
||||
: public crook_interface
|
||||
{
|
||||
bool draw(graph_reference graph, nana::color_t, nana::color_t fgcolor, const nana::rectangle& r, element_state es, const data& crook_data) override
|
||||
bool draw(graph_reference graph, const ::nana::color&, const ::nana::color& fgcolor, const nana::rectangle& r, element_state es, const data& crook_data) override
|
||||
{
|
||||
if(crook_data.check_state == state::unchecked)
|
||||
return true;
|
||||
@@ -218,7 +234,7 @@ namespace nana
|
||||
{
|
||||
if(colormap[u][v] & 0xFF000000)
|
||||
continue;
|
||||
graph.set_pixel(x + v, y, colormap[u][v]);
|
||||
graph.set_pixel(x + v, y, static_cast<color_rgb>(colormap[u][v]));
|
||||
}
|
||||
++y;
|
||||
}
|
||||
@@ -228,19 +244,292 @@ namespace nana
|
||||
int x = r.x + (static_cast<int>(r.width) - 16) / 2;
|
||||
int y = r.y + (static_cast<int>(r.height) - 16) / 2;
|
||||
|
||||
nana::color_t light = graph.mix(fgcolor, 0xFFFFFF, 0.5);
|
||||
graph.set_color(fgcolor);
|
||||
graph.line(point{ x + 3, y + 7 }, point{ x + 6, y + 10 });
|
||||
graph.line(point{ x + 7, y + 9 }, point{ x + 12, y + 4 });
|
||||
|
||||
graph.line(x + 3, y + 7, x + 6, y + 10, fgcolor);
|
||||
graph.line(x + 7, y + 9, x + 12, y + 4, fgcolor);
|
||||
graph.line(x + 3, y + 8, x + 6, y + 11, light);
|
||||
graph.line(x + 7, y + 10, x + 12, y + 5, light);
|
||||
graph.line(x + 4, y + 7, x + 6, y + 9, light);
|
||||
graph.line(x + 7, y + 8, x + 11, y + 4, light);
|
||||
graph.set_color(fgcolor.blend(colors::white, 0.5));
|
||||
graph.line(point{ x + 3, y + 8 }, point{ x + 6, y + 11 });
|
||||
graph.line(point{ x + 7, y + 10 }, point{ x + 12, y + 5 });
|
||||
graph.line(point{ x + 4, y + 7 }, point{ x + 6, y + 9 });
|
||||
graph.line(point{ x + 7, y + 8 }, point{ x + 11, y + 4 });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class border_depressed
|
||||
: public border_interface
|
||||
{
|
||||
bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate, unsigned weight)
|
||||
{
|
||||
graph.rectangle(r, false, static_cast<color_rgb>((element_state::focus_hovered == estate || element_state::focus_normal == estate) ? 0x0595E2 : 0x999A9E));
|
||||
graph.rectangle(::nana::rectangle{r}.pare_off(1), false, bgcolor);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class arrow_solid_triangle
|
||||
: public arrow_interface
|
||||
{
|
||||
bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate, direction dir) override
|
||||
{
|
||||
::nana::point pos{ r.x + 3, r.y + 3 };
|
||||
switch (dir)
|
||||
{
|
||||
case ::nana::direction::east:
|
||||
pos.x += 3;
|
||||
pos.y += 1;
|
||||
for (int i = 0; i < 5; ++i)
|
||||
graph.line(point{ pos.x + i, pos.y + i }, point{ pos.x + i, pos.y + 8 - i });
|
||||
break;
|
||||
case ::nana::direction::south:
|
||||
pos.y += 3;
|
||||
for (int i = 0; i < 5; ++i)
|
||||
graph.line(point{ pos.x + i, pos.y + i }, point{ pos.x + 8 - i, pos.y + i });
|
||||
break;
|
||||
case ::nana::direction::west:
|
||||
pos.x += 5;
|
||||
pos.y += 1;
|
||||
for (int i = 0; i < 5; ++i)
|
||||
graph.line(point{ pos.x - i, pos.y + i }, point{ pos.x - i, pos.y + 8 - i });
|
||||
break;
|
||||
case ::nana::direction::north:
|
||||
pos.y += 7;
|
||||
for (int i = 0; i < 5; ++i)
|
||||
graph.line(point{ pos.x + i, pos.y - i }, point{ pos.x + 8 - i, pos.y - i });
|
||||
break;
|
||||
case direction::southeast:
|
||||
pos.x += 2;
|
||||
pos.y += 7;
|
||||
for (int i = 0; i < 6; ++i)
|
||||
graph.line(point{ pos.x + i, pos.y - i }, point{ pos.x + 5, pos.y - i });
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};//end class arrow_solid_triangle
|
||||
|
||||
class arrow_hollow_triangle
|
||||
: public arrow_interface
|
||||
{
|
||||
bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate, ::nana::direction dir) override
|
||||
{
|
||||
int x = r.x + 3;
|
||||
int y = r.y + 3;
|
||||
switch (dir)
|
||||
{
|
||||
case ::nana::direction::east:
|
||||
x += 3;
|
||||
graph.line(point{ x, y + 1 }, point{ x, y + 9 });
|
||||
graph.line(point{ x + 1, y + 2 }, point{ x + 4, y + 5 });
|
||||
graph.line(point{ x + 3, y + 6 }, point{ x + 1, y + 8 });
|
||||
break;
|
||||
case direction::southeast:
|
||||
x += 7;
|
||||
y += 6;
|
||||
graph.line(point{ x - 5 , y + 1 }, point{ x, y + 1 });
|
||||
graph.line(point{ x, y - 4 }, point{ x, y });
|
||||
graph.line(point{ x - 4, y }, point{ x - 1, y - 3 });
|
||||
break;
|
||||
case direction::south:
|
||||
y += 3;
|
||||
graph.line(point{ x, y }, point{ x + 8, y });
|
||||
graph.line(point{ x + 1, y + 1 }, point{ x + 4, y + 4 });
|
||||
graph.line(point{ x + 7, y + 1 }, point{ x + 5, y + 3 });
|
||||
break;
|
||||
case direction::west:
|
||||
x += 5;
|
||||
y += 1;
|
||||
graph.line(point{ x, y }, point{ x, y + 8 });
|
||||
graph.line(point{ x - 4, y + 4 }, point{ x - 1, y + 1 });
|
||||
graph.line(point{ x - 3, y + 5 }, point{ x - 1, y + 7 });
|
||||
break;
|
||||
case direction::north:
|
||||
y += 7;
|
||||
graph.line(point{ x, y }, point{ x + 8, y });
|
||||
graph.line(point{ x + 1, y - 1 }, point{ x + 4, y - 4 });
|
||||
graph.line(point{ x + 5, y - 3 }, point{ x + 7, y - 1 });
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};//end class arrow_hollow_triangle
|
||||
|
||||
class arrowhead
|
||||
: public arrow_interface
|
||||
{
|
||||
bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate, ::nana::direction dir) override
|
||||
{
|
||||
int x = r.x;
|
||||
int y = r.y + 5;
|
||||
switch (dir)
|
||||
{
|
||||
case direction::north:
|
||||
{
|
||||
x += 3;
|
||||
int pixels = 1;
|
||||
for (int l = 0; l < 4; ++l)
|
||||
{
|
||||
for (int i = 0; i < pixels; ++i)
|
||||
{
|
||||
if (l == 3 && i == 3)
|
||||
continue;
|
||||
graph.set_pixel(x + i, y);
|
||||
}
|
||||
|
||||
x--;
|
||||
y++;
|
||||
pixels += 2;
|
||||
}
|
||||
|
||||
graph.set_pixel(x + 1, y);
|
||||
graph.set_pixel(x + 2, y);
|
||||
graph.set_pixel(x + 6, y);
|
||||
graph.set_pixel(x + 7, y);
|
||||
}
|
||||
break;
|
||||
case direction::south:
|
||||
{
|
||||
graph.set_pixel(x, y);
|
||||
graph.set_pixel(x + 1, y);
|
||||
graph.set_pixel(x + 5, y);
|
||||
graph.set_pixel(x + 6, y);
|
||||
|
||||
++y;
|
||||
int pixels = 7;
|
||||
for (int l = 0; l < 4; ++l)
|
||||
{
|
||||
for (int i = 0; i < pixels; ++i)
|
||||
{
|
||||
if (l != 0 || i != 3)
|
||||
graph.set_pixel(x + i, y);
|
||||
}
|
||||
|
||||
x++;
|
||||
y++;
|
||||
pixels -= 2;
|
||||
}
|
||||
}
|
||||
default:break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};//end class arrowhead
|
||||
|
||||
class arrow_double
|
||||
: public arrow_interface
|
||||
{
|
||||
bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate, ::nana::direction dir) override
|
||||
{
|
||||
int x = r.x;
|
||||
int y = r.y;
|
||||
switch (dir)
|
||||
{
|
||||
case direction::east:
|
||||
_m_line(graph, x + 4, y + 6, true);
|
||||
_m_line(graph, x + 5, y + 7, true);
|
||||
_m_line(graph, x + 6, y + 8, true);
|
||||
_m_line(graph, x + 5, y + 9, true);
|
||||
_m_line(graph, x + 4, y + 10, true);
|
||||
break;
|
||||
case direction::west:
|
||||
_m_line(graph, x + 5, y + 6, true);
|
||||
_m_line(graph, x + 4, y + 7, true);
|
||||
_m_line(graph, x + 3, y + 8, true);
|
||||
_m_line(graph, x + 4, y + 9, true);
|
||||
_m_line(graph, x + 5, y + 10, true);
|
||||
break;
|
||||
case direction::south:
|
||||
_m_line(graph, x + 5, y + 4, false);
|
||||
_m_line(graph, x + 6, y + 5, false);
|
||||
_m_line(graph, x + 7, y + 6, false);
|
||||
_m_line(graph, x + 8, y + 5, false);
|
||||
_m_line(graph, x + 9, y + 4, false);
|
||||
break;
|
||||
case direction::north:
|
||||
_m_line(graph, x + 5, y + 6, false);
|
||||
_m_line(graph, x + 6, y + 5, false);
|
||||
_m_line(graph, x + 7, y + 4, false);
|
||||
_m_line(graph, x + 8, y + 5, false);
|
||||
_m_line(graph, x + 9, y + 6, false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void _m_line(nana::paint::graphics & graph, int x, int y, bool horizontal)
|
||||
{
|
||||
graph.set_pixel(x, y);
|
||||
if (horizontal)
|
||||
{
|
||||
graph.set_pixel(x + 1, y);
|
||||
graph.set_pixel(x + 4, y);
|
||||
graph.set_pixel(x + 5, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
graph.set_pixel(x, y + 1);
|
||||
graph.set_pixel(x, y + 4);
|
||||
graph.set_pixel(x, y + 5);
|
||||
}
|
||||
}
|
||||
};//end class arrow_double
|
||||
|
||||
class annex_button
|
||||
: public element_interface
|
||||
{
|
||||
bool draw(graph_reference graph, const ::nana::color& arg_bgcolor, const ::nana::color& fgcolor, const rectangle& r, element_state estate) override
|
||||
{
|
||||
auto bgcolor = arg_bgcolor;
|
||||
|
||||
switch (estate)
|
||||
{
|
||||
case element_state::hovered:
|
||||
case element_state::focus_hovered:
|
||||
bgcolor = arg_bgcolor.blend(colors::white, 0.8);
|
||||
break;
|
||||
case element_state::pressed:
|
||||
bgcolor = arg_bgcolor.blend(colors::black, 0.8);
|
||||
break;
|
||||
case element_state::disabled:
|
||||
bgcolor = colors::dark_gray;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
auto part_px = (r.height - 3) * 5 / 13;
|
||||
graph.rectangle(r, false, bgcolor.blend(colors::black, 0.6));
|
||||
|
||||
::nana::point left_top{ r.x + 1, r.y + 1 }, right_top{r.right() - 2, r.y + 1};
|
||||
::nana::point left_mid{ r.x + 1, r.y + 1 + static_cast<int>(part_px) }, right_mid{ right_top.x, left_mid.y };
|
||||
::nana::point left_bottom{ r.x + 1, r.bottom() - 2 }, right_bottom{ r.right() - 2, r.bottom() - 2 };
|
||||
|
||||
graph.set_color(bgcolor.blend(colors::white, 0.9));
|
||||
graph.line(left_top, left_mid);
|
||||
graph.line(right_top, right_mid);
|
||||
|
||||
graph.set_color(bgcolor.blend(colors::white, 0.5));
|
||||
graph.line(left_top, right_top);
|
||||
|
||||
left_mid.y++;
|
||||
right_mid.y++;
|
||||
graph.set_color(bgcolor.blend(colors::black, 0.8));
|
||||
graph.line(left_mid, left_bottom);
|
||||
graph.line(right_mid, right_bottom);
|
||||
|
||||
::nana::rectangle part_r{ r.x + 2, r.y + 2, r.width - 4, part_px };
|
||||
graph.rectangle(part_r, true, bgcolor.blend(colors::white, 0.8));
|
||||
|
||||
part_r.y += static_cast<int>(part_r.height);
|
||||
part_r.height = (r.height - 3 - part_r.height);
|
||||
graph.rectangle(part_r, true, bgcolor);
|
||||
return true;
|
||||
}
|
||||
};//end class annex_button
|
||||
}//end namespace element
|
||||
|
||||
template<typename ElementInterface>
|
||||
class element_object
|
||||
@@ -250,11 +539,6 @@ namespace nana
|
||||
typedef pat::cloneable<element::provider::factory_interface<element_t>> factory_interface;
|
||||
|
||||
public:
|
||||
element_object()
|
||||
: element_ptr_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
~element_object()
|
||||
{
|
||||
if(factory_)
|
||||
@@ -289,7 +573,7 @@ namespace nana
|
||||
}
|
||||
private:
|
||||
factory_interface factory_; //Keep the factory for destroying the element
|
||||
element_t * element_ptr_;
|
||||
element_t * element_ptr_{nullptr};
|
||||
std::vector<std::pair<element_t*, factory_interface>> spare_;
|
||||
};
|
||||
|
||||
@@ -309,6 +593,7 @@ namespace nana
|
||||
element_manager()
|
||||
{
|
||||
crook_.employee = nullptr;
|
||||
border_.employee = nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -322,6 +607,15 @@ namespace nana
|
||||
|
||||
element::add_crook<element::crook>("");
|
||||
element::add_crook<element::menu_crook>("menu_crook");
|
||||
|
||||
element::add_border<element::border_depressed>("");
|
||||
|
||||
element::add_arrow<element::arrowhead>(""); //"arrowhead" in default
|
||||
element::add_arrow<element::arrow_double>("double");
|
||||
element::add_arrow<element::arrow_solid_triangle>("solid_triangle");
|
||||
element::add_arrow<element::arrow_hollow_triangle>("hollow_triangle");
|
||||
|
||||
element::add_button<element::annex_button>(""); //"annex" in default
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
@@ -335,8 +629,38 @@ namespace nana
|
||||
{
|
||||
return _m_get(name, crook_).keeper();
|
||||
}
|
||||
|
||||
void border(const std::string& name, const pat::cloneable<element::provider::factory_interface<element::border_interface>>& factory)
|
||||
{
|
||||
_m_add(name, border_, factory);
|
||||
}
|
||||
|
||||
element::border_interface * const * border(const std::string& name) const
|
||||
{
|
||||
return _m_get(name, border_).keeper();
|
||||
}
|
||||
|
||||
void arrow(const std::string& name, const pat::cloneable<element::provider::factory_interface<element::arrow_interface>>& factory)
|
||||
{
|
||||
_m_add((name.empty() ? "arrowhead" : name), arrow_, factory);
|
||||
}
|
||||
|
||||
element::arrow_interface * const * arrow(const std::string& name) const
|
||||
{
|
||||
return _m_get((name.empty() ? "arrowhead" : name), arrow_).keeper();
|
||||
}
|
||||
|
||||
void button(const std::string& name, const pat::cloneable<element::provider::factory_interface<element::element_interface>>& factory)
|
||||
{
|
||||
_m_add((name.empty() ? "annex" : name), button_, factory);
|
||||
}
|
||||
|
||||
element::element_interface * const * button(const std::string& name) const
|
||||
{
|
||||
return _m_get((name.empty() ? "annex" : name), button_).keeper();
|
||||
}
|
||||
private:
|
||||
typedef std::lock_guard<std::recursive_mutex> lock_guard;
|
||||
using lock_guard = std::lock_guard<std::recursive_mutex>;
|
||||
|
||||
template<typename ElementInterface>
|
||||
void _m_add(const std::string& name, item<ElementInterface>& m, const pat::cloneable<element::provider::factory_interface<ElementInterface>>& factory)
|
||||
@@ -367,7 +691,10 @@ namespace nana
|
||||
|
||||
private:
|
||||
mutable std::recursive_mutex mutex_;
|
||||
item<element::crook_interface> crook_;
|
||||
item<element::crook_interface> crook_;
|
||||
item<element::border_interface> border_;
|
||||
item<element::arrow_interface> arrow_;
|
||||
item<element::element_interface> button_;
|
||||
};
|
||||
|
||||
namespace element
|
||||
@@ -382,17 +709,40 @@ namespace nana
|
||||
{
|
||||
return element_manager::instance().crook(name);
|
||||
}
|
||||
|
||||
void provider::add_border(const std::string& name, const pat::cloneable<factory_interface<border_interface>>& factory)
|
||||
{
|
||||
element_manager::instance().border(name, factory);
|
||||
}
|
||||
|
||||
border_interface* const * provider::keeper_border(const std::string& name)
|
||||
{
|
||||
return element_manager::instance().border(name);
|
||||
}
|
||||
|
||||
void provider::add_arrow(const std::string& name, const pat::cloneable<factory_interface<arrow_interface>>& factory)
|
||||
{
|
||||
element_manager::instance().arrow(name, factory);
|
||||
}
|
||||
|
||||
arrow_interface* const * provider::keeper_arrow(const std::string& name)
|
||||
{
|
||||
return element_manager::instance().arrow(name);
|
||||
}
|
||||
|
||||
void provider::add_button(const std::string& name, const pat::cloneable<factory_interface<element_interface>>& factory)
|
||||
{
|
||||
element_manager::instance().button(name, factory);
|
||||
}
|
||||
|
||||
element_interface* const* provider::keeper_button(const std::string& name)
|
||||
{
|
||||
return element_manager::instance().button(name);
|
||||
}
|
||||
}//end namespace element
|
||||
|
||||
//facades
|
||||
//template<> class facade<element::crook>
|
||||
facade<element::crook>::facade()
|
||||
: keeper_(element::provider().keeper_crook(""))
|
||||
{
|
||||
data_.check_state = state::unchecked;
|
||||
data_.radio = false;
|
||||
}
|
||||
|
||||
facade<element::crook>::facade(const char* name)
|
||||
: keeper_(element::provider().keeper_crook(name ? name : ""))
|
||||
{
|
||||
@@ -430,15 +780,72 @@ namespace nana
|
||||
|
||||
void facade<element::crook>::switch_to(const char* name)
|
||||
{
|
||||
keeper_ = element::provider().keeper_crook(name);
|
||||
keeper_ = element::provider().keeper_crook(name ? name : "");
|
||||
}
|
||||
|
||||
bool facade<element::crook>::draw(graph_reference graph, nana::color_t bgcol, nana::color_t fgcol, const nana::rectangle& r, element_state es)
|
||||
bool facade<element::crook>::draw(graph_reference graph, const ::nana::color& bgcol, const ::nana::color& fgcol, const nana::rectangle& r, element_state es)
|
||||
{
|
||||
return (*keeper_)->draw(graph, bgcol, fgcol, r, es, data_);
|
||||
}
|
||||
//end class facade<element::crook>
|
||||
|
||||
//class facade<element::border>
|
||||
facade<element::border>::facade(const char* name)
|
||||
: keeper_(element::provider().keeper_border(name ? name : ""))
|
||||
{}
|
||||
|
||||
void facade<element::border>::switch_to(const char* name)
|
||||
{
|
||||
keeper_ = element::provider().keeper_border(name ? name : "");
|
||||
}
|
||||
|
||||
bool facade<element::border>::draw(graph_reference graph, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle& r, element_state es)
|
||||
{
|
||||
return (*keeper_)->draw(graph, bgcolor, fgcolor, r, es, 2);
|
||||
}
|
||||
//end class facade<element::border>
|
||||
|
||||
//class facade<element::arrow>
|
||||
facade<element::arrow>::facade(const char* name)
|
||||
: keeper_(element::provider().keeper_arrow(name ? name : ""))
|
||||
{
|
||||
}
|
||||
|
||||
void facade<element::arrow>::switch_to(const char* name)
|
||||
{
|
||||
keeper_ = element::provider().keeper_arrow(name ? name : "");
|
||||
}
|
||||
|
||||
void facade<element::arrow>::direction(::nana::direction dir)
|
||||
{
|
||||
dir_ = dir;
|
||||
}
|
||||
|
||||
//Implement element_interface
|
||||
bool facade<element::arrow>::draw(graph_reference graph, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle& r, element_state estate)
|
||||
{
|
||||
graph.set_color(fgcolor);
|
||||
return (*keeper_)->draw(graph, bgcolor, fgcolor, r, estate, dir_);
|
||||
}
|
||||
//end class facade<element::arrow>
|
||||
|
||||
//class facade<element::button>::
|
||||
facade<element::button>::facade(const char* name)
|
||||
: keeper_(element::provider().keeper_button(name ? name : ""))
|
||||
{}
|
||||
|
||||
void facade<element::button>::switch_to(const char* name)
|
||||
{
|
||||
keeper_ = element::provider().keeper_button(name ? name : "");
|
||||
}
|
||||
|
||||
//Implement element_interface
|
||||
bool facade<element::button>::draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate)
|
||||
{
|
||||
return (*keeper_)->draw(graph, bgcolor, fgcolor, r, estate);
|
||||
}
|
||||
//end class facade<element::button>
|
||||
|
||||
namespace element
|
||||
{
|
||||
void set_bground(const char* name, const pat::cloneable<element_interface>& obj)
|
||||
@@ -470,7 +877,7 @@ namespace nana
|
||||
ref_ptr_ = detail::bedrock::instance().get_element_store().bground(name);
|
||||
}
|
||||
|
||||
bool cite_bground::draw(graph_reference dst, nana::color_t bgcolor, nana::color_t fgcolor, const nana::rectangle& r, element_state state)
|
||||
bool cite_bground::draw(graph_reference dst, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const nana::rectangle& r, element_state state)
|
||||
{
|
||||
if (ref_ptr_ && *ref_ptr_)
|
||||
return (*ref_ptr_)->draw(dst, bgcolor, fgcolor, r, state);
|
||||
@@ -530,7 +937,7 @@ namespace nana
|
||||
draw_method * clone() const override
|
||||
{
|
||||
auto p = new draw_graph;
|
||||
p->graph.make(graph.width(), graph.height());
|
||||
p->graph.make(graph.size());
|
||||
graph.paste(p->graph, 0, 0);
|
||||
return p;
|
||||
}
|
||||
@@ -656,7 +1063,7 @@ namespace nana
|
||||
}
|
||||
|
||||
//Implement the methods of bground_interface.
|
||||
bool bground::draw(graph_reference dst, nana::color_t bgcolor, nana::color_t fgcolor, const nana::rectangle& to_r, element_state state)
|
||||
bool bground::draw(graph_reference dst, const ::nana::color&, const ::nana::color&, const nana::rectangle& to_r, element_state state)
|
||||
{
|
||||
if (nullptr == method_)
|
||||
return false;
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace nana
|
||||
{
|
||||
path_.create(*this);
|
||||
path_.splitstr(STR("/"));
|
||||
path_.events().selected([this](const arg_categorize<int>&)
|
||||
path_.events().selected.connect_unignorable([this](const arg_categorize<int>&)
|
||||
{
|
||||
auto path = path_.caption();
|
||||
auto root = path.substr(0, path.find(STR('/')));
|
||||
@@ -142,7 +142,7 @@ namespace nana
|
||||
filter_.multi_lines(false);
|
||||
filter_.tip_string(STR("Filter"));
|
||||
|
||||
filter_.events().key_release([this](const arg_keyboard&)
|
||||
filter_.events().key_release.connect_unignorable([this](const arg_keyboard&)
|
||||
{
|
||||
_m_list_fs();
|
||||
});
|
||||
@@ -150,7 +150,7 @@ namespace nana
|
||||
btn_folder_.create(*this);
|
||||
btn_folder_.caption(STR("&New Folder"));
|
||||
|
||||
btn_folder_.events().click([this](const arg_mouse&)
|
||||
btn_folder_.events().click.connect_unignorable([this](const arg_mouse&)
|
||||
{
|
||||
form fm(this->handle(), API::make_center(*this, 300, 35));
|
||||
fm.caption(STR("Name the new folder"));
|
||||
@@ -161,12 +161,12 @@ namespace nana
|
||||
button btn(fm, nana::rectangle(170, 5, 60, 25));
|
||||
btn.caption(STR("Create"));
|
||||
|
||||
btn.events().click(folder_creator(*this, fm, folder));
|
||||
btn.events().click.connect_unignorable(folder_creator(*this, fm, folder));
|
||||
|
||||
button btn_cancel(fm, nana::rectangle(235, 5, 60, 25));
|
||||
btn_cancel.caption(STR("Cancel"));
|
||||
|
||||
btn_cancel.events().click([&fm](const arg_mouse&)
|
||||
btn_cancel.events().click.connect_unignorable([&fm](const arg_mouse&)
|
||||
{
|
||||
fm.close();
|
||||
});
|
||||
@@ -184,8 +184,8 @@ namespace nana
|
||||
auto fn_sel_file = [this](const arg_mouse& arg){
|
||||
_m_sel_file(arg);
|
||||
};
|
||||
ls_file_.events().dbl_click(fn_sel_file);
|
||||
ls_file_.events().mouse_down(fn_sel_file);
|
||||
ls_file_.events().dbl_click.connect_unignorable(fn_sel_file);
|
||||
ls_file_.events().mouse_down.connect_unignorable(fn_sel_file);
|
||||
ls_file_.set_sort_compare(0, [](const nana::string& a, nana::any* fs_a, const nana::string& b, nana::any* fs_b, bool reverse) -> bool
|
||||
{
|
||||
int dira = fs_a->get<item_fs>()->directory ? 1 : 0;
|
||||
@@ -262,7 +262,7 @@ namespace nana
|
||||
tb_file_.create(*this);
|
||||
tb_file_.multi_lines(false);
|
||||
|
||||
tb_file_.events().key_char([this](const arg_keyboard& arg)
|
||||
tb_file_.events().key_char.connect_unignorable([this](const arg_keyboard& arg)
|
||||
{
|
||||
if(arg.key == nana::keyboard::enter)
|
||||
_m_ok();
|
||||
@@ -270,19 +270,19 @@ namespace nana
|
||||
|
||||
cb_types_.create(*this);
|
||||
cb_types_.editable(false);
|
||||
cb_types_.events().selected([this](const arg_combox&){ _m_list_fs(); });
|
||||
cb_types_.events().selected.connect_unignorable([this](const arg_combox&){ _m_list_fs(); });
|
||||
|
||||
btn_ok_.create(*this);
|
||||
btn_ok_.caption(STR("&OK"));
|
||||
|
||||
btn_ok_.events().click([this](const arg_mouse&)
|
||||
btn_ok_.events().click.connect_unignorable([this](const arg_mouse&)
|
||||
{
|
||||
_m_ok();
|
||||
});
|
||||
btn_cancel_.create(*this);
|
||||
btn_cancel_.caption(STR("&Cancel"));
|
||||
|
||||
btn_cancel_.events().click([this](const arg_mouse&)
|
||||
btn_cancel_.events().click.connect_unignorable([this](const arg_mouse&)
|
||||
{
|
||||
API::close_window(handle());
|
||||
});
|
||||
@@ -440,12 +440,12 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
tree_.events().expanded([this](const arg_treebox& arg)
|
||||
tree_.events().expanded.connect_unignorable([this](const arg_treebox& arg)
|
||||
{
|
||||
_m_tr_expand(arg.item, arg.operated);
|
||||
});
|
||||
|
||||
tree_.events().selected([this](const arg_treebox& arg)
|
||||
tree_.events().selected.connect_unignorable([this](const arg_treebox& arg)
|
||||
{
|
||||
if(arg.operated && (arg.item.value<kind::t>() == kind::filesystem))
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Message Box Class
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -9,17 +9,23 @@
|
||||
*
|
||||
* @file: nana/gui/msgbox.hpp
|
||||
*/
|
||||
#include <nana/gui/msgbox.hpp>
|
||||
#include <nana/gui/programming_interface.hpp>
|
||||
|
||||
#include <nana/gui.hpp>
|
||||
#include <nana/gui/widgets/label.hpp>
|
||||
#include <nana/gui/widgets/button.hpp>
|
||||
#include <nana/gui/widgets/spinbox.hpp>
|
||||
#include <nana/gui/widgets/combox.hpp>
|
||||
#include <nana/gui/widgets/textbox.hpp>
|
||||
#include <nana/gui/widgets/panel.hpp>
|
||||
#include <nana/gui/place.hpp>
|
||||
#include <nana/datetime.hpp>
|
||||
#include <nana/internationalization.hpp>
|
||||
#include <functional>
|
||||
#if defined(NANA_WINDOWS)
|
||||
#include <windows.h>
|
||||
#elif defined(NANA_X11)
|
||||
#include <nana/gui/wvl.hpp>
|
||||
#include <nana/gui/widgets/label.hpp>
|
||||
#include <nana/gui/widgets/button.hpp>
|
||||
#include <nana/gui/widgets/picture.hpp>
|
||||
#include <nana/paint/pixel_buffer.hpp>
|
||||
#include <nana/gui/place.hpp>
|
||||
#endif
|
||||
|
||||
namespace nana
|
||||
@@ -29,17 +35,17 @@ namespace nana
|
||||
: public form
|
||||
{
|
||||
public:
|
||||
msgbox_window(window wd, const nana::string& title, msgbox::button_t btn, msgbox::icon_t ico)
|
||||
: form(wd, nana::rectangle(1, 1, 1, 1), appear::decorate<>()),
|
||||
msgbox_window(window wd, const ::nana::string& title, msgbox::button_t btn, msgbox::icon_t ico)
|
||||
: form(wd, rectangle(1, 1, 1, 1), appear::decorate<>()),
|
||||
owner_(wd), pick_(msgbox::pick_yes)
|
||||
{
|
||||
this->caption(title);
|
||||
drawing dw(*this);
|
||||
dw.draw([this](::nana::paint::graphics& graph)
|
||||
dw.draw([this](paint::graphics& graph)
|
||||
{
|
||||
graph.rectangle(nana::rectangle{0, 0, graph.width(), graph.height() - 50}, 0xFFFFFF, true);
|
||||
graph.rectangle(rectangle{0, 0, graph.width(), graph.height() - 50}, true, colors::white);
|
||||
if(ico_.empty() == false)
|
||||
ico_.stretch(ico_.size(), graph, ::nana::rectangle{12, 25, 32, 32});
|
||||
ico_.stretch(ico_.size(), graph, rectangle{12, 25, 32, 32});
|
||||
});
|
||||
|
||||
unsigned width_pixel = 45;
|
||||
@@ -48,7 +54,7 @@ namespace nana
|
||||
place_.bind(*this);
|
||||
|
||||
yes_.create(*this);
|
||||
yes_.events().click([this](const arg_mouse& arg)
|
||||
yes_.events().click.connect_unignorable([this](const arg_mouse& arg)
|
||||
{
|
||||
_m_click(arg);
|
||||
});
|
||||
@@ -60,7 +66,7 @@ namespace nana
|
||||
yes_.caption(STR("Yes"));
|
||||
no_.create(*this);
|
||||
no_.caption(STR("No"));
|
||||
no_.events().click([this](const arg_mouse& arg)
|
||||
no_.events().click.connect_unignorable([this](const arg_mouse& arg)
|
||||
{
|
||||
_m_click(arg);
|
||||
});
|
||||
@@ -71,7 +77,7 @@ namespace nana
|
||||
{
|
||||
cancel_.create(*this);
|
||||
cancel_.caption(STR("Cancel"));
|
||||
cancel_.events().click([this](const arg_mouse& arg)
|
||||
cancel_.events().click.connect_unignorable([this](const arg_mouse& arg)
|
||||
{
|
||||
_m_click(arg);
|
||||
});
|
||||
@@ -107,7 +113,7 @@ namespace nana
|
||||
const unsigned text_pixels = 500 - ico_pixels;
|
||||
text_.create(*this, nana::rectangle(12 + ico_pixels, 25, 1, 1));
|
||||
|
||||
text_.background(0xFFFFFF);
|
||||
text_.bgcolor(colors::white);
|
||||
text_.caption(text);
|
||||
|
||||
nana::size ts = text_.measure(text_pixels);
|
||||
@@ -293,7 +299,7 @@ namespace nana
|
||||
{
|
||||
nana::paint::pixel_buffer pxbuf(32, 32);
|
||||
pxbuf.put(reinterpret_cast<const unsigned char*>(rawpx), 32, 32, 32, 4*32, true);
|
||||
ico_.make(32, 32);
|
||||
ico_.make({32, 32});
|
||||
pxbuf.paste(ico_.handle(), 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -319,146 +325,709 @@ namespace nana
|
||||
};
|
||||
#endif
|
||||
|
||||
//class msgbox
|
||||
msgbox::msgbox()
|
||||
: wd_(nullptr), button_(ok), icon_(icon_none)
|
||||
{}
|
||||
//class msgbox
|
||||
msgbox::msgbox()
|
||||
: wd_(nullptr), button_(ok), icon_(icon_none)
|
||||
{}
|
||||
|
||||
msgbox::msgbox(const msgbox& rhs)
|
||||
: wd_(rhs.wd_), title_(rhs.title_), button_(rhs.button_), icon_(rhs.icon_)
|
||||
msgbox::msgbox(const msgbox& rhs)
|
||||
: wd_(rhs.wd_), title_(rhs.title_), button_(rhs.button_), icon_(rhs.icon_)
|
||||
{
|
||||
sstream_<<rhs.sstream_.str();
|
||||
}
|
||||
|
||||
msgbox& msgbox::operator=(const msgbox& rhs)
|
||||
{
|
||||
if(this != &rhs)
|
||||
{
|
||||
sstream_<<rhs.sstream_.str();
|
||||
wd_ = rhs.wd_;
|
||||
title_ = rhs.title_;
|
||||
button_ = rhs.button_;
|
||||
icon_ = rhs.icon_;
|
||||
sstream_ << rhs.sstream_.str();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
msgbox& msgbox::operator=(const msgbox& rhs)
|
||||
{
|
||||
if(this != &rhs)
|
||||
{
|
||||
wd_ = rhs.wd_;
|
||||
title_ = rhs.title_;
|
||||
button_ = rhs.button_;
|
||||
icon_ = rhs.icon_;
|
||||
sstream_ << rhs.sstream_.str();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
msgbox::msgbox(const nana::string& title)
|
||||
: wd_(nullptr), title_(title), button_(ok), icon_(icon_none)
|
||||
{}
|
||||
|
||||
msgbox::msgbox(const nana::string& title)
|
||||
: wd_(nullptr), title_(title), button_(ok), icon_(icon_none)
|
||||
{}
|
||||
msgbox::msgbox(window wd, const nana::string& title)
|
||||
: wd_(wd), title_(title), button_(ok), icon_(icon_none)
|
||||
{}
|
||||
|
||||
msgbox::msgbox(window wd, const nana::string& title)
|
||||
: wd_(wd), title_(title), button_(ok), icon_(icon_none)
|
||||
{}
|
||||
msgbox::msgbox(window wd, const nana::string& title, button_t b)
|
||||
: wd_(wd), title_(title), button_(b), icon_(icon_none)
|
||||
{}
|
||||
|
||||
msgbox::msgbox(window wd, const nana::string& title, button_t b)
|
||||
: wd_(wd), title_(title), button_(b), icon_(icon_none)
|
||||
{}
|
||||
msgbox& msgbox::icon(icon_t ic)
|
||||
{
|
||||
icon_ = ic;
|
||||
return *this;
|
||||
}
|
||||
|
||||
msgbox& msgbox::icon(icon_t ic)
|
||||
{
|
||||
icon_ = ic;
|
||||
return *this;
|
||||
}
|
||||
void msgbox::clear()
|
||||
{
|
||||
sstream_.str("");
|
||||
sstream_.clear();
|
||||
}
|
||||
|
||||
void msgbox::clear()
|
||||
{
|
||||
sstream_.str("");
|
||||
sstream_.clear();
|
||||
}
|
||||
|
||||
msgbox & msgbox::operator<<(const nana::string& str)
|
||||
{
|
||||
msgbox & msgbox::operator<<(const nana::string& str)
|
||||
{
|
||||
#if defined(NANA_UNICODE)
|
||||
sstream_<<static_cast<std::string>(nana::charset(str));
|
||||
sstream_<<static_cast<std::string>(nana::charset(str));
|
||||
#else
|
||||
sstream_<<str;
|
||||
sstream_<<str;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
msgbox & msgbox::operator<<(const nana::char_t* str)
|
||||
{
|
||||
msgbox & msgbox::operator<<(const nana::char_t* str)
|
||||
{
|
||||
#if defined(NANA_UNICODE)
|
||||
sstream_<<static_cast<std::string>(nana::charset(str));;
|
||||
sstream_<<static_cast<std::string>(nana::charset(str));;
|
||||
#else
|
||||
sstream_<<str;
|
||||
sstream_<<str;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
msgbox & msgbox::operator<<(const nana::charset& cs)
|
||||
{
|
||||
std::string str = cs;
|
||||
sstream_ << str;
|
||||
return *this;
|
||||
}
|
||||
msgbox & msgbox::operator<<(const nana::charset& cs)
|
||||
{
|
||||
std::string str = cs;
|
||||
sstream_ << str;
|
||||
return *this;
|
||||
}
|
||||
|
||||
msgbox & msgbox::operator<<(std::ostream& (*manipulator)(std::ostream&))
|
||||
{
|
||||
sstream_<<manipulator;
|
||||
return *this;
|
||||
}
|
||||
msgbox & msgbox::operator<<(std::ostream& (*manipulator)(std::ostream&))
|
||||
{
|
||||
sstream_<<manipulator;
|
||||
return *this;
|
||||
}
|
||||
|
||||
msgbox::pick_t msgbox::show() const
|
||||
{
|
||||
msgbox::pick_t msgbox::show() const
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
int type = 0;
|
||||
switch(button_)
|
||||
{
|
||||
case msgbox::ok:
|
||||
type = MB_OK;
|
||||
break;
|
||||
case msgbox::yes_no:
|
||||
type = MB_YESNO;
|
||||
break;
|
||||
case msgbox::yes_no_cancel:
|
||||
type = MB_YESNOCANCEL;
|
||||
break;
|
||||
}
|
||||
int type = 0;
|
||||
switch(button_)
|
||||
{
|
||||
case msgbox::ok:
|
||||
type = MB_OK;
|
||||
break;
|
||||
case msgbox::yes_no:
|
||||
type = MB_YESNO;
|
||||
break;
|
||||
case msgbox::yes_no_cancel:
|
||||
type = MB_YESNOCANCEL;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(icon_)
|
||||
{
|
||||
case msgbox::icon_error:
|
||||
type |= MB_ICONERROR;
|
||||
break;
|
||||
case msgbox::icon_question:
|
||||
type |= MB_ICONQUESTION;
|
||||
break;
|
||||
case msgbox::icon_information:
|
||||
type |= MB_ICONINFORMATION;
|
||||
break;
|
||||
case msgbox::icon_warning:
|
||||
type |= MB_ICONWARNING;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
switch(icon_)
|
||||
{
|
||||
case msgbox::icon_error:
|
||||
type |= MB_ICONERROR;
|
||||
break;
|
||||
case msgbox::icon_question:
|
||||
type |= MB_ICONQUESTION;
|
||||
break;
|
||||
case msgbox::icon_information:
|
||||
type |= MB_ICONINFORMATION;
|
||||
break;
|
||||
case msgbox::icon_warning:
|
||||
type |= MB_ICONWARNING;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
#if defined(NANA_UNICODE)
|
||||
int bt = ::MessageBoxW(reinterpret_cast<HWND>(API::root(wd_)), static_cast<std::wstring>(nana::charset(sstream_.str())).c_str(), title_.c_str(), type);
|
||||
#else
|
||||
int bt = ::MessageBoxA(reinterpret_cast<HWND>(API::root(wd_), sstream_.str().c_str(), title_.c_str(), type);
|
||||
#endif
|
||||
switch(bt)
|
||||
{
|
||||
case IDOK:
|
||||
return pick_ok;
|
||||
case IDYES:
|
||||
return pick_yes;
|
||||
case IDNO:
|
||||
return pick_no;
|
||||
case IDCANCEL:
|
||||
return pick_cancel;
|
||||
}
|
||||
|
||||
return pick_yes;
|
||||
#elif defined(NANA_X11)
|
||||
msgbox_window box(wd_, title_, button_, icon_);
|
||||
box.prompt(nana::charset(sstream_.str()));
|
||||
return box.pick();
|
||||
#endif
|
||||
switch(bt)
|
||||
{
|
||||
case IDOK:
|
||||
return pick_ok;
|
||||
case IDYES:
|
||||
return pick_yes;
|
||||
case IDNO:
|
||||
return pick_no;
|
||||
case IDCANCEL:
|
||||
return pick_cancel;
|
||||
}
|
||||
|
||||
//end class msgbox
|
||||
return pick_yes;
|
||||
#elif defined(NANA_X11)
|
||||
msgbox_window box(wd_, title_, button_, icon_);
|
||||
box.prompt(nana::charset(sstream_.str()));
|
||||
return box.pick();
|
||||
#endif
|
||||
return pick_yes;
|
||||
}
|
||||
//end class msgbox
|
||||
|
||||
|
||||
//class inputbox
|
||||
|
||||
class inputbox_window
|
||||
: public ::nana::form
|
||||
{
|
||||
public:
|
||||
inputbox_window(window owner, const ::nana::string & desc, const ::nana::string& title, std::size_t contents, unsigned fixed_pixels, const std::vector<unsigned>& each_height)
|
||||
: form(owner, API::make_center(owner, 500, 300), appear::decorate<>())
|
||||
{
|
||||
desc_.create(*this);
|
||||
desc_.format(true).caption(desc);
|
||||
auto desc_extent = desc_.measure(470);
|
||||
|
||||
btn_ok_.create(*this);
|
||||
btn_ok_.i18n(i18n_eval("OK"));
|
||||
btn_ok_.events().click.connect_unignorable([this]{
|
||||
|
||||
if (verifier_ && !verifier_(handle()))
|
||||
return;
|
||||
|
||||
close();
|
||||
valid_input_ = true;
|
||||
});
|
||||
|
||||
btn_cancel_.create(*this);
|
||||
btn_cancel_.i18n(i18n_eval("Cancel"));
|
||||
btn_cancel_.events().click.connect_unignorable([this]{
|
||||
close();
|
||||
});
|
||||
|
||||
unsigned height = 20 + desc_extent.height + 10 + 38;
|
||||
|
||||
place_.bind(*this);
|
||||
std::stringstream ss;
|
||||
ss << "margin=10 vert <desc weight=" << desc_extent.height << "><vert margin=[10]";
|
||||
|
||||
for (std::size_t i = 0; i < contents; ++i)
|
||||
{
|
||||
unsigned px = 27;
|
||||
if (each_height[i] > 27)
|
||||
px = each_height[i];
|
||||
|
||||
ss << "<weight="<<px<<" margin=[3] input_" << i << ">";
|
||||
|
||||
height += px + 1;
|
||||
}
|
||||
|
||||
ss << "><margin=[15] weight=38<><buttons arrange=80 gap=10 weight=170>>";
|
||||
|
||||
place_.div(ss.str().data());
|
||||
place_["desc"] << desc_;
|
||||
place_["buttons"] << btn_ok_ << btn_cancel_;
|
||||
|
||||
if (desc_extent.width < 170)
|
||||
desc_extent.width = 170;
|
||||
|
||||
//Make sure the complete display of input extent
|
||||
if (desc_extent.width < fixed_pixels)
|
||||
desc_extent.width = fixed_pixels;
|
||||
|
||||
size({ desc_extent.width + 20, height });
|
||||
caption(title);
|
||||
}
|
||||
|
||||
void set_input(const std::vector<window>& inputs, std::function<bool(window)> verifier)
|
||||
{
|
||||
verifier_ = std::move(verifier);
|
||||
|
||||
std::size_t index = 0;
|
||||
for (auto wd : inputs)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "input_" << index++;
|
||||
place_[ss.str().data()] << wd;
|
||||
}
|
||||
place_.collocate();
|
||||
show();
|
||||
}
|
||||
|
||||
bool valid_input() const
|
||||
{
|
||||
return valid_input_;
|
||||
}
|
||||
private:
|
||||
::nana::label desc_;
|
||||
::nana::button btn_ok_;
|
||||
::nana::button btn_cancel_;
|
||||
bool valid_input_{ false };
|
||||
::nana::place place_;
|
||||
std::function<bool(window)> verifier_;
|
||||
};
|
||||
|
||||
//class integer
|
||||
struct inputbox::integer::implement
|
||||
{
|
||||
int value;
|
||||
int begin;
|
||||
int last;
|
||||
int step;
|
||||
|
||||
::nana::string label_text;
|
||||
::nana::panel<false> dock;
|
||||
::nana::label label;
|
||||
::nana::spinbox spinbox;
|
||||
};
|
||||
|
||||
inputbox::integer::integer(::nana::string label, int init_value, int begin, int last, int step)
|
||||
: impl_(new implement)
|
||||
{
|
||||
auto impl = impl_.get();
|
||||
impl->value = init_value;
|
||||
impl->begin = begin;
|
||||
impl->last = last;
|
||||
impl->step = step;
|
||||
impl->label_text = std::move(label);
|
||||
}
|
||||
|
||||
//Instance for impl_ because implmenet is incomplete type at the point of declaration
|
||||
inputbox::integer::~integer(){}
|
||||
|
||||
int inputbox::integer::value() const
|
||||
{
|
||||
return impl_->value;
|
||||
}
|
||||
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& inputbox::integer::label() const
|
||||
{
|
||||
return impl_->label_text;
|
||||
}
|
||||
|
||||
window inputbox::integer::create(window parent, unsigned label_px)
|
||||
{
|
||||
auto impl = impl_.get();
|
||||
impl->dock.create(parent);
|
||||
|
||||
impl->label.create(impl->dock, rectangle{ 0, 0, label_px, 0 });
|
||||
impl->label.text_align(::nana::align::right, ::nana::align_v::center);
|
||||
impl->label.caption(impl->label_text);
|
||||
impl->label.format(true);
|
||||
|
||||
//get the longest value
|
||||
int longest = (std::abs((impl->begin < 0 ? impl->begin * 10 : impl->begin)) < std::abs(impl->last < 0 ? impl->last * 10 : impl->last) ? impl->last : impl->begin);
|
||||
std::wstringstream ss;
|
||||
ss << longest;
|
||||
paint::graphics graph{ ::nana::size{ 10, 10 } };
|
||||
auto value_px = graph.text_extent_size(ss.str()).width + 34;
|
||||
|
||||
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.set_accept_integer(); //deprecated
|
||||
|
||||
//Workaround for no implementation of std::to_wstring by MinGW.
|
||||
ss.str(L"");
|
||||
ss.clear();
|
||||
ss << impl->value;
|
||||
impl->spinbox.value(ss.str());
|
||||
|
||||
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->spinbox.events().destroy.connect_unignorable([impl]
|
||||
{
|
||||
impl->value = impl->spinbox.to_int();
|
||||
});
|
||||
|
||||
return impl->dock;
|
||||
}
|
||||
|
||||
unsigned inputbox::integer::fixed_pixels() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
//end class integer
|
||||
|
||||
|
||||
//class real
|
||||
struct inputbox::real::implement
|
||||
{
|
||||
double value;
|
||||
double begin;
|
||||
double last;
|
||||
double step;
|
||||
|
||||
::nana::string label_text;
|
||||
::nana::panel<false> dock;
|
||||
::nana::label label;
|
||||
::nana::spinbox spinbox;
|
||||
};
|
||||
|
||||
inputbox::real::real(::nana::string label, double init_value, double begin, double last, double step)
|
||||
: impl_(new implement)
|
||||
{
|
||||
auto impl = impl_.get();
|
||||
impl->value = init_value;
|
||||
impl->begin = begin;
|
||||
impl->last = last;
|
||||
impl->step = step;
|
||||
impl->label_text = std::move(label);
|
||||
}
|
||||
|
||||
//Instance for impl_ because implmenet is incomplete type at the point of declaration
|
||||
inputbox::real::~real(){}
|
||||
|
||||
double inputbox::real::value() const
|
||||
{
|
||||
return impl_->value;
|
||||
}
|
||||
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& inputbox::real::label() const
|
||||
{
|
||||
return impl_->label_text;
|
||||
}
|
||||
|
||||
window inputbox::real::create(window parent, unsigned label_px)
|
||||
{
|
||||
auto impl = impl_.get();
|
||||
impl->dock.create(parent);
|
||||
|
||||
impl->label.create(impl->dock, rectangle{ 0, 0, label_px, 0 });
|
||||
impl->label.text_align(::nana::align::right, ::nana::align_v::center);
|
||||
impl->label.caption(impl->label_text);
|
||||
impl->label.format(true);
|
||||
|
||||
//get the longest value
|
||||
auto longest = (std::abs((impl->begin < 0 ? impl->begin * 10 : impl->begin)) < std::abs(impl->last < 0 ? impl->last * 10 : impl->last) ? impl->last : impl->begin);
|
||||
std::wstringstream ss;
|
||||
ss << longest;
|
||||
paint::graphics graph{ ::nana::size{ 10, 10 } };
|
||||
auto value_px = graph.text_extent_size(ss.str()).width + 34;
|
||||
|
||||
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.set_accept_real(); //deprecated
|
||||
|
||||
//Workaround for no implementation of std::to_wstring by MinGW.
|
||||
ss.str(L"");
|
||||
ss.clear();
|
||||
ss << impl->value;
|
||||
impl->spinbox.value(ss.str());
|
||||
|
||||
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->spinbox.events().destroy.connect_unignorable([impl]
|
||||
{
|
||||
impl->value = impl->spinbox.to_int();
|
||||
});
|
||||
|
||||
return impl->dock;
|
||||
}
|
||||
|
||||
unsigned inputbox::real::fixed_pixels() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
//end class real
|
||||
|
||||
|
||||
//class text
|
||||
struct inputbox::text::implement
|
||||
{
|
||||
::nana::string value;
|
||||
std::vector< ::nana::string> options;
|
||||
|
||||
::nana::string label_text;
|
||||
::nana::panel<false> dock;
|
||||
::nana::label label;
|
||||
::nana::combox combox;
|
||||
::nana::textbox textbox;
|
||||
};
|
||||
|
||||
inputbox::text::text(::nana::string label)
|
||||
: impl_(new implement)
|
||||
{
|
||||
impl_->label_text = std::move(label);
|
||||
}
|
||||
|
||||
inputbox::text::text(::nana::string label, std::vector<::nana::string> options)
|
||||
: impl_(new implement)
|
||||
{
|
||||
impl_->options.swap(options);
|
||||
impl_->label_text = std::move(label);
|
||||
}
|
||||
|
||||
//Instance for impl_ because implmenet is incomplete type at the point of declaration
|
||||
inputbox::text::~text(){}
|
||||
|
||||
::nana::string inputbox::text::value() const
|
||||
{
|
||||
return impl_->value;
|
||||
}
|
||||
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& inputbox::text::label() const
|
||||
{
|
||||
return impl_->label_text;
|
||||
}
|
||||
|
||||
window inputbox::text::create(window parent, unsigned label_px)
|
||||
{
|
||||
auto impl = impl_.get();
|
||||
impl->dock.create(parent);
|
||||
|
||||
impl->label.create(impl->dock, rectangle{ 0, 0, label_px, 0 });
|
||||
impl->label.text_align(::nana::align::right, ::nana::align_v::center);
|
||||
impl->label.caption(impl->label_text);
|
||||
impl->label.format(true);
|
||||
|
||||
unsigned value_px = 0;
|
||||
if (impl->options.empty())
|
||||
{
|
||||
impl->textbox.create(impl->dock, rectangle{ static_cast<int>(label_px + 10), 0, 0, 0 });
|
||||
}
|
||||
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)
|
||||
impl->combox.push_back(s);
|
||||
|
||||
impl->combox.option(0);
|
||||
}
|
||||
|
||||
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 });
|
||||
else
|
||||
impl->textbox.size({arg.width - label_px - 10, 24});
|
||||
});
|
||||
|
||||
auto & wdg = (value_px ? static_cast<widget&>(impl->combox) : static_cast<widget&>(impl->textbox));
|
||||
wdg.events().destroy.connect_unignorable([&wdg, impl]
|
||||
{
|
||||
impl->value = wdg.caption();
|
||||
});
|
||||
return impl->dock;
|
||||
}
|
||||
|
||||
unsigned inputbox::text::fixed_pixels() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
//end class text
|
||||
|
||||
|
||||
//class date
|
||||
struct inputbox::date::implement
|
||||
{
|
||||
int year;
|
||||
int month;
|
||||
int day;
|
||||
|
||||
::nana::string label_text;
|
||||
::nana::panel<false> dock;
|
||||
::nana::label label;
|
||||
::nana::combox wdg_month;
|
||||
::nana::spinbox wdg_day;
|
||||
::nana::spinbox wdg_year;
|
||||
};
|
||||
|
||||
inputbox::date::date(::nana::string label)
|
||||
: impl_(new implement)
|
||||
{
|
||||
impl_->label_text = std::move(label);
|
||||
}
|
||||
|
||||
//Instance for impl_ because implmenet is incomplete type at the point of declaration
|
||||
inputbox::date::~date(){}
|
||||
|
||||
::nana::string inputbox::date::value() const
|
||||
{
|
||||
std::wstringstream ss;
|
||||
ss << impl_->month << L'-' << impl_->day << L", " << impl_->year;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
int inputbox::date::year() const
|
||||
{
|
||||
return impl_->year;
|
||||
}
|
||||
|
||||
int inputbox::date::month() const
|
||||
{
|
||||
return impl_->month;
|
||||
}
|
||||
int inputbox::date::day() const
|
||||
{
|
||||
return impl_->day;
|
||||
}
|
||||
|
||||
//Implementation of abstract_content
|
||||
const ::nana::string& inputbox::date::label() const
|
||||
{
|
||||
return impl_->label_text;
|
||||
}
|
||||
|
||||
window inputbox::date::create(window parent, unsigned label_px)
|
||||
{
|
||||
auto today = ::nana::date().read();
|
||||
|
||||
auto impl = impl_.get();
|
||||
impl->dock.create(parent);
|
||||
|
||||
impl->label.create(impl->dock, rectangle{ 0, 0, label_px, 0 });
|
||||
impl->label.text_align(::nana::align::right, ::nana::align_v::center);
|
||||
impl->label.caption(impl->label_text);
|
||||
impl->label.format(true);
|
||||
|
||||
int left = static_cast<int>(label_px + 10);
|
||||
impl->wdg_month.create(impl->dock, rectangle{left, 0, 94, 0});
|
||||
|
||||
::nana::internationalization i18n;
|
||||
const char * monthstr[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
|
||||
for (auto i = std::begin(monthstr), end = std::end(monthstr); i != end; ++i)
|
||||
impl->wdg_month.push_back(i18n(*i));
|
||||
|
||||
left += 104;
|
||||
impl->wdg_day.create(impl->dock, rectangle{ left, 0, 38, 0 });
|
||||
impl->wdg_day.range(1, ::nana::date::month_days(today.year, today.month), 1);
|
||||
//impl->wdg_day.set_accept_integer(); //deprecated
|
||||
|
||||
left += 48;
|
||||
impl->wdg_year.create(impl->dock, rectangle{left, 0, 50, 0});
|
||||
impl->wdg_year.range(1601, 9999, 1);
|
||||
//impl->wdg_year.set_accept_integer(); //deprecated
|
||||
|
||||
impl->wdg_month.option(today.month - 1);
|
||||
|
||||
std::wstringstream ss;
|
||||
ss << today.day;
|
||||
impl->wdg_day.value(ss.str());
|
||||
ss.str(L"");
|
||||
ss.clear();
|
||||
ss << today.year;
|
||||
impl->wdg_year.value(ss.str());
|
||||
|
||||
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);
|
||||
|
||||
sz = impl->wdg_year.size();
|
||||
sz.height = 24;
|
||||
impl->wdg_year.size(sz);
|
||||
});
|
||||
|
||||
impl->wdg_day.events().destroy.connect_unignorable([impl]
|
||||
{
|
||||
impl->day = impl->wdg_day.to_int();
|
||||
impl->month = impl->wdg_month.option() + 1;
|
||||
});
|
||||
|
||||
impl->wdg_year.events().destroy.connect_unignorable([impl]
|
||||
{
|
||||
impl->year = impl->wdg_year.to_int();
|
||||
});
|
||||
|
||||
auto make_days = [impl]
|
||||
{
|
||||
auto month = impl->wdg_month.option() + 1;
|
||||
auto year = impl->wdg_year.to_int();
|
||||
int days = ::nana::date::month_days(year, month);
|
||||
|
||||
auto day = impl->wdg_day.to_int();
|
||||
impl->wdg_day.range(1, days, 1); //It resets the current value of wdg_day
|
||||
|
||||
if (day > days)
|
||||
day = days;
|
||||
|
||||
std::wstringstream ss;
|
||||
ss << day;
|
||||
impl->wdg_day.value(ss.str());
|
||||
};
|
||||
|
||||
impl->wdg_year.events().text_changed.connect_unignorable(make_days);
|
||||
impl->wdg_month.events().selected.connect_unignorable(make_days);
|
||||
|
||||
return impl->dock;
|
||||
}
|
||||
|
||||
unsigned inputbox::date::fixed_pixels() const
|
||||
{
|
||||
return 202;
|
||||
}
|
||||
//end class date
|
||||
|
||||
|
||||
inputbox::inputbox(window owner, ::nana::string desc, ::nana::string title)
|
||||
: owner_{ owner },
|
||||
description_(std::move(desc)),
|
||||
title_(std::move(title))
|
||||
{}
|
||||
|
||||
void inputbox::verify(std::function<bool(window)> verifier)
|
||||
{
|
||||
verifier_ = std::move(verifier);
|
||||
}
|
||||
|
||||
void inputbox::_m_fetch_args(std::vector<abstract_content*>&)
|
||||
{}
|
||||
|
||||
|
||||
bool inputbox::_m_open(std::vector<abstract_content*>& contents, bool modal)
|
||||
{
|
||||
std::vector<unsigned> each_pixels;
|
||||
unsigned label_px = 0, fixed_px = 0;
|
||||
paint::graphics graph({ 5, 5 });
|
||||
for (auto p : contents)
|
||||
{
|
||||
auto px = label::measure(graph, p->label(), 150, true, align::right, align_v::center);
|
||||
if (px.width > label_px)
|
||||
label_px = px.width;
|
||||
|
||||
px.width = p->fixed_pixels();
|
||||
if (px.width > fixed_px)
|
||||
fixed_px = px.width;
|
||||
|
||||
each_pixels.push_back(px.height);
|
||||
}
|
||||
|
||||
inputbox_window input_wd(owner_, description_, title_, contents.size(), label_px + 10 + fixed_px, each_pixels);
|
||||
|
||||
std::vector<window> inputs;
|
||||
for (auto p : contents)
|
||||
inputs.push_back(p->create(input_wd, label_px));
|
||||
|
||||
input_wd.set_input(inputs, verifier_);
|
||||
|
||||
if (modal)
|
||||
input_wd.modality();
|
||||
else
|
||||
API::wait_for(input_wd);
|
||||
|
||||
return input_wd.valid_input();
|
||||
}
|
||||
//end class inputbox
|
||||
}
|
||||
|
||||
@@ -1556,7 +1556,7 @@ namespace nana
|
||||
splitter_.cursor(splitter_cursor_);
|
||||
|
||||
dragger_.trigger(splitter_);
|
||||
splitter_.events().mouse_down.connect([this](const arg_mouse& arg)
|
||||
splitter_.events().mouse_down.connect_unignorable([this](const arg_mouse& arg)
|
||||
{
|
||||
if (false == arg.left_button)
|
||||
return;
|
||||
@@ -1584,7 +1584,7 @@ namespace nana
|
||||
right_pixels_ = area_right.*px_ptr;
|
||||
});
|
||||
|
||||
splitter_.events().mouse_move.connect([this](const arg_mouse& arg)
|
||||
splitter_.events().mouse_move.connect_unignorable([this](const arg_mouse& arg)
|
||||
{
|
||||
if (false == arg.left_button)
|
||||
return;
|
||||
|
||||
@@ -97,7 +97,9 @@ namespace API
|
||||
}
|
||||
|
||||
void effects_bground(window wd, const effects::bground_factory_interface& factory, double fade_rate)
|
||||
{
|
||||
{
|
||||
if (fade_rate < 0.0 || fade_rate > 1.0)
|
||||
throw std::invalid_argument("effects_bground: value range of fade_rate must be [0, 1].");
|
||||
auto const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||
internal_scope_guard isg;
|
||||
if(restrict::window_manager.available(iwd))
|
||||
@@ -110,6 +112,10 @@ namespace API
|
||||
iwd->effect.bground = new_effect_ptr;
|
||||
iwd->effect.bground_fade_rate = fade_rate;
|
||||
restrict::window_manager.enable_effects_bground(iwd, true);
|
||||
|
||||
if (fade_rate < 0.01)
|
||||
iwd->flags.make_bground_declared = true;
|
||||
|
||||
API::refresh_window(wd);
|
||||
}
|
||||
}
|
||||
@@ -150,14 +156,29 @@ namespace API
|
||||
return false;
|
||||
}
|
||||
|
||||
void set_scheme(window wd, widget_colors* wdg_colors)
|
||||
{
|
||||
auto iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if (restrict::window_manager.available(iwd))
|
||||
iwd->scheme = wdg_colors;
|
||||
}
|
||||
|
||||
widget_colors* get_scheme(window wd)
|
||||
{
|
||||
auto iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||
internal_scope_guard lock;
|
||||
return (restrict::window_manager.available(iwd) ? iwd->scheme : nullptr);
|
||||
}
|
||||
|
||||
void attach_drawer(widget& wd, drawer_trigger& dr)
|
||||
{
|
||||
const auto iwd = reinterpret_cast<restrict::core_window_t*>(wd.handle());
|
||||
internal_scope_guard isg;
|
||||
if(restrict::window_manager.available(iwd))
|
||||
{
|
||||
iwd->drawer.graphics.make(iwd->dimension.width, iwd->dimension.height);
|
||||
iwd->drawer.graphics.rectangle(iwd->color.background, true);
|
||||
iwd->drawer.graphics.make(iwd->dimension);
|
||||
iwd->drawer.graphics.rectangle(true, iwd->scheme->background.get_color());
|
||||
iwd->drawer.attached(wd, dr);
|
||||
iwd->drawer.refresh(); //Always redrawe no matter it is visible or invisible. This can make the graphics data correctly.
|
||||
}
|
||||
@@ -291,16 +312,6 @@ namespace API
|
||||
restrict::window_manager.unregister_shortkey(reinterpret_cast<restrict::core_window_t*>(wd), false);
|
||||
}
|
||||
|
||||
nana::size screen_size()
|
||||
{
|
||||
return restrict::interface_type::screen_size();
|
||||
}
|
||||
|
||||
rectangle screen_area_from_point(const point& pos)
|
||||
{
|
||||
return restrict::interface_type::screen_area_from_point(pos);
|
||||
}
|
||||
|
||||
nana::point cursor_position()
|
||||
{
|
||||
return restrict::interface_type::cursor_position();
|
||||
@@ -308,7 +319,7 @@ namespace API
|
||||
|
||||
nana::rectangle make_center(unsigned width, unsigned height)
|
||||
{
|
||||
nana::size screen = restrict::interface_type::screen_size();
|
||||
nana::size screen = restrict::interface_type::primary_monitor_size();
|
||||
nana::rectangle result(
|
||||
width > screen.width? 0: (screen.width - width)>>1,
|
||||
height > screen.height? 0: (screen.height - height)>> 1,
|
||||
@@ -343,6 +354,11 @@ namespace API
|
||||
return (restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)) == false);
|
||||
}
|
||||
|
||||
bool is_window(window wd)
|
||||
{
|
||||
return restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd));
|
||||
}
|
||||
|
||||
void enable_dropfiles(window wd, bool enb)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
@@ -529,9 +545,9 @@ namespace API
|
||||
}
|
||||
}
|
||||
|
||||
void bring_to_top(window wd)
|
||||
void bring_top(window wd, bool activated)
|
||||
{
|
||||
restrict::interface_type::bring_to_top(root(wd));
|
||||
restrict::interface_type::bring_top(root(wd), activated);
|
||||
}
|
||||
|
||||
bool set_window_z_order(window wd, window wd_after, z_order_action action_if_no_wd_after)
|
||||
@@ -558,6 +574,27 @@ namespace API
|
||||
return false;
|
||||
}
|
||||
|
||||
void draw_through(window wd, std::function<void()> draw_fn)
|
||||
{
|
||||
auto iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if (!restrict::bedrock.wd_manager.available(iwd))
|
||||
throw std::invalid_argument("draw_through: invalid window parameter");
|
||||
|
||||
if (::nana::category::flags::root != iwd->other.category)
|
||||
throw std::invalid_argument("draw_through: the window is not a root widget");
|
||||
|
||||
iwd->other.attribute.root->draw_through.swap(draw_fn);
|
||||
}
|
||||
|
||||
void map_through_widgets(window wd, native_drawable_type drawable)
|
||||
{
|
||||
auto iwd = reinterpret_cast<::nana::detail::basic_window*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if (restrict::bedrock.wd_manager.available(iwd) && iwd->is_draw_through() )
|
||||
restrict::bedrock.map_through_widgets(iwd, drawable);
|
||||
}
|
||||
|
||||
nana::size window_size(window wd)
|
||||
{
|
||||
nana::rectangle r;
|
||||
@@ -669,6 +706,12 @@ namespace API
|
||||
restrict::window_manager.update(reinterpret_cast<restrict::core_window_t*>(wd), false, true);
|
||||
}
|
||||
|
||||
|
||||
void window_caption(window wd, const std::string& title_utf8)
|
||||
{
|
||||
window_caption(wd, std::wstring(::nana::charset(title_utf8, ::nana::unicode::utf8)));
|
||||
}
|
||||
|
||||
void window_caption(window wd, const nana::string& title)
|
||||
{
|
||||
auto const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||
@@ -790,80 +833,85 @@ namespace API
|
||||
restrict::bedrock.pump_event(wd, false);
|
||||
}
|
||||
|
||||
nana::color_t foreground(window wd)
|
||||
color fgcolor(window wd)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
if(restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
|
||||
return reinterpret_cast<restrict::core_window_t*>(wd)->color.foreground;
|
||||
return 0;
|
||||
if (restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
|
||||
return reinterpret_cast<restrict::core_window_t*>(wd)->scheme->foreground.get_color();
|
||||
return{};
|
||||
}
|
||||
|
||||
color_t foreground(window wd, color_t col)
|
||||
color fgcolor(window wd, const color& clr)
|
||||
{
|
||||
auto iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if(restrict::window_manager.available(iwd))
|
||||
if (restrict::window_manager.available(iwd))
|
||||
{
|
||||
color_t prev = iwd->color.foreground;
|
||||
if(prev != col)
|
||||
auto prev = iwd->scheme->foreground.get_color();
|
||||
if (prev != clr)
|
||||
{
|
||||
iwd->color.foreground = col;
|
||||
iwd->scheme->foreground = clr;
|
||||
restrict::window_manager.update(iwd, true, false);
|
||||
}
|
||||
return prev;
|
||||
}
|
||||
return 0;
|
||||
return{};
|
||||
}
|
||||
|
||||
color_t background(window wd)
|
||||
color bgcolor(window wd)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
if(restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
|
||||
return reinterpret_cast<restrict::core_window_t*>(wd)->color.background;
|
||||
return 0;
|
||||
if (restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
|
||||
return reinterpret_cast<restrict::core_window_t*>(wd)->scheme->background.get_color();
|
||||
return{};
|
||||
}
|
||||
|
||||
color_t background(window wd, color_t col)
|
||||
color bgcolor(window wd, const color& clr)
|
||||
{
|
||||
auto iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if(restrict::window_manager.available(iwd))
|
||||
if (restrict::window_manager.available(iwd))
|
||||
{
|
||||
color_t prev = iwd->color.background;
|
||||
if(prev != col)
|
||||
auto prev = iwd->scheme->background.get_color();
|
||||
if (prev != clr)
|
||||
{
|
||||
iwd->color.background = col;
|
||||
iwd->scheme->background = clr;
|
||||
|
||||
//If the bground mode of this window is basic, it should remake the background
|
||||
if (iwd->effect.bground && iwd->effect.bground_fade_rate < 0.01) // fade rate < 0.01 means it is basic mode
|
||||
iwd->flags.make_bground_declared = true;
|
||||
|
||||
restrict::window_manager.update(iwd, true, false);
|
||||
}
|
||||
return prev;
|
||||
}
|
||||
return 0;
|
||||
return{};
|
||||
}
|
||||
|
||||
color_t active(window wd)
|
||||
color activated_color(window wd)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
if(restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
|
||||
return reinterpret_cast<restrict::core_window_t*>(wd)->color.active;
|
||||
return 0;
|
||||
if (restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
|
||||
return reinterpret_cast<restrict::core_window_t*>(wd)->scheme->activated.get_color();
|
||||
return{};
|
||||
}
|
||||
|
||||
color_t active(window wd, color_t col)
|
||||
color activated_color(window wd, const color& clr)
|
||||
{
|
||||
auto iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if(restrict::window_manager.available(iwd))
|
||||
if (restrict::window_manager.available(iwd))
|
||||
{
|
||||
color_t prev = iwd->color.active;
|
||||
if(prev != col)
|
||||
auto prev = iwd->scheme->activated.get_color();
|
||||
if (prev != clr)
|
||||
{
|
||||
iwd->color.active = col;
|
||||
iwd->scheme->activated = clr;
|
||||
restrict::window_manager.update(iwd, true, false);
|
||||
}
|
||||
return prev;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
return{};
|
||||
}
|
||||
|
||||
void create_caret(window wd, unsigned width, unsigned height)
|
||||
@@ -886,12 +934,12 @@ namespace API
|
||||
}
|
||||
}
|
||||
|
||||
void caret_pos(window wd, int x, int y)
|
||||
void caret_pos(window wd, const point& pos)
|
||||
{
|
||||
auto iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if(restrict::window_manager.available(iwd) && iwd->together.caret)
|
||||
iwd->together.caret->position(x, y);
|
||||
iwd->together.caret->position(pos.x, pos.y);
|
||||
}
|
||||
|
||||
nana::point caret_pos(window wd)
|
||||
|
||||
193
source/gui/screen.cpp
Normal file
193
source/gui/screen.cpp
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Screen Informations
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/gui/screen.cpp
|
||||
*/
|
||||
#include <nana/gui/screen.hpp>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <nana/gui/detail/native_window_interface.hpp>
|
||||
#include <nana/gui/programming_interface.hpp>
|
||||
#if defined(NANA_WINDOWS)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
namespace nana
|
||||
{
|
||||
//class display
|
||||
class real_display
|
||||
: public display
|
||||
{
|
||||
public:
|
||||
real_display(std::size_t number)
|
||||
: index_(number)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
DISPLAY_DEVICE disp;
|
||||
disp.cb = sizeof disp;
|
||||
if (::EnumDisplayDevices(nullptr, static_cast<DWORD>(index_), &disp, 0))
|
||||
{
|
||||
DEVMODE mode;
|
||||
mode.dmSize = sizeof mode;
|
||||
if (::EnumDisplaySettings(disp.DeviceName, ENUM_CURRENT_SETTINGS, &mode))
|
||||
{
|
||||
area_.x = mode.dmPosition.x;
|
||||
area_.y = mode.dmPosition.y;
|
||||
area_.width = mode.dmPelsWidth;
|
||||
area_.height = mode.dmPelsHeight;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (0 == index_)
|
||||
{
|
||||
area_ = detail::native_interface::primary_monitor_size();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
throw std::invalid_argument("Nana.Screen: Invalid monitor index.");
|
||||
}
|
||||
|
||||
real_display(std::size_t number, const ::nana::rectangle& r)
|
||||
: index_(number), area_(r)
|
||||
{
|
||||
}
|
||||
public:
|
||||
//Implementation of display
|
||||
std::size_t get_index() const override
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
const ::nana::rectangle& area() const override
|
||||
{
|
||||
return area_;
|
||||
}
|
||||
private:
|
||||
const std::size_t index_;
|
||||
::nana::rectangle area_;
|
||||
};
|
||||
|
||||
//class screen
|
||||
|
||||
::nana::size screen::desktop_size()
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
auto w = static_cast<size::value_type>(::GetSystemMetrics(SM_CXVIRTUALSCREEN));
|
||||
auto h = static_cast<size::value_type>(::GetSystemMetrics(SM_CYVIRTUALSCREEN));
|
||||
return{w, h};
|
||||
#else
|
||||
return ::nana::detail::native_interface::primary_monitor_size();
|
||||
#endif
|
||||
}
|
||||
|
||||
::nana::size screen::primary_monitor_size()
|
||||
{
|
||||
return ::nana::detail::native_interface::primary_monitor_size();
|
||||
}
|
||||
|
||||
std::shared_ptr<display> screen::from_point(const point& pos)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
typedef HMONITOR(__stdcall * MonitorFromPointT)(POINT, DWORD);
|
||||
|
||||
MonitorFromPointT mfp = reinterpret_cast<MonitorFromPointT>(::GetProcAddress(::GetModuleHandleA("User32.DLL"), "MonitorFromPoint"));
|
||||
if (mfp)
|
||||
{
|
||||
POINT native_pos = { pos.x, pos.y };
|
||||
HMONITOR monitor = mfp(native_pos, 2 /*MONITOR_DEFAULTTONEAREST*/);
|
||||
|
||||
MONITORINFO mi;
|
||||
mi.cbSize = sizeof mi;
|
||||
if (::GetMonitorInfo(monitor, &mi))
|
||||
{
|
||||
DISPLAY_DEVICE disp;
|
||||
disp.cb = sizeof disp;
|
||||
|
||||
DWORD index = 0;
|
||||
while (::EnumDisplayDevices(nullptr, index++, &disp, 0))
|
||||
{
|
||||
DEVMODE mode;
|
||||
mode.dmSize = sizeof mode;
|
||||
if (::EnumDisplaySettings(disp.DeviceName, ENUM_CURRENT_SETTINGS, &mode))
|
||||
{
|
||||
if (mode.dmPosition.x == mi.rcWork.left && mode.dmPosition.y == mi.rcWork.top &&
|
||||
(static_cast<int>(mode.dmPelsWidth) == mi.rcWork.right - mi.rcWork.left) &&
|
||||
(static_cast<int>(mode.dmPelsHeight) == mi.rcWork.bottom - mi.rcWork.top))
|
||||
{
|
||||
return std::make_shared<real_display>(static_cast<std::size_t>(index - 1), rectangle{ mode.dmPosition.x, mode.dmPosition.y, static_cast<unsigned>(mode.dmPelsWidth), static_cast<unsigned>(mode.dmPelsHeight) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return screen().get_primary();
|
||||
}
|
||||
|
||||
std::shared_ptr<display> screen::from_window(window wd)
|
||||
{
|
||||
::nana::point pos;
|
||||
API::calc_screen_point(wd, pos);
|
||||
return from_point(pos);
|
||||
}
|
||||
|
||||
std::size_t screen::count() const
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
DISPLAY_DEVICE disp;
|
||||
disp.cb = sizeof disp;
|
||||
|
||||
DWORD index = 0;
|
||||
while (::EnumDisplayDevices(nullptr, index++, &disp, 0));
|
||||
return static_cast<std::size_t>(index - 1);
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::shared_ptr<display> screen::get_display(std::size_t index) const
|
||||
{
|
||||
return std::make_shared<real_display>(index);
|
||||
}
|
||||
|
||||
std::shared_ptr<display> screen::get_primary() const
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
//return rectangle(mi.rcWork.left, mi.rcWork.top,
|
||||
// mi.rcWork.right - mi.rcWork.left, mi.rcWork.bottom - mi.rcWork.top);
|
||||
DISPLAY_DEVICE disp;
|
||||
disp.cb = sizeof disp;
|
||||
|
||||
DWORD index = 0;
|
||||
while (::EnumDisplayDevices(nullptr, index++, &disp, 0))
|
||||
{
|
||||
DEVMODE mode;
|
||||
mode.dmSize = sizeof mode;
|
||||
if (::EnumDisplaySettings(disp.DeviceName, ENUM_CURRENT_SETTINGS, &mode))
|
||||
{
|
||||
if (mode.dmPosition.x == 0 && mode.dmPosition.y == 0)
|
||||
return std::make_shared<real_display>(static_cast<std::size_t>(index - 1), rectangle{ mode.dmPosition.x, mode.dmPosition.y, static_cast<unsigned>(mode.dmPelsWidth), static_cast<unsigned>(mode.dmPelsHeight) });
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return std::make_shared<real_display>(0);
|
||||
}
|
||||
|
||||
void screen::for_each(std::function<void(display&)> fn) const
|
||||
{
|
||||
auto n = count();
|
||||
for (decltype(n) i = 0; i < n; ++i)
|
||||
{
|
||||
real_display disp(i);
|
||||
fn(disp);
|
||||
}
|
||||
}
|
||||
//end class screen
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <nana/gui/tooltip.hpp>
|
||||
#include <nana/gui/widgets/label.hpp>
|
||||
#include <nana/gui/timer.hpp>
|
||||
#include <nana/gui/screen.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace nana
|
||||
@@ -26,14 +27,14 @@ namespace nana
|
||||
private:
|
||||
void refresh(graph_reference graph)
|
||||
{
|
||||
graph.rectangle(0x0, false);
|
||||
graph.rectangle(1, 1, graph.width() - 2, graph.height() - 2, 0xF0F0F0, true);
|
||||
graph.rectangle(false, colors::black);
|
||||
graph.rectangle(::nana::rectangle(graph.size()).pare_off(1), true, {0xf0, 0xf0, 0xf0});
|
||||
}
|
||||
};
|
||||
|
||||
nana::point pos_by_screen(nana::point pos, const nana::size& sz, bool overlap_allowed)
|
||||
{
|
||||
auto scr_area = API::screen_area_from_point(pos);
|
||||
auto scr_area = screen::from_point(pos)->area();
|
||||
if (pos.x + sz.width > scr_area.x + scr_area.width)
|
||||
pos.x = static_cast<int>(scr_area.x + scr_area.width - sz.width);
|
||||
if (pos.x < scr_area.x)
|
||||
@@ -76,7 +77,7 @@ namespace nana
|
||||
void tooltip_text(const nana::string& text) override
|
||||
{
|
||||
label_.caption(text);
|
||||
auto text_s = label_.measure(API::screen_size().width * 2 / 3);
|
||||
auto text_s = label_.measure(screen::from_window(label_)->area().width * 2 / 3);
|
||||
this->size(nana::size{ text_s.width + 10, text_s.height + 10 });
|
||||
label_.move(rectangle{ 5, 5, text_s.width, text_s.height });
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Button Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -20,12 +20,8 @@ namespace nana{ namespace drawerbase
|
||||
//trigger
|
||||
//@brief: draw the button
|
||||
trigger::trigger()
|
||||
: widget_(nullptr),
|
||||
graph_(nullptr),
|
||||
cite_("button")
|
||||
{
|
||||
attr_.e_state = element_state::normal;
|
||||
|
||||
attr_.omitted = attr_.focused = attr_.pushed = attr_.enable_pushed = attr_.keep_pressed = false;
|
||||
attr_.focus_color = true;
|
||||
attr_.icon = nullptr;
|
||||
@@ -40,7 +36,7 @@ namespace nana{ namespace drawerbase
|
||||
{
|
||||
graph_ = &graph;
|
||||
|
||||
widget_ = &widget;
|
||||
wdg_ = &widget;
|
||||
window wd = widget;
|
||||
|
||||
API::tabstop(wd);
|
||||
@@ -61,7 +57,7 @@ namespace nana{ namespace drawerbase
|
||||
attr_.pushed = pshd;
|
||||
if(false == pshd)
|
||||
{
|
||||
if (API::find_window(API::cursor_position()) == widget_->handle())
|
||||
if (API::find_window(API::cursor_position()) == wdg_->handle())
|
||||
attr_.e_state = element_state::hovered;
|
||||
else
|
||||
attr_.e_state = element_state::normal;
|
||||
@@ -128,13 +124,13 @@ namespace nana{ namespace drawerbase
|
||||
attr_.keep_pressed = true;
|
||||
|
||||
_m_draw(graph);
|
||||
API::capture_window(*widget_, true);
|
||||
API::capture_window(*wdg_, true);
|
||||
API::lazy_refresh();
|
||||
}
|
||||
|
||||
void trigger::mouse_up(graph_reference graph, const arg_mouse&)
|
||||
{
|
||||
API::capture_window(*widget_, false);
|
||||
API::capture_window(*wdg_, false);
|
||||
attr_.keep_pressed = false;
|
||||
if(attr_.enable_pushed && (false == attr_.pushed))
|
||||
{
|
||||
@@ -173,7 +169,7 @@ namespace nana{ namespace drawerbase
|
||||
default:
|
||||
return;
|
||||
}
|
||||
API::move_tabstop(widget_->handle(), ch_tabstop_next);
|
||||
API::move_tabstop(*wdg_, ch_tabstop_next);
|
||||
}
|
||||
|
||||
void trigger::focus(graph_reference graph, const arg_focus& arg)
|
||||
@@ -185,7 +181,7 @@ namespace nana{ namespace drawerbase
|
||||
|
||||
void trigger::_m_draw_title(graph_reference graph, bool enabled)
|
||||
{
|
||||
nana::string text = widget_->caption();
|
||||
nana::string text = wdg_->caption();
|
||||
|
||||
nana::string::value_type shortkey;
|
||||
nana::string::size_type shortkey_pos;
|
||||
@@ -201,11 +197,12 @@ namespace nana{ namespace drawerbase
|
||||
icon_sz.width += 5;
|
||||
}
|
||||
|
||||
int x = (static_cast<int>(gsize.width - 1 - ts.width) >> 1);
|
||||
int y = (static_cast<int>(gsize.height - 1 - ts.height) >> 1);
|
||||
nana::point pos{
|
||||
static_cast<int>(gsize.width - 1 - ts.width) >> 1, static_cast<int>(gsize.height - 1 - ts.height) >> 1
|
||||
};
|
||||
|
||||
if(x < static_cast<int>(icon_sz.width))
|
||||
x = static_cast<int>(icon_sz.width);
|
||||
if(pos.x < static_cast<int>(icon_sz.width))
|
||||
pos.x = static_cast<int>(icon_sz.width);
|
||||
|
||||
unsigned omitted_pixels = gsize.width - icon_sz.width;
|
||||
std::size_t txtlen = str.size();
|
||||
@@ -217,35 +214,45 @@ namespace nana{ namespace drawerbase
|
||||
{
|
||||
if (element_state::pressed == attr_.e_state)
|
||||
{
|
||||
++x;
|
||||
++y;
|
||||
++pos.x;
|
||||
++pos.y;
|
||||
}
|
||||
color_t fgcolor = (attr_.focus_color ? (attr_.focused ? 0xFF : attr_.fgcolor) : attr_.fgcolor);
|
||||
if(attr_.omitted)
|
||||
tr.render(x, y, fgcolor, txtptr, txtlen, omitted_pixels, true);
|
||||
//color_t fgcolor = (attr_.focus_color ? (attr_.focused ? 0xFF : attr_.fgcolor) : attr_.fgcolor);
|
||||
auto fgcolor = attr_.fgcolor;
|
||||
if (attr_.focus_color && attr_.focused)
|
||||
fgcolor = ::nana::color(colors::blue);
|
||||
|
||||
graph.set_text_color(fgcolor);
|
||||
|
||||
if (attr_.omitted)
|
||||
tr.render(pos, txtptr, txtlen, omitted_pixels, true);
|
||||
else
|
||||
graph.bidi_string(x, y, fgcolor, txtptr, txtlen);
|
||||
graph.bidi_string(pos, txtptr, txtlen);
|
||||
|
||||
if(shortkey)
|
||||
{
|
||||
unsigned off_w = (shortkey_pos ? graph.text_extent_size(str, static_cast<unsigned>(shortkey_pos)).width : 0);
|
||||
nana::size shortkey_size = graph.text_extent_size(txtptr + shortkey_pos, 1);
|
||||
x += off_w;
|
||||
y += shortkey_size.height;
|
||||
graph.line(x, y, x + shortkey_size.width - 1, y, 0x0);
|
||||
pos.x += off_w;
|
||||
pos.y += static_cast<int>(shortkey_size.height);
|
||||
graph.set_color(colors::black);
|
||||
graph.line(pos, point{ pos.x + static_cast<int>(shortkey_size.width) - 1, pos.y });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
graph.set_text_color(::nana::color(colors::white));
|
||||
if(attr_.omitted)
|
||||
{
|
||||
tr.render(x + 1, y + 1, 0xFFFFFF, txtptr, txtlen, omitted_pixels, true);
|
||||
tr.render(x, y, 0x808080, txtptr, txtlen, omitted_pixels, true);
|
||||
tr.render(point{ pos.x + 1, pos.y + 1 }, txtptr, txtlen, omitted_pixels, true);
|
||||
graph.set_text_color(::nana::color(colors::gray));
|
||||
tr.render(pos, txtptr, txtlen, omitted_pixels, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
graph.bidi_string(x + 1, y + 1, 0xFFFFFF, txtptr, txtlen);
|
||||
graph.bidi_string(x, y, 0x808080, txtptr, txtlen);
|
||||
graph.bidi_string(point{ pos.x + 1, pos.y + 1 }, txtptr, txtlen);
|
||||
graph.set_text_color(::nana::color(colors::gray));
|
||||
graph.bidi_string(pos, txtptr, txtlen);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,11 +263,10 @@ namespace nana{ namespace drawerbase
|
||||
|
||||
void trigger::_m_draw(graph_reference graph)
|
||||
{
|
||||
window wd = widget_->handle();
|
||||
bool eb = API::window_enabled(wd);
|
||||
bool eb = wdg_->enabled();;
|
||||
|
||||
attr_.bgcolor = API::background(wd);
|
||||
attr_.fgcolor = API::foreground(wd);
|
||||
attr_.bgcolor = wdg_->bgcolor();
|
||||
attr_.fgcolor = wdg_->fgcolor();
|
||||
|
||||
element_state e_state = attr_.e_state;
|
||||
if (eb)
|
||||
@@ -278,7 +284,7 @@ namespace nana{ namespace drawerbase
|
||||
|
||||
if (false == cite_.draw(graph, attr_.bgcolor, attr_.fgcolor, graph.size(), e_state))
|
||||
{
|
||||
if (bground_mode::basic != API::effects_bground_mode(wd))
|
||||
if (bground_mode::basic != API::effects_bground_mode(wdg_->handle()))
|
||||
{
|
||||
_m_draw_background(graph);
|
||||
_m_draw_border(graph);
|
||||
@@ -291,15 +297,16 @@ namespace nana{ namespace drawerbase
|
||||
{
|
||||
nana::rectangle r(graph.size());
|
||||
r.pare_off(1);
|
||||
nana::color_t color_start = nana::paint::graphics::mix(attr_.bgcolor, 0xFFFFFF, 0.2);
|
||||
nana::color_t color_end = nana::paint::graphics::mix(attr_.bgcolor, 0x0, 0.95);
|
||||
|
||||
auto from = attr_.bgcolor.blend(colors::white, 0.2);
|
||||
auto to = attr_.bgcolor.blend(colors::black, 0.95);
|
||||
|
||||
if (element_state::pressed == attr_.e_state)
|
||||
{
|
||||
r.x = r.y = 2;
|
||||
std::swap(color_start, color_end);
|
||||
std::swap(from, to);
|
||||
}
|
||||
graph.shadow_rectangle(r, color_start, color_end, true);
|
||||
graph.gradual_rectangle(r, from, to, true);
|
||||
}
|
||||
|
||||
void trigger::_m_draw_border(graph_reference graph)
|
||||
@@ -308,28 +315,30 @@ namespace nana{ namespace drawerbase
|
||||
int right = r.width - 1;
|
||||
int bottom = r.height - 1;
|
||||
|
||||
graph.rectangle_line(r,
|
||||
0x7F7F7F, 0x7F7F7F, 0x707070, 0x707070);
|
||||
::nana::color lt{0x7f,0x7f,0x7f}, rb{0x70,0x70,0x70};
|
||||
graph.frame_rectangle(r, lt, lt, rb, rb);
|
||||
|
||||
graph.set_pixel(1, 1, 0x919191);
|
||||
graph.set_pixel(right - 1, 1, 0x919191);
|
||||
graph.set_pixel(right - 1, bottom - 1, 0x919191);
|
||||
graph.set_pixel(1, bottom - 1, 0x919191);
|
||||
graph.set_color({0x91,0x91,0x91});
|
||||
graph.set_pixel(1, 1);
|
||||
graph.set_pixel(right - 1, 1);
|
||||
graph.set_pixel(right - 1, bottom - 1);
|
||||
graph.set_pixel(1, bottom - 1);
|
||||
|
||||
graph.set_pixel(0, 0, color::button_face);
|
||||
graph.set_pixel(right, 0, color::button_face);
|
||||
graph.set_pixel(0, bottom, color::button_face);
|
||||
graph.set_pixel(right, bottom, color::button_face);
|
||||
graph.set_color(colors::button_face);
|
||||
graph.set_pixel(0, 0);
|
||||
graph.set_pixel(right, 0);
|
||||
graph.set_pixel(0, bottom);
|
||||
graph.set_pixel(right, bottom);
|
||||
|
||||
if (element_state::pressed == attr_.e_state)
|
||||
graph.rectangle(r.pare_off(1), 0xC3C3C3, false);
|
||||
graph.rectangle(r.pare_off(1), false, {0xc3, 0xc3, 0xc3});
|
||||
}
|
||||
|
||||
void trigger::emit_click()
|
||||
{
|
||||
arg_mouse arg;
|
||||
arg.evt_code = event_code::click;
|
||||
arg.window_handle = widget_->handle();
|
||||
arg.window_handle = wdg_->handle();
|
||||
arg.ctrl = arg.shift = false;
|
||||
arg.mid_button = arg.right_button = false;
|
||||
arg.left_button = true;
|
||||
@@ -470,7 +479,7 @@ namespace nana{ namespace drawerbase
|
||||
|
||||
void button::_m_complete_creation()
|
||||
{
|
||||
events().shortkey.connect([this]
|
||||
events().shortkey.connect_unignorable([this]
|
||||
{
|
||||
_m_shortkey();
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Categorize Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <nana/gui/wvl.hpp>
|
||||
#include <nana/gui/widgets/categorize.hpp>
|
||||
#include <nana/gui/widgets/float_listbox.hpp>
|
||||
#include <nana/gui/element.hpp>
|
||||
#include <nana/paint/gadget.hpp>
|
||||
#include <nana/gui/widgets/detail/tree_cont.hpp>
|
||||
#include <stdexcept>
|
||||
@@ -73,35 +74,36 @@ namespace nana
|
||||
void background(graph_reference graph, window wd, const nana::rectangle& r, const ui_element& ue)
|
||||
{
|
||||
ui_el_ = ue;
|
||||
style_.bgcolor = API::background(wd);
|
||||
style_.fgcolor = API::foreground(wd);
|
||||
style_.bgcolor = API::bgcolor(wd);
|
||||
style_.fgcolor = API::fgcolor(wd);
|
||||
|
||||
if(ue.what == ue.none || (API::window_enabled(wd) == false))
|
||||
{ //the mouse is out of the widget.
|
||||
style_.bgcolor = nana::paint::graphics::mix(style_.bgcolor, 0xA0C9F5, 0.9);
|
||||
style_.bgcolor = style_.bgcolor.blend(color{ 0xa0, 0xc9, 0xf5 }, 0.9);
|
||||
}
|
||||
graph.rectangle(r, style_.bgcolor, true);
|
||||
graph.rectangle(r, true, style_.bgcolor);
|
||||
}
|
||||
|
||||
virtual void root_arrow(graph_reference graph, const nana::rectangle& r, mouse_action state)
|
||||
{
|
||||
int x = r.x + (r.width - 16) / 2;
|
||||
int y = r.y + (r.height - 16) / 2;
|
||||
::nana::rectangle arrow_r{r.x + static_cast<int>(r.width - 16) / 2, r.y + static_cast<int>(r.height - 16) / 2, 16, 16};
|
||||
|
||||
if(ui_el_.what == ui_el_.item_root)
|
||||
{
|
||||
_m_item_bground(graph, r.x + 1, r.y, r.width - 2, r.height, (state == mouse_action::pressed ? mouse_action::pressed : mouse_action::over));
|
||||
graph.rectangle(r, 0x3C7FB1, false);
|
||||
graph.rectangle(r, false, color{ 0x3C, 0x7F, 0xB1 });
|
||||
if(state == mouse_action::pressed)
|
||||
{
|
||||
++x;
|
||||
++y;
|
||||
++arrow_r.x;
|
||||
++arrow_r.y;
|
||||
}
|
||||
}
|
||||
else
|
||||
graph.rectangle(r, style_.bgcolor, true);
|
||||
graph.rectangle(r, true, style_.bgcolor);
|
||||
|
||||
nana::paint::gadget::arrow_16_pixels(graph, x, y,
|
||||
style_.fgcolor, 3, nana::paint::gadget::directions::to_west);
|
||||
facade<element::arrow> arrow("double");
|
||||
arrow.direction(::nana::direction::west);
|
||||
arrow.draw(graph, {}, style_.fgcolor, arrow_r, element_state::normal);
|
||||
}
|
||||
|
||||
void item(graph_reference graph, const nana::rectangle& r, std::size_t index, const nana::string& name, unsigned txtheight, bool has_child, mouse_action state)
|
||||
@@ -126,31 +128,39 @@ namespace nana
|
||||
int top = r.y + 1;
|
||||
unsigned width = r.width - 2;
|
||||
unsigned height = r.height - 2;
|
||||
|
||||
::nana::color clr{ 0x3C, 0x7F, 0xB1 };
|
||||
if(has_child)
|
||||
{
|
||||
int left = r.x + r.width - 16;
|
||||
_m_item_bground(graph, left, top, 15, height, state_arrow);
|
||||
width -= 16;
|
||||
--left;
|
||||
graph.line(left, top, left, r.y + height, 0x3C7FB1);
|
||||
|
||||
int left = r.x + r.width - 17;
|
||||
_m_item_bground(graph, left + 1, top, 15, height, state_arrow);
|
||||
graph.line({ left, top }, { left, r.y + static_cast<int>(height) }, clr);
|
||||
}
|
||||
|
||||
_m_item_bground(graph, r.x + 1, top, width, height, state_name);
|
||||
graph.rectangle(r, 0x3C7FB1, false);
|
||||
graph.rectangle(r, false, clr);
|
||||
}
|
||||
graph.string(strpos.x, strpos.y, style_.fgcolor, name);
|
||||
graph.string(strpos, name, style_.fgcolor);
|
||||
|
||||
if(has_child)
|
||||
{
|
||||
nana::paint::gadget::arrow_16_pixels(graph, r.x + r.width - 16, r.y + (r.height - 16)/2,
|
||||
style_.fgcolor, 3, nana::paint::gadget::directions::to_east);
|
||||
facade<element::arrow> arrow("double");
|
||||
arrow.direction(::nana::direction::east);
|
||||
arrow.draw(graph, {}, style_.fgcolor, { r.right() - 16, r.y + static_cast<int>(r.height - 16) / 2, 16, 16 }, element_state::normal);
|
||||
}
|
||||
}
|
||||
|
||||
void border(graph_reference graph)
|
||||
{
|
||||
graph.rectangle(0xF0F0F0, false);
|
||||
graph.rectangle_line(nana::rectangle(graph.size()).pare_off(1),
|
||||
0x9DABB9, 0x484E55, 0x484E55, 0x9DABB9);
|
||||
rectangle r{ graph.size() };
|
||||
|
||||
graph.rectangle(r, false, { 0xf0, 0xf0, 0xf0 });
|
||||
|
||||
color lb(0x9d, 0xab, 0xb9);
|
||||
color tr(0x48, 0x4e, 0x55);
|
||||
graph.frame_rectangle(r.pare_off(1), lb, tr, tr, lb);
|
||||
}
|
||||
private:
|
||||
void _m_item_bground(graph_reference graph, int x, int y, unsigned width, unsigned height, mouse_action state)
|
||||
@@ -158,38 +168,38 @@ namespace nana
|
||||
const unsigned half = (height - 2) / 2;
|
||||
int left = x + 1;
|
||||
int top = y + 1;
|
||||
nana::color_t upcol, downcol;
|
||||
nana::color clr_top(0xea, 0xea, 0xea), clr_bottom(0xdc, 0xdc, 0xdc);
|
||||
switch(state)
|
||||
{
|
||||
case mouse_action::over:
|
||||
upcol = 0x0DFF2FC;
|
||||
downcol = 0xA9DAF5;
|
||||
clr_top.from_rgb(0xdf, 0xf2, 0xfc);
|
||||
clr_bottom.from_rgb(0xa9, 0xda, 0xf5);
|
||||
break;
|
||||
case mouse_action::pressed:
|
||||
upcol = 0xA6D7F2;
|
||||
downcol = 0x92C4F6;
|
||||
clr_top.from_rgb(0xa6, 0xd7, 0xf2);
|
||||
clr_bottom.from_rgb(0x92, 0xc4, 0xf6);
|
||||
++left;
|
||||
++top;
|
||||
break;
|
||||
case mouse_action::normal:
|
||||
default:
|
||||
upcol = 0xEAEAEA;
|
||||
downcol = 0xDCDCDC;
|
||||
break;
|
||||
}
|
||||
|
||||
graph.rectangle(left, top, width - 2, half, upcol, true);
|
||||
graph.rectangle(left, top + static_cast<int>(half), width - 2, (height - 2) - half, downcol, true);
|
||||
graph.rectangle(rectangle{ left, top, width - 2, half }, true, clr_top);
|
||||
graph.rectangle(rectangle{ left, top + static_cast<int>(half), width - 2, (height - 2) - half }, true, clr_bottom);
|
||||
if(mouse_action::pressed == state)
|
||||
{
|
||||
int bottom = y + height - 1;
|
||||
int right = x + width - 1;
|
||||
graph.line(x, y, right, y, 0x6E8D9F);
|
||||
graph.line(x, y + 1, x, bottom, 0x6E8D9F);
|
||||
|
||||
graph.set_color(color(0x6e, 0x8d, 0x9f));
|
||||
graph.line(point{ x, y }, point{right, y});
|
||||
graph.line(point{ x, y + 1 }, point{ x, bottom });
|
||||
++x;
|
||||
++y;
|
||||
graph.line(x, y, right, y, 0xA6C7D9);
|
||||
graph.line(x, y + 1, x, bottom, 0xA6C7D9);
|
||||
graph.set_color(color(0xa6, 0xc7, 0xd9));
|
||||
graph.line(point{ x, y }, point{ right, y });
|
||||
graph.line(point{ x, y + 1 }, point{ x, bottom });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,8 +207,10 @@ namespace nana
|
||||
ui_element ui_el_;
|
||||
struct style_tag
|
||||
{
|
||||
nana::color_t bgcolor;
|
||||
nana::color_t fgcolor;
|
||||
//nana::color_t bgcolor;
|
||||
//nana::color_t fgcolor;
|
||||
color bgcolor;
|
||||
color fgcolor;
|
||||
}style_;
|
||||
};
|
||||
|
||||
@@ -369,7 +381,6 @@ namespace nana
|
||||
};
|
||||
|
||||
scheme()
|
||||
: graph_(nullptr)
|
||||
{
|
||||
proto_.ui_renderer = pat::cloneable<renderer>(interior_renderer());
|
||||
style_.mode = mode::normal;
|
||||
@@ -379,7 +390,7 @@ namespace nana
|
||||
void attach(window wd, nana::paint::graphics* graph)
|
||||
{
|
||||
window_ = wd;
|
||||
API::background(wd, 0xFFFFFF);
|
||||
API::bgcolor(wd, colors::white);
|
||||
graph_ = graph;
|
||||
}
|
||||
|
||||
@@ -582,7 +593,7 @@ namespace nana
|
||||
r.width = r.height = 100;
|
||||
style_.listbox = &(form_loader<nana::float_listbox>()(window_, r, true));
|
||||
style_.listbox->set_module(style_.module, 16);
|
||||
style_.listbox->events().destroy.connect([this]
|
||||
style_.listbox->events().destroy.connect_unignorable([this]
|
||||
{
|
||||
_m_list_closed();
|
||||
});
|
||||
@@ -637,7 +648,7 @@ namespace nana
|
||||
|
||||
nana::rectangle _m_make_root_rectangle() const
|
||||
{
|
||||
return nana::rectangle(1, 1, 16, _m_item_fix_scale());
|
||||
return{ 1, 1, 16, _m_item_fix_scale() };
|
||||
}
|
||||
|
||||
//_m_make_rectangle
|
||||
@@ -765,8 +776,8 @@ namespace nana
|
||||
}
|
||||
}
|
||||
private:
|
||||
window window_;
|
||||
nana::paint::graphics * graph_;
|
||||
window window_{nullptr};
|
||||
nana::paint::graphics * graph_{nullptr};
|
||||
nana::string splitstr_;
|
||||
std::size_t head_;
|
||||
unsigned item_height_;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* A CheckBox Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -88,31 +89,33 @@ namespace checkbox
|
||||
void drawer::_m_draw_background(graph_reference graph)
|
||||
{
|
||||
if(bground_mode::basic != API::effects_bground_mode(*widget_))
|
||||
graph.rectangle(API::background(*widget_), true);
|
||||
graph.rectangle(true, API::bgcolor(*widget_));
|
||||
}
|
||||
|
||||
void drawer::_m_draw_checkbox(graph_reference graph, unsigned first_line_height)
|
||||
{
|
||||
impl_->crook.draw(graph, widget_->background(), widget_->foreground(), rectangle(0, first_line_height > 16 ? (first_line_height - 16) / 2 : 0, 16, 16), API::element_state(*widget_));
|
||||
impl_->crook.draw(graph, widget_->bgcolor(), widget_->fgcolor(), rectangle(0, first_line_height > 16 ? (first_line_height - 16) / 2 : 0, 16, 16), API::element_state(*widget_));
|
||||
}
|
||||
|
||||
void drawer::_m_draw_title(graph_reference graph)
|
||||
{
|
||||
if(graph.width() > 16 + interval)
|
||||
if (graph.width() > 16 + interval)
|
||||
{
|
||||
nana::string title = widget_->caption();
|
||||
|
||||
unsigned fgcolor = widget_->foreground();
|
||||
unsigned pixels = graph.width() - (16 + interval);
|
||||
|
||||
nana::paint::text_renderer tr(graph);
|
||||
if(API::window_enabled(widget_->handle()) == false)
|
||||
if (API::window_enabled(widget_->handle()) == false)
|
||||
{
|
||||
tr.render(17 + interval, 2, 0xFFFFFF, title.c_str(), title.length(), pixels);
|
||||
fgcolor = 0x808080;
|
||||
graph.set_text_color(colors::white);
|
||||
tr.render({ 17 + interval, 2 }, title.c_str(), title.length(), pixels);
|
||||
graph.set_text_color({ 0x80, 0x80, 0x80 });
|
||||
}
|
||||
else
|
||||
graph.set_text_color(widget_->fgcolor());
|
||||
|
||||
tr.render(16 + interval, 1, fgcolor, title.c_str(), title.length(), pixels);
|
||||
tr.render({ 16 + interval, 1 }, title.c_str(), title.length(), pixels);
|
||||
}
|
||||
}
|
||||
//end class drawer
|
||||
@@ -205,8 +208,8 @@ namespace checkbox
|
||||
element_tag el;
|
||||
|
||||
el.uiobj = &uiobj;
|
||||
el.eh_checked = uiobj.events().click.connect_front(std::bind(&radio_group::_m_checked, this, std::placeholders::_1));
|
||||
el.eh_destroy = uiobj.events().destroy.connect(std::bind(&radio_group::_m_destroy, this, std::placeholders::_1));
|
||||
el.eh_checked = uiobj.events().click.connect_unignorable(std::bind(&radio_group::_m_checked, this, std::placeholders::_1), true);
|
||||
el.eh_destroy = uiobj.events().destroy.connect_unignorable(std::bind(&radio_group::_m_destroy, this, std::placeholders::_1));
|
||||
ui_container_.push_back(el);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Combox Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -10,19 +10,41 @@
|
||||
* @file: nana/gui/widgets/combox.cpp
|
||||
*/
|
||||
|
||||
#include <nana/gui/wvl.hpp>
|
||||
#include <nana/gui.hpp>
|
||||
#include <nana/gui/widgets/combox.hpp>
|
||||
#include <nana/paint/gadget.hpp>
|
||||
#include <nana/gui/element.hpp>
|
||||
#include <nana/system/dataexch.hpp>
|
||||
#include <nana/gui/widgets/float_listbox.hpp>
|
||||
#include <nana/gui/widgets/skeletons/text_editor.hpp>
|
||||
#include <nana/gui/widgets/skeletons/textbase_export_interface.hpp>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
arg_combox::arg_combox(combox& wdg): widget(wdg)
|
||||
{}
|
||||
|
||||
namespace drawerbase
|
||||
{
|
||||
namespace combox
|
||||
{
|
||||
class event_agent
|
||||
: public widgets::skeletons::textbase_event_agent_interface
|
||||
{
|
||||
public:
|
||||
event_agent(::nana::combox& wdg)
|
||||
: widget_(wdg)
|
||||
{}
|
||||
|
||||
void first_change() override{} //empty, because combox does not have this event.
|
||||
|
||||
void text_changed() override
|
||||
{
|
||||
widget_.events().text_changed.emit(::nana::arg_combox{ widget_ });
|
||||
}
|
||||
private:
|
||||
::nana::combox & widget_;
|
||||
};
|
||||
|
||||
struct item
|
||||
: public float_listbox::item_interface
|
||||
{
|
||||
@@ -38,8 +60,8 @@ namespace nana
|
||||
{
|
||||
}
|
||||
|
||||
item(const nana::string& s)
|
||||
: item_text(s)
|
||||
item(nana::string&& s)
|
||||
: item_text(std::move(s))
|
||||
{}
|
||||
private:
|
||||
//implement item_interface methods
|
||||
@@ -57,25 +79,19 @@ namespace nana
|
||||
class drawer_impl
|
||||
{
|
||||
public:
|
||||
typedef nana::paint::graphics & graph_reference;
|
||||
typedef widget & widget_reference;
|
||||
using graph_reference = paint::graphics&;
|
||||
using widget_reference = widget&;
|
||||
|
||||
enum class where_t{unknown, text, push_button};
|
||||
enum class state_t{none, mouse_over, pressed};
|
||||
enum class parts{none, text, push_button};
|
||||
|
||||
drawer_impl()
|
||||
{
|
||||
state_.focused = false;
|
||||
state_.state = state_t::none;
|
||||
state_.pointer_where = where_t::unknown;
|
||||
state_.button_state = element_state::normal;
|
||||
state_.pointer_where = parts::none;
|
||||
state_.lister = nullptr;
|
||||
}
|
||||
|
||||
~drawer_impl()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void renderer(drawerbase::float_listbox::item_renderer* ir)
|
||||
{
|
||||
item_renderer_ = ir;
|
||||
@@ -84,13 +100,15 @@ namespace nana
|
||||
void attached(widget_reference wd, graph_reference graph)
|
||||
{
|
||||
widget_ = static_cast< ::nana::combox*>(&wd);
|
||||
editor_ = new widgets::skeletons::text_editor(widget_->handle(), graph);
|
||||
editor_->border_renderer([this](graph_reference graph, nana::color_t bgcolor){
|
||||
draw_border(graph, bgcolor);
|
||||
});
|
||||
|
||||
auto scheme = dynamic_cast< ::nana::widgets::skeletons::text_editor_scheme*>(API::dev::get_scheme(wd));
|
||||
editor_ = new widgets::skeletons::text_editor(widget_->handle(), graph, scheme);
|
||||
editor_->multi_lines(false);
|
||||
editable(false);
|
||||
graph_ = &graph;
|
||||
|
||||
evt_agent_.reset(new event_agent{ static_cast<nana::combox&>(wd) });
|
||||
editor_->textbase().set_event_agent(evt_agent_.get());
|
||||
}
|
||||
|
||||
void detached()
|
||||
@@ -100,17 +118,12 @@ namespace nana
|
||||
graph_ = nullptr;
|
||||
}
|
||||
|
||||
void insert(const nana::string& text)
|
||||
void insert(nana::string&& text)
|
||||
{
|
||||
items_.emplace_back(std::make_shared<item>(text));
|
||||
items_.emplace_back(std::make_shared<item>(std::move(text)));
|
||||
API::refresh_window(widget_->handle());
|
||||
}
|
||||
|
||||
where_t get_where() const
|
||||
{
|
||||
return state_.pointer_where;
|
||||
}
|
||||
|
||||
nana::any * anyobj(std::size_t pos, bool allocate_if_empty) const
|
||||
{
|
||||
if(pos >= items_.size())
|
||||
@@ -170,38 +183,36 @@ namespace nana
|
||||
|
||||
bool editable() const
|
||||
{
|
||||
return (editor_ ? editor_->attr().editable : false);
|
||||
return (editor_ && editor_->attr().editable);
|
||||
}
|
||||
|
||||
bool calc_where(graph_reference graph, int x, int y)
|
||||
{
|
||||
auto new_where = where_t::unknown;
|
||||
|
||||
auto new_where = parts::none;
|
||||
if(1 < x && x < static_cast<int>(graph.width()) - 2 && 1 < y && y < static_cast<int>(graph.height()) - 2)
|
||||
{
|
||||
if((editor_->attr().editable == false) || (static_cast<int>(graph.width()) - 22 <= x))
|
||||
new_where = where_t::push_button;
|
||||
new_where = parts::push_button;
|
||||
else
|
||||
new_where = where_t::text;
|
||||
new_where = parts::text;
|
||||
}
|
||||
|
||||
if(new_where != state_.pointer_where)
|
||||
{
|
||||
state_.pointer_where = new_where;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (new_where == state_.pointer_where)
|
||||
return false;
|
||||
|
||||
state_.pointer_where = new_where;
|
||||
return true;
|
||||
}
|
||||
|
||||
void set_mouse_over(bool mo)
|
||||
{
|
||||
state_.state = mo ? state_t::mouse_over : state_t::none;
|
||||
state_.pointer_where = where_t::unknown;
|
||||
state_.button_state = (mo ? element_state::hovered : element_state::normal);
|
||||
state_.pointer_where = parts::none;
|
||||
}
|
||||
|
||||
void set_mouse_press(bool mp)
|
||||
{
|
||||
state_.state = (mp ? state_t::pressed : state_t::mouse_over);
|
||||
state_.button_state = (mp ? element_state::pressed : element_state::hovered);
|
||||
}
|
||||
|
||||
void set_focused(bool f)
|
||||
@@ -219,9 +230,9 @@ namespace nana
|
||||
return (state_.lister != nullptr);
|
||||
}
|
||||
|
||||
void open_lister()
|
||||
void open_lister_if_push_button_positioned()
|
||||
{
|
||||
if((nullptr == state_.lister) && !items_.empty())
|
||||
if((nullptr == state_.lister) && !items_.empty() && (parts::push_button == state_.pointer_where))
|
||||
{
|
||||
module_.items.clear();
|
||||
std::copy(items_.cbegin(), items_.cend(), std::back_inserter(module_.items));
|
||||
@@ -232,7 +243,7 @@ namespace nana
|
||||
//The lister window closes by itself. I just take care about the destroy event.
|
||||
//The event should be destroy rather than unload. Because the unload event is invoked while
|
||||
//the lister is not closed, if popuping a message box, the lister will cover the message box.
|
||||
state_.lister->events().destroy.connect([this]
|
||||
state_.lister->events().destroy.connect_unignorable([this]
|
||||
{
|
||||
_m_lister_close_sig();
|
||||
});
|
||||
@@ -247,29 +258,30 @@ namespace nana
|
||||
|
||||
void move_items(bool upwards, bool circle)
|
||||
{
|
||||
if(nullptr == state_.lister)
|
||||
if (state_.lister)
|
||||
{
|
||||
std::size_t orig_i = module_.index;
|
||||
if(upwards)
|
||||
{
|
||||
if(module_.index && (module_.index < items_.size()))
|
||||
-- module_.index;
|
||||
else if(circle)
|
||||
module_.index = items_.size() - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((module_.index + 1) < items_.size())
|
||||
++ module_.index;
|
||||
else if(circle)
|
||||
module_.index = 0;
|
||||
}
|
||||
|
||||
if(orig_i != module_.index)
|
||||
option(module_.index, false);
|
||||
state_.lister->move_items(upwards, circle);
|
||||
return;
|
||||
}
|
||||
|
||||
auto pos = module_.index;
|
||||
if (upwards)
|
||||
{
|
||||
if (pos && (pos < items_.size()))
|
||||
--pos;
|
||||
else if (circle)
|
||||
pos = items_.size() - 1;
|
||||
}
|
||||
else
|
||||
state_.lister->move_items(upwards, circle);
|
||||
{
|
||||
if ((pos + 1) < items_.size())
|
||||
++pos;
|
||||
else if (circle)
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
if (pos != module_.index)
|
||||
option(pos, false);
|
||||
}
|
||||
|
||||
void draw()
|
||||
@@ -284,13 +296,6 @@ namespace nana
|
||||
_m_draw_image();
|
||||
}
|
||||
|
||||
void draw_border(graph_reference graph, nana::color_t bgcolor)
|
||||
{
|
||||
graph.rectangle((state_.focused ? 0x0595E2 : 0x999A9E), false);
|
||||
nana::rectangle r(graph.size());
|
||||
graph.rectangle(r.pare_off(1), bgcolor, false);
|
||||
}
|
||||
|
||||
std::size_t the_number_of_options() const
|
||||
{
|
||||
return items_.size();
|
||||
@@ -317,14 +322,13 @@ namespace nana
|
||||
{
|
||||
auto pos = API::cursor_position();
|
||||
API::calc_window_point(widget_->handle(), pos);
|
||||
if(calc_where(*graph_, pos.x, pos.y))
|
||||
state_.state = state_t::none;
|
||||
if (calc_where(*graph_, pos.x, pos.y))
|
||||
state_.button_state = element_state::normal;
|
||||
|
||||
editor_->text(items_[index]->item_text);
|
||||
_m_draw_push_button(widget_->enabled());
|
||||
_m_draw_image();
|
||||
|
||||
//Yes, it's safe to static_cast here!
|
||||
widget_->events().selected.emit(::nana::arg_combox(*widget_));
|
||||
}
|
||||
}
|
||||
@@ -334,9 +338,8 @@ namespace nana
|
||||
std::size_t pos = 0;
|
||||
for (auto & m : items_)
|
||||
{
|
||||
if (m->key && nana::detail::pred_equal_by_less(m->key.get(), p.get()))
|
||||
if (m->key && detail::pred_equal_by_less(m->key.get(), p.get()))
|
||||
return pos;
|
||||
|
||||
++pos;
|
||||
}
|
||||
|
||||
@@ -350,16 +353,17 @@ namespace nana
|
||||
return pos;
|
||||
}
|
||||
|
||||
void erase(nana::detail::key_interface * kv)
|
||||
void erase(detail::key_interface * kv)
|
||||
{
|
||||
for (auto i = items_.begin(); i != items_.end(); ++i)
|
||||
std::size_t pos = 0;
|
||||
for (auto & m : items_)
|
||||
{
|
||||
if ((*i)->key && nana::detail::pred_equal_by_less((*i)->key.get(), kv))
|
||||
if (m->key && detail::pred_equal_by_less(m->key.get(), kv))
|
||||
{
|
||||
std::size_t pos = i - items_.begin();
|
||||
this->erase(pos);
|
||||
erase(pos);
|
||||
return;
|
||||
}
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,28 +379,22 @@ namespace nana
|
||||
|
||||
void erase(std::size_t pos)
|
||||
{
|
||||
if (pos < items_.size())
|
||||
if (pos >= items_.size())
|
||||
return;
|
||||
|
||||
if (pos == module_.index)
|
||||
{
|
||||
if (pos == module_.index)
|
||||
{
|
||||
module_.index = nana::npos;
|
||||
this->widget_->caption(L"");
|
||||
}
|
||||
else if ((nana::npos != module_.index) && (pos < module_.index))
|
||||
--module_.index;
|
||||
|
||||
items_.erase(items_.begin() + pos);
|
||||
|
||||
//Redraw, because the state of push button is changed when the last item is created.
|
||||
if (items_.empty())
|
||||
API::refresh_window(*widget_);
|
||||
module_.index = ::nana::npos;
|
||||
this->widget_->caption(L"");
|
||||
}
|
||||
}
|
||||
else if ((::nana::npos != module_.index) && (pos < module_.index))
|
||||
--module_.index;
|
||||
|
||||
void text(nana::string&& str)
|
||||
{
|
||||
if (editor_)
|
||||
editor_->text(std::move(str));
|
||||
items_.erase(items_.begin() + pos);
|
||||
|
||||
//Redraw, because the state of push button is changed when the last item is removed.
|
||||
if (items_.empty())
|
||||
API::refresh_window(*widget_);
|
||||
}
|
||||
|
||||
void image(std::size_t pos, const nana::paint::image& img)
|
||||
@@ -414,12 +412,11 @@ namespace nana
|
||||
|
||||
bool image_pixels(unsigned px)
|
||||
{
|
||||
if(image_pixels_ != px)
|
||||
{
|
||||
image_pixels_ = px;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (image_pixels_ == px)
|
||||
return false;
|
||||
|
||||
image_pixels_ = px;
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
void _m_lister_close_sig()
|
||||
@@ -439,69 +436,47 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void _m_draw_background(graph_reference graph, const nana::rectangle&, nana::color_t)
|
||||
void _m_draw_background(graph_reference graph, const rectangle&, const ::nana::color&)
|
||||
{
|
||||
nana::rectangle r(graph.size());
|
||||
nana::color_t color_start = color::button_face_shadow_start;
|
||||
nana::color_t color_end = color::button_face_shadow_end;
|
||||
if(state_.state == state_t::pressed)
|
||||
{
|
||||
r.pare_off(2);
|
||||
std::swap(color_start, color_end);
|
||||
}
|
||||
else
|
||||
r.pare_off(1);
|
||||
auto clr_from = colors::button_face_shadow_start;
|
||||
auto clr_to = colors::button_face_shadow_end;
|
||||
|
||||
graph.shadow_rectangle(r, color_start, color_end, true);
|
||||
int pare_off_px = 1;
|
||||
if (element_state::pressed == state_.button_state)
|
||||
{
|
||||
pare_off_px = 2;
|
||||
std::swap(clr_from, clr_to);
|
||||
}
|
||||
|
||||
graph.gradual_rectangle(::nana::rectangle(graph.size()).pare_off(pare_off_px), clr_from, clr_to, true);
|
||||
}
|
||||
|
||||
void _m_draw_push_button(bool enabled)
|
||||
{
|
||||
using namespace nana::paint;
|
||||
::nana::rectangle r{graph_->size()};
|
||||
r.x = r.right() - 16;
|
||||
r.y = 1;
|
||||
r.width = 16;
|
||||
r.height -= 2;
|
||||
|
||||
if (nullptr == graph_) return;
|
||||
|
||||
int left = graph_->width() - 17;
|
||||
int right = left + 16;
|
||||
int top = 1;
|
||||
int bottom = graph_->height() - 2;
|
||||
int mid = top + (bottom - top) * 5 / 18;
|
||||
|
||||
nana::color_t topcol, topcol_ln, botcol, botcol_ln;
|
||||
nana::color_t arrow_color;
|
||||
if (enabled && items_.size())
|
||||
auto estate = state_.button_state;
|
||||
if (enabled && !items_.empty())
|
||||
{
|
||||
arrow_color = 0xFFFFFF;
|
||||
double percent = 1;
|
||||
if (has_lister() || (state_.state == state_t::pressed && state_.pointer_where == where_t::push_button))
|
||||
percent = 0.8;
|
||||
else if (state_.state == state_t::mouse_over)
|
||||
percent = 0.9;
|
||||
|
||||
topcol_ln = graphics::mix(0x3F476C, 0xFFFFFF, percent);
|
||||
botcol_ln = graphics::mix(0x031141, 0xFFFFFF, percent);
|
||||
topcol = graphics::mix(0x3F83B4, 0xFFFFFF, percent);
|
||||
botcol = graphics::mix(0x0C4A95, 0xFFFFFF, percent);
|
||||
if (has_lister() || (element_state::pressed == estate && state_.pointer_where == parts::push_button))
|
||||
estate = element_state::pressed;
|
||||
}
|
||||
else
|
||||
{
|
||||
arrow_color = 0xFFFFFF;
|
||||
topcol_ln = 0x7F7F7F;
|
||||
botcol_ln = 0x505050;
|
||||
topcol = 0xC3C3C3;
|
||||
botcol = 0xA0A0A0;
|
||||
}
|
||||
estate = element_state::disabled;
|
||||
|
||||
graph_->line(left, top, left, mid, topcol_ln);
|
||||
graph_->line(right - 1, top, right - 1, mid, topcol_ln);
|
||||
facade<element::button> button;
|
||||
button.draw(*graph_, ::nana::color{ 3, 65, 140 }, colors::white, r, estate);
|
||||
|
||||
graph_->line(left, mid + 1, left, bottom, botcol_ln);
|
||||
graph_->line(right - 1, mid + 1, right - 1, bottom, botcol_ln);
|
||||
facade<element::arrow> arrow("solid_triangle");
|
||||
arrow.direction(::nana::direction::south);
|
||||
|
||||
graph_->rectangle(left + 1, top, right - left - 2, mid - top + 1, topcol, true);
|
||||
graph_->rectangle(left + 1, mid + 1, right - left - 2, bottom - mid, botcol, true);
|
||||
|
||||
gadget::arrow_16_pixels(*graph_, left, top + ((bottom - top) / 2) - 7, arrow_color, 1, gadget::directions::to_south);
|
||||
r.y += (r.height / 2) - 7;
|
||||
r.width = r.height = 16;
|
||||
arrow.draw(*graph_, {}, colors::white, r, element_state::normal);
|
||||
}
|
||||
|
||||
void _m_draw_image()
|
||||
@@ -549,21 +524,21 @@ namespace nana
|
||||
img.stretch(img.size(), *graph_, nana::rectangle(pos, imgsz));
|
||||
}
|
||||
private:
|
||||
std::vector<std::shared_ptr<item> > items_;
|
||||
std::vector<std::shared_ptr<item>> items_;
|
||||
nana::float_listbox::module_type module_;
|
||||
::nana::combox * widget_ = nullptr;
|
||||
nana::paint::graphics * graph_ = nullptr;
|
||||
drawerbase::float_listbox::item_renderer* item_renderer_ = nullptr;
|
||||
|
||||
bool image_enabled_ = false;
|
||||
unsigned image_pixels_ = 16;
|
||||
widgets::skeletons::text_editor * editor_ = nullptr;
|
||||
::nana::combox * widget_{ nullptr };
|
||||
nana::paint::graphics * graph_{ nullptr };
|
||||
drawerbase::float_listbox::item_renderer* item_renderer_{ nullptr };
|
||||
|
||||
bool image_enabled_{ false };
|
||||
unsigned image_pixels_{ 16 };
|
||||
widgets::skeletons::text_editor * editor_{ nullptr };
|
||||
std::unique_ptr<event_agent> evt_agent_;
|
||||
struct state_type
|
||||
{
|
||||
bool focused;
|
||||
state_t state;
|
||||
where_t pointer_where;
|
||||
element_state button_state;
|
||||
parts pointer_where;
|
||||
|
||||
nana::float_listbox * lister;
|
||||
std::size_t item_index_before_selection;
|
||||
@@ -579,12 +554,6 @@ namespace nana
|
||||
trigger::~trigger()
|
||||
{
|
||||
delete drawer_;
|
||||
drawer_ = nullptr;
|
||||
}
|
||||
|
||||
void trigger::set_accept(std::function<bool(nana::char_t)>&& pred)
|
||||
{
|
||||
pred_acceptive_ = std::move(pred);
|
||||
}
|
||||
|
||||
drawer_impl& trigger::get_drawer_impl()
|
||||
@@ -599,7 +568,7 @@ namespace nana
|
||||
|
||||
void trigger::attached(widget_reference wdg, graph_reference graph)
|
||||
{
|
||||
wdg.background(0xFFFFFF);
|
||||
wdg.bgcolor(colors::white);
|
||||
drawer_->attached(wdg, graph);
|
||||
|
||||
API::effects_edge_nimbus(wdg, effects::edge_nimbus::active);
|
||||
@@ -655,8 +624,7 @@ namespace nana
|
||||
{
|
||||
auto * editor = drawer_->editor();
|
||||
if(false == editor->mouse_down(arg.left_button, arg.pos))
|
||||
if(drawer_impl::where_t::push_button == drawer_->get_where())
|
||||
drawer_->open_lister();
|
||||
drawer_->open_lister_if_push_button_positioned();
|
||||
|
||||
drawer_->draw();
|
||||
if(editor->attr().editable)
|
||||
@@ -668,15 +636,12 @@ namespace nana
|
||||
|
||||
void trigger::mouse_up(graph_reference graph, const arg_mouse& arg)
|
||||
{
|
||||
if(drawer_->widget_ptr()->enabled())
|
||||
if (drawer_->widget_ptr()->enabled() && !drawer_->has_lister())
|
||||
{
|
||||
if(false == drawer_->has_lister())
|
||||
{
|
||||
drawer_->editor()->mouse_up(arg.left_button, arg.pos);
|
||||
drawer_->set_mouse_press(false);
|
||||
drawer_->draw();
|
||||
API::lazy_refresh();
|
||||
}
|
||||
drawer_->editor()->mouse_up(arg.left_button, arg.pos);
|
||||
drawer_->set_mouse_press(false);
|
||||
drawer_->draw();
|
||||
API::lazy_refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -709,7 +674,7 @@ namespace nana
|
||||
|
||||
void trigger::key_press(graph_reference, const arg_keyboard& arg)
|
||||
{
|
||||
if(false == drawer_->widget_ptr()->enabled())
|
||||
if(!drawer_->widget_ptr()->enabled())
|
||||
return;
|
||||
|
||||
if(drawer_->editable())
|
||||
@@ -748,8 +713,7 @@ namespace nana
|
||||
|
||||
void trigger::key_char(graph_reference graph, const arg_keyboard& arg)
|
||||
{
|
||||
bool enterable = drawer_->widget_ptr()->enabled() && (!pred_acceptive_ || pred_acceptive_(arg.key));
|
||||
if (drawer_->editor()->respone_keyboard(arg.key, enterable))
|
||||
if (drawer_->editor()->respone_keyboard(arg.key))
|
||||
API::lazy_refresh();
|
||||
}
|
||||
//end class trigger
|
||||
@@ -807,7 +771,7 @@ namespace nana
|
||||
{
|
||||
if (pos_ == nana::npos)
|
||||
return false;
|
||||
return (impl_->at(pos_).item_text == static_cast<nana::string>(nana::charset(s)));
|
||||
return (impl_->at(pos_).item_text == static_cast<nana::string>(nana::charset(s, nana::unicode::utf8)));
|
||||
}
|
||||
|
||||
bool item_proxy::operator == (const wchar_t * s) const
|
||||
@@ -832,12 +796,11 @@ namespace nana
|
||||
/// Behavior of Iterator
|
||||
item_proxy & item_proxy::operator++()
|
||||
{
|
||||
if (nana::npos == pos_)
|
||||
return *this;
|
||||
|
||||
if (++pos_ == impl_->the_number_of_options())
|
||||
pos_ = nana::npos;
|
||||
|
||||
if (nana::npos != pos_)
|
||||
{
|
||||
if (++pos_ == impl_->the_number_of_options())
|
||||
pos_ = nana::npos;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -906,10 +869,10 @@ namespace nana
|
||||
create(wd, rectangle(), visible);
|
||||
}
|
||||
|
||||
combox::combox(window wd, const nana::string& text, bool visible)
|
||||
combox::combox(window wd, nana::string text, bool visible)
|
||||
{
|
||||
create(wd, rectangle(), visible);
|
||||
caption(text);
|
||||
caption(std::move(text));
|
||||
}
|
||||
|
||||
combox::combox(window wd, const nana::char_t* text, bool visible)
|
||||
@@ -925,69 +888,81 @@ namespace nana
|
||||
|
||||
void combox::clear()
|
||||
{
|
||||
internal_scope_guard sg;
|
||||
get_drawer_trigger().get_drawer_impl().clear();
|
||||
internal_scope_guard lock;
|
||||
_m_impl().clear();
|
||||
API::refresh_window(handle());
|
||||
}
|
||||
|
||||
void combox::editable(bool eb)
|
||||
{
|
||||
get_drawer_trigger().get_drawer_impl().editable(eb);
|
||||
internal_scope_guard lock;
|
||||
_m_impl().editable(eb);
|
||||
}
|
||||
|
||||
bool combox::editable() const
|
||||
{
|
||||
return get_drawer_trigger().get_drawer_impl().editable();
|
||||
internal_scope_guard lock;
|
||||
return _m_impl().editable();
|
||||
}
|
||||
|
||||
void combox::set_accept(std::function<bool(nana::char_t)> pred)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
get_drawer_trigger().set_accept(std::move(pred));
|
||||
auto editor = _m_impl().editor();
|
||||
if(editor)
|
||||
editor->set_accept(std::move(pred));
|
||||
}
|
||||
|
||||
combox& combox::push_back(const nana::string& text)
|
||||
combox& combox::push_back(nana::string text)
|
||||
{
|
||||
get_drawer_trigger().get_drawer_impl().insert(text);
|
||||
internal_scope_guard lock;
|
||||
_m_impl().insert(std::move(text));
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::size_t combox::the_number_of_options() const
|
||||
{
|
||||
return get_drawer_trigger().get_drawer_impl().the_number_of_options();
|
||||
internal_scope_guard lock;
|
||||
return _m_impl().the_number_of_options();
|
||||
}
|
||||
|
||||
std::size_t combox::option() const
|
||||
{
|
||||
return get_drawer_trigger().get_drawer_impl().option();
|
||||
internal_scope_guard lock;
|
||||
return _m_impl().option();
|
||||
}
|
||||
|
||||
void combox::option(std::size_t i)
|
||||
void combox::option(std::size_t pos)
|
||||
{
|
||||
get_drawer_trigger().get_drawer_impl().option(i, false);
|
||||
internal_scope_guard lock;
|
||||
_m_impl().option(pos, false);
|
||||
API::update_window(handle());
|
||||
}
|
||||
|
||||
nana::string combox::text(std::size_t i) const
|
||||
nana::string combox::text(std::size_t pos) const
|
||||
{
|
||||
return get_drawer_trigger().get_drawer_impl().at(i).item_text;
|
||||
internal_scope_guard lock;
|
||||
return _m_impl().at(pos).item_text;
|
||||
}
|
||||
|
||||
void combox::erase(std::size_t pos)
|
||||
{
|
||||
get_drawer_trigger().get_drawer_impl().erase(pos);
|
||||
internal_scope_guard lock;
|
||||
_m_impl().erase(pos);
|
||||
}
|
||||
|
||||
void combox::renderer(item_renderer* ir)
|
||||
{
|
||||
get_drawer_trigger().get_drawer_impl().renderer(ir);
|
||||
internal_scope_guard lock;
|
||||
_m_impl().renderer(ir);
|
||||
}
|
||||
|
||||
void combox::image(std::size_t i, const nana::paint::image& img)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
if(empty()) return;
|
||||
|
||||
auto & impl = get_drawer_trigger().get_drawer_impl();
|
||||
auto & impl = _m_impl();
|
||||
impl.image(i, img);
|
||||
if(i == impl.option())
|
||||
API::refresh_window(*this);
|
||||
@@ -995,43 +970,62 @@ namespace nana
|
||||
|
||||
nana::paint::image combox::image(std::size_t pos) const
|
||||
{
|
||||
return get_drawer_trigger().get_drawer_impl().at(pos).item_image;
|
||||
internal_scope_guard lock;
|
||||
return _m_impl().at(pos).item_image;
|
||||
}
|
||||
|
||||
void combox::image_pixels(unsigned px)
|
||||
{
|
||||
if(get_drawer_trigger().get_drawer_impl().image_pixels(px))
|
||||
internal_scope_guard lock;
|
||||
if (_m_impl().image_pixels(px))
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
|
||||
nana::string combox::_m_caption() const
|
||||
{
|
||||
internal_scope_guard isg;
|
||||
auto editor = get_drawer_trigger().get_drawer_impl().editor();
|
||||
internal_scope_guard lock;
|
||||
auto editor = _m_impl().editor();
|
||||
return (editor ? editor->text() : nana::string());
|
||||
}
|
||||
|
||||
void combox::_m_caption(nana::string&& str)
|
||||
{
|
||||
internal_scope_guard isg;
|
||||
get_drawer_trigger().get_drawer_impl().text(std::move(str));
|
||||
internal_scope_guard lock;
|
||||
|
||||
auto editor = _m_impl().editor();
|
||||
if (editor)
|
||||
editor->text(std::move(str));
|
||||
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
|
||||
nana::any * combox::_m_anyobj(std::size_t pos, bool alloc_if_empty) const
|
||||
{
|
||||
return get_drawer_trigger().get_drawer_impl().anyobj(pos, alloc_if_empty);
|
||||
internal_scope_guard lock;
|
||||
return _m_impl().anyobj(pos, alloc_if_empty);
|
||||
}
|
||||
|
||||
auto combox::_m_at_key(std::shared_ptr<nana::detail::key_interface>&& p) -> item_proxy
|
||||
{
|
||||
auto & impl = get_drawer_trigger().get_drawer_impl();
|
||||
internal_scope_guard lock;
|
||||
auto & impl = _m_impl();
|
||||
return item_proxy(&impl, impl.at_key(std::move(p)));
|
||||
}
|
||||
|
||||
void combox::_m_erase(nana::detail::key_interface* p)
|
||||
{
|
||||
get_drawer_trigger().get_drawer_impl().erase(p);
|
||||
internal_scope_guard lock;
|
||||
_m_impl().erase(p);
|
||||
}
|
||||
|
||||
drawerbase::combox::drawer_impl & combox::_m_impl()
|
||||
{
|
||||
return get_drawer_trigger().get_drawer_impl();
|
||||
}
|
||||
|
||||
const drawerbase::combox::drawer_impl& combox::_m_impl() const
|
||||
{
|
||||
return get_drawer_trigger().get_drawer_impl();
|
||||
}
|
||||
//end class combox
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* A date chooser Implementation
|
||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -10,6 +11,7 @@
|
||||
*/
|
||||
|
||||
#include <nana/gui/widgets/date_chooser.hpp>
|
||||
#include <nana/gui/element.hpp>
|
||||
#include <nana/paint/gadget.hpp>
|
||||
#include <nana/system/platform.hpp>
|
||||
#include <sstream>
|
||||
@@ -26,15 +28,17 @@ namespace nana
|
||||
: widget_(nullptr), chose_(false), page_(page::date), pos_(where::none)
|
||||
{
|
||||
const nana::string ws[] = {STR("S"), STR("M"), STR("T"), STR("W"), STR("T"), STR("F"), STR("S")};
|
||||
const nana::string ms[] = {STR("January"), STR("February"), STR("March"), STR("April"), STR("May"), STR("June"), STR("July"), STR("August"), STR("September"), STR("October"), STR("November"), STR("December")};
|
||||
|
||||
for(int i = 0; i < 7; ++i) weekstr_[i] = ws[i];
|
||||
for(int i = 0; i < 12; ++i) monthstr_[i] = ms[i];
|
||||
|
||||
nana::date d;
|
||||
chdate_.year = chmonth_.year = d.read().year;
|
||||
chdate_.month = chmonth_.month = d.read().month;
|
||||
chdate_.day = d.read().day;
|
||||
|
||||
color_.selected = { 0x2F, 0x36, 0x99 };
|
||||
color_.highlight = { 0x4D, 0x56, 0xC8 };
|
||||
color_.normal = colors::black;
|
||||
color_.bgcolor = { 0x88, 0xC4, 0xFF };
|
||||
}
|
||||
|
||||
bool trigger::chose() const
|
||||
@@ -49,43 +53,28 @@ namespace nana
|
||||
|
||||
void trigger::week_name(unsigned index, const nana::string& str)
|
||||
{
|
||||
if(0 <= index && index < 7)
|
||||
if(index < 7)
|
||||
this->weekstr_[index] = str;
|
||||
}
|
||||
|
||||
void trigger::month_name(unsigned index, const nana::string& str)
|
||||
{
|
||||
if(0 <= index && index < 12)
|
||||
this->monthstr_[index] = str;
|
||||
}
|
||||
|
||||
void trigger::_m_init_color()
|
||||
{
|
||||
color_.selected = 0x2F3699;
|
||||
color_.highlight = 0x4D56C8;
|
||||
color_.normal = 0x0;
|
||||
color_.bkcolor = 0x88C4FF;
|
||||
}
|
||||
|
||||
trigger::where trigger::_m_pos_where(graph_reference graph, int x, int y)
|
||||
trigger::where trigger::_m_pos_where(graph_reference graph, const ::nana::point& pos)
|
||||
{
|
||||
int xend = static_cast<int>(graph.width()) - 1;
|
||||
int yend = static_cast<int>(graph.height()) - 1;
|
||||
if(0 < y && y < static_cast<int>(topbar_height))
|
||||
if(0 < pos.y && pos.y < static_cast<int>(topbar_height))
|
||||
{
|
||||
if(static_cast<int>(border_size) < x && x < xend)
|
||||
if(static_cast<int>(border_size) < pos.x && pos.x < xend)
|
||||
{
|
||||
if(x < border_size + 16)
|
||||
if(pos.x < border_size + 16)
|
||||
return where::left_button;
|
||||
else if(xend - border_size - 16 < x)
|
||||
else if(xend - border_size - 16 < pos.x)
|
||||
return where::right_button;
|
||||
return where::topbar;
|
||||
}
|
||||
}
|
||||
else if(topbar_height < y && y < yend)
|
||||
else if(topbar_height < pos.y && pos.y < yend)
|
||||
{
|
||||
trace_pos_.x = x;
|
||||
trace_pos_.y = y;
|
||||
trace_pos_ = pos;
|
||||
return where::textarea;
|
||||
}
|
||||
return where::none;
|
||||
@@ -93,12 +82,10 @@ namespace nana
|
||||
|
||||
void trigger::_m_draw(graph_reference graph)
|
||||
{
|
||||
_m_init_color();
|
||||
|
||||
const unsigned width = graph.width() - 2;
|
||||
|
||||
graph.rectangle(0xB0B0B0, false);
|
||||
graph.rectangle(1, 1, width, topbar_height, 0xFFFFFF, true);
|
||||
graph.rectangle(false, {0xb0, 0xb0, 0xb0});
|
||||
graph.rectangle({ 1, 1, width, static_cast<unsigned>(topbar_height) }, true, colors::white);
|
||||
|
||||
_m_draw_topbar(graph);
|
||||
|
||||
@@ -106,8 +93,8 @@ namespace nana
|
||||
{
|
||||
nana::point refpos(1, static_cast<int>(topbar_height) + 1);
|
||||
|
||||
nana::paint::graphics gbuf(width, graph.height() - 2 - topbar_height);
|
||||
gbuf.rectangle(0xF0F0F0, true);
|
||||
nana::paint::graphics gbuf({ width, graph.height() - 2 - topbar_height });
|
||||
gbuf.rectangle(true, {0xf0, 0xf0, 0xf0});
|
||||
|
||||
switch(page_)
|
||||
{
|
||||
@@ -126,12 +113,17 @@ namespace nana
|
||||
|
||||
void trigger::_m_draw_topbar(graph_reference graph)
|
||||
{
|
||||
int ypos = (topbar_height - 16) / 2 + 1;
|
||||
::nana::color arrow_bgcolor;
|
||||
::nana::rectangle arrow_r{ static_cast<int>(border_size), (topbar_height - 16) / 2 + 1, 16, 16 };
|
||||
facade<element::arrow> arrow("solid_triangle");
|
||||
arrow.direction(::nana::direction::west);
|
||||
arrow.draw(graph, arrow_bgcolor, (pos_ == where::left_button ? color_.highlight : color_.normal), arrow_r, element_state::normal);
|
||||
|
||||
const nana::color_t color = color_.normal;
|
||||
|
||||
nana::paint::gadget::arrow_16_pixels(graph, border_size, ypos, (pos_ == where::left_button ? color_.highlight : color), 1, nana::paint::gadget::directions::to_west);
|
||||
nana::paint::gadget::arrow_16_pixels(graph, graph.width() - (border_size + 16 + 1), ypos, (pos_ == where::right_button ? color_.highlight : color), 1, nana::paint::gadget::directions::to_east);
|
||||
arrow_r.x = static_cast<int>(graph.width()) - static_cast<int>(border_size + 17);
|
||||
arrow.direction(::nana::direction::east);
|
||||
arrow.draw(graph, arrow_bgcolor, (pos_ == where::right_button ? color_.highlight : color_.normal), arrow_r, element_state::normal);
|
||||
|
||||
const char * monthstr[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
|
||||
|
||||
if(graph.width() > 32 + border_size * 2)
|
||||
{
|
||||
@@ -140,19 +132,19 @@ namespace nana
|
||||
nana::string str;
|
||||
if(page_ == page::date)
|
||||
{
|
||||
str += monthstr_[chmonth_.month - 1];
|
||||
str += ::nana::internationalization()(monthstr[chmonth_.month - 1]);
|
||||
str += STR(" ");
|
||||
}
|
||||
str += nana::charset(ss.str());
|
||||
|
||||
nana::size txt_s = graph.text_extent_size(str);
|
||||
|
||||
ypos = (topbar_height - txt_s.height) / 2 + 1;
|
||||
int top = (topbar_height - static_cast<int>(txt_s.height)) / 2 + 1;
|
||||
|
||||
int xpos = (graph.width() - txt_s.width) / 2;
|
||||
int xpos = static_cast<int>(graph.width() - txt_s.width) / 2;
|
||||
if(xpos < border_size + 16) xpos = 16 + border_size + 1;
|
||||
|
||||
graph.string(xpos, ypos, (pos_ == where::topbar ? color_.highlight : color), str);
|
||||
graph.string({ xpos, top }, str, (pos_ == where::topbar ? color_.highlight : color_.normal));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,9 +173,8 @@ namespace nana
|
||||
nana::rectangle r(static_cast<int>(x * dbasis.row_s), static_cast<int>(y * dbasis.line_s),
|
||||
static_cast<int>(dbasis.row_s), static_cast<int>(dbasis.line_s));
|
||||
|
||||
nana::color_t color{ color_.normal };
|
||||
|
||||
nana::point tpos{ trace_pos_ - dbasis.refpos };
|
||||
auto color = color_.normal;
|
||||
auto tpos = trace_pos_ - dbasis.refpos;
|
||||
|
||||
if((pos_ == where::textarea)
|
||||
&& (r.x <= tpos.x)
|
||||
@@ -194,22 +185,22 @@ namespace nana
|
||||
if((page_ != page::date) || y)
|
||||
{
|
||||
color = color_.highlight;
|
||||
graph.rectangle(r, color_.bkcolor, true);
|
||||
graph.rectangle(r, true, color_.bgcolor);
|
||||
}
|
||||
}
|
||||
|
||||
if(sel)
|
||||
{
|
||||
color = color_.highlight;
|
||||
graph.rectangle(r, color_.bkcolor, true);
|
||||
graph.rectangle(r, color_.selected, false);
|
||||
graph.rectangle(r, true, color_.bgcolor);
|
||||
graph.rectangle(r, false, color_.selected);
|
||||
}
|
||||
|
||||
if(primary == false)
|
||||
color = 0xB0B0B0;
|
||||
if(false == primary)
|
||||
color = { 0xB0, 0xB0, 0xB0 };
|
||||
|
||||
nana::size txt_s = graph.text_extent_size(str);
|
||||
graph.string(r.x + static_cast<int>(r.width - txt_s.width) / 2, r.y + static_cast<int>(r.height - txt_s.height) / 2, color, str);
|
||||
graph.string({ r.x + static_cast<int>(r.width - txt_s.width) / 2, r.y + static_cast<int>(r.height - txt_s.height) / 2 }, str, color);
|
||||
}
|
||||
|
||||
void trigger::_m_draw_pos(drawing_basis & dbasis, graph_reference graph, int x, int y, int number, bool primary, bool sel)
|
||||
@@ -315,11 +306,13 @@ namespace nana
|
||||
drawing_basis dbasis;
|
||||
_m_make_drawing_basis(dbasis, graph, refpos);
|
||||
|
||||
const char * monthstr[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
|
||||
::nana::internationalization i18n;
|
||||
for(int y = 0; y < 3; ++y)
|
||||
for(int x = 0; x < 4; ++x)
|
||||
{
|
||||
int index = x + y * 4;
|
||||
_m_draw_pos(dbasis, graph, x, y, monthstr_[index], true, (chmonth_.year == chdate_.year) && (index + 1 == chdate_.month));
|
||||
_m_draw_pos(dbasis, graph, x, y, i18n(monthstr[index]), true, (chmonth_.year == chdate_.year) && (index + 1 == chdate_.month));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,7 +410,7 @@ namespace nana
|
||||
r.x = static_cast<int>(newbuf.width() - r.width) / 2;
|
||||
r.y = static_cast<int>(newbuf.height() - r.height) / 2;
|
||||
|
||||
dzbuf.rectangle(0xFFFFFF, true);
|
||||
dzbuf.rectangle(true, colors::white);
|
||||
dirtybuf.stretch(dzbuf, r);
|
||||
|
||||
r.width = static_cast<int>(newbuf.width() + delta * (count - i));
|
||||
@@ -451,7 +444,7 @@ namespace nana
|
||||
r.height = static_cast<int>(newbuf.height() - delta_h * (count - i));
|
||||
r.x = static_cast<int>(newbuf.width() - r.width) / 2;
|
||||
r.y = static_cast<int>(newbuf.height() - r.height) / 2;
|
||||
nzbuf.rectangle(0xFFFFFF, true);
|
||||
nzbuf.rectangle(true, colors::white);
|
||||
newbuf.stretch(nzbuf, r);
|
||||
|
||||
nzbuf.blend(nzbuf.size(), dzbuf, nana::point(), fade * (count - i));
|
||||
@@ -477,7 +470,7 @@ namespace nana
|
||||
|
||||
void trigger::mouse_move(graph_reference graph, const arg_mouse& arg)
|
||||
{
|
||||
where pos = _m_pos_where(graph, arg.pos.x, arg.pos.y);
|
||||
where pos = _m_pos_where(graph, arg.pos);
|
||||
if(pos == pos_ && pos_ != where::textarea) return;
|
||||
pos_ = pos;
|
||||
_m_draw(graph);
|
||||
@@ -495,7 +488,7 @@ namespace nana
|
||||
void trigger::mouse_up(graph_reference graph, const arg_mouse& arg)
|
||||
{
|
||||
bool redraw = true;
|
||||
where pos = _m_pos_where(graph, arg.pos.x, arg.pos.y);
|
||||
where pos = _m_pos_where(graph, arg.pos);
|
||||
transform_action tfid = transform_action::none;
|
||||
|
||||
if(pos == where::topbar)
|
||||
@@ -604,12 +597,12 @@ namespace nana
|
||||
nana::point refpos(1, static_cast<int>(topbar_height) + 1);
|
||||
nana::rectangle r(0, 0, graph.width() - 2, graph.height() - 2 - topbar_height);
|
||||
|
||||
nana::paint::graphics dirtybuf(r.width, r.height);
|
||||
nana::paint::graphics dirtybuf({ r.width, r.height });
|
||||
dirtybuf.bitblt(r, graph, refpos);
|
||||
|
||||
_m_draw(graph);
|
||||
|
||||
nana::paint::graphics gbuf(r.width, r.height);
|
||||
nana::paint::graphics gbuf({ r.width, r.height });
|
||||
gbuf.bitblt(r, graph, refpos);
|
||||
|
||||
_m_perf_transform(tfid, graph, dirtybuf, gbuf, refpos);
|
||||
@@ -665,11 +658,5 @@ namespace nana
|
||||
get_drawer_trigger().week_name(index, str);
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
|
||||
void date_chooser::monthstr(unsigned index, const nana::string& str)
|
||||
{
|
||||
get_drawer_trigger().month_name(index, str);
|
||||
API::refresh_window(*this);
|
||||
}
|
||||
//end class date_chooser
|
||||
}//end namespace nana
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A float_listbox Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -18,10 +18,6 @@ namespace nana
|
||||
namespace drawerbase{
|
||||
namespace float_listbox
|
||||
{
|
||||
//class item_renderer
|
||||
item_renderer::~item_renderer(){}
|
||||
//end class item_renderer
|
||||
|
||||
class def_item_renderer
|
||||
: public item_renderer
|
||||
{
|
||||
@@ -36,26 +32,29 @@ namespace nana
|
||||
|
||||
void render(widget_reference, graph_reference graph, const nana::rectangle& r, const item_interface* item, state_t state)
|
||||
{
|
||||
if(state == StateHighlighted)
|
||||
if (state == StateHighlighted)
|
||||
{
|
||||
graph.rectangle(r, 0xAFC7E3, false);
|
||||
::nana::color clr{ 0xaf, 0xc7, 0xe3 };
|
||||
graph.rectangle(r, false, clr);
|
||||
|
||||
graph.set_pixel(r.x, r.y, 0xFFFFFF);
|
||||
graph.set_pixel(r.x + r.width - 1, r.y, 0xFFFFFF);
|
||||
graph.set_pixel(r.x, r.y + r.height - 1, 0xFFFFFF);
|
||||
graph.set_pixel(r.x + r.width - 1, r.y + r.height - 1, 0xFFFFFF);
|
||||
graph.set_color(colors::white);
|
||||
graph.set_pixel(r.x, r.y);
|
||||
graph.set_pixel(r.x + r.width - 1, r.y);
|
||||
graph.set_pixel(r.x, r.y + r.height - 1);
|
||||
graph.set_pixel(r.x + r.width - 1, r.y + r.height - 1);
|
||||
|
||||
graph.set_pixel(r.x + 1, r.y + 1, 0xAFC7E3);
|
||||
graph.set_pixel(r.x + r.width - 2, r.y + 1, 0xAFC7E3);
|
||||
graph.set_pixel(r.x + 1, r.y + r.height - 2, 0xAFC7E3);
|
||||
graph.set_pixel(r.x + r.width - 2, r.y + r.height - 2, 0xAFC7E3);
|
||||
graph.set_color(clr);
|
||||
graph.set_pixel(r.x + 1, r.y + 1);
|
||||
graph.set_pixel(r.x + r.width - 2, r.y + 1);
|
||||
graph.set_pixel(r.x + 1, r.y + r.height - 2);
|
||||
graph.set_pixel(r.x + r.width - 2, r.y + r.height - 2);
|
||||
|
||||
nana::rectangle po_r(r);
|
||||
graph.rectangle(po_r.pare_off(1), 0xEBF4FB, false);
|
||||
graph.shadow_rectangle(po_r.pare_off(1), 0xDDECFD, 0xC2DCFD, true);
|
||||
graph.rectangle(po_r.pare_off(1), false, { 0xEB, 0xF4, 0xFB });
|
||||
graph.gradual_rectangle(po_r.pare_off(1), { 0xDD, 0xEC, 0xFD }, { 0xC2, 0xDC, 0xFD }, true);
|
||||
}
|
||||
else
|
||||
graph.rectangle(r, 0xFFFFFF, true);
|
||||
graph.rectangle(r, true, colors::white);
|
||||
|
||||
int x = r.x + 2;
|
||||
if(image_enabled_)
|
||||
@@ -100,7 +99,8 @@ namespace nana
|
||||
}
|
||||
x += (image_pixels_ + 2);
|
||||
}
|
||||
graph.string(x, r.y + 2, 0x0, item->text());
|
||||
graph.set_text_color(colors::black);
|
||||
graph.string({ x, r.y + 2 }, item->text());
|
||||
}
|
||||
|
||||
unsigned item_pixels(graph_reference graph) const
|
||||
@@ -109,12 +109,6 @@ namespace nana
|
||||
}
|
||||
};//end class item_renderer
|
||||
|
||||
//struct module_def
|
||||
module_def::module_def()
|
||||
:max_items(10), index(npos)
|
||||
{}
|
||||
//end struct module_def
|
||||
|
||||
//class drawer_impl
|
||||
class drawer_impl
|
||||
{
|
||||
@@ -248,7 +242,7 @@ namespace nana
|
||||
if(wd)
|
||||
{
|
||||
widget_ = wd;
|
||||
wd->events().mouse_wheel.connect([this](const arg_wheel& arg){
|
||||
wd->events().mouse_wheel.connect_unignorable([this](const arg_wheel& arg){
|
||||
scroll_items(arg.upwards);
|
||||
});
|
||||
}
|
||||
@@ -339,11 +333,11 @@ namespace nana
|
||||
_m_open_scrollbar(*widget_, pages);
|
||||
}
|
||||
else
|
||||
graph_->string(4, 4, 0x808080, STR("Empty Listbox, No Module!"));
|
||||
graph_->string({ 4, 4 }, STR("Empty Listbox, No Module!"), {0x80, 0x80, 0x80});
|
||||
|
||||
//Draw border
|
||||
graph_->rectangle(0x0, false);
|
||||
graph_->rectangle(nana::rectangle(graph_->size()).pare_off(1), 0xFFFFFF, false);
|
||||
graph_->rectangle(false, colors::black);
|
||||
graph_->rectangle(nana::rectangle(graph_->size()).pare_off(1), false, colors::white);
|
||||
}
|
||||
private:
|
||||
bool _m_image_enabled() const
|
||||
|
||||
@@ -18,8 +18,6 @@ namespace nana
|
||||
namespace form
|
||||
{
|
||||
//class trigger
|
||||
trigger::trigger():wd_(nullptr){}
|
||||
|
||||
void trigger::attached(widget_reference widget, graph_reference graph)
|
||||
{
|
||||
wd_ = &widget;
|
||||
@@ -27,13 +25,7 @@ namespace nana
|
||||
|
||||
void trigger::refresh(graph_reference graph)
|
||||
{
|
||||
graph.rectangle(API::background(*wd_), true);
|
||||
}
|
||||
|
||||
void trigger::resized(graph_reference graph, const arg_resized&)
|
||||
{
|
||||
graph.rectangle(API::background(*wd_), true);
|
||||
API::lazy_refresh();
|
||||
graph.rectangle(true, API::bgcolor(*wd_));
|
||||
}
|
||||
}//end namespace form
|
||||
}//end namespace drawerbase
|
||||
@@ -57,6 +49,16 @@ namespace nana
|
||||
form::form(window owner, const rectangle& r, const appearance& apr)
|
||||
: form_base_t(owner, false, r, apr)
|
||||
{}
|
||||
|
||||
void form::modality() const
|
||||
{
|
||||
API::modal_window(handle());
|
||||
}
|
||||
|
||||
void form::wait_for_this()
|
||||
{
|
||||
API::wait_for(handle());
|
||||
}
|
||||
//end class form
|
||||
|
||||
//class nested_form
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace nana
|
||||
return true;
|
||||
}
|
||||
|
||||
void render(graph_reference graph, nana::color_t fgcolor, align th, align_v tv)
|
||||
void render(graph_reference graph, const ::nana::color& fgcolor, align th, align_v tv)
|
||||
{
|
||||
traceable_.clear();
|
||||
|
||||
@@ -161,18 +161,18 @@ namespace nana
|
||||
return false;
|
||||
}
|
||||
|
||||
nana::size measure(graph_reference graph, unsigned limited, align th, align_v tv)
|
||||
::nana::size measure(graph_reference graph, unsigned limited, align th, align_v tv)
|
||||
{
|
||||
nana::size retsize;
|
||||
::nana::size retsize;
|
||||
|
||||
nana::paint::font ft = graph.typeface(); //used for restoring the font
|
||||
auto ft = graph.typeface(); //used for restoring the font
|
||||
|
||||
const unsigned def_line_pixels = graph.text_extent_size(STR(" "), 1).height;
|
||||
|
||||
font_ = ft;
|
||||
fblock_ = nullptr;
|
||||
|
||||
_m_set_default(ft, 0);
|
||||
_m_set_default(ft, colors::black);
|
||||
_m_measure(graph);
|
||||
|
||||
render_status rs;
|
||||
@@ -216,7 +216,7 @@ namespace nana
|
||||
}
|
||||
}
|
||||
|
||||
void _m_set_default(const nana::paint::font& ft, nana::color_t fgcolor)
|
||||
void _m_set_default(const ::nana::paint::font& ft, const ::nana::color& fgcolor)
|
||||
{
|
||||
def_.font_name = ft.name();
|
||||
def_.font_size = ft.size();
|
||||
@@ -224,9 +224,9 @@ namespace nana
|
||||
def_.fgcolor = fgcolor;
|
||||
}
|
||||
|
||||
nana::color_t _m_fgcolor(nana::widgets::skeletons::fblock* fp)
|
||||
const ::nana::color& _m_fgcolor(nana::widgets::skeletons::fblock* fp)
|
||||
{
|
||||
while(fp->fgcolor == 0xFFFFFFFF)
|
||||
while(fp->fgcolor.invisible())
|
||||
{
|
||||
fp = fp->parent;
|
||||
if(nullptr == fp)
|
||||
@@ -562,12 +562,12 @@ namespace nana
|
||||
|
||||
if (text_range.second == data_ptr->text().length())
|
||||
{
|
||||
graph.string(rs.pos.x, y, _m_fgcolor(fblock_ptr), data_ptr->text());
|
||||
graph.string({ rs.pos.x, y }, data_ptr->text(), _m_fgcolor(fblock_ptr));
|
||||
}
|
||||
else
|
||||
{
|
||||
nana::string str = data_ptr->text().substr(text_range.first, text_range.second);
|
||||
graph.string(rs.pos.x, y, _m_fgcolor(fblock_ptr), str);
|
||||
graph.string({ rs.pos.x, y }, str, _m_fgcolor(fblock_ptr));
|
||||
sz = graph.text_extent_size(str);
|
||||
}
|
||||
_m_inser_if_traceable(rs.pos.x, y, sz, fblock_ptr);
|
||||
@@ -600,16 +600,16 @@ namespace nana
|
||||
private:
|
||||
dstream dstream_;
|
||||
bool format_enabled_ = false;
|
||||
nana::widgets::skeletons::fblock * fblock_ = nullptr;
|
||||
::nana::widgets::skeletons::fblock * fblock_ = nullptr;
|
||||
std::deque<traceable> traceable_;
|
||||
|
||||
nana::paint::font font_;
|
||||
::nana::paint::font font_;
|
||||
struct def_font_tag
|
||||
{
|
||||
nana::string font_name;
|
||||
::nana::string font_name;
|
||||
std::size_t font_size;
|
||||
bool font_bold;
|
||||
nana::color_t fgcolor;
|
||||
::nana::color fgcolor;
|
||||
}def_;
|
||||
};
|
||||
|
||||
@@ -748,9 +748,9 @@ namespace nana
|
||||
|
||||
window wd = impl_->wd->handle();
|
||||
if(bground_mode::basic != API::effects_bground_mode(wd))
|
||||
graph.rectangle(API::background(wd), true);
|
||||
graph.rectangle(true, API::bgcolor(wd));
|
||||
|
||||
impl_->renderer.render(graph, impl_->wd->foreground(), impl_->text_align, impl_->text_align_v);
|
||||
impl_->renderer.render(graph, API::fgcolor(wd), impl_->text_align, impl_->text_align_v);
|
||||
}
|
||||
|
||||
//end class label_drawer
|
||||
@@ -831,12 +831,20 @@ namespace nana
|
||||
if(graph_ptr->empty())
|
||||
{
|
||||
graph_ptr = &substitute;
|
||||
graph_ptr->make(10, 10);
|
||||
graph_ptr->make({ 10, 10 });
|
||||
}
|
||||
|
||||
return impl->renderer.measure(*graph_ptr, limited, impl->text_align, impl->text_align_v);
|
||||
}
|
||||
|
||||
::nana::size label::measure(paint::graphics& graph, const ::nana::string& str, unsigned allowed_width_in_pixel, bool format_enabled, align h_align, align_v v_align)
|
||||
{
|
||||
drawerbase::label::renderer rd;
|
||||
rd.format(format_enabled);
|
||||
rd.parse(str);
|
||||
return rd.measure(graph, allowed_width_in_pixel, h_align, v_align);
|
||||
}
|
||||
|
||||
label& label::text_align(align th, align_v tv)
|
||||
{
|
||||
internal_scope_guard isg;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -105,38 +105,42 @@ namespace nana
|
||||
nana::size sz = graph.size();
|
||||
sz.width -= 30;
|
||||
sz.height -= 2;
|
||||
graph.rectangle(color::gray_border, false);
|
||||
graph.rectangle(1, 1, 28, sz.height, 0xF6F6F6, true);
|
||||
graph.rectangle(29, 1, sz.width, sz.height, 0xFFFFFF, true);
|
||||
graph.rectangle(false, colors::gray_border);
|
||||
graph.rectangle({ 1, 1, 28, sz.height }, true, { 0xf6, 0xf6, 0xf6 });
|
||||
graph.rectangle({ 29, 1, sz.width, sz.height }, true, colors::white);
|
||||
}
|
||||
|
||||
void item(graph_reference graph, const nana::rectangle& r, const attr& at)
|
||||
{
|
||||
if(at.item_state == state::active)
|
||||
{
|
||||
graph.rectangle(r, 0xA8D8EB, false);
|
||||
graph.rectangle(r, false, {0xa8, 0xd8, 0xeb});
|
||||
nana::point points[4] = {
|
||||
nana::point(r.x, r.y),
|
||||
nana::point(r.x + r.width - 1, r.y),
|
||||
nana::point(r.x, r.y + r.height - 1),
|
||||
nana::point(r.x + r.width - 1, r.y + r.height - 1)
|
||||
};
|
||||
|
||||
graph.set_color({0xc0, 0xdd, 0xfc});
|
||||
for(int i = 0; i < 4; ++i)
|
||||
graph.set_pixel(points[i].x, points[i].y, 0xC0DDFC);
|
||||
graph.set_pixel(points[i].x, points[i].y);
|
||||
|
||||
if(at.enabled)
|
||||
graph.shadow_rectangle(nana::rectangle(r).pare_off(1), 0xE8F0F4, 0xDBECF4, true);
|
||||
graph.gradual_rectangle(nana::rectangle(r).pare_off(1), { 0xE8, 0xF0, 0xF4 }, { 0xDB,0xEC,0xF4 }, true);
|
||||
}
|
||||
|
||||
if(at.checked && (checks::none != at.check_style))
|
||||
{
|
||||
graph.rectangle(r, 0xCDD3E6, false);
|
||||
graph.rectangle(nana::rectangle(r).pare_off(1), 0xE6EFF4, true);
|
||||
graph.rectangle(r, false, { 0xCD, 0xD3, 0xE6 });
|
||||
|
||||
::nana::color clr(0xE6, 0xEF, 0xF4);
|
||||
graph.rectangle(nana::rectangle(r).pare_off(1), true, clr);
|
||||
|
||||
nana::rectangle crook_r = r;
|
||||
crook_r.width = 16;
|
||||
crook_.radio(at.check_style == checks::option);
|
||||
crook_.draw(graph, 0xE6EFF4, 0x0, crook_r, element_state::normal);
|
||||
crook_.draw(graph, clr, colors::black, crook_r, element_state::normal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,24 +151,22 @@ namespace nana
|
||||
|
||||
void item_text(graph_reference graph, const nana::point& pos, const nana::string& text, unsigned text_pixels, const attr& at)
|
||||
{
|
||||
graph.set_color(at.enabled ? colors::black : colors::gray_border);
|
||||
nana::paint::text_renderer tr(graph);
|
||||
tr.render(pos.x, pos.y, (at.enabled ? 0x0 : nana::color::gray_border), text.c_str(), text.length(), text_pixels, true);
|
||||
tr.render(pos, text.c_str(), text.length(), text_pixels, true);
|
||||
}
|
||||
|
||||
void sub_arrow(graph_reference graph, const nana::point& pos, unsigned pixels, const attr&)
|
||||
{
|
||||
nana::paint::gadget::arrow_16_pixels(graph, pos.x, pos.y + static_cast<int>(pixels - 16) / 2, 0x0, 0, nana::paint::gadget::directions::to_east);
|
||||
facade<element::arrow> arrow("hollow_triangle");
|
||||
arrow.direction(::nana::direction::east);
|
||||
arrow.draw(graph, {}, colors::black, { pos.x, pos.y + static_cast<int>(pixels - 16) / 2, 16, 16 }, element_state::normal);
|
||||
}
|
||||
|
||||
private:
|
||||
facade<element::crook> crook_;
|
||||
};
|
||||
|
||||
//class renderer_interface
|
||||
renderer_interface::~renderer_interface()
|
||||
{}
|
||||
//end class renderer_interface
|
||||
|
||||
class menu_builder
|
||||
: noncopyable
|
||||
{
|
||||
@@ -177,7 +179,7 @@ namespace nana
|
||||
|
||||
menu_builder()
|
||||
{
|
||||
root_.max_pixels = API::screen_size().width * 2 / 3;
|
||||
root_.max_pixels = screen::primary_monitor_size().width * 2 / 3;
|
||||
root_.item_pixels = 24;
|
||||
renderer_ = pat::cloneable<renderer_interface>(internal_renderer());
|
||||
}
|
||||
@@ -537,7 +539,7 @@ namespace nana
|
||||
renderer->item(*graph_, item_r, attr);
|
||||
|
||||
//Draw text, the text is transformed from orignal for hotkey character
|
||||
nana::string::value_type hotkey;
|
||||
nana::char_t hotkey;
|
||||
nana::string::size_type hotkey_pos;
|
||||
nana::string text = API::transform_shortkey_text(m.text, hotkey, &hotkey_pos);
|
||||
|
||||
@@ -555,7 +557,9 @@ namespace nana
|
||||
nana::size hotkey_size = graph_->text_extent_size(text.c_str() + hotkey_pos, 1);
|
||||
int x = item_r.x + 40 + off_w;
|
||||
int y = item_r.y + text_top_off + hotkey_size.height;
|
||||
graph_->line(x, y, x + hotkey_size.width - 1, y, 0x0);
|
||||
|
||||
graph_->set_color(colors::black);
|
||||
graph_->line({ x, y }, { x + static_cast<int>(hotkey_size.width) - 1, y });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,7 +570,8 @@ namespace nana
|
||||
}
|
||||
else
|
||||
{
|
||||
graph_->line(item_r.x + 40, item_r.y, graph_->width() - 1, item_r.y, nana::color::gray_border);
|
||||
graph_->set_color(colors::gray_border);
|
||||
graph_->line({ item_r.x + 40, item_r.y }, { static_cast<int>(graph_->width()) - 1, item_r.y });
|
||||
item_r.y += 2;
|
||||
}
|
||||
|
||||
@@ -654,7 +659,7 @@ namespace nana
|
||||
API::calc_screen_point(*widget_, pos);
|
||||
|
||||
//get the screen coordinates of the widget pos.
|
||||
auto scr_area = API::screen_area_from_point(detail_.monitor_pos);
|
||||
auto scr_area = screen::from_point(detail_.monitor_pos)->area();
|
||||
|
||||
if(pos.x + size.width > scr_area.x + scr_area.width)
|
||||
pos.x = static_cast<int>(scr_area.x + scr_area.width - size.width);
|
||||
@@ -736,21 +741,21 @@ namespace nana
|
||||
API::register_menu_window(this->handle(), !owner_menubar);
|
||||
}
|
||||
|
||||
events().destroy.connect([this]{
|
||||
events().destroy.connect_unignorable([this]{
|
||||
_m_destroy();
|
||||
});
|
||||
|
||||
events().key_press.connect([this](const arg_keyboard& arg){
|
||||
events().key_press.connect_unignorable([this](const arg_keyboard& arg){
|
||||
_m_key_down(arg);
|
||||
});
|
||||
|
||||
events().mouse_up.connect([this]{
|
||||
events().mouse_up.connect_unignorable([this]{
|
||||
pick();
|
||||
});
|
||||
|
||||
if (want_focus_)
|
||||
{
|
||||
event_focus_ = events().focus.connect([this](const arg_focus& arg)
|
||||
event_focus_ = events().focus.connect_unignorable([this](const arg_focus& arg)
|
||||
{
|
||||
_m_focus_changed(arg);
|
||||
});
|
||||
@@ -988,7 +993,7 @@ namespace nana
|
||||
void _m_make_mouse_event()
|
||||
{
|
||||
state_.mouse_pos = API::cursor_position();
|
||||
events().mouse_move.connect([this]{
|
||||
events().mouse_move.connect_unignorable([this]{
|
||||
_m_mouse_event();
|
||||
});
|
||||
}
|
||||
@@ -1319,7 +1324,7 @@ namespace nana
|
||||
{
|
||||
close();
|
||||
impl_->uiobj = &(form_loader<drawerbase::menu::menu_window, false>()(wd, point(x, y), &(*impl_->mbuilder.renderer())));
|
||||
impl_->uiobj->events().destroy.connect([this]{
|
||||
impl_->uiobj->events().destroy.connect_unignorable([this]{
|
||||
_m_destroy_menu_window();
|
||||
});
|
||||
impl_->uiobj->popup(impl_->mbuilder.data(), called_by_menubar);
|
||||
|
||||
@@ -100,38 +100,39 @@ namespace nana
|
||||
|
||||
void item_renderer::background(const nana::point& pos, const nana::size& size, state_t state)
|
||||
{
|
||||
nana::color_t bground = API::background(handle_);
|
||||
nana::color_t border, body, corner;
|
||||
auto bground = API::fgcolor(handle_);
|
||||
::nana::color border, body, corner;
|
||||
|
||||
switch(state)
|
||||
{
|
||||
case item_renderer::state_highlight:
|
||||
border = nana::color::highlight;
|
||||
body = 0xC0DDFC;
|
||||
corner = paint::graphics::mix(body, bground, 0.5);
|
||||
border = colors::highlight;
|
||||
body.from_rgb(0xC0, 0xDD, 0xFC);
|
||||
corner = body.blend(bground, 0.5);
|
||||
break;
|
||||
case item_renderer::state_selected:
|
||||
border = nana::color::dark_border;
|
||||
body = 0xFFFFFF;
|
||||
corner = paint::graphics::mix(border, bground, 0.5);
|
||||
border = colors::dark_border;
|
||||
body = colors::white;
|
||||
corner = body.blend(bground, 0.5);
|
||||
break;
|
||||
default: //Don't process other states.
|
||||
return;
|
||||
}
|
||||
|
||||
nana::rectangle r(pos, size);
|
||||
graph_.rectangle(r, border, false);
|
||||
graph_.rectangle(r, false, border);
|
||||
|
||||
graph_.set_pixel(pos.x, pos.y, corner);
|
||||
graph_.set_pixel(pos.x + size.width - 1, pos.y, corner);
|
||||
graph_.set_pixel(pos.x, pos.y + size.height - 1, corner);
|
||||
graph_.set_pixel(pos.x + size.width - 1, pos.y + size.height - 1, corner);
|
||||
graph_.rectangle(r.pare_off(1), body, true);
|
||||
graph_.set_color(corner);
|
||||
graph_.set_pixel(pos.x, pos.y);
|
||||
graph_.set_pixel(pos.x + size.width - 1, pos.y);
|
||||
graph_.set_pixel(pos.x, pos.y + size.height - 1);
|
||||
graph_.set_pixel(pos.x + size.width - 1, pos.y + size.height - 1);
|
||||
graph_.rectangle(r.pare_off(1), true, body);
|
||||
}
|
||||
|
||||
void item_renderer::caption(int x, int y, const nana::string& text)
|
||||
{
|
||||
graph_.string(x, y, 0x0, text);
|
||||
graph_.string({ x, y }, text, colors::black);
|
||||
}
|
||||
//end class item_renderer
|
||||
|
||||
@@ -508,8 +509,8 @@ namespace nana
|
||||
|
||||
void trigger::_m_draw()
|
||||
{
|
||||
nana::color_t bground_color = API::background(*widget_);
|
||||
graph_->rectangle(bground_color, true);
|
||||
auto bgcolor = API::bgcolor(*widget_);
|
||||
graph_->rectangle(true, bgcolor);
|
||||
|
||||
item_renderer ird(*widget_, *graph_);
|
||||
|
||||
@@ -538,8 +539,8 @@ namespace nana
|
||||
{
|
||||
int x = item_pos.x + item_s.width;
|
||||
int y1 = item_pos.y + 2, y2 = item_pos.y + item_s.height - 1;
|
||||
graph_->line(x, y1, x, y2, paint::graphics::mix(color::gray_border, bground_color, 0.6));
|
||||
graph_->line(x + 1, y1, x + 1, y2, paint::graphics::mix(color::button_face_shadow_end, bground_color, 0.5));
|
||||
graph_->line({ x, y1 }, { x, y2 }, bgcolor.blend(colors::gray_border, 0.4));
|
||||
graph_->line({ x + 1, y1 }, { x + 1, y2 }, bgcolor.blend(colors::button_face_shadow_end, 0.5));
|
||||
}
|
||||
|
||||
//Draw text, the text is transformed from orignal for hotkey character
|
||||
@@ -555,7 +556,7 @@ namespace nana
|
||||
graph_->text_metrics(ascent, descent, inleading);
|
||||
int x = item_pos.x + 8 + off_w;
|
||||
int y = item_pos.y + text_top_off + ascent + 1;
|
||||
graph_->line(x, y, x + hotkey_size.width - 1, y, 0x0);
|
||||
graph_->line({ x, y }, { x + static_cast<int>(hotkey_size.width) - 1, y }, ::nana::colors::black);
|
||||
}
|
||||
|
||||
item_pos.x += i->size.width;
|
||||
|
||||
@@ -20,10 +20,6 @@ namespace nana
|
||||
namespace panel
|
||||
{
|
||||
//class drawer
|
||||
drawer::drawer()
|
||||
:window_(nullptr)
|
||||
{}
|
||||
|
||||
void drawer::attached(widget_reference widget, graph_reference)
|
||||
{
|
||||
widget.caption(STR("Nana Panel"));
|
||||
@@ -33,7 +29,7 @@ namespace nana
|
||||
void drawer::refresh(graph_reference graph)
|
||||
{
|
||||
if(bground_mode::basic != API::effects_bground_mode(window_))
|
||||
graph.rectangle(API::background(window_), true);
|
||||
graph.rectangle(true, API::bgcolor(window_));
|
||||
}
|
||||
//end class drawer
|
||||
}//end namespace panel
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user