diff --git a/README.md b/README.md index a9201c8a..ba113804 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ NIM Duilib 包含了一整套桌面软件的开发部件,与其说这是一个 git clone https://github.com/netease-im/NIM_Duilib_Framework ``` -进入 `NIM_Duilib_Framework/samples` 目录,使用 Visual Studio 2013 Update 5 以上版本 IDE 打开 `samples.sln`,按下 F7 即可编译所有示例程序 +进入 `NIM_Duilib_Framework/examples` 目录,使用 Visual Studio 2013 Update 5 以上版本 IDE 打开 `examples.sln`,按下 F7 即可编译所有示例程序 ## 文档 @@ -38,19 +38,17 @@ git clone https://github.com/netease-im/NIM_Duilib_Framework ## 目录 +├─`base` 基础类库 ├─`bin` 各个示例程序输出目录,包含预设的皮肤和语言文件以及 CEF 依赖 ├─`docs` duilib 接口的说明文档 +├─`duilib` duilib 核心代码,依赖 base 但不依赖 shared ├─`libs` 静态库编译后的输出目录,包含预设的一些 CEF 组件静态库 -├─`samples` 各类示例程序 +├─`examples` 各类示例程序源代码 ├─`third_party` 第三方库,目前仅有 cef_control 有依赖 -├─`toolkits` -│ ├─`base` 基础类库 -│ ├─`duilib` duilib 核心代码,依赖 base 但不依赖 shared -│ ├─`shared` 包含一些工具的封装,如命令行解析、日志、路径处理等 -│ ├─`ui_components` 基于 duilib 封装的常用组件库如 `msgbox`、`toast`、`cef_control` 等 +├─`ui_components` 基于 duilib 封装的常用组件库如 `msgbox`、`toast`、`cef_control` 等 ## 交流 - - 遇到问题:欢迎查看我们整理过的[中文文档](docs/SUMMARY.md)参考[示例程序](samples/README.md)来帮助你解决疑惑 + - 遇到问题:欢迎查看我们整理过的[中文文档](docs/SUMMARY.md)参考[示例程序](examples/README.md)来帮助你解决疑惑 - 提交缺陷:在确保使用最新版本依然存在问题时请尽量以简洁的语言描述清楚复现该问题的步骤并提交 issue - 功能建议:如果你有什么好的想法或者提案,欢迎提交 issue 与我们交流 diff --git a/README_en-US.md b/README_en-US.md index 66bd5587..9169f4f2 100644 --- a/README_en-US.md +++ b/README_en-US.md @@ -29,7 +29,7 @@ Clone the repo into your disk. git clone https://github.com/netease-im/NIM_Duilib_Framework ``` -Enter the `NIM_Duilib_Framework/samples` directory,Open `samples.sln` with Visual Studio 2013 Update 5 or higher ,press `F7` to compile all projects. +Enter the `NIM_Duilib_Framework/examples` directory,Open `examples.sln` with Visual Studio 2013 Update 5 or higher ,press `F7` to compile all projects. ## Documentation @@ -38,19 +38,17 @@ Enter the `NIM_Duilib_Framework/samples` directory,Open `samples.sln` with Vis ## Structure -├─`bin` Samples output directories,include skin and language files and CEF dependencies. +├─`base` Base libraries. +├─`bin` Examples output directories,include skin and language files and CEF dependencies. ├─`docs` Documentation of Duilib. +├─`duilib` Duilib core, depend on base project. ├─`libs` Static library output directories, include CEF static library. -├─`samples` Samples of Duilib. +├─`examples` Examples of Duilib. ├─`third_party` Third party for CEF. -├─`toolkits` -│ ├─`base` Base libraries. -│ ├─`duilib` Duilib core, depend on base project. -│ ├─`shared` Utils, such as logs/string/path utils. -│ ├─`ui_components` UI components based on Duilib, such as `msgbox`,`toast`,`cef_control` +├─`ui_components` UI components based on Duilib, such as `msgbox`,`toast`,`cef_control` ## Communication - - Question: Read the [Documentation](docs/SUMMARY.md) and [Samples code](samples/README.md) to help you. + - Question: Read the [Documentation](docs/SUMMARY.md) and [Examples code](examples/README.md) to help you. - Report: File a bug in GitHub issues. - Suggestion: Request a new feature in Github issues. diff --git a/tool_kits/base/base.h b/base/base.h similarity index 100% rename from tool_kits/base/base.h rename to base/base.h diff --git a/tool_kits/base/base.vcxproj b/base/base.vcxproj similarity index 96% rename from tool_kits/base/base.vcxproj rename to base/base.vcxproj index 8d25f940..54673877 100644 --- a/tool_kits/base/base.vcxproj +++ b/base/base.vcxproj @@ -175,28 +175,28 @@ - ..\..\libs\ + $(ProjectDir)..\libs\ - $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ + $(ProjectDir)..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ $(ProjectName)_d $(ProjectName)_d - ..\..\libs\x64\ - $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ + $(ProjectDir)..\libs\x64\ + $(ProjectDir)..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ - ..\..\libs\ + $(ProjectDir)..\libs\ - $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ + $(ProjectDir)..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ - ..\..\libs\x64\ - $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ + $(ProjectDir)..\libs\x64\ + $(ProjectDir)..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ diff --git a/tool_kits/base/base.vcxproj.filters b/base/base.vcxproj.filters similarity index 100% rename from tool_kits/base/base.vcxproj.filters rename to base/base.vcxproj.filters diff --git a/tool_kits/base/base_config.h b/base/base_config.h similarity index 100% rename from tool_kits/base/base_config.h rename to base/base_config.h diff --git a/tool_kits/base/base_export.h b/base/base_export.h similarity index 100% rename from tool_kits/base/base_export.h rename to base/base_export.h diff --git a/tool_kits/base/base_types.h b/base/base_types.h similarity index 100% rename from tool_kits/base/base_types.h rename to base/base_types.h diff --git a/tool_kits/base/callback/callback.h b/base/callback/callback.h similarity index 100% rename from tool_kits/base/callback/callback.h rename to base/callback/callback.h diff --git a/tool_kits/base/compiler_specific.h b/base/compiler_specific.h similarity index 100% rename from tool_kits/base/compiler_specific.h rename to base/compiler_specific.h diff --git a/tool_kits/base/encrypt/des.cpp b/base/encrypt/des.cpp similarity index 100% rename from tool_kits/base/encrypt/des.cpp rename to base/encrypt/des.cpp diff --git a/tool_kits/base/encrypt/des.h b/base/encrypt/des.h similarity index 100% rename from tool_kits/base/encrypt/des.h rename to base/encrypt/des.h diff --git a/tool_kits/base/encrypt/encrypt.h b/base/encrypt/encrypt.h similarity index 100% rename from tool_kits/base/encrypt/encrypt.h rename to base/encrypt/encrypt.h diff --git a/tool_kits/base/encrypt/encrypt_impl.h b/base/encrypt/encrypt_impl.h similarity index 100% rename from tool_kits/base/encrypt/encrypt_impl.h rename to base/encrypt/encrypt_impl.h diff --git a/tool_kits/base/error.h b/base/error.h similarity index 100% rename from tool_kits/base/error.h rename to base/error.h diff --git a/tool_kits/base/file/file_path.h b/base/file/file_path.h similarity index 100% rename from tool_kits/base/file/file_path.h rename to base/file/file_path.h diff --git a/tool_kits/base/file/file_util.cpp b/base/file/file_util.cpp similarity index 100% rename from tool_kits/base/file/file_util.cpp rename to base/file/file_util.cpp diff --git a/tool_kits/base/file/file_util.h b/base/file/file_util.h similarity index 100% rename from tool_kits/base/file/file_util.h rename to base/file/file_util.h diff --git a/tool_kits/base/file/file_util_posix.cpp b/base/file/file_util_posix.cpp similarity index 100% rename from tool_kits/base/file/file_util_posix.cpp rename to base/file/file_util_posix.cpp diff --git a/tool_kits/base/file/file_util_win.cpp b/base/file/file_util_win.cpp similarity index 100% rename from tool_kits/base/file/file_util_win.cpp rename to base/file/file_util_win.cpp diff --git a/tool_kits/base/framework/default_message_pump.cpp b/base/framework/default_message_pump.cpp similarity index 100% rename from tool_kits/base/framework/default_message_pump.cpp rename to base/framework/default_message_pump.cpp diff --git a/tool_kits/base/framework/default_message_pump.h b/base/framework/default_message_pump.h similarity index 100% rename from tool_kits/base/framework/default_message_pump.h rename to base/framework/default_message_pump.h diff --git a/tool_kits/base/framework/message_loop.cpp b/base/framework/message_loop.cpp similarity index 100% rename from tool_kits/base/framework/message_loop.cpp rename to base/framework/message_loop.cpp diff --git a/tool_kits/base/framework/message_loop.h b/base/framework/message_loop.h similarity index 100% rename from tool_kits/base/framework/message_loop.h rename to base/framework/message_loop.h diff --git a/tool_kits/base/framework/message_loop_proxy.cpp b/base/framework/message_loop_proxy.cpp similarity index 100% rename from tool_kits/base/framework/message_loop_proxy.cpp rename to base/framework/message_loop_proxy.cpp diff --git a/tool_kits/base/framework/message_loop_proxy.h b/base/framework/message_loop_proxy.h similarity index 100% rename from tool_kits/base/framework/message_loop_proxy.h rename to base/framework/message_loop_proxy.h diff --git a/tool_kits/base/framework/message_pump.cpp b/base/framework/message_pump.cpp similarity index 100% rename from tool_kits/base/framework/message_pump.cpp rename to base/framework/message_pump.cpp diff --git a/tool_kits/base/framework/message_pump.h b/base/framework/message_pump.h similarity index 100% rename from tool_kits/base/framework/message_pump.h rename to base/framework/message_pump.h diff --git a/tool_kits/base/framework/observer_list.h b/base/framework/observer_list.h similarity index 100% rename from tool_kits/base/framework/observer_list.h rename to base/framework/observer_list.h diff --git a/tool_kits/base/framework/readme.txt b/base/framework/readme.txt similarity index 100% rename from tool_kits/base/framework/readme.txt rename to base/framework/readme.txt diff --git a/tool_kits/base/framework/task.h b/base/framework/task.h similarity index 100% rename from tool_kits/base/framework/task.h rename to base/framework/task.h diff --git a/tool_kits/base/framework/win_io_message_pump.cpp b/base/framework/win_io_message_pump.cpp similarity index 100% rename from tool_kits/base/framework/win_io_message_pump.cpp rename to base/framework/win_io_message_pump.cpp diff --git a/tool_kits/base/framework/win_io_message_pump.h b/base/framework/win_io_message_pump.h similarity index 100% rename from tool_kits/base/framework/win_io_message_pump.h rename to base/framework/win_io_message_pump.h diff --git a/tool_kits/base/framework/win_message_pump.cpp b/base/framework/win_message_pump.cpp similarity index 100% rename from tool_kits/base/framework/win_message_pump.cpp rename to base/framework/win_message_pump.cpp diff --git a/tool_kits/base/framework/win_message_pump.h b/base/framework/win_message_pump.h similarity index 100% rename from tool_kits/base/framework/win_message_pump.h rename to base/framework/win_message_pump.h diff --git a/tool_kits/base/framework/win_ui_message_pump.cpp b/base/framework/win_ui_message_pump.cpp similarity index 100% rename from tool_kits/base/framework/win_ui_message_pump.cpp rename to base/framework/win_ui_message_pump.cpp diff --git a/tool_kits/base/framework/win_ui_message_pump.h b/base/framework/win_ui_message_pump.h similarity index 100% rename from tool_kits/base/framework/win_ui_message_pump.h rename to base/framework/win_ui_message_pump.h diff --git a/tool_kits/base/hardware/cpu.cpp b/base/hardware/cpu.cpp similarity index 100% rename from tool_kits/base/hardware/cpu.cpp rename to base/hardware/cpu.cpp diff --git a/tool_kits/base/hardware/cpu.h b/base/hardware/cpu.h similarity index 100% rename from tool_kits/base/hardware/cpu.h rename to base/hardware/cpu.h diff --git a/tool_kits/base/macros.h b/base/macros.h similarity index 100% rename from tool_kits/base/macros.h rename to base/macros.h diff --git a/tool_kits/base/memory/blockbuffer.h b/base/memory/blockbuffer.h similarity index 100% rename from tool_kits/base/memory/blockbuffer.h rename to base/memory/blockbuffer.h diff --git a/tool_kits/base/memory/deleter.h b/base/memory/deleter.h similarity index 100% rename from tool_kits/base/memory/deleter.h rename to base/memory/deleter.h diff --git a/tool_kits/base/memory/lazy_instance.h b/base/memory/lazy_instance.h similarity index 100% rename from tool_kits/base/memory/lazy_instance.h rename to base/memory/lazy_instance.h diff --git a/tool_kits/base/memory/singleton.h b/base/memory/singleton.h similarity index 100% rename from tool_kits/base/memory/singleton.h rename to base/memory/singleton.h diff --git a/tool_kits/base/network/network_util.cpp b/base/network/network_util.cpp similarity index 100% rename from tool_kits/base/network/network_util.cpp rename to base/network/network_util.cpp diff --git a/tool_kits/base/network/network_util.h b/base/network/network_util.h similarity index 100% rename from tool_kits/base/network/network_util.h rename to base/network/network_util.h diff --git a/tool_kits/base/network/nio_base.h b/base/network/nio_base.h similarity index 100% rename from tool_kits/base/network/nio_base.h rename to base/network/nio_base.h diff --git a/tool_kits/base/port.h b/base/port.h similarity index 100% rename from tool_kits/base/port.h rename to base/port.h diff --git a/tool_kits/base/synchronization/lock.h b/base/synchronization/lock.h similarity index 100% rename from tool_kits/base/synchronization/lock.h rename to base/synchronization/lock.h diff --git a/tool_kits/base/synchronization/lock_posix.cpp b/base/synchronization/lock_posix.cpp similarity index 100% rename from tool_kits/base/synchronization/lock_posix.cpp rename to base/synchronization/lock_posix.cpp diff --git a/tool_kits/base/synchronization/lock_win.cpp b/base/synchronization/lock_win.cpp similarity index 100% rename from tool_kits/base/synchronization/lock_win.cpp rename to base/synchronization/lock_win.cpp diff --git a/tool_kits/base/synchronization/semaphore.h b/base/synchronization/semaphore.h similarity index 100% rename from tool_kits/base/synchronization/semaphore.h rename to base/synchronization/semaphore.h diff --git a/tool_kits/base/synchronization/semaphore_posix.cpp b/base/synchronization/semaphore_posix.cpp similarity index 100% rename from tool_kits/base/synchronization/semaphore_posix.cpp rename to base/synchronization/semaphore_posix.cpp diff --git a/tool_kits/base/synchronization/semaphore_win.cpp b/base/synchronization/semaphore_win.cpp similarity index 100% rename from tool_kits/base/synchronization/semaphore_win.cpp rename to base/synchronization/semaphore_win.cpp diff --git a/tool_kits/base/synchronization/waitable_event.h b/base/synchronization/waitable_event.h similarity index 100% rename from tool_kits/base/synchronization/waitable_event.h rename to base/synchronization/waitable_event.h diff --git a/tool_kits/base/synchronization/waitable_event_posix.cpp b/base/synchronization/waitable_event_posix.cpp similarity index 100% rename from tool_kits/base/synchronization/waitable_event_posix.cpp rename to base/synchronization/waitable_event_posix.cpp diff --git a/tool_kits/base/synchronization/waitable_event_win.cpp b/base/synchronization/waitable_event_win.cpp similarity index 100% rename from tool_kits/base/synchronization/waitable_event_win.cpp rename to base/synchronization/waitable_event_win.cpp diff --git a/tool_kits/base/third_party/chrome/atomicops.h b/base/third_party/chrome/atomicops.h similarity index 100% rename from tool_kits/base/third_party/chrome/atomicops.h rename to base/third_party/chrome/atomicops.h diff --git a/tool_kits/base/third_party/chrome/atomicops_internals_arm_gcc.h b/base/third_party/chrome/atomicops_internals_arm_gcc.h similarity index 100% rename from tool_kits/base/third_party/chrome/atomicops_internals_arm_gcc.h rename to base/third_party/chrome/atomicops_internals_arm_gcc.h diff --git a/tool_kits/base/third_party/chrome/atomicops_internals_atomicword_compat.h b/base/third_party/chrome/atomicops_internals_atomicword_compat.h similarity index 100% rename from tool_kits/base/third_party/chrome/atomicops_internals_atomicword_compat.h rename to base/third_party/chrome/atomicops_internals_atomicword_compat.h diff --git a/tool_kits/base/third_party/chrome/atomicops_internals_x86_gcc.cc b/base/third_party/chrome/atomicops_internals_x86_gcc.cc similarity index 100% rename from tool_kits/base/third_party/chrome/atomicops_internals_x86_gcc.cc rename to base/third_party/chrome/atomicops_internals_x86_gcc.cc diff --git a/tool_kits/base/third_party/chrome/atomicops_internals_x86_gcc.h b/base/third_party/chrome/atomicops_internals_x86_gcc.h similarity index 100% rename from tool_kits/base/third_party/chrome/atomicops_internals_x86_gcc.h rename to base/third_party/chrome/atomicops_internals_x86_gcc.h diff --git a/tool_kits/base/third_party/chrome/atomicops_internals_x86_macosx.h b/base/third_party/chrome/atomicops_internals_x86_macosx.h similarity index 100% rename from tool_kits/base/third_party/chrome/atomicops_internals_x86_macosx.h rename to base/third_party/chrome/atomicops_internals_x86_macosx.h diff --git a/tool_kits/base/third_party/chrome/atomicops_internals_x86_msvc.h b/base/third_party/chrome/atomicops_internals_x86_msvc.h similarity index 100% rename from tool_kits/base/third_party/chrome/atomicops_internals_x86_msvc.h rename to base/third_party/chrome/atomicops_internals_x86_msvc.h diff --git a/tool_kits/base/third_party/convert_utf/ConvertUTF.c b/base/third_party/convert_utf/ConvertUTF.c similarity index 100% rename from tool_kits/base/third_party/convert_utf/ConvertUTF.c rename to base/third_party/convert_utf/ConvertUTF.c diff --git a/tool_kits/base/third_party/convert_utf/ConvertUTF.h b/base/third_party/convert_utf/ConvertUTF.h similarity index 100% rename from tool_kits/base/third_party/convert_utf/ConvertUTF.h rename to base/third_party/convert_utf/ConvertUTF.h diff --git a/tool_kits/base/third_party/convert_utf/readme.txt b/base/third_party/convert_utf/readme.txt similarity index 100% rename from tool_kits/base/third_party/convert_utf/readme.txt rename to base/third_party/convert_utf/readme.txt diff --git a/tool_kits/base/third_party/modp_b64/Readme.txt b/base/third_party/modp_b64/Readme.txt similarity index 100% rename from tool_kits/base/third_party/modp_b64/Readme.txt rename to base/third_party/modp_b64/Readme.txt diff --git a/tool_kits/base/third_party/modp_b64/modp_b64.cc b/base/third_party/modp_b64/modp_b64.cc similarity index 100% rename from tool_kits/base/third_party/modp_b64/modp_b64.cc rename to base/third_party/modp_b64/modp_b64.cc diff --git a/tool_kits/base/third_party/modp_b64/modp_b64.h b/base/third_party/modp_b64/modp_b64.h similarity index 100% rename from tool_kits/base/third_party/modp_b64/modp_b64.h rename to base/third_party/modp_b64/modp_b64.h diff --git a/tool_kits/base/third_party/modp_b64/modp_b64_data.h b/base/third_party/modp_b64/modp_b64_data.h similarity index 100% rename from tool_kits/base/third_party/modp_b64/modp_b64_data.h rename to base/third_party/modp_b64/modp_b64_data.h diff --git a/tool_kits/base/thread/framework_thread.cpp b/base/thread/framework_thread.cpp similarity index 100% rename from tool_kits/base/thread/framework_thread.cpp rename to base/thread/framework_thread.cpp diff --git a/tool_kits/base/thread/framework_thread.h b/base/thread/framework_thread.h similarity index 100% rename from tool_kits/base/thread/framework_thread.h rename to base/thread/framework_thread.h diff --git a/tool_kits/base/thread/thread.h b/base/thread/thread.h similarity index 100% rename from tool_kits/base/thread/thread.h rename to base/thread/thread.h diff --git a/tool_kits/base/thread/thread_local.h b/base/thread/thread_local.h similarity index 100% rename from tool_kits/base/thread/thread_local.h rename to base/thread/thread_local.h diff --git a/tool_kits/base/thread/thread_local_posix.cpp b/base/thread/thread_local_posix.cpp similarity index 100% rename from tool_kits/base/thread/thread_local_posix.cpp rename to base/thread/thread_local_posix.cpp diff --git a/tool_kits/base/thread/thread_local_win.cpp b/base/thread/thread_local_win.cpp similarity index 100% rename from tool_kits/base/thread/thread_local_win.cpp rename to base/thread/thread_local_win.cpp diff --git a/tool_kits/base/thread/thread_manager.cpp b/base/thread/thread_manager.cpp similarity index 100% rename from tool_kits/base/thread/thread_manager.cpp rename to base/thread/thread_manager.cpp diff --git a/tool_kits/base/thread/thread_manager.h b/base/thread/thread_manager.h similarity index 95% rename from tool_kits/base/thread/thread_manager.h rename to base/thread/thread_manager.h index 91cca119..75b1ceda 100644 --- a/tool_kits/base/thread/thread_manager.h +++ b/base/thread/thread_manager.h @@ -9,6 +9,16 @@ #include "base/thread/framework_thread.h" #include "base/memory/singleton.h" +/** + * 一些预定义的线程 ID 值,提供开发者使用 + */ +enum ThreadIds +{ + kThreadMain, + kThreadDatabase, + kThreadGlobalMisc, +}; + namespace nbase { class MessageLoop; diff --git a/tool_kits/base/thread/thread_posix.cpp b/base/thread/thread_posix.cpp similarity index 100% rename from tool_kits/base/thread/thread_posix.cpp rename to base/thread/thread_posix.cpp diff --git a/tool_kits/base/thread/thread_win.cpp b/base/thread/thread_win.cpp similarity index 100% rename from tool_kits/base/thread/thread_win.cpp rename to base/thread/thread_win.cpp diff --git a/tool_kits/base/time/time.cpp b/base/time/time.cpp similarity index 100% rename from tool_kits/base/time/time.cpp rename to base/time/time.cpp diff --git a/tool_kits/base/time/time.h b/base/time/time.h similarity index 100% rename from tool_kits/base/time/time.h rename to base/time/time.h diff --git a/tool_kits/base/time/time_posix.cpp b/base/time/time_posix.cpp similarity index 100% rename from tool_kits/base/time/time_posix.cpp rename to base/time/time_posix.cpp diff --git a/tool_kits/base/time/time_win.cpp b/base/time/time_win.cpp similarity index 100% rename from tool_kits/base/time/time_win.cpp rename to base/time/time_win.cpp diff --git a/tool_kits/base/util/at_exit.cpp b/base/util/at_exit.cpp similarity index 100% rename from tool_kits/base/util/at_exit.cpp rename to base/util/at_exit.cpp diff --git a/tool_kits/base/util/at_exit.h b/base/util/at_exit.h similarity index 100% rename from tool_kits/base/util/at_exit.h rename to base/util/at_exit.h diff --git a/tool_kits/base/util/base64.cpp b/base/util/base64.cpp similarity index 100% rename from tool_kits/base/util/base64.cpp rename to base/util/base64.cpp diff --git a/tool_kits/base/util/base64.h b/base/util/base64.h similarity index 100% rename from tool_kits/base/util/base64.h rename to base/util/base64.h diff --git a/tool_kits/base/util/callback_unittest.cpp b/base/util/callback_unittest.cpp similarity index 100% rename from tool_kits/base/util/callback_unittest.cpp rename to base/util/callback_unittest.cpp diff --git a/tool_kits/base/util/cmd_line_args.cpp b/base/util/cmd_line_args.cpp similarity index 100% rename from tool_kits/base/util/cmd_line_args.cpp rename to base/util/cmd_line_args.cpp diff --git a/tool_kits/base/util/cmd_line_args.h b/base/util/cmd_line_args.h similarity index 100% rename from tool_kits/base/util/cmd_line_args.h rename to base/util/cmd_line_args.h diff --git a/tool_kits/base/util/string_number_conversions.cpp b/base/util/string_number_conversions.cpp similarity index 100% rename from tool_kits/base/util/string_number_conversions.cpp rename to base/util/string_number_conversions.cpp diff --git a/tool_kits/base/util/string_number_conversions.h b/base/util/string_number_conversions.h similarity index 100% rename from tool_kits/base/util/string_number_conversions.h rename to base/util/string_number_conversions.h diff --git a/tool_kits/base/util/string_util.cpp b/base/util/string_util.cpp similarity index 100% rename from tool_kits/base/util/string_util.cpp rename to base/util/string_util.cpp diff --git a/tool_kits/base/util/string_util.h b/base/util/string_util.h similarity index 100% rename from tool_kits/base/util/string_util.h rename to base/util/string_util.h diff --git a/tool_kits/base/util/stringize_macros.h b/base/util/stringize_macros.h similarity index 100% rename from tool_kits/base/util/stringize_macros.h rename to base/util/stringize_macros.h diff --git a/tool_kits/base/util/template_util.h b/base/util/template_util.h similarity index 100% rename from tool_kits/base/util/template_util.h rename to base/util/template_util.h diff --git a/tool_kits/base/util/unicode.h b/base/util/unicode.h similarity index 100% rename from tool_kits/base/util/unicode.h rename to base/util/unicode.h diff --git a/tool_kits/base/util/valuemap.h b/base/util/valuemap.h similarity index 100% rename from tool_kits/base/util/valuemap.h rename to base/util/valuemap.h diff --git a/tool_kits/base/win32/object_watcher.cpp b/base/win32/object_watcher.cpp similarity index 100% rename from tool_kits/base/win32/object_watcher.cpp rename to base/win32/object_watcher.cpp diff --git a/tool_kits/base/win32/object_watcher.h b/base/win32/object_watcher.h similarity index 100% rename from tool_kits/base/win32/object_watcher.h rename to base/win32/object_watcher.h diff --git a/tool_kits/base/win32/path_util.cpp b/base/win32/path_util.cpp similarity index 100% rename from tool_kits/base/win32/path_util.cpp rename to base/win32/path_util.cpp diff --git a/tool_kits/base/win32/path_util.h b/base/win32/path_util.h similarity index 100% rename from tool_kits/base/win32/path_util.h rename to base/win32/path_util.h diff --git a/tool_kits/base/win32/platform_string_util.cpp b/base/win32/platform_string_util.cpp similarity index 100% rename from tool_kits/base/win32/platform_string_util.cpp rename to base/win32/platform_string_util.cpp diff --git a/tool_kits/base/win32/platform_string_util.h b/base/win32/platform_string_util.h similarity index 100% rename from tool_kits/base/win32/platform_string_util.h rename to base/win32/platform_string_util.h diff --git a/tool_kits/base/win32/scoped_win_handle.h b/base/win32/scoped_win_handle.h similarity index 100% rename from tool_kits/base/win32/scoped_win_handle.h rename to base/win32/scoped_win_handle.h diff --git a/tool_kits/base/win32/security_util.cpp b/base/win32/security_util.cpp similarity index 100% rename from tool_kits/base/win32/security_util.cpp rename to base/win32/security_util.cpp diff --git a/tool_kits/base/win32/security_util.h b/base/win32/security_util.h similarity index 100% rename from tool_kits/base/win32/security_util.h rename to base/win32/security_util.h diff --git a/tool_kits/base/win32/shared_memory.cpp b/base/win32/shared_memory.cpp similarity index 100% rename from tool_kits/base/win32/shared_memory.cpp rename to base/win32/shared_memory.cpp diff --git a/tool_kits/base/win32/shared_memory.h b/base/win32/shared_memory.h similarity index 100% rename from tool_kits/base/win32/shared_memory.h rename to base/win32/shared_memory.h diff --git a/tool_kits/base/win32/win_util.cpp b/base/win32/win_util.cpp similarity index 100% rename from tool_kits/base/win32/win_util.cpp rename to base/win32/win_util.cpp diff --git a/tool_kits/base/win32/win_util.h b/base/win32/win_util.h similarity index 100% rename from tool_kits/base/win32/win_util.h rename to base/win32/win_util.h diff --git a/tool_kits/build/build_config.h b/build/build_config.h similarity index 100% rename from tool_kits/build/build_config.h rename to build/build_config.h diff --git a/tool_kits/build/stdafx.cpp b/build/stdafx.cpp similarity index 100% rename from tool_kits/build/stdafx.cpp rename to build/stdafx.cpp diff --git a/tool_kits/build/stdafx.h b/build/stdafx.h similarity index 100% rename from tool_kits/build/stdafx.h rename to build/stdafx.h diff --git a/tool_kits/build/uac_require_admin_win.manifest b/build/uac_require_admin_win.manifest similarity index 100% rename from tool_kits/build/uac_require_admin_win.manifest rename to build/uac_require_admin_win.manifest diff --git a/tool_kits/build/winsdk_config.h b/build/winsdk_config.h similarity index 100% rename from tool_kits/build/winsdk_config.h rename to build/winsdk_config.h diff --git a/tool_kits/build/xp_style_manifest_win.h b/build/xp_style_manifest_win.h similarity index 100% rename from tool_kits/build/xp_style_manifest_win.h rename to build/xp_style_manifest_win.h diff --git a/docs/PREVIEW.gif b/docs/PREVIEW.gif index 890a7182..9e82d53e 100644 Binary files a/docs/PREVIEW.gif and b/docs/PREVIEW.gif differ diff --git a/tool_kits/duilib/Animation/AnimationManager.cpp b/duilib/Animation/AnimationManager.cpp similarity index 100% rename from tool_kits/duilib/Animation/AnimationManager.cpp rename to duilib/Animation/AnimationManager.cpp diff --git a/tool_kits/duilib/Animation/AnimationManager.h b/duilib/Animation/AnimationManager.h similarity index 100% rename from tool_kits/duilib/Animation/AnimationManager.h rename to duilib/Animation/AnimationManager.h diff --git a/tool_kits/duilib/Animation/AnimationPlayer.cpp b/duilib/Animation/AnimationPlayer.cpp similarity index 100% rename from tool_kits/duilib/Animation/AnimationPlayer.cpp rename to duilib/Animation/AnimationPlayer.cpp diff --git a/tool_kits/duilib/Animation/AnimationPlayer.h b/duilib/Animation/AnimationPlayer.h similarity index 100% rename from tool_kits/duilib/Animation/AnimationPlayer.h rename to duilib/Animation/AnimationPlayer.h diff --git a/tool_kits/duilib/Box/ChildBox.cpp b/duilib/Box/ChildBox.cpp similarity index 100% rename from tool_kits/duilib/Box/ChildBox.cpp rename to duilib/Box/ChildBox.cpp diff --git a/tool_kits/duilib/Box/ChildBox.h b/duilib/Box/ChildBox.h similarity index 100% rename from tool_kits/duilib/Box/ChildBox.h rename to duilib/Box/ChildBox.h diff --git a/tool_kits/duilib/Box/HBox.cpp b/duilib/Box/HBox.cpp similarity index 100% rename from tool_kits/duilib/Box/HBox.cpp rename to duilib/Box/HBox.cpp diff --git a/tool_kits/duilib/Box/HBox.h b/duilib/Box/HBox.h similarity index 100% rename from tool_kits/duilib/Box/HBox.h rename to duilib/Box/HBox.h diff --git a/tool_kits/duilib/Box/TabBox.cpp b/duilib/Box/TabBox.cpp similarity index 100% rename from tool_kits/duilib/Box/TabBox.cpp rename to duilib/Box/TabBox.cpp diff --git a/tool_kits/duilib/Box/TabBox.h b/duilib/Box/TabBox.h similarity index 100% rename from tool_kits/duilib/Box/TabBox.h rename to duilib/Box/TabBox.h diff --git a/tool_kits/duilib/Box/TileBox.cpp b/duilib/Box/TileBox.cpp similarity index 100% rename from tool_kits/duilib/Box/TileBox.cpp rename to duilib/Box/TileBox.cpp diff --git a/tool_kits/duilib/Box/TileBox.h b/duilib/Box/TileBox.h similarity index 100% rename from tool_kits/duilib/Box/TileBox.h rename to duilib/Box/TileBox.h diff --git a/tool_kits/duilib/Box/VBox.cpp b/duilib/Box/VBox.cpp similarity index 100% rename from tool_kits/duilib/Box/VBox.cpp rename to duilib/Box/VBox.cpp diff --git a/tool_kits/duilib/Box/VBox.h b/duilib/Box/VBox.h similarity index 100% rename from tool_kits/duilib/Box/VBox.h rename to duilib/Box/VBox.h diff --git a/tool_kits/duilib/Control/Button.h b/duilib/Control/Button.h similarity index 100% rename from tool_kits/duilib/Control/Button.h rename to duilib/Control/Button.h diff --git a/tool_kits/duilib/Control/CheckBox.h b/duilib/Control/CheckBox.h similarity index 100% rename from tool_kits/duilib/Control/CheckBox.h rename to duilib/Control/CheckBox.h diff --git a/tool_kits/duilib/Control/CircleProgress.cpp b/duilib/Control/CircleProgress.cpp similarity index 96% rename from tool_kits/duilib/Control/CircleProgress.cpp rename to duilib/Control/CircleProgress.cpp index 63355586..c9b818b8 100644 --- a/tool_kits/duilib/Control/CircleProgress.cpp +++ b/duilib/Control/CircleProgress.cpp @@ -1,205 +1,205 @@ -#include "stdafx.h" -#include "CircleProgress.h" -#include "shlwapi.h" - -namespace ui -{ - -CircleProgress::CircleProgress() : - m_bCircular(true), - m_bClockwise(true), - m_nCircleWidth(1), - m_dwBackgroundColor(0), - m_dwForegroundColor(0), - m_dwGradientColor(0), - m_pIndicator(nullptr) -{ - -} - -void CircleProgress::SetAttribute(const std::wstring& srName, const std::wstring& strValue) -{ - if (srName == _T("circular")) SetCircular(strValue == _T("true")); - else if (srName == _T("circlewidth")) SetCircleWidth(_ttoi(strValue.c_str())); - else if (srName == _T("indicator")) SetIndicator(strValue); - else if (srName == _T("clockwise")) SetClockwiseRotation(strValue == _T("true")); - else if (srName == _T("bgcolor")) { - LPCTSTR pValue = strValue.c_str(); - while (*pValue > _T('\0') && *pValue <= _T(' ')) pValue = ::CharNext(pValue); - SetBackgroudColor(pValue); - } - else if (srName == _T("fgcolor")) { - LPCTSTR pValue = strValue.c_str(); - while (*pValue > _T('\0') && *pValue <= _T(' ')) pValue = ::CharNext(pValue); - SetForegroudColor(pValue); - } - else if (srName == _T("gradientcolor")) { - LPCTSTR pValue = strValue.c_str(); - while (*pValue > _T('\0') && *pValue <= _T(' ')) pValue = ::CharNext(pValue); - SetCircleGradientColor(pValue); - } - else Progress::SetAttribute(srName, strValue); -} - -void CircleProgress::PaintStatusImage(IRenderContext* pRender) -{ - Progress::PaintStatusImage(pRender); - if (m_bCircular) - { - //ĿǰIRenderContextкܶGDI+ӿδʵ֣ʱֱgdi+ͼ - //Ժܻʵ1DrawArc 2Penbrush() 3Graphics - int direction = m_bClockwise ? 1 : -1; //ת - int bordersize = 1; //ȿĿǰʹ1 - - Gdiplus::Graphics graphics(pRender->GetDC()); - graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); - Gdiplus::Pen bgPen(m_dwBackgroundColor, m_nCircleWidth); - // Բ - CPoint center; - center.x = m_rcItem.left + (m_rcItem.right - m_rcItem.left) / 2; - center.y = m_rcItem.top + (m_rcItem.bottom - m_rcItem.top) / 2; - - // ؼڵεı߽ - int side = min(m_rcItem.right - m_rcItem.left, m_rcItem.bottom - m_rcItem.top); - //UiRect rcBorder; ȻUiRect RectFתֱgdiRectF - Gdiplus::RectF rcBorder; - rcBorder.X = center.x - side / 2; - rcBorder.Y = center.y - side / 2; - rcBorder.Width = rcBorder.Height = side; - - Gdiplus::RectF outer = rcBorder; - if (m_pIndicator) { - outer.Inflate(-1.0F *m_pIndicator->GetWidth() / 2, -1.0F * m_pIndicator->GetWidth() / 2); - } - else - { - outer.Inflate(-0.5 * m_nCircleWidth, -0.5 * m_nCircleWidth); - } - outer.Inflate(-1, -1); - - - if (m_dwGradientColor == 0) - { - //ʹýɫֱǰɫ - Gdiplus::Pen fgPen(m_dwForegroundColor, m_nCircleWidth); - graphics.DrawArc(&bgPen, outer, 270, 360); //270濪ʼΪ0Ļұ߿ʼ - graphics.DrawArc(&fgPen, outer, 270, direction * 360 * (m_nValue - m_nMin) / (m_nMax - m_nMin)); - } - else - { - Gdiplus::REAL factors[4] = { 0.0f, 0.4f, 0.6f, 1.0f }; - Gdiplus::REAL positions[4] = { 0.0f, 0.2f, 0.8f, 1.0f }; - - Gdiplus::LinearGradientBrush lgbrush(rcBorder, m_dwForegroundColor, m_dwGradientColor, Gdiplus::LinearGradientModeVertical); - lgbrush.SetBlend(factors, positions, 4); - graphics.DrawArc(&bgPen, outer, 270, 360); - Gdiplus::Pen fgPen(&lgbrush, m_nCircleWidth); - graphics.DrawArc(&fgPen, outer, 270, direction * 360 * (m_nValue - m_nMin) / (m_nMax - m_nMin)); - - } - - //תָʾͼ꣬Ҫõ - if (m_pIndicator) - { - Gdiplus::Matrix matrix; - matrix.RotateAt(direction * 360 * (m_nValue - m_nMin) / (m_nMax - m_nMin), Gdiplus::PointF(center.x, center.y), Gdiplus::MatrixOrderAppend); - graphics.SetTransform(&matrix); - Gdiplus::RectF rectf; - rectf.X = center.x - m_pIndicator->GetWidth() / 2; - rectf.Y = outer.Y + bordersize / 2 - m_pIndicator->GetHeight() / 2; - rectf.Width = m_pIndicator->GetWidth(); - rectf.Height = m_pIndicator->GetHeight(); - graphics.DrawImage(m_pIndicator, rectf); - } - - } -} - -void CircleProgress::ClearImageCache() -{ - __super::ClearImageCache(); - if (m_pIndicator) - { - delete m_pIndicator; - m_pIndicator = nullptr; - } -} - -void CircleProgress::SetCircular(bool bCircular /*= true*/) -{ - m_bCircular = bCircular; - Invalidate(); -} - -void CircleProgress::SetClockwiseRotation(bool bClockwise /*= true*/) -{ - if (bClockwise != m_bClockwise) - { - m_bClockwise = bClockwise; - if (m_pIndicator) - { - //ѾתͼƬת෴ķ - m_pIndicator->RotateFlip(Gdiplus::Rotate180FlipNone); - } - - } -} - -void CircleProgress::SetCircleWidth(int nCircleWidth) -{ - m_nCircleWidth = nCircleWidth; - Invalidate(); -} - - -void CircleProgress::SetBackgroudColor(const std::wstring& strColor) -{ - m_dwBackgroundColor = GlobalManager::GetTextColor(strColor); - ASSERT(m_dwBackgroundColor != 0); - Invalidate(); -} - -void CircleProgress::SetForegroudColor(const std::wstring& strColor) -{ - m_dwForegroundColor = GlobalManager::GetTextColor(strColor); - ASSERT(m_dwForegroundColor != 0); - Invalidate(); -} - -void CircleProgress::SetIndicator(const std::wstring& sIndicatorImage) -{ - if (m_sIndicatorImage != sIndicatorImage) - { - m_sIndicatorImage = sIndicatorImage; - if (m_pIndicator) - { - delete m_pIndicator; - m_pIndicator = nullptr; - } - std::wstring imagepath = m_sIndicatorImage; - if (!::PathFileExistsW(imagepath.c_str())) { - imagepath = GlobalManager::GetResourcePath() + m_pWindow->GetWindowResourcePath() + imagepath; - } - if (!::PathFileExistsW(imagepath.c_str())) { - return; - } - m_pIndicator = new Gdiplus::Image(imagepath.c_str()); - - Gdiplus::Status state = m_pIndicator->GetLastStatus(); - if (Gdiplus::Ok == state) - { - // ٶͼƬָ - m_pIndicator->RotateFlip(m_bClockwise ? Gdiplus::Rotate90FlipNone : Gdiplus::Rotate270FlipNone); - Invalidate(); - } - } -} - -void CircleProgress::SetCircleGradientColor(const std::wstring& strColor) -{ - m_dwGradientColor = GlobalManager::GetTextColor(strColor); - ASSERT(m_dwGradientColor != 0); - Invalidate(); -} - -} +#include "stdafx.h" +#include "CircleProgress.h" +#include "shlwapi.h" + +namespace ui +{ + +CircleProgress::CircleProgress() : + m_bCircular(true), + m_bClockwise(true), + m_nCircleWidth(1), + m_dwBackgroundColor(0), + m_dwForegroundColor(0), + m_dwGradientColor(0), + m_pIndicator(nullptr) +{ + +} + +void CircleProgress::SetAttribute(const std::wstring& srName, const std::wstring& strValue) +{ + if (srName == _T("circular")) SetCircular(strValue == _T("true")); + else if (srName == _T("circlewidth")) SetCircleWidth(_ttoi(strValue.c_str())); + else if (srName == _T("indicator")) SetIndicator(strValue); + else if (srName == _T("clockwise")) SetClockwiseRotation(strValue == _T("true")); + else if (srName == _T("bgcolor")) { + LPCTSTR pValue = strValue.c_str(); + while (*pValue > _T('\0') && *pValue <= _T(' ')) pValue = ::CharNext(pValue); + SetBackgroudColor(pValue); + } + else if (srName == _T("fgcolor")) { + LPCTSTR pValue = strValue.c_str(); + while (*pValue > _T('\0') && *pValue <= _T(' ')) pValue = ::CharNext(pValue); + SetForegroudColor(pValue); + } + else if (srName == _T("gradientcolor")) { + LPCTSTR pValue = strValue.c_str(); + while (*pValue > _T('\0') && *pValue <= _T(' ')) pValue = ::CharNext(pValue); + SetCircleGradientColor(pValue); + } + else Progress::SetAttribute(srName, strValue); +} + +void CircleProgress::PaintStatusImage(IRenderContext* pRender) +{ + Progress::PaintStatusImage(pRender); + if (m_bCircular) + { + //ĿǰIRenderContextкܶGDI+ӿδʵ֣ʱֱgdi+ͼ + //Ժܻʵ1DrawArc 2Penbrush() 3Graphics + int direction = m_bClockwise ? 1 : -1; //ת + int bordersize = 1; //ȿĿǰʹ1 + + Gdiplus::Graphics graphics(pRender->GetDC()); + graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); + Gdiplus::Pen bgPen(m_dwBackgroundColor, m_nCircleWidth); + // Բ + CPoint center; + center.x = m_rcItem.left + (m_rcItem.right - m_rcItem.left) / 2; + center.y = m_rcItem.top + (m_rcItem.bottom - m_rcItem.top) / 2; + + // ؼڵεı߽ + int side = min(m_rcItem.right - m_rcItem.left, m_rcItem.bottom - m_rcItem.top); + //UiRect rcBorder; ȻUiRect RectFתֱgdiRectF + Gdiplus::RectF rcBorder; + rcBorder.X = center.x - side / 2; + rcBorder.Y = center.y - side / 2; + rcBorder.Width = rcBorder.Height = side; + + Gdiplus::RectF outer = rcBorder; + if (m_pIndicator) { + outer.Inflate(-1.0F *m_pIndicator->GetWidth() / 2, -1.0F * m_pIndicator->GetWidth() / 2); + } + else + { + outer.Inflate(-0.5 * m_nCircleWidth, -0.5 * m_nCircleWidth); + } + outer.Inflate(-1, -1); + + + if (m_dwGradientColor == 0) + { + //ʹýɫֱǰɫ + Gdiplus::Pen fgPen(m_dwForegroundColor, m_nCircleWidth); + graphics.DrawArc(&bgPen, outer, 270, 360); //270濪ʼΪ0Ļұ߿ʼ + graphics.DrawArc(&fgPen, outer, 270, direction * 360 * (m_nValue - m_nMin) / (m_nMax - m_nMin)); + } + else + { + Gdiplus::REAL factors[4] = { 0.0f, 0.4f, 0.6f, 1.0f }; + Gdiplus::REAL positions[4] = { 0.0f, 0.2f, 0.8f, 1.0f }; + + Gdiplus::LinearGradientBrush lgbrush(rcBorder, m_dwForegroundColor, m_dwGradientColor, Gdiplus::LinearGradientModeVertical); + lgbrush.SetBlend(factors, positions, 4); + graphics.DrawArc(&bgPen, outer, 270, 360); + Gdiplus::Pen fgPen(&lgbrush, m_nCircleWidth); + graphics.DrawArc(&fgPen, outer, 270, direction * 360 * (m_nValue - m_nMin) / (m_nMax - m_nMin)); + + } + + //תָʾͼ꣬Ҫõ + if (m_pIndicator) + { + Gdiplus::Matrix matrix; + matrix.RotateAt(direction * 360 * (m_nValue - m_nMin) / (m_nMax - m_nMin), Gdiplus::PointF(center.x, center.y), Gdiplus::MatrixOrderAppend); + graphics.SetTransform(&matrix); + Gdiplus::RectF rectf; + rectf.X = center.x - m_pIndicator->GetWidth() / 2; + rectf.Y = outer.Y + bordersize / 2 - m_pIndicator->GetHeight() / 2; + rectf.Width = m_pIndicator->GetWidth(); + rectf.Height = m_pIndicator->GetHeight(); + graphics.DrawImage(m_pIndicator, rectf); + } + + } +} + +void CircleProgress::ClearImageCache() +{ + __super::ClearImageCache(); + if (m_pIndicator) + { + delete m_pIndicator; + m_pIndicator = nullptr; + } +} + +void CircleProgress::SetCircular(bool bCircular /*= true*/) +{ + m_bCircular = bCircular; + Invalidate(); +} + +void CircleProgress::SetClockwiseRotation(bool bClockwise /*= true*/) +{ + if (bClockwise != m_bClockwise) + { + m_bClockwise = bClockwise; + if (m_pIndicator) + { + //ѾתͼƬת෴ķ + m_pIndicator->RotateFlip(Gdiplus::Rotate180FlipNone); + } + + } +} + +void CircleProgress::SetCircleWidth(int nCircleWidth) +{ + m_nCircleWidth = nCircleWidth; + Invalidate(); +} + + +void CircleProgress::SetBackgroudColor(const std::wstring& strColor) +{ + m_dwBackgroundColor = GlobalManager::GetTextColor(strColor); + ASSERT(m_dwBackgroundColor != 0); + Invalidate(); +} + +void CircleProgress::SetForegroudColor(const std::wstring& strColor) +{ + m_dwForegroundColor = GlobalManager::GetTextColor(strColor); + ASSERT(m_dwForegroundColor != 0); + Invalidate(); +} + +void CircleProgress::SetIndicator(const std::wstring& sIndicatorImage) +{ + if (m_sIndicatorImage != sIndicatorImage) + { + m_sIndicatorImage = sIndicatorImage; + if (m_pIndicator) + { + delete m_pIndicator; + m_pIndicator = nullptr; + } + std::wstring imagepath = m_sIndicatorImage; + if (!::PathFileExistsW(imagepath.c_str())) { + imagepath = GlobalManager::GetResourcePath() + m_pWindow->GetWindowResourcePath() + imagepath; + } + if (!::PathFileExistsW(imagepath.c_str())) { + return; + } + m_pIndicator = new Gdiplus::Image(imagepath.c_str()); + + Gdiplus::Status state = m_pIndicator->GetLastStatus(); + if (Gdiplus::Ok == state) + { + // ٶͼƬָ + m_pIndicator->RotateFlip(m_bClockwise ? Gdiplus::Rotate90FlipNone : Gdiplus::Rotate270FlipNone); + Invalidate(); + } + } +} + +void CircleProgress::SetCircleGradientColor(const std::wstring& strColor) +{ + m_dwGradientColor = GlobalManager::GetTextColor(strColor); + ASSERT(m_dwGradientColor != 0); + Invalidate(); +} + +} diff --git a/tool_kits/duilib/Control/CircleProgress.h b/duilib/Control/CircleProgress.h similarity index 96% rename from tool_kits/duilib/Control/CircleProgress.h rename to duilib/Control/CircleProgress.h index c3e4c008..f0d1ba10 100644 --- a/tool_kits/duilib/Control/CircleProgress.h +++ b/duilib/Control/CircleProgress.h @@ -1,89 +1,89 @@ -/** @file CircleProgress.h -* @brief ͽؼԲмı85% -* @copyright (c) 2019-2022, NetEase Inc. All rights reserved -* @author Xuhuajie -* @date 2019/8/14 -*/ - -#ifndef UI_CONTROL_CIRCLEPROGRESS_H_ -#define UI_CONTROL_CIRCLEPROGRESS_H_ - -#pragma once - -namespace ui -{ - -class UILIB_API CircleProgress : public Progress -{ -public: - CircleProgress(); - - /// д෽ṩԻܣο - virtual void SetAttribute(const std::wstring& strName, const std::wstring& strValue) override; - virtual void PaintStatusImage(IRenderContext* pRender) override; - virtual void ClearImageCache() override; - - /** - * @brief ûͽĬΪͨ - * @param[in] bCircular Ϊ true ʱΪͽfalse ʱΪʽĬΪ true - * @return - */ - void SetCircular(bool bCircular = true); - - /** - * @brief õ - * @param[in] bClockwise Ϊ true ʱΪ˳ʱ룬false ʱΪʱ룬ĬΪ true - * @return - */ - void SetClockwiseRotation(bool bClockwise = true); - - /** - * @brief Բ - * @param[in] nCircleWidth ֵ - * @return - */ - void SetCircleWidth(int nCircleWidth); - - /** - * @brief ýɫ - * @param[in] strColorҪõıɫַַ global.xml д - * @return - */ - void SetBackgroudColor(const std::wstring& strColor); - - /** - * @brief ýǰɫ - * @param[in] strColorҪõǰɫַַ global.xml д - * @return - */ - void SetForegroudColor(const std::wstring& strColor); - - /** - * @brief ýǰɫ SetForegroudColor ͬʱʹãԲ,޽Ч - * @param[in] strColorҪõǰɫַַ global.xml д - * @return - */ - void SetCircleGradientColor(const std::wstring& strColor); - - /** - * @brief ýָʾƶͼ - * @param[in] sIndicatorImage ҪõͼƬ - * @return - */ - void SetIndicator(const std::wstring& sIndicatorImage); - -protected: - bool m_bCircular; - bool m_bClockwise; - int m_nCircleWidth; - DWORD m_dwBackgroundColor; - DWORD m_dwForegroundColor; - DWORD m_dwGradientColor; - Gdiplus::Image* m_pIndicator; //ĿǰάԴ - std::wstring m_sIndicatorImage; - -}; - -} // namespace ui - -#endif // UI_CONTROL_CIRCLEPROGRESS_H_ +/** @file CircleProgress.h +* @brief ͽؼԲмı85% +* @copyright (c) 2019-2022, NetEase Inc. All rights reserved +* @author Xuhuajie +* @date 2019/8/14 +*/ + +#ifndef UI_CONTROL_CIRCLEPROGRESS_H_ +#define UI_CONTROL_CIRCLEPROGRESS_H_ + +#pragma once + +namespace ui +{ + +class UILIB_API CircleProgress : public Progress +{ +public: + CircleProgress(); + + /// д෽ṩԻܣο + virtual void SetAttribute(const std::wstring& strName, const std::wstring& strValue) override; + virtual void PaintStatusImage(IRenderContext* pRender) override; + virtual void ClearImageCache() override; + + /** + * @brief ûͽĬΪͨ + * @param[in] bCircular Ϊ true ʱΪͽfalse ʱΪʽĬΪ true + * @return + */ + void SetCircular(bool bCircular = true); + + /** + * @brief õ + * @param[in] bClockwise Ϊ true ʱΪ˳ʱ룬false ʱΪʱ룬ĬΪ true + * @return + */ + void SetClockwiseRotation(bool bClockwise = true); + + /** + * @brief Բ + * @param[in] nCircleWidth ֵ + * @return + */ + void SetCircleWidth(int nCircleWidth); + + /** + * @brief ýɫ + * @param[in] strColorҪõıɫַַ global.xml д + * @return + */ + void SetBackgroudColor(const std::wstring& strColor); + + /** + * @brief ýǰɫ + * @param[in] strColorҪõǰɫַַ global.xml д + * @return + */ + void SetForegroudColor(const std::wstring& strColor); + + /** + * @brief ýǰɫ SetForegroudColor ͬʱʹãԲ,޽Ч + * @param[in] strColorҪõǰɫַַ global.xml д + * @return + */ + void SetCircleGradientColor(const std::wstring& strColor); + + /** + * @brief ýָʾƶͼ + * @param[in] sIndicatorImage ҪõͼƬ + * @return + */ + void SetIndicator(const std::wstring& sIndicatorImage); + +protected: + bool m_bCircular; + bool m_bClockwise; + int m_nCircleWidth; + DWORD m_dwBackgroundColor; + DWORD m_dwForegroundColor; + DWORD m_dwGradientColor; + Gdiplus::Image* m_pIndicator; //ĿǰάԴ + std::wstring m_sIndicatorImage; + +}; + +} // namespace ui + +#endif // UI_CONTROL_CIRCLEPROGRESS_H_ diff --git a/tool_kits/duilib/Control/Combo.cpp b/duilib/Control/Combo.cpp similarity index 100% rename from tool_kits/duilib/Control/Combo.cpp rename to duilib/Control/Combo.cpp diff --git a/tool_kits/duilib/Control/Combo.h b/duilib/Control/Combo.h similarity index 100% rename from tool_kits/duilib/Control/Combo.h rename to duilib/Control/Combo.h diff --git a/tool_kits/duilib/Control/Label.h b/duilib/Control/Label.h similarity index 100% rename from tool_kits/duilib/Control/Label.h rename to duilib/Control/Label.h diff --git a/tool_kits/duilib/Control/List.cpp b/duilib/Control/List.cpp similarity index 100% rename from tool_kits/duilib/Control/List.cpp rename to duilib/Control/List.cpp diff --git a/tool_kits/duilib/Control/List.h b/duilib/Control/List.h similarity index 100% rename from tool_kits/duilib/Control/List.h rename to duilib/Control/List.h diff --git a/tool_kits/duilib/Control/Option.h b/duilib/Control/Option.h similarity index 100% rename from tool_kits/duilib/Control/Option.h rename to duilib/Control/Option.h diff --git a/tool_kits/duilib/Control/Progress.cpp b/duilib/Control/Progress.cpp similarity index 100% rename from tool_kits/duilib/Control/Progress.cpp rename to duilib/Control/Progress.cpp diff --git a/tool_kits/duilib/Control/Progress.h b/duilib/Control/Progress.h similarity index 100% rename from tool_kits/duilib/Control/Progress.h rename to duilib/Control/Progress.h diff --git a/tool_kits/duilib/Control/RichEdit.cpp b/duilib/Control/RichEdit.cpp similarity index 100% rename from tool_kits/duilib/Control/RichEdit.cpp rename to duilib/Control/RichEdit.cpp diff --git a/tool_kits/duilib/Control/RichEdit.h b/duilib/Control/RichEdit.h similarity index 100% rename from tool_kits/duilib/Control/RichEdit.h rename to duilib/Control/RichEdit.h diff --git a/tool_kits/duilib/Control/ScrollBar.cpp b/duilib/Control/ScrollBar.cpp similarity index 100% rename from tool_kits/duilib/Control/ScrollBar.cpp rename to duilib/Control/ScrollBar.cpp diff --git a/tool_kits/duilib/Control/ScrollBar.h b/duilib/Control/ScrollBar.h similarity index 100% rename from tool_kits/duilib/Control/ScrollBar.h rename to duilib/Control/ScrollBar.h diff --git a/tool_kits/duilib/Control/Slider.cpp b/duilib/Control/Slider.cpp similarity index 100% rename from tool_kits/duilib/Control/Slider.cpp rename to duilib/Control/Slider.cpp diff --git a/tool_kits/duilib/Control/Slider.h b/duilib/Control/Slider.h similarity index 100% rename from tool_kits/duilib/Control/Slider.h rename to duilib/Control/Slider.h diff --git a/tool_kits/duilib/Control/TreeView.cpp b/duilib/Control/TreeView.cpp similarity index 100% rename from tool_kits/duilib/Control/TreeView.cpp rename to duilib/Control/TreeView.cpp diff --git a/tool_kits/duilib/Control/TreeView.h b/duilib/Control/TreeView.h similarity index 100% rename from tool_kits/duilib/Control/TreeView.h rename to duilib/Control/TreeView.h diff --git a/tool_kits/duilib/Control/VirtualListBox.cpp b/duilib/Control/VirtualListBox.cpp similarity index 100% rename from tool_kits/duilib/Control/VirtualListBox.cpp rename to duilib/Control/VirtualListBox.cpp diff --git a/tool_kits/duilib/Control/VirtualListBox.h b/duilib/Control/VirtualListBox.h similarity index 100% rename from tool_kits/duilib/Control/VirtualListBox.h rename to duilib/Control/VirtualListBox.h diff --git a/tool_kits/duilib/Core/Box.cpp b/duilib/Core/Box.cpp similarity index 100% rename from tool_kits/duilib/Core/Box.cpp rename to duilib/Core/Box.cpp diff --git a/tool_kits/duilib/Core/Box.h b/duilib/Core/Box.h similarity index 100% rename from tool_kits/duilib/Core/Box.h rename to duilib/Core/Box.h diff --git a/tool_kits/duilib/Core/Control.cpp b/duilib/Core/Control.cpp similarity index 100% rename from tool_kits/duilib/Core/Control.cpp rename to duilib/Core/Control.cpp diff --git a/tool_kits/duilib/Core/Control.h b/duilib/Core/Control.h similarity index 100% rename from tool_kits/duilib/Core/Control.h rename to duilib/Core/Control.h diff --git a/tool_kits/duilib/Core/Define.cpp b/duilib/Core/Define.cpp similarity index 100% rename from tool_kits/duilib/Core/Define.cpp rename to duilib/Core/Define.cpp diff --git a/tool_kits/duilib/Core/Define.h b/duilib/Core/Define.h similarity index 100% rename from tool_kits/duilib/Core/Define.h rename to duilib/Core/Define.h diff --git a/tool_kits/duilib/Core/GlobalManager.cpp b/duilib/Core/GlobalManager.cpp similarity index 100% rename from tool_kits/duilib/Core/GlobalManager.cpp rename to duilib/Core/GlobalManager.cpp diff --git a/tool_kits/duilib/Core/GlobalManager.h b/duilib/Core/GlobalManager.h similarity index 100% rename from tool_kits/duilib/Core/GlobalManager.h rename to duilib/Core/GlobalManager.h diff --git a/tool_kits/duilib/Core/Image.cpp b/duilib/Core/Image.cpp similarity index 100% rename from tool_kits/duilib/Core/Image.cpp rename to duilib/Core/Image.cpp diff --git a/tool_kits/duilib/Core/Image.h b/duilib/Core/Image.h similarity index 100% rename from tool_kits/duilib/Core/Image.h rename to duilib/Core/Image.h diff --git a/tool_kits/duilib/Core/Markup.cpp b/duilib/Core/Markup.cpp similarity index 100% rename from tool_kits/duilib/Core/Markup.cpp rename to duilib/Core/Markup.cpp diff --git a/tool_kits/duilib/Core/Markup.h b/duilib/Core/Markup.h similarity index 100% rename from tool_kits/duilib/Core/Markup.h rename to duilib/Core/Markup.h diff --git a/tool_kits/duilib/Core/Placeholder.cpp b/duilib/Core/Placeholder.cpp similarity index 100% rename from tool_kits/duilib/Core/Placeholder.cpp rename to duilib/Core/Placeholder.cpp diff --git a/tool_kits/duilib/Core/Placeholder.h b/duilib/Core/Placeholder.h similarity index 100% rename from tool_kits/duilib/Core/Placeholder.h rename to duilib/Core/Placeholder.h diff --git a/tool_kits/duilib/Core/Window.cpp b/duilib/Core/Window.cpp similarity index 100% rename from tool_kits/duilib/Core/Window.cpp rename to duilib/Core/Window.cpp diff --git a/tool_kits/duilib/Core/Window.h b/duilib/Core/Window.h similarity index 100% rename from tool_kits/duilib/Core/Window.h rename to duilib/Core/Window.h diff --git a/tool_kits/duilib/Core/WindowBuilder.cpp b/duilib/Core/WindowBuilder.cpp similarity index 100% rename from tool_kits/duilib/Core/WindowBuilder.cpp rename to duilib/Core/WindowBuilder.cpp diff --git a/tool_kits/duilib/Core/WindowBuilder.h b/duilib/Core/WindowBuilder.h similarity index 100% rename from tool_kits/duilib/Core/WindowBuilder.h rename to duilib/Core/WindowBuilder.h diff --git a/tool_kits/duilib/Render/Bitmap.cpp b/duilib/Render/Bitmap.cpp similarity index 100% rename from tool_kits/duilib/Render/Bitmap.cpp rename to duilib/Render/Bitmap.cpp diff --git a/tool_kits/duilib/Render/Bitmap.h b/duilib/Render/Bitmap.h similarity index 100% rename from tool_kits/duilib/Render/Bitmap.h rename to duilib/Render/Bitmap.h diff --git a/tool_kits/duilib/Render/Brush.cpp b/duilib/Render/Brush.cpp similarity index 100% rename from tool_kits/duilib/Render/Brush.cpp rename to duilib/Render/Brush.cpp diff --git a/tool_kits/duilib/Render/Brush.h b/duilib/Render/Brush.h similarity index 100% rename from tool_kits/duilib/Render/Brush.h rename to duilib/Render/Brush.h diff --git a/tool_kits/duilib/Render/Clip.cpp b/duilib/Render/Clip.cpp similarity index 100% rename from tool_kits/duilib/Render/Clip.cpp rename to duilib/Render/Clip.cpp diff --git a/tool_kits/duilib/Render/Clip.h b/duilib/Render/Clip.h similarity index 100% rename from tool_kits/duilib/Render/Clip.h rename to duilib/Render/Clip.h diff --git a/tool_kits/duilib/Render/Factory.cpp b/duilib/Render/Factory.cpp similarity index 100% rename from tool_kits/duilib/Render/Factory.cpp rename to duilib/Render/Factory.cpp diff --git a/tool_kits/duilib/Render/Factory.h b/duilib/Render/Factory.h similarity index 100% rename from tool_kits/duilib/Render/Factory.h rename to duilib/Render/Factory.h diff --git a/tool_kits/duilib/Render/IRender.cpp b/duilib/Render/IRender.cpp similarity index 100% rename from tool_kits/duilib/Render/IRender.cpp rename to duilib/Render/IRender.cpp diff --git a/tool_kits/duilib/Render/IRender.h b/duilib/Render/IRender.h similarity index 100% rename from tool_kits/duilib/Render/IRender.h rename to duilib/Render/IRender.h diff --git a/tool_kits/duilib/Render/Matrix.cpp b/duilib/Render/Matrix.cpp similarity index 100% rename from tool_kits/duilib/Render/Matrix.cpp rename to duilib/Render/Matrix.cpp diff --git a/tool_kits/duilib/Render/Matrix.h b/duilib/Render/Matrix.h similarity index 100% rename from tool_kits/duilib/Render/Matrix.h rename to duilib/Render/Matrix.h diff --git a/tool_kits/duilib/Render/Path.cpp b/duilib/Render/Path.cpp similarity index 100% rename from tool_kits/duilib/Render/Path.cpp rename to duilib/Render/Path.cpp diff --git a/tool_kits/duilib/Render/Path.h b/duilib/Render/Path.h similarity index 100% rename from tool_kits/duilib/Render/Path.h rename to duilib/Render/Path.h diff --git a/tool_kits/duilib/Render/Pen.cpp b/duilib/Render/Pen.cpp similarity index 100% rename from tool_kits/duilib/Render/Pen.cpp rename to duilib/Render/Pen.cpp diff --git a/tool_kits/duilib/Render/Pen.h b/duilib/Render/Pen.h similarity index 100% rename from tool_kits/duilib/Render/Pen.h rename to duilib/Render/Pen.h diff --git a/tool_kits/duilib/Render/Render.cpp b/duilib/Render/Render.cpp similarity index 97% rename from tool_kits/duilib/Render/Render.cpp rename to duilib/Render/Render.cpp index 452a85a2..cb6a7682 100644 --- a/tool_kits/duilib/Render/Render.cpp +++ b/duilib/Render/Render.cpp @@ -1,626 +1,626 @@ -#include "StdAfx.h" - -namespace ui { - -static inline void DrawFunction(HDC hDC, bool bTransparent, UiRect rcDest, HDC hdcSrc, UiRect rcSrc, bool bAlphaChannel, int uFade) -{ - if (bTransparent || bAlphaChannel || uFade < 255 - || (rcSrc.GetWidth() == rcDest.GetWidth() && rcSrc.GetHeight() == rcDest.GetHeight())) { - BLENDFUNCTION ftn = { AC_SRC_OVER, 0, uFade, AC_SRC_ALPHA }; - ::AlphaBlend(hDC, rcDest.left, rcDest.top, rcDest.GetWidth(), rcDest.GetHeight(), - hdcSrc, rcSrc.left, rcSrc.top, rcSrc.GetWidth(), rcSrc.GetHeight(), ftn); - } - else { - ::StretchBlt(hDC, rcDest.left, rcDest.top, rcDest.GetWidth(), rcDest.GetHeight(), - hdcSrc, rcSrc.left, rcSrc.top, rcSrc.GetWidth(), rcSrc.GetHeight(), SRCCOPY); - } -} - -RenderContext_GdiPlus::RenderContext_GdiPlus() - : m_hDC(NULL) - , m_hOldBitmap(NULL) - , m_bTransparent(false) -{ - HDC hDC = ::GetDC(NULL); - m_hDC = ::CreateCompatibleDC(hDC); - ::ReleaseDC(NULL, hDC); - ASSERT(m_hDC); -} - -RenderContext_GdiPlus::~RenderContext_GdiPlus() -{ - if (m_hOldBitmap != NULL) - { - ::SelectObject(m_hDC, m_hOldBitmap); - m_hOldBitmap = NULL; - } - - if (m_hDC != NULL) - { - ::DeleteDC(m_hDC); - m_hDC = NULL; - } -} - -HDC RenderContext_GdiPlus::GetDC() -{ - return m_hDC; -} - -bool RenderContext_GdiPlus::Resize(int width, int height, bool flipBItmap) -{ - ASSERT(m_hDC); - if (m_bitmap.GetWidth() == width && m_bitmap.GetHeight() == height) - return false; - - if (m_hOldBitmap != NULL) - { - ::SelectObject(m_hDC, m_hOldBitmap); - } - - bool ret = m_bitmap.Init(m_hDC, width, height, flipBItmap); - m_hOldBitmap = (HBITMAP)::SelectObject(m_hDC, m_bitmap.GetBitmap()); - return ret; -} - -void RenderContext_GdiPlus::Clear() -{ - ASSERT(m_hDC); - m_bitmap.Clear(); -} - -std::unique_ptr RenderContext_GdiPlus::Clone() -{ - std::unique_ptr pClone = std::make_unique(); - pClone->Resize(GetWidth(), GetHeight()); - pClone->BitBlt(0, 0, GetWidth(), GetHeight(), m_hDC); - return pClone; -} - -HBITMAP RenderContext_GdiPlus::DetachBitmap() -{ - ASSERT(m_hDC && m_hOldBitmap); - ASSERT(m_bitmap.GetHeight() != 0 && m_bitmap.GetWidth() != 0); - if (m_hOldBitmap == NULL) - return NULL; - - ::SelectObject(m_hDC, m_hOldBitmap); - return m_bitmap.DetachBitmap(); -} - -BYTE* RenderContext_GdiPlus::GetBits() -{ - return m_bitmap.GetBits(); -} - -int RenderContext_GdiPlus::GetWidth() -{ - return m_bitmap.GetWidth(); -} - -int RenderContext_GdiPlus::GetHeight() -{ - return m_bitmap.GetHeight(); -} - -void RenderContext_GdiPlus::ClearAlpha(const UiRect& rcDirty, int alpha) -{ - m_bitmap.ClearAlpha(rcDirty, alpha); -} - -void RenderContext_GdiPlus::RestoreAlpha(const UiRect& rcDirty, const UiRect& rcShadowPadding, int alpha) -{ - m_bitmap.RestoreAlpha(rcDirty, rcShadowPadding, alpha); -} - -bool RenderContext_GdiPlus::IsRenderTransparent() const -{ - return m_bTransparent; -} - -bool RenderContext_GdiPlus::SetRenderTransparent(bool bTransparent) -{ - bool oldValue = m_bTransparent; - m_bTransparent = bTransparent; - return oldValue; -} - -void RenderContext_GdiPlus::Save() -{ - m_saveDC = SaveDC(m_hDC); -} - -void RenderContext_GdiPlus::Restore() -{ - RestoreDC(m_hDC, m_saveDC); -} - -CPoint RenderContext_GdiPlus::OffsetWindowOrg(CPoint ptOffset) -{ - CPoint ptOldWindowOrg; - GetWindowOrgEx(m_hDC, &ptOldWindowOrg); - ptOffset.Offset(ptOldWindowOrg.x, ptOldWindowOrg.y); - ::SetWindowOrgEx(m_hDC, ptOffset.x, ptOffset.y, NULL); - return ptOldWindowOrg; -} - -CPoint RenderContext_GdiPlus::SetWindowOrg(CPoint ptOffset) -{ - CPoint ptOldWindowOrg; - GetWindowOrgEx(m_hDC, &ptOldWindowOrg); - ::SetWindowOrgEx(m_hDC, ptOffset.x, ptOffset.y, NULL); - return ptOldWindowOrg; -} - -CPoint RenderContext_GdiPlus::GetWindowOrg() const -{ - CPoint ptWindowOrg; - GetWindowOrgEx(m_hDC, &ptWindowOrg); - return ptWindowOrg; -} - -void RenderContext_GdiPlus::SetClip(const UiRect& rc) -{ - m_clip.CreateClip(m_hDC, rc); -} - -void RenderContext_GdiPlus::SetRoundClip(const UiRect& rc, int width, int height) -{ - m_clip.CreateRoundClip(m_hDC, rc, width, height); -} - -void RenderContext_GdiPlus::ClearClip() -{ - m_clip.ClearClip(m_hDC); -} - -HRESULT RenderContext_GdiPlus::BitBlt(int x, int y, int cx, int cy, HDC hdcSrc, int xSrc /*= 0*/, int yScr /*= 0*/, DWORD rop /*= SRCCOPY*/) -{ - return ::BitBlt(m_hDC, x, y, cx, cy, hdcSrc, xSrc, yScr, rop); -} - -bool RenderContext_GdiPlus::AlphaBlend(int xDest, int yDest, int widthDest, int heightDest, HDC hdcSrc, int xSrc, int yScr, int widthSrc, int heightSrc, BYTE uFade /*= 255*/) -{ - BLENDFUNCTION bf = { AC_SRC_OVER, 0, uFade, AC_SRC_ALPHA }; - return (TRUE == ::AlphaBlend(m_hDC, xDest, yDest, widthDest, heightDest, hdcSrc, xSrc, yScr, widthSrc, heightSrc, bf)); -} - -void RenderContext_GdiPlus::DrawImage(const UiRect& rcPaint, HBITMAP hBitmap, bool bAlphaChannel, - const UiRect& rcImageDest, const UiRect& rcImageSource, const UiRect& rcCorners, BYTE uFade /*= 255*/, bool xtiled /*= false*/, bool ytiled /*= false*/) -{ - UiRect rcTestTemp; - if (!::IntersectRect(&rcTestTemp, &rcImageDest, &rcPaint)) return; - - ASSERT(::GetObjectType(m_hDC) == OBJ_DC || ::GetObjectType(m_hDC) == OBJ_MEMDC); - - if (hBitmap == NULL) return; - - HDC hCloneDC = ::CreateCompatibleDC(m_hDC); - HBITMAP hOldBitmap = (HBITMAP) ::SelectObject(hCloneDC, hBitmap); - int stretchBltMode = ::SetStretchBltMode(m_hDC, HALFTONE); - - UiRect rcTemp; - UiRect rcSource; - UiRect rcDest; - UiRect rcDpiCorner = rcCorners; - DpiManager::GetInstance()->ScaleRect(rcDpiCorner); - - // middle - rcDest.left = rcImageDest.left + rcDpiCorner.left; - rcDest.top = rcImageDest.top + rcDpiCorner.top; - rcDest.right = rcImageDest.right - rcDpiCorner.right; - rcDest.bottom = rcImageDest.bottom - rcDpiCorner.bottom; - rcSource.left = rcImageSource.left + rcCorners.left; - rcSource.top = rcImageSource.top + rcCorners.top; - rcSource.right = rcImageSource.right - rcCorners.right; - rcSource.bottom = rcImageSource.bottom - rcCorners.bottom; - if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { - if (!xtiled && !ytiled) { - DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); - } - else if (xtiled && ytiled) { - LONG lWidth = rcImageSource.right - rcImageSource.left - rcCorners.left - rcCorners.right; - LONG lHeight = rcImageSource.bottom - rcImageSource.top - rcCorners.top - rcCorners.bottom; - int iTimesX = (rcDest.right - rcDest.left + lWidth - 1) / lWidth; - int iTimesY = (rcDest.bottom - rcDest.top + lHeight - 1) / lHeight; - for (int j = 0; j < iTimesY; ++j) { - LONG lDestTop = rcDest.top + lHeight * j; - LONG lDestBottom = rcDest.top + lHeight * (j + 1); - LONG lDrawHeight = lHeight; - if (lDestBottom > rcDest.bottom) { - lDrawHeight -= lDestBottom - rcDest.bottom; - lDestBottom = rcDest.bottom; - } - for (int i = 0; i < iTimesX; ++i) { - LONG lDestLeft = rcDest.left + lWidth * i; - LONG lDestRight = rcDest.left + lWidth * (i + 1); - LONG lDrawWidth = lWidth; - if (lDestRight > rcDest.right) { - lDrawWidth -= lDestRight - rcDest.right; - lDestRight = rcDest.right; - } - rcDest.left = rcDest.left + lWidth * i; - rcDest.top = rcDest.top + lHeight * j; - rcDest.right = rcDest.left + lDestRight - lDestLeft; - rcDest.bottom = rcDest.top + lDestBottom - lDestTop; - rcSource.left = rcImageSource.left + rcCorners.left; - rcSource.top = rcImageSource.top + rcCorners.top; - rcSource.right = rcSource.left + lDrawWidth; - rcSource.bottom = rcSource.top + lDrawHeight; - DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); - } - } - } - else if (xtiled) { - LONG lWidth = rcImageSource.right - rcImageSource.left - rcCorners.left - rcCorners.right; - int iTimes = (rcDest.right - rcDest.left + lWidth - 1) / lWidth; - for (int i = 0; i < iTimes; ++i) { - LONG lDestLeft = rcDest.left + lWidth * i; - LONG lDestRight = rcDest.left + lWidth * (i + 1); - LONG lDrawWidth = lWidth; - if (lDestRight > rcDest.right) { - lDrawWidth -= lDestRight - rcDest.right; - lDestRight = rcDest.right; - } - rcDest.left = lDestLeft; - rcDest.top = rcDest.top; - rcDest.right = lDestRight; - rcDest.bottom = rcDest.top + rcDest.bottom; - rcSource.left = rcImageSource.left + rcCorners.left; - rcSource.top = rcImageSource.top + rcCorners.top; - rcSource.right = rcSource.left + lDrawWidth; - rcSource.bottom = rcImageSource.bottom - rcCorners.bottom; - DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); - } - } - else { // ytiled - LONG lHeight = rcImageSource.bottom - rcImageSource.top - rcCorners.top - rcCorners.bottom; - int iTimes = (rcDest.bottom - rcDest.top + lHeight - 1) / lHeight; - for (int i = 0; i < iTimes; ++i) { - LONG lDestTop = rcDest.top + lHeight * i; - LONG lDestBottom = rcDest.top + lHeight * (i + 1); - LONG lDrawHeight = lHeight; - if (lDestBottom > rcDest.bottom) { - lDrawHeight -= lDestBottom - rcDest.bottom; - lDestBottom = rcDest.bottom; - } - rcDest.left = rcDest.left; - rcDest.top = rcDest.top + lHeight * i; - rcDest.right = rcDest.left + rcDest.right; - rcDest.bottom = rcDest.top + lDestBottom - lDestTop; - rcSource.left = rcImageSource.left + rcCorners.left; - rcSource.top = rcImageSource.top + rcCorners.top; - rcSource.right = rcImageSource.right - rcCorners.right; - rcSource.bottom = rcSource.top + lDrawHeight; - DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); - } - } - } - - // left-top - if (rcCorners.left > 0 && rcCorners.top > 0) { - rcDest.left = rcImageDest.left; - rcDest.top = rcImageDest.top; - rcDest.right = rcImageDest.left + rcDpiCorner.left; - rcDest.bottom = rcImageDest.top + rcDpiCorner.top; - rcSource.left = rcImageSource.left; - rcSource.top = rcImageSource.top; - rcSource.right = rcImageSource.left + rcCorners.left; - rcSource.bottom = rcImageSource.top + rcCorners.top; - if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { - DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); - } - } - // top - if (rcCorners.top > 0) { - rcDest.left = rcImageDest.left + rcDpiCorner.left; - rcDest.top = rcImageDest.top; - rcDest.right = rcImageDest.right - rcDpiCorner.right; - rcDest.bottom = rcImageDest.top + rcDpiCorner.top; - rcSource.left = rcImageSource.left + rcCorners.left; - rcSource.top = rcImageSource.top; - rcSource.right = rcImageSource.right - rcCorners.right; - rcSource.bottom = rcImageSource.top + rcCorners.top; - if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { - DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); - } - } - // right-top - if (rcCorners.right > 0 && rcCorners.top > 0) { - rcDest.left = rcImageDest.right - rcDpiCorner.right; - rcDest.top = rcImageDest.top; - rcDest.right = rcImageDest.right; - rcDest.bottom = rcImageDest.top + rcDpiCorner.top; - rcSource.left = rcImageSource.right - rcCorners.right; - rcSource.top = rcImageSource.top; - rcSource.right = rcImageSource.right; - rcSource.bottom = rcImageSource.top + rcCorners.top; - if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { - DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); - } - } - // left - if (rcCorners.left > 0) { - rcDest.left = rcImageDest.left; - rcDest.top = rcImageDest.top + rcDpiCorner.top; - rcDest.right = rcImageDest.left + rcDpiCorner.left; - rcDest.bottom = rcImageDest.bottom - rcDpiCorner.bottom; - rcSource.left = rcImageSource.left; - rcSource.top = rcImageSource.top + rcCorners.top; - rcSource.right = rcImageSource.left + rcCorners.left; - rcSource.bottom = rcImageSource.bottom - rcCorners.bottom; - if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { - DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); - } - } - // right - if (rcCorners.right > 0) { - rcDest.left = rcImageDest.right - rcDpiCorner.right; - rcDest.top = rcImageDest.top + rcDpiCorner.top; - rcDest.right = rcImageDest.right; - rcDest.bottom = rcImageDest.bottom - rcDpiCorner.bottom; - rcSource.left = rcImageSource.right - rcCorners.right; - rcSource.top = rcImageSource.top + rcCorners.top; - rcSource.right = rcImageSource.right; - rcSource.bottom = rcImageSource.bottom - rcCorners.bottom; - if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { - DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); - } - } - // left-bottom - if (rcCorners.left > 0 && rcCorners.bottom > 0) { - rcDest.left = rcImageDest.left; - rcDest.top = rcImageDest.bottom - rcDpiCorner.bottom; - rcDest.right = rcImageDest.left + rcDpiCorner.left; - rcDest.bottom = rcImageDest.bottom; - rcSource.left = rcImageSource.left; - rcSource.top = rcImageSource.bottom - rcCorners.bottom; - rcSource.right = rcImageSource.left + rcCorners.left; - rcSource.bottom = rcImageSource.bottom; - if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { - DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); - } - } - // bottom - if (rcCorners.bottom > 0) { - rcDest.left = rcImageDest.left + rcDpiCorner.left; - rcDest.top = rcImageDest.bottom - rcDpiCorner.bottom; - rcDest.right = rcImageDest.right - rcDpiCorner.right; - rcDest.bottom = rcImageDest.bottom; - rcSource.left = rcImageSource.left + rcCorners.left; - rcSource.top = rcImageSource.bottom - rcCorners.bottom; - rcSource.right = rcImageSource.right - rcCorners.right; - rcSource.bottom = rcImageSource.bottom; - if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { - DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); - } - } - // right-bottom - if (rcCorners.right > 0 && rcCorners.bottom > 0) { - rcDest.left = rcImageDest.right - rcDpiCorner.right; - rcDest.top = rcImageDest.bottom - rcDpiCorner.bottom; - rcDest.right = rcImageDest.right; - rcDest.bottom = rcImageDest.bottom; - rcSource.left = rcImageSource.right - rcCorners.right; - rcSource.top = rcImageSource.bottom - rcCorners.bottom; - rcSource.right = rcImageSource.right; - rcSource.bottom = rcImageSource.bottom; - if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { - DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); - } - } - - ::SetStretchBltMode(m_hDC, stretchBltMode); - ::SelectObject(hCloneDC, hOldBitmap); - ::DeleteDC(hCloneDC); -} - -void RenderContext_GdiPlus::DrawColor(const UiRect& rc, DWORD dwColor, BYTE uFade) -{ - DWORD dwNewColor = dwColor; - if (uFade < 255) { - int alpha = dwColor >> 24; - dwNewColor = dwColor % 0xffffff; - alpha *= double(uFade) / 255; - dwNewColor += alpha << 24; - } - - Gdiplus::Graphics graphics(m_hDC); - Gdiplus::Color color(dwNewColor); - Gdiplus::SolidBrush brush(color); - Gdiplus::RectF rcFill(rc.left, rc.top, rc.GetWidth(), rc.GetHeight()); - graphics.FillRectangle(&brush, rcFill); -} - -void RenderContext_GdiPlus::DrawColor(const UiRect& rc, const std::wstring& colorStr, BYTE uFade) -{ - if (colorStr.empty()) { - return; - } - - DWORD dwColor = GlobalManager::GetTextColor(colorStr); - DrawColor(rc, dwColor, uFade); -} - -void RenderContext_GdiPlus::DrawLine(const UiRect& rc, int nSize, DWORD dwPenColor) -{ - Gdiplus::Graphics graphics(m_hDC); - Gdiplus::Pen pen(Gdiplus::Color(dwPenColor), (Gdiplus::REAL)nSize); - graphics.DrawLine(&pen, Gdiplus::Point(rc.left, rc.top), Gdiplus::Point(rc.right, rc.bottom)); -} - -void RenderContext_GdiPlus::DrawLine(const IPen* pen, int x1, int y1, int x2, int y2) -{ - Gdiplus::Graphics graphics(m_hDC); - graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); - graphics.DrawLine(((Pen_GdiPlus*)pen)->GetPen(), x1, y1, x2, y2); -} - -void RenderContext_GdiPlus::DrawBezier(const IPen* pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) -{ - Gdiplus::Graphics graphics(m_hDC); - graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); - graphics.DrawBezier(((Pen_GdiPlus*)pen)->GetPen(), x1, y1, x2, y2, x3, y3, x4, y4); -} - -void RenderContext_GdiPlus::DrawRect(const UiRect& rc, int nSize, DWORD dwPenColor) -{ - Gdiplus::Graphics graphics(m_hDC); - Gdiplus::Pen pen(Gdiplus::Color(dwPenColor), (Gdiplus::REAL)nSize); - graphics.DrawRectangle(&pen, rc.left, rc.top, rc.GetWidth(), rc.GetHeight()); -} - - -void RenderContext_GdiPlus::DrawRoundRect(const UiRect& rc, const CSize& roundSize, int nSize, DWORD dwPenColor) -{ - Gdiplus::Graphics graphics(m_hDC); - graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); - Gdiplus::Pen pen(Gdiplus::Color(dwPenColor), (Gdiplus::REAL)nSize); - - // ü±߿ʱȫһ - // UiRect rcInflate = rc; - // rcInflate.Inflate({ -1, -1, -1, -1 }); - - Gdiplus::GraphicsPath pPath; - pPath.AddArc(rc.left, rc.top, roundSize.cx, roundSize.cy, 180, 90); - pPath.AddLine(rc.left + roundSize.cx, rc.top, rc.right - roundSize.cx, rc.top); - pPath.AddArc(rc.right - roundSize.cx, rc.top, roundSize.cx, roundSize.cy, 270, 90); - pPath.AddLine(rc.right, rc.top + roundSize.cy, rc.right, rc.bottom - roundSize.cy); - pPath.AddArc(rc.right - roundSize.cx, rc.bottom - roundSize.cy, roundSize.cx, roundSize.cy, 0, 90); - pPath.AddLine(rc.right - roundSize.cx, rc.bottom, rc.left + roundSize.cx, rc.bottom); - pPath.AddArc(rc.left, rc.bottom - roundSize.cy, roundSize.cx, roundSize.cy, 90, 90); - pPath.AddLine(rc.left, rc.bottom - roundSize.cy, rc.left, rc.top + roundSize.cy); - pPath.CloseFigure(); - - graphics.DrawPath(&pen, &pPath); -} - -void RenderContext_GdiPlus::DrawText(const UiRect& rc, const std::wstring& strText, DWORD dwTextColor, const std::wstring& strFontId, UINT uStyle, BYTE uFade /*= 255*/, bool bLineLimit /*= false*/) -{ - ASSERT(::GetObjectType(m_hDC) == OBJ_DC || ::GetObjectType(m_hDC) == OBJ_MEMDC); - if (strText.empty()) return; - - Gdiplus::Graphics graphics(m_hDC); - Gdiplus::Font font(m_hDC, GlobalManager::GetFont(strFontId)); - Gdiplus::RectF rcPaint((Gdiplus::REAL)rc.left, (Gdiplus::REAL)rc.top, (Gdiplus::REAL)(rc.right - rc.left), (Gdiplus::REAL)(rc.bottom - rc.top)); - int alpha = dwTextColor >> 24; - uFade *= double(alpha) / 255; - if (uFade == 255) { - uFade = 254; - } - Gdiplus::SolidBrush tBrush(Gdiplus::Color(uFade, GetBValue(dwTextColor), GetGValue(dwTextColor), GetRValue(dwTextColor))); - - Gdiplus::StringFormat stringFormat = Gdiplus::StringFormat::GenericTypographic(); - if ((uStyle & DT_END_ELLIPSIS) != 0) { - stringFormat.SetTrimming(Gdiplus::StringTrimmingEllipsisCharacter); - } - - int formatFlags = 0; - if ((uStyle & DT_NOCLIP) != 0) { - formatFlags |= Gdiplus::StringFormatFlagsNoClip; - } - if ((uStyle & DT_SINGLELINE) != 0) { - formatFlags |= Gdiplus::StringFormatFlagsNoWrap; - } - if (bLineLimit) { - formatFlags |= Gdiplus::StringFormatFlagsLineLimit; - } - stringFormat.SetFormatFlags(formatFlags); - - if ((uStyle & DT_LEFT) != 0) { - stringFormat.SetAlignment(Gdiplus::StringAlignmentNear); - } - else if ((uStyle & DT_CENTER) != 0) { - stringFormat.SetAlignment(Gdiplus::StringAlignmentCenter); - } - else if ((uStyle & DT_RIGHT) != 0) { - stringFormat.SetAlignment(Gdiplus::StringAlignmentFar); - } - else { - stringFormat.SetAlignment(Gdiplus::StringAlignmentNear); - } - - if ((uStyle & DT_TOP) != 0) { - stringFormat.SetLineAlignment(Gdiplus::StringAlignmentNear); - } - else if ((uStyle & DT_VCENTER) != 0) { - TFontInfo* fontInfo = GlobalManager::GetTFontInfo(strFontId); - if (fontInfo->sFontName == L"") { - if (rcPaint.Height >= fontInfo->iSize + 2) { - rcPaint.Offset(0, 1); - } - } - stringFormat.SetLineAlignment(Gdiplus::StringAlignmentCenter); - } - else if ((uStyle & DT_BOTTOM) != 0) { - stringFormat.SetLineAlignment(Gdiplus::StringAlignmentFar); - } - else { - stringFormat.SetLineAlignment(Gdiplus::StringAlignmentNear); - } - - graphics.DrawString(strText.c_str(), (int)strText.length(), &font, rcPaint, &stringFormat, &tBrush); -} - -void RenderContext_GdiPlus::DrawEllipse(const UiRect& rc, int nSize, DWORD dwColor) -{ - Gdiplus::Graphics graphics(m_hDC); - graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); - Gdiplus::Pen pen(dwColor, nSize); - graphics.DrawEllipse(&pen, rc.left, rc.top, rc.GetWidth(), rc.GetHeight()); -} - -void RenderContext_GdiPlus::FillEllipse(const UiRect& rc, DWORD dwColor) -{ - Gdiplus::Graphics graphics(m_hDC); - graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); - Gdiplus::SolidBrush brush(dwColor); - graphics.FillEllipse(&brush, rc.left, rc.top, rc.GetWidth(), rc.GetHeight()); -} - -void RenderContext_GdiPlus::DrawPath(const IPath* path, const IPen* pen) -{ - Gdiplus::Graphics graphics(m_hDC); - graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); - graphics.DrawPath(((Pen_GdiPlus*)pen)->GetPen(), ((Path_Gdiplus*)path)->GetPath()); -} - -void RenderContext_GdiPlus::FillPath(const IPath* path, const IBrush* brush) -{ - Gdiplus::Graphics graphics(m_hDC); - graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); - graphics.FillPath(((Brush_Gdiplus*)brush)->GetBrush(), ((Path_Gdiplus*)path)->GetPath()); -} - -ui::UiRect RenderContext_GdiPlus::MeasureText(const std::wstring& strText, const std::wstring& strFontId, UINT uStyle, int width /*= DUI_NOSET_VALUE*/) -{ - Gdiplus::Graphics graphics(m_hDC); - Gdiplus::Font font(m_hDC, GlobalManager::GetFont(strFontId)); - Gdiplus::RectF bounds; - - Gdiplus::StringFormat stringFormat = Gdiplus::StringFormat::GenericTypographic(); - int formatFlags = 0; - if ((uStyle & DT_SINGLELINE) != 0) { - formatFlags |= Gdiplus::StringFormatFlagsNoWrap; - } - stringFormat.SetFormatFlags(formatFlags); - - if (width == DUI_NOSET_VALUE) { - graphics.MeasureString(strText.c_str(), (int)strText.length(), &font, Gdiplus::PointF(), &stringFormat, &bounds); - } - else { - Gdiplus::REAL height = 0; - if ((uStyle & DT_SINGLELINE) != 0) { - Gdiplus::RectF rcEmpty((Gdiplus::REAL)0, (Gdiplus::REAL)0, (Gdiplus::REAL)0, (Gdiplus::REAL)0); - graphics.MeasureString(L"", 2, &font, rcEmpty, &stringFormat, &bounds); - height = bounds.Height; - } - Gdiplus::RectF rcText((Gdiplus::REAL)0, (Gdiplus::REAL)0, (Gdiplus::REAL)width, height); - graphics.MeasureString(strText.c_str(), (int)strText.length(), &font, rcText, &stringFormat, &bounds); - } - - UiRect rc(int(bounds.GetLeft()), int(bounds.GetTop()), int(bounds.GetRight() + 1), int(bounds.GetBottom() + 1)); - return rc; -} - -} // namespace ui +#include "StdAfx.h" + +namespace ui { + +static inline void DrawFunction(HDC hDC, bool bTransparent, UiRect rcDest, HDC hdcSrc, UiRect rcSrc, bool bAlphaChannel, int uFade) +{ + if (bTransparent || bAlphaChannel || uFade < 255 + || (rcSrc.GetWidth() == rcDest.GetWidth() && rcSrc.GetHeight() == rcDest.GetHeight())) { + BLENDFUNCTION ftn = { AC_SRC_OVER, 0, uFade, AC_SRC_ALPHA }; + ::AlphaBlend(hDC, rcDest.left, rcDest.top, rcDest.GetWidth(), rcDest.GetHeight(), + hdcSrc, rcSrc.left, rcSrc.top, rcSrc.GetWidth(), rcSrc.GetHeight(), ftn); + } + else { + ::StretchBlt(hDC, rcDest.left, rcDest.top, rcDest.GetWidth(), rcDest.GetHeight(), + hdcSrc, rcSrc.left, rcSrc.top, rcSrc.GetWidth(), rcSrc.GetHeight(), SRCCOPY); + } +} + +RenderContext_GdiPlus::RenderContext_GdiPlus() + : m_hDC(NULL) + , m_hOldBitmap(NULL) + , m_bTransparent(false) +{ + HDC hDC = ::GetDC(NULL); + m_hDC = ::CreateCompatibleDC(hDC); + ::ReleaseDC(NULL, hDC); + ASSERT(m_hDC); +} + +RenderContext_GdiPlus::~RenderContext_GdiPlus() +{ + if (m_hOldBitmap != NULL) + { + ::SelectObject(m_hDC, m_hOldBitmap); + m_hOldBitmap = NULL; + } + + if (m_hDC != NULL) + { + ::DeleteDC(m_hDC); + m_hDC = NULL; + } +} + +HDC RenderContext_GdiPlus::GetDC() +{ + return m_hDC; +} + +bool RenderContext_GdiPlus::Resize(int width, int height, bool flipBItmap) +{ + ASSERT(m_hDC); + if (m_bitmap.GetWidth() == width && m_bitmap.GetHeight() == height) + return false; + + if (m_hOldBitmap != NULL) + { + ::SelectObject(m_hDC, m_hOldBitmap); + } + + bool ret = m_bitmap.Init(m_hDC, width, height, flipBItmap); + m_hOldBitmap = (HBITMAP)::SelectObject(m_hDC, m_bitmap.GetBitmap()); + return ret; +} + +void RenderContext_GdiPlus::Clear() +{ + ASSERT(m_hDC); + m_bitmap.Clear(); +} + +std::unique_ptr RenderContext_GdiPlus::Clone() +{ + std::unique_ptr pClone = std::make_unique(); + pClone->Resize(GetWidth(), GetHeight()); + pClone->BitBlt(0, 0, GetWidth(), GetHeight(), m_hDC); + return pClone; +} + +HBITMAP RenderContext_GdiPlus::DetachBitmap() +{ + ASSERT(m_hDC && m_hOldBitmap); + ASSERT(m_bitmap.GetHeight() != 0 && m_bitmap.GetWidth() != 0); + if (m_hOldBitmap == NULL) + return NULL; + + ::SelectObject(m_hDC, m_hOldBitmap); + return m_bitmap.DetachBitmap(); +} + +BYTE* RenderContext_GdiPlus::GetBits() +{ + return m_bitmap.GetBits(); +} + +int RenderContext_GdiPlus::GetWidth() +{ + return m_bitmap.GetWidth(); +} + +int RenderContext_GdiPlus::GetHeight() +{ + return m_bitmap.GetHeight(); +} + +void RenderContext_GdiPlus::ClearAlpha(const UiRect& rcDirty, int alpha) +{ + m_bitmap.ClearAlpha(rcDirty, alpha); +} + +void RenderContext_GdiPlus::RestoreAlpha(const UiRect& rcDirty, const UiRect& rcShadowPadding, int alpha) +{ + m_bitmap.RestoreAlpha(rcDirty, rcShadowPadding, alpha); +} + +bool RenderContext_GdiPlus::IsRenderTransparent() const +{ + return m_bTransparent; +} + +bool RenderContext_GdiPlus::SetRenderTransparent(bool bTransparent) +{ + bool oldValue = m_bTransparent; + m_bTransparent = bTransparent; + return oldValue; +} + +void RenderContext_GdiPlus::Save() +{ + m_saveDC = SaveDC(m_hDC); +} + +void RenderContext_GdiPlus::Restore() +{ + RestoreDC(m_hDC, m_saveDC); +} + +CPoint RenderContext_GdiPlus::OffsetWindowOrg(CPoint ptOffset) +{ + CPoint ptOldWindowOrg; + GetWindowOrgEx(m_hDC, &ptOldWindowOrg); + ptOffset.Offset(ptOldWindowOrg.x, ptOldWindowOrg.y); + ::SetWindowOrgEx(m_hDC, ptOffset.x, ptOffset.y, NULL); + return ptOldWindowOrg; +} + +CPoint RenderContext_GdiPlus::SetWindowOrg(CPoint ptOffset) +{ + CPoint ptOldWindowOrg; + GetWindowOrgEx(m_hDC, &ptOldWindowOrg); + ::SetWindowOrgEx(m_hDC, ptOffset.x, ptOffset.y, NULL); + return ptOldWindowOrg; +} + +CPoint RenderContext_GdiPlus::GetWindowOrg() const +{ + CPoint ptWindowOrg; + GetWindowOrgEx(m_hDC, &ptWindowOrg); + return ptWindowOrg; +} + +void RenderContext_GdiPlus::SetClip(const UiRect& rc) +{ + m_clip.CreateClip(m_hDC, rc); +} + +void RenderContext_GdiPlus::SetRoundClip(const UiRect& rc, int width, int height) +{ + m_clip.CreateRoundClip(m_hDC, rc, width, height); +} + +void RenderContext_GdiPlus::ClearClip() +{ + m_clip.ClearClip(m_hDC); +} + +HRESULT RenderContext_GdiPlus::BitBlt(int x, int y, int cx, int cy, HDC hdcSrc, int xSrc /*= 0*/, int yScr /*= 0*/, DWORD rop /*= SRCCOPY*/) +{ + return ::BitBlt(m_hDC, x, y, cx, cy, hdcSrc, xSrc, yScr, rop); +} + +bool RenderContext_GdiPlus::AlphaBlend(int xDest, int yDest, int widthDest, int heightDest, HDC hdcSrc, int xSrc, int yScr, int widthSrc, int heightSrc, BYTE uFade /*= 255*/) +{ + BLENDFUNCTION bf = { AC_SRC_OVER, 0, uFade, AC_SRC_ALPHA }; + return (TRUE == ::AlphaBlend(m_hDC, xDest, yDest, widthDest, heightDest, hdcSrc, xSrc, yScr, widthSrc, heightSrc, bf)); +} + +void RenderContext_GdiPlus::DrawImage(const UiRect& rcPaint, HBITMAP hBitmap, bool bAlphaChannel, + const UiRect& rcImageDest, const UiRect& rcImageSource, const UiRect& rcCorners, BYTE uFade /*= 255*/, bool xtiled /*= false*/, bool ytiled /*= false*/) +{ + UiRect rcTestTemp; + if (!::IntersectRect(&rcTestTemp, &rcImageDest, &rcPaint)) return; + + ASSERT(::GetObjectType(m_hDC) == OBJ_DC || ::GetObjectType(m_hDC) == OBJ_MEMDC); + + if (hBitmap == NULL) return; + + HDC hCloneDC = ::CreateCompatibleDC(m_hDC); + HBITMAP hOldBitmap = (HBITMAP) ::SelectObject(hCloneDC, hBitmap); + int stretchBltMode = ::SetStretchBltMode(m_hDC, HALFTONE); + + UiRect rcTemp; + UiRect rcSource; + UiRect rcDest; + UiRect rcDpiCorner = rcCorners; + DpiManager::GetInstance()->ScaleRect(rcDpiCorner); + + // middle + rcDest.left = rcImageDest.left + rcDpiCorner.left; + rcDest.top = rcImageDest.top + rcDpiCorner.top; + rcDest.right = rcImageDest.right - rcDpiCorner.right; + rcDest.bottom = rcImageDest.bottom - rcDpiCorner.bottom; + rcSource.left = rcImageSource.left + rcCorners.left; + rcSource.top = rcImageSource.top + rcCorners.top; + rcSource.right = rcImageSource.right - rcCorners.right; + rcSource.bottom = rcImageSource.bottom - rcCorners.bottom; + if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { + if (!xtiled && !ytiled) { + DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); + } + else if (xtiled && ytiled) { + LONG lWidth = rcImageSource.right - rcImageSource.left - rcCorners.left - rcCorners.right; + LONG lHeight = rcImageSource.bottom - rcImageSource.top - rcCorners.top - rcCorners.bottom; + int iTimesX = (rcDest.right - rcDest.left + lWidth - 1) / lWidth; + int iTimesY = (rcDest.bottom - rcDest.top + lHeight - 1) / lHeight; + for (int j = 0; j < iTimesY; ++j) { + LONG lDestTop = rcDest.top + lHeight * j; + LONG lDestBottom = rcDest.top + lHeight * (j + 1); + LONG lDrawHeight = lHeight; + if (lDestBottom > rcDest.bottom) { + lDrawHeight -= lDestBottom - rcDest.bottom; + lDestBottom = rcDest.bottom; + } + for (int i = 0; i < iTimesX; ++i) { + LONG lDestLeft = rcDest.left + lWidth * i; + LONG lDestRight = rcDest.left + lWidth * (i + 1); + LONG lDrawWidth = lWidth; + if (lDestRight > rcDest.right) { + lDrawWidth -= lDestRight - rcDest.right; + lDestRight = rcDest.right; + } + rcDest.left = rcDest.left + lWidth * i; + rcDest.top = rcDest.top + lHeight * j; + rcDest.right = rcDest.left + lDestRight - lDestLeft; + rcDest.bottom = rcDest.top + lDestBottom - lDestTop; + rcSource.left = rcImageSource.left + rcCorners.left; + rcSource.top = rcImageSource.top + rcCorners.top; + rcSource.right = rcSource.left + lDrawWidth; + rcSource.bottom = rcSource.top + lDrawHeight; + DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); + } + } + } + else if (xtiled) { + LONG lWidth = rcImageSource.right - rcImageSource.left - rcCorners.left - rcCorners.right; + int iTimes = (rcDest.right - rcDest.left + lWidth - 1) / lWidth; + for (int i = 0; i < iTimes; ++i) { + LONG lDestLeft = rcDest.left + lWidth * i; + LONG lDestRight = rcDest.left + lWidth * (i + 1); + LONG lDrawWidth = lWidth; + if (lDestRight > rcDest.right) { + lDrawWidth -= lDestRight - rcDest.right; + lDestRight = rcDest.right; + } + rcDest.left = lDestLeft; + rcDest.top = rcDest.top; + rcDest.right = lDestRight; + rcDest.bottom = rcDest.top + rcDest.bottom; + rcSource.left = rcImageSource.left + rcCorners.left; + rcSource.top = rcImageSource.top + rcCorners.top; + rcSource.right = rcSource.left + lDrawWidth; + rcSource.bottom = rcImageSource.bottom - rcCorners.bottom; + DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); + } + } + else { // ytiled + LONG lHeight = rcImageSource.bottom - rcImageSource.top - rcCorners.top - rcCorners.bottom; + int iTimes = (rcDest.bottom - rcDest.top + lHeight - 1) / lHeight; + for (int i = 0; i < iTimes; ++i) { + LONG lDestTop = rcDest.top + lHeight * i; + LONG lDestBottom = rcDest.top + lHeight * (i + 1); + LONG lDrawHeight = lHeight; + if (lDestBottom > rcDest.bottom) { + lDrawHeight -= lDestBottom - rcDest.bottom; + lDestBottom = rcDest.bottom; + } + rcDest.left = rcDest.left; + rcDest.top = rcDest.top + lHeight * i; + rcDest.right = rcDest.left + rcDest.right; + rcDest.bottom = rcDest.top + lDestBottom - lDestTop; + rcSource.left = rcImageSource.left + rcCorners.left; + rcSource.top = rcImageSource.top + rcCorners.top; + rcSource.right = rcImageSource.right - rcCorners.right; + rcSource.bottom = rcSource.top + lDrawHeight; + DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); + } + } + } + + // left-top + if (rcCorners.left > 0 && rcCorners.top > 0) { + rcDest.left = rcImageDest.left; + rcDest.top = rcImageDest.top; + rcDest.right = rcImageDest.left + rcDpiCorner.left; + rcDest.bottom = rcImageDest.top + rcDpiCorner.top; + rcSource.left = rcImageSource.left; + rcSource.top = rcImageSource.top; + rcSource.right = rcImageSource.left + rcCorners.left; + rcSource.bottom = rcImageSource.top + rcCorners.top; + if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { + DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); + } + } + // top + if (rcCorners.top > 0) { + rcDest.left = rcImageDest.left + rcDpiCorner.left; + rcDest.top = rcImageDest.top; + rcDest.right = rcImageDest.right - rcDpiCorner.right; + rcDest.bottom = rcImageDest.top + rcDpiCorner.top; + rcSource.left = rcImageSource.left + rcCorners.left; + rcSource.top = rcImageSource.top; + rcSource.right = rcImageSource.right - rcCorners.right; + rcSource.bottom = rcImageSource.top + rcCorners.top; + if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { + DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); + } + } + // right-top + if (rcCorners.right > 0 && rcCorners.top > 0) { + rcDest.left = rcImageDest.right - rcDpiCorner.right; + rcDest.top = rcImageDest.top; + rcDest.right = rcImageDest.right; + rcDest.bottom = rcImageDest.top + rcDpiCorner.top; + rcSource.left = rcImageSource.right - rcCorners.right; + rcSource.top = rcImageSource.top; + rcSource.right = rcImageSource.right; + rcSource.bottom = rcImageSource.top + rcCorners.top; + if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { + DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); + } + } + // left + if (rcCorners.left > 0) { + rcDest.left = rcImageDest.left; + rcDest.top = rcImageDest.top + rcDpiCorner.top; + rcDest.right = rcImageDest.left + rcDpiCorner.left; + rcDest.bottom = rcImageDest.bottom - rcDpiCorner.bottom; + rcSource.left = rcImageSource.left; + rcSource.top = rcImageSource.top + rcCorners.top; + rcSource.right = rcImageSource.left + rcCorners.left; + rcSource.bottom = rcImageSource.bottom - rcCorners.bottom; + if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { + DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); + } + } + // right + if (rcCorners.right > 0) { + rcDest.left = rcImageDest.right - rcDpiCorner.right; + rcDest.top = rcImageDest.top + rcDpiCorner.top; + rcDest.right = rcImageDest.right; + rcDest.bottom = rcImageDest.bottom - rcDpiCorner.bottom; + rcSource.left = rcImageSource.right - rcCorners.right; + rcSource.top = rcImageSource.top + rcCorners.top; + rcSource.right = rcImageSource.right; + rcSource.bottom = rcImageSource.bottom - rcCorners.bottom; + if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { + DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); + } + } + // left-bottom + if (rcCorners.left > 0 && rcCorners.bottom > 0) { + rcDest.left = rcImageDest.left; + rcDest.top = rcImageDest.bottom - rcDpiCorner.bottom; + rcDest.right = rcImageDest.left + rcDpiCorner.left; + rcDest.bottom = rcImageDest.bottom; + rcSource.left = rcImageSource.left; + rcSource.top = rcImageSource.bottom - rcCorners.bottom; + rcSource.right = rcImageSource.left + rcCorners.left; + rcSource.bottom = rcImageSource.bottom; + if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { + DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); + } + } + // bottom + if (rcCorners.bottom > 0) { + rcDest.left = rcImageDest.left + rcDpiCorner.left; + rcDest.top = rcImageDest.bottom - rcDpiCorner.bottom; + rcDest.right = rcImageDest.right - rcDpiCorner.right; + rcDest.bottom = rcImageDest.bottom; + rcSource.left = rcImageSource.left + rcCorners.left; + rcSource.top = rcImageSource.bottom - rcCorners.bottom; + rcSource.right = rcImageSource.right - rcCorners.right; + rcSource.bottom = rcImageSource.bottom; + if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { + DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); + } + } + // right-bottom + if (rcCorners.right > 0 && rcCorners.bottom > 0) { + rcDest.left = rcImageDest.right - rcDpiCorner.right; + rcDest.top = rcImageDest.bottom - rcDpiCorner.bottom; + rcDest.right = rcImageDest.right; + rcDest.bottom = rcImageDest.bottom; + rcSource.left = rcImageSource.right - rcCorners.right; + rcSource.top = rcImageSource.bottom - rcCorners.bottom; + rcSource.right = rcImageSource.right; + rcSource.bottom = rcImageSource.bottom; + if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) { + DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade); + } + } + + ::SetStretchBltMode(m_hDC, stretchBltMode); + ::SelectObject(hCloneDC, hOldBitmap); + ::DeleteDC(hCloneDC); +} + +void RenderContext_GdiPlus::DrawColor(const UiRect& rc, DWORD dwColor, BYTE uFade) +{ + DWORD dwNewColor = dwColor; + if (uFade < 255) { + int alpha = dwColor >> 24; + dwNewColor = dwColor % 0xffffff; + alpha *= double(uFade) / 255; + dwNewColor += alpha << 24; + } + + Gdiplus::Graphics graphics(m_hDC); + Gdiplus::Color color(dwNewColor); + Gdiplus::SolidBrush brush(color); + Gdiplus::RectF rcFill(rc.left, rc.top, rc.GetWidth(), rc.GetHeight()); + graphics.FillRectangle(&brush, rcFill); +} + +void RenderContext_GdiPlus::DrawColor(const UiRect& rc, const std::wstring& colorStr, BYTE uFade) +{ + if (colorStr.empty()) { + return; + } + + DWORD dwColor = GlobalManager::GetTextColor(colorStr); + DrawColor(rc, dwColor, uFade); +} + +void RenderContext_GdiPlus::DrawLine(const UiRect& rc, int nSize, DWORD dwPenColor) +{ + Gdiplus::Graphics graphics(m_hDC); + Gdiplus::Pen pen(Gdiplus::Color(dwPenColor), (Gdiplus::REAL)nSize); + graphics.DrawLine(&pen, Gdiplus::Point(rc.left, rc.top), Gdiplus::Point(rc.right, rc.bottom)); +} + +void RenderContext_GdiPlus::DrawLine(const IPen* pen, int x1, int y1, int x2, int y2) +{ + Gdiplus::Graphics graphics(m_hDC); + graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); + graphics.DrawLine(((Pen_GdiPlus*)pen)->GetPen(), x1, y1, x2, y2); +} + +void RenderContext_GdiPlus::DrawBezier(const IPen* pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) +{ + Gdiplus::Graphics graphics(m_hDC); + graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); + graphics.DrawBezier(((Pen_GdiPlus*)pen)->GetPen(), x1, y1, x2, y2, x3, y3, x4, y4); +} + +void RenderContext_GdiPlus::DrawRect(const UiRect& rc, int nSize, DWORD dwPenColor) +{ + Gdiplus::Graphics graphics(m_hDC); + Gdiplus::Pen pen(Gdiplus::Color(dwPenColor), (Gdiplus::REAL)nSize); + graphics.DrawRectangle(&pen, rc.left, rc.top, rc.GetWidth(), rc.GetHeight()); +} + + +void RenderContext_GdiPlus::DrawRoundRect(const UiRect& rc, const CSize& roundSize, int nSize, DWORD dwPenColor) +{ + Gdiplus::Graphics graphics(m_hDC); + graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); + Gdiplus::Pen pen(Gdiplus::Color(dwPenColor), (Gdiplus::REAL)nSize); + + // ü±߿ʱȫһ + // UiRect rcInflate = rc; + // rcInflate.Inflate({ -1, -1, -1, -1 }); + + Gdiplus::GraphicsPath pPath; + pPath.AddArc(rc.left, rc.top, roundSize.cx, roundSize.cy, 180, 90); + pPath.AddLine(rc.left + roundSize.cx, rc.top, rc.right - roundSize.cx, rc.top); + pPath.AddArc(rc.right - roundSize.cx, rc.top, roundSize.cx, roundSize.cy, 270, 90); + pPath.AddLine(rc.right, rc.top + roundSize.cy, rc.right, rc.bottom - roundSize.cy); + pPath.AddArc(rc.right - roundSize.cx, rc.bottom - roundSize.cy, roundSize.cx, roundSize.cy, 0, 90); + pPath.AddLine(rc.right - roundSize.cx, rc.bottom, rc.left + roundSize.cx, rc.bottom); + pPath.AddArc(rc.left, rc.bottom - roundSize.cy, roundSize.cx, roundSize.cy, 90, 90); + pPath.AddLine(rc.left, rc.bottom - roundSize.cy, rc.left, rc.top + roundSize.cy); + pPath.CloseFigure(); + + graphics.DrawPath(&pen, &pPath); +} + +void RenderContext_GdiPlus::DrawText(const UiRect& rc, const std::wstring& strText, DWORD dwTextColor, const std::wstring& strFontId, UINT uStyle, BYTE uFade /*= 255*/, bool bLineLimit /*= false*/) +{ + ASSERT(::GetObjectType(m_hDC) == OBJ_DC || ::GetObjectType(m_hDC) == OBJ_MEMDC); + if (strText.empty()) return; + + Gdiplus::Graphics graphics(m_hDC); + Gdiplus::Font font(m_hDC, GlobalManager::GetFont(strFontId)); + Gdiplus::RectF rcPaint((Gdiplus::REAL)rc.left, (Gdiplus::REAL)rc.top, (Gdiplus::REAL)(rc.right - rc.left), (Gdiplus::REAL)(rc.bottom - rc.top)); + int alpha = dwTextColor >> 24; + uFade *= double(alpha) / 255; + if (uFade == 255) { + uFade = 254; + } + Gdiplus::SolidBrush tBrush(Gdiplus::Color(uFade, GetBValue(dwTextColor), GetGValue(dwTextColor), GetRValue(dwTextColor))); + + Gdiplus::StringFormat stringFormat = Gdiplus::StringFormat::GenericTypographic(); + if ((uStyle & DT_END_ELLIPSIS) != 0) { + stringFormat.SetTrimming(Gdiplus::StringTrimmingEllipsisCharacter); + } + + int formatFlags = 0; + if ((uStyle & DT_NOCLIP) != 0) { + formatFlags |= Gdiplus::StringFormatFlagsNoClip; + } + if ((uStyle & DT_SINGLELINE) != 0) { + formatFlags |= Gdiplus::StringFormatFlagsNoWrap; + } + if (bLineLimit) { + formatFlags |= Gdiplus::StringFormatFlagsLineLimit; + } + stringFormat.SetFormatFlags(formatFlags); + + if ((uStyle & DT_LEFT) != 0) { + stringFormat.SetAlignment(Gdiplus::StringAlignmentNear); + } + else if ((uStyle & DT_CENTER) != 0) { + stringFormat.SetAlignment(Gdiplus::StringAlignmentCenter); + } + else if ((uStyle & DT_RIGHT) != 0) { + stringFormat.SetAlignment(Gdiplus::StringAlignmentFar); + } + else { + stringFormat.SetAlignment(Gdiplus::StringAlignmentNear); + } + + if ((uStyle & DT_TOP) != 0) { + stringFormat.SetLineAlignment(Gdiplus::StringAlignmentNear); + } + else if ((uStyle & DT_VCENTER) != 0) { + TFontInfo* fontInfo = GlobalManager::GetTFontInfo(strFontId); + if (fontInfo->sFontName == L"") { + if (rcPaint.Height >= fontInfo->iSize + 2) { + rcPaint.Offset(0, 1); + } + } + stringFormat.SetLineAlignment(Gdiplus::StringAlignmentCenter); + } + else if ((uStyle & DT_BOTTOM) != 0) { + stringFormat.SetLineAlignment(Gdiplus::StringAlignmentFar); + } + else { + stringFormat.SetLineAlignment(Gdiplus::StringAlignmentNear); + } + + graphics.DrawString(strText.c_str(), (int)strText.length(), &font, rcPaint, &stringFormat, &tBrush); +} + +void RenderContext_GdiPlus::DrawEllipse(const UiRect& rc, int nSize, DWORD dwColor) +{ + Gdiplus::Graphics graphics(m_hDC); + graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); + Gdiplus::Pen pen(dwColor, nSize); + graphics.DrawEllipse(&pen, rc.left, rc.top, rc.GetWidth(), rc.GetHeight()); +} + +void RenderContext_GdiPlus::FillEllipse(const UiRect& rc, DWORD dwColor) +{ + Gdiplus::Graphics graphics(m_hDC); + graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); + Gdiplus::SolidBrush brush(dwColor); + graphics.FillEllipse(&brush, rc.left, rc.top, rc.GetWidth(), rc.GetHeight()); +} + +void RenderContext_GdiPlus::DrawPath(const IPath* path, const IPen* pen) +{ + Gdiplus::Graphics graphics(m_hDC); + graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); + graphics.DrawPath(((Pen_GdiPlus*)pen)->GetPen(), ((Path_Gdiplus*)path)->GetPath()); +} + +void RenderContext_GdiPlus::FillPath(const IPath* path, const IBrush* brush) +{ + Gdiplus::Graphics graphics(m_hDC); + graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias); + graphics.FillPath(((Brush_Gdiplus*)brush)->GetBrush(), ((Path_Gdiplus*)path)->GetPath()); +} + +ui::UiRect RenderContext_GdiPlus::MeasureText(const std::wstring& strText, const std::wstring& strFontId, UINT uStyle, int width /*= DUI_NOSET_VALUE*/) +{ + Gdiplus::Graphics graphics(m_hDC); + Gdiplus::Font font(m_hDC, GlobalManager::GetFont(strFontId)); + Gdiplus::RectF bounds; + + Gdiplus::StringFormat stringFormat = Gdiplus::StringFormat::GenericTypographic(); + int formatFlags = 0; + if ((uStyle & DT_SINGLELINE) != 0) { + formatFlags |= Gdiplus::StringFormatFlagsNoWrap; + } + stringFormat.SetFormatFlags(formatFlags); + + if (width == DUI_NOSET_VALUE) { + graphics.MeasureString(strText.c_str(), (int)strText.length(), &font, Gdiplus::PointF(), &stringFormat, &bounds); + } + else { + Gdiplus::REAL height = 0; + if ((uStyle & DT_SINGLELINE) != 0) { + Gdiplus::RectF rcEmpty((Gdiplus::REAL)0, (Gdiplus::REAL)0, (Gdiplus::REAL)0, (Gdiplus::REAL)0); + graphics.MeasureString(L"", 2, &font, rcEmpty, &stringFormat, &bounds); + height = bounds.Height; + } + Gdiplus::RectF rcText((Gdiplus::REAL)0, (Gdiplus::REAL)0, (Gdiplus::REAL)width, height); + graphics.MeasureString(strText.c_str(), (int)strText.length(), &font, rcText, &stringFormat, &bounds); + } + + UiRect rc(int(bounds.GetLeft()), int(bounds.GetTop()), int(bounds.GetRight() + 1), int(bounds.GetBottom() + 1)); + return rc; +} + +} // namespace ui diff --git a/tool_kits/duilib/Render/Render.h b/duilib/Render/Render.h similarity index 100% rename from tool_kits/duilib/Render/Render.h rename to duilib/Render/Render.h diff --git a/tool_kits/duilib/StdAfx.cpp b/duilib/StdAfx.cpp similarity index 100% rename from tool_kits/duilib/StdAfx.cpp rename to duilib/StdAfx.cpp diff --git a/tool_kits/duilib/StdAfx.h b/duilib/StdAfx.h similarity index 100% rename from tool_kits/duilib/StdAfx.h rename to duilib/StdAfx.h diff --git a/tool_kits/duilib/UIlib.cpp b/duilib/UIlib.cpp similarity index 100% rename from tool_kits/duilib/UIlib.cpp rename to duilib/UIlib.cpp diff --git a/tool_kits/duilib/UIlib.h b/duilib/UIlib.h similarity index 100% rename from tool_kits/duilib/UIlib.h rename to duilib/UIlib.h diff --git a/tool_kits/duilib/Utils/ApiWrapper.cpp b/duilib/Utils/ApiWrapper.cpp similarity index 100% rename from tool_kits/duilib/Utils/ApiWrapper.cpp rename to duilib/Utils/ApiWrapper.cpp diff --git a/tool_kits/duilib/Utils/ApiWrapper.h b/duilib/Utils/ApiWrapper.h similarity index 100% rename from tool_kits/duilib/Utils/ApiWrapper.h rename to duilib/Utils/ApiWrapper.h diff --git a/tool_kits/duilib/Utils/Delegate.h b/duilib/Utils/Delegate.h similarity index 100% rename from tool_kits/duilib/Utils/Delegate.h rename to duilib/Utils/Delegate.h diff --git a/tool_kits/duilib/Utils/DpiManager.cpp b/duilib/Utils/DpiManager.cpp similarity index 100% rename from tool_kits/duilib/Utils/DpiManager.cpp rename to duilib/Utils/DpiManager.cpp diff --git a/tool_kits/duilib/Utils/DpiManager.h b/duilib/Utils/DpiManager.h similarity index 100% rename from tool_kits/duilib/Utils/DpiManager.h rename to duilib/Utils/DpiManager.h diff --git a/tool_kits/duilib/Utils/Macros.h b/duilib/Utils/Macros.h similarity index 100% rename from tool_kits/duilib/Utils/Macros.h rename to duilib/Utils/Macros.h diff --git a/tool_kits/duilib/Utils/MultiLangSupport.cpp b/duilib/Utils/MultiLangSupport.cpp similarity index 100% rename from tool_kits/duilib/Utils/MultiLangSupport.cpp rename to duilib/Utils/MultiLangSupport.cpp diff --git a/tool_kits/duilib/Utils/MultiLangSupport.h b/duilib/Utils/MultiLangSupport.h similarity index 100% rename from tool_kits/duilib/Utils/MultiLangSupport.h rename to duilib/Utils/MultiLangSupport.h diff --git a/tool_kits/duilib/Utils/OnScreenKeyboardManager.cpp b/duilib/Utils/OnScreenKeyboardManager.cpp similarity index 100% rename from tool_kits/duilib/Utils/OnScreenKeyboardManager.cpp rename to duilib/Utils/OnScreenKeyboardManager.cpp diff --git a/tool_kits/duilib/Utils/OnScreenKeyboardManager.h b/duilib/Utils/OnScreenKeyboardManager.h similarity index 100% rename from tool_kits/duilib/Utils/OnScreenKeyboardManager.h rename to duilib/Utils/OnScreenKeyboardManager.h diff --git a/tool_kits/duilib/Utils/Shadow.cpp b/duilib/Utils/Shadow.cpp similarity index 100% rename from tool_kits/duilib/Utils/Shadow.cpp rename to duilib/Utils/Shadow.cpp diff --git a/tool_kits/duilib/Utils/Shadow.h b/duilib/Utils/Shadow.h similarity index 100% rename from tool_kits/duilib/Utils/Shadow.h rename to duilib/Utils/Shadow.h diff --git a/tool_kits/duilib/Utils/StringUtil.cpp b/duilib/Utils/StringUtil.cpp similarity index 100% rename from tool_kits/duilib/Utils/StringUtil.cpp rename to duilib/Utils/StringUtil.cpp diff --git a/tool_kits/duilib/Utils/StringUtil.h b/duilib/Utils/StringUtil.h similarity index 100% rename from tool_kits/duilib/Utils/StringUtil.h rename to duilib/Utils/StringUtil.h diff --git a/tool_kits/duilib/Utils/TimerManager.cpp b/duilib/Utils/TimerManager.cpp similarity index 100% rename from tool_kits/duilib/Utils/TimerManager.cpp rename to duilib/Utils/TimerManager.cpp diff --git a/tool_kits/duilib/Utils/TimerManager.h b/duilib/Utils/TimerManager.h similarity index 100% rename from tool_kits/duilib/Utils/TimerManager.h rename to duilib/Utils/TimerManager.h diff --git a/tool_kits/duilib/Utils/UnZip.cpp b/duilib/Utils/UnZip.cpp similarity index 100% rename from tool_kits/duilib/Utils/UnZip.cpp rename to duilib/Utils/UnZip.cpp diff --git a/tool_kits/duilib/Utils/UnZip.h b/duilib/Utils/UnZip.h similarity index 100% rename from tool_kits/duilib/Utils/UnZip.h rename to duilib/Utils/UnZip.h diff --git a/tool_kits/duilib/Utils/Utils.h b/duilib/Utils/Utils.h similarity index 100% rename from tool_kits/duilib/Utils/Utils.h rename to duilib/Utils/Utils.h diff --git a/tool_kits/duilib/Utils/VersionHelpers.h b/duilib/Utils/VersionHelpers.h similarity index 100% rename from tool_kits/duilib/Utils/VersionHelpers.h rename to duilib/Utils/VersionHelpers.h diff --git a/tool_kits/duilib/Utils/WinImplBase.cpp b/duilib/Utils/WinImplBase.cpp similarity index 100% rename from tool_kits/duilib/Utils/WinImplBase.cpp rename to duilib/Utils/WinImplBase.cpp diff --git a/tool_kits/duilib/Utils/WinImplBase.h b/duilib/Utils/WinImplBase.h similarity index 100% rename from tool_kits/duilib/Utils/WinImplBase.h rename to duilib/Utils/WinImplBase.h diff --git a/tool_kits/duilib/Utils/flash11.tlh b/duilib/Utils/flash11.tlh similarity index 100% rename from tool_kits/duilib/Utils/flash11.tlh rename to duilib/Utils/flash11.tlh diff --git a/tool_kits/duilib/duilib.sln b/duilib/duilib.sln similarity index 100% rename from tool_kits/duilib/duilib.sln rename to duilib/duilib.sln diff --git a/tool_kits/duilib/duilib.vcxproj b/duilib/duilib.vcxproj similarity index 96% rename from tool_kits/duilib/duilib.vcxproj rename to duilib/duilib.vcxproj index 6177fdf3..aab42c50 100644 --- a/tool_kits/duilib/duilib.vcxproj +++ b/duilib/duilib.vcxproj @@ -1,422 +1,422 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {E106ACD7-4E53-4AEE-942B-D0DD426DB34E} - duilib - - - - StaticLibrary - false - Unicode - v120_xp - - - StaticLibrary - false - Unicode - v120_xp - - - StaticLibrary - false - Unicode - v120_xp - - - StaticLibrary - false - Unicode - v120_xp - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(ProjectDir)..\..\libs\ - $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ - false - false - false - false - false - false - $(ProjectDir)..\..\libs\ - $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ - false - false - false - false - false - false - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - $(ProjectName)_d - $(ProjectName)_d - - - $(ProjectDir)..\..\libs\x64\ - $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ - - - $(ProjectDir)..\..\libs\x64\ - $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\Debug/duilib.tlb - - - - - Disabled - .\;..\;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - Use - stdafx.h - $(IntDir)$(TargetName).pch - Level4 - true - EditAndContinue - false - 4100;4121;4127;4244;4310;4355;4481;4505;4512;4702;%(DisableSpecificWarnings) - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(ProjectDir)..\..\..\bin\$(ProjectName)_d.dll - true - %(AdditionalLibraryDirectories) - %(DelayLoadDLLs) - true - $(ProjectDir)..\..\..\bin\$(TargetName).pdb - 0x11000000 - $(ProjectDir)..\..\..\libs\duilib_d.lib - MachineX86 - comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;%(AdditionalDependencies) - - - true - .\Debug/duilib.bsc - - - comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;imm32.lib;shlwapi.lib - /IGNORE:4006,4221 %(AdditionalOptions) - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - .\Debug/duilib.tlb - - - - - Disabled - .\;..\;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - Use - stdafx.h - $(IntDir)$(TargetName).pch - Level4 - true - ProgramDatabase - false - 4100;4121;4127;4244;4310;4355;4481;4505;4512;4702;%(DisableSpecificWarnings) - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - $(ProjectDir)..\..\..\bin\$(ProjectName)_d.dll - true - %(AdditionalLibraryDirectories) - %(DelayLoadDLLs) - true - $(ProjectDir)..\..\..\bin\$(TargetName).pdb - 0x11000000 - $(ProjectDir)..\..\..\libs\duilib_d.lib - comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;%(AdditionalDependencies) - - - true - .\Debug/duilib.bsc - - - comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;imm32.lib;shlwapi.lib - /IGNORE:4006,4221 %(AdditionalOptions) - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\Release/duilib.tlb - - - - - MaxSpeed - Default - .\;..\;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - true - Use - $(IntDir)$(TargetName).pch - Level4 - true - true - true - MultiThreaded - 4100;4121;4127;4244;4310;4355;4481;4505;4512;4702;%(DisableSpecificWarnings) - - - NDEBUG;%(PreprocessorDefinitions) - 0x0406 - - - $(ProjectDir)..\..\..\bin\$(ProjectName).dll - true - %(AdditionalLibraryDirectories) - %(DelayLoadDLLs) - 0x11000000 - $(ProjectDir)..\..\..\libs\duilib.lib - MachineX86 - $(ProjectDir)..\..\..\bin\$(TargetName).pdb - true - comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;%(AdditionalDependencies) - - - true - .\Release/duilib.bsc - - - comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;imm32.lib;shlwapi.lib - /IGNORE:4006,4221 %(AdditionalOptions) - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - .\Release/duilib.tlb - - - - - MaxSpeed - Default - .\;..\;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - true - Use - $(IntDir)$(TargetName).pch - Level4 - true - true - true - MultiThreaded - 4100;4121;4127;4244;4310;4355;4481;4505;4512;4702;%(DisableSpecificWarnings) - - - NDEBUG;%(PreprocessorDefinitions) - 0x0406 - - - $(ProjectDir)..\..\..\bin\$(ProjectName).dll - true - %(AdditionalLibraryDirectories) - %(DelayLoadDLLs) - 0x11000000 - $(ProjectDir)..\..\..\libs\duilib.lib - $(ProjectDir)..\..\..\bin\$(TargetName).pdb - true - comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;%(AdditionalDependencies) - - - true - .\Release/duilib.bsc - - - comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;imm32.lib;shlwapi.lib - /IGNORE:4006,4221 %(AdditionalOptions) - - - - - - - false - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {E106ACD7-4E53-4AEE-942B-D0DD426DB34E} + duilib + + + + StaticLibrary + false + Unicode + v120_xp + + + StaticLibrary + false + Unicode + v120_xp + + + StaticLibrary + false + Unicode + v120_xp + + + StaticLibrary + false + Unicode + v120_xp + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(ProjectDir)..\libs\ + $(ProjectDir)..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ + false + false + false + false + false + false + $(ProjectDir)..\libs\ + $(ProjectDir)..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ + false + false + false + false + false + false + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + $(ProjectName)_d + $(ProjectName)_d + + + $(ProjectDir)..\libs\x64\ + $(ProjectDir)..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ + + + $(ProjectDir)..\libs\x64\ + $(ProjectDir)..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Debug/duilib.tlb + + + + + Disabled + .\;..\;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + Use + stdafx.h + $(IntDir)$(TargetName).pch + Level4 + true + EditAndContinue + false + 4100;4121;4127;4244;4310;4355;4481;4505;4512;4702;%(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + $(ProjectDir)..\..\..\bin\$(ProjectName)_d.dll + true + %(AdditionalLibraryDirectories) + %(DelayLoadDLLs) + true + $(ProjectDir)..\..\..\bin\$(TargetName).pdb + 0x11000000 + $(ProjectDir)..\..\..\libs\duilib_d.lib + MachineX86 + comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;%(AdditionalDependencies) + + + true + .\Debug/duilib.bsc + + + comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;imm32.lib;shlwapi.lib + /IGNORE:4006,4221 %(AdditionalOptions) + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + .\Debug/duilib.tlb + + + + + Disabled + .\;..\;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + Use + stdafx.h + $(IntDir)$(TargetName).pch + Level4 + true + ProgramDatabase + false + 4100;4121;4127;4244;4310;4355;4481;4505;4512;4702;%(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + $(ProjectDir)..\..\..\bin\$(ProjectName)_d.dll + true + %(AdditionalLibraryDirectories) + %(DelayLoadDLLs) + true + $(ProjectDir)..\..\..\bin\$(TargetName).pdb + 0x11000000 + $(ProjectDir)..\..\..\libs\duilib_d.lib + comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;%(AdditionalDependencies) + + + true + .\Debug/duilib.bsc + + + comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;imm32.lib;shlwapi.lib + /IGNORE:4006,4221 %(AdditionalOptions) + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Release/duilib.tlb + + + + + MaxSpeed + Default + .\;..\;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + true + Use + $(IntDir)$(TargetName).pch + Level4 + true + true + true + MultiThreaded + 4100;4121;4127;4244;4310;4355;4481;4505;4512;4702;%(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0406 + + + $(ProjectDir)..\..\..\bin\$(ProjectName).dll + true + %(AdditionalLibraryDirectories) + %(DelayLoadDLLs) + 0x11000000 + $(ProjectDir)..\..\..\libs\duilib.lib + MachineX86 + $(ProjectDir)..\..\..\bin\$(TargetName).pdb + true + comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;%(AdditionalDependencies) + + + true + .\Release/duilib.bsc + + + comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;imm32.lib;shlwapi.lib + /IGNORE:4006,4221 %(AdditionalOptions) + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + .\Release/duilib.tlb + + + + + MaxSpeed + Default + .\;..\;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + true + Use + $(IntDir)$(TargetName).pch + Level4 + true + true + true + MultiThreaded + 4100;4121;4127;4244;4310;4355;4481;4505;4512;4702;%(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0406 + + + $(ProjectDir)..\..\..\bin\$(ProjectName).dll + true + %(AdditionalLibraryDirectories) + %(DelayLoadDLLs) + 0x11000000 + $(ProjectDir)..\..\..\libs\duilib.lib + $(ProjectDir)..\..\..\bin\$(TargetName).pdb + true + comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;%(AdditionalDependencies) + + + true + .\Release/duilib.bsc + + + comctl32.lib;gdiplus.lib;msimg32.lib;winmm.lib;imm32.lib;shlwapi.lib + /IGNORE:4006,4221 %(AdditionalOptions) + + + + + + + false + + + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tool_kits/duilib/duilib.vcxproj.filters b/duilib/duilib.vcxproj.filters similarity index 97% rename from tool_kits/duilib/duilib.vcxproj.filters rename to duilib/duilib.vcxproj.filters index ab7a238e..219366eb 100644 --- a/tool_kits/duilib/duilib.vcxproj.filters +++ b/duilib/duilib.vcxproj.filters @@ -1,347 +1,347 @@ - - - - - {8fc45193-00aa-405d-8445-6f6619d94834} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {b7a95a7b-1188-487e-b75b-a6e6fe6055f7} - - - {ef45879d-87a5-4d7f-9a92-fdf97778b304} - - - {f70f6171-d9fd-4189-b1d7-5250e2d6f0fd} - - - {b7a7aeb7-2adb-4395-b80d-4922bd4efc19} - h;hpp;hxx;hm;inl - - - {3472fe0b-1976-4ada-9c67-2f07b06068d2} - - - {1a8a45f1-b601-4178-b118-b282f71c4dec} - - - {6eb00376-1e2b-4faf-9eaa-bdc915049307} - - - {38a8cc27-53b9-4413-8919-ae7448229ad2} - - - {101719c8-36d9-454c-be9a-d0f158cf21b4} - - - {4f978102-2279-42b9-ab99-8a719e9fdf53} - - - {2069d257-49fd-4283-9999-19e7dda732c8} - - - {ab59d168-e65b-4cf4-aff6-a2a07e35d058} - - - {93308611-e7ba-4331-845a-700f5b457c52} - - - - - Source Files - - - Source Files - - - Source Files\Utils - - - Source Files\Control - - - Source Files\Control - - - Source Files\Control - - - Source Files\Control - - - Source Files\Control - - - Source Files\Control - - - Source Files\Control - - - Source Files\Core - - - Source Files\Core - - - Source Files\Utils - - - Source Files\Core - - - Source Files\Core - - - Source Files\Core - - - Source Files\Box - - - Source Files\Box - - - Source Files\Box - - - Source Files\Box - - - Source Files\Box - - - Source Files\Utils - - - Source Files\Animation - - - Source Files\Core - - - Source Files\Utils - - - Source Files\Core - - - Source Files\Animation - - - Source Files\Utils - - - Source Files\Core - - - Source Files\Utils - - - Source Files\Control - - - Source Files\Utils - - - Source Files\Render - - - Source Files\Render - - - Source Files\Render - - - Source Files\Render - - - Source Files\Render - - - Source Files\Utils - - - Source Files\Render - - - Source Files\Render - - - Source Files\Render - - - Source Files\Render - - - Source Files\Render - - - Source Files\Utils - - - Source Files\Control - - - - - Header Files - - - Header Files - - - Header Files\Utils - - - Header Files\Utils - - - Header Files\Utils - - - Header Files\Control - - - Header Files\Control - - - Header Files\Control - - - Header Files\Control - - - Header Files\Control - - - Header Files\Control - - - Header Files\Control - - - Header Files\Control - - - Header Files\Control - - - Header Files\Control - - - Header Files\Control - - - Header Files\Core - - - Header Files\Core - - - Header Files\Core - - - Header Files\Utils - - - Header Files\Utils - - - Header Files\Core - - - Header Files\Core - - - Header Files\Core - - - Header Files\Box - - - Header Files\Box - - - Header Files\Box - - - Header Files\Box - - - Header Files\Box - - - Header Files\Animation - - - Header Files\Core - - - Header Files\Utils - - - Header Files\Core - - - Header Files\Animation - - - Header Files\Utils - - - Header Files\Utils - - - Header Files\Utils - - - Header Files\Utils - - - Header Files\Control - - - Header Files\Utils - - - Header Files\Render - - - Header Files\Render - - - Header Files\Render - - - Header Files\Render - - - Header Files\Render - - - Header Files\Utils - - - Header Files\Render - - - Header Files\Render - - - Header Files\Render - - - Header Files\Render - - - Header Files\Render - - - Header Files\Utils - - - Header Files\Control - - + + + + + {8fc45193-00aa-405d-8445-6f6619d94834} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {b7a95a7b-1188-487e-b75b-a6e6fe6055f7} + + + {ef45879d-87a5-4d7f-9a92-fdf97778b304} + + + {f70f6171-d9fd-4189-b1d7-5250e2d6f0fd} + + + {b7a7aeb7-2adb-4395-b80d-4922bd4efc19} + h;hpp;hxx;hm;inl + + + {3472fe0b-1976-4ada-9c67-2f07b06068d2} + + + {1a8a45f1-b601-4178-b118-b282f71c4dec} + + + {6eb00376-1e2b-4faf-9eaa-bdc915049307} + + + {38a8cc27-53b9-4413-8919-ae7448229ad2} + + + {101719c8-36d9-454c-be9a-d0f158cf21b4} + + + {4f978102-2279-42b9-ab99-8a719e9fdf53} + + + {2069d257-49fd-4283-9999-19e7dda732c8} + + + {ab59d168-e65b-4cf4-aff6-a2a07e35d058} + + + {93308611-e7ba-4331-845a-700f5b457c52} + + + + + Source Files + + + Source Files + + + Source Files\Utils + + + Source Files\Control + + + Source Files\Control + + + Source Files\Control + + + Source Files\Control + + + Source Files\Control + + + Source Files\Control + + + Source Files\Control + + + Source Files\Core + + + Source Files\Core + + + Source Files\Utils + + + Source Files\Core + + + Source Files\Core + + + Source Files\Core + + + Source Files\Box + + + Source Files\Box + + + Source Files\Box + + + Source Files\Box + + + Source Files\Box + + + Source Files\Utils + + + Source Files\Animation + + + Source Files\Core + + + Source Files\Utils + + + Source Files\Core + + + Source Files\Animation + + + Source Files\Utils + + + Source Files\Core + + + Source Files\Utils + + + Source Files\Control + + + Source Files\Utils + + + Source Files\Render + + + Source Files\Render + + + Source Files\Render + + + Source Files\Render + + + Source Files\Render + + + Source Files\Utils + + + Source Files\Render + + + Source Files\Render + + + Source Files\Render + + + Source Files\Render + + + Source Files\Render + + + Source Files\Utils + + + Source Files\Control + + + + + Header Files + + + Header Files + + + Header Files\Utils + + + Header Files\Utils + + + Header Files\Utils + + + Header Files\Control + + + Header Files\Control + + + Header Files\Control + + + Header Files\Control + + + Header Files\Control + + + Header Files\Control + + + Header Files\Control + + + Header Files\Control + + + Header Files\Control + + + Header Files\Control + + + Header Files\Control + + + Header Files\Core + + + Header Files\Core + + + Header Files\Core + + + Header Files\Utils + + + Header Files\Utils + + + Header Files\Core + + + Header Files\Core + + + Header Files\Core + + + Header Files\Box + + + Header Files\Box + + + Header Files\Box + + + Header Files\Box + + + Header Files\Box + + + Header Files\Animation + + + Header Files\Core + + + Header Files\Utils + + + Header Files\Core + + + Header Files\Animation + + + Header Files\Utils + + + Header Files\Utils + + + Header Files\Utils + + + Header Files\Utils + + + Header Files\Control + + + Header Files\Utils + + + Header Files\Render + + + Header Files\Render + + + Header Files\Render + + + Header Files\Render + + + Header Files\Render + + + Header Files\Utils + + + Header Files\Render + + + Header Files\Render + + + Header Files\Render + + + Header Files\Render + + + Header Files\Render + + + Header Files\Utils + + + Header Files\Control + + \ No newline at end of file diff --git a/samples/README.md b/examples/README.md similarity index 95% rename from samples/README.md rename to examples/README.md index a8063264..e54aa7f4 100644 --- a/samples/README.md +++ b/examples/README.md @@ -8,6 +8,7 @@ - `layouts` 包含一个登录窗口和一个模拟微信 PC 聊天布局的窗口示例 - `multi_browser` 基于 CEF 的自定义多标签可拖曳浏览器示例 - `richlist` 演示了一个列表控件中插入自定义列表项的用法 + - `virtualbox` 演示了多列虚拟列表的使用 ## Demos @@ -16,4 +17,3 @@ - [NetEase IM Demo](https://github.com/netease-im/NIM_PC_Demo) - [NetEase Interact Live Demo](https://yx-web-nosdn.netease.im/package/1542889389/NIM_InteractLive_PC_Demo_v2.9.0.zip?download=NIM_InteractLive_PC_Demo_v2.9.0.zip) - [NetEase Education Demo](https://yx-web-nosdn.netease.im/package/1537445692/NIM_Education_PC_Demo_v2.3.0.zip?download=NIM_Education_PC_Demo_v2.3.0.zip) - \ No newline at end of file diff --git a/samples/basic/basic.ico b/examples/basic/basic.ico similarity index 100% rename from samples/basic/basic.ico rename to examples/basic/basic.ico diff --git a/samples/basic/basic.rc b/examples/basic/basic.rc similarity index 100% rename from samples/basic/basic.rc rename to examples/basic/basic.rc diff --git a/samples/basic/basic.vcxproj b/examples/basic/basic.vcxproj similarity index 94% rename from samples/basic/basic.vcxproj rename to examples/basic/basic.vcxproj index c3f39261..7b88b773 100644 --- a/samples/basic/basic.vcxproj +++ b/examples/basic/basic.vcxproj @@ -1,4 +1,4 @@ - + @@ -75,7 +75,7 @@ $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ $(ProjectName)_d ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) @@ -83,21 +83,21 @@ $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ $(ProjectName)64_d ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) false $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) false $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) $(ProjectName)64 @@ -194,18 +194,15 @@ - + + + + {8d9a6595-717a-41c8-b468-0011a72be3d1} - + {e106acd7-4e53-4aee-942b-d0dd426db34e} - - {9951345f-620b-4bed-bb51-4f928cafd454} - - - - diff --git a/samples/basic/basic.vcxproj.filters b/examples/basic/basic.vcxproj.filters similarity index 100% rename from samples/basic/basic.vcxproj.filters rename to examples/basic/basic.vcxproj.filters diff --git a/samples/basic/basic_form.cpp b/examples/basic/basic_form.cpp similarity index 100% rename from samples/basic/basic_form.cpp rename to examples/basic/basic_form.cpp diff --git a/samples/basic/basic_form.h b/examples/basic/basic_form.h similarity index 100% rename from samples/basic/basic_form.h rename to examples/basic/basic_form.h diff --git a/samples/basic/main.cpp b/examples/basic/main.cpp similarity index 93% rename from samples/basic/main.cpp rename to examples/basic/main.cpp index 1fee9cfe..feab5a63 100644 --- a/samples/basic/main.cpp +++ b/examples/basic/main.cpp @@ -24,10 +24,10 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, void MainThread::Init() { - nbase::ThreadManager::RegisterThread(kThreadUI); + nbase::ThreadManager::RegisterThread(kThreadMain); // 获取资源路径,初始化全局参数 - std::wstring theme_dir = QPath::GetAppPath(); + std::wstring theme_dir = nbase::win32::GetCurrentModuleDirectory(); #ifdef _DEBUG // Debug 模式下使用本地文件夹作为资源 // 默认皮肤使用 resources\\themes\\default diff --git a/samples/basic/main.h b/examples/basic/main.h similarity index 100% rename from samples/basic/main.h rename to examples/basic/main.h diff --git a/samples/basic/resource.h b/examples/basic/resource.h similarity index 100% rename from samples/basic/resource.h rename to examples/basic/resource.h diff --git a/samples/basic/small.ico b/examples/basic/small.ico similarity index 100% rename from samples/basic/small.ico rename to examples/basic/small.ico diff --git a/samples/basic/stdafx.cpp b/examples/basic/stdafx.cpp similarity index 100% rename from samples/basic/stdafx.cpp rename to examples/basic/stdafx.cpp diff --git a/samples/layouts/stdafx.h b/examples/basic/stdafx.h similarity index 88% rename from samples/layouts/stdafx.h rename to examples/basic/stdafx.h index 9fae117e..95611366 100644 --- a/samples/layouts/stdafx.h +++ b/examples/basic/stdafx.h @@ -16,8 +16,5 @@ // base header #include "base/base.h" -// shared project -#include "shared/shared.h" - // duilib #include "duilib/UIlib.h" diff --git a/samples/basic/targetver.h b/examples/basic/targetver.h similarity index 100% rename from samples/basic/targetver.h rename to examples/basic/targetver.h diff --git a/samples/cef/cef.ico b/examples/cef/cef.ico similarity index 100% rename from samples/cef/cef.ico rename to examples/cef/cef.ico diff --git a/samples/cef/cef.rc b/examples/cef/cef.rc similarity index 100% rename from samples/cef/cef.rc rename to examples/cef/cef.rc diff --git a/samples/cef/cef.vcxproj b/examples/cef/cef.vcxproj similarity index 92% rename from samples/cef/cef.vcxproj rename to examples/cef/cef.vcxproj index e563046e..98cd777f 100644 --- a/samples/cef/cef.vcxproj +++ b/examples/cef/cef.vcxproj @@ -75,7 +75,7 @@ $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ $(ProjectName)_d ..\..\bin\ - ..\..\tool_kits\;..\..\third_party\cef_wrapper\;$(IncludePath) + ..\..\;..\..\third_party\cef_wrapper\;$(IncludePath) ..\..\libs\;$(LibraryPath) @@ -83,21 +83,21 @@ $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ $(ProjectName)64_d ..\..\bin\ - ..\..\tool_kits\;..\..\third_party\cef_wrapper\;$(IncludePath) + ..\..\;..\..\third_party\cef_wrapper\;$(IncludePath) ..\..\libs\x64\;$(LibraryPath) false $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ ..\..\bin\ - ..\..\tool_kits\;..\..\third_party\cef_wrapper\;$(IncludePath) + ..\..\;..\..\third_party\cef_wrapper\;$(IncludePath) ..\..\libs\;$(LibraryPath) false $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ ..\..\bin\ - ..\..\tool_kits\;..\..\third_party\cef_wrapper\;$(IncludePath) + ..\..\;..\..\third_party\cef_wrapper\;$(IncludePath) ..\..\libs\x64\;$(LibraryPath) $(ProjectName)64 @@ -198,16 +198,13 @@ - + {8d9a6595-717a-41c8-b468-0011a72be3d1} - + {e106acd7-4e53-4aee-942b-d0dd426db34e} - - {9951345f-620b-4bed-bb51-4f928cafd454} - - + {0149ba6e-3c0a-426d-aa0a-0b9ec7742f19} diff --git a/samples/cef/cef.vcxproj.filters b/examples/cef/cef.vcxproj.filters similarity index 100% rename from samples/cef/cef.vcxproj.filters rename to examples/cef/cef.vcxproj.filters diff --git a/samples/cef/cef_form.cpp b/examples/cef/cef_form.cpp similarity index 96% rename from samples/cef/cef_form.cpp rename to examples/cef/cef_form.cpp index bc3c23f8..1a7fd3d6 100644 --- a/samples/cef/cef_form.cpp +++ b/examples/cef/cef_form.cpp @@ -62,7 +62,7 @@ void CefForm::InitWindow() cef_control_->AttachDevTools(cef_control_dev_); // ƤĿ¼µ html ļ - cef_control_->LoadURL(QPath::GetAppPath() + L"resources\\themes\\default\\cef\\cef.html"); + cef_control_->LoadURL(nbase::win32::GetCurrentModuleDirectory() + L"resources\\themes\\default\\cef\\cef.html"); if (!nim_cef::CefManager::GetInstance()->IsEnableOffsetRender()) cef_control_dev_->SetVisible(false); diff --git a/samples/cef/cef_form.h b/examples/cef/cef_form.h similarity index 100% rename from samples/cef/cef_form.h rename to examples/cef/cef_form.h diff --git a/samples/cef/main.cpp b/examples/cef/main.cpp similarity index 87% rename from samples/cef/main.cpp rename to examples/cef/main.cpp index e740026a..0f199790 100644 --- a/samples/cef/main.cpp +++ b/examples/cef/main.cpp @@ -25,7 +25,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, // 初始化 CEF CefSettings settings; - if (!nim_cef::CefManager::GetInstance()->Initialize(QPath::GetAppPath() + L"cef_temp\\", settings, kEnableOffsetRender)) + if (!nim_cef::CefManager::GetInstance()->Initialize(nbase::win32::GetCurrentModuleDirectory() + L"cef_temp\\", settings, kEnableOffsetRender)) { return 0; } @@ -46,13 +46,13 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, void MainThread::Init() { - nbase::ThreadManager::RegisterThread(kThreadUI); + nbase::ThreadManager::RegisterThread(kThreadMain); // 获取资源路径,初始化全局参数 // 默认皮肤使用 resources\\themes\\default // 默认语言使用 resources\\lang\\zh_CN // 如需修改请指定 Startup 最后两个参数 - std::wstring theme_dir = QPath::GetAppPath(); + std::wstring theme_dir = nbase::win32::GetCurrentModuleDirectory(); ui::GlobalManager::Startup(theme_dir + L"resources\\", ui::CreateControlCallback(), false); // 创建一个默认带有阴影的居中窗口 diff --git a/samples/cef/main.h b/examples/cef/main.h similarity index 100% rename from samples/cef/main.h rename to examples/cef/main.h diff --git a/samples/cef/resource.h b/examples/cef/resource.h similarity index 100% rename from samples/cef/resource.h rename to examples/cef/resource.h diff --git a/samples/cef/small.ico b/examples/cef/small.ico similarity index 100% rename from samples/cef/small.ico rename to examples/cef/small.ico diff --git a/samples/cef/stdafx.cpp b/examples/cef/stdafx.cpp similarity index 100% rename from samples/cef/stdafx.cpp rename to examples/cef/stdafx.cpp diff --git a/samples/cef/stdafx.h b/examples/cef/stdafx.h similarity index 90% rename from samples/cef/stdafx.h rename to examples/cef/stdafx.h index f0832686..4a9d4a42 100644 --- a/samples/cef/stdafx.h +++ b/examples/cef/stdafx.h @@ -16,9 +16,6 @@ // base header #include "base/base.h" -// shared project -#include "shared/shared.h" - // duilib #include "duilib/UIlib.h" diff --git a/samples/cef/targetver.h b/examples/cef/targetver.h similarity index 100% rename from samples/cef/targetver.h rename to examples/cef/targetver.h diff --git a/samples/controls/controls.ico b/examples/controls/controls.ico similarity index 100% rename from samples/controls/controls.ico rename to examples/controls/controls.ico diff --git a/samples/controls/controls.rc b/examples/controls/controls.rc similarity index 100% rename from samples/controls/controls.rc rename to examples/controls/controls.rc diff --git a/samples/controls/controls.vcxproj b/examples/controls/controls.vcxproj similarity index 93% rename from samples/controls/controls.vcxproj rename to examples/controls/controls.vcxproj index 246ad58a..456957b6 100644 --- a/samples/controls/controls.vcxproj +++ b/examples/controls/controls.vcxproj @@ -75,7 +75,7 @@ $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ $(ProjectName)_d ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) @@ -83,21 +83,21 @@ $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ $(ProjectName)64_d ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) false $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) false $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) $(ProjectName)64 @@ -194,16 +194,13 @@ - + {8d9a6595-717a-41c8-b468-0011a72be3d1} - + {e106acd7-4e53-4aee-942b-d0dd426db34e} - - {9951345f-620b-4bed-bb51-4f928cafd454} - - + {0149ba6e-3c0a-426d-aa0a-0b9ec7742f19} diff --git a/samples/controls/controls.vcxproj.filters b/examples/controls/controls.vcxproj.filters similarity index 100% rename from samples/controls/controls.vcxproj.filters rename to examples/controls/controls.vcxproj.filters diff --git a/samples/controls/controls_form.cpp b/examples/controls/controls_form.cpp similarity index 90% rename from samples/controls/controls_form.cpp rename to examples/controls/controls_form.cpp index 03ed699e..257bfe5e 100644 --- a/samples/controls/controls_form.cpp +++ b/examples/controls/controls_form.cpp @@ -103,17 +103,15 @@ void ControlForm::InitWindow() } // Post task to UI thread - nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&ControlForm::OnLoadedResourceFile, this, xml)); // or Post2UI(nbase::Bind(&ControlForm::OnLoadedResourceFile, this, xml)); + nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&ControlForm::OnLoadedResourceFile, this, xml)); // or Post2UI(nbase::Bind(&ControlForm::OnLoadedResourceFile, this, xml)); }; // Using ToWeakCallback to protect closure when if [ControlForm] was destoryed nbase::ThreadManager::PostTask(kThreadGlobalMisc, ToWeakCallback(closure)); // or Post2GlobalMisc(ToWeakCallback(closure)); /* Post repeat task to update progress value 200 milliseconds once */ StdClosure repeat_task = [this]() { - auto timestamp = shared::tools::GenerateTimeStamp(); - int64_t timestamp_num = 0; - nbase::StringToInt64(timestamp, ×tamp_num); - nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&ControlForm::OnProgressValueChagned, this, timestamp_num % 100)); + nbase::TimeDelta time_delta = nbase::TimeDelta::FromMicroseconds(nbase::Time::Now().ToInternalValue()); + nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&ControlForm::OnProgressValueChagned, this, time_delta.ToMilliseconds() % 100)); }; nbase::ThreadManager::PostRepeatedTask(kThreadGlobalMisc, ToWeakCallback(repeat_task), nbase::TimeDelta::FromMilliseconds(200)); @@ -156,7 +154,7 @@ void ControlForm::OnProgressValueChagned(float value) progress->SetValue(value); auto circleprogress = dynamic_cast(FindControl(L"circleprogress")); circleprogress->SetValue(value); - TCHAR szBuffer[32] = {0}; + TCHAR szBuffer[32] = {0}; swprintf_s(szBuffer, _T("%.0f%%"), value); circleprogress->SetText(szBuffer); } diff --git a/samples/controls/controls_form.h b/examples/controls/controls_form.h similarity index 100% rename from samples/controls/controls_form.h rename to examples/controls/controls_form.h diff --git a/samples/controls/main.cpp b/examples/controls/main.cpp similarity index 81% rename from samples/controls/main.cpp rename to examples/controls/main.cpp index 4006ff65..97608de5 100644 --- a/samples/controls/main.cpp +++ b/examples/controls/main.cpp @@ -18,16 +18,26 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, return 0; } +void MiscThread::Init() +{ + nbase::ThreadManager::RegisterThread(thread_id_); +} + +void MiscThread::Cleanup() +{ + nbase::ThreadManager::UnregisterThread(); +} + void MainThread::Init() { - nbase::ThreadManager::RegisterThread(kThreadUI); + nbase::ThreadManager::RegisterThread(kThreadMain); // 启动杂事处理线程 misc_thread_.reset(new MiscThread(kThreadGlobalMisc, "Global Misc Thread")); misc_thread_->Start(); // 获取资源路径,初始化全局参数 - std::wstring app_dir = QPath::GetAppPath(); + std::wstring app_dir = nbase::win32::GetCurrentModuleDirectory(); ui::GlobalManager::Startup(app_dir + L"resources\\", ui::CreateControlCallback(), false); // 创建一个默认带有阴影的居中窗口 diff --git a/samples/controls/main.h b/examples/controls/main.h similarity index 51% rename from samples/controls/main.h rename to examples/controls/main.h index 40980e10..cc822498 100644 --- a/samples/controls/main.h +++ b/examples/controls/main.h @@ -2,10 +2,40 @@ #include "resource.h" +/** @class ߳ +* @brief ̳߳࣬ nbase::FrameworkThread +* @copyright (c) 2015, NetEase Inc. All rights reserved +* @date 2015/1/1 +*/ +class MiscThread : public nbase::FrameworkThread +{ +public: + MiscThread(enum ThreadIds thread_id, const char *name) + : FrameworkThread(name) + , thread_id_(thread_id) {} + + ~MiscThread(void) {} + +private: + /** + * 麯ʼ߳ + * @return void ޷ֵ + */ + virtual void Init() override; + + /** + * 麯߳˳ʱһЩ + * @return void ޷ֵ + */ + virtual void Cleanup() override; + +private: + enum ThreadIds thread_id_; +}; + /** @class MainThread * @brief ̣߳UỊ̳߳࣬ nbase::FrameworkThread * @copyright (c) 2015, NetEase Inc. All rights reserved -* @author towik * @date 2015/1/1 */ class MainThread : public nbase::FrameworkThread diff --git a/samples/controls/resource.h b/examples/controls/resource.h similarity index 100% rename from samples/controls/resource.h rename to examples/controls/resource.h diff --git a/samples/controls/small.ico b/examples/controls/small.ico similarity index 100% rename from samples/controls/small.ico rename to examples/controls/small.ico diff --git a/samples/controls/stdafx.cpp b/examples/controls/stdafx.cpp similarity index 100% rename from samples/controls/stdafx.cpp rename to examples/controls/stdafx.cpp diff --git a/samples/controls/stdafx.h b/examples/controls/stdafx.h similarity index 89% rename from samples/controls/stdafx.h rename to examples/controls/stdafx.h index d15652aa..337ee2a2 100644 --- a/samples/controls/stdafx.h +++ b/examples/controls/stdafx.h @@ -16,9 +16,6 @@ // base header #include "base/base.h" -// shared project -#include "shared/shared.h" - // duilib #include "duilib/UIlib.h" diff --git a/samples/controls/targetver.h b/examples/controls/targetver.h similarity index 100% rename from samples/controls/targetver.h rename to examples/controls/targetver.h diff --git a/samples/samples.sln b/examples/examples.sln similarity index 84% rename from samples/samples.sln rename to examples/examples.sln index b6b79bde..639e2c63 100644 --- a/samples/samples.sln +++ b/examples/examples.sln @@ -1,15 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +VisualStudioVersion = 12.0.40629.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tool_kits", "tool_kits", "{66F85B8F-11B7-4964-B51E-99DF85D8FE00}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "duilib", "..\tool_kits\duilib\duilib.vcxproj", "{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "base", "..\tool_kits\base\base.vcxproj", "{8D9A6595-717A-41C8-B468-0011A72BE3D1}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{B2087994-3DF6-4A57-B8C6-6F744520D7FA}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{B2087994-3DF6-4A57-B8C6-6F744520D7FA}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic", "basic\basic.vcxproj", "{F1A9371F-9A34-45A0-98EB-83FF371F067F}" EndProject @@ -21,17 +15,19 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "richlist", "richlist\richli EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_browser", "multi_browser\multi_browser.vcxproj", "{FDB5539F-1060-4975-B603-B66454C8C897}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared", "..\tool_kits\shared\shared.vcxproj", "{9951345F-620B-4BED-BB51-4F928CAFD454}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ui_components", "..\tool_kits\ui_components\ui_components.vcxproj", "{0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "third_party", "third_party", "{1DA0A8E2-5832-42FC-83F7-2CDCAD379C90}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcef_dll_wrapper", "..\third_party\cef_wrapper\libcef_dll_wrapper.vcxproj", "{A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "controls", "controls\controls.vcxproj", "{8BD95440-9000-4745-8011-27DD553EF06F}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VirtualBox", "VirtualBox\VirtualBox.vcxproj", "{E35589C6-9509-4116-996F-1D045C2DACAE}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "virtualbox", "VirtualBox\VirtualBox.vcxproj", "{E35589C6-9509-4116-996F-1D045C2DACAE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "base", "..\base\base.vcxproj", "{8D9A6595-717A-41C8-B468-0011A72BE3D1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "duilib", "..\duilib\duilib.vcxproj", "{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ui_components", "..\ui_components\ui_components.vcxproj", "{0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -41,22 +37,6 @@ Global Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|Win32.ActiveCfg = Debug|Win32 - {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|Win32.Build.0 = Debug|Win32 - {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|x64.ActiveCfg = Debug|x64 - {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|x64.Build.0 = Debug|x64 - {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|Win32.ActiveCfg = Release|Win32 - {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|Win32.Build.0 = Release|Win32 - {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|x64.ActiveCfg = Release|x64 - {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|x64.Build.0 = Release|x64 - {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Debug|Win32.ActiveCfg = Debug|Win32 - {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Debug|Win32.Build.0 = Debug|Win32 - {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Debug|x64.ActiveCfg = Debug|x64 - {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Debug|x64.Build.0 = Debug|x64 - {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Release|Win32.ActiveCfg = Release|Win32 - {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Release|Win32.Build.0 = Release|Win32 - {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Release|x64.ActiveCfg = Release|x64 - {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Release|x64.Build.0 = Release|x64 {F1A9371F-9A34-45A0-98EB-83FF371F067F}.Debug|Win32.ActiveCfg = Debug|Win32 {F1A9371F-9A34-45A0-98EB-83FF371F067F}.Debug|Win32.Build.0 = Debug|Win32 {F1A9371F-9A34-45A0-98EB-83FF371F067F}.Debug|x64.ActiveCfg = Debug|x64 @@ -97,22 +77,6 @@ Global {FDB5539F-1060-4975-B603-B66454C8C897}.Release|Win32.Build.0 = Release|Win32 {FDB5539F-1060-4975-B603-B66454C8C897}.Release|x64.ActiveCfg = Release|x64 {FDB5539F-1060-4975-B603-B66454C8C897}.Release|x64.Build.0 = Release|x64 - {9951345F-620B-4BED-BB51-4F928CAFD454}.Debug|Win32.ActiveCfg = Debug|Win32 - {9951345F-620B-4BED-BB51-4F928CAFD454}.Debug|Win32.Build.0 = Debug|Win32 - {9951345F-620B-4BED-BB51-4F928CAFD454}.Debug|x64.ActiveCfg = Debug|x64 - {9951345F-620B-4BED-BB51-4F928CAFD454}.Debug|x64.Build.0 = Debug|x64 - {9951345F-620B-4BED-BB51-4F928CAFD454}.Release|Win32.ActiveCfg = Release|Win32 - {9951345F-620B-4BED-BB51-4F928CAFD454}.Release|Win32.Build.0 = Release|Win32 - {9951345F-620B-4BED-BB51-4F928CAFD454}.Release|x64.ActiveCfg = Release|x64 - {9951345F-620B-4BED-BB51-4F928CAFD454}.Release|x64.Build.0 = Release|x64 - {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Debug|Win32.ActiveCfg = Debug|Win32 - {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Debug|Win32.Build.0 = Debug|Win32 - {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Debug|x64.ActiveCfg = Debug|x64 - {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Debug|x64.Build.0 = Debug|x64 - {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Release|Win32.ActiveCfg = Release|Win32 - {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Release|Win32.Build.0 = Release|Win32 - {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Release|x64.ActiveCfg = Release|x64 - {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Release|x64.Build.0 = Release|x64 {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9}.Debug|Win32.ActiveCfg = Debug|Win32 {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9}.Debug|Win32.Build.0 = Debug|Win32 {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9}.Debug|x64.ActiveCfg = Debug|x64 @@ -135,23 +99,43 @@ Global {E35589C6-9509-4116-996F-1D045C2DACAE}.Release|Win32.ActiveCfg = Release|Win32 {E35589C6-9509-4116-996F-1D045C2DACAE}.Release|Win32.Build.0 = Release|Win32 {E35589C6-9509-4116-996F-1D045C2DACAE}.Release|x64.ActiveCfg = Release|Win32 + {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Debug|Win32.ActiveCfg = Debug|Win32 + {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Debug|Win32.Build.0 = Debug|Win32 + {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Debug|x64.ActiveCfg = Debug|x64 + {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Debug|x64.Build.0 = Debug|x64 + {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Release|Win32.ActiveCfg = Release|Win32 + {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Release|Win32.Build.0 = Release|Win32 + {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Release|x64.ActiveCfg = Release|x64 + {8D9A6595-717A-41C8-B468-0011A72BE3D1}.Release|x64.Build.0 = Release|x64 + {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|Win32.ActiveCfg = Debug|Win32 + {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|Win32.Build.0 = Debug|Win32 + {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|x64.ActiveCfg = Debug|x64 + {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|x64.Build.0 = Debug|x64 + {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|Win32.ActiveCfg = Release|Win32 + {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|Win32.Build.0 = Release|Win32 + {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|x64.ActiveCfg = Release|x64 + {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|x64.Build.0 = Release|x64 + {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Debug|Win32.ActiveCfg = Debug|Win32 + {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Debug|Win32.Build.0 = Debug|Win32 + {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Debug|x64.ActiveCfg = Debug|x64 + {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Debug|x64.Build.0 = Debug|x64 + {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Release|Win32.ActiveCfg = Release|Win32 + {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Release|Win32.Build.0 = Release|Win32 + {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Release|x64.ActiveCfg = Release|x64 + {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {E106ACD7-4E53-4AEE-942B-D0DD426DB34E} = {66F85B8F-11B7-4964-B51E-99DF85D8FE00} - {8D9A6595-717A-41C8-B468-0011A72BE3D1} = {66F85B8F-11B7-4964-B51E-99DF85D8FE00} - {9951345F-620B-4BED-BB51-4F928CAFD454} = {66F85B8F-11B7-4964-B51E-99DF85D8FE00} - {0149BA6E-3C0A-426D-AA0A-0B9EC7742F19} = {66F85B8F-11B7-4964-B51E-99DF85D8FE00} {F1A9371F-9A34-45A0-98EB-83FF371F067F} = {B2087994-3DF6-4A57-B8C6-6F744520D7FA} {2BFFA1EE-039D-479E-9BCC-2D12F8AEDD16} = {B2087994-3DF6-4A57-B8C6-6F744520D7FA} {B8588C07-9CE2-456C-83B1-86E4B65D4108} = {B2087994-3DF6-4A57-B8C6-6F744520D7FA} {878F5BF0-652A-4FDB-992B-BB7F26D62F0D} = {B2087994-3DF6-4A57-B8C6-6F744520D7FA} {FDB5539F-1060-4975-B603-B66454C8C897} = {B2087994-3DF6-4A57-B8C6-6F744520D7FA} + {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9} = {1DA0A8E2-5832-42FC-83F7-2CDCAD379C90} {8BD95440-9000-4745-8011-27DD553EF06F} = {B2087994-3DF6-4A57-B8C6-6F744520D7FA} {E35589C6-9509-4116-996F-1D045C2DACAE} = {B2087994-3DF6-4A57-B8C6-6F744520D7FA} - {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9} = {1DA0A8E2-5832-42FC-83F7-2CDCAD379C90} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {68CA0970-4242-4E4F-94D2-C19760FCA05D} diff --git a/samples/layouts/layouts.ico b/examples/layouts/layouts.ico similarity index 100% rename from samples/layouts/layouts.ico rename to examples/layouts/layouts.ico diff --git a/samples/layouts/layouts.rc b/examples/layouts/layouts.rc similarity index 100% rename from samples/layouts/layouts.rc rename to examples/layouts/layouts.rc diff --git a/samples/layouts/layouts.vcxproj b/examples/layouts/layouts.vcxproj similarity index 94% rename from samples/layouts/layouts.vcxproj rename to examples/layouts/layouts.vcxproj index c4e738f2..09e6bd26 100644 --- a/samples/layouts/layouts.vcxproj +++ b/examples/layouts/layouts.vcxproj @@ -1,4 +1,4 @@ - + @@ -75,7 +75,7 @@ $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ $(ProjectName)_d ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) @@ -83,21 +83,21 @@ $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ $(ProjectName)64_d ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) false $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) false $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) $(ProjectName)64 @@ -194,15 +194,12 @@ - + {8d9a6595-717a-41c8-b468-0011a72be3d1} - + {e106acd7-4e53-4aee-942b-d0dd426db34e} - - {9951345f-620b-4bed-bb51-4f928cafd454} - diff --git a/samples/layouts/layouts.vcxproj.filters b/examples/layouts/layouts.vcxproj.filters similarity index 100% rename from samples/layouts/layouts.vcxproj.filters rename to examples/layouts/layouts.vcxproj.filters diff --git a/samples/layouts/layouts_form.cpp b/examples/layouts/layouts_form.cpp similarity index 100% rename from samples/layouts/layouts_form.cpp rename to examples/layouts/layouts_form.cpp diff --git a/samples/layouts/layouts_form.h b/examples/layouts/layouts_form.h similarity index 100% rename from samples/layouts/layouts_form.h rename to examples/layouts/layouts_form.h diff --git a/samples/layouts/main.cpp b/examples/layouts/main.cpp similarity index 91% rename from samples/layouts/main.cpp rename to examples/layouts/main.cpp index 806a015f..d4e08fa4 100644 --- a/samples/layouts/main.cpp +++ b/examples/layouts/main.cpp @@ -24,13 +24,13 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, void MainThread::Init() { - nbase::ThreadManager::RegisterThread(kThreadUI); + nbase::ThreadManager::RegisterThread(kThreadMain); // 获取资源路径,初始化全局参数 // 默认皮肤使用 resources\\themes\\default // 默认语言使用 resources\\lang\\zh_CN // 如需修改请指定 Startup 最后两个参数 - std::wstring theme_dir = QPath::GetAppPath(); + std::wstring theme_dir = nbase::win32::GetCurrentModuleDirectory(); ui::GlobalManager::Startup(theme_dir + L"resources\\", ui::CreateControlCallback(), false); // 一个仿微信的布局示例 diff --git a/samples/layouts/main.h b/examples/layouts/main.h similarity index 100% rename from samples/layouts/main.h rename to examples/layouts/main.h diff --git a/samples/layouts/resource.h b/examples/layouts/resource.h similarity index 100% rename from samples/layouts/resource.h rename to examples/layouts/resource.h diff --git a/samples/layouts/small.ico b/examples/layouts/small.ico similarity index 100% rename from samples/layouts/small.ico rename to examples/layouts/small.ico diff --git a/samples/layouts/stdafx.cpp b/examples/layouts/stdafx.cpp similarity index 100% rename from samples/layouts/stdafx.cpp rename to examples/layouts/stdafx.cpp diff --git a/samples/basic/stdafx.h b/examples/layouts/stdafx.h similarity index 88% rename from samples/basic/stdafx.h rename to examples/layouts/stdafx.h index 9fae117e..95611366 100644 --- a/samples/basic/stdafx.h +++ b/examples/layouts/stdafx.h @@ -16,8 +16,5 @@ // base header #include "base/base.h" -// shared project -#include "shared/shared.h" - // duilib #include "duilib/UIlib.h" diff --git a/samples/layouts/targetver.h b/examples/layouts/targetver.h similarity index 100% rename from samples/layouts/targetver.h rename to examples/layouts/targetver.h diff --git a/samples/multi_browser/Resource.h b/examples/multi_browser/Resource.h similarity index 100% rename from samples/multi_browser/Resource.h rename to examples/multi_browser/Resource.h diff --git a/samples/multi_browser/browser/browser_box.cpp b/examples/multi_browser/browser/browser_box.cpp similarity index 97% rename from samples/multi_browser/browser/browser_box.cpp rename to examples/multi_browser/browser/browser_box.cpp index ef1cd5c7..234d36fd 100644 --- a/samples/multi_browser/browser/browser_box.cpp +++ b/examples/multi_browser/browser/browser_box.cpp @@ -48,7 +48,7 @@ void BrowserBox::InitBrowserBox(const std::wstring &url) // Ĭҳ std::wstring html_path = url; if (html_path.empty()) - html_path = QPath::GetAppPath() + L"resources\\themes\\default\\cef\\cef.html"; + html_path = nbase::win32::GetCurrentModuleDirectory() + L"resources\\themes\\default\\cef\\cef.html"; cef_control_->LoadURL(html_path); diff --git a/samples/multi_browser/browser/browser_box.h b/examples/multi_browser/browser/browser_box.h similarity index 100% rename from samples/multi_browser/browser/browser_box.h rename to examples/multi_browser/browser/browser_box.h diff --git a/samples/multi_browser/browser/custom_layout.cpp b/examples/multi_browser/browser/custom_layout.cpp similarity index 100% rename from samples/multi_browser/browser/custom_layout.cpp rename to examples/multi_browser/browser/custom_layout.cpp diff --git a/samples/multi_browser/browser/custom_layout.h b/examples/multi_browser/browser/custom_layout.h similarity index 100% rename from samples/multi_browser/browser/custom_layout.h rename to examples/multi_browser/browser/custom_layout.h diff --git a/samples/multi_browser/browser/multi_browser_form.cpp b/examples/multi_browser/browser/multi_browser_form.cpp similarity index 96% rename from samples/multi_browser/browser/multi_browser_form.cpp rename to examples/multi_browser/browser/multi_browser_form.cpp index 54aaf5df..e7aa0b92 100644 --- a/samples/multi_browser/browser/multi_browser_form.cpp +++ b/examples/multi_browser/browser/multi_browser_form.cpp @@ -249,7 +249,9 @@ bool MultiBrowserForm::OnClicked( ui::EventArgs* arg ) } else if (name == L"btn_add") { - MultiBrowserManager::GetInstance()->CreateBorwserBox(this, shared::tools::GenerateTimeStamp(), L""); + nbase::TimeDelta time_delta = nbase::TimeDelta::FromMicroseconds(nbase::Time::Now().ToInternalValue()); + std::string timeStamp = nbase::StringPrintf("%I64u", time_delta.ToMilliseconds()); + MultiBrowserManager::GetInstance()->CreateBorwserBox(this, timeStamp, L""); } else if (active_browser_box_) { @@ -279,12 +281,16 @@ bool MultiBrowserForm::OnReturn(ui::EventArgs* arg) std::wstring name = arg->pSender->GetName(); if (name == L"edit_url") { -// // ڵǰҳת -// auto cef_control = active_browser_box_->GetCefControl(); -// if (cef_control) -// cef_control->LoadURL(edit_url_->GetText()); +#if 0 + // ڵǰҳת + auto cef_control = active_browser_box_->GetCefControl(); + if (cef_control) + cef_control->LoadURL(edit_url_->GetText()); +#endif + nbase::TimeDelta time_delta = nbase::TimeDelta::FromMicroseconds(nbase::Time::Now().ToInternalValue()); + std::string timeStamp = nbase::StringPrintf("%I64u", time_delta.ToMilliseconds()); // ½ǩҳ - MultiBrowserManager::GetInstance()->CreateBorwserBox(this, shared::tools::GenerateTimeStamp(), edit_url_->GetText()); + MultiBrowserManager::GetInstance()->CreateBorwserBox(this, timeStamp, edit_url_->GetText()); } return false; diff --git a/samples/multi_browser/browser/multi_browser_form.h b/examples/multi_browser/browser/multi_browser_form.h similarity index 100% rename from samples/multi_browser/browser/multi_browser_form.h rename to examples/multi_browser/browser/multi_browser_form.h diff --git a/samples/multi_browser/browser/multi_browser_form_dragdrop.cpp b/examples/multi_browser/browser/multi_browser_form_dragdrop.cpp similarity index 92% rename from samples/multi_browser/browser/multi_browser_form_dragdrop.cpp rename to examples/multi_browser/browser/multi_browser_form_dragdrop.cpp index bc6d6332..6c8fb66d 100644 --- a/samples/multi_browser/browser/multi_browser_form_dragdrop.cpp +++ b/examples/multi_browser/browser/multi_browser_form_dragdrop.cpp @@ -23,17 +23,14 @@ bool MultiBrowserForm::InitDragDrop() IID_IDropTargetHelper, (void**)&drop_helper_))) { - QLOG_ERR(L"MultiBrowserForm::InitDragDrop Create CLSID_DragDropHelper faild"); return false; } if (FAILED(RegisterDragDrop(this->GetHWND(), this))) { - QLOG_ERR(L"MultiBrowserForm::InitDragDrop RegisterDragDrop faild"); return false; } - QLOG_APP(L"MultiBrowserForm::InitDragDrop succeed"); return true; } @@ -85,7 +82,6 @@ HRESULT MultiBrowserForm::DragEnter(IDataObject * pDataObject, DWORD grfKeyState } else { - QLOG_APP(L"MultiBrowserForm::Drop receive a BrowserBox"); *pdwEffect = DROPEFFECT_MOVE; } @@ -138,14 +134,15 @@ HRESULT MultiBrowserForm::Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL // 如果不是拖拽浏览器盒子 if (!MultiBrowserManager::GetInstance()->IsDragingBorwserBox()) { -// if (NULL != active_browser_box_ && active_browser_box_->CheckDropEnable(pt)) -// { -// /ctive_browser_box_->Drop(pDataObj, grfKeyState, pt, pdwEffect); -// } +#if 0 + if (NULL != active_browser_box_ && active_browser_box_->CheckDropEnable(pt)) + { + active_browser_box_->Drop(pDataObj, grfKeyState, pt, pdwEffect); + } +#endif } else { - QLOG_APP(L"MultiBrowserForm::Drop drop a BrowserBox"); *pdwEffect = DROPEFFECT_MOVE; MultiBrowserManager::GetInstance()->SetDropForm(this); } @@ -189,7 +186,7 @@ bool MultiBrowserForm::OnProcessTabItemDrag(ui::EventArgs* param) StdClosure cb = [=]{ MultiBrowserManager::GetInstance()->DoDragBorwserBox(active_browser_box_, bitmap, pt); }; - nbase::ThreadManager::PostTask(kThreadUI, cb); + nbase::ThreadManager::PostTask(kThreadMain, cb); } } break; diff --git a/samples/multi_browser/browser/multi_browser_manager.cpp b/examples/multi_browser/browser/multi_browser_manager.cpp similarity index 100% rename from samples/multi_browser/browser/multi_browser_manager.cpp rename to examples/multi_browser/browser/multi_browser_manager.cpp diff --git a/samples/multi_browser/browser/multi_browser_manager.h b/examples/multi_browser/browser/multi_browser_manager.h similarity index 100% rename from samples/multi_browser/browser/multi_browser_manager.h rename to examples/multi_browser/browser/multi_browser_manager.h diff --git a/samples/multi_browser/control/browser_tab_item.cpp b/examples/multi_browser/control/browser_tab_item.cpp similarity index 100% rename from samples/multi_browser/control/browser_tab_item.cpp rename to examples/multi_browser/control/browser_tab_item.cpp diff --git a/samples/multi_browser/control/browser_tab_item.h b/examples/multi_browser/control/browser_tab_item.h similarity index 100% rename from samples/multi_browser/control/browser_tab_item.h rename to examples/multi_browser/control/browser_tab_item.h diff --git a/samples/multi_browser/dragdrop/bitmap_control.cpp b/examples/multi_browser/dragdrop/bitmap_control.cpp similarity index 100% rename from samples/multi_browser/dragdrop/bitmap_control.cpp rename to examples/multi_browser/dragdrop/bitmap_control.cpp diff --git a/samples/multi_browser/dragdrop/bitmap_control.h b/examples/multi_browser/dragdrop/bitmap_control.h similarity index 100% rename from samples/multi_browser/dragdrop/bitmap_control.h rename to examples/multi_browser/dragdrop/bitmap_control.h diff --git a/samples/multi_browser/dragdrop/drag_drop.cpp b/examples/multi_browser/dragdrop/drag_drop.cpp similarity index 100% rename from samples/multi_browser/dragdrop/drag_drop.cpp rename to examples/multi_browser/dragdrop/drag_drop.cpp diff --git a/samples/multi_browser/dragdrop/drag_drop.h b/examples/multi_browser/dragdrop/drag_drop.h similarity index 100% rename from samples/multi_browser/dragdrop/drag_drop.h rename to examples/multi_browser/dragdrop/drag_drop.h diff --git a/samples/multi_browser/dragdrop/drag_form.cpp b/examples/multi_browser/dragdrop/drag_form.cpp similarity index 100% rename from samples/multi_browser/dragdrop/drag_form.cpp rename to examples/multi_browser/dragdrop/drag_form.cpp diff --git a/samples/multi_browser/dragdrop/drag_form.h b/examples/multi_browser/dragdrop/drag_form.h similarity index 100% rename from samples/multi_browser/dragdrop/drag_form.h rename to examples/multi_browser/dragdrop/drag_form.h diff --git a/samples/multi_browser/main.cpp b/examples/multi_browser/main.cpp similarity index 74% rename from samples/multi_browser/main.cpp rename to examples/multi_browser/main.cpp index 1b0dc600..86003e91 100644 --- a/samples/multi_browser/main.cpp +++ b/examples/multi_browser/main.cpp @@ -34,7 +34,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, // 初始化 CEF CefSettings settings; - if (!nim_cef::CefManager::GetInstance()->Initialize(QPath::GetAppPath() + L"cef_temp\\", settings, true)) + if (!nim_cef::CefManager::GetInstance()->Initialize(nbase::win32::GetCurrentModuleDirectory() + L"cef_temp\\", settings, true)) { return 0; } @@ -55,12 +55,14 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, void MainThread::Init() { - nbase::ThreadManager::RegisterThread(kThreadUI); + nbase::ThreadManager::RegisterThread(kThreadMain); - std::wstring theme_dir = QPath::GetAppPath(); + std::wstring theme_dir = nbase::win32::GetCurrentModuleDirectory(); ui::GlobalManager::Startup(theme_dir + L"resources\\", ui::CreateControlCallback(), false); - MultiBrowserManager::GetInstance()->CreateBorwserBox(NULL, shared::tools::GenerateTimeStamp(), L""); + nbase::TimeDelta time_delta = nbase::TimeDelta::FromMicroseconds(nbase::Time::Now().ToInternalValue()); + std::string timeStamp = nbase::StringPrintf("%I64u", time_delta.ToMilliseconds()); + MultiBrowserManager::GetInstance()->CreateBorwserBox(NULL, timeStamp, L""); } void MainThread::Cleanup() diff --git a/samples/multi_browser/main.h b/examples/multi_browser/main.h similarity index 100% rename from samples/multi_browser/main.h rename to examples/multi_browser/main.h diff --git a/samples/multi_browser/multi_browser.ico b/examples/multi_browser/multi_browser.ico similarity index 100% rename from samples/multi_browser/multi_browser.ico rename to examples/multi_browser/multi_browser.ico diff --git a/samples/multi_browser/multi_browser.rc b/examples/multi_browser/multi_browser.rc similarity index 100% rename from samples/multi_browser/multi_browser.rc rename to examples/multi_browser/multi_browser.rc diff --git a/samples/multi_browser/multi_browser.vcxproj b/examples/multi_browser/multi_browser.vcxproj similarity index 90% rename from samples/multi_browser/multi_browser.vcxproj rename to examples/multi_browser/multi_browser.vcxproj index 450fdedc..71731080 100644 --- a/samples/multi_browser/multi_browser.vcxproj +++ b/examples/multi_browser/multi_browser.vcxproj @@ -59,12 +59,12 @@ ..\..\bin\ $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ $(ProjectName)_d - .\;..\;..\..\;..\..\tool_kits\;..\..\tool_kits\ui_components\;..\..\third_party\cef_wrapper\;$(IncludePath) + .\;..\;..\..\;..\..\third_party\cef_wrapper\;$(IncludePath) ..\..\libs\;$(LibraryPath) false - .\;..\;..\..\;..\..\tool_kits\;..\..\tool_kits\ui_components\;..\..\third_party\cef_wrapper\;$(IncludePath) + .\;..\;..\..\;..\..\third_party\cef_wrapper\;$(IncludePath) ..\..\libs\;$(LibraryPath) ..\..\bin\ $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ @@ -73,11 +73,11 @@ ..\..\bin\ $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ $(ProjectName)64_d - .\;..\;..\..\;..\..\tool_kits\;..\..\tool_kits\ui_components\;..\..\third_party\cef_wrapper\;$(IncludePath) + .\;..\;..\..\;..\..\third_party\cef_wrapper\;$(IncludePath) ..\..\libs\x64\;$(LibraryPath) - .\;..\;..\..\;..\..\tool_kits\;..\..\tool_kits\ui_components\;..\..\third_party\cef_wrapper\;$(IncludePath) + .\;..\;..\..\;..\..\third_party\cef_wrapper\;$(IncludePath) ..\..\libs\x64\;$(LibraryPath) ..\..\bin\ $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ @@ -180,16 +180,13 @@ - + {8d9a6595-717a-41c8-b468-0011a72be3d1} - + {e106acd7-4e53-4aee-942b-d0dd426db34e} - - {9951345f-620b-4bed-bb51-4f928cafd454} - - + {0149ba6e-3c0a-426d-aa0a-0b9ec7742f19} diff --git a/samples/multi_browser/multi_browser.vcxproj.filters b/examples/multi_browser/multi_browser.vcxproj.filters similarity index 100% rename from samples/multi_browser/multi_browser.vcxproj.filters rename to examples/multi_browser/multi_browser.vcxproj.filters diff --git a/samples/multi_browser/small.ico b/examples/multi_browser/small.ico similarity index 100% rename from samples/multi_browser/small.ico rename to examples/multi_browser/small.ico diff --git a/samples/multi_browser/stdafx.cpp b/examples/multi_browser/stdafx.cpp similarity index 100% rename from samples/multi_browser/stdafx.cpp rename to examples/multi_browser/stdafx.cpp diff --git a/samples/multi_browser/stdafx.h b/examples/multi_browser/stdafx.h similarity index 89% rename from samples/multi_browser/stdafx.h rename to examples/multi_browser/stdafx.h index 014638e1..4afaa671 100644 --- a/samples/multi_browser/stdafx.h +++ b/examples/multi_browser/stdafx.h @@ -16,9 +16,6 @@ // base header #include "base/base.h" -// shared project -#include "shared/shared.h" - // duilib #include "duilib/UIlib.h" diff --git a/samples/multi_browser/targetver.h b/examples/multi_browser/targetver.h similarity index 100% rename from samples/multi_browser/targetver.h rename to examples/multi_browser/targetver.h diff --git a/samples/multi_browser/taskbar/dwm_util.cpp b/examples/multi_browser/taskbar/dwm_util.cpp similarity index 100% rename from samples/multi_browser/taskbar/dwm_util.cpp rename to examples/multi_browser/taskbar/dwm_util.cpp diff --git a/samples/multi_browser/taskbar/dwm_util.h b/examples/multi_browser/taskbar/dwm_util.h similarity index 100% rename from samples/multi_browser/taskbar/dwm_util.h rename to examples/multi_browser/taskbar/dwm_util.h diff --git a/samples/multi_browser/taskbar/taskbar_manager.cpp b/examples/multi_browser/taskbar/taskbar_manager.cpp similarity index 99% rename from samples/multi_browser/taskbar/taskbar_manager.cpp rename to examples/multi_browser/taskbar/taskbar_manager.cpp index ab00cb45..a0280bf5 100644 --- a/samples/multi_browser/taskbar/taskbar_manager.cpp +++ b/examples/multi_browser/taskbar/taskbar_manager.cpp @@ -37,7 +37,6 @@ void TaskbarTabItem::Init(const std::wstring &taskbar_title, const std::string & if (ret != S_OK) { is_win7_or_greater_ = false; - QLOG_ERR(L"DwmSetWindowAttribute error: {0}") << ret; } } diff --git a/samples/multi_browser/taskbar/taskbar_manager.h b/examples/multi_browser/taskbar/taskbar_manager.h similarity index 100% rename from samples/multi_browser/taskbar/taskbar_manager.h rename to examples/multi_browser/taskbar/taskbar_manager.h diff --git a/samples/richlist/item.cpp b/examples/richlist/item.cpp similarity index 80% rename from samples/richlist/item.cpp rename to examples/richlist/item.cpp index 9072186b..ee50c78c 100644 --- a/samples/richlist/item.cpp +++ b/examples/richlist/item.cpp @@ -20,14 +20,12 @@ void Item::InitSubControls(const std::wstring& img, const std::wstring& title) btn_del_ = dynamic_cast(FindSubControl(L"btn_del")); // ģ - auto timestamp = shared::tools::GenerateTimeStamp(); - int64_t timestamp_num = 0; - nbase::StringToInt64(timestamp, ×tamp_num); - progress_->SetValue((double)(timestamp_num % 100)); + nbase::TimeDelta time_delta = nbase::TimeDelta::FromMicroseconds(nbase::Time::Now().ToInternalValue()); + progress_->SetValue((double)(time_delta.ToMilliseconds() % 100)); // ͼ control_img_->SetBkImage(img); - label_title_->SetText(nbase::StringPrintf(L"%s %d%%", title.c_str(), timestamp_num % 100)); + label_title_->SetText(nbase::StringPrintf(L"%s %d%%", title.c_str(), time_delta.ToMilliseconds() % 100)); // ɾ btn_del_->AttachClick(nbase::Bind(&Item::OnRemove, this, std::placeholders::_1)); diff --git a/samples/richlist/item.h b/examples/richlist/item.h similarity index 100% rename from samples/richlist/item.h rename to examples/richlist/item.h diff --git a/samples/richlist/main.cpp b/examples/richlist/main.cpp similarity index 90% rename from samples/richlist/main.cpp rename to examples/richlist/main.cpp index 2de54cd6..4ffa5464 100644 --- a/samples/richlist/main.cpp +++ b/examples/richlist/main.cpp @@ -24,10 +24,10 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, void MainThread::Init() { - nbase::ThreadManager::RegisterThread(kThreadUI); + nbase::ThreadManager::RegisterThread(kThreadMain); // 获取资源路径,初始化全局参数 - std::wstring theme_dir = QPath::GetAppPath(); + std::wstring theme_dir = nbase::win32::GetCurrentModuleDirectory(); ui::GlobalManager::Startup(theme_dir + L"resources\\", ui::CreateControlCallback(), false); // 创建一个默认带有阴影的居中窗口 diff --git a/samples/richlist/main.h b/examples/richlist/main.h similarity index 100% rename from samples/richlist/main.h rename to examples/richlist/main.h diff --git a/samples/richlist/resource.h b/examples/richlist/resource.h similarity index 100% rename from samples/richlist/resource.h rename to examples/richlist/resource.h diff --git a/samples/richlist/richlist.ico b/examples/richlist/richlist.ico similarity index 100% rename from samples/richlist/richlist.ico rename to examples/richlist/richlist.ico diff --git a/samples/richlist/richlist.rc b/examples/richlist/richlist.rc similarity index 100% rename from samples/richlist/richlist.rc rename to examples/richlist/richlist.rc diff --git a/samples/richlist/richlist.vcxproj b/examples/richlist/richlist.vcxproj similarity index 93% rename from samples/richlist/richlist.vcxproj rename to examples/richlist/richlist.vcxproj index 21dd5e21..176fa5f7 100644 --- a/samples/richlist/richlist.vcxproj +++ b/examples/richlist/richlist.vcxproj @@ -75,7 +75,7 @@ $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ $(ProjectName)_d ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) @@ -83,21 +83,21 @@ $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ $(ProjectName)64_d ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) false $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) false $(ProjectDir)..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ ..\..\bin\ - ..\..\tool_kits\;$(IncludePath) + ..\..\;$(IncludePath) $(LibraryPath) $(ProjectName)64 @@ -196,16 +196,13 @@ - + {8d9a6595-717a-41c8-b468-0011a72be3d1} - + {e106acd7-4e53-4aee-942b-d0dd426db34e} - - {9951345f-620b-4bed-bb51-4f928cafd454} - - + {0149ba6e-3c0a-426d-aa0a-0b9ec7742f19} diff --git a/samples/richlist/richlist.vcxproj.filters b/examples/richlist/richlist.vcxproj.filters similarity index 100% rename from samples/richlist/richlist.vcxproj.filters rename to examples/richlist/richlist.vcxproj.filters diff --git a/samples/richlist/richlist_form.cpp b/examples/richlist/richlist_form.cpp similarity index 100% rename from samples/richlist/richlist_form.cpp rename to examples/richlist/richlist_form.cpp diff --git a/samples/richlist/richlist_form.h b/examples/richlist/richlist_form.h similarity index 100% rename from samples/richlist/richlist_form.h rename to examples/richlist/richlist_form.h diff --git a/samples/richlist/small.ico b/examples/richlist/small.ico similarity index 100% rename from samples/richlist/small.ico rename to examples/richlist/small.ico diff --git a/samples/richlist/stdafx.cpp b/examples/richlist/stdafx.cpp similarity index 100% rename from samples/richlist/stdafx.cpp rename to examples/richlist/stdafx.cpp diff --git a/samples/richlist/stdafx.h b/examples/richlist/stdafx.h similarity index 89% rename from samples/richlist/stdafx.h rename to examples/richlist/stdafx.h index d15652aa..337ee2a2 100644 --- a/samples/richlist/stdafx.h +++ b/examples/richlist/stdafx.h @@ -16,9 +16,6 @@ // base header #include "base/base.h" -// shared project -#include "shared/shared.h" - // duilib #include "duilib/UIlib.h" diff --git a/samples/richlist/targetver.h b/examples/richlist/targetver.h similarity index 100% rename from samples/richlist/targetver.h rename to examples/richlist/targetver.h diff --git a/samples/virtualbox/Resource.h b/examples/virtualbox/Resource.h similarity index 100% rename from samples/virtualbox/Resource.h rename to examples/virtualbox/Resource.h diff --git a/samples/virtualbox/VirtualTileBox.cpp b/examples/virtualbox/VirtualTileBox.cpp similarity index 100% rename from samples/virtualbox/VirtualTileBox.cpp rename to examples/virtualbox/VirtualTileBox.cpp diff --git a/samples/virtualbox/VirtualTileBox.h b/examples/virtualbox/VirtualTileBox.h similarity index 97% rename from samples/virtualbox/VirtualTileBox.h rename to examples/virtualbox/VirtualTileBox.h index ecd8913f..6566e35b 100644 --- a/samples/virtualbox/VirtualTileBox.h +++ b/examples/virtualbox/VirtualTileBox.h @@ -1,7 +1,7 @@ #pragma once -typedef function DataChangedNotify; -typedef function CountChangedNotify; +typedef std::function DataChangedNotify; +typedef std::function CountChangedNotify; class UILIB_API VirtualTileInterface: public nbase::SupportWeakCallback { diff --git a/samples/virtualbox/item.cpp b/examples/virtualbox/item.cpp similarity index 84% rename from samples/virtualbox/item.cpp rename to examples/virtualbox/item.cpp index 8af32a0e..d9dff7a3 100644 --- a/samples/virtualbox/item.cpp +++ b/examples/virtualbox/item.cpp @@ -22,11 +22,9 @@ void Item::InitSubControls(const std::wstring& img, const std::wstring& title, i progress_ = dynamic_cast(FindSubControl(L"progress")); btn_del_ = dynamic_cast(FindSubControl(L"btn_del")); // ģ - auto timestamp = shared::tools::GenerateTimeStamp(); - int64_t timestamp_num = 0; - nbase::StringToInt64(timestamp, ×tamp_num); - t_time = timestamp_num; - progress_->SetValue((double)(timestamp_num % 100)); + nbase::TimeDelta time_delta = nbase::TimeDelta::FromMicroseconds(nbase::Time::Now().ToInternalValue()); + t_time = time_delta.ToMilliseconds(); + progress_->SetValue((double)(time_delta.ToMilliseconds() % 100)); // ͼ control_img_->SetBkImage(img); // ɾ diff --git a/samples/virtualbox/item.h b/examples/virtualbox/item.h similarity index 100% rename from samples/virtualbox/item.h rename to examples/virtualbox/item.h diff --git a/samples/virtualbox/main.cpp b/examples/virtualbox/main.cpp similarity index 90% rename from samples/virtualbox/main.cpp rename to examples/virtualbox/main.cpp index d316f2e8..4f9993b0 100644 --- a/samples/virtualbox/main.cpp +++ b/examples/virtualbox/main.cpp @@ -34,10 +34,10 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, void MainThread::Init() { - nbase::ThreadManager::RegisterThread(kThreadUI); + nbase::ThreadManager::RegisterThread(kThreadMain); // ȡԴ·ʼȫֲ - std::wstring theme_dir = QPath::GetAppPath(); + std::wstring theme_dir = nbase::win32::GetCurrentModuleDirectory(); ui::GlobalManager::Startup(theme_dir + L"resources\\", MyCreateControlCallback, false); // һĬϴӰľд diff --git a/samples/virtualbox/main.h b/examples/virtualbox/main.h similarity index 100% rename from samples/virtualbox/main.h rename to examples/virtualbox/main.h diff --git a/samples/virtualbox/main_form.cpp b/examples/virtualbox/main_form.cpp similarity index 100% rename from samples/virtualbox/main_form.cpp rename to examples/virtualbox/main_form.cpp diff --git a/samples/virtualbox/main_form.h b/examples/virtualbox/main_form.h similarity index 100% rename from samples/virtualbox/main_form.h rename to examples/virtualbox/main_form.h diff --git a/samples/virtualbox/provider.cpp b/examples/virtualbox/provider.cpp similarity index 91% rename from samples/virtualbox/provider.cpp rename to examples/virtualbox/provider.cpp index ea40c1b2..b60a734b 100644 --- a/samples/virtualbox/provider.cpp +++ b/examples/virtualbox/provider.cpp @@ -74,9 +74,9 @@ void Provider::RemoveTask(int nIndex) EmitCountChanged(); } -void Provider::ChangeTaskName(int nIndex, const wstring& sName) +void Provider::ChangeTaskName(int nIndex, const std::wstring& sName) { - if (nIndex > 0 && nIndex < m_vTasks.size()) + if (nIndex > 0 && nIndex < (int)m_vTasks.size()) { m_vTasks[nIndex].sName = sName; } diff --git a/samples/virtualbox/provider.h b/examples/virtualbox/provider.h similarity index 89% rename from samples/virtualbox/provider.h rename to examples/virtualbox/provider.h index 5fdb8b60..f18205e9 100644 --- a/samples/virtualbox/provider.h +++ b/examples/virtualbox/provider.h @@ -6,7 +6,7 @@ struct DownloadTask { int nId; - wstring sName; + std::wstring sName; }; class Provider : public VirtualTileInterface @@ -34,7 +34,7 @@ class Provider : public VirtualTileInterface public: void SetTotal(int nTotal); void RemoveTask(int nIndex); - void ChangeTaskName(int nIndex, const wstring& sName); + void ChangeTaskName(int nIndex, const std::wstring& sName); private: int m_nTotal; diff --git a/samples/virtualbox/small.ico b/examples/virtualbox/small.ico similarity index 100% rename from samples/virtualbox/small.ico rename to examples/virtualbox/small.ico diff --git a/samples/virtualbox/stdafx.cpp b/examples/virtualbox/stdafx.cpp similarity index 100% rename from samples/virtualbox/stdafx.cpp rename to examples/virtualbox/stdafx.cpp diff --git a/samples/virtualbox/stdafx.h b/examples/virtualbox/stdafx.h similarity index 90% rename from samples/virtualbox/stdafx.h rename to examples/virtualbox/stdafx.h index e0159f3f..35e2d627 100644 --- a/samples/virtualbox/stdafx.h +++ b/examples/virtualbox/stdafx.h @@ -16,15 +16,11 @@ #include #include #include - - +#include // base header #include "base/base.h" -// shared project -#include "shared/shared.h" - // duilib #include "duilib/UIlib.h" diff --git a/samples/virtualbox/targetver.h b/examples/virtualbox/targetver.h similarity index 100% rename from samples/virtualbox/targetver.h rename to examples/virtualbox/targetver.h diff --git a/samples/virtualbox/virtualbox.filters b/examples/virtualbox/virtualbox.filters similarity index 100% rename from samples/virtualbox/virtualbox.filters rename to examples/virtualbox/virtualbox.filters diff --git a/samples/virtualbox/virtualbox.ico b/examples/virtualbox/virtualbox.ico similarity index 100% rename from samples/virtualbox/virtualbox.ico rename to examples/virtualbox/virtualbox.ico diff --git a/samples/virtualbox/virtualbox.rc b/examples/virtualbox/virtualbox.rc similarity index 100% rename from samples/virtualbox/virtualbox.rc rename to examples/virtualbox/virtualbox.rc diff --git a/samples/virtualbox/virtualbox.vcxproj b/examples/virtualbox/virtualbox.vcxproj similarity index 92% rename from samples/virtualbox/virtualbox.vcxproj rename to examples/virtualbox/virtualbox.vcxproj index 688aa885..0fbb98c1 100644 --- a/samples/virtualbox/virtualbox.vcxproj +++ b/examples/virtualbox/virtualbox.vcxproj @@ -59,7 +59,7 @@ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true MultiThreadedDebug - ..\..\tool_kits\; + ..\..\ Windows @@ -76,7 +76,7 @@ WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true MultiThreaded - ..\..\tool_kits\; + ..\..\ Windows @@ -114,15 +114,12 @@ - + {8d9a6595-717a-41c8-b468-0011a72be3d1} - + {e106acd7-4e53-4aee-942b-d0dd426db34e} - - {9951345f-620b-4bed-bb51-4f928cafd454} - diff --git a/tool_kits/shared/base.h b/tool_kits/shared/base.h deleted file mode 100644 index cf63ddde..00000000 --- a/tool_kits/shared/base.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include "log.h" -#include "closure.h" -#include "zoom_image.h" \ No newline at end of file diff --git a/tool_kits/shared/closure.cpp b/tool_kits/shared/closure.cpp deleted file mode 100644 index d0fa3ca4..00000000 --- a/tool_kits/shared/closure.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "stdafx.h" -#include "closure.h" -#include "shared/threads.h" -#include "base/thread/thread_manager.h" - -void Post2UI(const StdClosure &closure) -{ - nbase::ThreadManager::PostTask(kThreadUI, closure); -} - -void Post2GlobalMisc(const StdClosure &closure) -{ - nbase::ThreadManager::PostTask(kThreadGlobalMisc, closure); -} - -void Post2Database(const StdClosure &closure) -{ - nbase::ThreadManager::PostTask(kThreadDatabase, closure); -} diff --git a/tool_kits/shared/closure.h b/tool_kits/shared/closure.h deleted file mode 100644 index 38eaf562..00000000 --- a/tool_kits/shared/closure.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -//#include "util.h" -#include "base/callback/callback.h" - -//ͶUI߳ -void Post2UI(const StdClosure &closure); - -//ͶȫMisc߳ -void Post2GlobalMisc(const StdClosure &closure); - -//ͶDB߳ -void Post2Database(const StdClosure &closure); \ No newline at end of file diff --git a/tool_kits/shared/cmd_line.cpp b/tool_kits/shared/cmd_line.cpp deleted file mode 100644 index 887ded7e..00000000 --- a/tool_kits/shared/cmd_line.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "stdafx.h" -#include "cmd_line.h" -#include "base/util/string_util.h" - -namespace shared -{ -CommandLine::CommandLine(const std::wstring &cmd) : cmd_(cmd) -{ - Parse(cmd_, map_); -} - -CommandLine::~CommandLine() -{ - -} - -bool CommandLine::Parse(const std::wstring &cmd, std::map ¶m_map) -{ - std::list param_list; - if (nbase::StringTokenize(cmd, L"/", param_list) == 0) - return false; - - std::wstring token, key, value; - size_t pos; - for (std::list::iterator it = param_list.begin(); it != param_list.end(); ++it) - { - token = *it; - key = L""; - value = L""; - pos = token.find(L' ', 0); - if (pos < 0 || pos >= token.size()) - pos = token.size(); - key = token.substr(0, pos); - if (pos < token.size()) - { - value = token.substr(pos, token.size() - pos); - value = nbase::StringTrim(value.c_str()); - if (value.size() >= 2 && value[0] == '"' && value[value.size()-1] == '"') - { - std::wstring str = value.substr(1, value.size() - 2); - value = str; - } - } - param_map[key] = value; - } - - return true; -} - -bool CommandLine::Get(const std::wstring &key, std::wstring &value) -{ - value = L""; - if (map_.size() == 0) - return false; - - std::map::iterator it = map_.find(key); - if (it == map_.end()) - return false; - - value = it->second; - - return true; -} - -std::map CommandLine::GetMap(void) -{ - return map_; -} - -bool CommandLine::IsExist(const std::wstring &key) -{ - return (map_.find(key) != map_.end()); -} -}//namespace shared \ No newline at end of file diff --git a/tool_kits/shared/cmd_line.h b/tool_kits/shared/cmd_line.h deleted file mode 100644 index 0f2bd9f0..00000000 --- a/tool_kits/shared/cmd_line.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef SHARED_CMD_LINE_H_ -#define SHARED_CMD_LINE_H_ - -#include -#include - -namespace shared -{ -class CommandLine -{ -public: - CommandLine(const std::wstring &cmd); - ~CommandLine(); - - bool Get(const std::wstring &key, std::wstring &value); - bool IsExist(const std::wstring &key); - std::map GetMap(void); - -protected: - // 򵥽cmd'/'ָ'/' - static bool Parse(const std::wstring &cmd, std::map ¶m_map); - -protected: - std::wstring cmd_; - std::map map_; -}; -}//namespace shared - -#endif //SHARED_CMD_LINE_H_ diff --git a/tool_kits/shared/db_helper.cpp b/tool_kits/shared/db_helper.cpp deleted file mode 100644 index b9694dbc..00000000 --- a/tool_kits/shared/db_helper.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "stdafx.h" -#include "shared/db_helper.h" -#include "shared/utf8_file_util.h" -#include "base/util/string_util.h" -namespace shared -{ - - bool NimDBPretreatment::FilePathIsExist(const std::string& file_path, bool is_directory) - { - return shared::FilePathIsExist(file_path, is_directory); - } - bool NimDBPretreatment::DeleteFile(const std::string& file_path) - { - return shared::DeleteFile(file_path) && (GetLastError() == 0); - } - bool NimDBPretreatment::CopyFile(const std::string &from_path, const std::string &to_path, bool fail_if_exists) - { - return shared::CopyFile(from_path, to_path) && (GetLastError() == 0); - } - bool NimDBPretreatment::CreateDir(const std::string& dir_path) - { - return shared::CreateDirectory(dir_path); - } - bool NimDBPretreatment::GetDirFromPath(const std::string& file_path, std::string& dir) - { - return shared::FilePathApartDirectory(file_path, dir); - } - bool NimDBPretreatment::GetFileNameFromPath(const std::string& file_path, std::string& name, std::string& ext) - { - std::string file_name; - if (!shared::FilePathApartFileName(file_path, name)) - return false; - if (name.empty()) - return false; - shared::FilePathExtension(file_name, ext); - return true; - } - bool NimDBPretreatment::MoveFile(const std::string &from_path, const std::string &to_path) - { - std::wstring w_from_path = nbase::UTF8ToUTF16(from_path); - std::wstring w_to_path = nbase::UTF8ToUTF16(to_path); - return (::MoveFile(w_from_path.c_str(), w_to_path.c_str()) == TRUE); - //return (::MoveFileA(from_path.c_str(), to_path.c_str()) == TRUE); - } - void NimDBPretreatment::ClearTLSLastError() - { - ::SetLastError(0); - } - unsigned int NimDBPretreatment::GetTLSLastError() - { - return (unsigned int)GetLastError(); - } - void NimDBPretreatment::LockDBFile() - { - db_lock_.Lock(); - } - void NimDBPretreatment::UnLockDBFile() - { - db_lock_.Unlock(); - } -} \ No newline at end of file diff --git a/tool_kits/shared/db_helper.h b/tool_kits/shared/db_helper.h deleted file mode 100644 index 68c59388..00000000 --- a/tool_kits/shared/db_helper.h +++ /dev/null @@ -1,107 +0,0 @@ -#pragma once - -#include "base/memory/singleton.h" -#include "base/synchronization/lock.h" -#include "base/callback/callback.h" -#include "db/db_pretreatment.h" -#include "shared/tool.h" -namespace shared -{ -typedef int NimDBVersionType; -class NimDBPretreatment : public ndb::DBPretreatment, public ndb::DBPretreatment::FileSystem -{ -public: - virtual bool FilePathIsExist(const std::string& file_path, bool is_directory) override; - virtual bool DeleteFile(const std::string& file_path) override; - virtual bool CopyFile(const std::string &from_path, const std::string &to_path, bool fail_if_exists) override; - virtual bool CreateDir(const std::string& dir_path) override; - virtual bool GetDirFromPath(const std::string& file_path, std::string& dir) override;//dir δβ"/" or "\\" - virtual bool GetFileNameFromPath(const std::string& file_path, std::string& name, std::string& ext) override; - virtual bool MoveFile(const std::string &from_path, const std::string &to_path) override; - virtual void ClearTLSLastError() override; - virtual unsigned int GetTLSLastError() override; - virtual void LockDBFile() override; - virtual void UnLockDBFile() override; -protected: - nbase::NLock db_lock_; -}; -class NimDatabase : public NimDBPretreatment, virtual public nbase::SupportWeakCallback -{ -public: - NimDatabase(NimDBVersionType base_version, NimDBVersionType newest_version) : - base_version_(base_version), newest_version_(newest_version) - { - } -public: - bool CreateDB() - { - PretreatmentConfig&& config = CreatePretreatmentConfig(); - config.db_path_ = std::move(GetDBPath()); - config.base_version_ = base_version_; - config.newest_version_ = newest_version_; - if (config.newest_version_ < config.base_version_) - config.newest_version_ = config.base_version_; - if (!config.db_path_.empty() && OnBeforCreateDatabase(config)) - { - NimDBPretreatment::Init(config); - return NimDBPretreatment::DoPretreatment(this, GetEncryptKey(), create_db_sqls_, update_function_list_); - } - return false; - }; - virtual bool CloseDB() override - { - OnBeforCloseDatabase(); - return NimDBPretreatment::CloseDB();; - }; -protected: - virtual void AddCreateDBSql(const std::string& sql) - { - create_db_sqls_.push_back(sql); - } - virtual void AddCreateDBSql(std::string&& sql) - { - create_db_sqls_.push_back(std::forward(sql)); - } - virtual void AddUpdateFunction(NimDBVersionType version, const DBUpdateFunc& opration) - { - update_function_list_.insert(std::make_pair(version, opration)); - } - virtual void AddUpdateFunction(NimDBVersionType version, DBUpdateFunc&& opration) - { - update_function_list_.insert(std::make_pair(version, std::forward(opration))); - } - virtual void OnClear() override - { - create_db_sqls_.clear(); - update_function_list_.clear(); - } - virtual bool OnBeforCreateDatabase(PretreatmentConfig& config) - { - return true; - } - virtual bool OnBeforCloseDatabase() - { - return true; - } - virtual std::string GetEncryptKey() const - { - return ""; - } - virtual std::string GetDBPath() const = 0; -private: - inline PretreatmentConfig CreatePretreatmentConfig() - { - PretreatmentConfig config; - config.back_db_dir_ = ""; - config.enable_backup_ = true; - config.enable_restore_ = false; - config.enable_def_restore_ = false; - return config; - } -private: - std::list create_db_sqls_; - DBUpdateFuncList update_function_list_; - NimDBVersionType base_version_; - NimDBVersionType newest_version_; -}; -} \ No newline at end of file diff --git a/tool_kits/shared/image_ole_i.c b/tool_kits/shared/image_ole_i.c deleted file mode 100644 index eda4a288..00000000 --- a/tool_kits/shared/image_ole_i.c +++ /dev/null @@ -1,94 +0,0 @@ - - -/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */ - -/* link this file in with the server and any clients */ - - - /* File created by MIDL compiler version 7.00.0555 */ -/* at Thu Jul 20 13:21:34 2017 - */ -/* Compiler settings for image_ole.idl: - Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 - protocol : dce , ms_ext, c_ext, robust - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() -*/ -/* @@MIDL_FILE_HEADING( ) */ - -#pragma warning( disable: 4049 ) /* more than 64k source lines */ - - -#ifdef __cplusplus -extern "C"{ -#endif - - -#include -#include - -#ifdef _MIDL_USE_GUIDDEF_ - -#ifndef INITGUID -#define INITGUID -#include -#undef INITGUID -#else -#include -#endif - -#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ - DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) - -#else // !_MIDL_USE_GUIDDEF_ - -#ifndef __IID_DEFINED__ -#define __IID_DEFINED__ - -typedef struct _IID -{ - unsigned long x; - unsigned short s1; - unsigned short s2; - unsigned char c[8]; -} IID; - -#endif // __IID_DEFINED__ - -#ifndef CLSID_DEFINED -#define CLSID_DEFINED -typedef IID CLSID; -#endif // CLSID_DEFINED - -#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ - const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} - -#endif !_MIDL_USE_GUIDDEF_ - -MIDL_DEFINE_GUID(IID, IID_IComponentRegistrar,0xa817e7a2,0x43fa,0x11d0,0x9e,0x44,0x00,0xaa,0x00,0xb6,0x77,0x0a); - - -MIDL_DEFINE_GUID(IID, IID_IImageOle,0xFDEEBA15,0x2214,0x4AAA,0x82,0x22,0x73,0x54,0x49,0x1B,0xE2,0x6C); - - -MIDL_DEFINE_GUID(IID, LIBID_image_oleLib,0x20667E6E,0x41AD,0x40D0,0xBF,0xE9,0x94,0x84,0x0D,0x87,0x2C,0xD4); - - -MIDL_DEFINE_GUID(CLSID, CLSID_CompReg,0x070D3F66,0x491B,0x4F0D,0x9E,0xCC,0x53,0x58,0xBB,0x7B,0x03,0x03); - - -MIDL_DEFINE_GUID(IID, DIID__IImageOleEvents,0x280EB118,0xCF3F,0x49C4,0xA6,0xE2,0xDE,0x4B,0x00,0x8C,0x5B,0xBB); - - -MIDL_DEFINE_GUID(CLSID, CLSID_ImageOle,0xB0C73E85,0x1599,0x4705,0xBD,0x6B,0xDB,0x1D,0xF7,0x67,0xFC,0x6D); - -#undef MIDL_DEFINE_GUID - -#ifdef __cplusplus -} -#endif - - - diff --git a/tool_kits/shared/image_ole_i.h b/tool_kits/shared/image_ole_i.h deleted file mode 100644 index c958ffb6..00000000 --- a/tool_kits/shared/image_ole_i.h +++ /dev/null @@ -1,729 +0,0 @@ - - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 7.00.0555 */ -/* at Thu Jul 20 13:21:34 2017 - */ -/* Compiler settings for image_ole.idl: - Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 - protocol : dce , ms_ext, c_ext, robust - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() -*/ -/* @@MIDL_FILE_HEADING( ) */ - -#pragma warning( disable: 4049 ) /* more than 64k source lines */ - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 475 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ - -#ifndef COM_NO_WINDOWS_H -#include "windows.h" -#include "ole2.h" -#endif /*COM_NO_WINDOWS_H*/ - -#ifndef __image_ole_i_h__ -#define __image_ole_i_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -/* Forward Declarations */ - -#ifndef __IComponentRegistrar_FWD_DEFINED__ -#define __IComponentRegistrar_FWD_DEFINED__ -typedef interface IComponentRegistrar IComponentRegistrar; -#endif /* __IComponentRegistrar_FWD_DEFINED__ */ - - -#ifndef __IImageOle_FWD_DEFINED__ -#define __IImageOle_FWD_DEFINED__ -typedef interface IImageOle IImageOle; -#endif /* __IImageOle_FWD_DEFINED__ */ - - -#ifndef __CompReg_FWD_DEFINED__ -#define __CompReg_FWD_DEFINED__ - -#ifdef __cplusplus -typedef class CompReg CompReg; -#else -typedef struct CompReg CompReg; -#endif /* __cplusplus */ - -#endif /* __CompReg_FWD_DEFINED__ */ - - -#ifndef ___IImageOleEvents_FWD_DEFINED__ -#define ___IImageOleEvents_FWD_DEFINED__ -typedef interface _IImageOleEvents _IImageOleEvents; -#endif /* ___IImageOleEvents_FWD_DEFINED__ */ - - -#ifndef __ImageOle_FWD_DEFINED__ -#define __ImageOle_FWD_DEFINED__ - -#ifdef __cplusplus -typedef class ImageOle ImageOle; -#else -typedef struct ImageOle ImageOle; -#endif /* __cplusplus */ - -#endif /* __ImageOle_FWD_DEFINED__ */ - - -/* header files for imported files */ -#include "oaidl.h" -#include "ocidl.h" - -#ifdef __cplusplus -extern "C"{ -#endif - - -#ifndef __IComponentRegistrar_INTERFACE_DEFINED__ -#define __IComponentRegistrar_INTERFACE_DEFINED__ - -/* interface IComponentRegistrar */ -/* [unique][dual][uuid][object] */ - - -EXTERN_C const IID IID_IComponentRegistrar; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("a817e7a2-43fa-11d0-9e44-00aa00b6770a") - IComponentRegistrar : public IDispatch - { - public: - virtual /* [id] */ HRESULT STDMETHODCALLTYPE Attach( - /* [in] */ BSTR bstrPath) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE RegisterAll( void) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE UnregisterAll( void) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetComponents( - /* [out] */ SAFEARRAY * *pbstrCLSIDs, - /* [out] */ SAFEARRAY * *pbstrDescriptions) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE RegisterComponent( - /* [in] */ BSTR bstrCLSID) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE UnregisterComponent( - /* [in] */ BSTR bstrCLSID) = 0; - - }; - -#else /* C style interface */ - - typedef struct IComponentRegistrarVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IComponentRegistrar * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IComponentRegistrar * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IComponentRegistrar * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - IComponentRegistrar * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - IComponentRegistrar * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - IComponentRegistrar * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [range][in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - IComponentRegistrar * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *Attach )( - IComponentRegistrar * This, - /* [in] */ BSTR bstrPath); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *RegisterAll )( - IComponentRegistrar * This); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *UnregisterAll )( - IComponentRegistrar * This); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *GetComponents )( - IComponentRegistrar * This, - /* [out] */ SAFEARRAY * *pbstrCLSIDs, - /* [out] */ SAFEARRAY * *pbstrDescriptions); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *RegisterComponent )( - IComponentRegistrar * This, - /* [in] */ BSTR bstrCLSID); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *UnregisterComponent )( - IComponentRegistrar * This, - /* [in] */ BSTR bstrCLSID); - - END_INTERFACE - } IComponentRegistrarVtbl; - - interface IComponentRegistrar - { - CONST_VTBL struct IComponentRegistrarVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IComponentRegistrar_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IComponentRegistrar_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IComponentRegistrar_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IComponentRegistrar_GetTypeInfoCount(This,pctinfo) \ - ( (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) ) - -#define IComponentRegistrar_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - ( (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) ) - -#define IComponentRegistrar_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - ( (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) ) - -#define IComponentRegistrar_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - ( (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) ) - - -#define IComponentRegistrar_Attach(This,bstrPath) \ - ( (This)->lpVtbl -> Attach(This,bstrPath) ) - -#define IComponentRegistrar_RegisterAll(This) \ - ( (This)->lpVtbl -> RegisterAll(This) ) - -#define IComponentRegistrar_UnregisterAll(This) \ - ( (This)->lpVtbl -> UnregisterAll(This) ) - -#define IComponentRegistrar_GetComponents(This,pbstrCLSIDs,pbstrDescriptions) \ - ( (This)->lpVtbl -> GetComponents(This,pbstrCLSIDs,pbstrDescriptions) ) - -#define IComponentRegistrar_RegisterComponent(This,bstrCLSID) \ - ( (This)->lpVtbl -> RegisterComponent(This,bstrCLSID) ) - -#define IComponentRegistrar_UnregisterComponent(This,bstrCLSID) \ - ( (This)->lpVtbl -> UnregisterComponent(This,bstrCLSID) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IComponentRegistrar_INTERFACE_DEFINED__ */ - - -#ifndef __IImageOle_INTERFACE_DEFINED__ -#define __IImageOle_INTERFACE_DEFINED__ - -/* interface IImageOle */ -/* [unique][nonextensible][dual][uuid][object] */ - - -EXTERN_C const IID IID_IImageOle; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("FDEEBA15-2214-4AAA-8222-7354491BE26C") - IImageOle : public IDispatch - { - public: - virtual /* [id] */ HRESULT STDMETHODCALLTYPE LoadFromFile( - /* [in] */ BSTR lpszPathName) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetFaceId( - /* [in] */ LONG face_id) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetFaceId( - LONG *face_id) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetFaceIndex( - LONG face_index) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetFaceIndex( - LONG *face_index) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetImageFile( - BSTR *file_name) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetImageRect( - LPRECT rect) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetImageFomat( - GUID *guid) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE SaveAsFile( - BSTR file_path) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetScaleSize( - BOOL bScale, - int nWidth, - int nHeight) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetBgColor( - COLORREF clrBg) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE Draw( void) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetFaceTag( - /* [in] */ BSTR face_tag) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetFaceTag( - /* [out] */ BSTR *face_tag) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetFont( - /* [in] */ BSTR font_name, - /* [in] */ LONG font_size, - /* [in] */ COLORREF clrText) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetGUID( - BSTR guid) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetGUID( - BSTR *guid) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetScale( - LONG *scale) = 0; - - virtual /* [id] */ HRESULT STDMETHODCALLTYPE LoadFromDescription( - /* [in] */ BSTR des) = 0; - - }; - -#else /* C style interface */ - - typedef struct IImageOleVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IImageOle * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IImageOle * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IImageOle * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - IImageOle * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - IImageOle * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - IImageOle * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [range][in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - IImageOle * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *LoadFromFile )( - IImageOle * This, - /* [in] */ BSTR lpszPathName); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *SetFaceId )( - IImageOle * This, - /* [in] */ LONG face_id); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *GetFaceId )( - IImageOle * This, - LONG *face_id); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *SetFaceIndex )( - IImageOle * This, - LONG face_index); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *GetFaceIndex )( - IImageOle * This, - LONG *face_index); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *GetImageFile )( - IImageOle * This, - BSTR *file_name); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *GetImageRect )( - IImageOle * This, - LPRECT rect); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *GetImageFomat )( - IImageOle * This, - GUID *guid); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *SaveAsFile )( - IImageOle * This, - BSTR file_path); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *SetScaleSize )( - IImageOle * This, - BOOL bScale, - int nWidth, - int nHeight); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *SetBgColor )( - IImageOle * This, - COLORREF clrBg); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *Draw )( - IImageOle * This); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *SetFaceTag )( - IImageOle * This, - /* [in] */ BSTR face_tag); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *GetFaceTag )( - IImageOle * This, - /* [out] */ BSTR *face_tag); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *SetFont )( - IImageOle * This, - /* [in] */ BSTR font_name, - /* [in] */ LONG font_size, - /* [in] */ COLORREF clrText); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *SetGUID )( - IImageOle * This, - BSTR guid); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *GetGUID )( - IImageOle * This, - BSTR *guid); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *GetScale )( - IImageOle * This, - LONG *scale); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *LoadFromDescription )( - IImageOle * This, - /* [in] */ BSTR des); - - END_INTERFACE - } IImageOleVtbl; - - interface IImageOle - { - CONST_VTBL struct IImageOleVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IImageOle_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define IImageOle_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define IImageOle_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define IImageOle_GetTypeInfoCount(This,pctinfo) \ - ( (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) ) - -#define IImageOle_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - ( (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) ) - -#define IImageOle_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - ( (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) ) - -#define IImageOle_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - ( (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) ) - - -#define IImageOle_LoadFromFile(This,lpszPathName) \ - ( (This)->lpVtbl -> LoadFromFile(This,lpszPathName) ) - -#define IImageOle_SetFaceId(This,face_id) \ - ( (This)->lpVtbl -> SetFaceId(This,face_id) ) - -#define IImageOle_GetFaceId(This,face_id) \ - ( (This)->lpVtbl -> GetFaceId(This,face_id) ) - -#define IImageOle_SetFaceIndex(This,face_index) \ - ( (This)->lpVtbl -> SetFaceIndex(This,face_index) ) - -#define IImageOle_GetFaceIndex(This,face_index) \ - ( (This)->lpVtbl -> GetFaceIndex(This,face_index) ) - -#define IImageOle_GetImageFile(This,file_name) \ - ( (This)->lpVtbl -> GetImageFile(This,file_name) ) - -#define IImageOle_GetImageRect(This,rect) \ - ( (This)->lpVtbl -> GetImageRect(This,rect) ) - -#define IImageOle_GetImageFomat(This,guid) \ - ( (This)->lpVtbl -> GetImageFomat(This,guid) ) - -#define IImageOle_SaveAsFile(This,file_path) \ - ( (This)->lpVtbl -> SaveAsFile(This,file_path) ) - -#define IImageOle_SetScaleSize(This,bScale,nWidth,nHeight) \ - ( (This)->lpVtbl -> SetScaleSize(This,bScale,nWidth,nHeight) ) - -#define IImageOle_SetBgColor(This,clrBg) \ - ( (This)->lpVtbl -> SetBgColor(This,clrBg) ) - -#define IImageOle_Draw(This) \ - ( (This)->lpVtbl -> Draw(This) ) - -#define IImageOle_SetFaceTag(This,face_tag) \ - ( (This)->lpVtbl -> SetFaceTag(This,face_tag) ) - -#define IImageOle_GetFaceTag(This,face_tag) \ - ( (This)->lpVtbl -> GetFaceTag(This,face_tag) ) - -#define IImageOle_SetFont(This,font_name,font_size,clrText) \ - ( (This)->lpVtbl -> SetFont(This,font_name,font_size,clrText) ) - -#define IImageOle_SetGUID(This,guid) \ - ( (This)->lpVtbl -> SetGUID(This,guid) ) - -#define IImageOle_GetGUID(This,guid) \ - ( (This)->lpVtbl -> GetGUID(This,guid) ) - -#define IImageOle_GetScale(This,scale) \ - ( (This)->lpVtbl -> GetScale(This,scale) ) - -#define IImageOle_LoadFromDescription(This,des) \ - ( (This)->lpVtbl -> LoadFromDescription(This,des) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - - -#endif /* __IImageOle_INTERFACE_DEFINED__ */ - - - -#ifndef __image_oleLib_LIBRARY_DEFINED__ -#define __image_oleLib_LIBRARY_DEFINED__ - -/* library image_oleLib */ -/* [custom][version][uuid] */ - - -EXTERN_C const IID LIBID_image_oleLib; - -EXTERN_C const CLSID CLSID_CompReg; - -#ifdef __cplusplus - -class DECLSPEC_UUID("070D3F66-491B-4F0D-9ECC-5358BB7B0303") -CompReg; -#endif - -#ifndef ___IImageOleEvents_DISPINTERFACE_DEFINED__ -#define ___IImageOleEvents_DISPINTERFACE_DEFINED__ - -/* dispinterface _IImageOleEvents */ -/* [uuid] */ - - -EXTERN_C const IID DIID__IImageOleEvents; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("280EB118-CF3F-49C4-A6E2-DE4B008C5BBB") - _IImageOleEvents : public IDispatch - { - }; - -#else /* C style interface */ - - typedef struct _IImageOleEventsVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - _IImageOleEvents * This, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - __RPC__deref_out void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - _IImageOleEvents * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - _IImageOleEvents * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - _IImageOleEvents * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - _IImageOleEvents * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - _IImageOleEvents * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [range][in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - _IImageOleEvents * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - END_INTERFACE - } _IImageOleEventsVtbl; - - interface _IImageOleEvents - { - CONST_VTBL struct _IImageOleEventsVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define _IImageOleEvents_QueryInterface(This,riid,ppvObject) \ - ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) - -#define _IImageOleEvents_AddRef(This) \ - ( (This)->lpVtbl -> AddRef(This) ) - -#define _IImageOleEvents_Release(This) \ - ( (This)->lpVtbl -> Release(This) ) - - -#define _IImageOleEvents_GetTypeInfoCount(This,pctinfo) \ - ( (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) ) - -#define _IImageOleEvents_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - ( (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) ) - -#define _IImageOleEvents_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - ( (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) ) - -#define _IImageOleEvents_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - ( (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) ) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - -#endif /* ___IImageOleEvents_DISPINTERFACE_DEFINED__ */ - - -EXTERN_C const CLSID CLSID_ImageOle; - -#ifdef __cplusplus - -class DECLSPEC_UUID("B0C73E85-1599-4705-BD6B-DB1DF767FC6D") -ImageOle; -#endif -#endif /* __image_oleLib_LIBRARY_DEFINED__ */ - -/* Additional Prototypes for ALL interfaces */ - -unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * ); -unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * ); -unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * ); -void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * ); - -unsigned long __RPC_USER LPSAFEARRAY_UserSize( unsigned long *, unsigned long , LPSAFEARRAY * ); -unsigned char * __RPC_USER LPSAFEARRAY_UserMarshal( unsigned long *, unsigned char *, LPSAFEARRAY * ); -unsigned char * __RPC_USER LPSAFEARRAY_UserUnmarshal(unsigned long *, unsigned char *, LPSAFEARRAY * ); -void __RPC_USER LPSAFEARRAY_UserFree( unsigned long *, LPSAFEARRAY * ); - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/tool_kits/shared/ipc_manager.cpp b/tool_kits/shared/ipc_manager.cpp deleted file mode 100644 index 1069b66b..00000000 --- a/tool_kits/shared/ipc_manager.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "stdafx.h" -#include "ipc_manager.h" -#include "base/macros.h" - -namespace shared -{ - -IPCManager::IPCManager() -{ - -} - -IPCManager::~IPCManager() -{ - nbase::NAutoLock auto_lock(&lock_); - - for (std::map::const_iterator it = shared_memory_handle_map_.begin(); - it != shared_memory_handle_map_.end(); ++it) - { - ::CloseHandle(it->second); - } - shared_memory_handle_map_.clear(); -} - -bool IPCManager::CreateSharedMemory(const std::wstring &tag, const std::string &data) -{ - DestroySharedMemory(tag); - - nbase::NAutoLock auto_lock(&lock_); - - PSECURITY_DESCRIPTOR pSec = (PSECURITY_DESCRIPTOR)::LocalAlloc(LMEM_FIXED, SECURITY_DESCRIPTOR_MIN_LENGTH); - if (!pSec) - { - return false; - } - if (!::InitializeSecurityDescriptor(pSec, SECURITY_DESCRIPTOR_REVISION)) - { - ::LocalFree(pSec); - return false; - } - if (!::SetSecurityDescriptorDacl(pSec, true, NULL, true)) - { - ::LocalFree(pSec); - return false; - } - - SECURITY_ATTRIBUTES attr; - attr.bInheritHandle = false; - attr.lpSecurityDescriptor = pSec; - attr.nLength = sizeof(SECURITY_ATTRIBUTES); - - HANDLE h = ::CreateFileMapping(INVALID_HANDLE_VALUE, &attr, PAGE_READWRITE, 0, MAX_PATH, tag.c_str()); - if (h == NULL) - return false; - - PVOID pView = ::MapViewOfFile(h, FILE_MAP_WRITE, 0, 0, 0); - if (pView == NULL) - { - ::CloseHandle(h); - return false; - } - - memset(pView, 0, MAX_PATH); - memcpy(pView, data.c_str(), data.length()); - - ::UnmapViewOfFile(pView); - shared_memory_handle_map_[tag] = h; - return true; -} - -void IPCManager::DestroySharedMemory(const std::wstring &tag) -{ - nbase::NAutoLock auto_lock(&lock_); - - if (shared_memory_handle_map_.find(tag) == shared_memory_handle_map_.end()) - return; - - ::CloseHandle(shared_memory_handle_map_[tag]); - shared_memory_handle_map_.erase(tag); -} -}//namespace shared \ No newline at end of file diff --git a/tool_kits/shared/ipc_manager.h b/tool_kits/shared/ipc_manager.h deleted file mode 100644 index e268fbae..00000000 --- a/tool_kits/shared/ipc_manager.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef SHARED_IPC_MANAGER_H_ -#define SHARED_IPC_MANAGER_H_ - -#include "base/synchronization/lock.h" -#include "base/memory/singleton.h" -#include -#include - -namespace shared -{ -// IPC -class IPCManager -{ -public: - SINGLETON_DEFINE(IPCManager); - IPCManager(); - ~IPCManager(); - bool CreateSharedMemory(const std::wstring &tag, const std::string &data); - void DestroySharedMemory(const std::wstring &tag); - -private: - std::map shared_memory_handle_map_; - nbase::NLock lock_; -}; -}//namespace shared - -#endif //SHARED_IPC_MANAGER_H_ diff --git a/tool_kits/shared/log.cpp b/tool_kits/shared/log.cpp deleted file mode 100644 index 786f80f1..00000000 --- a/tool_kits/shared/log.cpp +++ /dev/null @@ -1,251 +0,0 @@ -#include "stdafx.h" -#include "log.h" - - - -void QLogImpl::SetLogFile( const std::wstring &file_path ) -{ - log_file_ = file_path; -} - -std::wstring QLogImpl::GetLogFile() -{ - return log_file_; -} - -void QLogImpl::SetLogLevel( LOG_LEVEL lv ) -{ - log_level_ = lv; -} - -void QLogImpl::WriteLog( LOG_LEVEL lv, const std::wstring &log ) -{ -#ifdef _DEBUG - fwprintf_s( stdout, L"%s", log.c_str() ); -#endif - -#ifdef _WINDOWS - OutputDebugStringW( log.c_str() ); -#endif - - if( lv > log_level_ ) - return; - - if( log_file_.empty() ) - return; - - std::string str = nbase::UTF16ToUTF8(log); - - nbase::NAutoLock auto_lock( &lock_ ); - - bool exist = nbase::FilePathIsExist(log_file_, false); - - std::unique_ptr fp; - FILE* fp_file = nullptr; - _wfopen_s(&fp_file, log_file_.c_str(), L"a+"); - fp.reset(fp_file); - if( !fp ) - return; - - if( !exist ) - { - const char utf8[3] = { (char) 0xEF, (char) 0xBB, (char) 0xBF }; - fwrite(utf8, sizeof(char), 3, fp.get() ); - } - - fwrite(str.c_str(), sizeof(char), str.size(), fp.get()); - fp.reset(NULL); -} - -void QLogImpl::HalfTo( long max, long to ) -{ - nbase::NAutoLock auto_lock( &lock_); - - //ļ - std::unique_ptr fp; - FILE* fp_file = nullptr; - _wfopen_s(&fp_file, log_file_.c_str(), L"r"); - fp.reset(fp_file); - if(!fp) - { - fp.reset(NULL); - return; - } - - //ȡ - int ret = fseek(fp.get(), 0L, SEEK_END); - if (ret != 0) - { - return; - } - - //Сmaxֱӷ - long len = ftell(fp.get()); - if(len <= max) - { - return; - } - - //maxֻto - len = max * (-1); - ret = fseek(fp.get(), len, SEEK_END); - if (ret != 0) - { - return; - } - - //ļ - nbase::PathString new_file = log_file_ + L".old"; - std::unique_ptr fp2; - FILE* fp_file2 = nullptr; - _wfopen_s(&fp_file2, new_file.c_str(), L"w"); - fp2.reset(fp_file2); - if(!fp2) - { - return; - } - - //дļ - char cbuf[12 * 1024] = { 0 }; - int cn = sizeof(cbuf), n = 0; - while(!feof(fp.get())) - { - n = fread_s(cbuf, cn, sizeof(char), cn, fp.get()); - if(n > 0) - { - fwrite(cbuf, sizeof(char), n, fp2.get()); - } - else - { - break; - } - } - fp.reset(NULL); - fp2.reset(NULL); - - //ļ滻 - bool del = nbase::DeleteFileW(log_file_); - if(del) - { - ::_wrename(new_file.c_str(), log_file_.c_str()); - } - else - { - nbase::DeleteFileW(new_file); - } -} - - -QLogHelper::QLogHelper( const char* file, long line ) -{ - index_ = 0; - level_ = LV_PRO; - - nbase::Time::TimeStruct qt = nbase::Time::Now().ToTimeStruct(true); - time_ = nbase::StringPrintf( L"[%04d-%02d-%02d %02d:%02d:%02d", - qt.year_, qt.month_, qt.day_of_month_, qt.hour_, qt.minute_, qt.second_); - - std::wstring str = nbase::UTF8ToUTF16(file); - std::wstring file_name; - nbase::FilePathApartFileName(str, file_name); - - file_line_ = nbase::StringPrintf( L" %s:%ld ", file_name.c_str(), line ); -} - -QLogHelper::~QLogHelper() -{ - std::wstring lv; - switch( level_ ) - { - case LV_ERR: - lv = L"LV_ERR"; - break; - case LV_WAR: - lv = L"LV_WAR"; - break; - case LV_APP: - lv = L"LV_APP"; - break; - case LV_PRO: - lv = L"LV_PRO"; - break; - default: - assert( 0 ); - break; - } - lv.append( L"] " ); - - if( string_.empty() ) - string_ = fmt_; - else if( !fmt_.empty() ) - string_.append(fmt_); - - std::wstring log = time_ + file_line_ + lv + string_ + L"\r\n"; - QLogImpl::GetInstance()->WriteLog( level_, log ); -} - -QLogHelper& QLogHelper::VLog( LOG_LEVEL lv, const std::wstring &fmt ) -{ - level_ = lv; - fmt_ = fmt; - return *this; -} - -QLogHelper& QLogHelper::operator<<(const std::wstring &str) -{ - int len = 0; - size_t pos = FindArg( len ); - if( pos == fmt_.npos ) - { - assert( 0 ); - } - else - { - string_.append( fmt_.substr( 0, pos ) ); - string_.append( str ); - - fmt_.erase( 0, pos + len ); - } - - index_++; - return *this; -} - -QLogHelper& QLogHelper::operator<<(const std::string &str) -{ - std::wstring wstr = nbase::UTF8ToUTF16(str); - return this->operator<<(wstr); -} - -QLogHelper& QLogHelper::operator<<(const long long lld) -{ - int len = 0; - size_t pos = FindArg( len ); - if( pos == fmt_.npos ) - { - assert( 0 ); - } - else - { - std::wstring data = nbase::Int64ToString16(lld); - - string_.append( fmt_.substr( 0, pos ) ); - string_.append( data ); - - fmt_.erase( 0, pos + len ); - } - - index_++; - return *this; -} - -size_t QLogHelper::FindArg( int &len ) -{ - assert( !fmt_.empty() ); - assert( index_ >= 0 && index_ <= 20 ); - - std::wstring str = nbase::StringPrintf(L"{%d}", index_); - len = str.size(); - - return fmt_.find( str ); -} \ No newline at end of file diff --git a/tool_kits/shared/log.h b/tool_kits/shared/log.h deleted file mode 100644 index 2cec416e..00000000 --- a/tool_kits/shared/log.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once -//#include "util.h" - - -/* c#coutlog - * ʾ - * QLOG_ERR(L"I am {0},this is {1} year,you can also call me {2}") <= HANZI_MIN && ch <= HANZI_MAX) - { - pinyin_char = pinyin_.get() + code_index_[ch - HANZI_MIN]; - str_firstLetters_ += pinyin_char[0]; - } - else - { - str_firstLetters_.push_back((char)ch); - } - } - - return str_firstLetters_.c_str(); -} - - -std::wstring PinYinHelper::GetPinyinFilePath() -{ - std::wstring full_path; - std::wstring path = nbase::win32::GetCurrentModuleDirectory(); - full_path = path + kFileName; - return full_path; -} - -bool PinYinHelper::LoadPinyinTable() -{ - if (code_index_.get() && pinyin_.get()) - return true; - std::wstring path = GetPinyinFilePath(); - - file_handle_.reset(nbase::OpenFile(path, L"rb")); - if (!file_handle_) - { - //LOG_ERR("Open translator file error!"); - return false; - } - int hanzi_num = 0; - int pinyin_size = 0; - fread(&hanzi_num, 4, 1, file_handle_.get()); - fread(&pinyin_size, 4, 1, file_handle_.get()); - code_index_.reset(new int[4 * hanzi_num]); - if (!code_index_.get()) - { - //LOG_ERR("code_index_ New memory error!"); - return false; - } - pinyin_.reset(new char[pinyin_size]); - if (!pinyin_.get()) - { - //LOG_ERR("pinyin_ New memory error!"); - return false; - } - int ret; - ret = fread(code_index_.get(), 4, hanzi_num, file_handle_.get()); - if (ret != hanzi_num) - { - //LOG_ERR("code_index_ Read file error!"); - return false; - } - ret = fread(pinyin_.get(), 1, pinyin_size, file_handle_.get()); - if (ret != pinyin_size) - { - //LOG_ERR("pinyin_ Read file error!"); - return false; - } - return true; -} - -const char* PinYinHelper::ConvertToFullSpell(const std::wstring& chinese) -{ - if (chinese.empty() || !code_index_.get() || !pinyin_.get()) - { - return ""; - } - str_pinyin_.clear(); - for(unsigned int i = 0; i < chinese.length(); i++) - { - wchar_t ch = chinese[i]; - const char *pinyin_char = NULL; - if(ch >= HANZI_MIN && ch <= HANZI_MAX) - { - pinyin_char = pinyin_.get() + code_index_[ch - HANZI_MIN]; - str_pinyin_.append(pinyin_char); - } - else - { - str_pinyin_.push_back((char)ch); - } - } - - return str_pinyin_.c_str(); -} diff --git a/tool_kits/shared/pin_yin_helper.h b/tool_kits/shared/pin_yin_helper.h deleted file mode 100644 index 1e68bf0b..00000000 --- a/tool_kits/shared/pin_yin_helper.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef CHINESE_PIN_YIN_H_ -#define CHINESE_PIN_YIN_H_ - -/* - * - * Author tom|yuzj - * Date 2013-10-10 - * Brief 拼音 - * - */ - -using namespace std; - -class PinYinHelper -{ -public: - SINGLETON_DEFINE(PinYinHelper); - - PinYinHelper(); - ~PinYinHelper(); - const char* ConvertToFullSpell(const std::wstring& chinese); - const char* ConvertToSimpleSpell(const std::wstring& chinese); -private: - std::wstring GetPinyinFilePath(); - bool LoadPinyinTable(); - -private: - std::unique_ptr file_handle_; - std::unique_ptr code_index_; - std::unique_ptr pinyin_; - std::string str_pinyin_; - std::string str_firstLetters_; -}; -#endif//CHINESE_PIN_YIN_H_ \ No newline at end of file diff --git a/tool_kits/shared/ring.cpp b/tool_kits/shared/ring.cpp deleted file mode 100644 index 603d6c65..00000000 --- a/tool_kits/shared/ring.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include "stdafx.h" -#include "ring.h" -#include "log.h" -#include "util.h" - -static const std::wstring kNewMessage = L"new_message.wav"; -static const std::wstring kVoipConnecting = L"voip_connecting.wav"; -static const std::wstring kVoipNoResponse = L"voip_no_response.wav"; -static const std::wstring kVoipPeerBusy = L"voip_peer_busy.wav"; -static const std::wstring kVoipPeerReject = L"voip_peer_reject.wav"; -static const std::wstring kVoipRing = L"voip_ring.wav"; - -namespace shared -{ -Ring::Ring() -{ - hwnd_ = NULL; -} - -Ring::~Ring() -{ - Destroy(); -} - -bool Ring::Init(HWND hwnd) -{ - hwnd_ = MCIWndCreateW(hwnd, NULL, WS_POPUP | MCIWNDF_NOERRORDLG | MCIWNDF_NOTIFYMODE, NULL); - if (hwnd_ == NULL) - { - QLOG_ERR(L"MCIWndCreateW error {0}") << GetLastError(); - return false; - } - return true; -} - -void Ring::Play(RingType type, bool replay) -{ - assert(hwnd_); - if (hwnd_ == NULL) - return; - - Stop(); - replay_ = replay; - - std::wstring dir = QPath::GetAppPath() + L"res\\audio\\"; - switch (type) - { - case RING_NEW_MESSAGE: - dir.append(kNewMessage); - break; - case RING_VOIP_CONNTETING: - dir.append(kVoipConnecting); - break; - case RING_VOIP_NORESPONSE: - dir.append(kVoipNoResponse); - break; - case RING_VOIP_PEERBUSY: - dir.append(kVoipPeerBusy); - break; - case RING_VOIP_PEERREJECT: - dir.append(kVoipPeerReject); - break; - case RING_VOIP_RING: - dir.append(kVoipRing); - break; - } - - DWORD ret = MCIWndOpen(hwnd_, dir.c_str(), 0); - if (ret == 0) - MCIWndPlay(hwnd_); - else - QLOG_ERR(L"MCIWndOpen error {0}") << ret; -} - -void Ring::Replay() -{ - if (hwnd_ != NULL && MCIWndCanPlay(hwnd_)) - { - MCIWndSeek(hwnd_, 0); - MCIWndPlay(hwnd_); - } -} - - -void Ring::Stop() -{ - replay_ = false; - if (hwnd_) - { - MCIWndStop(hwnd_); - MCIWndClose(hwnd_); - } -} - -void Ring::Destroy() -{ - if (hwnd_) - { - Stop(); - } -} - -LRESULT Ring::Notify(UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - if (uMsg == MCIWNDM_NOTIFYMODE) - { - if (lParam == MCI_MODE_STOP && replay_) - { - Replay(); - } - } - return 0; -} -} \ No newline at end of file diff --git a/tool_kits/shared/ring.h b/tool_kits/shared/ring.h deleted file mode 100644 index 0c8ee5ad..00000000 --- a/tool_kits/shared/ring.h +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once -#include - -enum RingType -{ - RING_NEW_MESSAGE = 0, - RING_VOIP_CONNTETING, - RING_VOIP_NORESPONSE, - RING_VOIP_PEERBUSY, - RING_VOIP_PEERREJECT, - RING_VOIP_RING, -}; - -namespace shared -{ -/** @class Ring - * @brief 提示音播放类 - * @copyright (c) 2016, NetEase Inc. All rights reserved - * @date 2016/09/18 - */ -class Ring -{ -public: - Ring(); - virtual ~Ring(); - - /** - * 初始化提示音播放窗口 - * @param[in] hwnd 父窗口句柄 - * @return bool true 成功,false 失败 - */ - bool Init(HWND hwnd); - - /** - * 播放提示音 - * @param[in] type 提示类型 - * @param[in] replay 是否重复提示 - * @return void 无返回值 - */ - void Play(RingType type, bool replay = false); - - /** - * 重放提示音 - * @return void 无返回值 - */ - void Replay(); - - /** - * 停止提示音 - * @return void 无返回值 - */ - void Stop(); - - /** - * 提示窗口消息处理函数 - * @param[in] uMsg 消息类型 - * @param[in] wParam 附加参数 - * @param[in] lParam 附加参数 - * @return LRESULT 返回值 - */ - LRESULT Notify(UINT uMsg, WPARAM wParam, LPARAM lParam); -private: - /** - * 消息提示音窗口 - * @return void 无返回值 - */ - void Destroy(); -private: - HWND hwnd_; - bool replay_; -}; -} \ No newline at end of file diff --git a/tool_kits/shared/shared.h b/tool_kits/shared/shared.h deleted file mode 100644 index c3af6bac..00000000 --- a/tool_kits/shared/shared.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "auto_unregister.h" -#include "closure.h" -#include "cmd_line.h" -#include "image_ole_i.h" -#include "ipc_manager.h" -#include "log.h" -#include "misc_thread.h" -#include "pin_yin_helper.h" -#include "ring.h" -#include "templated_object_factory.h" -#include "threads.h" -#include "tool.h" -#include "utf8_file_util.h" -#include "util.h" -#include "zoom_image.h" diff --git a/tool_kits/shared/shared.vcxproj b/tool_kits/shared/shared.vcxproj deleted file mode 100644 index 1179eb57..00000000 --- a/tool_kits/shared/shared.vcxproj +++ /dev/null @@ -1,215 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {9951345F-620B-4BED-BB51-4F928CAFD454} - shared - - - - StaticLibrary - true - Unicode - v120_xp - - - StaticLibrary - true - Unicode - v120_xp - - - StaticLibrary - false - true - Unicode - v120_xp - - - StaticLibrary - false - true - Unicode - v120_xp - - - - - - - - - - - - - - - - - - - ..\..\libs\ - ..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ - $(ProjectName)_d - - - $(ProjectName)_d - ..\..\libs\x64\ - ..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ - - - ..\..\libs\ - ..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ - - - ..\..\libs\x64\ - ..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ - - - - Level3 - Disabled - .\;..\ - WIN32;NIM_WIN_DESKTOP_ONLY_SDK;%(PreprocessorDefinitions) - MultiThreadedDebug - Use - - - - - true - - - - - Level3 - Disabled - .\;..\ - WIN32;NIM_WIN_DESKTOP_ONLY_SDK;%(PreprocessorDefinitions) - MultiThreadedDebug - Use - - - - - true - - - - - Level3 - MaxSpeed - true - true - .\;..\ - WIN32;NIM_WIN_DESKTOP_ONLY_SDK;%(PreprocessorDefinitions) - MultiThreaded - Use - - - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - .\;..\ - WIN32;NIM_WIN_DESKTOP_ONLY_SDK;%(PreprocessorDefinitions) - MultiThreaded - Use - - - - - true - true - true - - - - - {8d9a6595-717a-41c8-b468-0011a72be3d1} - - - - - - - false - false - false - false - NotUsing - NotUsing - NotUsing - NotUsing - - - - - - - - Create - Create - Create - Create - - - - - - - - - - - - false - false - false - false - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tool_kits/shared/shared.vcxproj.filters b/tool_kits/shared/shared.vcxproj.filters deleted file mode 100644 index 0f646a3f..00000000 --- a/tool_kits/shared/shared.vcxproj.filters +++ /dev/null @@ -1,43 +0,0 @@ - - - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tool_kits/shared/stdafx.cpp b/tool_kits/shared/stdafx.cpp deleted file mode 100644 index f4cec5da..00000000 --- a/tool_kits/shared/stdafx.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "stdafx.h" - -// TODO: STDAFX.H -// κĸͷļڴļ diff --git a/tool_kits/shared/stdafx.h b/tool_kits/shared/stdafx.h deleted file mode 100644 index 9fe979d0..00000000 --- a/tool_kits/shared/stdafx.h +++ /dev/null @@ -1,23 +0,0 @@ -#define _CRT_SECURE_NO_WARNINGS -#pragma once - -//c++ header -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//base header -#include "base/base.h" - -//third_party -#include "duilib/UIlib.h" diff --git a/tool_kits/shared/templated_object_factory.h b/tool_kits/shared/templated_object_factory.h deleted file mode 100644 index fce32056..00000000 --- a/tool_kits/shared/templated_object_factory.h +++ /dev/null @@ -1,114 +0,0 @@ -#pragma once -namespace shared -{ - class TemplatedObjectFactoryWrapper; - /* - TemplatedObjectFactory - ܣע͵ϢһTOBJFLGʵTBaseӦTOBJFLGĸ - */ - template - class TemplatedObjectFactory : public nbase::Singleton> - { - private: - using _ParentType = nbase::Singleton>; - using _MyType = TemplatedObjectFactory; - friend class TemplatedObjectFactoryWrapper; - - public: - TemplatedObjectFactory() = default; - ~TemplatedObjectFactory() = default; - private: - /* - TClassʵķ, TClass : public TBaseĹϵ - params TClassĹ - TBase͵ָ - */ - template - TBase* Create(const TParam&... params) - { - return dynamic_cast(new TClass(params...)); - } - template - void AddCreateFunction(TOBJFLG flg, const TParam&... params) - { - auto it = std::find_if(crate_function_list_.begin(), crate_function_list_.end(), [&](const decltype(*crate_function_list_.begin()) & item){ - return flg == item.first; - }); - if (it == crate_function_list_.end()) - crate_function_list_.emplace_back(std::make_pair(flg, std::bind(&TemplatedObjectFactory::Create, this, params...))); - } - auto CreateSharedObject(TOBJFLG flg)->std::shared_ptr - { - auto it = std::find_if(crate_function_list_.begin(), crate_function_list_.end(), [&](const decltype(*crate_function_list_.begin()) & item){ - return flg == item.first; - }); - if (it != crate_function_list_.end()) - return std::shared_ptr((*it).second()); - return nullptr; - } - TBase* CreateObject(TOBJFLG flg) - { - TBase* ret = nullptr; - auto it = std::find_if(crate_function_list_.begin(), crate_function_list_.end(), [&](const decltype(*crate_function_list_.begin()) & item){ - return flg == item.first; - }); - if (it != crate_function_list_.end()) - ret = (*it).second(); - return ret; - } - void CreateAllSharedObject(std::list>& objects) - { - for (auto it : crate_function_list_) - objects.emplace_back(std::shared_ptr(it.second())); - } - private: - std::list>> crate_function_list_; - }; - class TemplatedObjectFactoryWrapper - { - public: - //ע - template - static void RegisteredOjbect(const TOBJFLG& flg, const TParam&... params) - { - using TDecayType = typename std::decay::type; - if (std::is_base_of::value) - { - auto&& manager = TemplatedObjectFactory::GetInstance(); - if (manager != nullptr) - manager->AddCreateFunction(flg, params...); - } - } - //üʵ - template - static auto InstantiateSharedRegisteredOjbect(const TFLG& flag)->std::shared_ptr - { - using TDecayType = typename std::decay::type; - auto&& manager = TemplatedObjectFactory::GetInstance(); - if (manager != nullptr) - return manager->CreateSharedObject(flag); - return nullptr; - } - //ʵ - template - static auto InstantiateRegisteredOjbect(const TFLG& flag)->TBase* - { - using TDecayType = typename std::decay::type; - auto&& manager = TemplatedObjectFactory::GetInstance(); - if (manager != nullptr) - return manager->CreateObject(flag); - return nullptr; - } - //עΪ TBase TFLG Ϊʶĵʵ - template - static auto InstantiateAllRegisteredSharedOjbect()->std::list> - { - using TDecayType = typename std::decay::type; - std::list> ret; - auto&& manager = TemplatedObjectFactory::GetInstance(); - if (manager != nullptr) - manager->CreateAllSharedObject(ret); - return ret; - } - }; -} diff --git a/tool_kits/shared/threads.h b/tool_kits/shared/threads.h deleted file mode 100644 index 3e282631..00000000 --- a/tool_kits/shared/threads.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef SHARED_THREADS_H_ -#define SHARED_THREADS_H_ - -// thread ids -enum ThreadId -{ - kThreadBegin = -1,//线程ID定义开始 - kThreadUI, //UI线程(主线程) - kThreadDatabase, //写DB线程 - kThreadGlobalMisc, //全局Misc线程(比如:打开url) - kThreadDuilibHelper,//Duilib专用,UI辅助线程 - kThreadLiveStreaming,//直播线程 - kThreadScreenCapture,//取屏线程 - kThreadApp,//用户自定义应用线程 - kThreadEnd,//线程ID定义结束 -}; - -#endif // SHARED_THREADS_H_ diff --git a/tool_kits/shared/tool.cpp b/tool_kits/shared/tool.cpp deleted file mode 100644 index d2a99435..00000000 --- a/tool_kits/shared/tool.cpp +++ /dev/null @@ -1,653 +0,0 @@ -#include "stdafx.h" -#include "tool.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "base/util/string_util.h" -#include "base/file/file_util.h" -#include "base/thread/framework_thread.h" -#include "base/macros.h" -#include "base/win32/path_util.h" - -UINT g_show_wnd_forgroud_message = 0; - -namespace shared -{ -namespace tools -{ -const wchar_t KShowWndForgroudMessageID[] = L"ShowWndForgroudMessageIdentifer"; - -////////////////////////////////////////////////////// -// 系统相关 -int GetOSVersion() -{ - static int os_version_ = -1; - if (os_version_ < 0) - { - OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) }; - if (!::GetVersionEx(&ovi)) - return -1; - - os_version_ = (ovi.dwMajorVersion * 100 + ovi.dwMinorVersion); - } - return os_version_; -} - -std::string GetOSVersionString() -{ - int ver = GetOSVersion(); - switch (ver) - { - case 500: - return "Windows 2000"; - case 501: - return "Windows XP"; - case 502: - return "Windows Server 2003"; - case 600: - return "Windows Vista"; - case 601: - return "Windows 7"; - case 602: - return "Windows 8"; - default: - return nbase::StringPrintf("[%d]", ver); - } -} - -typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); -LPFN_ISWOW64PROCESS fnIsWow64Process; -bool IsWow64() -{ - BOOL is_wow64 = FALSE; - fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress( - GetModuleHandle(TEXT("kernel32")),"IsWow64Process"); - - if(NULL != fnIsWow64Process) - { - if (!fnIsWow64Process(GetCurrentProcess(),&is_wow64)) - return false; - } - - return is_wow64 ? true : false; -} - -////////////////////////////////////////////////////// -// 字符串处理 -std::string FormatTime(nbase::Time::TimeStruct t) -{ - return nbase::StringPrintf("%04u-%02u-%02u %02u:%02u:%02u", - t.year(), t.month(), t.day_of_month(), - t.hour(), t.minute(), t.second()); -} - -std::wstring FormatBytes(double bytes) -{ - if (bytes < 1024 * 1024) - return nbase::StringPrintf(L"%.2fKB", bytes / 1024); - else if (bytes < 1024 * 1024 * 1024) - return nbase::StringPrintf(L"%.2fMB", bytes / 1024 / 1024); - else - return nbase::StringPrintf(L"%.2fGB", bytes / 1024 / 1024 / 1024); -} - -std::wstring FormatBps(double bytes) -{ - double bits = bytes * 8; - - if (bits < 100000) - return nbase::StringPrintf(L"%dbps", (int)bits); - else if (bits < 1024 * 1024) - return nbase::StringPrintf(L"%dKbps", (int)(bits / 1024)); - else if (bits < 1024 * 1024 * 1024) - return nbase::StringPrintf(L"%.2fMbps", bits / 1024 / 1024); - else - return nbase::StringPrintf(L"%.2fGbps", bits / 1024 / 1024 / 1024); -} - -void SplitString(const std::string &str, const std::string &seperator, std::vector &array) -{ - array.clear(); - if (str.empty() || seperator.empty()) - return; - - size_t position; - std::string tmp_str = str; - - position = tmp_str.find(seperator.c_str()); - while (position != tmp_str.npos) - { - if (position) - array.push_back(tmp_str.substr(0, position)); - tmp_str.erase(0, position + seperator.length()); - position = tmp_str.find(seperator); - } - - if (!tmp_str.empty()) - array.push_back(tmp_str); -} - -void SplitString(const std::wstring &str, const std::wstring &seperator, std::vector &array) -{ - array.clear(); - if (str.empty() || seperator.empty()) - return; - - size_t position; - std::wstring tmp_str = str; - - position = tmp_str.find(seperator.c_str()); - while (position != tmp_str.npos) - { - if (position) - array.push_back(tmp_str.substr(0, position)); - tmp_str.erase(0, position + seperator.length()); - position = tmp_str.find(seperator); - } - - if (!tmp_str.empty()) - array.push_back(tmp_str); -} - -std::string StringReverse(const std::string &input) -{ - int len = input.size(); - std::string output; - output.resize(len); - for (int i = 0; i < len; i++) - { - output[i] = input[len - 1 - i]; - } - - return output; -} - -std::string FilterUCS4(const std::string& str, bool replace_spaces) -{ - if (GetOSVersion() >= 602) - { - return str; - } - bool ret = true; - std::string str_out; - for (UINT i=0;i= 0xf0)//过滤0xffff+ - { - i += 4; - if (single_char >= 0xf8) - { - i++; - } - if (single_char >= 0xfc) - { - i++; - } - ret = false; - if (replace_spaces) - { - str_out += " "; - } - continue; - } - else - { - if (single_char == 0xe2 && i+2 < str.size())//过滤其他无法显示的字符表情 0x26xx为表情符 0x2700-0x27bf为印刷符 - { - UINT ch_u = 0x2000; - UINT single_char_temp = str.at(i+1); - single_char_temp &= 0x3f; - ch_u += single_char_temp<<6; - single_char_temp = str.at(i+2); - single_char_temp &= 0x3f; - ch_u += single_char_temp; - if (GetOSVersion() >= 600)//win7 vista - { - if (ch_u == 0x2614 || ch_u == 0x2615 || ch_u == 0x2618 || ch_u == 0x2619 - || ch_u == 0x2670 || ch_u == 0x2670 || ch_u == 0x2670 - || (ch_u >= 0x267e && ch_u < 0x27c0) ) - { - i += 3; - ret = false; - if (replace_spaces) - { - str_out += " "; - } - continue; - } - } - else//xp - { - if ((ch_u >= 0x2614 && ch_u <= 0x2619) || (ch_u >= 0x267e && ch_u < 0x27c0)) - { - i += 3; - ret = false; - if (replace_spaces) - { - str_out += " "; - } - continue; - } - } - } - str_out += str.at(i); - i++; - } - } - return str_out; -} - -UTF8String FormatSQLText(const UTF8String &sql_text) -{ - UTF8String formated_text(sql_text); - //SQL标准规定,在字符串中,单引号需要使用逃逸字符,即在一行中使用两个单引号。 - nbase::StringReplaceAll("'", "''", formated_text); - return formated_text; -} - -////////////////////////////////////////////////////// -// 文件处理 -std::wstring GetSpecialFolder(int id) -{ - std::wstring path; - - LPITEMIDLIST idl; - LPMALLOC shell_malloc; - if (SHGetMalloc(&shell_malloc) == S_OK) - { - if (SHGetSpecialFolderLocation(NULL, id , &idl) == S_OK) - { - WCHAR *dir = new WCHAR[MAX_PATH]; - SHGetPathFromIDList(idl, dir); - shell_malloc->Free(idl); - path = dir; - delete dir; - } - shell_malloc->Release(); - } - - return path; -} - -std::wstring GetResourcePath(void) -{ - std::wstring app_path = nbase::win32::GetCurrentModuleDirectory(); - return app_path + L"res\\"; -} - -void MakeExtendPath(std::wstring &path) -{ - std::wstring temp = nbase::StringPrintf(L"\\\\?\\%s", path.c_str()); - path = temp; -} - -// 清空达到一定长度的文件 -void ClearFile(const wchar_t *path, long file_length_limit) -{ - int fd; - if ((fd = _wopen(path, O_CREAT | O_RDWR | O_APPEND, _S_IREAD | _S_IWRITE)) < 0) - return; - - long len = _filelength(fd); - _close(fd); - if (len < file_length_limit) - return; - - if ((fd = _wopen(path, O_CREAT | O_RDWR | O_TRUNC, _S_IREAD | _S_IWRITE)) >= 0) - _close(fd); -} - -bool FilePathIsExist(const std::string &utf8_filepath_in, bool is_directory) -{ - std::wstring filepath_in = nbase::UTF8ToUTF16(utf8_filepath_in); - return nbase::FilePathIsExist(filepath_in, is_directory); -} - -bool FindFile(const std::wstring &dir,const std::wstring &file_desc,std::wstring &file_path) -{ - WIN32_FIND_DATAW find_data; - HANDLE file_handle; - - file_handle = ::FindFirstFileW(nbase::StringPrintf(L"%s%s",dir.c_str(),L"*.*").c_str(),&find_data); - if (file_handle != INVALID_HANDLE_VALUE) - { - do - { - if (find_data.cFileName == nbase::StringPrintf(L"%s.lnk",file_desc.c_str())) - { - file_path = nbase::StringPrintf(L"%s%s",dir.c_str(),find_data.cFileName); - ::FindClose(file_handle); - return true; - } - // 如果是子文件夹 - if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && find_data.cFileName[0] != '.') - { - std::wstring in_dir = nbase::StringPrintf(L"%s%s\\",dir.c_str(),find_data.cFileName); - // 递归遍历 - if(FindFile(in_dir,file_desc,file_path)) - return true; - } - } while (::FindNextFileW(file_handle,&find_data)); - - ::FindClose(file_handle); - return false; - } - else - { - return false; - } -} - -std::wstring EnsureValidFileName(const std::wstring &file_name, const std::wstring &find /* = L"/:*?<>|" */, const std::wstring &replace /* = L"_" */) -{ - std::wstring valid = file_name; - const size_t replace_len = replace.length(); - const wchar_t *find_ptr = find.c_str(); - const wchar_t *replace_ptr = replace.c_str(); - - for (size_t pos = valid.find_first_of(find_ptr, 0); pos != std::wstring::npos && pos < valid.length(); pos = valid.find_first_of(find_ptr, pos)) - { - valid.replace(pos, 1, replace_ptr, replace_len); - pos += replace_len; - } - - return valid; -} - -////////////////////////////////////////////////////// -// 数学相关 -int CalcAvg(const std::vector &vec, bool is_revise/* = true*/) -{ - if (vec.empty()) - return 0; - - int sum = 0; - size_t count = vec.size(); - - if (count <= 5 || !is_revise) - { - for (size_t i = 0; i < count; i++) - { - sum += vec[i]; - } - return sum / count; - } - // 去掉最小值和最大值 - else - { - std::vector::const_iterator minIt = std::min_element(vec.begin(), vec.end()); - std::vector::const_iterator maxIt = std::max_element(vec.begin(), vec.end()); - - if (minIt == maxIt) - return *minIt; - - for (std::vector::const_iterator it = vec.begin(); it != vec.end(); ++it) - { - if (it == minIt || it == maxIt) - continue; - - sum += *it; - } - return sum / (count - 2); - } -} - -int CalcStDev(const std::vector &vec) -{ - if (vec.empty()) - return 0; - - int avg = CalcAvg(vec); - - double square_sum = 0; - size_t count = vec.size(); - for (size_t i = 0; i < count; i++) - { - int diff = abs(vec[i] - avg); - square_sum += pow((double)diff, 2); - } - square_sum = square_sum / count; - - return (int)(sqrt(square_sum)); -} - -void SafeOpenUrl(const std::wstring &url, int show_cmd) -{ - std::wstring url_temp = url; - std::wstring url_trim = nbase::StringTrimLeft(url_temp.c_str()); - url_trim = nbase::StringTrimRight(url_trim.c_str()); - HINSTANCE result = ::ShellExecute(NULL, _T("open"), url_trim.c_str(), NULL, NULL, show_cmd); - if ((DWORD)result <= 32) - { - ::ShellExecute(NULL, _T("open"), _T("IEXPLORE.EXE"), url_trim.c_str(), NULL, show_cmd); - } -} - -void SafeOpenUrlEx(const std::string &url, int show_cmd) -{ - std::string url_temp = url; - std::wstring open_url = nbase::UTF8ToUTF16(url_temp); - SafeOpenUrl(open_url, show_cmd); -} - -bool RunAppWithRedirection(const std::wstring &app_path, const std::wstring &app_cmd, std::string &output) -{ - SECURITY_ATTRIBUTES sa; - sa.nLength = sizeof(SECURITY_ATTRIBUTES); - sa.lpSecurityDescriptor = NULL; - sa.bInheritHandle = TRUE; - - // ChildIn_Write是子进程的输入句柄,ChildIn_Read是父进程用于写入子进程输入的句柄 - // ChildOut_Write是子进程的输出句柄,ChildOut_Read是父进程用于读取子进程输出的句柄 - HANDLE child_in_read = NULL; - HANDLE child_in_write = NULL; - HANDLE child_out_read = NULL; - HANDLE child_out_write = NULL; - BOOL ret1 = CreatePipe(&child_in_read, &child_in_write, &sa, 0); - BOOL ret2 = SetHandleInformation(child_in_write, HANDLE_FLAG_INHERIT, 0); - BOOL ret3 = CreatePipe(&child_out_read, &child_out_write, &sa, 0); - BOOL ret4 = SetHandleInformation(child_out_read, HANDLE_FLAG_INHERIT, 0); - - if (!ret1 || !ret2 || !ret3 || !ret4) - { - ::CloseHandle(child_in_read); - ::CloseHandle(child_in_write); - ::CloseHandle(child_out_read); - ::CloseHandle(child_out_write); - return false; - } - - STARTUPINFO si = {0}; - si.cb = sizeof(STARTUPINFO); - si.hStdError = child_out_write; - si.hStdOutput = child_out_write; - si.hStdInput = child_in_read; - si.dwFlags |= STARTF_USESTDHANDLES; - PROCESS_INFORMATION pi; - - if (!CreateProcess(app_path.c_str(), (LPWSTR)app_cmd.c_str(), NULL, NULL, TRUE, - CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) - { - ::CloseHandle(child_in_read); - ::CloseHandle(child_in_write); - ::CloseHandle(child_out_read); - ::CloseHandle(child_out_write); - return false; - } - ::CloseHandle(child_in_write); - ::CloseHandle(child_out_write); - - output.clear(); - while (true) - { - char buf[32 * 1024] = {0}; - DWORD len; - if (::ReadFile(child_out_read, buf, 32 * 1024, &len, NULL) == FALSE) - break; - output.append(buf, len); - } - ::CloseHandle(child_in_read); - ::CloseHandle(child_out_read); - - return true; -} - -std::string GenerateTimeStamp() -{ - nbase::TimeDelta time_delta = nbase::TimeDelta::FromMicroseconds(nbase::Time::Now().ToInternalValue()); - std::string ret = nbase::StringPrintf("%I64u",time_delta.ToMilliseconds()); - return ret; -} - -BOOL DllRegisterServer(LPCTSTR lpszFileName, BOOL bUnregister) -{ - typedef HRESULT (WINAPI * FREG)(); - - HMODULE hDLL = ::LoadLibrary(lpszFileName); - if (NULL == hDLL) - return FALSE; - - CHAR * lpszFuncName; - if (!bUnregister) - lpszFuncName = "DllRegisterServer"; - else - lpszFuncName = "DllUnregisterServer"; - - BOOL bRet = FALSE; - FREG lpfunc = (FREG)::GetProcAddress(hDLL, lpszFuncName); - if (lpfunc != NULL) - { - lpfunc(); - bRet = TRUE; - } - - ::FreeLibrary(hDLL); - - return bRet; -} - -BOOL DllRegisterServer(LPCTSTR lpszFileName) -{ - return DllRegisterServer(lpszFileName, FALSE); -} - -BOOL DllUnregisterServer(LPCTSTR lpszFileName) -{ - return DllRegisterServer(lpszFileName, TRUE); -} - -void RegisterShowWndForgroudMessage() -{ - g_show_wnd_forgroud_message = ::RegisterWindowMessage(KShowWndForgroudMessageID); -} - -UINT GetShowWndForgroudMessageID() -{ - return g_show_wnd_forgroud_message; -} - -bool GetImageCLSID(const wchar_t* format, CLSID* pCLSID) -{ - UINT num = 0; - UINT size = 0; - Gdiplus::ImageCodecInfo* pImageCodecInfo = NULL; - Gdiplus::GetImageEncodersSize(&num, &size); - - if (size == 0) - return false; - - pImageCodecInfo = (Gdiplus::ImageCodecInfo*)(malloc(size)); - if(pImageCodecInfo == NULL) - return false; - Gdiplus::GetImageEncoders(num, size, pImageCodecInfo); - - for (UINT i = 0; i < num; ++i) - { - if( wcscmp(pImageCodecInfo[i].MimeType, format) == 0 ) - { - *pCLSID = pImageCodecInfo[i].Clsid; - free(pImageCodecInfo); - return true; - } - } - free(pImageCodecInfo); - - return false; -} - -void File::GetFolder( const std::wstring &dir, StringVector &out, bool full_path /*= false*/ ) -{ - std::wstring path = dir + L"\\*.*"; - - WIN32_FIND_DATAW fd; - HANDLE hFind = ::FindFirstFileW(path.c_str(), &fd); - - DWORD attr = 0; - while(hFind != INVALID_HANDLE_VALUE) - { - attr = fd.dwFileAttributes; - if(attr & FILE_ATTRIBUTE_HIDDEN) { - } - else if(attr & FILE_ATTRIBUTE_DIRECTORY) - { - wchar_t* name = fd.cFileName; - if( wcscmp(name, L".") == 0 || wcscmp(name, L"..") == 0 ){ - } - else - { - if(full_path) - out.push_back( dir + L"\\" + name ); - else - out.push_back( name ); - } - } - - BOOL bRet = ::FindNextFileW(hFind, &fd); - if(!bRet) - break; - } - - ::FindClose(hFind); -} - -void File::GetFile( const std::wstring &dir, std::vector &out, bool full_path /*= false*/ ) -{ - std::wstring path = dir + L"\\*.*"; - - WIN32_FIND_DATAW fd; - HANDLE hFind = ::FindFirstFileW(path.c_str(), &fd); - - DWORD attr = 0; - while(hFind != INVALID_HANDLE_VALUE) - { - attr = fd.dwFileAttributes; - if(attr & FILE_ATTRIBUTE_HIDDEN || attr & FILE_ATTRIBUTE_DIRECTORY){ - } - else - { - FileItem fi = { fd.cFileName, fd.nFileSizeLow }; - if(full_path) - fi.file_ = dir + L"\\" + fd.cFileName; - out.push_back(fi); - } - - BOOL bRet = ::FindNextFileW(hFind, &fd); - if(!bRet) - break; - } - - ::FindClose(hFind); -} - - -}//namespace tools -}//namespace shared \ No newline at end of file diff --git a/tool_kits/shared/tool.h b/tool_kits/shared/tool.h deleted file mode 100644 index 3a2f33c5..00000000 --- a/tool_kits/shared/tool.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef SHARED_TOOL_H_ -#define SHARED_TOOL_H_ - -#include -#include -#include "base/time/time.h" -#include "base/base_types.h" - -namespace shared -{ -namespace tools -{ -// ϵͳ -int GetOSVersion(); -std::string GetOSVersionString(); -bool IsWow64(); - -// ַ -std::string FormatTime(nbase::Time::TimeStruct t); -std::wstring FormatBytes(double bytes); -std::wstring FormatBps(double bytes); -void SplitString(const std::string &str, const std::string &seperator, std::vector &array); -void SplitString(const std::wstring &str, const std::wstring &seperator, std::vector &array); -std::string StringReverse(const std::string &input); - -// ޷ʾıַ -std::string FilterUCS4(const std::string& str, bool replace_spaces = true); - -// ʽSQLַת嵥ţִSQL׳쳣 -UTF8String FormatSQLText(const UTF8String &sql_text); - -// ܷ񷢶 -bool IsChinaPhoneNumber(const std::string &str); -bool IsAuthCode(const std::string &str); - -// ļ -std::wstring GetSpecialFolder(int id); -std::wstring GetResourcePath(void); -void MakeExtendPath(std::wstring &path); -void ClearFile(const wchar_t *path, long file_length_limit); -bool FilePathIsExist(const std::string &utf8_filepath_in, bool is_directory); - -// õݹķʽָĿµļ -bool FindFile(const std::wstring &dir,const std::wstring &file_desc,std::wstring &file_path); -std::wstring EnsureValidFileName(const std::wstring &file_name, const std::wstring &find = L"\\/:*?\"<>|", const std::wstring &replace = L"_"); - -// ѧ -int CalcAvg(const std::vector &vec, bool is_revise = true); -int CalcStDev(const std::vector &vec); - -// ַ -void SafeOpenUrl(const std::wstring &url, int show_cmd); -void SafeOpenUrlEx(const std::string &url, int show_cmd); - -bool RestartComputer(); -bool RunAppWithRedirection(const std::wstring &app_path, const std::wstring &app_cmd, std::string &output); - -// ʱȺ -std::string GenerateTimeStamp(); - -// Register Server -BOOL DllRegisterServer(LPCTSTR lpszFileName); -BOOL DllUnregisterServer(LPCTSTR lpszFileName); - -// ͨmessage -void RegisterShowWndForgroudMessage(); -UINT GetShowWndForgroudMessageID(); - -// ȡͼƬͶӦCLSID -bool GetImageCLSID(const wchar_t* format, CLSID* pCLSID); - -// ļµļ޵һ㣩 -struct FileItem -{ - std::wstring file_; - long size_; -}; - -typedef std::vector StringVector; -typedef std::vector FileItemVector; - -class File -{ -public: - //dirҪ"\\" - static void GetFolder(const std::wstring &dir, StringVector &out, bool full_path = false); - //dirҪ"\\" - static void GetFile(const std::wstring &dir, std::vector &out, bool full_path = false); -}; - -}//namespace tools -}//namespace shared - -#endif //SHARED_TOOL_H_ diff --git a/tool_kits/shared/utf8_file_util.cpp b/tool_kits/shared/utf8_file_util.cpp deleted file mode 100644 index f0a923e9..00000000 --- a/tool_kits/shared/utf8_file_util.cpp +++ /dev/null @@ -1,226 +0,0 @@ -// File operation utilities for UTF-8 encoding support -#include "stdafx.h" -#include "shared/utf8_file_util.h" - -#include "base/file/file_util.h" -#include "base/util/string_util.h" - -#ifndef OS_WIN -#error "Only used on MS-Windows" -#endif - -namespace shared -{ - -static const UTF8Char kEndChar = '\0'; -static const UTF8Char kFilePathSeparators[] = "\\/"; -static const UTF8Char kFilePathCurrentDirectory[] = "."; -static const UTF8Char kFilePathParentDirectory[] = ".."; -static const UTF8Char kFilePathExtensionSeparator = '.'; - -bool IsFilePathSeparator(const UTF8Char separator) -{ - if (separator == kEndChar) - return false; - - size_t len = sizeof(kFilePathSeparators)/sizeof(UTF8Char); - for (size_t i = 0; i < len; i++) - { - if (separator == kFilePathSeparators[i]) - return true; - } - - return false; -} - -bool IsFilePathSeparator(const UTF8String &separator) -{ - if (separator.empty()) - return false; - UTF8Char c = separator[0]; - return IsFilePathSeparator(c); -} - -bool FilePathExtension(const UTF8String &filepath_in, - UTF8String &extension_out) -{ - if (filepath_in.size() == 0) - return false; - bool ret = false; - UTF8String file_name; - if (FilePathApartFileName(filepath_in, file_name)) - { - size_t pos = file_name.rfind(kFilePathExtensionSeparator); - if (pos != UTF8String::npos) - { - extension_out = file_name.substr(pos, UTF8String::npos); - ret = true; - } - } - return ret; -} - -bool FilePathApartDirectory(const UTF8String &filepath_in, - UTF8String &directory_out) -{ - size_t index = filepath_in.size() - 1; - if (index <= 0 || filepath_in.size() == 0) - return false; - for (; index != 0; index--) - { - if (IsFilePathSeparator(filepath_in[index])) - { - if (index == filepath_in.size() - 1) - directory_out = filepath_in; - else - directory_out = filepath_in.substr(0, index + 1); - return true; - } - } - return false; -} - -// Get the filename from the whole filepath -bool FilePathApartFileName(const UTF8String &filepath_in, - UTF8String &filename_out) -{ - if (filepath_in.size() == 0) - return false; - bool ret = true; - size_t separator_pos = UTF8String::npos; - size_t separators_count = sizeof(kFilePathSeparators) / sizeof(UTF8Char); - for (size_t index = 0; index < separators_count; index++) - { - separator_pos = filepath_in.rfind(kFilePathSeparators[index]); - if (separator_pos != UTF8String::npos) - break; - } - if (separator_pos++ != UTF8String::npos && separator_pos < filepath_in.size()) - filename_out = filepath_in.substr(separator_pos); - else if (separator_pos >= filepath_in.size()) - ret = false; - else - filename_out = filepath_in; - return ret; -} - -template -bool ParsePathComponentsT(const CharType *path, - const CharType *seperators, - std::list > &components) -{ - components.clear(); - if (path == NULL) - return false; - const CharType *prev = NULL; - const CharType *next = path; - const CharType *c; - while (*next) - { - prev = next; - // find the first seperator - for (;;) - { - for (c = seperators; *c && *next != *c; c++); - if (*c || !*next) - break; - next++; - } - components.push_back(std::basic_string(prev, next - prev)); - if (*next) - components.back().push_back(*seperators); - // skip duplicated seperators - for (++next;;) - { - for (c = seperators; *c && *next != *c; c++); - if (!*c) - break; - next++; - } - } - return true; -} - -bool ParsePathComponents(const UTF8Char *path, - std::list &components) -{ - return ParsePathComponentsT(path, - kFilePathSeparators, - components); -} - -bool IsDirectoryComponent(const UTF8String &component) -{ - if (component.empty()) - return false; - return *component.rbegin() == kFilePathSeparators[0] || - *component.rbegin() == kFilePathSeparators[1]; -} - -bool FilePathCompose(const UTF8String &directory_in, - const UTF8String &filename_in, - UTF8String &filepath_out) -{ - UTF8String directory; - if (!FilePathApartDirectory(directory_in, directory)) - return false; - filepath_out = directory + filename_in; - return true; -} - -bool FilePathIsExist(const UTF8String &filepath, bool is_directory) -{ - UTF16String filepath2 = nbase::UTF8ToUTF16(filepath); - return nbase::FilePathIsExist(filepath2, is_directory); -} - -bool CreateDirectory(const UTF8String& full_path) -{ - UTF16String full_path2 = nbase::UTF8ToUTF16(full_path); - return nbase::CreateDirectory(full_path2); -} - -FILE* OpenFile(const UTF8String &filepath, const nbase::PathChar *mode) -{ - UTF16String filepath2 = nbase::UTF8ToUTF16(filepath); - return nbase::OpenFile(filepath2, mode); -} - -int ReadFile(const UTF8String &filepath, void *data_out, int size) -{ - UTF16String filepath2 = nbase::UTF8ToUTF16(filepath); - return nbase::ReadFile(filepath2, data_out, size); -} - -bool ReadFileToString(const UTF8String &filepath, std::string &contents_out) -{ - UTF16String filepath2 = nbase::UTF8ToUTF16(filepath); - return nbase::ReadFileToString(filepath2, contents_out); -} - -int WriteFile(const UTF8String &filepath, const std::string &data) -{ - UTF16String filepath2 = nbase::UTF8ToUTF16(filepath); - return nbase::WriteFile(filepath2, data); -} - -bool CopyFile(const UTF8String &from_path, const UTF8String &to_path) -{ - UTF16String from_path2 = nbase::UTF8ToUTF16(from_path); - UTF16String to_path2 = nbase::UTF8ToUTF16(to_path); - return nbase::CopyFile(from_path2, to_path2); -} - -bool DeleteFile(const UTF8String &filepath) -{ - UTF16String filepath2 = nbase::UTF8ToUTF16(filepath); - return nbase::DeleteFile(filepath2); -} - -int64_t GetFileSize(const UTF8String &filepath) -{ - UTF16String filepath2 = nbase::UTF8ToUTF16(filepath); - return nbase::GetFileSize(filepath2); -} - -} // namespace shared diff --git a/tool_kits/shared/utf8_file_util.h b/tool_kits/shared/utf8_file_util.h deleted file mode 100644 index a49655db..00000000 --- a/tool_kits/shared/utf8_file_util.h +++ /dev/null @@ -1,70 +0,0 @@ -// File operation utilities for UTF-8 encoding support - -#ifndef SHARED_UTF8_FILE_UTIL_H_ -#define SHARED_UTF8_FILE_UTIL_H_ - -#include -#include "base/util/unicode.h" -#include "base/file/file_path.h" // for PathChar - -namespace shared -{ - -// Check the character is filepath separator -bool IsFilePathSeparator(const UTF8Char separator); -bool IsFilePathSeparator(const UTF8String &separator); - -// Get the file extension from filepath -bool FilePathExtension(const UTF8String &filepath_in, - UTF8String &extension_out); - -// Get the directory from the whole filepath -bool FilePathApartDirectory(const UTF8String &filepath_in, - UTF8String &directory_out); -// Get the filename from the whole filepath -bool FilePathApartFileName(const UTF8String &filepath_in, - UTF8String &filename_out); - -// Parse and extract all components of a path -bool ParsePathComponents(const UTF8Char *PathChar, - std::list &components); - -// Check if |component| is a directory -bool IsDirectoryComponent(const UTF8String &component); - -// Compose the filepath from directory and filename -bool FilePathCompose(const UTF8String &directory_in, - const UTF8String &filename_in, - UTF8String &filepath_out); - -// Check the filepath is exist -// If |is_directory| is true, check a directory, or check the path -bool FilePathIsExist(const UTF8String &filepath_in, bool is_directory); - -// Create a directory, all subdirs will be created if not existing -bool CreateDirectory(const UTF8String& full_path); - -// Wrapper for fopen-like calls. Returns non-NULL FILE* on success -FILE* OpenFile(const UTF8String &filepath, const nbase::PathChar *mode); - -// Reads the given number of bytes from the file into the buffer -int ReadFile(const UTF8String &filepath, void *data_out, int size); - -// Read the file at |path| into |contents|, returning true on success. -bool ReadFileToString(const UTF8String &filepath, std::string &contents_out); - -// Writes the content of given buffer into the file -int WriteFile(const UTF8String &filepath, const std::string &data); - -// Copies a single file. -bool CopyFile(const UTF8String &from_path, const UTF8String &to_path); - -// Deletes the given path. -bool DeleteFile(const UTF8String &filepath); - -// Get file size. -int64_t GetFileSize(const UTF8String &filepath); - -} // namespace shared - -#endif // SHARED_UTF8_FILE_UTIL_H_ diff --git a/tool_kits/shared/util.cpp b/tool_kits/shared/util.cpp deleted file mode 100644 index 10447110..00000000 --- a/tool_kits/shared/util.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "stdafx.h" -#include "util.h" -#include "shared/log.h" -#include "shellapi.h" - -std::wstring QPath::GetAppPath() -{ - return nbase::win32::GetCurrentModuleDirectory(); -} - -void QPath::AddNewEnvironment(const std::wstring& directory) -{ - TCHAR path_environment[4096]; - GetEnvironmentVariable(L"PATH", path_environment, 4096); - std::wstring new_path = directory + L";"; - std::wstring new_environment = new_path + path_environment; - SetEnvironmentVariable(L"PATH", new_environment.c_str()); -} - -// -std::map QCommand::key_value_; - -void QCommand::ParseCommand( const std::wstring &cmd ) -{ - std::list arrays = ui::StringHelper::Split(cmd, L"/"); - for(std::list::const_iterator i = arrays.begin(); i != arrays.end(); i++) - { - std::list object = ui::StringHelper::Split(*i, L" "); - assert(object.size() == 2); - key_value_[ *object.begin() ] = *object.rbegin(); - } -} - -std::wstring QCommand::Get( const std::wstring &key ) -{ - std::map::const_iterator i = key_value_.find(key); - if(i == key_value_.end()) - return L""; - else - return i->second; -} - -void QCommand::Set( const std::wstring &key, const std::wstring &value ) -{ - key_value_[key] = value; -} - -void QCommand::Erase(const std::wstring &key) -{ - key_value_.erase(key); -} - -bool QCommand::AppStartWidthCommand( const std::wstring &app, const std::wstring &cmd ) -{ - HINSTANCE hInst = ::ShellExecuteW(NULL, L"open", app.c_str(), cmd.c_str(), NULL, SW_SHOWNORMAL); - return (int)hInst > 32; -} - -bool QCommand::RestartApp(const std::wstring &cmd) -{ - wchar_t app[1024] = { 0 }; - GetModuleFileName(NULL, app, 1024); - HINSTANCE hInst = ::ShellExecuteW(NULL, L"open", app, cmd.c_str(), NULL, SW_SHOWNORMAL); - return (int)hInst > 32; -} \ No newline at end of file diff --git a/tool_kits/shared/util.h b/tool_kits/shared/util.h deleted file mode 100644 index 798d947d..00000000 --- a/tool_kits/shared/util.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -#include -#include - -class QString -{ -public: -}; - -class QPath -{ -public: - /** - * @brief ȡ exe Ŀ¼ - * @return exe Ŀ¼βб - */ - static std::wstring GetAppPath(); - - /** - * @brief һĿ¼ִгĻ - * @param[in] directory ҪӵĿ¼ - * @return - */ - static void AddNewEnvironment(const std::wstring& directory); -}; - -class QCommand -{ -public: - static void ParseCommand(const std::wstring &cmd); - static bool AppStartWidthCommand(const std::wstring &app, const std::wstring &cmd); - static bool RestartApp(const std::wstring &cmd); - static std::wstring Get(const std::wstring &key); - static void Set(const std::wstring &key, const std::wstring &value); - static void Erase(const std::wstring &key); -private: - static std::map key_value_; -}; \ No newline at end of file diff --git a/tool_kits/shared/xml_util.cpp b/tool_kits/shared/xml_util.cpp deleted file mode 100644 index a3fc4c0d..00000000 --- a/tool_kits/shared/xml_util.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2013, NetEase Inc. All rights reserved. -// -// wrt(guangguang) -// 2013/8/28 -// -// Xml document utilities -#include "stdafx.h" -#include "shared/xml_util.h" - -#include -#include -#include "base/memory/deleter.h" - -namespace shared -{ - -bool LoadXmlFromFile(TiXmlDocument &xml, const std::wstring &file_path) -{ - std::unique_ptr fp; - FILE* fp_file = nullptr; - if (_wfopen_s(&fp_file, file_path.c_str(), L"rb") != 0) { - return false; - } - fp.reset(fp_file); - if (!fp) { - return false; - } - if (!xml.LoadFile(fp.get())) { - return false; - } - return true; -} - -} \ No newline at end of file diff --git a/tool_kits/shared/xml_util.h b/tool_kits/shared/xml_util.h deleted file mode 100644 index 350faa2e..00000000 --- a/tool_kits/shared/xml_util.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2013, NetEase Inc. All rights reserved. -// -// wrt(guangguang) -// 2013/8/28 -// -// Xml document utilities - -#ifndef SHARED_XML_UTIL_H_ -#define SHARED_XML_UTIL_H_ - -#include -#include "third_party/tinyxml/tinyxml.h" - -namespace shared -{ - -bool LoadXmlFromFile(TiXmlDocument &xml, const std::wstring &file_path); - -} - - -#endif // SHARED_XML_UTIL_H_ diff --git a/tool_kits/shared/zoom_image.cpp b/tool_kits/shared/zoom_image.cpp deleted file mode 100644 index a2ee912d..00000000 --- a/tool_kits/shared/zoom_image.cpp +++ /dev/null @@ -1,455 +0,0 @@ -#include "stdafx.h" -#include "zoom_image.h" - -using namespace Gdiplus; - -ZoomImage::ZoomImage(void):width_(0),height_(0),ratio_(0),zoom_type_(by_none),area_zoom_(false) - ,auto_max_width_(1280),auto_max_height_(1280) -{ -} - - -ZoomImage::~ZoomImage(void) -{ -} - -void ZoomImage::SetImagePath(const std::wstring &image_path) -{ - image_path_ = image_path; -} - -void ZoomImage::SetAutoZoom(bool area_zoom,int auto_max_with,int auto_max_height) -{ - area_zoom_ = area_zoom; - auto_max_width_ = auto_max_with; - auto_max_height_ = auto_max_height; - zoom_type_ = by_auto; -} - -void ZoomImage::SetSize(int width,int height) -{ - width_ = width; - height_ = height; - zoom_type_ = by_fixed_size; - -} - -void ZoomImage::SetRatio(float ratio) -{ - ratio_ = ratio; - zoom_type_ = by_ratio; -} - -bool ZoomImage::Zoom(const std::wstring &filepath,std::wstring mime_type) -{ - if( !nbase::FilePathIsExist(filepath, false) ) - { - assert(0); - return false; - } - - if (zoom_type_ == by_none) - return false; - if (zoom_type_ == by_fixed_size && (width_ <= 0 ||height_ <= 0)) - return false; - if (zoom_type_ == by_ratio && ratio_ <= 0.0000001) - return false; - - Image image_src(filepath.c_str()); - if (image_src.GetLastStatus() != Ok) - return false; - GUID guid; - if (image_src.GetRawFormat(&guid) != Ok) - return false; - if (guid == ImageFormatGIF) //֧GIFļ; - return false; - - RotateFlipType type = GetRotateFlipType(image_src); - if (type != RotateNoneFlipNone) - image_src.RotateFlip(type); - - if (!IsNeedZoom(image_src.GetWidth(),image_src.GetHeight())) - return false; - - CalculateSize(image_src.GetWidth(),image_src.GetHeight()); - Bitmap canvas(width_,height_); - Graphics graphics(&canvas); - RectF rf(0.0f, 0.0f, (REAL)width_, (REAL)height_); - - graphics.SetSmoothingMode(SmoothingModeAntiAlias); -#if (GDIPVER >= 0x0110) - graphics.SetSmoothingMode(SmoothingModeAntiAlias8x8); -#endif - graphics.SetCompositingMode(CompositingModeSourceOver); - graphics.SetInterpolationMode(InterpolationModeHighQualityBicubic); - graphics.SetPixelOffsetMode(PixelOffsetModeHighQuality); - - if (Ok != graphics.DrawImage(&image_src,rf)) - { - int err = graphics.GetLastStatus(); - QLOG_APP(L"ZoomImage Error: {0}")< 1.0000000) - ret = true; - break; - case by_auto: - { - if (area_zoom_) - { - if (width * height> auto_max_width_ * auto_max_height_) - ret = true; - } - else - { - if (width > auto_max_width_ || height > auto_max_height_) - ret = true; - } - - } - - break; - default: - break; - } - - return ret; -} - -bool ZoomImage::CalculateSize(int width_src,int height_src) -{ - if (zoom_type_ == by_ratio) - { - width_ = (int) (width_src * ratio_); - height_ = (int) (height_src * ratio_); - } - else if (zoom_type_ == by_auto) - { - if (area_zoom_) - { - width_ = (int) ( sqrtf(auto_max_width_* (float)auto_max_height_*(float)width_src/height_src) ); - height_ = (int) ( sqrtf(auto_max_width_* (float)auto_max_height_*(float)height_src/width_src) ); - } - else - { - - float ratio = min((float)auto_max_width_/(float)width_src,(float)auto_max_height_/(float)height_src); - - width_ = (int) (width_src * ratio); - height_ = (int) (height_src * ratio); - } - } - return true; -} - -bool ZoomImage::SavePaddingImage(const std::wstring& image_path, const std::wstring& image_path_out, int width, int height, std::wstring mime_type) -{ - bool ret = false; - if (image_path.empty()) - { - return false; - } - Gdiplus::Image image_src(image_path.c_str()); - if (image_src.GetLastStatus() != Gdiplus::Ok) - { - return false; - } - Gdiplus::REAL width_src = (REAL) image_src.GetWidth(); - Gdiplus::REAL height_src = (REAL) image_src.GetHeight(); - if (width_src > 0 && height_src > 0) - { - int fixed_w = width; - int fixed_h = height; - if (fixed_h > 0 && fixed_w > 0) - { - Gdiplus::REAL left = 0; - Gdiplus::REAL top = 0; - if (width_src * fixed_h > height_src * fixed_w) - { - left = width_src - (height_src * fixed_w / fixed_h); - width_src -= left; - left /= 2; - } - else - { - top = height_src - (width_src * fixed_h / fixed_w); - height_src -= top; - top /= 2; - } - - HDC hdc = ::GetDC(NULL); - HDC hMemDC = CreateCompatibleDC(hdc); - HBITMAP hbmp = CreateCompatibleBitmap(hdc, fixed_w, fixed_h); - HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, hbmp); - Gdiplus::Graphics graphics(hMemDC); - Gdiplus::RectF rectf(0.0f, 0.0f, (REAL)fixed_w, (REAL)fixed_h); - graphics.DrawImage(&image_src, rectf, left, top, width_src, height_src, Gdiplus::UnitPixel); - hbmp = (HBITMAP)SelectObject(hMemDC, hOldBitmap); - // - DeleteDC(hMemDC); - ::ReleaseDC(NULL, hdc); - Gdiplus::Bitmap bmp(hbmp, NULL); - ret = SaveImage(bmp, image_path_out, mime_type, 100); - DeleteObject(hbmp); - } - } - return ret; -} - -bool ZoomImage::GetImageCLSID(const wchar_t* format, CLSID* pCLSID) -{ - UINT num = 0; - UINT size = 0; - ImageCodecInfo* pImageCodecInfo = NULL; - GetImageEncodersSize(&num, &size); - - if (size == 0) - return false; - - pImageCodecInfo = (ImageCodecInfo*)(malloc(size)); - if(pImageCodecInfo == NULL) - return false; - GetImageEncoders(num, size, pImageCodecInfo); - - for (UINT i = 0; i < num; ++i) - { - if ( wcscmp(pImageCodecInfo[i].MimeType, format) == 0 ) - { - *pCLSID = pImageCodecInfo[i].Clsid; - free(pImageCodecInfo); - return true; - } - } - free(pImageCodecInfo); - - return false; -} - -bool ZoomImage::ConvertImageFormat(std::wstring& filepath,std::wstring mime_type) -{ - if( !nbase::FilePathIsExist(filepath, false) ) - { - assert(0); - return false; - } - - Image image(filepath.c_str()); - if (image.GetLastStatus() != Ok) - { - ASSERT(0); - return false; - } - return SaveImage(image,image_path_,mime_type); -} - -bool ZoomImage::SaveImage(Gdiplus::Image& image, const std::wstring& file_path,std::wstring mime_type,long quality_num/* = 90*/) -{ - CLSID clsid; - if (!GetImageCLSID(mime_type.c_str(),&clsid)) - return false; - - EncoderParameters encoder_paramters; - encoder_paramters.Count = 1; - encoder_paramters.Parameter[0].Guid = EncoderQuality; - encoder_paramters.Parameter[0].NumberOfValues = 1; - encoder_paramters.Parameter[0].Type = EncoderParameterValueTypeLong; - encoder_paramters.Parameter[0].Value = (void*)&quality_num; - Status status = image.Save(file_path.c_str(),&clsid,&encoder_paramters); - if (status != Ok) - { - int err = status; - QLOG_APP(L"SaveImage Error: {0}")< 0) - { - PropertyItem *property_item = (PropertyItem*) malloc( nSize ); - if (image.GetPropertyItem( PropertyTagOrientation, nSize, property_item ) == Ok) - { - orientation = *(short*)property_item->value; - } - - free(property_item); - } - return GetRotateFlipType(orientation); -} - -Gdiplus::RotateFlipType ZoomImage::GetRotateFlipType(short orientation) -{ - RotateFlipType type = RotateNoneFlipNone; - switch(orientation) - { - case 1: - break; - case 2: - type = RotateNoneFlipX; - break; - case 3: - type = RotateNoneFlipXY; - break; - case 4: - type = RotateNoneFlipY; - break; - case 5: - type = Rotate90FlipX; - break; - case 6: - type = Rotate90FlipNone; - break; - case 7: - type = Rotate90FlipY; - break; - case 8: - type = Rotate270FlipNone; - break; - default: - break; - } - return type; -} - -void ZoomImage::GetMimeType(const std::wstring& filepath, std::wstring& mime_type_out, std::wstring& exten_out) -{ - if (filepath.empty()) - { - return; - } - Image image_src(filepath.c_str()); - if (image_src.GetLastStatus() != Ok) - { - return; - } - GUID guid; - if (image_src.GetRawFormat(&guid) != Ok) - { - return; - } - mime_type_out = GetMimeType(guid); - if (mime_type_out.empty()) - { - return; - } - if (mime_type_out == kImageGIF) - { - exten_out = L".gif"; - } - else if (mime_type_out == kImageJPEG) - { - exten_out = L".jpg"; - } - else if (mime_type_out == kImagePNG) - { - exten_out = L".png"; - } - else if (mime_type_out == kImageBMP) - { - exten_out = L".bmp"; - } -} - -std::wstring ZoomImage::GetMimeType(const std::wstring& filepath) -{ - if (filepath.empty()) - return L""; - Image image_src(filepath.c_str()); - Gdiplus::Status status = image_src.GetLastStatus(); - if(status != Ok) - { - QLOG_ERR(L"Image {0} error {1}") < img; - img.reset( Gdiplus::Image::FromFile( file.c_str() ) ); - if(img.get() != NULL) - { - Gdiplus::RotateFlipType type = ZoomImage::GetRotateFlipType(*img); - if (type != RotateNoneFlipNone) //תͼƬ; - img->RotateFlip(type); - - size.cx = img->GetWidth(); - size.cy = img->GetHeight(); - if (size.cx == 0 || size.cy == 0) - { - size.cx = max_width; - size.cy = (int) (size.cx * 0.618); - need_resize = true; - } - else - { - if (size.cx > max_width || size.cy > max_height) - { - float index_x = (float)max_width / (float)size.cx; - float index_y = (float)max_height / (float)size.cy; - float index = min(index_x, index_y); - size.cx = (int)(size.cx * index); - size.cy = (int)(size.cy * index); - need_resize = true; - } - } - } - } - else - { - assert(0); - } - return need_resize; -} - -void ZoomImageF( const std::wstring &src, const std::wstring &dest, int cx, int cy ) -{ - ZoomImage zoom; - zoom.SetImagePath(dest); - zoom.SetSize(cx, cy); - zoom.Zoom(src); -} diff --git a/tool_kits/shared/zoom_image.h b/tool_kits/shared/zoom_image.h deleted file mode 100644 index 74250696..00000000 --- a/tool_kits/shared/zoom_image.h +++ /dev/null @@ -1,86 +0,0 @@ -#pragma once -//#include "util.h" -#include "log.h" -#include -#include - -static const std::wstring kImageJPEG = L"image/jpeg"; -static const std::wstring kImagePNG = L"image/png"; -static const std::wstring kImageBMP = L"image/bmp"; -static const std::wstring kImageGIF = L"image/gif"; - - -class ZoomImage -{ -public: - ZoomImage(void); - ~ZoomImage(void); - //źͼƬ· - void SetImagePath(const std::wstring &image_path); - //ΪԶģʽ - void SetAutoZoom(bool area_zoom,int auto_max_with,int auto_max_height); - //Ϊ̶Сģʽ - void SetSize(int width,int height); - //Ϊģʽ - void SetRatio(float ratio); - - /* - * @brief ijһͼƬ浽Ϊָʽ - * @param filepath:ҪŵԴͼƬ· - * @param mime_type:ͼƬ - */ - bool Zoom(const std::wstring& filepath,std::wstring mime_type=L"image/jpeg"); - //ͼƬΪָͣͼƬ - bool ConvertImageFormat(std::wstring& filepath, std::wstring mime_type); - //ȡͼķת - static Gdiplus::RotateFlipType GetRotateFlipType(Gdiplus::Image& image); - static std::wstring GetMimeType(const std::wstring& filepath); - static void GetMimeType(const std::wstring& filepath, std::wstring& mime_type_out, std::wstring& exten_out); - /* - * @brief widthheightıȡԴͼƬͬΧͼƬ֣浽Ϊָʽ - * @param filepath:ԴͼƬ· - * @param image_path_out:ͼƬ· - * @param width:ҪŵԴͼƬ· - * @param height:ҪŵԴͼƬ· - * @param mime_type:ͼƬ - */ - static bool SavePaddingImage(const std::wstring& image_path, const std::wstring& image_path_out, int width, int height, std::wstring mime_type = L"image/jpeg"); - -protected: - //жǷҪ - bool IsNeedZoom(int width,int height); - //źĴС浽width_height_ - bool CalculateSize(int width_src,int height_src); - static bool GetImageCLSID(const wchar_t* format, CLSID* pCLSID); - static bool SaveImage(Gdiplus::Image& image, const std::wstring& file_path,std::wstring mime_type,long quality_num = 95); - static Gdiplus::RotateFlipType GetRotateFlipType(short orientation); - static std::wstring GetMimeType(GUID& clsid); - -private: - enum ZoomType - { - by_fixed_size = 0, - by_ratio, - by_auto,by_none - };//by_fixed_size:̶ߴ,by_ratio:; - - std::wstring file_path_save_; - ZoomType zoom_type_; - - bool area_zoom_; //Ƿwidth*height; - int auto_max_width_; - int auto_max_height_; - - int width_; - int height_; - - float ratio_; - - std::wstring image_path_; -}; - -//ͼmax_width * max_height£ֵΪtrueʾҪüͬʱͼƬsize -bool CalculateImageSize(const std::wstring& file, SIZE& size, int max_width, int max_height); - -//ͼСcx * cy -void ZoomImageF(const std::wstring &src, const std::wstring &dest, int cx, int cy); \ No newline at end of file diff --git a/tool_kits/ui_components/cef_control/app/cef_js_bridge.cpp b/ui_components/cef_control/app/cef_js_bridge.cpp similarity index 98% rename from tool_kits/ui_components/cef_control/app/cef_js_bridge.cpp rename to ui_components/cef_control/app/cef_js_bridge.cpp index 860dd184..0b95d408 100644 --- a/tool_kits/ui_components/cef_control/app/cef_js_bridge.cpp +++ b/ui_components/cef_control/app/cef_js_bridge.cpp @@ -245,7 +245,7 @@ bool CefJSBridge::ExecuteCppCallbackFunc(int cpp_callback_id, const CefString& j auto callback = it->second; if (callback) { - Post2UI([=]() { callback(json_string); }); + nbase::ThreadManager::PostTask(kThreadMain, [=]() { callback(json_string); }); } // ִɺӻƳ @@ -291,7 +291,7 @@ bool CefJSBridge::ExecuteCppFunc(const CefString& function_name, const CefString if (it != browser_registered_function_.cend()) { auto function = it->second; - Post2UI([=]() { + nbase::ThreadManager::PostTask(kThreadMain, [=]() { function(params, [=](bool has_error, const std::string& json_result) { // Դ룬Ҫװ args->SetInt(0, js_callback_id); @@ -307,7 +307,7 @@ bool CefJSBridge::ExecuteCppFunc(const CefString& function_name, const CefString if (it != browser_registered_function_.cend()) { auto function = it->second; - Post2UI([=]() { + nbase::ThreadManager::PostTask(kThreadMain, [=]() { function(params, [=](bool has_error, const std::string& json_result) { // Դ룬Ҫװ args->SetInt(0, js_callback_id); diff --git a/tool_kits/ui_components/cef_control/app/cef_js_bridge.h b/ui_components/cef_control/app/cef_js_bridge.h similarity index 100% rename from tool_kits/ui_components/cef_control/app/cef_js_bridge.h rename to ui_components/cef_control/app/cef_js_bridge.h diff --git a/tool_kits/ui_components/cef_control/app/client_app.cpp b/ui_components/cef_control/app/client_app.cpp similarity index 100% rename from tool_kits/ui_components/cef_control/app/client_app.cpp rename to ui_components/cef_control/app/client_app.cpp diff --git a/tool_kits/ui_components/cef_control/app/client_app.h b/ui_components/cef_control/app/client_app.h similarity index 100% rename from tool_kits/ui_components/cef_control/app/client_app.h rename to ui_components/cef_control/app/client_app.h diff --git a/tool_kits/ui_components/cef_control/app/client_app_browser.cpp b/ui_components/cef_control/app/client_app_browser.cpp similarity index 100% rename from tool_kits/ui_components/cef_control/app/client_app_browser.cpp rename to ui_components/cef_control/app/client_app_browser.cpp diff --git a/tool_kits/ui_components/cef_control/app/client_app_render.cpp b/ui_components/cef_control/app/client_app_render.cpp similarity index 100% rename from tool_kits/ui_components/cef_control/app/client_app_render.cpp rename to ui_components/cef_control/app/client_app_render.cpp diff --git a/tool_kits/ui_components/cef_control/app/ipc_string_define.h b/ui_components/cef_control/app/ipc_string_define.h similarity index 100% rename from tool_kits/ui_components/cef_control/app/ipc_string_define.h rename to ui_components/cef_control/app/ipc_string_define.h diff --git a/tool_kits/ui_components/cef_control/app/js_handler.cpp b/ui_components/cef_control/app/js_handler.cpp similarity index 100% rename from tool_kits/ui_components/cef_control/app/js_handler.cpp rename to ui_components/cef_control/app/js_handler.cpp diff --git a/tool_kits/ui_components/cef_control/app/js_handler.h b/ui_components/cef_control/app/js_handler.h similarity index 100% rename from tool_kits/ui_components/cef_control/app/js_handler.h rename to ui_components/cef_control/app/js_handler.h diff --git a/tool_kits/ui_components/cef_control/control/cef_control.cpp b/ui_components/cef_control/control/cef_control.cpp similarity index 100% rename from tool_kits/ui_components/cef_control/control/cef_control.cpp rename to ui_components/cef_control/control/cef_control.cpp diff --git a/tool_kits/ui_components/cef_control/control/cef_control.h b/ui_components/cef_control/control/cef_control.h similarity index 100% rename from tool_kits/ui_components/cef_control/control/cef_control.h rename to ui_components/cef_control/control/cef_control.h diff --git a/tool_kits/ui_components/cef_control/control/cef_control_base.cpp b/ui_components/cef_control/control/cef_control_base.cpp similarity index 100% rename from tool_kits/ui_components/cef_control/control/cef_control_base.cpp rename to ui_components/cef_control/control/cef_control_base.cpp diff --git a/tool_kits/ui_components/cef_control/control/cef_control_base.h b/ui_components/cef_control/control/cef_control_base.h similarity index 100% rename from tool_kits/ui_components/cef_control/control/cef_control_base.h rename to ui_components/cef_control/control/cef_control_base.h diff --git a/tool_kits/ui_components/cef_control/control/cef_control_base_ui.cpp b/ui_components/cef_control/control/cef_control_base_ui.cpp similarity index 97% rename from tool_kits/ui_components/cef_control/control/cef_control_base_ui.cpp rename to ui_components/cef_control/control/cef_control_base_ui.cpp index aeccb098..fc324801 100644 --- a/tool_kits/ui_components/cef_control/control/cef_control_base_ui.cpp +++ b/ui_components/cef_control/control/cef_control_base_ui.cpp @@ -206,7 +206,6 @@ bool CefControlBase::CallJSFunction(const std::wstring& js_function_name, const if (!js_bridge_->CallJSFunction(nbase::UTF16ToUTF8(js_function_name).c_str(), nbase::UTF16ToUTF8(params).c_str(), frame, callback)) { - QLOG_ERR(L"Failed to call JavaScript function {0}") << js_function_name; return false; } @@ -225,7 +224,6 @@ bool CefControlBase::CallJSFunction(const std::wstring& js_function_name, const if (!js_bridge_->CallJSFunction(nbase::UTF16ToUTF8(js_function_name).c_str(), nbase::UTF16ToUTF8(params).c_str(), frame, callback)) { - QLOG_ERR(L"Failed to call JavaScript function {0}") << js_function_name; return false; } diff --git a/tool_kits/ui_components/cef_control/control/cef_control_event.h b/ui_components/cef_control/control/cef_control_event.h similarity index 100% rename from tool_kits/ui_components/cef_control/control/cef_control_event.h rename to ui_components/cef_control/control/cef_control_event.h diff --git a/tool_kits/ui_components/cef_control/control/cef_control_ui.cpp b/ui_components/cef_control/control/cef_control_ui.cpp similarity index 99% rename from tool_kits/ui_components/cef_control/control/cef_control_ui.cpp rename to ui_components/cef_control/control/cef_control_ui.cpp index a50c59d4..b38be90c 100644 --- a/tool_kits/ui_components/cef_control/control/cef_control_ui.cpp +++ b/ui_components/cef_control/control/cef_control_ui.cpp @@ -280,7 +280,7 @@ bool CefControl::AttachDevTools(Control* control) { auto weak = view->GetWeakFlag(); auto task = [this, weak, view](){ - nbase::ThreadManager::PostTask(ThreadId::kThreadUI, ToWeakCallback([this, weak, view](){ + nbase::ThreadManager::PostTask(kThreadMain, ToWeakCallback([this, weak, view](){ if (weak.expired()) return; AttachDevTools(view); diff --git a/tool_kits/ui_components/cef_control/control/cef_native_control.cpp b/ui_components/cef_control/control/cef_native_control.cpp similarity index 98% rename from tool_kits/ui_components/cef_control/control/cef_native_control.cpp rename to ui_components/cef_control/control/cef_native_control.cpp index 653e584e..305c41fc 100644 --- a/tool_kits/ui_components/cef_control/control/cef_native_control.cpp +++ b/ui_components/cef_control/control/cef_native_control.cpp @@ -151,7 +151,7 @@ bool CefNativeControl::AttachDevTools(Control* /*view*/) { auto task = ToWeakCallback([this]() { - nbase::ThreadManager::PostTask(ThreadId::kThreadUI, ToWeakCallback([this](){ + nbase::ThreadManager::PostTask(kThreadMain, ToWeakCallback([this](){ AttachDevTools(nullptr); })); }); diff --git a/tool_kits/ui_components/cef_control/control/cef_native_control.h b/ui_components/cef_control/control/cef_native_control.h similarity index 100% rename from tool_kits/ui_components/cef_control/control/cef_native_control.h rename to ui_components/cef_control/control/cef_native_control.h diff --git a/tool_kits/ui_components/cef_control/handler/browser_handler.cpp b/ui_components/cef_control/handler/browser_handler.cpp similarity index 89% rename from tool_kits/ui_components/cef_control/handler/browser_handler.cpp rename to ui_components/cef_control/handler/browser_handler.cpp index b5996e93..5c30169d 100644 --- a/tool_kits/ui_components/cef_control/handler/browser_handler.cpp +++ b/ui_components/cef_control/handler/browser_handler.cpp @@ -135,7 +135,7 @@ bool BrowserHandler::OnBeforePopup(CefRefPtr browser, void BrowserHandler::OnAfterCreated(CefRefPtr browser) { REQUIRE_UI_THREAD(); - nbase::ThreadManager::PostTask(kThreadUI, ToWeakCallback([this, browser](){ + nbase::ThreadManager::PostTask(kThreadMain, ToWeakCallback([this, browser](){ browser_list_.emplace_back(browser); if (browser_ != nullptr) browser_->GetHost()->WasHidden(true); @@ -167,7 +167,7 @@ bool BrowserHandler::DoClose(CefRefPtr browser) void BrowserHandler::OnBeforeClose(CefRefPtr browser) { REQUIRE_UI_THREAD(); - nbase::ThreadManager::PostTask(kThreadUI, ToWeakCallback([this, browser](){ + nbase::ThreadManager::PostTask(kThreadMain, ToWeakCallback([this, browser](){ CefManager::GetInstance()->SubBrowserCount(); auto it = std::find_if(browser_list_.begin(), browser_list_.end(), [&](const CefRefPtr& item){ return item->IsSame(browser); @@ -248,13 +248,13 @@ bool BrowserHandler::GetScreenPoint(CefRefPtr browser, int viewX, in void BrowserHandler::OnPopupShow(CefRefPtr browser, bool show) { if (handle_delegate_) - nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnPopupShow, handle_delegate_, browser, show)); + nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnPopupShow, handle_delegate_, browser, show)); } void BrowserHandler::OnPopupSize(CefRefPtr browser, const CefRect& rect) { if (handle_delegate_) - nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnPopupSize, handle_delegate_, browser, rect)); + nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnPopupSize, handle_delegate_, browser, rect)); } void BrowserHandler::OnPaint(CefRefPtr browser, @@ -273,7 +273,7 @@ void BrowserHandler::OnPaint(CefRefPtr browser, paint_buffer_.resize(buffer_length + 1); memcpy(&paint_buffer_[0], (char*)buffer, width * height * 4); - nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnPaint, handle_delegate_, browser, type, dirtyRects, &paint_buffer_, width, height)); + nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnPaint, handle_delegate_, browser, type, dirtyRects, &paint_buffer_, width, height)); } } @@ -338,14 +338,14 @@ void BrowserHandler::OnAddressChange(CefRefPtr browser, CefRefPtr browser, const CefString& title) { // Update the browser window title... if (handle_delegate_) - nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnTitleChange, handle_delegate_, browser, title)); + nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnTitleChange, handle_delegate_, browser, title)); } bool BrowserHandler::OnConsoleMessage(CefRefPtr browser, const CefString& message, const CefString& source, int line) @@ -360,28 +360,28 @@ void BrowserHandler::OnLoadingStateChange(CefRefPtr browser, bool is { // Update UI for browser state... if (handle_delegate_) - nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnLoadingStateChange, handle_delegate_, browser, isLoading, canGoBack, canGoForward)); + nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnLoadingStateChange, handle_delegate_, browser, isLoading, canGoBack, canGoForward)); } void BrowserHandler::OnLoadStart(CefRefPtr browser, CefRefPtr frame) { // A frame has started loading content... if (handle_delegate_) - nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnLoadStart, handle_delegate_, browser, frame)); + nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnLoadStart, handle_delegate_, browser, frame)); } void BrowserHandler::OnLoadEnd(CefRefPtr browser, CefRefPtr frame, int httpStatusCode) { // A frame has finished loading content... if (handle_delegate_) - nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnLoadEnd, handle_delegate_, browser, frame, httpStatusCode)); + nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnLoadEnd, handle_delegate_, browser, frame, httpStatusCode)); } void BrowserHandler::OnLoadError(CefRefPtr browser, CefRefPtr frame, ErrorCode errorCode, const CefString& errorText, const CefString& failedUrl) { // A frame has failed to load content... if (handle_delegate_) - nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnLoadError, handle_delegate_, browser, frame, errorCode, errorText, failedUrl)); + nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnLoadError, handle_delegate_, browser, frame, errorCode, errorText, failedUrl)); } bool BrowserHandler::OnJSDialog(CefRefPtr browser, const CefString& origin_url, const CefString& accept_lang, JSDialogType dialog_type, const CefString& message_text, const CefString& default_prompt_text, CefRefPtr callback, bool& suppress_message) @@ -424,7 +424,7 @@ CefRequestHandler::ReturnValue BrowserHandler::OnBeforeResourceLoad( void BrowserHandler::OnRenderProcessTerminated(CefRefPtr browser, TerminationStatus status) { if (handle_delegate_) - nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&HandlerDelegate::OnRenderProcessTerminated, handle_delegate_, browser, status)); + nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&HandlerDelegate::OnRenderProcessTerminated, handle_delegate_, browser, status)); } diff --git a/tool_kits/ui_components/cef_control/handler/browser_handler.h b/ui_components/cef_control/handler/browser_handler.h similarity index 99% rename from tool_kits/ui_components/cef_control/handler/browser_handler.h rename to ui_components/cef_control/handler/browser_handler.h index a0de4b7d..3c12ed48 100644 --- a/tool_kits/ui_components/cef_control/handler/browser_handler.h +++ b/ui_components/cef_control/handler/browser_handler.h @@ -7,7 +7,7 @@ #pragma once #include "include/cef_client.h" #include "include/cef_browser.h" -#include "shared/auto_unregister.h" +#include "cef_control/util/auto_unregister.h" #include "cef_control/app/cef_js_bridge.h" namespace nim_cef diff --git a/tool_kits/ui_components/cef_control/manager/cef_manager.cpp b/ui_components/cef_control/manager/cef_manager.cpp similarity index 96% rename from tool_kits/ui_components/cef_control/manager/cef_manager.cpp rename to ui_components/cef_control/manager/cef_manager.cpp index 879412db..201b5e06 100644 --- a/tool_kits/ui_components/cef_control/manager/cef_manager.cpp +++ b/ui_components/cef_control/manager/cef_manager.cpp @@ -72,7 +72,7 @@ void CefManager::AddCefDllToPath() TCHAR path_envirom[4096] = { 0 }; GetEnvironmentVariable(L"path", path_envirom, 4096); - std::wstring cef_path = QPath::GetAppPath(); + std::wstring cef_path = nbase::win32::GetCurrentModuleDirectory(); #ifdef _DEBUG //cef_path += L"cef_debug"; // ڼʹdebugģʽҲʹcef release汾dllΪεcef˳ʱжϣҪcefĹܲҪʹdebug汾dll cef_path += L"cef"; @@ -133,7 +133,6 @@ void CefManager::UnInitialize() #if !defined(SUPPORT_CEF) return; #endif - QLOG_APP(L"shutting down cef..."); CefShutdown(); } @@ -174,10 +173,10 @@ void CefManager::PostQuitMessage(int nExitCode) // Ӧõٺٵ::PostQuitMessage if (browser_count_ == 0) { - Post2UI([nExitCode]() + nbase::ThreadManager::PostTask(kThreadMain, [nExitCode]() { ::PostQuitMessage(nExitCode); - }); + }); } else { @@ -186,7 +185,7 @@ void CefManager::PostQuitMessage(int nExitCode) CefManager::GetInstance()->PostQuitMessage(nExitCode); }; - nbase::ThreadManager::PostDelayedTask(kThreadUI, cb, nbase::TimeDelta::FromMilliseconds(500)); + nbase::ThreadManager::PostDelayedTask(kThreadMain, cb, nbase::TimeDelta::FromMilliseconds(500)); } } diff --git a/tool_kits/ui_components/cef_control/manager/cef_manager.h b/ui_components/cef_control/manager/cef_manager.h similarity index 100% rename from tool_kits/ui_components/cef_control/manager/cef_manager.h rename to ui_components/cef_control/manager/cef_manager.h diff --git a/tool_kits/shared/auto_unregister.h b/ui_components/cef_control/util/auto_unregister.h similarity index 100% rename from tool_kits/shared/auto_unregister.h rename to ui_components/cef_control/util/auto_unregister.h diff --git a/tool_kits/ui_components/cef_control/util/memory_dc.cpp b/ui_components/cef_control/util/memory_dc.cpp similarity index 100% rename from tool_kits/ui_components/cef_control/util/memory_dc.cpp rename to ui_components/cef_control/util/memory_dc.cpp diff --git a/tool_kits/ui_components/cef_control/util/memory_dc.h b/ui_components/cef_control/util/memory_dc.h similarity index 100% rename from tool_kits/ui_components/cef_control/util/memory_dc.h rename to ui_components/cef_control/util/memory_dc.h diff --git a/tool_kits/ui_components/cef_control/util/util.h b/ui_components/cef_control/util/util.h similarity index 100% rename from tool_kits/ui_components/cef_control/util/util.h rename to ui_components/cef_control/util/util.h diff --git a/tool_kits/ui_components/menu/ui_menu.cpp b/ui_components/menu/ui_menu.cpp similarity index 100% rename from tool_kits/ui_components/menu/ui_menu.cpp rename to ui_components/menu/ui_menu.cpp diff --git a/tool_kits/ui_components/menu/ui_menu.h b/ui_components/menu/ui_menu.h similarity index 100% rename from tool_kits/ui_components/menu/ui_menu.h rename to ui_components/menu/ui_menu.h diff --git a/tool_kits/ui_components/modal_wnd/async_do_modal.cpp b/ui_components/modal_wnd/async_do_modal.cpp similarity index 100% rename from tool_kits/ui_components/modal_wnd/async_do_modal.cpp rename to ui_components/modal_wnd/async_do_modal.cpp diff --git a/tool_kits/ui_components/modal_wnd/async_do_modal.h b/ui_components/modal_wnd/async_do_modal.h similarity index 100% rename from tool_kits/ui_components/modal_wnd/async_do_modal.h rename to ui_components/modal_wnd/async_do_modal.h diff --git a/tool_kits/ui_components/modal_wnd/async_modal_runner.cpp b/ui_components/modal_wnd/async_modal_runner.cpp similarity index 95% rename from tool_kits/ui_components/modal_wnd/async_modal_runner.cpp rename to ui_components/modal_wnd/async_modal_runner.cpp index c0c8986a..56f89faf 100644 --- a/tool_kits/ui_components/modal_wnd/async_modal_runner.cpp +++ b/ui_components/modal_wnd/async_modal_runner.cpp @@ -1,8 +1,8 @@ #include "stdafx.h" #include "async_modal_runner.h" -#include #include "base/thread/thread_manager.h" -#include "shared/threads.h" + +#include static const char kModalThreadName[] = "AsyncModalRunner"; @@ -102,7 +102,7 @@ void AsyncModalRunnerManager::CancelAllThreads() void AsyncModalRunnerManager::OnThreadWillExit(AsyncModalRunner *runner) { - nbase::ThreadManager::PostTask(kThreadUI, nbase::Bind(&AsyncModalRunnerManager::Deregister, this, runner)); + nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(&AsyncModalRunnerManager::Deregister, this, runner)); } void AsyncModalRunnerManager::Deregister(AsyncModalRunner *runner) diff --git a/tool_kits/ui_components/modal_wnd/async_modal_runner.h b/ui_components/modal_wnd/async_modal_runner.h similarity index 100% rename from tool_kits/ui_components/modal_wnd/async_modal_runner.h rename to ui_components/modal_wnd/async_modal_runner.h diff --git a/tool_kits/ui_components/modal_wnd/file_dialog_ex.cpp b/ui_components/modal_wnd/file_dialog_ex.cpp similarity index 96% rename from tool_kits/ui_components/modal_wnd/file_dialog_ex.cpp rename to ui_components/modal_wnd/file_dialog_ex.cpp index e5ed9f55..f629c7e5 100644 --- a/tool_kits/ui_components/modal_wnd/file_dialog_ex.cpp +++ b/ui_components/modal_wnd/file_dialog_ex.cpp @@ -5,7 +5,6 @@ #include "base/thread/thread_manager.h" #include "base/util/string_util.h" #include "base/file/file_util.h" -#include "shared/threads.h" CFileDialogEx::CFileDialogEx(void) { @@ -173,7 +172,7 @@ void CFileDialogEx::SyncShowModal() if (file_name.size() == 0) { StdClosure closure = nbase::Bind(file_dialog_callback2_, ret, file_directory); - nbase::ThreadManager::PostTask(kThreadUI, closure); + nbase::ThreadManager::PostTask(kThreadMain, closure); } else { @@ -183,7 +182,7 @@ void CFileDialogEx::SyncShowModal() if (nbase::FilePathIsExist(file_path, false)) { StdClosure closure = nbase::Bind(file_dialog_callback2_, ret, file_path); - nbase::ThreadManager::PostTask(kThreadUI, closure); + nbase::ThreadManager::PostTask(kThreadMain, closure); } get_length += file_name.size()+1; file_name = m_stOFN.lpstrFile + get_length; @@ -193,14 +192,14 @@ void CFileDialogEx::SyncShowModal() else { StdClosure closure = nbase::Bind(file_dialog_callback2_, ret, GetPathName()); - nbase::ThreadManager::PostTask(kThreadUI, closure); + nbase::ThreadManager::PostTask(kThreadMain, closure); } } else if (file_dialog_type_ == FDT_SaveFile) { BOOL ret = ::GetSaveFileName(&m_stOFN); StdClosure closure = nbase::Bind(file_dialog_callback2_, ret, GetPathName()); - nbase::ThreadManager::PostTask(kThreadUI, closure); + nbase::ThreadManager::PostTask(kThreadMain, closure); } else { diff --git a/tool_kits/ui_components/modal_wnd/file_dialog_ex.h b/ui_components/modal_wnd/file_dialog_ex.h similarity index 99% rename from tool_kits/ui_components/modal_wnd/file_dialog_ex.h rename to ui_components/modal_wnd/file_dialog_ex.h index f2434ef3..be249a54 100644 --- a/tool_kits/ui_components/modal_wnd/file_dialog_ex.h +++ b/ui_components/modal_wnd/file_dialog_ex.h @@ -1,9 +1,10 @@ #ifndef _TOOL_FILE_DIALOGEX_H_ #define _TOOL_FILE_DIALOGEX_H_ -#include #include "modal_wnd_base.h" +#include + struct __POSITION {}; typedef __POSITION* POSITION; diff --git a/tool_kits/ui_components/modal_wnd/modal_wnd_base.h b/ui_components/modal_wnd/modal_wnd_base.h similarity index 100% rename from tool_kits/ui_components/modal_wnd/modal_wnd_base.h rename to ui_components/modal_wnd/modal_wnd_base.h diff --git a/tool_kits/ui_components/msgbox/msgbox.cpp b/ui_components/msgbox/msgbox.cpp similarity index 97% rename from tool_kits/ui_components/msgbox/msgbox.cpp rename to ui_components/msgbox/msgbox.cpp index bc458c80..ecd75b3f 100644 --- a/tool_kits/ui_components/msgbox/msgbox.cpp +++ b/ui_components/msgbox/msgbox.cpp @@ -178,6 +178,6 @@ void MsgBox::EndMsgBox(MsgBoxRet ret) if (msgbox_callback_) { - Post2UI(nbase::Bind(msgbox_callback_, ret)); + nbase::ThreadManager::PostTask(kThreadMain, nbase::Bind(msgbox_callback_, ret)); } } diff --git a/tool_kits/ui_components/msgbox/msgbox.h b/ui_components/msgbox/msgbox.h similarity index 100% rename from tool_kits/ui_components/msgbox/msgbox.h rename to ui_components/msgbox/msgbox.h diff --git a/tool_kits/ui_components/shadow_wnd/shadow_wnd.cpp b/ui_components/shadow_wnd/shadow_wnd.cpp similarity index 100% rename from tool_kits/ui_components/shadow_wnd/shadow_wnd.cpp rename to ui_components/shadow_wnd/shadow_wnd.cpp diff --git a/tool_kits/ui_components/shadow_wnd/shadow_wnd.h b/ui_components/shadow_wnd/shadow_wnd.h similarity index 100% rename from tool_kits/ui_components/shadow_wnd/shadow_wnd.h rename to ui_components/shadow_wnd/shadow_wnd.h diff --git a/tool_kits/ui_components/stdafx.cpp b/ui_components/stdafx.cpp similarity index 100% rename from tool_kits/ui_components/stdafx.cpp rename to ui_components/stdafx.cpp diff --git a/tool_kits/ui_components/stdafx.h b/ui_components/stdafx.h similarity index 92% rename from tool_kits/ui_components/stdafx.h rename to ui_components/stdafx.h index a41f2ded..0e2cb7c8 100644 --- a/tool_kits/ui_components/stdafx.h +++ b/ui_components/stdafx.h @@ -23,8 +23,5 @@ // base #include "base/base.h" -// shared -#include "shared/shared.h" - // duilib #include "duilib/UIlib.h" diff --git a/tool_kits/ui_components/targetver.h b/ui_components/targetver.h similarity index 100% rename from tool_kits/ui_components/targetver.h rename to ui_components/targetver.h diff --git a/tool_kits/ui_components/toast/toast.cpp b/ui_components/toast/toast.cpp similarity index 97% rename from tool_kits/ui_components/toast/toast.cpp rename to ui_components/toast/toast.cpp index da2c9ae4..a5148f16 100644 --- a/tool_kits/ui_components/toast/toast.cpp +++ b/ui_components/toast/toast.cpp @@ -90,7 +90,7 @@ void Toast::SetDuration(int duration) if (duration <= 0) return; - nbase::ThreadManager::PostDelayedTask(kThreadUI, ToWeakCallback([this]() + nbase::ThreadManager::PostDelayedTask(kThreadMain, ToWeakCallback([this]() { this->Close(); }), nbase::TimeDelta::FromMilliseconds(duration)); diff --git a/tool_kits/ui_components/toast/toast.h b/ui_components/toast/toast.h similarity index 100% rename from tool_kits/ui_components/toast/toast.h rename to ui_components/toast/toast.h diff --git a/tool_kits/ui_components/ui_cef_control.h b/ui_components/ui_cef_control.h similarity index 100% rename from tool_kits/ui_components/ui_cef_control.h rename to ui_components/ui_cef_control.h diff --git a/tool_kits/ui_components/ui_components.h b/ui_components/ui_components.h similarity index 100% rename from tool_kits/ui_components/ui_components.h rename to ui_components/ui_components.h diff --git a/tool_kits/ui_components/ui_components.vcxproj b/ui_components/ui_components.vcxproj similarity index 87% rename from tool_kits/ui_components/ui_components.vcxproj rename to ui_components/ui_components.vcxproj index b8fa6e95..b752bff1 100644 --- a/tool_kits/ui_components/ui_components.vcxproj +++ b/ui_components/ui_components.vcxproj @@ -72,23 +72,23 @@ true - ..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ - ..\..\libs\ + $(ProjectDir)..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ + $(ProjectDir)..\libs\ true - ..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ - ..\..\libs\x64\ + $(ProjectDir)..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ + $(ProjectDir)..\libs\x64\ false - ..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ - ..\..\libs\ + $(ProjectDir)..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ + $(ProjectDir)..\libs\ false - ..\..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ - ..\..\libs\x64\ + $(ProjectDir)..\tmp\$(PlatformName)\$(ProjectName)\$(Configuration)\ + $(ProjectDir)..\libs\x64\ @@ -98,7 +98,7 @@ true SUPPORT_CEF;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) true - .\;..\;..\..\third_party\cef_wrapper\;%(AdditionalIncludeDirectories) + .\;..\;..\third_party\cef_wrapper\;%(AdditionalIncludeDirectories) MultiThreadedDebug @@ -106,7 +106,7 @@ true - ..\..\libs\;%(AdditionalLibraryDirectories) + ..\libs\;%(AdditionalLibraryDirectories) nim_libcef_d.lib;libcef_dll_wrapper_d.lib;%(AdditionalDependencies) /IGNORE:4006,4221 %(AdditionalOptions) @@ -119,7 +119,7 @@ true SUPPORT_CEF;_DEBUG;_LIB;%(PreprocessorDefinitions) true - .\;..\;..\..\third_party\cef_wrapper\;%(AdditionalIncludeDirectories) + .\;..\;..\third_party\cef_wrapper\;%(AdditionalIncludeDirectories) MultiThreadedDebug @@ -127,7 +127,7 @@ true - ..\..\libs\x64\;%(AdditionalLibraryDirectories) + ..\libs\x64\;%(AdditionalLibraryDirectories) nim_libcef_d.lib;%(AdditionalDependencies) /IGNORE:4006,4221 %(AdditionalOptions) @@ -142,7 +142,7 @@ true SUPPORT_CEF;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) true - .\;..\;..\..\third_party\cef_wrapper\;%(AdditionalIncludeDirectories) + .\;..\;..\third_party\cef_wrapper\;%(AdditionalIncludeDirectories) MultiThreaded @@ -152,7 +152,7 @@ true - ..\..\libs\;%(AdditionalLibraryDirectories) + ..\libs\;%(AdditionalLibraryDirectories) nim_libcef.lib;%(AdditionalDependencies) /IGNORE:4006,4221 %(AdditionalOptions) @@ -167,7 +167,7 @@ true SUPPORT_CEF;NDEBUG;_LIB;%(PreprocessorDefinitions) true - .\;..\;..\..\third_party\cef_wrapper\;%(AdditionalIncludeDirectories) + .\;..\;..\third_party\cef_wrapper\;%(AdditionalIncludeDirectories) MultiThreaded @@ -177,12 +177,13 @@ true - ..\..\libs\x64\;%(AdditionalLibraryDirectories) + ..\libs\x64\;%(AdditionalLibraryDirectories) nim_libcef.lib;%(AdditionalDependencies) /IGNORE:4006,4221 %(AdditionalOptions) + @@ -241,7 +242,7 @@ - + {a9d6dc71-c0dc-4549-aea0-3b15b44e86a9} diff --git a/tool_kits/ui_components/ui_components.vcxproj.filters b/ui_components/ui_components.vcxproj.filters similarity index 98% rename from tool_kits/ui_components/ui_components.vcxproj.filters rename to ui_components/ui_components.vcxproj.filters index fb95b759..1ad65660 100644 --- a/tool_kits/ui_components/ui_components.vcxproj.filters +++ b/ui_components/ui_components.vcxproj.filters @@ -129,6 +129,9 @@ 头文件 + + cef_control\util + diff --git a/tool_kits/ui_components/windows_manager/window_ex.cpp b/ui_components/windows_manager/window_ex.cpp similarity index 100% rename from tool_kits/ui_components/windows_manager/window_ex.cpp rename to ui_components/windows_manager/window_ex.cpp diff --git a/tool_kits/ui_components/windows_manager/window_ex.h b/ui_components/windows_manager/window_ex.h similarity index 100% rename from tool_kits/ui_components/windows_manager/window_ex.h rename to ui_components/windows_manager/window_ex.h diff --git a/tool_kits/ui_components/windows_manager/windows_manager.cpp b/ui_components/windows_manager/windows_manager.cpp similarity index 94% rename from tool_kits/ui_components/windows_manager/windows_manager.cpp rename to ui_components/windows_manager/windows_manager.cpp index e7625bda..9243d353 100644 --- a/tool_kits/ui_components/windows_manager/windows_manager.cpp +++ b/ui_components/windows_manager/windows_manager.cpp @@ -1,6 +1,5 @@ #include "stdafx.h" #include "windows_manager.h" -#include "shared/log.h" namespace nim_comp { @@ -26,10 +25,6 @@ bool WindowsManager::RegisterWindow(const std::wstring wnd_class_name, const std if (it != windows_map_.end()) { std::map::iterator it2 = it->second.find(wnd_id); - if (it2 != it->second.end()) - { - QLOG_PRO(L"The window has already registered !") << wnd_class_name << wnd_id; - } it->second[wnd_id] = wnd; } else diff --git a/tool_kits/ui_components/windows_manager/windows_manager.h b/ui_components/windows_manager/windows_manager.h similarity index 100% rename from tool_kits/ui_components/windows_manager/windows_manager.h rename to ui_components/windows_manager/windows_manager.h