Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9fe2fe5874 | ||
|
|
1be1ecbbf2 | ||
|
|
37e7d278bd |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,3 +1,7 @@
|
||||
build/*
|
||||
build64/*
|
||||
demo/*
|
||||
_temp/
|
||||
_bin/
|
||||
temp/
|
||||
bin/
|
||||
.vs/
|
||||
38
CLAUDE.md
38
CLAUDE.md
@@ -9,20 +9,26 @@ EzUI 是一个基于原生 Win32 消息机制和 Direct2D 的 C++ 桌面 UI 框
|
||||
## 构建命令
|
||||
|
||||
```bash
|
||||
build.bat # 构建 32 位版本
|
||||
build64.bat # 构建 64 位版本
|
||||
build.bat # 构建 32 位静态库
|
||||
build64.bat # 构建 64 位静态库
|
||||
```
|
||||
|
||||
或使用 CMake 直接构建:
|
||||
CMake 构建:
|
||||
```bash
|
||||
cmake -B build
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
静态库/动态库切换:
|
||||
```bash
|
||||
cmake -B build -DBUILD_SHARED_LIBS=ON # 动态库
|
||||
cmake -B build -DBUILD_SHARED_LIBS=OFF # 静态库(默认)
|
||||
```
|
||||
|
||||
## 核心架构
|
||||
|
||||
### 窗口类型 (继承层次)
|
||||
- `Window` - 经典边框窗口
|
||||
- `Window` - 经典带边框窗口
|
||||
- `BorderlessWindow` - 无边框带阴影窗口
|
||||
- `LayeredWindow` - 分层透明窗口,支持异形
|
||||
- `PopupWindow` - 失焦自动关闭的弹出窗口
|
||||
@@ -32,7 +38,13 @@ cmake --build build
|
||||
- 基础控件:`Label`, `Button`, `TextBox`, `PictureBox`
|
||||
- 选择控件:`CheckBox`, `RadioButton`, `ComboBox`
|
||||
- 布局容器:`HLayout`, `VLayout`, `HListView`, `VListView`, `TileListView`, `TabLayout`
|
||||
- 功能控件:`ScrollBar`, `Menu`, `NotifyIcon`, `ProgressBar`
|
||||
- 功能控件:`ScrollBar`, `Menu`, `NotifyIcon`, `ProgressBar`, `TreeView`, `Spacer`
|
||||
|
||||
### 布局系统
|
||||
- **尺寸优先级**:比例尺寸 (`SetRateWidth/Height`) > 绝对尺寸 (`SetFixedSize`) > 控件内容大小
|
||||
- **自动布局**:`SetAutoWidth/Height` 让控件根据内容自动调整大小
|
||||
- **停靠布局**:`SetDockStyle` 支持 Fill/Vertical/Horizontal 停靠
|
||||
- **布局状态**:`TryPendLayout`/`ResumeLayout` 批量添加控件后统一布局
|
||||
|
||||
### 样式与渲染
|
||||
- `UIManager` - UI 样式与资源管理,支持 XML 布局加载
|
||||
@@ -41,7 +53,20 @@ cmake --build build
|
||||
- `RenderTypes` - 颜色、对齐方式等绘图类型
|
||||
|
||||
### 事件系统
|
||||
支持事件冒泡机制,可实现事件捕获与穿透。Debug 模式下按 F11 可查看布局信息和控件边界。
|
||||
- 支持事件冒泡机制,可实现事件捕获与穿透
|
||||
- `NotifyFlags` 控制控件哪些事件需要通知窗口
|
||||
- `Event` 枚举定义所有事件类型,支持位运算组合
|
||||
- Debug 模式下按 F11 可查看布局信息和控件边界
|
||||
|
||||
### 线程模型
|
||||
- UI 线程:`Application::Run` 启动消息循环
|
||||
- 跨线程调用:`BeginInvoke`(异步)/ `Invoke`(同步)
|
||||
- 全局隐藏窗口 `__EzUI_MessageWnd` 用于线程通讯
|
||||
|
||||
### 资源管理
|
||||
- 控件树内存由父控件自动管理:`Attach`/`Detach`
|
||||
- 图片资源通过 `PtrManager` 自动释放
|
||||
- XML 布局加载后由 `UIManager` 管理生命周期
|
||||
|
||||
## 开发约定
|
||||
|
||||
@@ -49,3 +74,4 @@ cmake --build build
|
||||
- 源文件位于 `sources/` 目录
|
||||
- 一切皆控件,纯代码组合 UI
|
||||
- 使用 CSS 驱动视觉,结构与样式分离
|
||||
- 中文注释,中文沟通
|
||||
|
||||
@@ -44,4 +44,7 @@ function(add_resource_package TARGET_NAME INPUT_DIR OUTPUT_FILE)
|
||||
endfunction()
|
||||
|
||||
#添加子项目
|
||||
#add_subdirectory(./demo) # 暂时注释掉,只编译库
|
||||
option(BUILD_DEMO "Build demo projects" ON)
|
||||
if(BUILD_DEMO)
|
||||
add_subdirectory(./demo)
|
||||
endif()
|
||||
|
||||
4
build_x64.bat
Normal file
4
build_x64.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
chcp 65001
|
||||
@echo off
|
||||
cmake -S . -B build_x64 -A x64 -DBUILD_EZUI=OFF
|
||||
pause
|
||||
4
build_x86.bat
Normal file
4
build_x86.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
chcp 65001
|
||||
@echo off
|
||||
cmake -S . -B build_x86 -A Win32 -DBUILD_EZUI=OFF
|
||||
pause
|
||||
31
demo/Adminstor/Adminstor.sln
Normal file
31
demo/Adminstor/Adminstor.sln
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36811.4 d17.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Adminstor", "Adminstor\Adminstor.vcxproj", "{EE06DEDC-52B5-4B5D-8B52-7FEB02D77E6B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EE06DEDC-52B5-4B5D-8B52-7FEB02D77E6B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{EE06DEDC-52B5-4B5D-8B52-7FEB02D77E6B}.Debug|x64.Build.0 = Debug|x64
|
||||
{EE06DEDC-52B5-4B5D-8B52-7FEB02D77E6B}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{EE06DEDC-52B5-4B5D-8B52-7FEB02D77E6B}.Debug|x86.Build.0 = Debug|Win32
|
||||
{EE06DEDC-52B5-4B5D-8B52-7FEB02D77E6B}.Release|x64.ActiveCfg = Release|x64
|
||||
{EE06DEDC-52B5-4B5D-8B52-7FEB02D77E6B}.Release|x64.Build.0 = Release|x64
|
||||
{EE06DEDC-52B5-4B5D-8B52-7FEB02D77E6B}.Release|x86.ActiveCfg = Release|Win32
|
||||
{EE06DEDC-52B5-4B5D-8B52-7FEB02D77E6B}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {AC1EAB6C-7DC1-484D-92AE-6736232936CA}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
205
demo/Adminstor/Adminstor/Adminstor.vcxproj
Normal file
205
demo/Adminstor/Adminstor/Adminstor.vcxproj
Normal file
@@ -0,0 +1,205 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{ee06dedc-52b5-4b5d-8b52-7feb02d77e6b}</ProjectGuid>
|
||||
<RootNamespace>Adminstor</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>..\_bin\</OutDir>
|
||||
<IntDir>..\_temp\$(Platform)$(Configuration)$(ProjectName)\</IntDir>
|
||||
<IncludePath>..\ThirdParty\EzUI\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>..\ThirdParty\EzUI\lib;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>$(ProjectName)_$(Configuration)_$(Platform)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>..\_bin\</OutDir>
|
||||
<IntDir>..\_temp\$(Platform)$(Configuration)$(ProjectName)\</IntDir>
|
||||
<IncludePath>..\ThirdParty\EzUI\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>..\ThirdParty\EzUI\lib;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>$(ProjectName)_$(Configuration)_$(Platform)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>..\_bin\</OutDir>
|
||||
<IntDir>..\_temp\$(Platform)$(Configuration)$(ProjectName)\</IntDir>
|
||||
<IncludePath>..\ThirdParty\EzUI\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>..\ThirdParty\EzUI\lib;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>$(ProjectName)_$(Configuration)_$(Platform)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>..\_bin\</OutDir>
|
||||
<IntDir>..\_temp\$(Platform)$(Configuration)$(ProjectName)\</IntDir>
|
||||
<IncludePath>..\ThirdParty\EzUI\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>..\ThirdParty\EzUI\lib;$(LibraryPath)</LibraryPath>
|
||||
<TargetName>$(ProjectName)_$(Configuration)_$(Platform)</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>
|
||||
</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>EzUI_$(Configuration)_$(Platform).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>
|
||||
</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<AdditionalDependencies>EzUI_$(Configuration)_$(Platform).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>
|
||||
</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>EzUI_$(Configuration)_$(Platform).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>
|
||||
</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<AdditionalDependencies>EzUI_$(Configuration)_$(Platform).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="loginForm.h" />
|
||||
<ClInclude Include="mainForm.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="DemoUi.cpp" />
|
||||
<ClCompile Include="loginForm.cpp" />
|
||||
<ClCompile Include="mainForm.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="DemoUi.ico" />
|
||||
<Image Include="small.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="DemoUi.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
61
demo/Adminstor/Adminstor/Adminstor.vcxproj.filters
Normal file
61
demo/Adminstor/Adminstor/Adminstor.vcxproj.filters
Normal file
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Resource.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="loginForm.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="mainForm.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="DemoUi.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="loginForm.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="mainForm.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="small.ico">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
<Image Include="DemoUi.ico">
|
||||
<Filter>资源文件</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="DemoUi.rc">
|
||||
<Filter>资源文件</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
4
demo/Adminstor/Adminstor/Adminstor.vcxproj.user
Normal file
4
demo/Adminstor/Adminstor/Adminstor.vcxproj.user
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
||||
BIN
demo/Adminstor/Adminstor/DemoUi.aps
Normal file
BIN
demo/Adminstor/Adminstor/DemoUi.aps
Normal file
Binary file not shown.
15
demo/Adminstor/Adminstor/DemoUi.cpp
Normal file
15
demo/Adminstor/Adminstor/DemoUi.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "pch.h"
|
||||
#include "loginForm.h"
|
||||
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow)
|
||||
{
|
||||
//app类
|
||||
Application app(hInstance);
|
||||
app.EnableHighDpi();//启用高DPI
|
||||
|
||||
//创建登录创建
|
||||
loginForm loginFrm;
|
||||
loginFrm.Show();
|
||||
|
||||
return app.Exec();//进行消息循环
|
||||
}
|
||||
BIN
demo/Adminstor/Adminstor/DemoUi.ico
Normal file
BIN
demo/Adminstor/Adminstor/DemoUi.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
BIN
demo/Adminstor/Adminstor/DemoUi.rc
Normal file
BIN
demo/Adminstor/Adminstor/DemoUi.rc
Normal file
Binary file not shown.
17
demo/Adminstor/Adminstor/Resource.h
Normal file
17
demo/Adminstor/Adminstor/Resource.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ 生成的包含文件。
|
||||
// 供 DemoUi.rc 使用
|
||||
//
|
||||
#define IDD_INPUT 102
|
||||
#define IDC_EDIT1 1000
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 104
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
21
demo/Adminstor/Adminstor/framework.h
Normal file
21
demo/Adminstor/Adminstor/framework.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "resource.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "ezui/Application.h" //app类
|
||||
#include "EzUI/Window.h" //基础窗口类
|
||||
#include "EzUI/Button.h" //按钮
|
||||
#include "EzUI/TextBox.h" //文本框
|
||||
#include "EzUI/CheckBox.h" //复选框
|
||||
#include "EzUI/PictureBox.h" //图片控件
|
||||
#include "EzUI/TabLayout.h" //选项卡控件
|
||||
#include "EzUI/VLayout.h" //垂直布局
|
||||
#include "EzUI/HLayout.h"//水平布局
|
||||
#include "EzUI/VListView.h"//垂直带滚动条列表
|
||||
#include "EzUI/HListView.h"//水平带滚动条列表
|
||||
#include "EzUI/TileListView.h"//瓦片列表
|
||||
#include "EzUI/LayeredWindow.h"//分层窗口类-可以异型透明窗口
|
||||
#include "ezui/UIManager.h"//ui管理类(使用xml生成控件)
|
||||
#include "EzUI/Animation.h"
|
||||
|
||||
57
demo/Adminstor/Adminstor/loginForm.cpp
Normal file
57
demo/Adminstor/Adminstor/loginForm.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "pch.h"
|
||||
#include "loginForm.h"
|
||||
#include "mainForm.h"
|
||||
|
||||
void loginForm::OnNotify(Control* sender, EventArgs& args)
|
||||
{
|
||||
if (args.EventType == Event::OnMouseDown) {
|
||||
if (sender->Name == "btnLogin") {
|
||||
TextBox* editUser = (TextBox*)FindControl("user");
|
||||
TextBox* editpwd = (TextBox*)FindControl("pwd");
|
||||
CheckBox* ckbox = (CheckBox*)FindControl("ckbox");
|
||||
/*if (!ckbox->GetCheck()) {
|
||||
::MessageBoxW(Hwnd(), L"请阅读协议并勾选!", L"提示", MB_OK);
|
||||
return;
|
||||
}*/
|
||||
UIString user = editUser->GetText();
|
||||
UIString pwd = editpwd->GetText();
|
||||
|
||||
Hide(); // 隐藏登录窗口
|
||||
static mainForm mainForm;
|
||||
mainForm.Show(); // 显示主界面
|
||||
|
||||
//if (user == "ad" && pwd == "123") {
|
||||
// ::MessageBoxW(Hwnd(), L"登录成功!", L"提示", MB_OK);
|
||||
// Hide(); // 隐藏登录窗口
|
||||
// static mainForm mainForm;
|
||||
// mainForm.Show(); // 显示主界面
|
||||
//}
|
||||
//else {
|
||||
// ::MessageBoxW(Hwnd(), L"用户名或密码错误!", L"提示", MB_OK);
|
||||
//}
|
||||
}
|
||||
if (sender->Name == "btnExit") {
|
||||
Application::Exit();
|
||||
}
|
||||
// 打开链接
|
||||
if (!sender->GetAttribute("url").empty()) {
|
||||
::ShellExecuteA(0, "open", sender->GetAttribute("url").c_str(), "", "", SW_SHOW);
|
||||
}
|
||||
}
|
||||
__super::OnNotify(sender, args);
|
||||
}
|
||||
|
||||
void loginForm::OnClose(bool& close)
|
||||
{
|
||||
Application::Exit();
|
||||
}
|
||||
|
||||
loginForm::loginForm() :LayeredWindow(320, 448)
|
||||
{
|
||||
umg.LoadXml("res/loginForm.htm");//加载xml里面的控件与样式
|
||||
umg.SetupUI(this);
|
||||
}
|
||||
|
||||
loginForm::~loginForm()
|
||||
{
|
||||
}
|
||||
23
demo/Adminstor/Adminstor/loginForm.h
Normal file
23
demo/Adminstor/Adminstor/loginForm.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
|
||||
using namespace ezui;
|
||||
|
||||
//using Form = LayeredWindow; //支持异形透明窗口(带阴影)
|
||||
//using Form = BorderlessWindow; //常规无边框窗口(带阴影)
|
||||
//using Form = Window; //标准窗口(带系统标题栏)
|
||||
|
||||
// 登陆窗口
|
||||
class loginForm :public LayeredWindow
|
||||
{
|
||||
private:
|
||||
//ui管理类
|
||||
UIManager umg;
|
||||
protected:
|
||||
virtual void OnNotify(Control* sender, EventArgs& args)override;//重载事件通知
|
||||
virtual void OnClose(bool& close)override;//当窗口关闭的时候
|
||||
public:
|
||||
loginForm();
|
||||
virtual ~loginForm();
|
||||
};
|
||||
|
||||
96
demo/Adminstor/Adminstor/mainForm.cpp
Normal file
96
demo/Adminstor/Adminstor/mainForm.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
#include "pch.h"
|
||||
#include "mainForm.h"
|
||||
|
||||
void mainForm::OnNotify(Control* sender, EventArgs& args)
|
||||
{
|
||||
UIString btnName = sender->Name; // 控件id
|
||||
Event eventType = args.EventType; // 事件类型
|
||||
|
||||
switch (eventType)
|
||||
{
|
||||
case ezui::OnMouseDown: //鼠标按下
|
||||
{
|
||||
if (btnName == "btnExitMain") { //退出
|
||||
int result = ::MessageBoxW(Hwnd(), L"要退出程序吗?", L"提示", MB_YESNO | MB_ICONQUESTION);
|
||||
if (result == IDYES)
|
||||
exit(0);
|
||||
}
|
||||
else if (btnName == "btnMinMain") { //最小化
|
||||
this->ShowMinimized();
|
||||
}
|
||||
else if (btnName == "btnMaxMain") { //最大化|还原
|
||||
if (this->IsMaximized()) {
|
||||
this->ShowNormal();
|
||||
// 修改控件文字
|
||||
Button* btnMax = (Button*)FindControl("btnMaxMain");
|
||||
btnMax->SetText(L"🗖");
|
||||
}
|
||||
else {
|
||||
this->ShowMaximized();
|
||||
// 修改控件文字
|
||||
Button* btnMax = (Button*)FindControl("btnMaxMain");
|
||||
btnMax->SetText(L"🗗");
|
||||
}
|
||||
}
|
||||
else if (btnName == "btnAdmin") { //到管理页面 获取 mainTab ,设置页面为0
|
||||
TabLayout* mainTab = (TabLayout*)FindControl("mainTab");
|
||||
mainTab->SetPageIndex(0);
|
||||
mainTab->Invalidate();
|
||||
}
|
||||
else if (btnName == "btnTools") { //到工具页面 获取 mainTab ,设置页面为1
|
||||
TabLayout* mainTab = (TabLayout*)FindControl("mainTab");
|
||||
mainTab->SetPageIndex(1);
|
||||
mainTab->Invalidate();
|
||||
}
|
||||
else if (btnName == "btnAdminConnect") { //管理页面的连接按钮按下,先获取 btnAdminConnect 按钮,设置为不可用,修改文字为“连接中...”
|
||||
Button* btnAdminConnect = (Button*)FindControl("btnAdminConnect");
|
||||
btnAdminConnect->SetText(L"🔄");
|
||||
btnAdminConnect->Style.BackColor = Color(0, 185, 107);
|
||||
}
|
||||
else if (btnName == "btnAdminTemp") { //管理页面的测试按钮
|
||||
TextBox* textAdmin = (TextBox*)FindControl("textAdminOutput"); //获取输出框
|
||||
//textAdmin->Insert(L"\n测试成功!", true);
|
||||
if (textAdmin) {
|
||||
textAdmin->Insert(L"\n测试成功!",true);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ezui::OnMouseDoubleClick: //鼠标双击
|
||||
{
|
||||
//if (btnName == "titleMain") { //标题布局
|
||||
// if (this->IsMaximized()) {
|
||||
// this->ShowNormal();
|
||||
// }
|
||||
// else {
|
||||
// this->ShowMaximized();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (args.EventType == Event::OnMouseDown) {
|
||||
|
||||
|
||||
}
|
||||
__super::OnNotify(sender, args);
|
||||
}
|
||||
|
||||
void mainForm::OnClose(bool& close)
|
||||
{
|
||||
Application::Exit();
|
||||
}
|
||||
|
||||
mainForm::mainForm() :LayeredWindow(1000, 750)
|
||||
{
|
||||
SetResizable(true); // 启用窗口大小调整
|
||||
SetMiniSize(Size(600, 450)); // 设置最小尺寸
|
||||
umg.LoadXml("res/mainForm.htm");//加载xml里面的控件与样式
|
||||
umg.SetupUI(this);
|
||||
}
|
||||
|
||||
mainForm::~mainForm()
|
||||
{
|
||||
}
|
||||
20
demo/Adminstor/Adminstor/mainForm.h
Normal file
20
demo/Adminstor/Adminstor/mainForm.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
|
||||
using namespace ezui;
|
||||
|
||||
|
||||
// 主窗口
|
||||
class mainForm :public LayeredWindow
|
||||
{
|
||||
private:
|
||||
//ui管理类
|
||||
UIManager umg;
|
||||
protected:
|
||||
virtual void OnNotify(Control* sender, EventArgs& args)override;//重载事件通知
|
||||
virtual void OnClose(bool& close)override;//当窗口关闭的时候
|
||||
public:
|
||||
mainForm();
|
||||
virtual ~mainForm();
|
||||
};
|
||||
|
||||
1
demo/Adminstor/Adminstor/pch.cpp
Normal file
1
demo/Adminstor/Adminstor/pch.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "pch.h"
|
||||
2
demo/Adminstor/Adminstor/pch.h
Normal file
2
demo/Adminstor/Adminstor/pch.h
Normal file
@@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
BIN
demo/Adminstor/Adminstor/small.ico
Normal file
BIN
demo/Adminstor/Adminstor/small.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
29
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Animation.h
vendored
Normal file
29
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Animation.h
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
#include "EzUI.h"
|
||||
#include "Timer.h"
|
||||
|
||||
namespace ezui {
|
||||
|
||||
class UI_EXPORT Animation : public Object {
|
||||
private:
|
||||
Timer *m_timer;
|
||||
float m_startValue = 0;
|
||||
float m_endValue = 0;
|
||||
float m_currValue = 0;
|
||||
float m_speedPerMs = 0;
|
||||
std::chrono::steady_clock::time_point m_lastTime;
|
||||
public:
|
||||
//当值更改的时候发生的事件(请绑定此函数进行回调,请自行线程同步)
|
||||
std::function<void(float)> ValueChanged;
|
||||
Animation(Object* parentObject = NULL);
|
||||
virtual ~Animation();
|
||||
void SetStartValue(float value);
|
||||
void SetEndValue(float value);
|
||||
//开始动画
|
||||
void Start(int durationMs, int fps = 90);
|
||||
//动画是否已经停止
|
||||
bool IsStopped();
|
||||
void Stop();
|
||||
};
|
||||
|
||||
};
|
||||
24
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Application.h
vendored
Normal file
24
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Application.h
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "Window.h"
|
||||
#include "Resource.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT Application
|
||||
{
|
||||
public:
|
||||
//退出消息循环
|
||||
static void Exit(int exitCode = 0);
|
||||
//获取程序启动路径
|
||||
static UIString StartPath();
|
||||
public:
|
||||
Application(HINSTANCE hInstance = NULL);
|
||||
//使用本地文件名称或者资源中的名称加载资源包
|
||||
//填入vs中的资源ID名称 或者 本地文件名 一个Application只允许有一个资源文件
|
||||
bool SetResource(const UIString& localOrResName);
|
||||
//启用高DPI适配
|
||||
void EnableHighDpi();
|
||||
virtual ~Application();
|
||||
//执行消息循环
|
||||
int Exec();
|
||||
};
|
||||
};
|
||||
34
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Bitmap.h
vendored
Normal file
34
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Bitmap.h
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include "EzUI.h"
|
||||
|
||||
namespace ezui {
|
||||
//BGRA 32位图
|
||||
class UI_EXPORT Bitmap {
|
||||
private:
|
||||
int m_width = 0;
|
||||
int m_height = 0;
|
||||
HBITMAP m_bmp = NULL;
|
||||
HDC m_hdc = NULL;
|
||||
byte* m_point = NULL;
|
||||
BITMAPINFO m_bmpInfo;
|
||||
Bitmap(const Bitmap& hBitmap) = delete;
|
||||
void operator=(const Bitmap& hBitmap) = delete;
|
||||
protected:
|
||||
void Create(int width, int height);
|
||||
public:
|
||||
int Width()const;
|
||||
int Height()const;
|
||||
//BGRA 32位图
|
||||
Bitmap(int width, int height);
|
||||
Bitmap(HDC dc, const Rect& rect);
|
||||
void SetPixel(int x, int y, const Color& color);
|
||||
Color GetPixel(int x, int y)const;
|
||||
byte* GetPixel();
|
||||
void Earse(const Rect& rect);//抹除矩形内容
|
||||
HBITMAP GetHBITMAP();
|
||||
HDC GetDC();
|
||||
bool Save(const UIString& fileName);
|
||||
Bitmap* Clone()const;
|
||||
virtual ~Bitmap();
|
||||
};
|
||||
};
|
||||
38
demo/Adminstor/ThirdParty/EzUI/include/EzUI/BorderlessWindow.h
vendored
Normal file
38
demo/Adminstor/ThirdParty/EzUI/include/EzUI/BorderlessWindow.h
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
#include "Window.h"
|
||||
#include "ShadowBox.h"
|
||||
|
||||
namespace ezui {
|
||||
/// <summary>
|
||||
/// BorderlessWindow //无边框 带阴影
|
||||
/// </summary>
|
||||
class UI_EXPORT BorderlessWindow :public Window {
|
||||
private:
|
||||
int m_shadowWeight = 20;
|
||||
ShadowBox* m_shadowBox = NULL;
|
||||
float m_shadowScale = 1.0f;
|
||||
//是否支持缩放
|
||||
bool m_bResize = false;
|
||||
protected:
|
||||
virtual LRESULT WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)override;
|
||||
virtual void OnMove(const Point& location) override;
|
||||
virtual void OnSize(const Size& sz) override;
|
||||
virtual void OnDpiChange(float systemScale, const Rect& newRect);//当dpi发生更改时
|
||||
virtual HWND GetShadowHwnd()override;//获取阴影窗口句柄
|
||||
public:
|
||||
//设置阴影宽度
|
||||
void SetShadow(int weight);
|
||||
BorderlessWindow(int width, int height, HWND owner = NULL, DWORD dwStyle = NULL, DWORD dwExStyle = NULL);
|
||||
virtual ~BorderlessWindow();
|
||||
//更新窗口阴影
|
||||
void UpdateShadowBox();
|
||||
//获取阴影窗口
|
||||
ShadowBox* GetShadowBox();
|
||||
//关闭窗口阴影 关掉阴影窗口 已有的边框也会随之消失
|
||||
void CloseShadowBox();
|
||||
//设置窗口缩放支持
|
||||
void SetResizable(bool resize);
|
||||
//是否支持调整大小
|
||||
bool IsResizable();
|
||||
};
|
||||
};
|
||||
14
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Button.h
vendored
Normal file
14
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Button.h
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "Label.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT Button :
|
||||
public Label
|
||||
{
|
||||
private:
|
||||
void Init();
|
||||
public:
|
||||
Button(Object* parentObject = NULL);
|
||||
virtual ~Button();
|
||||
};
|
||||
};
|
||||
33
demo/Adminstor/ThirdParty/EzUI/include/EzUI/CheckBox.h
vendored
Normal file
33
demo/Adminstor/ThirdParty/EzUI/include/EzUI/CheckBox.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include "Label.h"
|
||||
|
||||
namespace ezui {
|
||||
|
||||
class UI_EXPORT CheckBox :
|
||||
public Label
|
||||
{
|
||||
private:
|
||||
bool m_checked = false;
|
||||
public:
|
||||
//选中样式
|
||||
ControlStyle CheckedStyle;
|
||||
//选中状态发送变化的回调函数
|
||||
std::function<void(CheckBox* sender, bool checked)> CheckedChanged = NULL;
|
||||
protected:
|
||||
virtual ControlStyle& GetStyle(const ControlState& _state)override;
|
||||
virtual void OnMouseDown(const MouseEventArgs& arg)override;
|
||||
virtual void OnDpiChange(const DpiChangeEventArgs& args)override;
|
||||
virtual void OnMouseEnter(const MouseEventArgs& args)override;
|
||||
virtual void OnMouseUp(const MouseEventArgs& args)override;
|
||||
virtual void OnMouseLeave(const MouseEventArgs& args)override;
|
||||
public:
|
||||
CheckBox(Object* parentObject = NULL);
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
//设置选中状态
|
||||
virtual void SetCheck(bool checked);
|
||||
//获取选中状态
|
||||
virtual bool GetCheck();
|
||||
virtual ~CheckBox();
|
||||
};
|
||||
|
||||
};
|
||||
51
demo/Adminstor/ThirdParty/EzUI/include/EzUI/ComboBox.h
vendored
Normal file
51
demo/Adminstor/ThirdParty/EzUI/include/EzUI/ComboBox.h
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
#include "TextBox.h"
|
||||
#include "Label.h"
|
||||
#include "VListView.h"
|
||||
#include "PopupWindow.h"
|
||||
#include "HLayout.h"
|
||||
|
||||
namespace ezui {
|
||||
//简易的下拉列表框
|
||||
class UI_EXPORT ComboBox :public HLayout {
|
||||
private:
|
||||
//添加选项请使用AddItem
|
||||
virtual Control* Add(Control* childCtl)override;
|
||||
//移除选项请使用RemoveItem
|
||||
virtual void Remove(Control* childCtl, bool freeCtrl)override;
|
||||
private:
|
||||
//下拉菜单选项
|
||||
class MenuContent :public PopupWindow {
|
||||
public:
|
||||
Control* m_hittestCtl;
|
||||
MenuContent(Control* ownerCtl, Control* hittestCtl);
|
||||
virtual void OnKillFocus(HWND wnd) override;
|
||||
virtual ~MenuContent();
|
||||
};
|
||||
private:
|
||||
//下拉菜单窗口
|
||||
MenuContent* m_menuWnd = NULL;
|
||||
//选择之后显示的文本框
|
||||
TextBox m_textBox;
|
||||
//展开菜单的按钮
|
||||
Label m_UpDown;
|
||||
|
||||
VListView m_list;
|
||||
int m_index = -1;
|
||||
void Init();
|
||||
protected:
|
||||
virtual void OnLayout()override;
|
||||
public:
|
||||
ComboBox(Object* parentObject = NULL);
|
||||
//获取选中的文字
|
||||
UIString GetText();
|
||||
//获取选中的下标
|
||||
int GetCheck();
|
||||
//选中某个下标
|
||||
bool SetCheck(int pos);
|
||||
virtual ~ComboBox();
|
||||
//添加一个item并返回新item的下标
|
||||
int AddItem(const UIString& text);
|
||||
void RemoveItem(int index);
|
||||
};
|
||||
};
|
||||
527
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Control.h
vendored
Normal file
527
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Control.h
vendored
Normal file
@@ -0,0 +1,527 @@
|
||||
#pragma once
|
||||
#include "EzUI.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT Control :public Object
|
||||
{
|
||||
private:
|
||||
|
||||
//顶层窗口句柄
|
||||
HWND m_hWnd = NULL;
|
||||
|
||||
// 控件是否已经被移除或释放
|
||||
bool* m_bRemove = NULL;
|
||||
|
||||
//控件是否被为按住状态
|
||||
bool m_pressed = false;
|
||||
|
||||
// 控件是否启用,禁止状态下鼠标键盘消息将不可用
|
||||
bool m_enabled = true;
|
||||
|
||||
// 控件是否可见。此标志为 true 时,控件为显示状态
|
||||
bool m_bVisible = true;
|
||||
|
||||
// 当前控件的 DPI 缩放比例
|
||||
float m_scale = 1.0f;
|
||||
|
||||
// 子控件集合
|
||||
Controls m_controls;
|
||||
|
||||
// 管理图片的释放
|
||||
PtrManager<Image*> m_imgs;
|
||||
|
||||
// 布局状态
|
||||
// AddControl、InsertControl、RemoveControl、OnSize 时此标志为挂起状态
|
||||
// 调用 ResumeLayout 标志为布局中
|
||||
// 调用 OnLayout() 之后标志为 None
|
||||
ezui::LayoutState m_layoutState = ezui::LayoutState::None;
|
||||
|
||||
// 鼠标悬浮提示文字
|
||||
UIString m_tipsText;
|
||||
|
||||
// 上一次位置
|
||||
Point m_lastLocation;
|
||||
|
||||
// 上一次大小
|
||||
Size m_lastSize;
|
||||
|
||||
// 是否根据内容自动宽度
|
||||
bool m_bAutoWidth = false;
|
||||
|
||||
// 根据内容自动高度变化
|
||||
bool m_bAutoHeight = false;
|
||||
|
||||
// 控件内容宽高
|
||||
Size m_contentSize;
|
||||
|
||||
// 绝对尺寸
|
||||
Size m_fixedSize;
|
||||
|
||||
//比例尺寸(优先级最高)
|
||||
SizeF m_rateSize;
|
||||
|
||||
// 控件矩形区域(基于父控件)
|
||||
Rect m_rect;
|
||||
|
||||
// 控件在窗口中的可见区域
|
||||
Rect m_viewRect;
|
||||
|
||||
// dock 样式
|
||||
DockStyle m_dock = DockStyle::None;
|
||||
|
||||
// 控件是否可以被命中(值为false情况下就是穿透效果)
|
||||
bool m_hitTestEnabled = true;
|
||||
protected:
|
||||
// 基于控件中的可见控件集合
|
||||
Controls ViewControls;
|
||||
// 控件当前状态
|
||||
ControlState State = ControlState::Static;
|
||||
public:
|
||||
// 外边距
|
||||
// 让容器独占一行或一列时,设置边距会使控件变小,不可设置为负数
|
||||
Distance Margin;
|
||||
|
||||
// 控件的 ObjectName ID
|
||||
UIString Name;
|
||||
|
||||
// 控件行为
|
||||
ControlAction Action = ControlAction::None;
|
||||
|
||||
// 静态默认样式
|
||||
ControlStyle Style;
|
||||
|
||||
//禁用状态样式
|
||||
ControlStyle DisabledStyle;
|
||||
|
||||
// 鼠标悬浮样式
|
||||
ControlStyle HoverStyle;
|
||||
|
||||
// 鼠标按下样式
|
||||
ControlStyle ActiveStyle;
|
||||
|
||||
// 父控件指针
|
||||
Control* Parent = NULL;
|
||||
|
||||
//是否添加到所在窗口/IFrame中的OnNotify函数中
|
||||
Event NotifyFlags = Event::OnMouseEvent | Event::OnKeyBoardEvent;
|
||||
// 事件处理器
|
||||
std::function<void(Control*, EventArgs&)> EventHandler = NULL;
|
||||
|
||||
private:
|
||||
// 禁止拷贝构造
|
||||
Control(const Control&) = delete;
|
||||
|
||||
// 禁止赋值
|
||||
Control& operator=(const Control&) = delete;
|
||||
|
||||
// 计算基于父控件的裁剪区域
|
||||
void ComputeClipRect();
|
||||
|
||||
// 所有事件优先进入此函数(内部处理)
|
||||
void OnEvent(EventArgs& arg);
|
||||
|
||||
protected:
|
||||
//属性或者css样式都适用(css样式和属性都可以设置这些,只对静态样式生效)
|
||||
virtual bool ApplyStyleProperty(const UIString& key, const UIString& value);
|
||||
|
||||
// 设置内容宽度,仅限子类使用
|
||||
virtual void SetContentWidth(int width);
|
||||
|
||||
// 设置内容高度,仅限子类使用
|
||||
virtual void SetContentHeight(int height);
|
||||
|
||||
// 设置内容尺寸,仅限子类使用
|
||||
virtual void SetContentSize(const Size& size);
|
||||
|
||||
// 绘制之前
|
||||
virtual void OnPaintBefore(PaintEventArgs& args);
|
||||
|
||||
// 控件绘制
|
||||
virtual void OnPaint(PaintEventArgs& args);
|
||||
|
||||
// 子控件绘制,可重载此函数优化鼠标操作性能
|
||||
virtual void OnChildPaint(PaintEventArgs& args);
|
||||
|
||||
// 背景绘制
|
||||
virtual void OnBackgroundPaint(PaintEventArgs& painter);
|
||||
|
||||
// 前景绘制
|
||||
virtual void OnForePaint(PaintEventArgs& e);
|
||||
|
||||
// 边框绘制
|
||||
virtual void OnBorderPaint(PaintEventArgs& painter, const Border& border);
|
||||
|
||||
// 坐标发生改变
|
||||
virtual void OnMove(const MoveEventArgs& arg);
|
||||
|
||||
// 大小发生改变
|
||||
virtual void OnSize(const SizeEventArgs& arg);
|
||||
|
||||
// DPI 发生改变
|
||||
virtual void OnDpiChange(const DpiChangeEventArgs& arg);
|
||||
|
||||
// 控件布局逻辑,需重写布局请重写此函数
|
||||
virtual void OnLayout();
|
||||
|
||||
// 鼠标在控件上移动
|
||||
virtual void OnMouseMove(const MouseEventArgs& arg);
|
||||
|
||||
// 鼠标离开控件
|
||||
virtual void OnMouseLeave(const MouseEventArgs& args);
|
||||
|
||||
// 鼠标滚轮事件
|
||||
virtual void OnMouseWheel(const MouseEventArgs& arg);
|
||||
|
||||
// 鼠标按下事件
|
||||
virtual void OnMouseDown(const MouseEventArgs& arg);
|
||||
|
||||
// 鼠标弹起事件
|
||||
virtual void OnMouseUp(const MouseEventArgs& arg);
|
||||
|
||||
// 鼠标双击事件
|
||||
virtual void OnMouseDoubleClick(const MouseEventArgs& arg);
|
||||
|
||||
// 鼠标移入控件
|
||||
virtual void OnMouseEnter(const MouseEventArgs& arg);
|
||||
|
||||
// 鼠标事件统一入口
|
||||
virtual void OnMouseEvent(const MouseEventArgs& args);
|
||||
|
||||
// 键盘事件统一入口
|
||||
virtual void OnKeyBoardEvent(const KeyboardEventArgs& _args);
|
||||
|
||||
// 字符输入事件(WM_CHAR)
|
||||
virtual void OnKeyChar(const KeyboardEventArgs& _args);
|
||||
|
||||
// 键盘按下事件(WM_KEYDOWN)
|
||||
virtual void OnKeyDown(const KeyboardEventArgs& _args);
|
||||
|
||||
// 键盘弹起事件(WM_KEYUP)
|
||||
virtual void OnKeyUp(const KeyboardEventArgs& _args);
|
||||
|
||||
// 获得焦点事件
|
||||
virtual void OnFocus(const FocusEventArgs& _args);
|
||||
|
||||
// 失去焦点事件
|
||||
virtual void OnKillFocus(const KillFocusEventArgs& _args);
|
||||
|
||||
// 被移除时执行的逻辑
|
||||
virtual void OnRemove();
|
||||
|
||||
public:
|
||||
// 获取当前控件状态下的样式信息
|
||||
virtual ControlStyle& GetStyle(const ControlState& _state);
|
||||
|
||||
// 获取左上圆角半径
|
||||
int GetBorderTopLeftRadius(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取右上圆角半径
|
||||
int GetBorderTopRightRadius(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取右下圆角半径
|
||||
int GetBorderBottomRightRadius(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取左下圆角半径
|
||||
int GetBorderBottomLeftRadius(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取左边框宽度
|
||||
int GetBorderLeft(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取上边框宽度
|
||||
int GetBorderTop(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取右边框宽度
|
||||
int GetBorderRight(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取下边框宽度
|
||||
int GetBorderBottom(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取边框颜色
|
||||
Color GetBorderColor(ControlState _state = ControlState::None);
|
||||
|
||||
//获取边框样式
|
||||
StrokeStyle GetBorderStyle(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取前景图片
|
||||
Image* GetForeImage(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取背景图片
|
||||
Image* GetBackImage(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取背景颜色
|
||||
Color GetBackColor(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取旋转角度
|
||||
float GetAngle(ControlState _state = ControlState::None);
|
||||
|
||||
//获取当前控件的鼠标光标
|
||||
virtual HCURSOR GetCursor(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取前景颜色
|
||||
Color GetForeColor(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取字体 Family
|
||||
std::wstring GetFontFamily(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取字体大小
|
||||
int GetFontSize(ControlState _state = ControlState::None);
|
||||
|
||||
//获取公共数据
|
||||
WindowData* GetPublicData();
|
||||
|
||||
//获取上层Frame容器
|
||||
IFrame* GetFrame();
|
||||
public:
|
||||
|
||||
// 构造函数 可传入父对象(由父对象自动管理内存)
|
||||
Control(Object* parentObject = NULL);
|
||||
|
||||
// 析构函数
|
||||
virtual ~Control();
|
||||
|
||||
//绑定对象(跟随释放)
|
||||
using Object::Attach;
|
||||
|
||||
//分离对象(解除跟随释放)
|
||||
using Object::Detach;
|
||||
|
||||
//绑定图片(跟随释放)
|
||||
Image* Attach(Image* img);
|
||||
|
||||
//分离图片(解除跟随释放)
|
||||
void Detach(Image* img);
|
||||
|
||||
//窗口句柄
|
||||
HWND Hwnd();
|
||||
|
||||
//设置窗口句柄
|
||||
void SetHwnd(HWND hWnd);
|
||||
|
||||
// 以下函数请保证在父控件布局已完成的情况下使用,使用 ResumeLayout() 执行布局
|
||||
// 获取 X 坐标
|
||||
int X();
|
||||
|
||||
// 获取 Y 坐标
|
||||
int Y();
|
||||
|
||||
// 获取宽度
|
||||
int Width();
|
||||
|
||||
// 获取高度
|
||||
int Height();
|
||||
|
||||
// 设置 X 坐标
|
||||
void SetX(int X);
|
||||
|
||||
// 设置 Y 坐标
|
||||
void SetY(int Y);
|
||||
|
||||
// 移动相对于父控件的位置
|
||||
void SetLocation(const Point& pt);
|
||||
|
||||
// 设置控件大小(当重绘控件时不建议多次使用,影响性能,会调用 SetRect 函数)
|
||||
void SetSize(const Size& size);
|
||||
|
||||
// 设置绝对宽高
|
||||
void SetFixedSize(const Size& size);
|
||||
|
||||
// 设置宽度(当重绘控件时不建议多次使用,影响性能,会调用 SetRect 函数)
|
||||
void SetWidth(int width);
|
||||
|
||||
// 设置高度(当重绘控件时不建议多次使用,影响性能,会调用 SetRect 函数)
|
||||
void SetHeight(int height);
|
||||
|
||||
// 设置绝对宽度
|
||||
void SetFixedWidth(int fixedWidth);
|
||||
|
||||
// 设置绝对高度
|
||||
void SetFixedHeight(int fixedHeight);
|
||||
|
||||
//设置宽度比例(优先级最高)
|
||||
void SetRateWidth(float rateWidth);
|
||||
|
||||
//设置高度比例(优先级最高)
|
||||
void SetRateHeight(float rateHeight);
|
||||
|
||||
// 设置相对父控件矩形,返回实际的 rect
|
||||
const Rect& SetRect(const Rect& rect);
|
||||
|
||||
// 获取绝对宽度
|
||||
int GetFixedWidth();
|
||||
|
||||
// 获取绝对高度
|
||||
int GetFixedHeight();
|
||||
|
||||
// 获取光标位置
|
||||
virtual Rect GetCareRect();
|
||||
|
||||
// 是否自动宽度
|
||||
virtual bool IsAutoWidth();
|
||||
|
||||
// 是否自动高度
|
||||
virtual bool IsAutoHeight();
|
||||
|
||||
// 设置自动宽度
|
||||
virtual void SetAutoWidth(bool flag);
|
||||
|
||||
// 设置自动高度
|
||||
virtual void SetAutoHeight(bool flag);
|
||||
|
||||
// 设置自动大小
|
||||
virtual void SetAutoSize(bool flag);
|
||||
|
||||
// 获取控件内容大小
|
||||
virtual const Size& GetContentSize();
|
||||
|
||||
// 获取控件大小
|
||||
Size GetSize();
|
||||
|
||||
// 获取控件位置
|
||||
Point GetLocation();
|
||||
|
||||
// 获取相对于父控件的矩形(布局计算后)
|
||||
virtual const Rect& GetRect();
|
||||
|
||||
// 获取基于客户端区域的矩形
|
||||
Rect GetClientRect();
|
||||
|
||||
//获取控件基于屏幕的矩形位置
|
||||
Rect GetScreenRect();
|
||||
|
||||
// 获取控件的 DockStyle(停靠方式)
|
||||
DockStyle GetDockStyle();
|
||||
|
||||
// 设置控件的 DockStyle
|
||||
void SetDockStyle(const DockStyle& dockStyle);
|
||||
|
||||
// 获取控件的缩放系数
|
||||
float GetScale();
|
||||
|
||||
// 是否存在挂起的布局
|
||||
bool IsPendLayout();
|
||||
|
||||
// 尝试挂起布局,返回当前布局状态
|
||||
const LayoutState TryPendLayout();
|
||||
|
||||
// 获取当前布局状态
|
||||
const LayoutState GetLayoutState();
|
||||
|
||||
// 结束当前布局(使其立即生效)
|
||||
void EndLayout();
|
||||
|
||||
// 立即强制刷新布局
|
||||
virtual void RefreshLayout();
|
||||
|
||||
// 设置提示文字(类似 tooltip)
|
||||
void SetTips(const UIString& text);
|
||||
|
||||
// 获取提示文字
|
||||
const UIString& GetTips();
|
||||
|
||||
// 获取控件的滚动条对象
|
||||
virtual ScrollBar* GetScrollBar();
|
||||
|
||||
// 派发事件(如鼠标单击事件等...)返回true则事件成功派发 返回false代表派发途中当前控件已被释放
|
||||
void SendEvent(const EventArgs& arg);
|
||||
|
||||
// 设置控件属性
|
||||
virtual void SetAttribute(const UIString& attrName, const UIString& attrValue);
|
||||
|
||||
// 获取当前可见的子控件集合
|
||||
const Controls& GetViewControls();
|
||||
|
||||
// 获取所有子控件(不建议直接修改)
|
||||
const Controls& GetControls();
|
||||
|
||||
// 使用下标获取控件,自动跳过 spacer 类控件
|
||||
Control* GetControl(int pos);
|
||||
|
||||
// 是否包含指定控件(递归遍历所有子控件)
|
||||
bool Contains(Control* ctl);
|
||||
|
||||
// 获取指定子控件的索引
|
||||
int IndexOf(Control* childCtl);
|
||||
|
||||
// 根据 name 查找控件(包括自身)
|
||||
Control* FindControl(const UIString& ctlName);
|
||||
|
||||
// 根据属性查找所有匹配控件(包括自身)
|
||||
Controls FindControl(const UIString& attrName, const UIString& attrValue);
|
||||
|
||||
// 根据属性查找第一个匹配控件(包括自身)
|
||||
Control* FindSingleControl(const UIString& attrName, const UIString& attrValue);
|
||||
|
||||
// 根据 name 查找子控件(仅限直接子集)
|
||||
Control* FindChild(const UIString& ctlName);
|
||||
|
||||
// 根据属性查找所有匹配的子控件(仅限直接子集)
|
||||
Controls FindChild(const UIString& attrName, const UIString& attrValue);
|
||||
|
||||
// 根据属性查找第一个匹配的子控件(仅限直接子集)
|
||||
Control* FindSingleChild(const UIString& attrName, const UIString& attrValue);
|
||||
|
||||
// 交换两个子控件的位置
|
||||
virtual bool SwapChild(Control* childCtl, Control* childCt2);
|
||||
|
||||
//是否启用控件
|
||||
void SetEnabled(bool flag);
|
||||
|
||||
//是否禁用控件
|
||||
void SetDisabled(bool flag);
|
||||
|
||||
//控件是否已启用
|
||||
bool IsEnabled();
|
||||
|
||||
// 在指定位置插入子控件
|
||||
virtual void Insert(int pos, Control* childCtl);
|
||||
|
||||
// 添加控件到末尾(如果是弹簧控件,在释放时将自动销毁)
|
||||
virtual Control* Add(Control* childCtl);
|
||||
|
||||
// 移除控件,freeCtrl 标志是否释放控件内存
|
||||
virtual void Remove(Control* childCtl, bool freeCtrl = false);
|
||||
|
||||
// 设置控件的父控件
|
||||
virtual void SetParent(Control* parentCtl);
|
||||
|
||||
// 清空所有子控件
|
||||
virtual void Clear();
|
||||
|
||||
// 清空所有子控件,freeChilds 决定是否释放子控件内存
|
||||
virtual void Clear(bool freeChilds);
|
||||
|
||||
// 设置控件可见性
|
||||
virtual void SetVisible(bool flag);
|
||||
|
||||
// 获取控件可见性状态
|
||||
virtual bool IsVisible();
|
||||
|
||||
//设置控件是否可以被鼠标命中(false则是鼠标穿透效果)
|
||||
void SetHitTestVisible(bool bEnable);
|
||||
|
||||
//控件是否可以被命中
|
||||
bool IsHitTestVisible();
|
||||
|
||||
//隐藏控件
|
||||
void Hide();
|
||||
|
||||
//显示控件
|
||||
void Show();
|
||||
|
||||
// 标记控件区域为无效(将会延迟刷新UI)
|
||||
virtual bool Invalidate();
|
||||
|
||||
// 立即强制刷新控件区域并更新无效区域(且立即触发布局)
|
||||
virtual void Refresh();
|
||||
|
||||
//传入Style的引用 处理key value
|
||||
virtual void SetStyle(ControlStyle& style, const UIString& key, const UIString& value);
|
||||
|
||||
//传入状态并分析样式字符串
|
||||
virtual void SetStyleSheet(ControlState state, const UIString& styleStr);
|
||||
|
||||
//控件是否被按住
|
||||
bool IsPressed();
|
||||
};
|
||||
|
||||
};
|
||||
268
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Direct2DRender.h
vendored
Normal file
268
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Direct2DRender.h
vendored
Normal file
@@ -0,0 +1,268 @@
|
||||
#pragma once
|
||||
#include "UIDef.h"
|
||||
#if USED_DIRECT2D
|
||||
#ifndef UI_EXPORT
|
||||
#define UI_EXPORT
|
||||
#endif
|
||||
|
||||
#include <d2d1.h>
|
||||
#include <d2d1helper.h>
|
||||
#include <dwrite.h>
|
||||
#include <wincodec.h>
|
||||
#include "RenderTypes.h"
|
||||
|
||||
namespace ezui {
|
||||
UI_EXPORT void RenderInitialize();//全局初始化direct2d
|
||||
UI_EXPORT void RenderUnInitialize();//释放direct2d
|
||||
UI_EXPORT float GetMaxRadius(float width, float height, float _radius);//获取最大半径 用于自动适应border-radius属性
|
||||
class UI_EXPORT Font {
|
||||
private:
|
||||
Font() = delete;
|
||||
std::wstring m_fontFamily;
|
||||
float m_fontSize = 0;
|
||||
IDWriteTextFormat* m_value = NULL;
|
||||
bool m_ref = false;
|
||||
void Copy(const Font& _copy);
|
||||
public:
|
||||
Font(const Font& _copy);
|
||||
Font(const std::wstring& fontFamily, float fontSize);
|
||||
float GetFontSize()const;
|
||||
const std::wstring& GetFontFamily()const;
|
||||
IDWriteTextFormat* Get() const;
|
||||
bool operator==(const Font& _right);
|
||||
virtual ~Font();
|
||||
};
|
||||
|
||||
//文本命中测试数据
|
||||
class UI_EXPORT HitTestMetrics {
|
||||
public:
|
||||
int Length;
|
||||
int TextPos;//命中的下标
|
||||
RectF FontBox;//文字的矩形位置
|
||||
bool IsTrailingHit;//命中位置是否在尾部
|
||||
public:
|
||||
Rect GetCare() {
|
||||
float x = FontBox.X;
|
||||
if (IsTrailingHit) {
|
||||
x += FontBox.Width;
|
||||
}
|
||||
float y = FontBox.Y;
|
||||
return Rect((int)x, (int)y, 1, (int)(FontBox.Height + 0.5));
|
||||
}
|
||||
int GetFontHeight() {
|
||||
return int(FontBox.Height + 0.5);
|
||||
}
|
||||
};
|
||||
|
||||
class UI_EXPORT TextLayout {
|
||||
private:
|
||||
TextLayout(const TextLayout& rightValue) = delete;
|
||||
IDWriteTextLayout* m_textLayout = NULL;
|
||||
std::wstring m_fontFamily;
|
||||
DWRITE_TEXT_METRICS m_textMetrics = {};
|
||||
std::vector<RectF> m_lineRects;
|
||||
int m_unicodeSize = 0;
|
||||
float m_fontSize = 0;
|
||||
public:
|
||||
void GetMetrics();
|
||||
TextLayout(const std::wstring& text, const Font& font, const SizeF& maxSize = SizeF{ EZUI_FLOAT_MAX,EZUI_FLOAT_MAX }, TextAlign textAlgin = TextAlign::TopLeft);
|
||||
Point HitTestPoint(const Point& pt, int* outTextPos, BOOL* outIsTrailingHit, int* fontHeight);
|
||||
void HitTestPoint(const Point& pt, HitTestMetrics* hitTestMetrics);//根据坐标执行命中测试
|
||||
Point HitTestTextPosition(int textPos, BOOL isTrailingHit);//根据文字下标执行命中测试
|
||||
const std::wstring& GetFontFamily();
|
||||
float GetFontSize();
|
||||
int Width();
|
||||
int Height();
|
||||
//获取文本整体的占用空间
|
||||
Size GetFontBox();
|
||||
//获取每行文字的矩形位置
|
||||
const std::vector<RectF>& GetLineRects();
|
||||
int GetFontHeight();//获取字体高度
|
||||
int GetLineCount();//获取一共有多少行
|
||||
IDWriteTextLayout* Get() const;
|
||||
void SetTextAlign(TextAlign textAlign);
|
||||
void SetUnderline(int pos = 0, int count = 0);
|
||||
virtual ~TextLayout();
|
||||
};
|
||||
|
||||
//几何图形基础类(支持自定义路径)
|
||||
class UI_EXPORT Geometry {
|
||||
protected:
|
||||
ID2D1GeometrySink* m_pSink = NULL;
|
||||
ID2D1Geometry* m_rgn = NULL;
|
||||
Geometry(const Geometry& rightCopy) = delete;
|
||||
public:
|
||||
Geometry();
|
||||
virtual ~Geometry();
|
||||
void AddArc(const PointF& endPoint, float radius);
|
||||
void AddAcr(const D2D1_ARC_SEGMENT& arc);
|
||||
void AddLine(const PointF& endPoint);
|
||||
void BeginFigure(const PointF& startPoint, D2D1_FIGURE_BEGIN figureBegin = D2D1_FIGURE_BEGIN_FILLED);
|
||||
void CloseFigure(D2D1_FIGURE_END figureEnd = D2D1_FIGURE_END_CLOSED);
|
||||
ID2D1Geometry* Get()const;
|
||||
public:
|
||||
/// <summary>
|
||||
/// 将两个几何图形通过指定的合并模式(Union、Intersect、Xor、Exclude)合并到一个输出几何中。
|
||||
/// </summary>
|
||||
/// <param name="out">合并结果输出到该 Geometry。</param>
|
||||
/// <param name="a">参与合并的第一个 Geometry。</param>
|
||||
/// <param name="b">参与合并的第二个 Geometry。</param>
|
||||
/// <param name="COMBINE_MODE">几何合并模式,取值如 D2D1_COMBINE_MODE_UNION、INTERSECT、XOR、EXCLUDE。</param>
|
||||
static void Combine(Geometry& out, const Geometry& a, const Geometry& b, D2D1_COMBINE_MODE COMBINE_MODE);
|
||||
|
||||
/// <summary>
|
||||
/// 合并两个区域,取它们的联合部分(即最大边界区域)。
|
||||
/// </summary>
|
||||
static void Union(Geometry& out, const Geometry& a, const Geometry& b) {
|
||||
Combine(out, a, b, D2D1_COMBINE_MODE::D2D1_COMBINE_MODE_UNION);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取两个区域的交集部分。
|
||||
/// </summary>
|
||||
static void Intersect(Geometry& out, const Geometry& a, const Geometry& b) {
|
||||
Combine(out, a, b, D2D1_COMBINE_MODE::D2D1_COMBINE_MODE_INTERSECT);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合并两个区域,保留不重叠的部分(异或运算)。
|
||||
/// </summary>
|
||||
static void Xor(Geometry& out, const Geometry& a, const Geometry& b) {
|
||||
Combine(out, a, b, D2D1_COMBINE_MODE::D2D1_COMBINE_MODE_XOR);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从第一个区域中排除第二个区域的部分(差集)。
|
||||
/// </summary>
|
||||
static void Exclude(Geometry& out, const Geometry& a, const Geometry& b) {
|
||||
Combine(out, a, b, D2D1_COMBINE_MODE::D2D1_COMBINE_MODE_EXCLUDE);
|
||||
}
|
||||
};
|
||||
|
||||
//矩形(已经完成闭合)
|
||||
class UI_EXPORT RectangleGeometry :public Geometry {
|
||||
private:
|
||||
void Create(float x, float y, float width, float height, float _radius);
|
||||
public:
|
||||
RectangleGeometry(float x, float y, float width, float height, float _radius = 0);
|
||||
RectangleGeometry(const RectF& _rect, float radius = 0);
|
||||
RectangleGeometry(const RectF& _rect, float topLeftRadius, float topRightRadius, float bottomRightRadius, float bottomLeftRadius);
|
||||
virtual ~RectangleGeometry() {};
|
||||
};
|
||||
|
||||
//扇形(已经完成闭合)
|
||||
class UI_EXPORT PieGeometry :public Geometry {
|
||||
public:
|
||||
PieGeometry(const RectF& rectF, float startAngle, float endAngle);
|
||||
virtual ~PieGeometry() {};
|
||||
};
|
||||
|
||||
//圆形/椭圆(已经完成闭合)
|
||||
class UI_EXPORT EllipseGeometry :public PieGeometry {
|
||||
public:
|
||||
EllipseGeometry(const RectF& rectF) :PieGeometry(rectF, 0, 360) {}
|
||||
virtual ~EllipseGeometry() {};
|
||||
};
|
||||
|
||||
class UI_EXPORT DXImage : public IImage {
|
||||
struct GifFrame
|
||||
{
|
||||
IWICBitmap* wicBitmap; // 存一份完整帧
|
||||
UINT delay;
|
||||
};
|
||||
protected:
|
||||
std::vector<GifFrame> m_frames;
|
||||
IWICBitmapDecoder* m_bitmapdecoder = NULL;
|
||||
IWICBitmapFrameDecode* m_pframe = NULL;
|
||||
IWICFormatConverter* m_fmtcovter = NULL;//从文件加载
|
||||
IWICBitmap* m_bitMap = NULL;//从HBITMAP中加载
|
||||
int m_width = 0;
|
||||
int m_height = 0;
|
||||
ID2D1Bitmap* m_d2dBitmap = NULL;
|
||||
private:
|
||||
void CreateFormStream(IStream* istram);
|
||||
void CreateFromFile(const std::wstring& file);
|
||||
void Init();
|
||||
public:
|
||||
bool Visible = true;
|
||||
void DecodeOfRender(ID2D1RenderTarget* render);
|
||||
//如果HBITMAP带有透明通道 确保传入的图像颜色值已经与 Alpha 通道预乘
|
||||
DXImage(HBITMAP hBitmap);
|
||||
DXImage(IStream* istram);
|
||||
DXImage(const std::wstring& file);
|
||||
//创建带预乘Alpha的BGRA图片
|
||||
DXImage(int width, int height);
|
||||
DXImage(const void* data, size_t count);
|
||||
ID2D1Bitmap* Get();
|
||||
IWICBitmap* GetIWICBitmap();
|
||||
int Width();
|
||||
int Height();
|
||||
virtual WORD NextFrame()override;
|
||||
DXImage* Clone();
|
||||
virtual ~DXImage();
|
||||
};
|
||||
|
||||
class Bezier {
|
||||
public:
|
||||
Point point1;
|
||||
Point point2;
|
||||
Point point3;
|
||||
};
|
||||
};
|
||||
|
||||
namespace ezui {
|
||||
|
||||
class UI_EXPORT DXRender {
|
||||
private:
|
||||
ID2D1DCRenderTarget* m_render = NULL;
|
||||
ID2D1SolidColorBrush* m_brush = NULL;
|
||||
Font* m_font = NULL;
|
||||
ID2D1StrokeStyle* m_pStrokeStyle = NULL;
|
||||
Point m_offset;
|
||||
PointF m_rotatePoint;
|
||||
float m_angle = 0;
|
||||
private:
|
||||
DXRender(const DXRender& rightValue) = delete;
|
||||
public:
|
||||
ID2D1SolidColorBrush* GetBrush();
|
||||
ID2D1StrokeStyle* GetStrokeStyle();
|
||||
public:
|
||||
DXRender(DXImage* dxImage);
|
||||
DXRender(HDC dc, int x, int y, int width, int height);//创建dx绘图对象
|
||||
virtual ~DXRender();
|
||||
void SetFont(const std::wstring& fontFamily, float fontSize);//必须先调用
|
||||
void SetFont(const Font& _copy_font);//必须先调用
|
||||
void SetColor(const __EzUI__Color& color);//会之前必须调用
|
||||
void SetStrokeStyle(StrokeStyle strokeStyle = StrokeStyle::Solid);//设置样式 虚线/实线
|
||||
void DrawTextLayout(const TextLayout& textLayout, const PointF & = { 0,0 });//根据已有的布局绘制文字
|
||||
void DrawString(const std::wstring& text, const RectF& _rect, ezui::TextAlign textAlign);//绘制文字
|
||||
void DrawLine(const PointF& _A, const PointF& _B, float width = 1);//绘制一条线
|
||||
void DrawRectangle(const RectF& _rect, float _radius = 0, float width = 1);//绘制矩形
|
||||
void FillRectangle(const RectF& _rect, float _radius = 0);
|
||||
//填充矩形
|
||||
void PushLayer(const Geometry& dxGeometry);
|
||||
void PopLayer();
|
||||
void PushAxisAlignedClip(const RectF& rectBounds);
|
||||
void PopAxisAlignedClip();
|
||||
void SetTransform(float offsetX, float offsetY);//对画布进行旋转和偏移
|
||||
void SetTransform(float startX, float startY, float angle);//设置旋转起始点与旋转角度
|
||||
void SetTransform(float offsetX, float offsetY, float startX, float startY, float angle);
|
||||
void DrawImage(DXImage* _image, const RectF& tagRect, float opacity = 1);//绘制图像
|
||||
void DrawBezier(const PointF& startPoint, const Bezier& points, float width = 1);//贝塞尔线
|
||||
void DrawBezier(const PointF& startPoint, std::list<Bezier>& points, float width = 1);//贝塞尔线
|
||||
void DrawEllipse(const RectF& rectF, float width = 1);
|
||||
void FillEllipse(const RectF& rectF);
|
||||
void DrawPie(const RectF& rectF, float startAngle, float endAngle, float strokeWidth = 1);
|
||||
void FillPie(const RectF& rectF, float startAngle, float endAngle);
|
||||
void DrawPoint(const PointF& pt);
|
||||
void DrawArc(const RectF& rect, float startAngle, float sweepAngle, float width = 1);//未实现
|
||||
void DrawArc(const PointF& point1, const PointF& point2, const PointF& point3, float width = 1);
|
||||
void DrawGeometry(ID2D1Geometry* path, float width = 1);
|
||||
void FillGeometry(ID2D1Geometry* path);
|
||||
void DrawGeometry(Geometry* path, float width = 1);
|
||||
void FillGeometry(Geometry* path);
|
||||
void Flush();
|
||||
ID2D1DCRenderTarget* Get();//获取原生DX对象
|
||||
};
|
||||
};
|
||||
#endif
|
||||
530
demo/Adminstor/ThirdParty/EzUI/include/EzUI/EzUI.h
vendored
Normal file
530
demo/Adminstor/ThirdParty/EzUI/include/EzUI/EzUI.h
vendored
Normal file
@@ -0,0 +1,530 @@
|
||||
/*/
|
||||
Author:yang
|
||||
Email:19980103ly@gmail.com/718987717@qq.com
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "UIDef.h"
|
||||
#include "UIString.h"
|
||||
#include "Resource.h"
|
||||
#include "RenderTypes.h"
|
||||
#include "Direct2DRender.h"
|
||||
|
||||
#undef LoadCursor
|
||||
#undef LoadIcon
|
||||
|
||||
namespace ezui {
|
||||
struct MonitorInfo;
|
||||
class Object;
|
||||
class EventArgs;
|
||||
class ControlStyle;
|
||||
class IFrame;
|
||||
class Control;
|
||||
class Window;
|
||||
class Spacer;
|
||||
class ScrollBar;
|
||||
class Bitmap;
|
||||
enum class Cursor :ULONG_PTR;
|
||||
|
||||
#if 1
|
||||
typedef std::vector<Control*> Controls;
|
||||
#else
|
||||
class UI_EXPORT Controls :public std::list<Control*> {
|
||||
public:
|
||||
//不要频繁使用此函数
|
||||
inline Control* operator[](size_t right_pos)const
|
||||
{
|
||||
size_t pos = 0;
|
||||
for (auto& it : *this) {
|
||||
if (pos == right_pos) {
|
||||
return it;
|
||||
}
|
||||
++pos;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
//全局资源句柄
|
||||
extern UI_VAR_EXPORT HMODULE __EzUI__HINSTANCE;//全局实例
|
||||
extern UI_VAR_EXPORT Resource* __EzUI__Resource;//文件中的全局资源句柄
|
||||
extern UI_VAR_EXPORT DWORD __EzUI__ThreadId;//UI的线程Id
|
||||
extern UI_VAR_EXPORT HWND __EzUI_MessageWnd;//用于UI通讯的隐形窗口
|
||||
extern UI_VAR_EXPORT const std::list<ezui::MonitorInfo> __EzUI__MonitorInfos;//所有监视器信息
|
||||
|
||||
//判断两个float是相等(两数是否接近)
|
||||
extern UI_EXPORT bool IsFloatEqual(float num1, float num2);
|
||||
//加载HICON
|
||||
extern UI_EXPORT HICON LoadIcon(const UIString& fileName);
|
||||
//装载字体
|
||||
extern UI_EXPORT void InstallFont(const UIString& fontFileName);
|
||||
//卸载字体
|
||||
extern UI_EXPORT void UnstallFont(const UIString& fontFileName);
|
||||
//复制内容到剪切板
|
||||
extern UI_EXPORT bool CopyToClipboard(int uFormat, void* pData, size_t size, HWND hWnd = NULL);
|
||||
//打开剪切板
|
||||
extern UI_EXPORT bool GetClipboardData(int uFormat, std::function<void(void*, size_t)> Callback, HWND hWnd = NULL);
|
||||
//复制unicode文字
|
||||
extern UI_EXPORT bool CopyToClipboard(const std::wstring& str, HWND hWnd = NULL);
|
||||
//粘贴unicode文字
|
||||
extern UI_EXPORT bool GetClipboardData(std::wstring* outStr, HWND hWnd = NULL);
|
||||
//自动获取文件资源(本地文件/资源文件)
|
||||
extern UI_EXPORT bool GetResource(const UIString& fileName, std::string* outData);
|
||||
//获取当前所有监视器的信息
|
||||
extern UI_EXPORT size_t GetMonitor(std::list<MonitorInfo>* outMonitorInfo);
|
||||
//获取用户当前所在的显示器
|
||||
extern UI_EXPORT void GetMontior(MonitorInfo* outInfo, HWND hWnd = NULL);
|
||||
//使用窗口的矩形位置获取所在的显示器
|
||||
extern UI_EXPORT void GetMontior(MonitorInfo* outInfo, const Rect& rect);
|
||||
//加载光标
|
||||
extern UI_EXPORT HCURSOR LoadCursor(Cursor cursorType);
|
||||
//加载光标(//需要释放)
|
||||
extern UI_EXPORT HCURSOR LoadCursor(const UIString& fileName);
|
||||
//释放光标
|
||||
extern UI_EXPORT void FreeCursor(HCURSOR hCursor);
|
||||
//默认处理OnNotify函数(处理一些控件的基础行为)
|
||||
extern UI_EXPORT void DefaultNotify(Control* sender, EventArgs& args);
|
||||
|
||||
class UI_EXPORT Color :public ezui::__EzUI__Color {
|
||||
public:
|
||||
Color(const ezui::__EzUI__Color& copy) { this->BGRA = copy.GetValue(); }
|
||||
Color(const DWORD& rgba = 0) :ezui::__EzUI__Color(rgba) {}
|
||||
Color(BYTE r, BYTE g, BYTE b, BYTE a = 255) :ezui::__EzUI__Color(r, g, b, a) {}
|
||||
public:
|
||||
//构建一个Color
|
||||
static Color Make(const UIString& colorStr, bool* isGood = NULL);
|
||||
virtual ~Color() {}
|
||||
};
|
||||
|
||||
#if USED_DIRECT2D
|
||||
class UI_EXPORT Image :public DXImage {
|
||||
private:
|
||||
#ifdef _DEBUG
|
||||
UIString m_path;
|
||||
#endif
|
||||
public:
|
||||
virtual ~Image() {}
|
||||
//创建带预乘Alpha的BGRA图片
|
||||
Image(int width, int height) :DXImage(width, height) {}
|
||||
Image(HBITMAP hBitmap) :DXImage(hBitmap) {}
|
||||
Image(Bitmap* bitmap);
|
||||
Image(IStream* iStream) :DXImage(iStream) {}
|
||||
Image(const std::wstring& fileName) :DXImage(fileName) {}
|
||||
Image(const void* data, size_t dataCount) :DXImage(data, dataCount) {}
|
||||
public:
|
||||
//从资源或者本地文件自动构建一个Image
|
||||
static Image* Make(const UIString& fileOrRes);
|
||||
};
|
||||
#endif
|
||||
// 定义用于保存显示器信息的结构体
|
||||
struct MonitorInfo {
|
||||
HMONITOR Monitor = NULL;
|
||||
//显示器的位置 多显示器下Y轴可能出现负数或者大于0的时候代表显示器在设置里面显示器是错位的(多显示器没有平行);
|
||||
//逻辑宽高
|
||||
ezui::Rect Rect;
|
||||
//工作区域
|
||||
ezui::Rect WorkRect;
|
||||
//显示器物理宽高
|
||||
Size Physical;
|
||||
//显示器缩放比例 1.0 1.25 1.5 1.75 2.0
|
||||
float Scale = 1.0f;
|
||||
//显示器帧率
|
||||
float FPS = 60;
|
||||
//是否为主显示器
|
||||
bool Primary = false;
|
||||
};
|
||||
struct WindowData {
|
||||
//缩放率
|
||||
float Scale = 1.0f;
|
||||
//单次绘图数量
|
||||
int PaintCount = 0;
|
||||
#ifdef _DEBUG
|
||||
//是否开启debug模式
|
||||
bool Debug = false;
|
||||
//调试模式下的特有字段
|
||||
int ColorIndex = 0;
|
||||
Color DebugColor;
|
||||
std::vector<Color> DebugColors{ Color::Red,Color::Green,Color::Blue,Color::Black,Color::White };
|
||||
#endif
|
||||
//主窗类的实例
|
||||
ezui::Window* Window = NULL;
|
||||
//使一个区域无效
|
||||
std::function<void(const Rect&)> InvalidateRect = NULL;
|
||||
//立即更新全部无效区域
|
||||
std::function<void()> Refresh = NULL;
|
||||
//清空控件标记等等...
|
||||
std::function<void(Control*)> CleanControl = NULL;
|
||||
//内部移动窗口的函数
|
||||
std::function<void()> MoveWindow = NULL;
|
||||
//内部使用标题部分移动窗口的函数
|
||||
std::function<void()> TitleMoveWindow = NULL;
|
||||
//处理消息过程的回调函数
|
||||
std::function<LRESULT(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)> WndProc = NULL;
|
||||
|
||||
#ifdef _DEBUG
|
||||
virtual ~WindowData() {
|
||||
}
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
enum class LayoutState {
|
||||
//无状态 (无需布局)
|
||||
None,
|
||||
//挂起中
|
||||
Pend,
|
||||
//布局中
|
||||
Layouting
|
||||
};
|
||||
enum Event :long long {
|
||||
None = 1,
|
||||
OnMouseWheel = 2,
|
||||
OnMouseEnter = 4,
|
||||
OnMouseMove = 8,
|
||||
OnMouseLeave = 16,
|
||||
OnMouseDoubleClick = 32,
|
||||
OnMouseDown = 64,
|
||||
OnMouseUp = 128,
|
||||
OnKeyDown = 256,
|
||||
OnKeyUp = 512,
|
||||
OnPaint = 1024,
|
||||
OnFocus = 2048,
|
||||
OnKillFocus = 4096,
|
||||
OnKeyChar = 8192,
|
||||
OnMove = 16384,
|
||||
OnSize = 32768,
|
||||
OnRect = 65536,
|
||||
OnDpiChange = 131072,
|
||||
OnActive = OnMouseDown | OnMouseUp,
|
||||
OnHover = OnMouseEnter | OnMouseLeave,
|
||||
OnMouseDrag = OnMouseDown | OnMouseMove,
|
||||
OnMouseEvent = OnMouseWheel | OnMouseEnter | OnMouseMove | OnMouseLeave | OnMouseDoubleClick | OnMouseDown | OnMouseUp,
|
||||
OnKeyBoardEvent = OnKeyDown | OnKeyUp | OnKeyChar
|
||||
};
|
||||
//重载枚举的 | 运算符
|
||||
inline Event operator|(Event left, Event right)
|
||||
{
|
||||
return static_cast<Event>(static_cast<long long>(left) | static_cast<long long>(right));
|
||||
}
|
||||
//控件行为
|
||||
enum class ControlAction {
|
||||
None,
|
||||
Title,//具有移动窗口 双击最大化窗口的行为
|
||||
MoveWindow,//移动窗口
|
||||
Mini,//最小化
|
||||
Max,//最大化|恢复
|
||||
Close//关闭
|
||||
};
|
||||
enum class ControlState :int {
|
||||
None = 1,//无状态 则是使用_nowStyle缓存样式
|
||||
Static = 2,//静态
|
||||
Disabled = 4,//禁用状态
|
||||
Checked = 8,//选中状态
|
||||
Hover = 16,//鼠标悬浮
|
||||
Active = 32//鼠标按住
|
||||
};
|
||||
EZUI_ENUM_OPERATORS(ControlState, int);
|
||||
|
||||
enum class DockStyle {
|
||||
// 摘要:
|
||||
//未设置
|
||||
None,
|
||||
// 摘要:
|
||||
//在父控件中 左右保持
|
||||
Horizontal,
|
||||
// 摘要:
|
||||
//在父控件中 上下保持
|
||||
Vertical,
|
||||
// 摘要:
|
||||
// 铺满整个父控件
|
||||
Fill
|
||||
};
|
||||
enum class MouseButton {
|
||||
// 摘要:
|
||||
// 未曾按下鼠标按钮。
|
||||
None,
|
||||
//
|
||||
// 摘要:
|
||||
// 鼠标左按钮曾按下。
|
||||
Left,
|
||||
//
|
||||
// 摘要:
|
||||
// 鼠标右按钮曾按下。
|
||||
Right,
|
||||
//
|
||||
// 摘要:
|
||||
// 鼠标中按钮曾按下。
|
||||
Middle,
|
||||
//
|
||||
// 摘要:
|
||||
// 第 1 个 XButton 曾按下。
|
||||
XButton1,
|
||||
//
|
||||
// 摘要:
|
||||
// 第 2 个 XButton 曾按下。
|
||||
XButton2
|
||||
};
|
||||
enum class Cursor :ULONG_PTR
|
||||
{
|
||||
None = 0,//未指定
|
||||
APPSTARTING = (ULONG_PTR)IDC_APPSTARTING,// 标准的箭头和小沙漏
|
||||
ARROW = (ULONG_PTR)IDC_ARROW,// 标准的箭头
|
||||
CROSS = (ULONG_PTR)IDC_CROSS,// 十字光标
|
||||
HAND = (ULONG_PTR)IDC_HAND,// Windows 98/Me, Windows 2000/XP: Hand
|
||||
HELP = (ULONG_PTR)IDC_HELP,// 标准的箭头和问号
|
||||
IBEAM = (ULONG_PTR)IDC_IBEAM,// 工字光标
|
||||
ICON = (ULONG_PTR)IDC_ICON,// Obsolete for applications marked version 4.0 or later.
|
||||
NO = (ULONG_PTR)IDC_NO,// 禁止圈
|
||||
SIZE = (ULONG_PTR)IDC_SIZE,// Obsolete for applications marked version 4.0 or later. Use SIZEALL.
|
||||
SIZEALL = (ULONG_PTR)IDC_SIZEALL,// 四向箭头指向东、西、南、北
|
||||
SIZENESW = (ULONG_PTR)IDC_SIZENESW,// 双箭头指向东北和西南
|
||||
SIZENS = (ULONG_PTR)IDC_SIZENS, // 双箭头指向南北
|
||||
SIZENWSE = (ULONG_PTR)IDC_SIZENWSE,// 双箭头指向西北和东南
|
||||
SIZEWE = (ULONG_PTR)IDC_SIZEWE,// 双箭头指向东西
|
||||
UPARROW = (ULONG_PTR)IDC_UPARROW,// 垂直箭头
|
||||
WAIT = (ULONG_PTR)IDC_WAIT// 沙漏,Windows7下会显示为选择的圆圈表示等待
|
||||
};
|
||||
|
||||
//基础事件
|
||||
class UI_EXPORT EventArgs {
|
||||
public:
|
||||
Event EventType = Event::None;
|
||||
EventArgs(Event eventType) {
|
||||
this->EventType = eventType;
|
||||
}
|
||||
virtual ~EventArgs() {};
|
||||
};
|
||||
//为鼠标事件提供基础数据
|
||||
class UI_EXPORT MouseEventArgs :public EventArgs {
|
||||
public:
|
||||
MouseButton Button = MouseButton::None;
|
||||
int ZDelta = 0;//方向
|
||||
Point Location;
|
||||
public:
|
||||
MouseEventArgs(Event eventType, const Point& location = Point(0, 0), MouseButton mouseButton = MouseButton::None, int ZDelta = 0) :EventArgs(eventType) {
|
||||
this->Button = mouseButton;
|
||||
this->Location = location;
|
||||
this->ZDelta = ZDelta;
|
||||
}
|
||||
virtual ~MouseEventArgs() {}
|
||||
};
|
||||
// 摘要:
|
||||
//为键盘事件提供基础数据
|
||||
class UI_EXPORT KeyboardEventArgs :public EventArgs {
|
||||
public:
|
||||
/// <summary>
|
||||
/// 一般是指 键盘的ascii值
|
||||
/// </summary>
|
||||
WPARAM wParam;
|
||||
LPARAM lParam;
|
||||
KeyboardEventArgs(Event eventType, WPARAM wParam, LPARAM lParam) :EventArgs(eventType) {
|
||||
this->wParam = wParam;
|
||||
this->lParam = lParam;
|
||||
}
|
||||
virtual ~KeyboardEventArgs() {}
|
||||
};
|
||||
//获取焦点
|
||||
class UI_EXPORT FocusEventArgs :public EventArgs {
|
||||
public:
|
||||
Control* Control;
|
||||
FocusEventArgs(ezui::Control* ctl) :EventArgs(Event::OnFocus) {
|
||||
this->Control = ctl;
|
||||
}
|
||||
virtual ~FocusEventArgs() {}
|
||||
};
|
||||
//失去焦点
|
||||
class UI_EXPORT KillFocusEventArgs :public EventArgs {
|
||||
public:
|
||||
Control* Control;
|
||||
KillFocusEventArgs(ezui::Control* ctl) :EventArgs(Event::OnKillFocus) {
|
||||
this->Control = ctl;
|
||||
}
|
||||
virtual ~KillFocusEventArgs() {}
|
||||
};
|
||||
//坐标发生改变
|
||||
class UI_EXPORT MoveEventArgs :public EventArgs {
|
||||
public:
|
||||
const ezui::Point Location;
|
||||
MoveEventArgs(const ezui::Point& location) :EventArgs(Event::OnMove), Location(location) {}
|
||||
virtual ~MoveEventArgs() {}
|
||||
};
|
||||
//大小发生改变
|
||||
class UI_EXPORT SizeEventArgs :public EventArgs {
|
||||
public:
|
||||
const ezui::Size Size;
|
||||
SizeEventArgs(const ezui::Size& size) :EventArgs(Event::OnSize), Size(size) {}
|
||||
virtual ~SizeEventArgs() {}
|
||||
};
|
||||
//dpi发生变化
|
||||
class UI_EXPORT DpiChangeEventArgs :public EventArgs {
|
||||
public:
|
||||
float Scale = 1.0f;
|
||||
DpiChangeEventArgs(float scale) :EventArgs(Event::OnDpiChange), Scale(scale) {}
|
||||
virtual ~DpiChangeEventArgs() {}
|
||||
};
|
||||
// 为 OnPaint 事件提供数据。
|
||||
class UI_EXPORT PaintEventArgs :public EventArgs {
|
||||
private:
|
||||
std::list<bool> m_layers;
|
||||
std::list<Point> m_offsets;
|
||||
public:
|
||||
PaintEventArgs(const PaintEventArgs&) = delete;
|
||||
PaintEventArgs& operator=(const PaintEventArgs&) = delete;
|
||||
WindowData* PublicData = NULL;
|
||||
::HWND HWND = NULL;
|
||||
HDC DC = NULL;
|
||||
ezui::DXRender& Graphics;//画家
|
||||
Rect InvalidRectangle;//WM_PAINT里面的无效区域
|
||||
PaintEventArgs(ezui::DXRender& _painter) : EventArgs(Event::OnPaint), Graphics(_painter) {}
|
||||
virtual ~PaintEventArgs() {}
|
||||
//添加裁剪(速度较快)
|
||||
void PushLayer(const Rect& rectBounds);
|
||||
//添加异形裁剪 比较耗性能,但是可以异形抗锯齿裁剪
|
||||
void PushLayer(const Geometry& dxGeometry);
|
||||
//弹出最后一个裁剪
|
||||
void PopLayer();
|
||||
//放入一个偏移
|
||||
void PushOffset(const Point& offset);
|
||||
//弹出最后一个偏移
|
||||
void PopOffset();
|
||||
};
|
||||
// 为控件样式提供数据。
|
||||
class UI_EXPORT ControlStyle {
|
||||
public:
|
||||
//边框信息
|
||||
ezui::Border Border;
|
||||
//整体不透明度
|
||||
//UI_Float Opacity;
|
||||
//背景颜色
|
||||
Color BackColor = 0;
|
||||
//背景图片 如果指定的图片被删除 请必须将此置零
|
||||
Image* BackImage = NULL;
|
||||
//前景图片 如果指定的图片被删除 请必须将此置零
|
||||
Image* ForeImage = NULL;
|
||||
//字体名称 具有继承性
|
||||
std::wstring FontFamily;
|
||||
//字体大小 具有继承性
|
||||
int FontSize = 0;
|
||||
//前景颜色 具有继承性
|
||||
Color ForeColor;
|
||||
//鼠标样式
|
||||
HCURSOR Cursor = NULL;
|
||||
//旋转范围 0~360
|
||||
float Angle = 0;
|
||||
private:
|
||||
void operator=(const ControlStyle& right) {} //禁止直接赋值 因为这样会导致 Color执行拷贝使得Color变得不合法的有效
|
||||
ControlStyle(const ControlStyle& right) {} //禁止拷贝
|
||||
public:
|
||||
ControlStyle() {}
|
||||
virtual ~ControlStyle() {}
|
||||
void Scale(float scale);
|
||||
};
|
||||
|
||||
//指针管理
|
||||
template <typename T>
|
||||
class PtrManager {
|
||||
private:
|
||||
std::vector<T> m_ptrs;
|
||||
public:
|
||||
PtrManager() {}
|
||||
virtual ~PtrManager() {
|
||||
for (auto& obj : m_ptrs) {
|
||||
delete obj;
|
||||
}
|
||||
}
|
||||
void Add(const T& v) {
|
||||
if (v) {
|
||||
m_ptrs.push_back(v);
|
||||
}
|
||||
}
|
||||
void Remove(const T& v/*, bool bFree = false*/) {
|
||||
auto it = std::find(m_ptrs.begin(), m_ptrs.end(), v);
|
||||
if (it != m_ptrs.end()) {
|
||||
/*if (bFree) {
|
||||
delete(*it);
|
||||
}*/
|
||||
m_ptrs.erase(it);
|
||||
}
|
||||
}
|
||||
void Clear() {
|
||||
for (auto& obj : m_ptrs) {
|
||||
delete obj;
|
||||
}
|
||||
m_ptrs.clear();
|
||||
}
|
||||
};
|
||||
|
||||
//常用对象基类
|
||||
class UI_EXPORT Object {
|
||||
private:
|
||||
//属性集合
|
||||
std::map<UIString, UIString> m_attrs;
|
||||
// 管理子对象的释放
|
||||
PtrManager<Object*> m_childObjects;
|
||||
public:
|
||||
//用户自定义数据
|
||||
UINT_PTR Tag = NULL;
|
||||
public:
|
||||
Object(Object* parentObject = NULL);
|
||||
virtual ~Object();
|
||||
public:
|
||||
//设置属性
|
||||
virtual void SetAttribute(const UIString& attrName, const UIString& attrValue);
|
||||
//获取属性
|
||||
virtual UIString GetAttribute(const UIString& attrName);
|
||||
//获取全部属性
|
||||
virtual const std::map<UIString, UIString>& GetAttributes();
|
||||
//移除某个属性
|
||||
virtual void RemoveAttribute(const UIString& attrName);
|
||||
//绑定对象(跟随释放)
|
||||
virtual Object* Attach(Object* obj);
|
||||
//分离对象(解除跟随释放)
|
||||
virtual void Detach(Object* obj);
|
||||
//延迟删除
|
||||
void DeleteLater();
|
||||
};
|
||||
|
||||
//原理采用PostMessage
|
||||
template<class Func, class... Args>
|
||||
bool BeginInvoke(Func&& f, Args&& ...args) {
|
||||
HWND hWnd = ezui::__EzUI_MessageWnd;
|
||||
if (hWnd == NULL || !::IsWindow(hWnd)) {
|
||||
return false;
|
||||
}
|
||||
std::function<void()>* func = new std::function<void()>(std::bind(std::forward<Func>(f), std::forward<Args>(args)...));
|
||||
if (::PostMessage(hWnd, WM_GUI_SYSTEM, WM_GUI_BEGININVOKE, (LPARAM)func) == LRESULT(0)) {
|
||||
delete func;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//原理采用SendMessage
|
||||
template<class Func, class... Args>
|
||||
bool Invoke(Func&& f, Args&& ...args) {
|
||||
std::function<void()> func(std::bind(std::forward<Func>(f), std::forward<Args>(args)...));
|
||||
if (::GetCurrentThreadId() == ezui::__EzUI__ThreadId) {
|
||||
func();
|
||||
return true;
|
||||
}
|
||||
HWND hWnd = ezui::__EzUI_MessageWnd;
|
||||
if (hWnd == NULL || !::IsWindow(hWnd)) {
|
||||
return false;
|
||||
}
|
||||
if (::SendMessage(hWnd, WM_GUI_SYSTEM, WM_GUI_INVOKE, (LPARAM)&func) == LRESULT(-1)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//统计函数耗时
|
||||
template<class Func, class... Args>
|
||||
int64_t StopWatch(Func&& f, Args&& ...args) {
|
||||
auto beginTime = std::chrono::steady_clock::now();
|
||||
std::forward<Func>(f)(std::forward<Args>(args)...);
|
||||
auto delta = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - beginTime).count();
|
||||
return delta;
|
||||
}
|
||||
|
||||
};
|
||||
18
demo/Adminstor/ThirdParty/EzUI/include/EzUI/HLayout.h
vendored
Normal file
18
demo/Adminstor/ThirdParty/EzUI/include/EzUI/HLayout.h
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT HLayout :
|
||||
public Control
|
||||
{
|
||||
public:
|
||||
VAlign ContentAlign = VAlign::Mid;
|
||||
protected:
|
||||
virtual void OnLayout()override;
|
||||
public:
|
||||
HLayout(Object* parentObject = NULL);
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
virtual ~HLayout();
|
||||
};
|
||||
using HBox = HLayout;
|
||||
};
|
||||
21
demo/Adminstor/ThirdParty/EzUI/include/EzUI/HListView.h
vendored
Normal file
21
demo/Adminstor/ThirdParty/EzUI/include/EzUI/HListView.h
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "PagedListView.h"
|
||||
#include "HScrollBar.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT HListView :
|
||||
public PagedListView
|
||||
{
|
||||
private:
|
||||
HScrollBar m_hScrollBar;
|
||||
void Init();
|
||||
void Offset(int offset);
|
||||
protected:
|
||||
virtual void OnLayout()override;
|
||||
virtual void OnChildPaint(PaintEventArgs& args)override;
|
||||
public:
|
||||
HListView(Object* parentObject = NULL);
|
||||
virtual ~HListView();
|
||||
virtual ScrollBar* GetScrollBar()override;
|
||||
};
|
||||
};
|
||||
21
demo/Adminstor/ThirdParty/EzUI/include/EzUI/HScrollBar.h
vendored
Normal file
21
demo/Adminstor/ThirdParty/EzUI/include/EzUI/HScrollBar.h
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
#include "ScrollBar.h"
|
||||
|
||||
namespace ezui {
|
||||
|
||||
class UI_EXPORT HScrollBar :
|
||||
public ScrollBar
|
||||
{
|
||||
protected:
|
||||
virtual void OnMouseDown(const MouseEventArgs& arg)override;
|
||||
virtual void OnMouseMove(const MouseEventArgs& arg)override;
|
||||
virtual void GetInfo(int* viewLength, int* contentLength, int* scrollBarLength)override;
|
||||
public:
|
||||
HScrollBar(Object* parentObject = NULL);
|
||||
virtual ~HScrollBar();
|
||||
virtual void ScrollTo(Control* ctl)override;
|
||||
virtual void ParentSize(const Size& parentSize)override;
|
||||
virtual Rect GetSliderRect()override;
|
||||
};
|
||||
};
|
||||
32
demo/Adminstor/ThirdParty/EzUI/include/EzUI/IFrame.h
vendored
Normal file
32
demo/Adminstor/ThirdParty/EzUI/include/EzUI/IFrame.h
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include "EzUI.h"
|
||||
#include "UIManager.h"
|
||||
|
||||
namespace ezui {
|
||||
//内联页面 内部控件与外部隔离
|
||||
class UI_EXPORT IFrame :public Control {
|
||||
private:
|
||||
UIManager m_umg;//内部UI管理器
|
||||
private:
|
||||
virtual Control* Add(Control* childCtl)override;
|
||||
virtual void Remove(Control* childCtl, bool freeCtrl = false)override;
|
||||
public:
|
||||
//对外暴露消息通知回调
|
||||
std::function<void(Control*, EventArgs&)> NotifyHandler = NULL;
|
||||
IFrame(Object* parentObject = NULL);
|
||||
virtual ~IFrame();
|
||||
//从文件中加载xml
|
||||
void LoadXml(const UIString& fileName);
|
||||
//从内存中加载xml
|
||||
void LoadXml(const char* fileData, size_t fileSize);
|
||||
//设置唯一布局
|
||||
void SetLayout(Control* ctrl);
|
||||
//获取布局
|
||||
Control* GetLayout();
|
||||
virtual void SetAttribute(const UIString& attrName, const UIString& attrValue)override;
|
||||
//消息通知
|
||||
virtual void OnNotify(Control* sender, EventArgs& args);
|
||||
//获取UI管理器
|
||||
UIManager* GetUIManager();
|
||||
};
|
||||
};
|
||||
36
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Label.h
vendored
Normal file
36
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Label.h
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT Label :
|
||||
public Control
|
||||
{
|
||||
private:
|
||||
std::wstring m_wstr;
|
||||
int m_underlinePos = 0;//显示下划线起始下标
|
||||
int m_underlineCount = 0;//显示下划线文字个数
|
||||
std::wstring m_ellipsisText;//文字溢出将显示的文字
|
||||
protected:
|
||||
virtual void OnForePaint(PaintEventArgs& args) override;
|
||||
virtual void OnDpiChange(const DpiChangeEventArgs& args)override;
|
||||
virtual void OnLayout()override;
|
||||
public:
|
||||
//基于控件的文字的边距
|
||||
ezui::Distance TextMargin;
|
||||
//文字对齐方式
|
||||
TextAlign TextAlign = TextAlign::MiddleCenter;
|
||||
public:
|
||||
Label(Object* parentObject = NULL);
|
||||
virtual ~Label();
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
virtual void RefreshLayout() override;
|
||||
//设置文字
|
||||
void SetText(const UIString& text);
|
||||
//获取文字
|
||||
UIString GetText()const;
|
||||
//设置文字溢出控件之后的显示文字
|
||||
void SetElidedText(const UIString& text);
|
||||
//设置下划线位置
|
||||
void SetUnderline(int pos, int count);
|
||||
};
|
||||
};
|
||||
30
demo/Adminstor/ThirdParty/EzUI/include/EzUI/LayeredWindow.h
vendored
Normal file
30
demo/Adminstor/ThirdParty/EzUI/include/EzUI/LayeredWindow.h
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include "BorderlessWindow.h"
|
||||
#include "Bitmap.h"
|
||||
#include "Task.h"
|
||||
#include "Timer.h"
|
||||
|
||||
namespace ezui {
|
||||
/// <summary>
|
||||
/// //LayeredWindow //无边框 带阴影 窗口透明异形 窗口大小发生改变重绘
|
||||
/// </summary>
|
||||
class UI_EXPORT LayeredWindow :public BorderlessWindow
|
||||
{
|
||||
private:
|
||||
std::list<Rect> m_invalidateRect;
|
||||
Bitmap* m_winBitmap = NULL;
|
||||
void UpdateLayeredWindow(HDC hdc);
|
||||
void BeginPaint(Rect* rect);
|
||||
void EndPaint();
|
||||
void Paint();
|
||||
protected:
|
||||
virtual void OnSize(const Size& sz)override;
|
||||
void InvalidateRect(const Rect& rect);
|
||||
virtual LRESULT WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)override;
|
||||
public:
|
||||
//窗口透明度
|
||||
float Opacity = 1.0f;
|
||||
LayeredWindow(int width, int height, HWND owner = NULL, DWORD dwStyle = NULL, DWORD dwExStyle = NULL);
|
||||
virtual ~LayeredWindow();
|
||||
};
|
||||
};
|
||||
20
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Menu.h
vendored
Normal file
20
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Menu.h
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "EzUI.h"
|
||||
|
||||
namespace ezui {
|
||||
//菜单类
|
||||
class UI_EXPORT Menu :public Object
|
||||
{
|
||||
private:
|
||||
HMENU m_hMenu = NULL;
|
||||
public:
|
||||
//菜单子项被选点击的回调事件 UINT:子项ID
|
||||
std::function<void(UINT_PTR)> MouseClick = NULL;
|
||||
Menu(Object* parentObj = NULL);
|
||||
virtual ~Menu();
|
||||
HMENU HMenu();
|
||||
UINT_PTR Append(const UIString& text);
|
||||
void Remove(const UINT_PTR id);
|
||||
};
|
||||
|
||||
};
|
||||
27
demo/Adminstor/ThirdParty/EzUI/include/EzUI/NotifyIcon.h
vendored
Normal file
27
demo/Adminstor/ThirdParty/EzUI/include/EzUI/NotifyIcon.h
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#include "Menu.h"
|
||||
#include <shellapi.h>
|
||||
namespace ezui {
|
||||
//系统托盘类
|
||||
class UI_EXPORT NotifyIcon :public Object
|
||||
{
|
||||
private:
|
||||
HWND m_hWnd = NULL;
|
||||
Menu* m_menu = NULL;
|
||||
NOTIFYICONDATAW m_nid = {};
|
||||
WindowData m_publicData;
|
||||
protected:
|
||||
virtual LRESULT WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
public:
|
||||
//事件处理 只会返回鼠标事件
|
||||
std::function<void(const MouseEventArgs&)> EventHandler = NULL;
|
||||
NotifyIcon(Object* parentObj = NULL);
|
||||
void SetIcon(HICON icon);
|
||||
//设置鼠标悬停时显示的提示文本
|
||||
void SetTips(const UIString& text);
|
||||
void SetMenu(Menu* menu);
|
||||
void ShowBalloonTip(const UIString& title, const UIString& msg, int timeOut = 1000);
|
||||
virtual ~NotifyIcon();
|
||||
};
|
||||
|
||||
};
|
||||
39
demo/Adminstor/ThirdParty/EzUI/include/EzUI/PagedListView.h
vendored
Normal file
39
demo/Adminstor/ThirdParty/EzUI/include/EzUI/PagedListView.h
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
|
||||
namespace ezui {
|
||||
/**
|
||||
* 是一个分页显示控件集合的容器控件
|
||||
*
|
||||
* 它支持对一批子控件进行分页管理,例如:
|
||||
* - 显示每页固定数量的控件;
|
||||
* - 支持翻页;
|
||||
* - 当控件到达末页时需要手动调用NextPage进行加载下一页;
|
||||
*
|
||||
* 子类:VList/HList/TileList 继承使其具备分页管理的能力
|
||||
*/
|
||||
class UI_EXPORT PagedListView :
|
||||
public Control
|
||||
{
|
||||
private:
|
||||
int m_pageIndex = 0;
|
||||
int m_pageTotal = 0;
|
||||
int m_pageSize = 0;
|
||||
Controls m_items;
|
||||
public:
|
||||
PagedListView(Object* parentObject = NULL);
|
||||
virtual ~PagedListView();
|
||||
//页面需要加载下一页的时候发生
|
||||
std::function<bool(PagedListView*, int)> NextPaging = NULL;
|
||||
void SetPageInfo(const Controls& items, int pageSize);
|
||||
/// <summary>
|
||||
/// 获取某页的item集合
|
||||
/// </summary>
|
||||
/// <param name="index">1~N</param>
|
||||
/// <param name="outCtls">输出集合</param>
|
||||
void GetPage(int index, Controls* outCtls);
|
||||
virtual void NextPage();
|
||||
virtual void Clear() override;
|
||||
virtual void Clear(bool freeChilds) override;
|
||||
};
|
||||
};
|
||||
20
demo/Adminstor/ThirdParty/EzUI/include/EzUI/PictureBox.h
vendored
Normal file
20
demo/Adminstor/ThirdParty/EzUI/include/EzUI/PictureBox.h
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
#include "Timer.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT PictureBox : public Control {
|
||||
private:
|
||||
Timer* m_timer;
|
||||
private:
|
||||
void Init();
|
||||
protected:
|
||||
virtual void OnForePaint(PaintEventArgs& arg)override;
|
||||
public:
|
||||
//图片(支持gif图自动播放)
|
||||
Image* Image = NULL;
|
||||
PictureBox(Object* parentObject = NULL);
|
||||
virtual ~PictureBox();
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
};
|
||||
};
|
||||
22
demo/Adminstor/ThirdParty/EzUI/include/EzUI/PopupWindow.h
vendored
Normal file
22
demo/Adminstor/ThirdParty/EzUI/include/EzUI/PopupWindow.h
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "Window.h"
|
||||
#include "BorderlessWindow.h"
|
||||
#include "LayeredWindow.h"
|
||||
|
||||
namespace ezui {
|
||||
/// <summary>
|
||||
/// 弹出式窗口(失去焦点窗口将会关闭) 一般用于做右键菜单等等
|
||||
/// </summary>
|
||||
class UI_EXPORT PopupWindow :public LayeredWindow {
|
||||
private:
|
||||
Control* m_ownerCtl = NULL;
|
||||
protected:
|
||||
virtual void OnKillFocus(HWND hWnd) override;
|
||||
public:
|
||||
PopupWindow(int width, int height, HWND ownerHwnd);
|
||||
PopupWindow(int width, int height, Control* ownerCtl = NULL);
|
||||
virtual void Show()override;
|
||||
virtual int ShowModal(bool disableOnwer = false)override;
|
||||
virtual ~PopupWindow();
|
||||
};
|
||||
};
|
||||
76
demo/Adminstor/ThirdParty/EzUI/include/EzUI/ProgressBar.h
vendored
Normal file
76
demo/Adminstor/ThirdParty/EzUI/include/EzUI/ProgressBar.h
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
|
||||
namespace ezui {
|
||||
/// <summary>
|
||||
/// 进度条控件
|
||||
/// </summary>
|
||||
class UI_EXPORT ProgressBar : public Control {
|
||||
private:
|
||||
float m_progress = 0.0f; // 进度值 0.0f - 1.0f
|
||||
Color m_progressColor = Color::Blue; // 进度条颜色
|
||||
Color m_backgroundColor = Color::LightGray; // 背景颜色
|
||||
|
||||
public:
|
||||
ProgressBar(Object* parentObject = NULL);
|
||||
virtual ~ProgressBar();
|
||||
|
||||
/// <summary>
|
||||
/// 设置进度值
|
||||
/// </summary>
|
||||
/// <param name="progress">进度值,范围 0.0f - 1.0f</param>
|
||||
void SetProgress(float progress);
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前进度值
|
||||
/// </summary>
|
||||
/// <returns>当前进度值</returns>
|
||||
float GetProgress() const;
|
||||
|
||||
/// <summary>
|
||||
/// 设置进度条颜色
|
||||
/// </summary>
|
||||
/// <param name="color">进度条颜色</param>
|
||||
void SetProgressColor(const Color& color);
|
||||
|
||||
/// <summary>
|
||||
/// 获取进度条颜色
|
||||
/// </summary>
|
||||
/// <returns>进度条颜色</returns>
|
||||
Color GetProgressColor() const;
|
||||
|
||||
/// <summary>
|
||||
/// 设置背景颜色
|
||||
/// </summary>
|
||||
/// <param name="color">背景颜色</param>
|
||||
void SetBackgroundColor(const Color& color);
|
||||
|
||||
/// <summary>
|
||||
/// 获取背景颜色
|
||||
/// </summary>
|
||||
/// <returns>背景颜色</returns>
|
||||
Color GetBackgroundColor() const;
|
||||
|
||||
/// <summary>
|
||||
/// 设置控件属性
|
||||
/// </summary>
|
||||
/// <param name="attrName">属性名</param>
|
||||
/// <param name="attrValue">属性值</param>
|
||||
virtual void SetAttribute(const UIString& attrName, const UIString& attrValue) override;
|
||||
|
||||
protected:
|
||||
/// <summary>
|
||||
/// 绘制控件
|
||||
/// </summary>
|
||||
/// <param name="args">绘制参数</param>
|
||||
virtual void OnPaint(PaintEventArgs& args) override;
|
||||
|
||||
/// <summary>
|
||||
/// 应用样式属性
|
||||
/// </summary>
|
||||
/// <param name="key">属性键</param>
|
||||
/// <param name="value">属性值</param>
|
||||
/// <returns>是否成功应用</returns>
|
||||
virtual bool ApplyStyleProperty(const UIString& key, const UIString& value) override;
|
||||
};
|
||||
}
|
||||
14
demo/Adminstor/ThirdParty/EzUI/include/EzUI/RadioButton.h
vendored
Normal file
14
demo/Adminstor/ThirdParty/EzUI/include/EzUI/RadioButton.h
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "CheckBox.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT RadioButton :
|
||||
public CheckBox
|
||||
{
|
||||
protected:
|
||||
virtual void OnMouseDown(const MouseEventArgs& arg)override;
|
||||
public:
|
||||
RadioButton(Object* parentObject = NULL);
|
||||
virtual~RadioButton();
|
||||
};
|
||||
};
|
||||
813
demo/Adminstor/ThirdParty/EzUI/include/EzUI/RenderTypes.h
vendored
Normal file
813
demo/Adminstor/ThirdParty/EzUI/include/EzUI/RenderTypes.h
vendored
Normal file
@@ -0,0 +1,813 @@
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
|
||||
namespace ezui {
|
||||
//size模式
|
||||
enum class SizeMode {
|
||||
//图片强行拉伸完全填充控件
|
||||
//不裁剪,图片变形
|
||||
Stretch,
|
||||
//图片缩放后完全填充控件
|
||||
//图片会裁剪, 保持比例裁剪和控件同大小
|
||||
Cover,
|
||||
//图片缩放后完整居中显示在控件上
|
||||
//控件会留白
|
||||
Fit,
|
||||
//图片保持原尺寸,
|
||||
//如果图片小于控件: 控件留白,
|
||||
//如果图片大于控件: 控件边界外的部分被裁剪
|
||||
Original
|
||||
};
|
||||
typedef SizeMode ImageSizeMode;
|
||||
|
||||
#if 1
|
||||
#define Align_Top 1
|
||||
#define Align_Bottom 2
|
||||
#define Align_Left 4
|
||||
#define Align_Right 8
|
||||
#define Align_Mid 16
|
||||
#define Align_Center 32
|
||||
#else //GDI
|
||||
#define Align_Top DT_TOP
|
||||
#define Align_Bottom DT_BOTTOM
|
||||
#define Align_Left DT_LEFT
|
||||
#define Align_Right DT_RIGHT
|
||||
#define Align_Mid DT_VCENTER
|
||||
#define Align_Center DT_CENTER
|
||||
#endif
|
||||
/// <summary>
|
||||
/// 水平状态下的对齐方式
|
||||
/// </summary>
|
||||
enum class HAlign :int
|
||||
{
|
||||
Left = Align_Left,
|
||||
Center = Align_Center,
|
||||
Right = Align_Right
|
||||
};
|
||||
EZUI_ENUM_OPERATORS(HAlign, int);
|
||||
|
||||
/// <summary>
|
||||
/// 垂直状态下的对齐方式
|
||||
/// </summary>
|
||||
enum class VAlign :int
|
||||
{
|
||||
Top = Align_Top,
|
||||
Mid = Align_Mid,
|
||||
Bottom = Align_Bottom
|
||||
};
|
||||
EZUI_ENUM_OPERATORS(VAlign, int);
|
||||
|
||||
//包含垂直与水平对齐方式
|
||||
enum class Align :int {
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上顶部对齐,在水平方向上左边对齐。
|
||||
TopLeft = (int)VAlign::Top | (int)HAlign::Left,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上顶部对齐,在水平方向上居中对齐。
|
||||
TopCenter = (int)VAlign::Top | (int)HAlign::Center,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上顶部对齐,在水平方向上右边对齐。
|
||||
TopRight = (int)VAlign::Top | (int)HAlign::Right,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上中间对齐,在水平方向上左边对齐。
|
||||
MiddleLeft = (int)VAlign::Mid | (int)HAlign::Left,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上中间对齐,在水平方向上居中对齐。
|
||||
MiddleCenter = (int)VAlign::Mid | (int)HAlign::Center,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上中间对齐,在水平方向上右边对齐。
|
||||
MiddleRight = (int)VAlign::Mid | (int)HAlign::Right,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上底边对齐,在水平方向上左边对齐。
|
||||
BottomLeft = (int)VAlign::Bottom | (int)HAlign::Left,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上底边对齐,在水平方向上居中对齐。
|
||||
BottomCenter = (int)VAlign::Bottom | (int)HAlign::Center,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上底边对齐,在水平方向上右边对齐。
|
||||
BottomRight = (int)VAlign::Bottom | (int)HAlign::Right
|
||||
};
|
||||
EZUI_ENUM_OPERATORS(Align, int);
|
||||
|
||||
typedef Align TextAlign;
|
||||
|
||||
enum class FontStyle {
|
||||
NORMAL
|
||||
/* DWRITE_FONT_STYLE_NORMAL
|
||||
字体样式 :正常。
|
||||
DWRITE_FONT_STYLE_OBLIQUE
|
||||
字体样式 :倾斜。
|
||||
DWRITE_FONT_STYLE_ITALIC
|
||||
字体样式 :斜体。 */
|
||||
};
|
||||
|
||||
//描边样式
|
||||
enum class StrokeStyle
|
||||
{
|
||||
None,//无
|
||||
Solid,//实线
|
||||
Dash//虚线
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
class __EzUI__Size
|
||||
{
|
||||
public:
|
||||
T Width;
|
||||
T Height;
|
||||
public:
|
||||
__EzUI__Size()
|
||||
{
|
||||
Width = Height = 0;
|
||||
}
|
||||
__EzUI__Size(const __EzUI__Size& __Size)
|
||||
{
|
||||
Width = __Size.Width;
|
||||
Height = __Size.Height;
|
||||
}
|
||||
__EzUI__Size(T width,
|
||||
T height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
bool operator!=(const __EzUI__Size& _right) const
|
||||
{
|
||||
return !(Width == _right.Width && Height == _right.Height);
|
||||
}
|
||||
void Scale(float scale) {
|
||||
Width = (Width * scale) + 0.5;
|
||||
Height = (Height * scale) + 0.5;
|
||||
}
|
||||
bool Equals(const __EzUI__Size& sz) const
|
||||
{
|
||||
return (Width == sz.Width) && (Height == sz.Height);
|
||||
}
|
||||
bool Empty() const
|
||||
{
|
||||
return (Width == 0 && Height == 0);
|
||||
}
|
||||
__EzUI__Size operator+(const __EzUI__Size& sz) const
|
||||
{
|
||||
return __EzUI__Size(Width + sz.Width,
|
||||
Height + sz.Height);
|
||||
}
|
||||
__EzUI__Size operator-(const __EzUI__Size& sz) const
|
||||
{
|
||||
return __EzUI__Size(Width - sz.Width,
|
||||
Height - sz.Height);
|
||||
}
|
||||
|
||||
bool operator==(const __EzUI__Size& _right) const
|
||||
{
|
||||
return Equals(_right);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class __EzUI__Point
|
||||
{
|
||||
public:
|
||||
T X;
|
||||
T Y;
|
||||
public:
|
||||
__EzUI__Point()
|
||||
{
|
||||
X = Y = 0;
|
||||
}
|
||||
|
||||
__EzUI__Point(const __EzUI__Point& __Point)
|
||||
{
|
||||
X = __Point.X;
|
||||
Y = __Point.Y;
|
||||
}
|
||||
|
||||
__EzUI__Point(const __EzUI__Size<T>& __Size)
|
||||
{
|
||||
X = __Size.Width;
|
||||
Y = __Size.Height;
|
||||
}
|
||||
|
||||
__EzUI__Point(T x,
|
||||
T y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
void Scale(float scale) {
|
||||
X = (X * scale) + 0.5;
|
||||
Y = (Y * scale) + 0.5;
|
||||
}
|
||||
bool Equals(const __EzUI__Point& __Point)const
|
||||
{
|
||||
return (X == __Point.X) && (Y == __Point.Y);
|
||||
}
|
||||
__EzUI__Point operator+(const __EzUI__Point& __Point) const
|
||||
{
|
||||
return __Point(X + __Point.X,
|
||||
Y + __Point.Y);
|
||||
}
|
||||
__EzUI__Point operator-(const __EzUI__Point& __Point) const
|
||||
{
|
||||
return __Point(X - __Point.X,
|
||||
Y - __Point.Y);
|
||||
}
|
||||
bool operator==(const __EzUI__Point& __Point) const
|
||||
{
|
||||
return Equals(__Point);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class __EzUI__Rect
|
||||
{
|
||||
public:
|
||||
T X;
|
||||
T Y;
|
||||
T Width;
|
||||
T Height;
|
||||
public:
|
||||
|
||||
__EzUI__Rect()
|
||||
{
|
||||
X = Y = Width = Height = 0;
|
||||
}
|
||||
|
||||
__EzUI__Rect(T x,
|
||||
T y,
|
||||
T width,
|
||||
T height)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
__EzUI__Rect(const RECT& rect) {
|
||||
X = rect.left;
|
||||
Y = rect.top;
|
||||
Width = rect.right - rect.left;
|
||||
Height = rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
__EzUI__Rect(const __EzUI__Point<T>& location, const __EzUI__Size<T>& size) {
|
||||
X = location.X;
|
||||
Y = location.Y;
|
||||
Width = size.Width;
|
||||
Height = size.Height;
|
||||
}
|
||||
|
||||
__EzUI__Point<T> GetLocation() const
|
||||
{
|
||||
return __EzUI__Point<T>{ X, Y };
|
||||
}
|
||||
|
||||
__EzUI__Size<T> GetSize() const
|
||||
{
|
||||
return __EzUI__Size<T>(Width, Height);
|
||||
}
|
||||
|
||||
RECT ToRECT() const {
|
||||
return RECT{ (LONG)GetLeft(), (LONG)GetTop(), (LONG)GetRight(), (LONG)GetBottom() };
|
||||
}
|
||||
|
||||
T GetLeft() const
|
||||
{
|
||||
return X;
|
||||
}
|
||||
|
||||
T GetTop() const
|
||||
{
|
||||
return Y;
|
||||
}
|
||||
T GetRight() const
|
||||
{
|
||||
return X + Width;
|
||||
}
|
||||
T GetBottom() const
|
||||
{
|
||||
return Y + Height;
|
||||
}
|
||||
bool IsEmptyArea() const
|
||||
{
|
||||
return (Width <= 0) || (Height <= 0);
|
||||
}
|
||||
|
||||
virtual const __EzUI__Rect& Scale(float scale) {
|
||||
X = T((X * scale) + 0.5);
|
||||
Y = T((Y * scale) + 0.5);
|
||||
Width = T((Width * scale) + 0.5);
|
||||
Height = T((Height * scale) + 0.5);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Equals(const __EzUI__Rect& __Rect) const
|
||||
{
|
||||
return X == __Rect.X &&
|
||||
Y == __Rect.Y &&
|
||||
Width == __Rect.Width &&
|
||||
Height == __Rect.Height;
|
||||
}
|
||||
|
||||
bool operator == (const __EzUI__Rect& right) {
|
||||
return Equals(right);
|
||||
}
|
||||
|
||||
__EzUI__Rect& operator+=(T value) {
|
||||
X -= value;
|
||||
Y -= value;
|
||||
Width += value * 2;
|
||||
Height += value * 2;
|
||||
return *this;
|
||||
}
|
||||
__EzUI__Rect& operator-=(T value) {
|
||||
X += value;
|
||||
Y += value;
|
||||
Width -= value * 2;
|
||||
Height -= value * 2;
|
||||
return *this;
|
||||
}
|
||||
__EzUI__Rect operator+(T value) const {
|
||||
__EzUI__Rect out = *this;
|
||||
out += value;
|
||||
return out;
|
||||
}
|
||||
__EzUI__Rect operator-(T value) const {
|
||||
__EzUI__Rect out = *this;
|
||||
out -= value;
|
||||
return out;
|
||||
}
|
||||
|
||||
bool Contains(T x,
|
||||
T y) const
|
||||
{
|
||||
return x >= X && x < X + Width &&
|
||||
y >= Y && y < Y + Height;
|
||||
}
|
||||
|
||||
bool Contains(const __EzUI__Point<T>& pt) const
|
||||
{
|
||||
return Contains(pt.X, pt.Y);
|
||||
}
|
||||
|
||||
bool Contains(const __EzUI__Rect& __Rect) const
|
||||
{
|
||||
return (X <= __Rect.X) && (__Rect.GetRight() <= GetRight()) &&
|
||||
(Y <= __Rect.Y) && (__Rect.GetBottom() <= GetBottom());
|
||||
|
||||
}
|
||||
|
||||
void Inflate(T dx,
|
||||
T dy)
|
||||
{
|
||||
X -= dx;
|
||||
Y -= dy;
|
||||
Width += 2 * dx;
|
||||
Height += 2 * dy;
|
||||
}
|
||||
|
||||
void Inflate(const __EzUI__Point<T>& point)
|
||||
{
|
||||
Inflate(point.X, point.Y);
|
||||
}
|
||||
|
||||
bool Intersect(const __EzUI__Rect& __Rect)
|
||||
{
|
||||
return Intersect(*this, *this, __Rect);
|
||||
}
|
||||
|
||||
static bool Intersect(__EzUI__Rect& c,
|
||||
const __EzUI__Rect& a,
|
||||
const __EzUI__Rect& b)
|
||||
{
|
||||
T right = min(a.GetRight(), b.GetRight());
|
||||
T bottom = min(a.GetBottom(), b.GetBottom());
|
||||
T left = max(a.GetLeft(), b.GetLeft());
|
||||
T top = max(a.GetTop(), b.GetTop());
|
||||
|
||||
c.X = left;
|
||||
c.Y = top;
|
||||
c.Width = right - left;
|
||||
c.Height = bottom - top;
|
||||
return !c.IsEmptyArea();
|
||||
}
|
||||
|
||||
bool IntersectsWith(const __EzUI__Rect& __Rect) const
|
||||
{
|
||||
return (GetLeft() < __Rect.GetRight() &&
|
||||
GetTop() < __Rect.GetBottom() &&
|
||||
GetRight() > __Rect.GetLeft() &&
|
||||
GetBottom() > __Rect.GetTop());
|
||||
}
|
||||
|
||||
static bool Union(__EzUI__Rect& c,
|
||||
const __EzUI__Rect& a,
|
||||
const __EzUI__Rect& b)
|
||||
{
|
||||
|
||||
if (a.IsEmptyArea()) {
|
||||
c = b;
|
||||
return !c.IsEmptyArea();
|
||||
}
|
||||
if (b.IsEmptyArea()) {
|
||||
c = a;
|
||||
return !c.IsEmptyArea();
|
||||
}
|
||||
|
||||
T right = max(a.GetRight(), b.GetRight());
|
||||
T bottom = max(a.GetBottom(), b.GetBottom());
|
||||
T left = min(a.GetLeft(), b.GetLeft());
|
||||
T top = min(a.GetTop(), b.GetTop());
|
||||
|
||||
c.X = left;
|
||||
c.Y = top;
|
||||
c.Width = right - left;
|
||||
c.Height = bottom - top;
|
||||
return !c.IsEmptyArea();
|
||||
}
|
||||
void Offset(const __EzUI__Point<T>& point)
|
||||
{
|
||||
Offset(point.X, point.Y);
|
||||
}
|
||||
void Offset(T dx,
|
||||
T dy)
|
||||
{
|
||||
X += dx;
|
||||
Y += dy;
|
||||
}
|
||||
virtual ~__EzUI__Rect() {}
|
||||
};
|
||||
|
||||
class __EzUI__Color
|
||||
{
|
||||
protected:
|
||||
DWORD BGRA = 0;
|
||||
public:
|
||||
__EzUI__Color() {}
|
||||
__EzUI__Color(
|
||||
const BYTE& r,
|
||||
const BYTE& g,
|
||||
const BYTE& b,
|
||||
const BYTE& a = 255)
|
||||
{
|
||||
((BYTE*)&BGRA)[0] = b;
|
||||
((BYTE*)&BGRA)[1] = g;
|
||||
((BYTE*)&BGRA)[2] = r;
|
||||
((BYTE*)&BGRA)[3] = a;
|
||||
}
|
||||
__EzUI__Color(DWORD bgra)
|
||||
{
|
||||
BGRA = bgra;
|
||||
}
|
||||
virtual ~__EzUI__Color() {}
|
||||
BYTE GetR() const
|
||||
{
|
||||
return ((BYTE*)&BGRA)[2];
|
||||
}
|
||||
BYTE GetG() const
|
||||
{
|
||||
return ((BYTE*)&BGRA)[1];
|
||||
}
|
||||
BYTE GetB() const
|
||||
{
|
||||
return ((BYTE*)&BGRA)[0];
|
||||
}
|
||||
BYTE GetA() const
|
||||
{
|
||||
return ((BYTE*)&BGRA)[3];
|
||||
}
|
||||
DWORD GetValue() const
|
||||
{
|
||||
return BGRA;
|
||||
}
|
||||
void SetValue(DWORD bgra)
|
||||
{
|
||||
BGRA = bgra;
|
||||
}
|
||||
void SetR(BYTE value) {
|
||||
((BYTE*)&BGRA)[2] = value;
|
||||
}
|
||||
void SetG(BYTE value) {
|
||||
((BYTE*)&BGRA)[1] = value;
|
||||
}
|
||||
void SetB(BYTE value) {
|
||||
((BYTE*)&BGRA)[0] = value;
|
||||
}
|
||||
void SetA(BYTE value) {
|
||||
((BYTE*)&BGRA)[3] = value;
|
||||
}
|
||||
public:
|
||||
// Common color constants (BGRA format)
|
||||
enum : DWORD
|
||||
{
|
||||
Transparent = 0x00000000, // 全透明
|
||||
|
||||
Black = 0xFF000000, // 黑色
|
||||
White = 0xFFFFFFFF, // 白色
|
||||
Gray = 0xFF808080, // 灰色
|
||||
LightGray = 0xFFD3D3D3, // 浅灰色
|
||||
DarkGray = 0xFFA9A9A9, // 深灰色
|
||||
|
||||
Red = 0xFFFF0000, // 红色
|
||||
DarkRed = 0xFF8B0000, // 深红色
|
||||
LightCoral = 0xFFF08080, // 浅珊瑚红
|
||||
Tomato = 0xFFFF6347, // 番茄色
|
||||
Crimson = 0xFFDC143C, // 猩红色
|
||||
|
||||
Green = 0xFF00FF00, // 绿色
|
||||
Lime = 0xFF00FF00, // 酸橙绿(亮绿)
|
||||
DarkGreen = 0xFF006400, // 深绿色
|
||||
LawnGreen = 0xFF7CFC00, // 草坪绿
|
||||
PaleGreen = 0xFF98FB98, // 苍绿色
|
||||
|
||||
Blue = 0xFF0000FF, // 蓝色
|
||||
RoyalBlue = 0xFF4169E1, // 皇家蓝
|
||||
DodgerBlue = 0xFF1E90FF, // 道奇蓝
|
||||
DeepSkyBlue = 0xFF00BFFF, // 深天蓝
|
||||
LightBlue = 0xFFADD8E6, // 浅蓝色
|
||||
|
||||
Yellow = 0xFF00FFFF, // 黄色
|
||||
Gold = 0xFFFFD700, // 金色
|
||||
LightYellow = 0xFFFFFFE0, // 浅黄色
|
||||
Khaki = 0xFFF0E68C, // 卡其色
|
||||
|
||||
Orange = 0xFFFFA500, // 橙色
|
||||
DarkOrange = 0xFFFF8C00, // 深橙色
|
||||
Coral = 0xFFFF7F50, // 珊瑚色
|
||||
Salmon = 0xFFFA8072, // 鲑鱼色
|
||||
|
||||
Purple = 0xFF800080, // 紫色
|
||||
MediumPurple = 0xFF9370DB,// 中紫色
|
||||
Indigo = 0xFF4B0082, // 靛青色
|
||||
Violet = 0xFFEE82EE, // 紫罗兰
|
||||
Plum = 0xFFDDA0DD, // 李子紫
|
||||
|
||||
Cyan = 0xFF00FFFF, // 青色
|
||||
Teal = 0xFF808000, // 水鸭色(G+B)
|
||||
Aqua = 0xFF00FFFF, // 浅绿色(水色)
|
||||
|
||||
Turquoise = 0xFF40E0D0, // 绿松石色
|
||||
|
||||
Brown = 0xFFA52A2A, // 棕色
|
||||
Maroon = 0xFF800000, // 栗色(褐红)
|
||||
Tan = 0xFFD2B48C, // 茶色
|
||||
Beige = 0xFFF5F5DC, // 米色
|
||||
|
||||
Navy = 0xFF000080, // 藏青色
|
||||
Olive = 0xFF808000, // 橄榄色
|
||||
Silver = 0xFFC0C0C0 // 银色
|
||||
};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class __EzUI__Line {
|
||||
public:
|
||||
__EzUI__Point<T> pointA;
|
||||
__EzUI__Point<T> pointB;
|
||||
public:
|
||||
__EzUI__Line() {
|
||||
pointA.X = 0;
|
||||
pointA.Y = 0;
|
||||
pointB.X = 0;
|
||||
pointB.Y = 0;
|
||||
}
|
||||
__EzUI__Line(const __EzUI__Point<T>& _pointA, const __EzUI__Point<T>& _pointB) {
|
||||
this->pointA = _pointA;
|
||||
this->pointB = _pointB;
|
||||
}
|
||||
};
|
||||
|
||||
typedef __EzUI__Point<int> Point;
|
||||
typedef __EzUI__Point<float> PointF;
|
||||
typedef __EzUI__Line<int> Line;
|
||||
typedef __EzUI__Line<float> LineF;
|
||||
typedef __EzUI__Size<int> Size;
|
||||
typedef __EzUI__Rect<int> Rect;
|
||||
|
||||
class SizeF :public __EzUI__Size<float> {
|
||||
public:
|
||||
SizeF()
|
||||
{
|
||||
Width = Height = 0;
|
||||
}
|
||||
SizeF(float width,
|
||||
float height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
SizeF(const SizeF& __Size)
|
||||
{
|
||||
Width = __Size.Width;
|
||||
Height = __Size.Height;
|
||||
}
|
||||
SizeF(const Size& __Size)
|
||||
{
|
||||
Width = (float)__Size.Width;
|
||||
Height = (float)__Size.Height;
|
||||
}
|
||||
};
|
||||
|
||||
class RectF :public __EzUI__Rect<float> {
|
||||
public:
|
||||
RectF() {
|
||||
this->X = 0;
|
||||
this->Y = 0;
|
||||
this->Width = 0;
|
||||
this->Height = 0;
|
||||
}
|
||||
RectF(const Rect& rect) {
|
||||
this->X = (float)rect.X;
|
||||
this->Y = (float)rect.Y;
|
||||
this->Width = (float)rect.Width;
|
||||
this->Height = (float)rect.Height;
|
||||
}
|
||||
RectF(const RectF& rect) {
|
||||
this->X = rect.X;
|
||||
this->Y = rect.Y;
|
||||
this->Width = rect.Width;
|
||||
this->Height = rect.Height;
|
||||
}
|
||||
RectF(float x, float y, float width, float height) {
|
||||
this->X = x;
|
||||
this->Y = y;
|
||||
this->Width = width;
|
||||
this->Height = height;
|
||||
}
|
||||
virtual const RectF& Scale(float scale) {
|
||||
X = (X * scale);
|
||||
Y = (Y * scale);
|
||||
Width = (Width * scale);
|
||||
Height = (Height * scale);
|
||||
return *this;
|
||||
}
|
||||
//转换
|
||||
static RectF Transformation(SizeMode sizeMode, const RectF& container, const SizeF& contentSize) {
|
||||
if (sizeMode == SizeMode::Stretch) {
|
||||
return container;
|
||||
}
|
||||
//容器数据
|
||||
float containerWidth = container.Width;
|
||||
float containerHeight = container.Height;
|
||||
float containerRatio = containerWidth / containerHeight;//宽高比
|
||||
//内容数据
|
||||
float contentWidth = contentSize.Width;
|
||||
float contentHeight = contentSize.Height;
|
||||
float contentRatio = contentWidth / contentHeight; //宽高比
|
||||
|
||||
if (sizeMode == SizeMode::Fit) {
|
||||
if (containerRatio < contentRatio) {
|
||||
float zoomHeight = containerWidth / contentWidth * contentHeight;
|
||||
float y = (containerHeight - zoomHeight) / 2.0f + container.Y;
|
||||
return RectF(container.X, y, containerWidth, zoomHeight);
|
||||
}
|
||||
else {
|
||||
float zoomWidth = containerHeight / contentHeight * contentWidth;
|
||||
float x = (containerWidth - zoomWidth) / 2.0f + container.X;
|
||||
return RectF(x, container.Y, zoomWidth, containerHeight);
|
||||
}
|
||||
}
|
||||
if (sizeMode == SizeMode::Cover) {
|
||||
if (containerRatio < contentRatio) {
|
||||
//1000 670 容器大小
|
||||
//1000 300 内容大小
|
||||
//2233 670 缩放后的内容大小
|
||||
float zoomWidth = containerHeight / contentHeight * contentWidth;//内容应该这么宽才对
|
||||
float x = (zoomWidth - containerWidth) / 2.0f;
|
||||
return RectF(container.X - x, container.Y, zoomWidth, containerHeight);
|
||||
}
|
||||
else {
|
||||
//1000 600 容器大小
|
||||
//400 600 内容大小
|
||||
//1000 1500 缩放后的内容大小
|
||||
float zoomHeight = containerWidth / contentWidth * contentHeight;//内容应该这么高才对
|
||||
float y = (zoomHeight - containerHeight) / 2.0f;
|
||||
return RectF(container.X, container.Y - y, containerWidth, zoomHeight);
|
||||
}
|
||||
}
|
||||
//按照内容原大小居中显示
|
||||
if (sizeMode == SizeMode::Original) {
|
||||
float x = (container.Width - contentSize.Width) / 2.0f;
|
||||
float y = (container.Height - contentSize.Height) / 2.0f;
|
||||
return RectF(x, y, contentSize.Width, contentSize.Height);
|
||||
}
|
||||
return container;
|
||||
}
|
||||
virtual ~RectF() {};
|
||||
};
|
||||
|
||||
struct Distance {
|
||||
public:
|
||||
WORD Left, Top, Right, Bottom;
|
||||
Distance() {
|
||||
Left = Top = Right = Bottom = 0;
|
||||
}
|
||||
Distance(WORD distanceAll) {
|
||||
Left = Top = Right = Bottom = distanceAll;
|
||||
}
|
||||
Distance& operator=(WORD distanceAll) {
|
||||
Left = Top = Right = Bottom = distanceAll;
|
||||
return *this;
|
||||
}
|
||||
void Scale(float scale) {
|
||||
Top = WORD(Top * scale + 0.5);
|
||||
Bottom = WORD(Bottom * scale + 0.5);
|
||||
Left = WORD(Left * scale + 0.5);
|
||||
Right = WORD(Right * scale + 0.5);
|
||||
}
|
||||
//获取垂直所占空间
|
||||
WORD GetVSpace() {
|
||||
return Top + Bottom;
|
||||
}
|
||||
//获取水平所占空间
|
||||
WORD GetHSpace() {
|
||||
return Left + Right;
|
||||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 描述边框的一些信息
|
||||
/// </summary>
|
||||
class Border {
|
||||
public:
|
||||
WORD Left = 0;//左边边框大小
|
||||
WORD Top = 0;//顶部边框大小
|
||||
WORD Right = 0;//右边边框大小
|
||||
WORD Bottom = 0;//底部边框大小
|
||||
WORD TopLeftRadius = 0;
|
||||
WORD TopRightRadius = 0;
|
||||
WORD BottomRightRadius = 0;
|
||||
WORD BottomLeftRadius = 0;
|
||||
__EzUI__Color Color;
|
||||
StrokeStyle Style = StrokeStyle::None;
|
||||
public:
|
||||
class Radius {
|
||||
Border& Border;
|
||||
public:
|
||||
Radius(ezui::Border& bd) :Border(bd) {}
|
||||
//对四个角度同时设置半径大小
|
||||
Radius& operator=(WORD radius) {
|
||||
Border.TopLeftRadius = radius;
|
||||
Border.TopRightRadius = radius;
|
||||
Border.BottomRightRadius = radius;
|
||||
Border.BottomLeftRadius = radius;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
public:
|
||||
Border::Radius Radius = (*this);
|
||||
public:
|
||||
Border() {}
|
||||
//对四个边设置大小
|
||||
Border& operator=(WORD borderWidth) {
|
||||
Left = borderWidth;
|
||||
Top = borderWidth;
|
||||
Right = borderWidth;
|
||||
Bottom = borderWidth;
|
||||
return *this;
|
||||
}
|
||||
void Scale(float scale) {
|
||||
Left = WORD(Left * scale + 0.5);
|
||||
Top = WORD(Top * scale + 0.5);
|
||||
Right = WORD(Right * scale + 0.5);
|
||||
Bottom = WORD(Bottom * scale + 0.5);
|
||||
TopLeftRadius = WORD(TopLeftRadius * scale + 0.5);
|
||||
TopRightRadius = WORD(TopRightRadius * scale + 0.5);
|
||||
BottomRightRadius = WORD(BottomRightRadius * scale + 0.5);
|
||||
BottomLeftRadius = WORD(BottomLeftRadius * scale + 0.5);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class IImage {
|
||||
protected:
|
||||
WORD m_frameCount = 0;//总帧数
|
||||
WORD m_framePos = 0;//当前帧率索引
|
||||
public:
|
||||
Rect Clip;//取出图像部分区域进行绘制
|
||||
Point DrawPosition;//绘制在owner矩形坐标
|
||||
ezui::Size DrawSize;//绘制在owner矩形的大小
|
||||
ImageSizeMode SizeMode = ImageSizeMode::Fit;// 图像显示模式
|
||||
public:
|
||||
virtual ~IImage() {}
|
||||
WORD FrameCount() {
|
||||
return m_frameCount;
|
||||
}
|
||||
//跳转到下一帧 并且获取下一帧的延迟
|
||||
virtual WORD NextFrame() = 0;
|
||||
};
|
||||
|
||||
};
|
||||
50
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Resource.h
vendored
Normal file
50
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Resource.h
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include "UIString.h"
|
||||
|
||||
namespace ezui {
|
||||
/// <summary>
|
||||
/// 框架中的资源类
|
||||
/// </summary>
|
||||
class UI_EXPORT Resource {
|
||||
public:
|
||||
struct Entry {
|
||||
std::streampos Offset = 0;//偏移
|
||||
std::streamsize Size = 0;//大小
|
||||
UIString Name;//名称
|
||||
};
|
||||
//资源文件读取流
|
||||
class UI_EXPORT ReadStream {
|
||||
std::streampos m_pos = 0;
|
||||
std::streamsize m_count = 0;
|
||||
const char* m_ptr = NULL;
|
||||
std::ifstream* m_ifs = NULL;
|
||||
public:
|
||||
ReadStream(HRSRC hRsrc);
|
||||
ReadStream(const UIString& fileName);
|
||||
void seekg(std::streampos pos);
|
||||
void read(char* buf, std::streamsize count);
|
||||
std::streampos tellg();
|
||||
const std::streamsize size();
|
||||
virtual ~ReadStream();
|
||||
};
|
||||
private:
|
||||
ReadStream* m_rStream = NULL;
|
||||
void UnPackage();
|
||||
bool m_isGood = false;
|
||||
public:
|
||||
const std::list<Entry> Items;
|
||||
bool IsGood();
|
||||
//对资源目录进行打包
|
||||
static bool Package(const UIString& dir, const UIString& outFile, const std::function<void(const UIString&, int, int)>& packCallback = NULL);
|
||||
public:
|
||||
virtual ~Resource();
|
||||
//从本地文件创建资源对象
|
||||
Resource(const UIString& resFile);
|
||||
//使用windows内置资源文件创建资源对象
|
||||
Resource(HRSRC hRsrc);
|
||||
//寻找资源中的文件
|
||||
bool GetFile(const UIString& fileName, std::string* out);
|
||||
//传入item直接返回数据
|
||||
void GetFile(const Entry& item, std::string* out);
|
||||
};
|
||||
};
|
||||
67
demo/Adminstor/ThirdParty/EzUI/include/EzUI/ScrollBar.h
vendored
Normal file
67
demo/Adminstor/ThirdParty/EzUI/include/EzUI/ScrollBar.h
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT ScrollBar :public Control {
|
||||
protected:
|
||||
//鼠标是否已经按下
|
||||
bool m_mouseDown = false;
|
||||
//上一次鼠标命中的坐标
|
||||
int m_lastPoint = 0;
|
||||
//滚动条当前的坐标
|
||||
double m_sliderPos = 0;
|
||||
//滚动条的长度
|
||||
int m_sliderLength = 0;
|
||||
//滚动条每滚动一次的比率
|
||||
double m_rollRate = 0;
|
||||
//父容器内的坐标偏移
|
||||
int m_offset = 0;
|
||||
//父容器的内容长度
|
||||
int m_contentLength = 0;
|
||||
//父容器可见长度(容器自身长度)
|
||||
int m_viewLength = 0;
|
||||
//溢出容器的长度
|
||||
int m_overflowLength = 0;
|
||||
|
||||
//int _old_viewLength = 0;
|
||||
//int _old_contentLength = 0;
|
||||
//int _old_offset = 0;
|
||||
private:
|
||||
void Init();
|
||||
public:
|
||||
//滚动条计算出偏移之后的回调函数
|
||||
std::function<void(int)> OffsetCallback = NULL;
|
||||
//滚动事件 arg1:发送者 arg2:滚动百分比 arg3:滚动类型
|
||||
std::function<void(ScrollBar*, float, Event)> Scroll = NULL;
|
||||
protected:
|
||||
virtual void OnBackgroundPaint(PaintEventArgs& arg)override;
|
||||
virtual void OnForePaint(PaintEventArgs& args) override;
|
||||
virtual void OnMouseDown(const MouseEventArgs& arg)override;
|
||||
virtual void OnMouseUp(const MouseEventArgs& arg)override;
|
||||
virtual void OnMouseLeave(const MouseEventArgs& arg) override;
|
||||
virtual void OnMouseWheel(const MouseEventArgs& arg)override;
|
||||
virtual void GetInfo(int* viewLength, int* contentLength, int* scrollBarLength) = 0;
|
||||
void ScrollTo(int offset, const Event& type);
|
||||
void SyncInfo();
|
||||
public:
|
||||
//滚动到指定控件可见位置
|
||||
virtual void ScrollTo(Control* ctl) = 0;
|
||||
//按照百分比滚动 0.0f~1.0f
|
||||
void ScrollTo(float scrollRate);
|
||||
//获取当前滚动到的位置 进度的百分比
|
||||
float ScrollPos();
|
||||
//获取滑块的矩形
|
||||
virtual Rect GetSliderRect() = 0;//
|
||||
virtual void ParentSize(const Size& parentSize) = 0;
|
||||
//滚动条是否已经绘制且显示
|
||||
bool IsDraw();
|
||||
//重置滚动条数据到起点(不执行重绘)
|
||||
void Reset();
|
||||
//滚动条是否能够滚动
|
||||
bool Scrollable();
|
||||
//当父控件发生内容发生改变 请调用刷新滚动条
|
||||
void RefreshScroll();
|
||||
ScrollBar(Object* parentObject = NULL);
|
||||
virtual ~ScrollBar();
|
||||
};
|
||||
};
|
||||
28
demo/Adminstor/ThirdParty/EzUI/include/EzUI/ShadowBox.h
vendored
Normal file
28
demo/Adminstor/ThirdParty/EzUI/include/EzUI/ShadowBox.h
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include "Window.h"
|
||||
#include "Bitmap.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT ShadowBox
|
||||
{
|
||||
private:
|
||||
Size m_lastSize;
|
||||
int m_lastShadowMargin = 0;
|
||||
Bitmap* m_bufBitmap = NULL;
|
||||
HWND m_hWnd = NULL;
|
||||
HWND m_mainHWnd = NULL;
|
||||
WORD m_radius = 0;
|
||||
WindowData* m_publicData = NULL;
|
||||
private:
|
||||
void SetAplpha(int x, int y, BYTE a, float radius);
|
||||
bool SetShadow(int m_Width, int m_Height, int iSize, float radius);
|
||||
protected:
|
||||
virtual LRESULT WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
public:
|
||||
ShadowBox(int width, int height, HWND mainHwnd);//构造函数
|
||||
virtual ~ShadowBox();
|
||||
//在父窗口发生改变的时候更新阴影区域
|
||||
virtual void Update(int shadowMargin, int radius);
|
||||
HWND Hwnd();
|
||||
};
|
||||
};
|
||||
23
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Spacer.h
vendored
Normal file
23
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Spacer.h
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
|
||||
namespace ezui {
|
||||
//添加弹簧无需用户手动释放(不可在栈上创建弹簧对象)
|
||||
class UI_EXPORT Spacer :public Control {
|
||||
public:
|
||||
Spacer();
|
||||
virtual ~Spacer();
|
||||
};
|
||||
//具有绝对高度的 的弹簧
|
||||
class UI_EXPORT VSpacer :public Spacer {
|
||||
public:
|
||||
virtual ~VSpacer();
|
||||
VSpacer(int fixedHeight = 0);
|
||||
};
|
||||
//具有绝对宽度的 的弹簧
|
||||
class UI_EXPORT HSpacer :public Spacer {
|
||||
public:
|
||||
virtual ~HSpacer();
|
||||
HSpacer(int fixedWidth = 0);
|
||||
};
|
||||
};
|
||||
43
demo/Adminstor/ThirdParty/EzUI/include/EzUI/TabLayout.h
vendored
Normal file
43
demo/Adminstor/ThirdParty/EzUI/include/EzUI/TabLayout.h
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
#include "Timer.h"
|
||||
|
||||
namespace ezui {
|
||||
//滑动方向
|
||||
enum class SlideDirection {
|
||||
Horizontal, // 横向滑动(比如从左滑到右)
|
||||
Vertical // 纵向滑动(比如从上滑到底)
|
||||
};
|
||||
class UI_EXPORT TabLayout :
|
||||
public Control
|
||||
{
|
||||
private:
|
||||
int m_pageIndex = 0;
|
||||
Timer* m_timer;
|
||||
int m_offset = 0;
|
||||
int m_nowOffset = 0;
|
||||
std::vector<int> m_initial;
|
||||
SlideDirection m_dlideDirection;
|
||||
float m_stepAcc = 0;
|
||||
float m_stepPerFrame = 0;
|
||||
void Sort();
|
||||
void Init();
|
||||
protected:
|
||||
virtual void OnLayout()override;
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
virtual void OnChildPaint(PaintEventArgs& args)override;
|
||||
public:
|
||||
TabLayout(Object* parentObject = NULL);
|
||||
virtual ~TabLayout();
|
||||
virtual void Remove(Control* ctl, bool freeCtl = false)override;
|
||||
virtual Control* Add(Control* childCtl)override;
|
||||
//设置当前显示页
|
||||
void SetPageIndex(int index);
|
||||
//动画方式滑动到某一页
|
||||
void SlideToPage(int index, SlideDirection dlideDirection = SlideDirection::Horizontal, int durationMs = 150, int fps = 90);
|
||||
void SetPage(Control* ctl);
|
||||
Control* GetPage();
|
||||
//获取当前页索引
|
||||
int GetPageIndex();
|
||||
};
|
||||
};
|
||||
98
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Task.h
vendored
Normal file
98
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Task.h
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
#pragma once
|
||||
#include "EzUI.h"
|
||||
|
||||
namespace ezui {
|
||||
//互斥锁
|
||||
class UI_EXPORT Mutex {
|
||||
private:
|
||||
CRITICAL_SECTION m_mtx; // 互斥锁
|
||||
bool m_bLocked;
|
||||
Mutex(const Mutex&) = delete;
|
||||
public:
|
||||
Mutex();
|
||||
virtual ~Mutex();
|
||||
// 锁定互斥锁
|
||||
void Lock();
|
||||
// 解锁互斥锁
|
||||
void UnLock();
|
||||
};
|
||||
//带互斥锁的条件变量类
|
||||
class UI_EXPORT ConditionVariable {
|
||||
private:
|
||||
HANDLE m_codv = NULL; // 事件对象(模拟条件变量)
|
||||
Mutex m_mtx; // 锁对象
|
||||
ConditionVariable(const ConditionVariable&) = delete;
|
||||
public:
|
||||
ConditionVariable();
|
||||
virtual ~ConditionVariable();
|
||||
// 唤醒等待的线程(唤醒单个线程)
|
||||
void Notify();
|
||||
// 可选条件的等待(不可以多个线程使用此函数)
|
||||
void Wait(const std::function<bool()>& condition_cb = NULL);
|
||||
// 锁定互斥锁
|
||||
void Lock();
|
||||
// 解锁互斥锁
|
||||
void Unlock();
|
||||
};
|
||||
};
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT Task {
|
||||
bool m_finished = false;
|
||||
std::thread* m_thread = NULL;
|
||||
bool m_bJoin = false;
|
||||
private:
|
||||
Task(const Task&) = delete;
|
||||
void DoWork(std::function<void()>* func);
|
||||
public:
|
||||
template<class Func, class... Args>
|
||||
Task(Func&& f, Args&& ...args) {
|
||||
std::function<void()>* func = new std::function<void()>(std::bind(std::forward<Func>(f), std::forward<Args>(args)...));
|
||||
m_thread = new std::thread([this, func]() mutable {
|
||||
DoWork(func);
|
||||
});
|
||||
}
|
||||
void Wait();
|
||||
//当前任务是否已经停止
|
||||
bool IsStopped();
|
||||
virtual ~Task();
|
||||
};
|
||||
|
||||
class UI_EXPORT TaskFactory {
|
||||
bool m_bStop = false;
|
||||
std::list<Task*> m_tasks;
|
||||
std::list<std::function<void()>> m_funcs;
|
||||
std::mutex m_mtx;
|
||||
std::condition_variable m_codv;
|
||||
//用于等待任务清空的锁和条件变量
|
||||
std::mutex m_mtx2;
|
||||
std::condition_variable m_codv2;
|
||||
private:
|
||||
TaskFactory(const TaskFactory&) = delete;
|
||||
public:
|
||||
TaskFactory(int maxTaskCount = 50);
|
||||
//添加到任务队列中的末尾(先后顺序执行)
|
||||
template<class Func, class... Args>
|
||||
void Add(Func&& f, Args&& ...args) {
|
||||
{
|
||||
std::unique_lock<std::mutex> autoLock(m_mtx);
|
||||
m_funcs.emplace_back(std::bind(std::forward<Func>(f), std::forward<Args>(args)...));
|
||||
}
|
||||
m_codv.notify_one();
|
||||
}
|
||||
//添加至任务队列的第一位(优先执行)
|
||||
template<class Func, class... Args>
|
||||
void AddToFrist(Func&& f, Args&& ...args) {
|
||||
{
|
||||
std::unique_lock<std::mutex> autoLock(m_mtx);
|
||||
m_funcs.emplace_front(std::bind(std::forward<Func>(f), std::forward<Args>(args)...));
|
||||
}
|
||||
m_codv.notify_one();
|
||||
}
|
||||
|
||||
//等待所有任务被取走
|
||||
void WaitAll();
|
||||
virtual ~TaskFactory();
|
||||
};
|
||||
|
||||
};
|
||||
116
demo/Adminstor/ThirdParty/EzUI/include/EzUI/TextBox.h
vendored
Normal file
116
demo/Adminstor/ThirdParty/EzUI/include/EzUI/TextBox.h
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
#include "VScrollBar.h"
|
||||
#include "Timer.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT TextBox :
|
||||
public Control
|
||||
{
|
||||
private:
|
||||
VScrollBar m_vScrollbar;
|
||||
int m_lastWidth = 0;
|
||||
int m_lastHeight = 0;
|
||||
bool m_multiLine = false;
|
||||
std::wstring m_text;//文字
|
||||
Size m_fontBox;
|
||||
bool m_down = false;//是否具有焦点中
|
||||
bool m_focus = false;//是否具有焦点中
|
||||
Point m_point_Start;//开始选中的位置
|
||||
Point m_point_End;//结束位置
|
||||
std::vector<RectF> m_selectRects;//选中的字符矩形
|
||||
Rect m_careRect;//光标位置
|
||||
Font* m_font = NULL;//字体
|
||||
TextLayout* m_textLayout = NULL;//字体布局
|
||||
Point m_pointA;//A点
|
||||
BOOL m_A_isTrailingHit;//如果是1表示是字符的后半边
|
||||
int m_A_TextPos = 0;//点击了第几个字符
|
||||
Point m_pointB;//B点
|
||||
BOOL m_B_isTrailingHit;//如果是1表示是字符的后半边
|
||||
int m_B_TextPos = 0;//点击了第几个字符
|
||||
int m_textPos = 0;//当前文字的下标 0~text.size()
|
||||
int m_scrollX = 0;//用于左右滚动
|
||||
int m_scrollY = 0;//用于y轴滚动
|
||||
int m_lastX = 0;//上一个x位置
|
||||
int m_lastY = 0;//上一个y位置
|
||||
Timer* m_timer;//用于光标闪烁
|
||||
bool m_bCareShow = false;//用于光标闪烁
|
||||
int m_maxLen = -1;//最大文字数量
|
||||
std::wstring m_placeholder;//placeholder懂得都懂 (在没有文字的情况下显示的文字)
|
||||
std::wstring m_passwordChar;
|
||||
bool m_readOnly = false;//是否只读
|
||||
// 内边距(四边独立)
|
||||
int m_padLeft = 6;
|
||||
int m_padTop = 4;
|
||||
int m_padRight = 6;
|
||||
int m_padBottom = 4;
|
||||
public:
|
||||
//文字对其方式(针对单行输入框有效)
|
||||
TextAlign TextAlign = TextAlign::MiddleLeft;
|
||||
private:
|
||||
void Init();
|
||||
void InsertUnicode(const std::wstring& str, bool isEnd = false);//插入unicode文字内部使用
|
||||
bool DeleteRange();//删除选中内容
|
||||
bool GetSelectedRange(int* outPos, int* outCount);//获取当前被选中的区域 返回下标和个数
|
||||
bool Copy();//复制到剪切板
|
||||
bool Paste();//粘贴
|
||||
bool SelectedAll();//全选
|
||||
void OnBackspace();//退格键要做的事
|
||||
void BuildCare();//构建光标
|
||||
void BuildSelectedRect();
|
||||
Point ConvertPoint(const Point& pt);//坐标转换
|
||||
protected:
|
||||
virtual void OnRemove()override;
|
||||
virtual void SetAutoWidth(bool flag)override;
|
||||
virtual void SetAutoHeight(bool flag)override;
|
||||
virtual void OnForePaint(PaintEventArgs& e) override;
|
||||
virtual void OnKeyChar(const KeyboardEventArgs& arg) override;
|
||||
virtual void OnKeyDown(const KeyboardEventArgs& arg)override;
|
||||
virtual void OnMouseDown(const MouseEventArgs& arg)override;
|
||||
virtual void OnMouseWheel(const MouseEventArgs& arg)override;
|
||||
virtual void OnMouseMove(const MouseEventArgs& arg) override;
|
||||
virtual void OnMouseUp(const MouseEventArgs& arg)override;
|
||||
virtual void OnFocus(const FocusEventArgs& arg) override;
|
||||
virtual void OnKillFocus(const KillFocusEventArgs& arg) override;
|
||||
virtual void OnLayout();
|
||||
void Offset(int moveY);
|
||||
// 支持 TextBox 自身扩展样式属性(padding 系列)
|
||||
virtual bool ApplyStyleProperty(const UIString& key, const UIString& value) override;
|
||||
public:
|
||||
std::function<void(const UIString&)> TextChanged = NULL;
|
||||
public:
|
||||
TextBox(Object* parentObject = NULL);
|
||||
virtual ~TextBox();
|
||||
// 设置内边距 (兼容旧接口:水平=px, 垂直=py)
|
||||
void SetPadding(int px, int py);
|
||||
// 设置四边
|
||||
void SetPadding4(int left, int top, int right, int bottom);
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
//获取焦点所在光标位置
|
||||
virtual Rect GetCareRect()override;
|
||||
//分析字符串
|
||||
void Analysis();
|
||||
//在当前光标中插入文字
|
||||
void Insert(const UIString& str, bool isEnd = false);
|
||||
//获取输入框文字
|
||||
const UIString GetText();
|
||||
//获取滚动条
|
||||
virtual ScrollBar* GetScrollBar()override;
|
||||
//设置文字
|
||||
void SetText(const UIString& text);
|
||||
//是否多行显示
|
||||
bool IsMultiLine();
|
||||
//设置是否多行显示
|
||||
void SetMultiLine(bool multiLine);
|
||||
//设置为是否只读
|
||||
void SetReadOnly(bool bReadOnly);
|
||||
//是否为只读
|
||||
bool IsReadOnly();
|
||||
//设置最大输入字符个数
|
||||
void SetMaxLength(int maxLen);
|
||||
// 设置占位符文本
|
||||
void SetPlaceholderText(const UIString& text);
|
||||
//设置密码框占位符(建议单字符)
|
||||
void SetPasswordChar(const UIString& passwordChar);
|
||||
};
|
||||
};
|
||||
22
demo/Adminstor/ThirdParty/EzUI/include/EzUI/TileListView.h
vendored
Normal file
22
demo/Adminstor/ThirdParty/EzUI/include/EzUI/TileListView.h
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "PagedListView.h"
|
||||
#include "VScrollBar.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT TileListView :
|
||||
public PagedListView
|
||||
{
|
||||
private:
|
||||
VScrollBar m_vScrollBar;
|
||||
bool m_autoHeight = false;//根据内容的高度自动变化
|
||||
void Init();
|
||||
void Offset(int offset);
|
||||
protected:
|
||||
virtual void OnChildPaint(PaintEventArgs& args)override;
|
||||
virtual void OnLayout()override;
|
||||
public:
|
||||
TileListView(Object* parentObject = NULL);
|
||||
virtual ~TileListView();
|
||||
virtual ScrollBar* GetScrollBar()override;
|
||||
};
|
||||
};
|
||||
39
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Timer.h
vendored
Normal file
39
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Timer.h
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
#include "EzUI.h"
|
||||
#include "Task.h"
|
||||
|
||||
namespace ezui {
|
||||
|
||||
//使用线程的计时器 不与主进程同步(启动的时候就直接开始执行回调函数)
|
||||
class UI_EXPORT Timer :public Object {
|
||||
bool m_bExit = false;
|
||||
std::atomic<bool> m_bPause = true;
|
||||
Task* m_task = NULL;
|
||||
HANDLE m_event = NULL;
|
||||
public:
|
||||
std::function<void(Timer*)> Tick = NULL;
|
||||
int Interval = 0;
|
||||
public:
|
||||
//Timeout干啥的不用我多说什么了吧
|
||||
template<class Func, class... Args>
|
||||
static void Timeout(int msec, Func&& f, Args&& ...args) {
|
||||
std::function<void()>* func = new std::function<void()>(std::bind(f, args...));
|
||||
Timer* timer = new Timer;
|
||||
timer->Interval = 0;
|
||||
timer->Tick = [msec, func](Timer* t) {
|
||||
t->Stop();
|
||||
Sleep(msec);
|
||||
(*func)();
|
||||
delete func;
|
||||
t->DeleteLater();
|
||||
};
|
||||
timer->Start();
|
||||
};
|
||||
public:
|
||||
Timer(Object* parentObject = NULL);
|
||||
bool IsStopped();
|
||||
void Start();
|
||||
void Stop();
|
||||
virtual ~Timer();
|
||||
};
|
||||
};
|
||||
14
demo/Adminstor/ThirdParty/EzUI/include/EzUI/TreeView.h
vendored
Normal file
14
demo/Adminstor/ThirdParty/EzUI/include/EzUI/TreeView.h
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "HListView.h"
|
||||
#include "VListView.h"
|
||||
namespace ezui {
|
||||
//树形菜单 还在设计中
|
||||
class UI_EXPORT TreeView :public HListView {
|
||||
private:
|
||||
VListView m_vList;
|
||||
public:
|
||||
TreeView(Object* parentObj = NULL);
|
||||
void AddNode(const UIString& nodeName);
|
||||
virtual ~TreeView();
|
||||
};
|
||||
};
|
||||
116
demo/Adminstor/ThirdParty/EzUI/include/EzUI/UIDef.h
vendored
Normal file
116
demo/Adminstor/ThirdParty/EzUI/include/EzUI/UIDef.h
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#ifndef GET_X_LPARAM
|
||||
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
|
||||
#endif // !GET_X_LPARAM
|
||||
|
||||
#ifndef GET_Y_LPARAM
|
||||
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
|
||||
#endif // !GET_Y_LPARAM
|
||||
|
||||
#ifndef ASSERT
|
||||
#ifdef _DEBUG
|
||||
#define ASSERT(expr) _ASSERTE(expr)
|
||||
#else
|
||||
#define ASSERT(expr) ((void)0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GCL_HCURSOR
|
||||
#define GCL_HCURSOR -12
|
||||
#endif
|
||||
|
||||
#ifdef _WIN64
|
||||
#define UI_SET_USERDATA(hWnd,data) SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)data);
|
||||
#define UI_GET_USERDATA(hwnd) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
||||
#else
|
||||
#define UI_SET_USERDATA(hWnd,data) SetWindowLongW(hWnd, GWLP_USERDATA, (LONG)data);
|
||||
#define UI_GET_USERDATA(hwnd) GetWindowLongW(hwnd, GWLP_USERDATA);
|
||||
#endif
|
||||
|
||||
#if defined _M_IX86
|
||||
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#elif defined _M_IA64
|
||||
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#elif defined _M_X64
|
||||
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#else
|
||||
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#endif
|
||||
|
||||
//框架内保留的消息 用于GUI框架内部通讯
|
||||
#define WM_GUI_SYSTEM WM_USER
|
||||
#define WM_GUI_APP WM_APP
|
||||
//扩展消息 在WM_GUI_SYSTEM消息中的wParam参数中体现
|
||||
#define WM_GUI_INVOKE 0x01
|
||||
#define WM_GUI_BEGININVOKE 0x02
|
||||
|
||||
#if defined(EZUI_STATIC)
|
||||
|
||||
#define UI_EXPORT
|
||||
#define UI_VAR_EXPORT
|
||||
|
||||
#elif defined(_WINDLL)
|
||||
|
||||
#define UI_EXPORT __declspec(dllexport)
|
||||
#define UI_VAR_EXPORT __declspec(dllexport)
|
||||
|
||||
#else
|
||||
|
||||
#define UI_EXPORT
|
||||
#define UI_VAR_EXPORT __declspec(dllimport)
|
||||
|
||||
#endif // EZUI_STATIC
|
||||
|
||||
#define EZUI_WINDOW_CLASS L"EzUI_Window" //基础窗口类名
|
||||
#define EZUI_INVOKER_WINDOW_CLASS L"EzUI_InvokerWindow" //用于线程同步的窗口类名
|
||||
#define EZUI_FLOAT_MAX 16777216.0f //最后一个可以精确表示的整数
|
||||
#define EZUI_FLOAT_EPSILON 1e-6f // 浮点误差阈值
|
||||
//下面的渲染方式只能选一个
|
||||
#define USED_DIRECT2D 1 //DX绘制 性能好 内存占用高
|
||||
|
||||
//生成枚举类常用操作符
|
||||
#define EZUI_ENUM_OPERATORS(ENUM_TYPE, BASE_TYPE) \
|
||||
inline ENUM_TYPE operator|(ENUM_TYPE a, ENUM_TYPE b) { \
|
||||
return static_cast<ENUM_TYPE>(static_cast<BASE_TYPE>(a) | static_cast<BASE_TYPE>(b)); \
|
||||
} \
|
||||
inline ENUM_TYPE operator&(ENUM_TYPE a, ENUM_TYPE b) { \
|
||||
return static_cast<ENUM_TYPE>(static_cast<BASE_TYPE>(a) & static_cast<BASE_TYPE>(b)); \
|
||||
} \
|
||||
inline ENUM_TYPE operator~(ENUM_TYPE a) { \
|
||||
return static_cast<ENUM_TYPE>(~static_cast<BASE_TYPE>(a)); \
|
||||
} \
|
||||
inline ENUM_TYPE operator^(ENUM_TYPE a, ENUM_TYPE b) { \
|
||||
return static_cast<ENUM_TYPE>(static_cast<BASE_TYPE>(a) ^ static_cast<BASE_TYPE>(b)); \
|
||||
} \
|
||||
inline ENUM_TYPE& operator|=(ENUM_TYPE& a, ENUM_TYPE b) { \
|
||||
a = a | b; \
|
||||
return a; \
|
||||
} \
|
||||
inline ENUM_TYPE& operator&=(ENUM_TYPE& a, ENUM_TYPE b) { \
|
||||
a = a & b; \
|
||||
return a; \
|
||||
} \
|
||||
inline ENUM_TYPE& operator^=(ENUM_TYPE& a, ENUM_TYPE b) { \
|
||||
a = a ^ b; \
|
||||
return a; \
|
||||
}
|
||||
77
demo/Adminstor/ThirdParty/EzUI/include/EzUI/UIManager.h
vendored
Normal file
77
demo/Adminstor/ThirdParty/EzUI/include/EzUI/UIManager.h
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
#include "Spacer.h"
|
||||
#include "HLayout.h"
|
||||
#include "Label.h"
|
||||
#include "VLayout.h"
|
||||
#include "TileListView.h"
|
||||
#include "Button.h"
|
||||
#include "VListView.h"
|
||||
#include "HListView.h"
|
||||
#include "RadioButton.h"
|
||||
#include "CheckBox.h"
|
||||
#include "TextBox.h"
|
||||
#include "TabLayout.h"
|
||||
#include "PictureBox.h"
|
||||
#include "ProgressBar.h"
|
||||
#include "Window.h"
|
||||
#include "ComboBox.h"
|
||||
|
||||
namespace ezui {
|
||||
//主窗口中的内联页面类
|
||||
class UI_EXPORT UIManager {
|
||||
public:
|
||||
struct Style
|
||||
{
|
||||
ControlState m_styleType;
|
||||
UIString m_selectorName;
|
||||
UIString m_styleStr;
|
||||
};
|
||||
struct XmlNode {
|
||||
Control* m_ctl;
|
||||
UIString m_tagName;
|
||||
public:
|
||||
XmlNode(Control* ctl, const UIString& tagName) :m_ctl(ctl), m_tagName(tagName) {}
|
||||
};
|
||||
private:
|
||||
std::vector<Control*> m_rootNode;//根节点列表
|
||||
std::list<XmlNode> m_controls;
|
||||
std::list<UIManager::Style> m_styles;
|
||||
void LoadControl(void* node, Control* control);
|
||||
Control* BuildControl(void* node);//内部函数
|
||||
//记录XML中的控件到管理器 管理器释放的时候 由管理器加载的控件将自动释放
|
||||
void RegisterControl(Control* ctl, const UIString& tagNamee);
|
||||
void AnalysisStyle(const UIString& styleStr, std::list<UIManager::Style>* out);//分析样式
|
||||
void ApplyStyle(Control* ctl, const std::list<UIManager::Style>& selectors, const UIString& tagName);
|
||||
//应用样式(为控件应用所有样式)
|
||||
protected:
|
||||
//当解析到一个节点的时候发生
|
||||
virtual Control* OnBuildControl(const UIString& nodeName);
|
||||
//获取根节点控件
|
||||
Control* GetRoot(int index = 0);
|
||||
public:
|
||||
UIManager();
|
||||
virtual ~UIManager();
|
||||
void SetupUI(Window* window);
|
||||
void SetupUI(Control* parentCtl);
|
||||
//从文件中加载布局(不允许多次加载xml)
|
||||
void LoadXml(const UIString& fileName);
|
||||
//从内存加载布局(不允许多次加载xml)
|
||||
void LoadXml(const char* fileData, size_t fileSize);
|
||||
//设置样式表
|
||||
void SetStyleSheet(const UIString& styleContent);
|
||||
//从文件中加载样式
|
||||
void LoadStyle(const UIString& fileName);
|
||||
//释放由本此对象创建的控件
|
||||
void Free(Control** ctl);
|
||||
};
|
||||
//注册基础控件
|
||||
void InitControls();
|
||||
//注册自定义控件
|
||||
void RegisterControl(const UIString& ctrlName, const std::function<Control* ()>& create_cb);
|
||||
//注册自定义控件
|
||||
template<typename T>
|
||||
void RegisterControl(const UIString& ctrlName) {
|
||||
RegisterControl(ctrlName, []() -> Control* { return new T; });
|
||||
}
|
||||
};
|
||||
28
demo/Adminstor/ThirdParty/EzUI/include/EzUI/UISelector.h
vendored
Normal file
28
demo/Adminstor/ThirdParty/EzUI/include/EzUI/UISelector.h
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include "UIManager.h"
|
||||
|
||||
namespace ezui {
|
||||
//控件选择器(多功能选择器暂时未完善)
|
||||
class UI_EXPORT UISelector
|
||||
{
|
||||
private:
|
||||
Control* m_ctl = NULL;
|
||||
Control* m_notCtl = NULL;
|
||||
std::vector<Control*> m_ctls;
|
||||
UISelector& NextName(const UIString& key) { return *this; };
|
||||
UISelector& NextId(const UIString& key) { return *this; };
|
||||
public:
|
||||
UISelector(const std::vector<Control*>& controls);
|
||||
UISelector(const std::list<Control*>& controls);
|
||||
UISelector(Control* control);
|
||||
UISelector(Control* control, const UIString& mathStr);
|
||||
virtual ~UISelector();
|
||||
UISelector& Css(const UIString& styleStr);
|
||||
UISelector& CssHover(const UIString& styleStr);
|
||||
UISelector& CssActive(const UIString& styleStr);
|
||||
UISelector& Attr(const UIString& key, const UIString& value);
|
||||
UISelector& Refresh();
|
||||
UISelector& Not(Control* fiterCtl);
|
||||
};
|
||||
#define $ UISelector
|
||||
};
|
||||
78
demo/Adminstor/ThirdParty/EzUI/include/EzUI/UIString.h
vendored
Normal file
78
demo/Adminstor/ThirdParty/EzUI/include/EzUI/UIString.h
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
#pragma once
|
||||
#include "UIDef.h"
|
||||
#include <codecvt>
|
||||
#include <iomanip>
|
||||
|
||||
namespace ezui {
|
||||
namespace ui_text {
|
||||
|
||||
//-----------------------------------------------Copy Start-----------------------------------------------
|
||||
/// <summary>
|
||||
/// utf8字符串
|
||||
/// </summary>
|
||||
class UI_EXPORT String :public std::string {
|
||||
public:
|
||||
String();
|
||||
virtual ~String();
|
||||
String(const String& _right)noexcept;
|
||||
String(String&& _right)noexcept;
|
||||
String& operator=(const String& _right)noexcept;
|
||||
String& operator=(String&& _right)noexcept;
|
||||
String(const std::string& str)noexcept;
|
||||
String(const char* szbuf)noexcept;
|
||||
String(const wchar_t* szbuf)noexcept;
|
||||
String(const std::wstring& wstr)noexcept;
|
||||
//返回utf8字符个数
|
||||
size_t utf8Length() const;
|
||||
std::wstring unicode() const;
|
||||
std::string ansi() const;
|
||||
void erase(char _ch);
|
||||
void erase(size_t pos, size_t count);
|
||||
String replace(char oldChar, char newChar)const;
|
||||
String replace(const String& oldText, const String& newText, bool allReplace = true)const;
|
||||
String toLower()const;
|
||||
String toUpper()const;
|
||||
//去除前后空格
|
||||
String trim()const;
|
||||
//find value count
|
||||
size_t count(const String& value)const;
|
||||
std::vector<String> split(const String& ch)const;
|
||||
bool operator==(const wchar_t* szbuf)const;
|
||||
bool operator==(const std::wstring& wStr)const;
|
||||
|
||||
template<typename ...T>
|
||||
inline String format(const T &...args) {
|
||||
auto bufSize = ::snprintf(NULL, 0, this->c_str(), std::forward<const T&>(args)...) + 1; // +1是为了'结束符\0'
|
||||
char* buf = new char[bufSize] {0};
|
||||
auto count = ::sprintf_s(buf, bufSize, this->c_str(), std::forward<const T&>(args)...);
|
||||
String ret(buf);
|
||||
delete[] buf;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
//base convert
|
||||
UI_EXPORT void AnyToUnicode(const std::string& src_str, UINT codePage, std::wstring* out_wstr);
|
||||
UI_EXPORT void UnicodeToAny(const std::wstring& unicode_wstr, UINT codePage, std::string* out_str);
|
||||
//
|
||||
UI_EXPORT void GBKToUTF8(const std::string& str, std::string* outStr);
|
||||
UI_EXPORT void UTF8ToGBK(const std::string& str, std::string* outStr);
|
||||
UI_EXPORT void ANSIToUniCode(const std::string& str, std::wstring* outStr);
|
||||
UI_EXPORT void ANSIToUTF8(const std::string& str, std::string* outStr);
|
||||
UI_EXPORT void UnicodeToANSI(const std::wstring& wstr, std::string* outStr);
|
||||
UI_EXPORT void UnicodeToUTF8(const std::wstring& wstr, std::string* outStr);
|
||||
UI_EXPORT void UTF8ToANSI(const std::string& str, std::string* outStr);
|
||||
UI_EXPORT void UTF8ToUnicode(const std::string& str, std::wstring* outStr);
|
||||
//
|
||||
UI_EXPORT void Tolower(std::string* str_in_out);
|
||||
UI_EXPORT void Toupper(std::string* str_in_out);
|
||||
UI_EXPORT void Erase(std::string* str_in_out, char ch);
|
||||
UI_EXPORT void Replace(std::string* str_in_out, char oldChar, char newChar);
|
||||
UI_EXPORT size_t Replace(std::string* str_in_out, const std::string& oldText, const std::string& newText, bool replaceAll = true);
|
||||
UI_EXPORT void Split(const std::string& str_in, const std::string& ch, std::vector<std::string>* strs_out);
|
||||
//
|
||||
UI_EXPORT String ToString(double number, size_t keepBitSize);
|
||||
//-----------------------------------------------Copy End-----------------------------------------------
|
||||
};
|
||||
using UIString = ui_text::String;
|
||||
};
|
||||
18
demo/Adminstor/ThirdParty/EzUI/include/EzUI/VLayout.h
vendored
Normal file
18
demo/Adminstor/ThirdParty/EzUI/include/EzUI/VLayout.h
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT VLayout :
|
||||
public Control
|
||||
{
|
||||
public:
|
||||
HAlign ContentAlign = HAlign::Center;
|
||||
protected:
|
||||
virtual void OnLayout() override;
|
||||
public:
|
||||
VLayout(Object* parentObject = NULL);
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
virtual ~VLayout();
|
||||
};
|
||||
using VBox = VLayout;
|
||||
};
|
||||
22
demo/Adminstor/ThirdParty/EzUI/include/EzUI/VListView.h
vendored
Normal file
22
demo/Adminstor/ThirdParty/EzUI/include/EzUI/VListView.h
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "PagedListView.h"
|
||||
#include "VScrollBar.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT VListView :
|
||||
public PagedListView
|
||||
{
|
||||
private:
|
||||
VScrollBar m_vScrollBar;
|
||||
void Init();
|
||||
//对控件进行偏移
|
||||
void Offset(int offset);
|
||||
protected:
|
||||
virtual void OnLayout()override;
|
||||
virtual void OnChildPaint(PaintEventArgs& args)override;
|
||||
public:
|
||||
VListView(Object* parentObject = NULL);
|
||||
virtual ~VListView();
|
||||
virtual ScrollBar* GetScrollBar() override;
|
||||
};
|
||||
};
|
||||
22
demo/Adminstor/ThirdParty/EzUI/include/EzUI/VScrollBar.h
vendored
Normal file
22
demo/Adminstor/ThirdParty/EzUI/include/EzUI/VScrollBar.h
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
#include "ScrollBar.h"
|
||||
|
||||
namespace ezui {
|
||||
|
||||
class UI_EXPORT VScrollBar :
|
||||
public ScrollBar
|
||||
{
|
||||
protected:
|
||||
virtual void OnMouseDown(const MouseEventArgs& arg)override;
|
||||
virtual void OnMouseMove(const MouseEventArgs& arg)override;
|
||||
virtual void GetInfo(int* viewLength, int* contentLength, int* scrollBarLength)override;
|
||||
public:
|
||||
VScrollBar(Object* parentObject = NULL);
|
||||
virtual ~VScrollBar();
|
||||
virtual void ScrollTo(Control* ctl)override;
|
||||
virtual void ParentSize(const Size& size)override;
|
||||
virtual Rect GetSliderRect()override;
|
||||
};
|
||||
|
||||
};
|
||||
267
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Window.h
vendored
Normal file
267
demo/Adminstor/ThirdParty/EzUI/include/EzUI/Window.h
vendored
Normal file
@@ -0,0 +1,267 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
#include "ScrollBar.h"
|
||||
#include "Spacer.h"
|
||||
|
||||
#undef IsMinimized
|
||||
#undef IsMaximized
|
||||
#undef IsRestored
|
||||
|
||||
namespace ezui {
|
||||
/// <summary>
|
||||
/// Window //经典带边框带系统菜单WIN32窗口样式
|
||||
/// </summary>
|
||||
class UI_EXPORT Window :public Object
|
||||
{
|
||||
private:
|
||||
//具有鼠标焦点的控件
|
||||
Control* m_focusControl = NULL;
|
||||
//具有键盘焦点的控件
|
||||
Control* m_inputControl = NULL;
|
||||
//窗口公共数据
|
||||
WindowData* m_publicData = NULL;
|
||||
//窗口句柄
|
||||
HWND m_hWnd = NULL;
|
||||
//鼠标跟踪
|
||||
bool m_bTracking = false;
|
||||
//鼠标是否在里面
|
||||
bool m_mouseIn = false;
|
||||
//鼠标是否已经按下
|
||||
bool m_mouseDown = false;
|
||||
//窗口移动
|
||||
bool m_moveWindow = false;
|
||||
//记录鼠标坐标
|
||||
POINT m_dragPoint;
|
||||
//记录鼠标按下的坐标
|
||||
Point m_downPoint;
|
||||
//上一次鼠标按下的时间
|
||||
ULONGLONG m_lastDownTime = 0;
|
||||
//上一次鼠标按下的按钮
|
||||
MouseButton m_lastBtn = MouseButton::None;
|
||||
//窗口最小尺寸
|
||||
Size m_miniSize;
|
||||
//窗口最大尺寸
|
||||
Size m_maxSize;
|
||||
//当窗口关闭的时候退出代码
|
||||
int m_closeCode = 0;
|
||||
//基于桌面的坐标
|
||||
Rect m_rect;
|
||||
//客户绘图区域
|
||||
Rect m_rectClient;
|
||||
//所属窗口句柄
|
||||
HWND m_ownerWnd = NULL;
|
||||
//窗口根Frame
|
||||
IFrame* m_frame = NULL;
|
||||
// 管理图片的释放
|
||||
PtrManager<Image*> m_imgs;
|
||||
public:
|
||||
//对外暴露消息通知回调
|
||||
std::function<void(Control*, EventArgs&)> NotifyHandler = NULL;
|
||||
private:
|
||||
Window(const Window&) = delete;
|
||||
Window& operator=(const Window&) = delete;
|
||||
bool IsInWindow(Control& pControl, Control& it);
|
||||
void Init(int width, int height, HWND owner, DWORD dStyle, DWORD dwExStyle);//初始窗口
|
||||
//仅移动窗口
|
||||
void MoveWindow();
|
||||
//鼠标按下以标题栏方式移动窗口
|
||||
void TitleMoveWindow();
|
||||
//在窗口中使用基于客户区的鼠标位置寻找可命中的控件
|
||||
Control* HitTestControl(const Point& clientPoint, Point* outPoint);
|
||||
//派发事件
|
||||
void SendEvent(Control* ctrl, const EventArgs& args);
|
||||
protected:
|
||||
//当dpi发生更改时
|
||||
virtual void OnDpiChange(float systemScale, const Rect& newRect);
|
||||
//鼠标移动时发生
|
||||
virtual void OnMouseMove(const Point& point);
|
||||
//当鼠标悬停时发生
|
||||
virtual void OnMouseHover(const Point& point);
|
||||
//鼠标离开时发生
|
||||
virtual void OnMouseLeave();
|
||||
//鼠标滚动发生
|
||||
virtual void OnMouseWheel(int zDelta, const Point& point);
|
||||
//鼠标双击是发生
|
||||
virtual void OnMouseDoubleClick(MouseButton mbtn, const Point& point);
|
||||
//鼠标按下时发生
|
||||
virtual void OnMouseDown(MouseButton mbtn, const Point& point);
|
||||
//鼠标弹起时发生
|
||||
virtual void OnMouseUp(MouseButton mbtn, const Point& point);
|
||||
//生成渲染器 渲染参数
|
||||
virtual void DoPaint(HDC winDC, const Rect& rePaint);
|
||||
//渲染中
|
||||
virtual void OnPaint(PaintEventArgs& arg);
|
||||
//位置发生改变时发生
|
||||
virtual void OnMove(const Point& point);
|
||||
//大小发生改变时发生
|
||||
virtual void OnSize(const Size& sz);
|
||||
//当窗口收到WM_CLOSE消息时发生
|
||||
virtual void OnClose(bool& bClose);
|
||||
//当窗口销毁时发生
|
||||
virtual void OnDestroy();
|
||||
//字符消息
|
||||
virtual void OnKeyChar(WPARAM wParam, LPARAM lParam);
|
||||
//键盘按下
|
||||
virtual void OnKeyDown(WPARAM wParam, LPARAM lParam);
|
||||
//键盘抬起
|
||||
virtual void OnKeyUp(WPARAM wParam, LPARAM lParam);
|
||||
//获得输入焦点时发生
|
||||
virtual void OnFocus(HWND hWnd);
|
||||
//失去输入焦点时发生
|
||||
virtual void OnKillFocus(HWND hWnd);
|
||||
//鼠标 键盘 重绘 会进入此函数,如果返回true则事件将不再交给sender控件处理 将忽略类似OnMouseDown... Notiify事件处理器...
|
||||
virtual void OnNotify(Control* sender, EventArgs& args);
|
||||
//处理消息队列的
|
||||
virtual LRESULT WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
//获取阴影窗口句柄
|
||||
virtual HWND GetShadowHwnd();
|
||||
public:
|
||||
Window(int width, int height, HWND owner = NULL, DWORD dStyle = WS_OVERLAPPEDWINDOW, DWORD dwExStyle = NULL);
|
||||
|
||||
virtual ~Window();
|
||||
|
||||
//使用id寻找控件
|
||||
Control* FindControl(const UIString& objectName);
|
||||
|
||||
//获取公共数据
|
||||
WindowData* GetPublicData();
|
||||
|
||||
//窗口句柄
|
||||
HWND Hwnd();
|
||||
|
||||
//获取窗口X坐标
|
||||
int X();
|
||||
|
||||
//获取窗口Y坐标
|
||||
int Y();
|
||||
|
||||
// 获取窗口宽度
|
||||
int Width();
|
||||
|
||||
// 获取窗口高度
|
||||
int Height();
|
||||
|
||||
//获取窗口基于显示器的矩形
|
||||
const Rect& GetWindowRect();
|
||||
|
||||
//获取客户区矩形
|
||||
const Rect& GetClientRect();
|
||||
|
||||
//获取当前窗口dpi缩放系数
|
||||
float GetScale();
|
||||
|
||||
//设置窗口size
|
||||
void SetSize(const Size& size);
|
||||
|
||||
//设置窗口位置
|
||||
void SetLocation(const Point& pt);
|
||||
|
||||
//设置窗口位置大小
|
||||
void SetRect(const Rect& rect);
|
||||
|
||||
//设置窗口最小size
|
||||
void SetMiniSize(const Size& size);
|
||||
|
||||
//设置窗口最大size
|
||||
void SetMaxSize(const Size& size);
|
||||
|
||||
//设置绝对宽高
|
||||
void SetFixedSize(const Size& size);
|
||||
|
||||
//设置窗口icon
|
||||
void SetIcon(HICON icon);
|
||||
|
||||
//设置窗口主布局
|
||||
void SetLayout(ezui::Control* layout);
|
||||
|
||||
//从文件中加载布局
|
||||
void LoadXml(const UIString& fileName);
|
||||
|
||||
//从内存加载布局
|
||||
void LoadXml(const char* fileData, size_t fileSize);
|
||||
|
||||
//获取窗口主布局
|
||||
Control* GetLayout();
|
||||
|
||||
//设置窗口标题
|
||||
void SetText(const UIString& text);
|
||||
|
||||
//获取窗口标题
|
||||
UIString GetText();
|
||||
|
||||
//设置与取消窗口置顶
|
||||
void SetTopMost(bool top);
|
||||
|
||||
//是否全屏
|
||||
bool IsFullScreen();
|
||||
|
||||
//是否最小化
|
||||
bool IsMinimized();
|
||||
|
||||
//窗口是否最大化
|
||||
bool IsMaximized();
|
||||
|
||||
//窗口是否置顶
|
||||
bool IsTopMost();
|
||||
|
||||
//操作窗口的显示
|
||||
virtual void Show();
|
||||
|
||||
//操作窗口的显示 带参数
|
||||
void Show(int cmdShow);
|
||||
|
||||
//隐藏窗口
|
||||
virtual void Hide();
|
||||
|
||||
//正常显示窗口
|
||||
void ShowNormal();
|
||||
|
||||
//关闭窗口 exitCode为退出代码
|
||||
void Close(int exitCode = 0);
|
||||
|
||||
//模态窗口方式显示窗口(会阻塞) 请务必在窗口构造函数中传入owner窗口句柄
|
||||
virtual int ShowModal(bool disableOnwer = true);
|
||||
|
||||
//最小化窗口
|
||||
void ShowMinimized();
|
||||
|
||||
//最大化窗口
|
||||
void ShowMaximized();
|
||||
|
||||
//让窗口占满当前屏幕
|
||||
void ShowFullScreen();
|
||||
|
||||
//窗口是否显示
|
||||
bool IsVisible();
|
||||
|
||||
//设置窗口显示/隐藏
|
||||
void SetVisible(bool flag);
|
||||
|
||||
//使区域无效(延迟刷新)
|
||||
void Invalidate();
|
||||
|
||||
//立即更新所有无效区域(立即刷新)
|
||||
void Refresh();
|
||||
|
||||
//居中到屏幕
|
||||
void CenterToScreen();
|
||||
|
||||
//参考某个窗口进行居中
|
||||
void CenterToWindow(HWND wnd = NULL);
|
||||
|
||||
//给指定控件为焦点控件
|
||||
void SetFocus(Control* ctl);
|
||||
|
||||
//绑定对象(跟随释放)
|
||||
using Object::Attach;
|
||||
|
||||
//分离对象(解除跟随释放)
|
||||
using Object::Detach;
|
||||
|
||||
//绑定图片(跟随释放)
|
||||
Image* Attach(Image* img);
|
||||
|
||||
//分离图片(解除跟随释放)
|
||||
void Detach(Image* img);
|
||||
};
|
||||
};
|
||||
303
demo/Adminstor/ThirdParty/EzUI/include/EzUI/tinystr.h
vendored
Normal file
303
demo/Adminstor/ThirdParty/EzUI/include/EzUI/tinystr.h
vendored
Normal file
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#ifndef TIXML_USE_STL
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
/* The support for explicit isn't that universal, and it isn't really
|
||||
required - it is used to check that the TiXmlString class isn't incorrectly
|
||||
used. Be nice to old compilers and macro it here:
|
||||
*/
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200 )
|
||||
// Microsoft visual studio, version 6 and higher.
|
||||
#define TIXML_EXPLICIT explicit
|
||||
#elif defined(__GNUC__) && (__GNUC__ >= 3 )
|
||||
// GCC version 3 and higher.s
|
||||
#define TIXML_EXPLICIT explicit
|
||||
#else
|
||||
#define TIXML_EXPLICIT
|
||||
#endif
|
||||
|
||||
|
||||
namespace ezui {
|
||||
|
||||
/*
|
||||
TiXmlString is an emulation of a subset of the std::string template.
|
||||
Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.
|
||||
Only the member functions relevant to the TinyXML project have been implemented.
|
||||
The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
|
||||
a string and there's no more room, we allocate a buffer twice as big as we need.
|
||||
*/
|
||||
class TiXmlString
|
||||
{
|
||||
public:
|
||||
// The size type used
|
||||
typedef size_t size_type;
|
||||
|
||||
// Error value for find primitive
|
||||
static const size_type npos; // = -1;
|
||||
|
||||
|
||||
// TiXmlString empty constructor
|
||||
TiXmlString() : rep_(&nullrep_)
|
||||
{
|
||||
}
|
||||
|
||||
// TiXmlString copy constructor
|
||||
TiXmlString(const TiXmlString& copy) : rep_(0)
|
||||
{
|
||||
init(copy.length());
|
||||
memcpy(start(), copy.data(), length());
|
||||
}
|
||||
|
||||
// TiXmlString constructor, based on a string
|
||||
TIXML_EXPLICIT TiXmlString(const char* copy) : rep_(0)
|
||||
{
|
||||
init(static_cast<size_type>(strlen(copy)));
|
||||
memcpy(start(), copy, length());
|
||||
}
|
||||
|
||||
// TiXmlString constructor, based on a string
|
||||
TIXML_EXPLICIT TiXmlString(const char* str, size_type len) : rep_(0)
|
||||
{
|
||||
init(len);
|
||||
memcpy(start(), str, len);
|
||||
}
|
||||
|
||||
// TiXmlString destructor
|
||||
~TiXmlString()
|
||||
{
|
||||
quit();
|
||||
}
|
||||
|
||||
TiXmlString& operator = (const char* copy)
|
||||
{
|
||||
return assign(copy, (size_type)strlen(copy));
|
||||
}
|
||||
|
||||
TiXmlString& operator = (const TiXmlString& copy)
|
||||
{
|
||||
return assign(copy.start(), copy.length());
|
||||
}
|
||||
|
||||
|
||||
// += operator. Maps to append
|
||||
TiXmlString& operator += (const char* suffix)
|
||||
{
|
||||
return append(suffix, static_cast<size_type>(strlen(suffix)));
|
||||
}
|
||||
|
||||
// += operator. Maps to append
|
||||
TiXmlString& operator += (char single)
|
||||
{
|
||||
return append(&single, 1);
|
||||
}
|
||||
|
||||
// += operator. Maps to append
|
||||
TiXmlString& operator += (const TiXmlString& suffix)
|
||||
{
|
||||
return append(suffix.data(), suffix.length());
|
||||
}
|
||||
|
||||
|
||||
// Convert a TiXmlString into a null-terminated char *
|
||||
const char* c_str() const { return rep_->str; }
|
||||
|
||||
// Convert a TiXmlString into a char * (need not be null terminated).
|
||||
const char* data() const { return rep_->str; }
|
||||
|
||||
// Return the length of a TiXmlString
|
||||
size_type length() const { return rep_->size; }
|
||||
|
||||
// Alias for length()
|
||||
size_type size() const { return rep_->size; }
|
||||
|
||||
// Checks if a TiXmlString is empty
|
||||
bool empty() const { return rep_->size == 0; }
|
||||
|
||||
// Return capacity of string
|
||||
size_type capacity() const { return rep_->capacity; }
|
||||
|
||||
|
||||
// single char extraction
|
||||
const char& at(size_type index) const
|
||||
{
|
||||
assert(index < length());
|
||||
return rep_->str[index];
|
||||
}
|
||||
|
||||
// [] operator
|
||||
char& operator [] (size_type index) const
|
||||
{
|
||||
assert(index < length());
|
||||
return rep_->str[index];
|
||||
}
|
||||
|
||||
// find a char in a string. Return TiXmlString::npos if not found
|
||||
size_type find(char lookup) const
|
||||
{
|
||||
return find(lookup, 0);
|
||||
}
|
||||
|
||||
// find a char in a string from an offset. Return TiXmlString::npos if not found
|
||||
size_type find(char tofind, size_type offset) const
|
||||
{
|
||||
if (offset >= length()) return npos;
|
||||
|
||||
for (const char* p = c_str() + offset; *p != '\0'; ++p)
|
||||
{
|
||||
if (*p == tofind) return static_cast<size_type>(p - c_str());
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
//Lee:
|
||||
//The original was just too strange, though correct:
|
||||
// TiXmlString().swap(*this);
|
||||
//Instead use the quit & re-init:
|
||||
quit();
|
||||
init(0, 0);
|
||||
}
|
||||
|
||||
/* Function to reserve a big amount of data when we know we'll need it. Be aware that this
|
||||
function DOES NOT clear the content of the TiXmlString if any exists.
|
||||
*/
|
||||
void reserve(size_type cap);
|
||||
|
||||
TiXmlString& assign(const char* str, size_type len);
|
||||
|
||||
TiXmlString& append(const char* str, size_type len);
|
||||
|
||||
void swap(TiXmlString& other)
|
||||
{
|
||||
Rep* r = rep_;
|
||||
rep_ = other.rep_;
|
||||
other.rep_ = r;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void init(size_type sz) { init(sz, sz); }
|
||||
void set_size(size_type sz) { rep_->str[rep_->size = sz] = '\0'; }
|
||||
char* start() const { return rep_->str; }
|
||||
char* finish() const { return rep_->str + rep_->size; }
|
||||
|
||||
struct Rep
|
||||
{
|
||||
size_type size, capacity;
|
||||
char str[1];
|
||||
};
|
||||
|
||||
void init(size_type sz, size_type cap)
|
||||
{
|
||||
if (cap)
|
||||
{
|
||||
// Lee: the original form:
|
||||
// rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));
|
||||
// doesn't work in some cases of new being overloaded. Switching
|
||||
// to the normal allocation, although use an 'int' for systems
|
||||
// that are overly picky about structure alignment.
|
||||
const size_type bytesNeeded = sizeof(Rep) + cap;
|
||||
const size_type intsNeeded = (bytesNeeded + sizeof(int) - 1) / sizeof(int);
|
||||
rep_ = reinterpret_cast<Rep*>(new int[intsNeeded]);
|
||||
|
||||
rep_->str[rep_->size = sz] = '\0';
|
||||
rep_->capacity = cap;
|
||||
}
|
||||
else
|
||||
{
|
||||
rep_ = &nullrep_;
|
||||
}
|
||||
}
|
||||
|
||||
void quit()
|
||||
{
|
||||
if (rep_ != &nullrep_)
|
||||
{
|
||||
// The rep_ is really an array of ints. (see the allocator, above).
|
||||
// Cast it back before delete, so the compiler won't incorrectly call destructors.
|
||||
delete[](reinterpret_cast<int*>(rep_));
|
||||
}
|
||||
}
|
||||
|
||||
Rep* rep_;
|
||||
static Rep nullrep_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline bool operator == (const TiXmlString& a, const TiXmlString& b)
|
||||
{
|
||||
return (a.length() == b.length()) // optimization on some platforms
|
||||
&& (strcmp(a.c_str(), b.c_str()) == 0); // actual compare
|
||||
}
|
||||
inline bool operator < (const TiXmlString& a, const TiXmlString& b)
|
||||
{
|
||||
return strcmp(a.c_str(), b.c_str()) < 0;
|
||||
}
|
||||
|
||||
inline bool operator != (const TiXmlString& a, const TiXmlString& b) { return !(a == b); }
|
||||
inline bool operator > (const TiXmlString& a, const TiXmlString& b) { return b < a; }
|
||||
inline bool operator <= (const TiXmlString& a, const TiXmlString& b) { return !(b < a); }
|
||||
inline bool operator >= (const TiXmlString& a, const TiXmlString& b) { return !(a < b); }
|
||||
|
||||
inline bool operator == (const TiXmlString& a, const char* b) { return strcmp(a.c_str(), b) == 0; }
|
||||
inline bool operator == (const char* a, const TiXmlString& b) { return b == a; }
|
||||
inline bool operator != (const TiXmlString& a, const char* b) { return !(a == b); }
|
||||
inline bool operator != (const char* a, const TiXmlString& b) { return !(b == a); }
|
||||
|
||||
TiXmlString operator + (const TiXmlString& a, const TiXmlString& b);
|
||||
TiXmlString operator + (const TiXmlString& a, const char* b);
|
||||
TiXmlString operator + (const char* a, const TiXmlString& b);
|
||||
|
||||
|
||||
/*
|
||||
TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.
|
||||
Only the operators that we need for TinyXML have been developped.
|
||||
*/
|
||||
class TiXmlOutStream : public TiXmlString
|
||||
{
|
||||
public:
|
||||
|
||||
// TiXmlOutStream << operator.
|
||||
TiXmlOutStream& operator << (const TiXmlString& in)
|
||||
{
|
||||
*this += in;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// TiXmlOutStream << operator.
|
||||
TiXmlOutStream& operator << (const char* in)
|
||||
{
|
||||
*this += in;
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
#endif // TIXML_USE_STL
|
||||
1806
demo/Adminstor/ThirdParty/EzUI/include/EzUI/tinyxml.h
vendored
Normal file
1806
demo/Adminstor/ThirdParty/EzUI/include/EzUI/tinyxml.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_Win32.lib
vendored
Normal file
BIN
demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_Win32.lib
vendored
Normal file
Binary file not shown.
BIN
demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_Win32.pdb
vendored
Normal file
BIN
demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_Win32.pdb
vendored
Normal file
Binary file not shown.
BIN
demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_x64.lib
vendored
Normal file
BIN
demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_x64.lib
vendored
Normal file
Binary file not shown.
BIN
demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_x64.pdb
vendored
Normal file
BIN
demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Debug_x64.pdb
vendored
Normal file
Binary file not shown.
BIN
demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Release_Win32.lib
vendored
Normal file
BIN
demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Release_Win32.lib
vendored
Normal file
Binary file not shown.
BIN
demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Release_x64.lib
vendored
Normal file
BIN
demo/Adminstor/ThirdParty/EzUI/lib/EzUI_Release_x64.lib
vendored
Normal file
Binary file not shown.
33
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Animation.h
vendored
Normal file
33
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Animation.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include "EzUI.h"
|
||||
#include "Timer.h"
|
||||
|
||||
namespace ezui {
|
||||
|
||||
class UI_EXPORT Animation : public Object {
|
||||
private:
|
||||
TimerClock m_timer;
|
||||
float m_startValue = 0;
|
||||
float m_endValue = 0;
|
||||
float m_currValue = 0;
|
||||
std::atomic<bool> m_tickPending = false;
|
||||
std::shared_ptr<std::atomic<bool>> m_alive;
|
||||
bool m_finished = true;
|
||||
float m_damping = 1.0f;
|
||||
public:
|
||||
//当值更改的时候发生的事件(请绑定此函数进行回调,已处理线程同步)
|
||||
std::function<void(float)> ValueChanged;
|
||||
Animation(Object* ownerObject = NULL);
|
||||
virtual ~Animation();
|
||||
void SetStartValue(float value);
|
||||
void SetEndValue(float value);
|
||||
//开始动画
|
||||
void Start(int durationMs, int fps = 90);
|
||||
//动画是否已经停止(判断的是计时器状态)
|
||||
bool IsStopped()const;
|
||||
//动画是否已跑完(判断起始值和结束值)
|
||||
bool IsFinished()const;
|
||||
void Stop();
|
||||
};
|
||||
|
||||
};
|
||||
24
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Application.h
vendored
Normal file
24
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Application.h
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "Window.h"
|
||||
#include "Resource.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT Application
|
||||
{
|
||||
public:
|
||||
//退出消息循环
|
||||
static void Exit(int exitCode = 0);
|
||||
//获取程序启动路径
|
||||
static UIString StartPath();
|
||||
public:
|
||||
Application(HINSTANCE hInstance = NULL);
|
||||
//使用本地文件名称或者资源中的名称加载资源包
|
||||
//填入vs中的资源ID名称 或者 本地文件名 一个Application只允许有一个资源文件
|
||||
bool SetResource(const UIString& localOrResName);
|
||||
//启用高DPI适配
|
||||
void EnableHighDpi();
|
||||
virtual ~Application();
|
||||
//执行消息循环
|
||||
int Exec();
|
||||
};
|
||||
};
|
||||
34
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Bitmap.h
vendored
Normal file
34
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Bitmap.h
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include "EzUI.h"
|
||||
|
||||
namespace ezui {
|
||||
//BGRA 32位图
|
||||
class UI_EXPORT Bitmap {
|
||||
private:
|
||||
int m_width = 0;
|
||||
int m_height = 0;
|
||||
HBITMAP m_bmp = NULL;
|
||||
HDC m_hdc = NULL;
|
||||
uint8_t* m_point = NULL;
|
||||
BITMAPINFO m_bmpInfo;
|
||||
Bitmap(const Bitmap& hBitmap) = delete;
|
||||
void operator=(const Bitmap& hBitmap) = delete;
|
||||
protected:
|
||||
void Create(int width, int height);
|
||||
public:
|
||||
int Width()const;
|
||||
int Height()const;
|
||||
//BGRA 32位图
|
||||
Bitmap(int width, int height);
|
||||
Bitmap(HDC dc, const Rect& rect);
|
||||
void SetPixel(int x, int y, const Color& color);
|
||||
Color GetPixel(int x, int y)const;
|
||||
uint8_t* GetPixel();
|
||||
void Earse(const Rect& rect);//抹除矩形内容
|
||||
HBITMAP GetHBITMAP();
|
||||
HDC GetDC();
|
||||
bool Save(const UIString& fileName);
|
||||
Bitmap* Clone()const;
|
||||
virtual ~Bitmap();
|
||||
};
|
||||
};
|
||||
41
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/BorderlessWindow.h
vendored
Normal file
41
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/BorderlessWindow.h
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
#include "Window.h"
|
||||
#include "ShadowBox.h"
|
||||
|
||||
namespace ezui {
|
||||
/// <summary>
|
||||
/// BorderlessWindow //无边框 带阴影
|
||||
/// </summary>
|
||||
class UI_EXPORT BorderlessWindow :public Window {
|
||||
private:
|
||||
int m_shadowWeight = 20;
|
||||
ShadowBox* m_shadowBox = NULL;
|
||||
float m_shadowScale = 1.0f;
|
||||
//是否支持缩放
|
||||
bool m_bResize = false;
|
||||
//是否第一次已经绘制
|
||||
bool isFirstPaint = false;
|
||||
protected:
|
||||
virtual LRESULT WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)override;
|
||||
virtual void DoPaint(HDC winDC, const Rect& rePaint)override;
|
||||
virtual void OnMove(const Point& location) override;
|
||||
virtual void OnSize(const Size& sz) override;
|
||||
virtual void OnDpiChange(float systemScale, const Rect& newRect);//当dpi发生更改时
|
||||
virtual HWND GetShadowHwnd()override;//获取阴影窗口句柄
|
||||
public:
|
||||
//设置阴影宽度
|
||||
void SetShadow(int weight);
|
||||
BorderlessWindow(int width, int height, HWND owner = NULL, DWORD dwStyle = NULL, DWORD dwExStyle = NULL);
|
||||
virtual ~BorderlessWindow();
|
||||
//更新窗口阴影
|
||||
void UpdateShadowBox();
|
||||
//获取阴影窗口
|
||||
ShadowBox* GetShadowBox();
|
||||
//关闭窗口阴影 关掉阴影窗口 已有的边框也会随之消失
|
||||
void CloseShadowBox();
|
||||
//设置窗口缩放支持
|
||||
void SetResizable(bool resize);
|
||||
//是否支持调整大小
|
||||
bool IsResizable();
|
||||
};
|
||||
};
|
||||
14
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Button.h
vendored
Normal file
14
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Button.h
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "Label.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT Button :
|
||||
public Label
|
||||
{
|
||||
private:
|
||||
void Init();
|
||||
public:
|
||||
Button(Object* ownerObject = NULL);
|
||||
virtual ~Button();
|
||||
};
|
||||
};
|
||||
30
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/CheckBox.h
vendored
Normal file
30
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/CheckBox.h
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include "Label.h"
|
||||
|
||||
namespace ezui {
|
||||
|
||||
class UI_EXPORT CheckBox :
|
||||
public Label
|
||||
{
|
||||
private:
|
||||
bool m_checked = false;
|
||||
public:
|
||||
//选中样式
|
||||
ControlStyle CheckedStyle;
|
||||
//选中状态发送变化的回调函数
|
||||
std::function<void(CheckBox* sender, bool checked)> CheckedChanged = NULL;
|
||||
protected:
|
||||
virtual ControlStyle& GetStyle(const ControlState& _state)override;
|
||||
virtual void OnMouseDown(const MouseEventArgs& arg)override;
|
||||
virtual void OnDpiChange(const DpiChangeEventArgs& args)override;
|
||||
public:
|
||||
CheckBox(Object* ownerObject = NULL);
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
//设置选中状态
|
||||
virtual void SetCheck(bool checked);
|
||||
//获取选中状态
|
||||
virtual bool GetCheck();
|
||||
virtual ~CheckBox();
|
||||
};
|
||||
|
||||
};
|
||||
53
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/ComboBox.h
vendored
Normal file
53
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/ComboBox.h
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
#include "TextBox.h"
|
||||
#include "Label.h"
|
||||
#include "VListView.h"
|
||||
#include "PopupWindow.h"
|
||||
#include "HLayout.h"
|
||||
|
||||
namespace ezui {
|
||||
//简易的下拉列表框
|
||||
class UI_EXPORT ComboBox :public HLayout {
|
||||
private:
|
||||
//添加选项请使用AddItem
|
||||
virtual Control* AddChild(Control* childCtl)override;
|
||||
//移除选项请使用RemoveItem
|
||||
virtual void RemoveChild(Control* childCtl, bool freeCtrl)override;
|
||||
private:
|
||||
//下拉菜单选项
|
||||
class MenuContent :public PopupWindow {
|
||||
public:
|
||||
Control* m_ownerCtrl;
|
||||
Control* m_hittestCtl;
|
||||
MenuContent(Control* ownerCtl, Control* hittestCtl);
|
||||
virtual void OnKillFocus(HWND wnd) override;
|
||||
virtual void Show() override;
|
||||
virtual ~MenuContent();
|
||||
};
|
||||
private:
|
||||
//下拉菜单窗口
|
||||
MenuContent* m_menuWnd = NULL;
|
||||
//选择之后显示的文本框
|
||||
TextBox m_textBox;
|
||||
//展开菜单的按钮
|
||||
Label m_UpDown;
|
||||
|
||||
VListView m_list;
|
||||
int m_index = -1;
|
||||
void Init();
|
||||
protected:
|
||||
virtual void OnLayout()override;
|
||||
public:
|
||||
ComboBox(Object* ownerObject = NULL);
|
||||
//获取选中的文字
|
||||
UIString GetText();
|
||||
//获取选中的下标
|
||||
int GetCheck();
|
||||
//选中某个下标
|
||||
bool SetCheck(int pos);
|
||||
virtual ~ComboBox();
|
||||
//添加一个item并返回新item的下标
|
||||
int AddItem(const UIString& text);
|
||||
void RemoveItem(int index);
|
||||
};
|
||||
};
|
||||
659
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Control.h
vendored
Normal file
659
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Control.h
vendored
Normal file
@@ -0,0 +1,659 @@
|
||||
#pragma once
|
||||
#include "EzUI.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT Control :public Object
|
||||
{
|
||||
friend class HListView;
|
||||
friend class VListView;
|
||||
friend class TabLayout;
|
||||
friend class TileListView;
|
||||
friend class TextBox;
|
||||
friend class UILoader;
|
||||
friend class Frame;
|
||||
friend class CheckBox;
|
||||
friend class Window;
|
||||
friend class ScrollBar;
|
||||
friend class VLayout;
|
||||
friend class HLayout;
|
||||
private:
|
||||
//顶层窗口句柄
|
||||
HWND m_hWnd = NULL;
|
||||
|
||||
// 控件是否已经被移除或释放
|
||||
bool* m_bRemove = NULL;
|
||||
|
||||
//控件是否被为按住状态
|
||||
bool m_pressed = false;
|
||||
|
||||
// 控件是否可见。此标志为 true 时,控件为显示状态
|
||||
bool m_bVisible = true;
|
||||
|
||||
//控件是否浮动
|
||||
bool m_float = false;
|
||||
|
||||
// 当前控件的 DPI 缩放比例
|
||||
float m_scale = 1.0f;
|
||||
|
||||
// 子控件集合
|
||||
ControlCollection m_controls;
|
||||
|
||||
// 管理图片的释放
|
||||
PtrManager<Image*> m_imgs;
|
||||
|
||||
// 布局状态
|
||||
// AddControl、InsertControl、RemoveControl、OnSize 时此标志为挂起状态
|
||||
// 调用 ResumeLayout 标志为布局中
|
||||
// 调用 OnLayout() 之后标志为 None
|
||||
ezui::LayoutState m_layoutState = ezui::LayoutState::None;
|
||||
|
||||
// 鼠标悬浮提示文字
|
||||
UIString m_tipsText;
|
||||
|
||||
// 上一次位置
|
||||
Point m_lastLocation;
|
||||
|
||||
// 上一次大小
|
||||
Size m_lastSize;
|
||||
|
||||
// 是否根据内容自动宽度
|
||||
bool m_bAutoWidth = false;
|
||||
|
||||
// 根据内容自动高度变化
|
||||
bool m_bAutoHeight = false;
|
||||
|
||||
// 控件内容宽高
|
||||
Size m_contentSize;
|
||||
|
||||
// 绝对尺寸
|
||||
Size m_fixedSize;
|
||||
|
||||
//比例尺寸
|
||||
SizeF m_rateSize;
|
||||
|
||||
//最小宽高
|
||||
Size m_minSize;
|
||||
|
||||
//最大宽高
|
||||
Size m_maxSize;
|
||||
|
||||
//基于父控件矩形区域
|
||||
Rect m_realRect;
|
||||
|
||||
//基于客户端的矩形区域
|
||||
Rect m_rectInClient;
|
||||
|
||||
//基于窗口剪裁过的区域
|
||||
Rect m_viewClipRect;
|
||||
|
||||
// 控件是否可以被命中(值为false情况下就是穿透效果)
|
||||
bool m_hitTestEnabled = true;
|
||||
|
||||
//存储的样式集合
|
||||
std::list<ezui::Style> m_styles;
|
||||
|
||||
// 基于控件中的可见控件集合
|
||||
ControlCollection m_viewControls;
|
||||
|
||||
// 父控件指针
|
||||
Control* m_parent = NULL;
|
||||
|
||||
// 控件当前状态
|
||||
ControlState m_state = ControlState::Static;
|
||||
|
||||
// 外边距
|
||||
// 当父控件为布局控件或列表控件时生效(不可为负数)
|
||||
Distance m_margin;
|
||||
public:
|
||||
|
||||
// 控件的 ObjectName ID
|
||||
UIString Name;
|
||||
|
||||
// 控件行为
|
||||
ControlAction Action = ControlAction::None;
|
||||
|
||||
// 静态默认样式
|
||||
ControlStyle Style;
|
||||
|
||||
//具有焦点的时候的样式
|
||||
ControlStyle FocusStyle;
|
||||
|
||||
//禁用状态样式
|
||||
ControlStyle DisabledStyle;
|
||||
|
||||
// 鼠标悬浮样式
|
||||
ControlStyle HoverStyle;
|
||||
|
||||
// 鼠标按下样式
|
||||
ControlStyle ActiveStyle;
|
||||
|
||||
//是否添加到所在窗口/IFrame中的OnNotify函数中
|
||||
Event NotifyFlags = Event::OnMouseEvent | Event::OnKeyBoardEvent;
|
||||
|
||||
// 事件处理器
|
||||
std::function<void(Control*, EventArgs&)> EventHandler = NULL;
|
||||
private:
|
||||
// 禁止拷贝构造
|
||||
Control(const Control&) = delete;
|
||||
|
||||
// 禁止赋值
|
||||
Control& operator=(const Control&) = delete;
|
||||
|
||||
// 计算基于父控件的裁剪区域
|
||||
void ComputeClipRect();
|
||||
|
||||
// 所有事件优先进入此函数(内部处理)
|
||||
void OnEvent(EventArgs& arg);
|
||||
|
||||
//递归子控件给匹配成功的样式应用上
|
||||
void ApplyChildStyles(const std::list<ezui::Style>& styles);
|
||||
|
||||
//向上匹配样式(直到所属的Frame层)
|
||||
void ApplyParentStyles();
|
||||
protected:
|
||||
//属性或者css样式都适用(css样式和属性都可以设置这些,只对静态样式生效)
|
||||
virtual bool ApplyStyleProperty(const UIString& key, const UIString& value);
|
||||
|
||||
/// <summary>
|
||||
/// 为当前控件的指定状态设置单个样式属性
|
||||
/// </summary>
|
||||
/// <param name="style">目标状态样式对象,例如 this->HoverStyle</param>
|
||||
/// <param name="key">样式键名,例如 "font-size"</param>
|
||||
/// <param name="value">样式值,例如 "13px"</param>
|
||||
virtual void SetStyle(ControlStyle& style, const UIString& key, const UIString& value);
|
||||
|
||||
// 设置内容宽度,仅限子类使用
|
||||
virtual void SetContentWidth(int width);
|
||||
|
||||
// 设置内容高度,仅限子类使用
|
||||
virtual void SetContentHeight(int height);
|
||||
|
||||
// 设置内容尺寸,仅限子类使用
|
||||
virtual void SetContentSize(const Size& size);
|
||||
|
||||
// 绘制之前
|
||||
virtual void OnPaintBefore(PaintEventArgs& args);
|
||||
|
||||
// 控件绘制
|
||||
virtual void OnPaint(PaintEventArgs& args);
|
||||
|
||||
// 子控件绘制,可重载此函数优化鼠标操作性能
|
||||
virtual void OnChildPaint(PaintEventArgs& args);
|
||||
|
||||
// 背景绘制
|
||||
virtual void OnBackgroundPaint(PaintEventArgs& painter);
|
||||
|
||||
// 前景绘制
|
||||
virtual void OnForePaint(PaintEventArgs& e);
|
||||
|
||||
// 边框绘制
|
||||
virtual void OnBorderPaint(PaintEventArgs& painter, const Border& border);
|
||||
|
||||
// 坐标发生改变
|
||||
virtual void OnMove(const MoveEventArgs& arg);
|
||||
|
||||
// 大小发生改变
|
||||
virtual void OnSize(const SizeEventArgs& arg);
|
||||
|
||||
// DPI 发生改变
|
||||
virtual void OnDpiChange(const DpiChangeEventArgs& arg);
|
||||
|
||||
// 控件布局逻辑,需重写布局请重写此函数
|
||||
virtual void OnLayout();
|
||||
|
||||
// 鼠标在控件上移动
|
||||
virtual void OnMouseMove(const MouseEventArgs& arg);
|
||||
|
||||
// 鼠标离开控件
|
||||
virtual void OnMouseLeave(const MouseEventArgs& args);
|
||||
|
||||
// 鼠标滚轮事件
|
||||
virtual void OnMouseWheel(const MouseEventArgs& arg);
|
||||
|
||||
// 鼠标按下事件
|
||||
virtual void OnMouseDown(const MouseEventArgs& arg);
|
||||
|
||||
// 鼠标弹起事件
|
||||
virtual void OnMouseUp(const MouseEventArgs& arg);
|
||||
|
||||
// 鼠标双击事件
|
||||
virtual void OnMouseDoubleClick(const MouseEventArgs& arg);
|
||||
|
||||
// 鼠标移入控件
|
||||
virtual void OnMouseEnter(const MouseEventArgs& arg);
|
||||
|
||||
// 鼠标事件统一入口
|
||||
virtual void OnMouseEvent(const MouseEventArgs& args);
|
||||
|
||||
// 键盘事件统一入口
|
||||
virtual void OnKeyBoardEvent(const KeyboardEventArgs& _args);
|
||||
|
||||
// 字符输入事件(WM_CHAR)
|
||||
virtual void OnKeyChar(const KeyboardEventArgs& _args);
|
||||
|
||||
// 键盘按下事件(WM_KEYDOWN)
|
||||
virtual void OnKeyDown(const KeyboardEventArgs& _args);
|
||||
|
||||
// 键盘弹起事件(WM_KEYUP)
|
||||
virtual void OnKeyUp(const KeyboardEventArgs& _args);
|
||||
|
||||
// 获得焦点事件
|
||||
virtual void OnFocus(const FocusEventArgs& _args);
|
||||
|
||||
// 失去焦点事件
|
||||
virtual void OnKillFocus(const KillFocusEventArgs& _args);
|
||||
|
||||
// 被移除时执行的逻辑
|
||||
virtual void OnRemove();
|
||||
|
||||
public:
|
||||
// 获取当前控件状态下的样式信息
|
||||
virtual ControlStyle& GetStyle(const ControlState& _state);
|
||||
|
||||
// 获取左上圆角半径
|
||||
Value<int16_t> GetBorderTopLeftRadius(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取右上圆角半径
|
||||
Value<int16_t> GetBorderTopRightRadius(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取右下圆角半径
|
||||
Value<int16_t> GetBorderBottomRightRadius(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取左下圆角半径
|
||||
Value<int16_t> GetBorderBottomLeftRadius(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取左边框宽度
|
||||
Value<int16_t> GetBorderLeft(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取上边框宽度
|
||||
Value<int16_t> GetBorderTop(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取右边框宽度
|
||||
Value<int16_t> GetBorderRight(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取下边框宽度
|
||||
Value<int16_t> GetBorderBottom(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取边框颜色
|
||||
Value<Color> GetBorderColor(ControlState _state = ControlState::None);
|
||||
|
||||
//获取边框样式
|
||||
Value<StrokeStyle> GetBorderStyle(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取前景图片
|
||||
Value<Image*> GetForeImage(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取背景图片
|
||||
Value<Image*> GetBackImage(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取背景颜色
|
||||
Value<Color> GetBackColor(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取旋转角度
|
||||
Value<float> GetAngle(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取透明度
|
||||
Value<float> GetOpacity(ControlState _state = ControlState::None);
|
||||
|
||||
//获取当前控件的鼠标光标
|
||||
virtual Value<HCURSOR> GetCursor(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取前景颜色
|
||||
Value<Color> GetForeColor(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取字体 Family
|
||||
Value<std::wstring> GetFontFamily(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取字体大小
|
||||
Value<int> GetFontSize(ControlState _state = ControlState::None);
|
||||
|
||||
// 获取字体粗度
|
||||
Value<int> GetFontWeight(ControlState _state = ControlState::None);
|
||||
|
||||
//获取公共数据
|
||||
WindowContext* GetWindowContext();
|
||||
|
||||
//获取上层Frame容器
|
||||
Frame* GetFrame();
|
||||
public:
|
||||
|
||||
// 构造函数 可传入父对象(由父对象自动管理内存)
|
||||
Control(Object* ownerObject = NULL);
|
||||
|
||||
// 析构函数
|
||||
virtual ~Control();
|
||||
|
||||
//绑定对象(跟随释放)
|
||||
using Object::Attach;
|
||||
|
||||
//分离对象(解除跟随释放)
|
||||
using Object::Detach;
|
||||
|
||||
//绑定图片(跟随释放)
|
||||
Image* Attach(Image* img);
|
||||
|
||||
//分离图片(解除跟随释放)
|
||||
void Detach(Image* img);
|
||||
|
||||
//窗口句柄
|
||||
HWND Hwnd();
|
||||
|
||||
//设置窗口句柄
|
||||
void SetHwnd(HWND hWnd);
|
||||
|
||||
// 以下函数请保证在父控件布局已完成的情况下使用,使用 ResumeLayout() 执行布局
|
||||
// 获取 X 坐标
|
||||
int X();
|
||||
|
||||
// 获取 Y 坐标
|
||||
int Y();
|
||||
|
||||
// 获取宽度
|
||||
int Width();
|
||||
|
||||
// 获取高度
|
||||
int Height();
|
||||
|
||||
//计算带有策略的宽度
|
||||
int CalcWidth();
|
||||
|
||||
//计算带有策略的度
|
||||
int CalcHeight();
|
||||
|
||||
// 设置 X 坐标
|
||||
void SetX(int X);
|
||||
|
||||
// 设置 Y 坐标
|
||||
void SetY(int Y);
|
||||
|
||||
// 移动相对于父控件的位置
|
||||
void SetLocation(const Point& pt);
|
||||
|
||||
// 设置控件大小(当重绘控件时不建议多次使用,影响性能,会调用 SetRect 函数)
|
||||
void SetSize(const Size& size);
|
||||
|
||||
// 设置绝对宽高
|
||||
void SetFixedSize(const Size& size);
|
||||
|
||||
// 设置宽度(当重绘控件时不建议多次使用,影响性能,会调用 SetRect 函数)
|
||||
void SetWidth(int width);
|
||||
|
||||
// 设置高度(当重绘控件时不建议多次使用,影响性能,会调用 SetRect 函数)
|
||||
void SetHeight(int height);
|
||||
|
||||
// 设置绝对宽度
|
||||
void SetFixedWidth(int fixedWidth);
|
||||
|
||||
// 设置绝对高度
|
||||
void SetFixedHeight(int fixedHeight);
|
||||
|
||||
//设置基于父控件百分比宽度(0~1.0f)
|
||||
void SetRateWidth(float rateWidth);
|
||||
|
||||
//设置基于父控件百分比高度(0~1.0f)
|
||||
void SetRateHeight(float rateHeight);
|
||||
|
||||
// 设置基于父控件百分比宽高(0.0f~1.0f)
|
||||
void SetRateSize(const SizeF& size);
|
||||
|
||||
// 设置相对父控件矩形,返回实际的 rect
|
||||
const Rect& SetRect(const Rect& rect);
|
||||
|
||||
// 获取绝对宽度
|
||||
int GetFixedWidth();
|
||||
|
||||
// 获取绝对高度
|
||||
int GetFixedHeight();
|
||||
|
||||
// 获取最小宽度
|
||||
int GetMinWidth();
|
||||
|
||||
// 获取最小高度
|
||||
int GetMinHeight();
|
||||
|
||||
// 获取最大宽度
|
||||
int GetMaxWidth();
|
||||
|
||||
// 获取最大高度
|
||||
int GetMaxHeight();
|
||||
|
||||
// 设置最小宽度
|
||||
void SetMinWidth(int w);
|
||||
|
||||
// 设置最小高度
|
||||
void SetMinHeight(int h);
|
||||
|
||||
// 设置最大宽度
|
||||
void SetMaxWidth(int w);
|
||||
|
||||
// 设置最大高度
|
||||
void SetMaxHeight(int h);
|
||||
|
||||
//设置最小size
|
||||
void SetMinSize(const Size& sz);
|
||||
|
||||
//设置最大size
|
||||
void SetMaxSize(const Size& sz);
|
||||
|
||||
// 获取光标位置
|
||||
virtual Rect GetCareRect();
|
||||
|
||||
// 是否自动宽度
|
||||
virtual bool IsAutoWidth();
|
||||
|
||||
// 是否自动高度
|
||||
virtual bool IsAutoHeight();
|
||||
|
||||
// 设置自动宽度
|
||||
virtual void SetAutoWidth(bool flag);
|
||||
|
||||
// 设置自动高度
|
||||
virtual void SetAutoHeight(bool flag);
|
||||
|
||||
// 设置自动大小
|
||||
virtual void SetAutoSize(bool flag);
|
||||
|
||||
// 获取控件内容大小
|
||||
virtual const Size& GetContentSize();
|
||||
|
||||
// 获取控件大小
|
||||
Size GetSize();
|
||||
|
||||
// 获取控件位置
|
||||
Point GetLocation();
|
||||
|
||||
// 获取相对于父控件的矩形(布局计算后)
|
||||
virtual const Rect& GetRect();
|
||||
|
||||
// 获取基于客户端区域的矩形
|
||||
Rect GetRectInClient();
|
||||
|
||||
//获取控件基于屏幕的矩形位置
|
||||
Rect GetRectInScreen();
|
||||
|
||||
//获取控件基于Frame层的矩形位置
|
||||
Rect GetRectInFrame();
|
||||
|
||||
// 获取控件的缩放系数
|
||||
float GetScale();
|
||||
|
||||
// 是否存在挂起的布局
|
||||
bool IsPendLayout();
|
||||
|
||||
// 尝试挂起布局,返回当前布局状态
|
||||
const LayoutState TryPendLayout();
|
||||
|
||||
// 获取当前布局状态
|
||||
const LayoutState GetLayoutState();
|
||||
|
||||
// 结束当前布局(使其立即生效)
|
||||
void EndLayout();
|
||||
|
||||
// 立即强制刷新布局
|
||||
virtual void RefreshLayout();
|
||||
|
||||
// 设置提示文字(类似 tooltip)
|
||||
void SetTips(const UIString& text);
|
||||
|
||||
// 获取提示文字
|
||||
const UIString& GetTips();
|
||||
|
||||
// 获取控件的滚动条对象
|
||||
virtual ScrollBar* GetScrollBar();
|
||||
|
||||
// 派发事件(如鼠标单击事件等...)返回true则事件成功派发 返回false代表派发途中当前控件已被释放
|
||||
void SendEvent(const EventArgs& arg);
|
||||
|
||||
// 设置控件属性
|
||||
virtual void SetAttribute(const UIString& attrName, const UIString& attrValue);
|
||||
|
||||
// 获取当前可见的子控件集合
|
||||
const ControlCollection& GetCachedViewControls();
|
||||
|
||||
//获取父控件
|
||||
Control* GetParent();
|
||||
|
||||
// 获取所有子控件集合
|
||||
const ControlCollection& GetControls();
|
||||
|
||||
// 使用下标获取控件,自动跳过 spacer 类控件
|
||||
Control* GetControl(int pos);
|
||||
|
||||
// 是否包含指定控件(递归遍历所有子控件)
|
||||
bool Contains(Control* ctrl);
|
||||
|
||||
// 获取指定子控件的索引
|
||||
int IndexOf(Control* childCtl);
|
||||
|
||||
// 根据 name 查找控件(包括自身)
|
||||
Control* FindControl(const UIString& ctrlName);
|
||||
|
||||
// 根据属性查找所有匹配控件(包括自身)
|
||||
ControlCollection FindControls(const UIString& attrName, const UIString& attrValue);
|
||||
|
||||
// 根据 name 查找子控件(仅限直接子集)
|
||||
Control* FindChild(const UIString& ctlName);
|
||||
|
||||
// 根据属性查找所有匹配的子控件(仅限直接子集)
|
||||
ControlCollection FindChildren(const UIString& attrName, const UIString& attrValue);
|
||||
|
||||
// 交换两个子控件的位置
|
||||
virtual bool SwapChildren(Control* childCtl, Control* childCt2);
|
||||
|
||||
//是否启用控件
|
||||
void SetEnabled(bool flag);
|
||||
|
||||
//是否禁用控件
|
||||
void SetDisabled(bool flag);
|
||||
|
||||
//控件是否已启用
|
||||
bool IsEnabled();
|
||||
|
||||
// 在指定位置插入子控件
|
||||
virtual Control* InsertChild(int pos, Control* childCtl);
|
||||
|
||||
// 添加控件到末尾(如果是弹簧控件,在释放时将自动销毁)
|
||||
virtual Control* AddChild(Control* childCtrl);
|
||||
|
||||
//解析xml字符串并添加到控件集合末尾
|
||||
virtual Control* Append(const UIString& xmlStr);
|
||||
|
||||
//解析xml字符串并添加到控件集合第一位
|
||||
virtual Control* Prepend(const UIString& xmlStr);
|
||||
|
||||
// 移除控件,freeCtrl 标志是否释放控件内存
|
||||
virtual void RemoveChild(Control* childCtl, bool freeCtrl = false);
|
||||
|
||||
//移除并且销毁全部弹簧
|
||||
void DestroySpacers();
|
||||
|
||||
// 设置控件的父控件
|
||||
virtual void SetParent(Control* parentCtl);
|
||||
|
||||
// 移除所有子控件
|
||||
virtual void RemoveAll();
|
||||
|
||||
// 移除所有子控件,freeChilds 决定是否释放子控件内存
|
||||
virtual void RemoveAll(bool freeAll);
|
||||
|
||||
//是否为弹簧控件
|
||||
virtual bool IsSpacer();
|
||||
|
||||
//是否为Frame
|
||||
virtual bool IsFrame();
|
||||
|
||||
// 设置控件浮动
|
||||
virtual void SetFloat(bool flag);
|
||||
|
||||
// 控件是否浮动
|
||||
virtual bool IsFloat();
|
||||
|
||||
// 设置控件可见性
|
||||
virtual void SetVisible(bool flag);
|
||||
|
||||
// 获取控件可见性状态
|
||||
virtual bool IsVisible();
|
||||
|
||||
//设置控件是否可以被鼠标命中(false则是鼠标穿透效果)
|
||||
void SetHitTestVisible(bool bEnable);
|
||||
|
||||
//控件是否可以被命中
|
||||
bool IsHitTestVisible();
|
||||
|
||||
//隐藏控件
|
||||
void Hide();
|
||||
|
||||
//显示控件
|
||||
void Show();
|
||||
|
||||
// 标记控件区域为无效(将会延迟刷新UI)
|
||||
virtual bool Invalidate();
|
||||
|
||||
// 立即强制刷新控件区域并更新无效区域(且立即触发布局)
|
||||
virtual void Refresh();
|
||||
|
||||
/// <summary>
|
||||
/// 为当前控件的指定状态批量设置样式(使用分号分隔)
|
||||
/// </summary>
|
||||
/// <param name="state">控件状态,例如 ControlState::Hover</param>
|
||||
/// <param name="styleStr">样式字符串,例如 "font-size: 13px; color: #ffffff;"</param>
|
||||
virtual void SetStyleSheet(ControlState state, const UIString& styleStr);
|
||||
|
||||
/// <summary>
|
||||
/// 设置样式集合,并自动匹配应用到符合条件的子控件
|
||||
/// </summary>
|
||||
/// <param name="styleStr">样式字符串,例如 "#btn:hover { font-size:13px; }"</param>
|
||||
virtual void SetStyleSheet(const UIString& styleStr);
|
||||
|
||||
//设置基于父控件的边距四周边距
|
||||
void SetMargin(int allMargin);
|
||||
|
||||
//设置基于父控件的边距上下边距
|
||||
void SetMargin(int topBottom, int leftRight);
|
||||
|
||||
//设置基于父控件的上边距
|
||||
void SetMarginTop(int topMargin);
|
||||
|
||||
//设置基于父控件的左边距
|
||||
void SetMarginLeft(int leftMargin);
|
||||
|
||||
//设置基于父控件的右边距
|
||||
void SetMarginRight(int rightMargin);
|
||||
|
||||
//设置基于父控件的下边距
|
||||
void SetMarginBottom(int bottomMargin);
|
||||
|
||||
//设置基于父控件的边距 上 右 下 左
|
||||
void SetMargin(int top, int right, int bottom, int left);
|
||||
|
||||
//获取基于父控件的边距信息;
|
||||
const Distance& GetMargin();
|
||||
|
||||
//控件是否被按住
|
||||
bool IsPressed();
|
||||
|
||||
//给当前控件设置为焦点控件
|
||||
void SetFocus();
|
||||
};
|
||||
|
||||
};
|
||||
280
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Direct2DRender.h
vendored
Normal file
280
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Direct2DRender.h
vendored
Normal file
@@ -0,0 +1,280 @@
|
||||
#pragma once
|
||||
#include "UIDef.h"
|
||||
#if USED_DIRECT2D
|
||||
#ifndef UI_EXPORT
|
||||
#define UI_EXPORT
|
||||
#endif
|
||||
|
||||
#include <d2d1.h>
|
||||
#include <d2d1helper.h>
|
||||
#include <dwrite.h>
|
||||
#include <wincodec.h>
|
||||
#include "RenderTypes.h"
|
||||
|
||||
namespace ezui {
|
||||
UI_EXPORT void RenderInitialize();//全局初始化direct2d
|
||||
UI_EXPORT void RenderUnInitialize();//释放direct2d
|
||||
UI_EXPORT float GetMaxRadius(float width, float height, float _radius);//获取最大半径 用于自动适应border-radius属性
|
||||
class UI_EXPORT Font {
|
||||
private:
|
||||
Font() = delete;
|
||||
std::wstring m_fontFamily;
|
||||
float m_fontSize = 0;
|
||||
int m_fontWeight = 0;
|
||||
IDWriteTextFormat* m_value = NULL;
|
||||
bool m_ref = false;
|
||||
void Copy(const Font& _copy);
|
||||
public:
|
||||
Font(const Font& _copy);
|
||||
Font(const std::wstring& fontFamily, float fontSize, int fontweight = 0);
|
||||
float GetFontSize()const;
|
||||
float GetFontWeight()const;
|
||||
const std::wstring& GetFontFamily()const;
|
||||
IDWriteTextFormat* Get() const;
|
||||
bool operator==(const Font& _right);
|
||||
virtual ~Font();
|
||||
};
|
||||
|
||||
//文本命中测试数据
|
||||
class UI_EXPORT HitTestMetrics {
|
||||
public:
|
||||
int Length;
|
||||
int TextPos;//命中的下标
|
||||
RectF FontBox;//文字的矩形位置
|
||||
bool IsTrailingHit;//命中位置是否在尾部
|
||||
public:
|
||||
Rect GetCare() {
|
||||
float x = FontBox.X;
|
||||
if (IsTrailingHit) {
|
||||
x += FontBox.Width;
|
||||
}
|
||||
float y = FontBox.Y;
|
||||
return Rect((int)x, (int)y, 1, (int)(FontBox.Height + 0.5));
|
||||
}
|
||||
int GetFontHeight() {
|
||||
return int(FontBox.Height + 0.5);
|
||||
}
|
||||
};
|
||||
|
||||
class UI_EXPORT TextLayout {
|
||||
private:
|
||||
TextLayout(const TextLayout& rightValue) = delete;
|
||||
IDWriteTextLayout* m_textLayout = NULL;
|
||||
std::wstring m_fontFamily;
|
||||
DWRITE_TEXT_METRICS m_textMetrics = {};
|
||||
std::vector<RectF> m_lineRects;
|
||||
int m_unicodeSize = 0;
|
||||
float m_fontSize = 0;
|
||||
public:
|
||||
void GetMetrics();
|
||||
TextLayout(const std::wstring& text, const Font& font, const SizeF& maxSize = SizeF{ EZUI_FLOAT_MAX,EZUI_FLOAT_MAX }, TextAlign textAlgin = TextAlign::TopLeft);
|
||||
Point HitTestPoint(const Point& pt, int* outTextPos, BOOL* outIsTrailingHit, int* fontHeight);
|
||||
void HitTestPoint(const Point& pt, HitTestMetrics* hitTestMetrics);//根据坐标执行命中测试
|
||||
Point HitTestTextPosition(int textPos, BOOL isTrailingHit);//根据文字下标执行命中测试
|
||||
const std::wstring& GetFontFamily();
|
||||
float GetFontSize();
|
||||
int Width();
|
||||
int Height();
|
||||
//获取文本整体的占用空间
|
||||
Size GetFontBox();
|
||||
//获取每行文字的矩形位置
|
||||
const std::vector<RectF>& GetLineRects();
|
||||
int GetFontHeight();//获取字体高度
|
||||
int GetLineCount();//获取一共有多少行
|
||||
IDWriteTextLayout* Get() const;
|
||||
void SetTextAlign(TextAlign textAlign);
|
||||
void SetUnderline(int pos = 0, int count = 0);
|
||||
virtual ~TextLayout();
|
||||
};
|
||||
|
||||
//几何图形基础类(支持自定义路径)
|
||||
class UI_EXPORT Geometry {
|
||||
protected:
|
||||
ID2D1GeometrySink* m_pSink = NULL;
|
||||
ID2D1Geometry* m_rgn = NULL;
|
||||
Geometry(const Geometry& rightCopy) = delete;
|
||||
public:
|
||||
Geometry();
|
||||
virtual ~Geometry();
|
||||
void AddArc(const PointF& endPoint, float radius);
|
||||
void AddAcr(const D2D1_ARC_SEGMENT& arc);
|
||||
void AddLine(const PointF& endPoint);
|
||||
void BeginFigure(const PointF& startPoint, D2D1_FIGURE_BEGIN figureBegin = D2D1_FIGURE_BEGIN_FILLED);
|
||||
void CloseFigure(D2D1_FIGURE_END figureEnd = D2D1_FIGURE_END_CLOSED);
|
||||
ID2D1Geometry* Get()const;
|
||||
public:
|
||||
/// <summary>
|
||||
/// 将两个几何图形通过指定的合并模式(Union、Intersect、Xor、Exclude)合并到一个输出几何中。
|
||||
/// </summary>
|
||||
/// <param name="out">合并结果输出到该 Geometry。</param>
|
||||
/// <param name="a">参与合并的第一个 Geometry。</param>
|
||||
/// <param name="b">参与合并的第二个 Geometry。</param>
|
||||
/// <param name="COMBINE_MODE">几何合并模式,取值如 D2D1_COMBINE_MODE_UNION、INTERSECT、XOR、EXCLUDE。</param>
|
||||
static void Combine(Geometry& out, const Geometry& a, const Geometry& b, D2D1_COMBINE_MODE COMBINE_MODE);
|
||||
|
||||
/// <summary>
|
||||
/// 合并两个区域,取它们的联合部分(即最大边界区域)。
|
||||
/// </summary>
|
||||
static void Union(Geometry& out, const Geometry& a, const Geometry& b) {
|
||||
Combine(out, a, b, D2D1_COMBINE_MODE::D2D1_COMBINE_MODE_UNION);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取两个区域的交集部分。
|
||||
/// </summary>
|
||||
static void Intersect(Geometry& out, const Geometry& a, const Geometry& b) {
|
||||
Combine(out, a, b, D2D1_COMBINE_MODE::D2D1_COMBINE_MODE_INTERSECT);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合并两个区域,保留不重叠的部分(异或运算)。
|
||||
/// </summary>
|
||||
static void Xor(Geometry& out, const Geometry& a, const Geometry& b) {
|
||||
Combine(out, a, b, D2D1_COMBINE_MODE::D2D1_COMBINE_MODE_XOR);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从第一个区域中排除第二个区域的部分(差集)。
|
||||
/// </summary>
|
||||
static void Exclude(Geometry& out, const Geometry& a, const Geometry& b) {
|
||||
Combine(out, a, b, D2D1_COMBINE_MODE::D2D1_COMBINE_MODE_EXCLUDE);
|
||||
}
|
||||
};
|
||||
|
||||
//矩形(已经完成闭合)
|
||||
class UI_EXPORT RectangleGeometry :public Geometry {
|
||||
private:
|
||||
void Create(float x, float y, float width, float height, float _radius);
|
||||
public:
|
||||
RectangleGeometry(float x, float y, float width, float height, float _radius = 0);
|
||||
RectangleGeometry(const RectF& _rect, float radius = 0);
|
||||
RectangleGeometry(const RectF& _rect, float topLeftRadius, float topRightRadius, float bottomRightRadius, float bottomLeftRadius);
|
||||
virtual ~RectangleGeometry() {};
|
||||
};
|
||||
|
||||
//扇形(已经完成闭合)
|
||||
class UI_EXPORT PieGeometry :public Geometry {
|
||||
public:
|
||||
PieGeometry(const RectF& rectF, float startAngle, float endAngle);
|
||||
virtual ~PieGeometry() {};
|
||||
};
|
||||
|
||||
//圆形/椭圆(已经完成闭合)
|
||||
class UI_EXPORT EllipseGeometry :public PieGeometry {
|
||||
public:
|
||||
EllipseGeometry(const RectF& rectF) :PieGeometry(rectF, 0, 360) {}
|
||||
virtual ~EllipseGeometry() {};
|
||||
};
|
||||
|
||||
class UI_EXPORT DXImage : public IImage {
|
||||
struct GifFrame
|
||||
{
|
||||
IWICBitmap* wicBitmap; // 存一份完整帧
|
||||
UINT delay;
|
||||
};
|
||||
protected:
|
||||
std::vector<GifFrame> m_frames;
|
||||
IWICBitmapDecoder* m_bitmapdecoder = NULL;
|
||||
IWICBitmapFrameDecode* m_pframe = NULL;
|
||||
IWICFormatConverter* m_fmtcovter = NULL;//从文件加载
|
||||
IWICBitmap* m_bitMap = NULL;//从HBITMAP中加载
|
||||
int m_width = 0;
|
||||
int m_height = 0;
|
||||
ID2D1Bitmap* m_d2dBitmap = NULL;
|
||||
void* m_lastRender = NULL;
|
||||
private:
|
||||
void CreateFormStream(IStream* istram);
|
||||
void CreateFromFile(const std::wstring& file);
|
||||
void Init();
|
||||
public:
|
||||
bool Visible = true;
|
||||
void CreateD2DBitmap(ID2D1RenderTarget* render);
|
||||
//如果HBITMAP带有透明通道 确保传入的图像颜色值已经与 Alpha 通道预乘
|
||||
DXImage(HBITMAP hBitmap);
|
||||
DXImage(IStream* istram);
|
||||
DXImage(const std::wstring& file);
|
||||
//创建带预乘Alpha的BGRA图片
|
||||
DXImage(int width, int height);
|
||||
DXImage(const void* data, size_t count);
|
||||
ID2D1Bitmap* Get();
|
||||
IWICBitmap* GetIWICBitmap();
|
||||
int Width();
|
||||
int Height();
|
||||
virtual int NextFrame()override;
|
||||
DXImage* Clone();
|
||||
virtual ~DXImage();
|
||||
};
|
||||
|
||||
class Bezier {
|
||||
public:
|
||||
Point point1;
|
||||
Point point2;
|
||||
Point point3;
|
||||
};
|
||||
};
|
||||
|
||||
namespace ezui {
|
||||
|
||||
class UI_EXPORT DXRender {
|
||||
private:
|
||||
ID2D1DCRenderTarget* m_render = NULL;
|
||||
ID2D1SolidColorBrush* m_brush = NULL;
|
||||
Font* m_font = NULL;
|
||||
ID2D1StrokeStyle* m_pStrokeStyle = NULL;
|
||||
Point m_offset;
|
||||
PointF m_rotatePoint;
|
||||
float m_angle = std::numeric_limits<float>::quiet_NaN();
|
||||
Size m_size;
|
||||
HWND m_hwnd = NULL;
|
||||
HDC m_hdc = NULL;
|
||||
bool m_begin = false;
|
||||
private:
|
||||
DXRender(const DXRender& rightValue) = delete;
|
||||
public:
|
||||
ID2D1SolidColorBrush* GetBrush();
|
||||
ID2D1StrokeStyle* GetStrokeStyle();
|
||||
public:
|
||||
DXRender(DXImage* dxImage);
|
||||
DXRender(HDC dc, int width, int height);//创建dx绘图对象
|
||||
DXRender(HWND hWnd, int width, int height);//创建dx绘图对象
|
||||
void BeginDraw();
|
||||
void EndDraw();
|
||||
virtual ~DXRender();
|
||||
//如果此对象是由HDC创建的则重置大小时需要传入HDC,如果是使用HWND的则无需传入HDC
|
||||
void ReSize(int width, int height, HDC dc = NULL);
|
||||
void SetFont(const std::wstring& fontFamily, float fontSize, int fontWeight = 0);//必须先调用
|
||||
void SetFont(const Font& _copy_font);//必须先调用
|
||||
void SetColor(const __EzUI__Color& color);//会之前必须调用
|
||||
void SetStrokeStyle(StrokeStyle strokeStyle = StrokeStyle::Solid);//设置样式 虚线/实线
|
||||
void DrawTextLayout(const TextLayout& textLayout, const PointF & = { 0,0 });//根据已有的布局绘制文字
|
||||
void DrawString(const std::wstring& text, const RectF& _rect, ezui::TextAlign textAlign);//绘制文字
|
||||
void DrawLine(const PointF& _A, const PointF& _B, float width = 1);//绘制一条线
|
||||
void DrawRectangle(const RectF& _rect, float _radius = 0, float width = 1);//绘制矩形
|
||||
void FillRectangle(const RectF& _rect, float _radius = 0);
|
||||
//填充矩形
|
||||
void PushLayer(const Geometry& dxGeometry, float opacity = 1.0f);
|
||||
void PopLayer();
|
||||
void PushAxisAlignedClip(const RectF& rectBounds);
|
||||
void PopAxisAlignedClip();
|
||||
void SetTransform(float offsetX, float offsetY);//对画布进行旋转和偏移
|
||||
void SetTransform(float startX, float startY, float angle);//设置旋转起始点与旋转角度
|
||||
void SetTransform(float offsetX, float offsetY, float startX, float startY, float angle);
|
||||
void DrawImage(DXImage* _image, const RectF& tagRect, float opacity = 1);//绘制图像
|
||||
void DrawBezier(const PointF& startPoint, const Bezier& points, float width = 1);//贝塞尔线
|
||||
void DrawBezier(const PointF& startPoint, std::list<Bezier>& points, float width = 1);//贝塞尔线
|
||||
void DrawEllipse(const RectF& rectF, float width = 1);
|
||||
void FillEllipse(const RectF& rectF);
|
||||
void DrawPie(const RectF& rectF, float startAngle, float endAngle, float strokeWidth = 1);
|
||||
void FillPie(const RectF& rectF, float startAngle, float endAngle);
|
||||
void DrawPoint(const PointF& pt);
|
||||
void DrawArc(const RectF& rect, float startAngle, float sweepAngle, float width = 1);//未实现
|
||||
void DrawArc(const PointF& point1, const PointF& point2, const PointF& point3, float width = 1);
|
||||
void DrawGeometry(ID2D1Geometry* path, float width = 1);
|
||||
void FillGeometry(ID2D1Geometry* path);
|
||||
void DrawGeometry(Geometry* path, float width = 1);
|
||||
void FillGeometry(Geometry* path);
|
||||
HRESULT Flush();
|
||||
ID2D1DCRenderTarget* Get();//获取原生DX对象
|
||||
};
|
||||
};
|
||||
#endif
|
||||
636
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/EzUI.h
vendored
Normal file
636
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/EzUI.h
vendored
Normal file
@@ -0,0 +1,636 @@
|
||||
/*/
|
||||
Author:yang
|
||||
Email:19980103ly@gmail.com/718987717@qq.com
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "UIDef.h"
|
||||
#include "UIString.h"
|
||||
#include "Resource.h"
|
||||
#include "RenderTypes.h"
|
||||
#include "Direct2DRender.h"
|
||||
|
||||
#undef LoadCursor
|
||||
#undef LoadIcon
|
||||
|
||||
namespace ezui {
|
||||
class Object;
|
||||
enum class Cursor : ULONG_PTR;
|
||||
struct MonitorInfo;
|
||||
struct Style;
|
||||
class EventArgs;
|
||||
class ControlStyle;
|
||||
class Bitmap;
|
||||
class Window;
|
||||
|
||||
class Control;
|
||||
class Frame;
|
||||
class Spacer;
|
||||
class ScrollBar;
|
||||
class VScrollBar;
|
||||
class HScrollBar;
|
||||
class TabLayout;
|
||||
class TextBox;
|
||||
class TileListView;
|
||||
class TreeView;
|
||||
class VLayout;
|
||||
class VListView;
|
||||
class Button;
|
||||
class CheckBox;
|
||||
class ComboBox;
|
||||
class HLayout;
|
||||
class HListView;
|
||||
class Label;
|
||||
class PagedListView;
|
||||
class PictureBox;
|
||||
class RadioButton;
|
||||
|
||||
#if 1
|
||||
//控件集合
|
||||
class UI_EXPORT ControlCollection : public std::vector<Control*> {
|
||||
public:
|
||||
ControlCollection() = default;
|
||||
~ControlCollection() = default;
|
||||
//返回集合中的第一个控件
|
||||
Control* First() {
|
||||
return this->empty() ? NULL : this->front();
|
||||
}
|
||||
//返回集合中的最后一个控件
|
||||
Control* Last() {
|
||||
return this->empty() ? NULL : this->back();
|
||||
}
|
||||
//移除元素
|
||||
void Remove(Control* ctrl) {
|
||||
auto itor = std::find(this->begin(), this->end(), ctrl);
|
||||
if (itor != this->end()) {
|
||||
this->erase(itor);
|
||||
}
|
||||
}
|
||||
//检查元素是否存在
|
||||
bool Contains(Control* ctrl) {
|
||||
auto itor = std::find(this->begin(), this->end(), ctrl);
|
||||
return itor != this->end();
|
||||
}
|
||||
};
|
||||
#else
|
||||
// 控件集合
|
||||
class UI_EXPORT ControlCollection : public std::list<Control*> {
|
||||
public:
|
||||
ControlCollection() = default;
|
||||
~ControlCollection() = default;
|
||||
// 慎用 链表不适合随机访问,下标越大,遍历越慢 O(n)
|
||||
Control* operator[](size_t index) const {
|
||||
if (index >= this->size()) {
|
||||
return NULL;
|
||||
}
|
||||
auto it = this->begin();
|
||||
std::advance(it, index); // 高效移动迭代器
|
||||
return *it;
|
||||
}
|
||||
//返回集合中的第一个控件
|
||||
Control* First() const {
|
||||
return this->empty() ? NULL : this->front();
|
||||
}
|
||||
//返回集合中的最后一个控件
|
||||
Control* Last() const {
|
||||
return this->empty() ? NULL : this->back();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
namespace detail {
|
||||
//全局资源句柄
|
||||
extern UI_VAR_EXPORT HMODULE __EzUI__HINSTANCE;//全局实例
|
||||
extern UI_VAR_EXPORT Resource* __EzUI__Resource;//文件中的全局资源句柄
|
||||
extern UI_VAR_EXPORT DWORD __EzUI__ThreadId;//UI的线程Id
|
||||
extern UI_VAR_EXPORT HWND __EzUI_MessageWnd;//用于UI通讯的隐形窗口
|
||||
extern UI_VAR_EXPORT const std::list<ezui::MonitorInfo> __EzUI__MonitorInfos;//所有监视器信息
|
||||
};
|
||||
|
||||
//判断两个float是相等(两数是否接近)
|
||||
extern UI_EXPORT bool IsFloatEqual(float num1, float num2);
|
||||
//加载HICON
|
||||
extern UI_EXPORT HICON LoadIcon(const UIString& fileName);
|
||||
//装载字体
|
||||
extern UI_EXPORT void InstallFont(const UIString& fontFileName);
|
||||
//卸载字体
|
||||
extern UI_EXPORT void UnstallFont(const UIString& fontFileName);
|
||||
//复制内容到剪切板
|
||||
extern UI_EXPORT bool CopyToClipboard(int uFormat, void* pData, size_t size, HWND hWnd = NULL);
|
||||
//打开剪切板
|
||||
extern UI_EXPORT bool GetClipboardData(int uFormat, std::function<void(void*, size_t)> Callback, HWND hWnd = NULL);
|
||||
//复制unicode文字
|
||||
extern UI_EXPORT bool CopyToClipboard(const std::wstring& str, HWND hWnd = NULL);
|
||||
//粘贴unicode文字
|
||||
extern UI_EXPORT bool GetClipboardData(std::wstring* outStr, HWND hWnd = NULL);
|
||||
//自动获取文件资源(本地文件/资源文件)
|
||||
extern UI_EXPORT bool GetResource(const UIString& fileName, std::string* outData);
|
||||
//获取当前所有监视器的信息
|
||||
extern UI_EXPORT size_t GetMonitor(std::list<MonitorInfo>* outMonitorInfo);
|
||||
//获取用户当前所在的显示器
|
||||
extern UI_EXPORT void GetMontior(MonitorInfo* outInfo, HWND hWnd = NULL);
|
||||
//使用窗口的矩形位置获取所在的显示器
|
||||
extern UI_EXPORT void GetMontior(MonitorInfo* outInfo, const Rect& rect);
|
||||
//加载光标
|
||||
extern UI_EXPORT HCURSOR LoadCursor(Cursor cursorType);
|
||||
//加载光标(//需要释放)
|
||||
extern UI_EXPORT HCURSOR LoadCursor(const UIString& fileName);
|
||||
//释放光标
|
||||
extern UI_EXPORT void FreeCursor(HCURSOR hCursor);
|
||||
//默认处理OnNotify函数(处理一些控件的基础行为)
|
||||
extern UI_EXPORT void DefaultNotify(Control* sender, EventArgs& args);
|
||||
|
||||
class UI_EXPORT Color :public ezui::__EzUI__Color {
|
||||
public:
|
||||
Color(const ezui::__EzUI__Color& copy) { this->BGRA = copy.GetValue(); }
|
||||
Color(const uint32_t& bgra = 0) :ezui::__EzUI__Color(bgra) {}
|
||||
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) :ezui::__EzUI__Color(r, g, b, a) {}
|
||||
public:
|
||||
//构建一个Color
|
||||
static Color Make(const UIString& colorStr, bool* isGood = NULL);
|
||||
virtual ~Color() {}
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述边框的一些信息
|
||||
/// </summary>
|
||||
class Border {
|
||||
public:
|
||||
Value<int16_t> Left;//左边边框大小
|
||||
Value<int16_t> Top;//顶部边框大小
|
||||
Value<int16_t> Right;//右边边框大小
|
||||
Value<int16_t> Bottom;//底部边框大小
|
||||
Value<int16_t> TopLeftRadius;
|
||||
Value<int16_t> TopRightRadius;
|
||||
Value<int16_t> BottomRightRadius;
|
||||
Value<int16_t> BottomLeftRadius;
|
||||
Value<Color> Color;
|
||||
Value<StrokeStyle> Style = StrokeStyle::None;
|
||||
public:
|
||||
class Radius {
|
||||
Border& Border;
|
||||
public:
|
||||
Radius(ezui::Border& bd) :Border(bd) {}
|
||||
//对四个角度同时设置半径大小
|
||||
Radius& operator=(Value<int16_t> radius) {
|
||||
Border.TopLeftRadius = radius;
|
||||
Border.TopRightRadius = radius;
|
||||
Border.BottomRightRadius = radius;
|
||||
Border.BottomLeftRadius = radius;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
public:
|
||||
Border::Radius Radius = (*this);
|
||||
public:
|
||||
Border() {
|
||||
this->Style.SetEnabled(false);
|
||||
}
|
||||
//对四个边设置大小
|
||||
Border& operator=(Value<int16_t> borderWidth) {
|
||||
Left = borderWidth;
|
||||
Top = borderWidth;
|
||||
Right = borderWidth;
|
||||
Bottom = borderWidth;
|
||||
return *this;
|
||||
}
|
||||
void Scale(float scale) {
|
||||
Left.Set(Left * scale + 0.5);
|
||||
Top.Set(Top * scale + 0.5);
|
||||
Right.Set(Right * scale + 0.5);
|
||||
Bottom.Set(Bottom * scale + 0.5);
|
||||
TopLeftRadius.Set(TopLeftRadius * scale + 0.5);
|
||||
TopRightRadius.Set(TopRightRadius * scale + 0.5);
|
||||
BottomRightRadius.Set(BottomRightRadius * scale + 0.5);
|
||||
BottomLeftRadius.Set(BottomLeftRadius * scale + 0.5);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if USED_DIRECT2D
|
||||
class UI_EXPORT Image :public DXImage {
|
||||
private:
|
||||
#ifdef _DEBUG
|
||||
UIString m_path;
|
||||
#endif
|
||||
public:
|
||||
virtual ~Image() {}
|
||||
//创建带预乘Alpha的BGRA图片
|
||||
Image(int width, int height) :DXImage(width, height) {}
|
||||
Image(HBITMAP hBitmap) :DXImage(hBitmap) {}
|
||||
Image(Bitmap* bitmap);
|
||||
Image(IStream* iStream) :DXImage(iStream) {}
|
||||
Image(const std::wstring& fileName) :DXImage(fileName) {}
|
||||
Image(const void* data, size_t dataCount) :DXImage(data, dataCount) {}
|
||||
public:
|
||||
//从资源或者本地文件自动构建一个Image
|
||||
static Image* Make(const UIString& fileOrRes);
|
||||
};
|
||||
#endif
|
||||
// 定义用于保存显示器信息的结构体
|
||||
struct MonitorInfo {
|
||||
HMONITOR Monitor = NULL;
|
||||
//显示器的位置 多显示器下Y轴可能出现负数或者大于0的时候代表显示器在设置里面显示器是错位的(多显示器没有平行);
|
||||
//逻辑宽高
|
||||
ezui::Rect Rect;
|
||||
//工作区域
|
||||
ezui::Rect WorkRect;
|
||||
//显示器物理宽高
|
||||
Size Physical;
|
||||
//显示器缩放比例 1.0 1.25 1.5 1.75 2.0
|
||||
float Scale = 1.0f;
|
||||
//显示器帧率
|
||||
float FPS = 60;
|
||||
//是否为主显示器
|
||||
bool Primary = false;
|
||||
};
|
||||
|
||||
//窗口公共数据
|
||||
struct WindowContext {
|
||||
//缩放率
|
||||
float Scale = 1.0f;
|
||||
//单次绘图数量
|
||||
int DrawControlCount = 0;
|
||||
//上一帧绘制时间
|
||||
unsigned long long LastFrameTime = 0;
|
||||
//一秒内绘制次数
|
||||
int DrawFrameCount = 0;
|
||||
#ifdef _DEBUG
|
||||
//是否开启debug模式
|
||||
bool Debug = false;
|
||||
//调试模式下的特有字段
|
||||
int ColorIndex = 0;
|
||||
Color DebugColor;
|
||||
std::vector<Color> DebugColors{ Color::Red,Color::Green,Color::Blue,Color::Black,Color::White };
|
||||
#endif
|
||||
//主窗类的实例
|
||||
ezui::Window* Window = NULL;
|
||||
//使一个区域无效
|
||||
std::function<void(const Rect&)> InvalidateRect = NULL;
|
||||
//立即更新全部无效区域
|
||||
std::function<void()> Refresh = NULL;
|
||||
//清空控件标记等等...
|
||||
std::function<void(Control*)> CleanControl = NULL;
|
||||
//内部移动窗口的函数
|
||||
std::function<void()> MoveWindow = NULL;
|
||||
//内部使用标题部分移动窗口的函数
|
||||
std::function<void()> TitleMoveWindow = NULL;
|
||||
//处理消息过程的回调函数
|
||||
std::function<LRESULT(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)> WndProc = NULL;
|
||||
//设置焦点控件
|
||||
std::function<void(Control*)> SetFocus = NULL;
|
||||
};
|
||||
|
||||
enum class LayoutState {
|
||||
//无状态 (无需布局)
|
||||
None,
|
||||
//挂起中
|
||||
Pend,
|
||||
//布局中
|
||||
Layouting
|
||||
};
|
||||
enum class Event :long long {
|
||||
None = 0,
|
||||
OnMouseWheel = 1,
|
||||
OnMouseEnter = 2,
|
||||
OnMouseMove = 4,
|
||||
OnMouseLeave = 8,
|
||||
OnMouseDoubleClick = 16,
|
||||
OnMouseDown = 32,
|
||||
OnMouseUp = 64,
|
||||
OnKeyDown = 128,
|
||||
OnKeyUp = 256,
|
||||
OnPaint = 512,
|
||||
OnFocus = 1024,
|
||||
OnKillFocus = 2048,
|
||||
OnKeyChar = 4096,
|
||||
OnMove = 8192,
|
||||
OnSize = 16384,
|
||||
OnRect = 32768,
|
||||
OnDpiChange = 65536,
|
||||
OnActive = OnMouseDown | OnMouseUp,
|
||||
OnHover = OnMouseEnter | OnMouseLeave,
|
||||
OnMouseDrag = OnMouseDown | OnMouseMove,
|
||||
OnMouseEvent = OnMouseWheel | OnMouseEnter | OnMouseMove | OnMouseLeave | OnMouseDoubleClick | OnMouseDown | OnMouseUp,
|
||||
OnKeyBoardEvent = OnKeyDown | OnKeyUp | OnKeyChar
|
||||
};
|
||||
EZUI_ENUM_OPERATORS(Event, long long);
|
||||
|
||||
//控件行为
|
||||
enum class ControlAction {
|
||||
None,
|
||||
Title,//具有移动窗口 双击最大化窗口的行为
|
||||
MoveWindow,//移动窗口
|
||||
Mini,//最小化
|
||||
Max,//最大化|恢复
|
||||
Close//关闭
|
||||
};
|
||||
enum class ControlState :int {
|
||||
None = 1,//无状态 则是使用_nowStyle缓存样式
|
||||
Static = 2,//静态
|
||||
Disabled = 4,//禁用状态
|
||||
Checked = 8,//选中状态
|
||||
Hover = 16,//鼠标悬浮
|
||||
Active = 32,//鼠标按住
|
||||
Focus = 64//具有焦点时
|
||||
};
|
||||
EZUI_ENUM_OPERATORS(ControlState, int);
|
||||
|
||||
enum class MouseButton {
|
||||
// 摘要:
|
||||
// 未曾按下鼠标按钮。
|
||||
None,
|
||||
//
|
||||
// 摘要:
|
||||
// 鼠标左按钮曾按下。
|
||||
Left,
|
||||
//
|
||||
// 摘要:
|
||||
// 鼠标右按钮曾按下。
|
||||
Right,
|
||||
//
|
||||
// 摘要:
|
||||
// 鼠标中按钮曾按下。
|
||||
Middle,
|
||||
//
|
||||
// 摘要:
|
||||
// 第 1 个 XButton 曾按下。
|
||||
XButton1,
|
||||
//
|
||||
// 摘要:
|
||||
// 第 2 个 XButton 曾按下。
|
||||
XButton2
|
||||
};
|
||||
enum class Cursor :ULONG_PTR
|
||||
{
|
||||
None = 0,//未指定
|
||||
APPSTARTING = (ULONG_PTR)IDC_APPSTARTING,// 标准的箭头和小沙漏
|
||||
ARROW = (ULONG_PTR)IDC_ARROW,// 标准的箭头
|
||||
CROSS = (ULONG_PTR)IDC_CROSS,// 十字光标
|
||||
HAND = (ULONG_PTR)IDC_HAND,// Windows 98/Me, Windows 2000/XP: Hand
|
||||
HELP = (ULONG_PTR)IDC_HELP,// 标准的箭头和问号
|
||||
IBEAM = (ULONG_PTR)IDC_IBEAM,// 工字光标
|
||||
ICON = (ULONG_PTR)IDC_ICON,// Obsolete for applications marked version 4.0 or later.
|
||||
NO = (ULONG_PTR)IDC_NO,// 禁止圈
|
||||
SIZE = (ULONG_PTR)IDC_SIZE,// Obsolete for applications marked version 4.0 or later. Use SIZEALL.
|
||||
SIZEALL = (ULONG_PTR)IDC_SIZEALL,// 四向箭头指向东、西、南、北
|
||||
SIZENESW = (ULONG_PTR)IDC_SIZENESW,// 双箭头指向东北和西南
|
||||
SIZENS = (ULONG_PTR)IDC_SIZENS, // 双箭头指向南北
|
||||
SIZENWSE = (ULONG_PTR)IDC_SIZENWSE,// 双箭头指向西北和东南
|
||||
SIZEWE = (ULONG_PTR)IDC_SIZEWE,// 双箭头指向东西
|
||||
UPARROW = (ULONG_PTR)IDC_UPARROW,// 垂直箭头
|
||||
WAIT = (ULONG_PTR)IDC_WAIT// 沙漏,Windows7下会显示为选择的圆圈表示等待
|
||||
};
|
||||
|
||||
//基础事件
|
||||
class UI_EXPORT EventArgs {
|
||||
public:
|
||||
Event EventType = Event::None;
|
||||
EventArgs(Event eventType) {
|
||||
this->EventType = eventType;
|
||||
}
|
||||
virtual ~EventArgs() {};
|
||||
};
|
||||
//为鼠标事件提供基础数据
|
||||
class UI_EXPORT MouseEventArgs :public EventArgs {
|
||||
public:
|
||||
MouseButton Button = MouseButton::None;
|
||||
int ZDelta = 0;//方向
|
||||
Point Location;
|
||||
public:
|
||||
MouseEventArgs(Event eventType, const Point& location = Point(0, 0), MouseButton mouseButton = MouseButton::None, int ZDelta = 0) :EventArgs(eventType) {
|
||||
this->Button = mouseButton;
|
||||
this->Location = location;
|
||||
this->ZDelta = ZDelta;
|
||||
}
|
||||
virtual ~MouseEventArgs() {}
|
||||
};
|
||||
// 摘要:
|
||||
//为键盘事件提供基础数据
|
||||
class UI_EXPORT KeyboardEventArgs :public EventArgs {
|
||||
public:
|
||||
/// <summary>
|
||||
/// 一般是指 键盘的ascii值
|
||||
/// </summary>
|
||||
WPARAM wParam;
|
||||
LPARAM lParam;
|
||||
KeyboardEventArgs(Event eventType, WPARAM wParam, LPARAM lParam) :EventArgs(eventType) {
|
||||
this->wParam = wParam;
|
||||
this->lParam = lParam;
|
||||
}
|
||||
virtual ~KeyboardEventArgs() {}
|
||||
};
|
||||
//获取焦点
|
||||
class UI_EXPORT FocusEventArgs :public EventArgs {
|
||||
public:
|
||||
Control* Control;
|
||||
FocusEventArgs(ezui::Control* ctl) :EventArgs(Event::OnFocus) {
|
||||
this->Control = ctl;
|
||||
}
|
||||
virtual ~FocusEventArgs() {}
|
||||
};
|
||||
//失去焦点
|
||||
class UI_EXPORT KillFocusEventArgs :public EventArgs {
|
||||
public:
|
||||
Control* Control;
|
||||
KillFocusEventArgs(ezui::Control* ctl) :EventArgs(Event::OnKillFocus) {
|
||||
this->Control = ctl;
|
||||
}
|
||||
virtual ~KillFocusEventArgs() {}
|
||||
};
|
||||
//坐标发生改变
|
||||
class UI_EXPORT MoveEventArgs :public EventArgs {
|
||||
public:
|
||||
const ezui::Point Location;
|
||||
MoveEventArgs(const ezui::Point& location) :EventArgs(Event::OnMove), Location(location) {}
|
||||
virtual ~MoveEventArgs() {}
|
||||
};
|
||||
//大小发生改变
|
||||
class UI_EXPORT SizeEventArgs :public EventArgs {
|
||||
public:
|
||||
const ezui::Size Size;
|
||||
SizeEventArgs(const ezui::Size& size) :EventArgs(Event::OnSize), Size(size) {}
|
||||
virtual ~SizeEventArgs() {}
|
||||
};
|
||||
//dpi发生变化
|
||||
class UI_EXPORT DpiChangeEventArgs :public EventArgs {
|
||||
public:
|
||||
float Scale = 1.0f;
|
||||
DpiChangeEventArgs(float scale) :EventArgs(Event::OnDpiChange), Scale(scale) {}
|
||||
virtual ~DpiChangeEventArgs() {}
|
||||
};
|
||||
// 为 OnPaint 事件提供数据。
|
||||
class UI_EXPORT PaintEventArgs :public EventArgs {
|
||||
private:
|
||||
std::list<bool> m_layers;
|
||||
std::list<Point> m_offsets;
|
||||
public:
|
||||
PaintEventArgs(const PaintEventArgs&) = delete;
|
||||
PaintEventArgs& operator=(const PaintEventArgs&) = delete;
|
||||
WindowContext* PublicData = NULL;
|
||||
::HWND HWND = NULL;
|
||||
HDC DC = NULL;
|
||||
ezui::DXRender& Graphics;//画家
|
||||
Rect InvalidRectangle;//WM_PAINT里面的无效区域
|
||||
PaintEventArgs(ezui::DXRender& _painter) : EventArgs(Event::OnPaint), Graphics(_painter) {}
|
||||
virtual ~PaintEventArgs() {}
|
||||
//添加裁剪(速度较快)
|
||||
void PushLayer(const Rect& rectBounds);
|
||||
//添加异形裁剪 比较耗性能,但是可以异形抗锯齿裁剪
|
||||
void PushLayer(const Geometry& dxGeometry, float opacity);
|
||||
//弹出最后一个裁剪
|
||||
void PopLayer();
|
||||
//放入一个偏移
|
||||
void PushOffset(const Point& offset);
|
||||
//弹出最后一个偏移
|
||||
void PopOffset();
|
||||
};
|
||||
// 为控件样式提供数据。
|
||||
class UI_EXPORT ControlStyle {
|
||||
public:
|
||||
//边框信息
|
||||
ezui::Border Border;
|
||||
//背景颜色
|
||||
Value<Color> BackColor;
|
||||
//背景图片 如果指定的图片被删除 请必须将此置零
|
||||
Value<Image*> BackImage;
|
||||
//前景图片 如果指定的图片被删除 请必须将此置零
|
||||
Value<Image*> ForeImage;
|
||||
//字体名称 具有继承性
|
||||
Value<std::wstring> FontFamily;
|
||||
//字体大小 具有继承性
|
||||
Value<int> FontSize;
|
||||
//字体粗度 值范围1~999 如需加粗一般为700即可 具有继承性值
|
||||
Value<int> FontWeight;
|
||||
//前景颜色 具有继承性
|
||||
Value<Color> ForeColor;
|
||||
//鼠标样式
|
||||
Value<HCURSOR> Cursor;
|
||||
//正数角度(0~ 360) -> 逆时针旋转
|
||||
//负数角度(0~ -360) -> 顺时针旋转
|
||||
Value<float> Angle;
|
||||
//透明度(0~1.0)
|
||||
Value<float> Opacity;
|
||||
private:
|
||||
void operator=(const ControlStyle& right) {} //禁止直接赋值 因为这样会导致 Color执行拷贝使得Color变得不合法的有效
|
||||
ControlStyle(const ControlStyle& right) {} //禁止拷贝
|
||||
public:
|
||||
ControlStyle() {
|
||||
Angle.Set(std::numeric_limits<float>::quiet_NaN());
|
||||
Opacity.Set(std::numeric_limits<float>::quiet_NaN());
|
||||
}
|
||||
virtual ~ControlStyle() {}
|
||||
void Scale(float scale);
|
||||
};
|
||||
|
||||
//指针管理
|
||||
template <typename T>
|
||||
class PtrManager {
|
||||
private:
|
||||
std::vector<T> m_ptrs;
|
||||
public:
|
||||
PtrManager() {}
|
||||
virtual ~PtrManager() {
|
||||
this->Clear();
|
||||
}
|
||||
void Add(const T& v) {
|
||||
if (v) {
|
||||
m_ptrs.push_back(v);
|
||||
}
|
||||
}
|
||||
void Remove(const T& v) {
|
||||
auto it = std::find(m_ptrs.begin(), m_ptrs.end(), v);
|
||||
if (it != m_ptrs.end()) {
|
||||
m_ptrs.erase(it);
|
||||
}
|
||||
}
|
||||
void Clear() {
|
||||
auto itor = m_ptrs.begin();
|
||||
while (itor != m_ptrs.end())
|
||||
{
|
||||
T item = *itor;
|
||||
itor = m_ptrs.erase(itor); // erase 返回下一个有效迭代器
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//常用对象基类
|
||||
class UI_EXPORT Object {
|
||||
private:
|
||||
//属性集合
|
||||
std::map<UIString, UIString> m_attrs;
|
||||
// 管理子对象的释放
|
||||
PtrManager<Object*> m_childObjects;
|
||||
//是否正在被销毁
|
||||
bool m_bIsDestroying = false;
|
||||
public:
|
||||
//用户自定义数据
|
||||
UINT_PTR Tag = NULL;
|
||||
public:
|
||||
Object(Object* ownerObject = NULL);
|
||||
virtual ~Object();
|
||||
public:
|
||||
//设置属性
|
||||
virtual void SetAttribute(const UIString& attrName, const UIString& attrValue);
|
||||
//获取属性
|
||||
virtual UIString GetAttribute(const UIString& attrName);
|
||||
//获取全部属性
|
||||
virtual const std::map<UIString, UIString>& GetAttributes();
|
||||
//移除某个属性
|
||||
virtual void RemoveAttribute(const UIString& attrName);
|
||||
//绑定对象(跟随释放)
|
||||
virtual Object* Attach(Object* obj);
|
||||
//分离对象(解除跟随释放)
|
||||
virtual void Detach(Object* obj);
|
||||
//对象是否正在被销毁(预防析构降级导致控件访问报错)
|
||||
bool IsDestroying();
|
||||
//延迟删除
|
||||
void DeleteLater();
|
||||
};
|
||||
|
||||
//原理采用PostMessage
|
||||
template<class Func, class... Args>
|
||||
bool BeginInvoke(Func&& f, Args&& ...args) {
|
||||
HWND hWnd = ezui::detail::__EzUI_MessageWnd;
|
||||
if (hWnd == NULL || !::IsWindow(hWnd)) {
|
||||
return false;
|
||||
}
|
||||
std::function<void()>* func = new std::function<void()>(std::bind(std::forward<Func>(f), std::forward<Args>(args)...));
|
||||
if (::PostMessage(hWnd, WM_GUI_SYSTEM, WM_GUI_BEGININVOKE, (LPARAM)func) == LRESULT(0)) {
|
||||
delete func;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//原理采用SendMessage
|
||||
template<class Func, class... Args>
|
||||
bool Invoke(Func&& f, Args&& ...args) {
|
||||
std::function<void()> func(std::bind(std::forward<Func>(f), std::forward<Args>(args)...));
|
||||
if (::GetCurrentThreadId() == ezui::detail::__EzUI__ThreadId) {
|
||||
func();
|
||||
return true;
|
||||
}
|
||||
HWND hWnd = ezui::detail::__EzUI_MessageWnd;
|
||||
if (hWnd == NULL || !::IsWindow(hWnd)) {
|
||||
return false;
|
||||
}
|
||||
if (::SendMessage(hWnd, WM_GUI_SYSTEM, WM_GUI_INVOKE, (LPARAM)&func) == LRESULT(-1)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//统计函数耗时
|
||||
template<class Func, class... Args>
|
||||
int64_t StopWatch(Func&& f, Args&& ...args) {
|
||||
auto beginTime = std::chrono::steady_clock::now();
|
||||
std::forward<Func>(f)(std::forward<Args>(args)...);
|
||||
auto delta = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - beginTime).count();
|
||||
return delta;
|
||||
}
|
||||
|
||||
};
|
||||
29
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Frame.h
vendored
Normal file
29
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Frame.h
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
#include "EzUI.h"
|
||||
#include "UILoader.h"
|
||||
|
||||
namespace ezui {
|
||||
//内联页面 内部控件与外部隔离
|
||||
class UI_EXPORT Frame :public Control {
|
||||
private:
|
||||
UILoader m_loader;//内部UI管理器
|
||||
public:
|
||||
//对外暴露消息通知回调
|
||||
std::function<void(Control*, EventArgs&)> NotifyHandler = NULL;
|
||||
Frame(Object* ownerObject = NULL);
|
||||
virtual ~Frame();
|
||||
//是否为Frame
|
||||
virtual bool IsFrame()override final;
|
||||
//从文件中加载xml
|
||||
void LoadXml(const UIString& fileName);
|
||||
//设置唯一布局
|
||||
void SetLayout(Control* ctrl);
|
||||
//获取布局
|
||||
Control* GetLayout();
|
||||
virtual void SetAttribute(const UIString& attrName, const UIString& attrValue)override;
|
||||
//消息通知
|
||||
virtual void OnNotify(Control* sender, EventArgs& args);
|
||||
//获取UI管理器
|
||||
UILoader* GetUILoader();
|
||||
};
|
||||
};
|
||||
24
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/HLayout.h
vendored
Normal file
24
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/HLayout.h
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT HLayout :
|
||||
public Control
|
||||
{
|
||||
private:
|
||||
VAlign m_contentAlign = VAlign::Mid;
|
||||
protected:
|
||||
void DistributeAutoWidths(std::vector<Control*> const& autoSizeCtrls, int availableWidth);
|
||||
virtual void OnLayout()override;
|
||||
public:
|
||||
HLayout(Object* ownerObject = NULL);
|
||||
// 添加一个弹簧控件:
|
||||
// - 传入 fixedWidth > 0,则作为固定高度的空白,位不可伸缩
|
||||
// - 传入 fixedWidth == 0,则作为可拉伸的弹簧,占据剩余空间
|
||||
void AddSpacer(int fixedWidth = 0);
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
void SetContentAlign(VAlign contentAlign);
|
||||
virtual ~HLayout();
|
||||
};
|
||||
using HBox = HLayout;
|
||||
};
|
||||
24
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/HListView.h
vendored
Normal file
24
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/HListView.h
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "PagedListView.h"
|
||||
#include "HScrollBar.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT HListView :
|
||||
public PagedListView
|
||||
{
|
||||
private:
|
||||
VAlign m_contentAlign = VAlign::Mid;
|
||||
HScrollBar m_hScrollBar;
|
||||
void Init();
|
||||
void Offset(int offset);
|
||||
protected:
|
||||
virtual void OnLayout()override;
|
||||
virtual void OnChildPaint(PaintEventArgs& args)override;
|
||||
public:
|
||||
HListView(Object* ownerObject = NULL);
|
||||
virtual ~HListView();
|
||||
void SetContentAlign(VAlign contentAlign);
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
virtual ScrollBar* GetScrollBar()override;
|
||||
};
|
||||
};
|
||||
21
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/HScrollBar.h
vendored
Normal file
21
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/HScrollBar.h
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
#include "ScrollBar.h"
|
||||
|
||||
namespace ezui {
|
||||
|
||||
class UI_EXPORT HScrollBar :
|
||||
public ScrollBar
|
||||
{
|
||||
protected:
|
||||
virtual void OnMouseDown(const MouseEventArgs& arg)override;
|
||||
virtual void OnMouseMove(const MouseEventArgs& arg)override;
|
||||
virtual void GetInfo(int* viewLength, int* contentLength, int* scrollBarLength)override;
|
||||
virtual void OnParentSize(const Size& parentSize)override;
|
||||
public:
|
||||
HScrollBar(Object* ownerObject = NULL);
|
||||
virtual ~HScrollBar();
|
||||
virtual void ScrollTo(Control* ctl)override;
|
||||
virtual Rect GetSliderRect()override;
|
||||
};
|
||||
};
|
||||
36
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Label.h
vendored
Normal file
36
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Label.h
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT Label :
|
||||
public Control
|
||||
{
|
||||
private:
|
||||
std::wstring m_wstr;
|
||||
int m_underlinePos = 0;//显示下划线起始下标
|
||||
int m_underlineCount = 0;//显示下划线文字个数
|
||||
std::wstring m_ellipsisText;//文字溢出将显示的文字
|
||||
protected:
|
||||
virtual void OnForePaint(PaintEventArgs& args) override;
|
||||
virtual void OnDpiChange(const DpiChangeEventArgs& args)override;
|
||||
virtual void OnLayout()override;
|
||||
public:
|
||||
//基于控件的文字的边距
|
||||
ezui::Distance TextMargin;
|
||||
//文字对齐方式
|
||||
TextAlign TextAlign = TextAlign::MiddleCenter;
|
||||
public:
|
||||
Label(Object* ownerObject = NULL);
|
||||
virtual ~Label();
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
virtual void RefreshLayout() override;
|
||||
//设置文字
|
||||
void SetText(const UIString& text);
|
||||
//获取文字
|
||||
UIString GetText()const;
|
||||
//设置文字溢出控件之后的显示文字
|
||||
void SetElidedText(const UIString& text);
|
||||
//设置下划线位置
|
||||
void SetUnderline(int pos, int count);
|
||||
};
|
||||
};
|
||||
30
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/LayeredWindow.h
vendored
Normal file
30
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/LayeredWindow.h
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include "BorderlessWindow.h"
|
||||
#include "Bitmap.h"
|
||||
#include "Task.h"
|
||||
#include "Timer.h"
|
||||
|
||||
namespace ezui {
|
||||
/// <summary>
|
||||
/// //LayeredWindow //无边框 带阴影 窗口透明异形 窗口大小发生改变重绘
|
||||
/// </summary>
|
||||
class UI_EXPORT LayeredWindow :public BorderlessWindow
|
||||
{
|
||||
private:
|
||||
std::list<Rect> m_invalidateRect;
|
||||
Bitmap* m_winBitmap = NULL;
|
||||
void UpdateLayeredWindow(HDC hdc, const Rect& rePaintRect);
|
||||
void BeginPaint(std::vector<Rect>* outRect);
|
||||
void EndPaint();
|
||||
bool Paint();
|
||||
protected:
|
||||
virtual void OnSize(const Size& sz)override;
|
||||
void InvalidateRect(const Rect& rect);
|
||||
virtual LRESULT WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)override;
|
||||
public:
|
||||
//窗口透明度
|
||||
float Opacity = 1.0f;
|
||||
LayeredWindow(int width, int height, HWND owner = NULL, DWORD dwStyle = NULL, DWORD dwExStyle = NULL);
|
||||
virtual ~LayeredWindow();
|
||||
};
|
||||
};
|
||||
20
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Menu.h
vendored
Normal file
20
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Menu.h
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "EzUI.h"
|
||||
|
||||
namespace ezui {
|
||||
//菜单类
|
||||
class UI_EXPORT Menu :public Object
|
||||
{
|
||||
private:
|
||||
HMENU m_hMenu = NULL;
|
||||
public:
|
||||
//菜单子项被选点击的回调事件 UINT:子项ID
|
||||
std::function<void(UINT_PTR)> MouseClick = NULL;
|
||||
Menu(Object* ownerObject = NULL);
|
||||
virtual ~Menu();
|
||||
HMENU HMenu();
|
||||
UINT_PTR Append(const UIString& text);
|
||||
void Remove(const UINT_PTR id);
|
||||
};
|
||||
|
||||
};
|
||||
27
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/NotifyIcon.h
vendored
Normal file
27
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/NotifyIcon.h
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#include "Menu.h"
|
||||
#include <shellapi.h>
|
||||
namespace ezui {
|
||||
//系统托盘类
|
||||
class UI_EXPORT NotifyIcon :public Object
|
||||
{
|
||||
private:
|
||||
HWND m_hWnd = NULL;
|
||||
Menu* m_menu = NULL;
|
||||
NOTIFYICONDATAW m_nid = {};
|
||||
WindowContext m_publicData;
|
||||
protected:
|
||||
virtual LRESULT WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
public:
|
||||
//事件处理 只会返回鼠标事件
|
||||
std::function<void(const MouseEventArgs&)> EventHandler = NULL;
|
||||
NotifyIcon(Object* ownerObject = NULL);
|
||||
void SetIcon(HICON icon);
|
||||
//设置鼠标悬停时显示的提示文本
|
||||
void SetTips(const UIString& text);
|
||||
void SetMenu(Menu* menu);
|
||||
void ShowBalloonTip(const UIString& title, const UIString& msg, int timeOut = 1000);
|
||||
virtual ~NotifyIcon();
|
||||
};
|
||||
|
||||
};
|
||||
39
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/PagedListView.h
vendored
Normal file
39
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/PagedListView.h
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
|
||||
namespace ezui {
|
||||
/**
|
||||
* 是一个分页显示控件集合的容器控件
|
||||
*
|
||||
* 它支持对一批子控件进行分页管理,例如:
|
||||
* - 显示每页固定数量的控件;
|
||||
* - 支持翻页;
|
||||
* - 当控件到达末页时需要手动调用NextPage进行加载下一页;
|
||||
*
|
||||
* 子类:VList/HList/TileList 继承使其具备分页管理的能力
|
||||
*/
|
||||
class UI_EXPORT PagedListView :
|
||||
public Control
|
||||
{
|
||||
private:
|
||||
int m_pageIndex = 0;
|
||||
int m_pageTotal = 0;
|
||||
int m_pageSize = 0;
|
||||
ControlCollection m_items;
|
||||
public:
|
||||
PagedListView(Object* ownerObject = NULL);
|
||||
virtual ~PagedListView();
|
||||
//页面需要加载下一页的时候发生
|
||||
std::function<bool(PagedListView*, int)> NextPaging = NULL;
|
||||
void SetPageInfo(const ControlCollection& items, int pageSize);
|
||||
/// <summary>
|
||||
/// 获取某页的item集合
|
||||
/// </summary>
|
||||
/// <param name="index">1~N</param>
|
||||
/// <param name="outCtls">输出集合</param>
|
||||
void GetPage(int index, ControlCollection* outCtls);
|
||||
virtual void NextPage();
|
||||
virtual void RemoveAll() override;
|
||||
virtual void RemoveAll(bool freeChilds) override;
|
||||
};
|
||||
};
|
||||
21
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/PictureBox.h
vendored
Normal file
21
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/PictureBox.h
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
#include "Timer.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT PictureBox : public Control {
|
||||
private:
|
||||
Timer m_timer;
|
||||
std::shared_ptr<std::atomic<bool>> m_alive;
|
||||
private:
|
||||
void Init();
|
||||
protected:
|
||||
virtual void OnForePaint(PaintEventArgs& arg)override;
|
||||
public:
|
||||
//图片(支持gif图自动播放)
|
||||
Image* Image = NULL;
|
||||
PictureBox(Object* ownerObject = NULL);
|
||||
virtual ~PictureBox();
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
};
|
||||
};
|
||||
22
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/PopupWindow.h
vendored
Normal file
22
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/PopupWindow.h
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "Window.h"
|
||||
#include "BorderlessWindow.h"
|
||||
#include "LayeredWindow.h"
|
||||
|
||||
namespace ezui {
|
||||
/// <summary>
|
||||
/// 弹出式窗口(失去焦点窗口将会关闭) 一般用于做右键菜单等等
|
||||
/// </summary>
|
||||
class UI_EXPORT PopupWindow :public LayeredWindow {
|
||||
private:
|
||||
bool isShowModal = false;
|
||||
protected:
|
||||
virtual void OnKillFocus(HWND hWnd) override;
|
||||
public:
|
||||
//弹出的窗口在拥有窗口前面 ownerHwnd为NULL则置顶窗口
|
||||
PopupWindow(int width, int height, HWND ownerHwnd = NULL);
|
||||
virtual void Show()override;
|
||||
virtual int ShowModal(bool disableOnwer = false)override;
|
||||
virtual ~PopupWindow();
|
||||
};
|
||||
};
|
||||
14
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/RadioButton.h
vendored
Normal file
14
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/RadioButton.h
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "CheckBox.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT RadioButton :
|
||||
public CheckBox
|
||||
{
|
||||
protected:
|
||||
virtual void OnMouseDown(const MouseEventArgs& arg)override;
|
||||
public:
|
||||
RadioButton(Object* ownerObject = NULL);
|
||||
virtual~RadioButton();
|
||||
};
|
||||
};
|
||||
742
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/RenderTypes.h
vendored
Normal file
742
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/RenderTypes.h
vendored
Normal file
@@ -0,0 +1,742 @@
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
|
||||
namespace ezui {
|
||||
//size模式
|
||||
enum class SizeMode {
|
||||
//图片强行拉伸完全填充控件
|
||||
//不裁剪,图片变形
|
||||
Stretch,
|
||||
//图片缩放后完全填充控件
|
||||
//图片会裁剪, 保持比例裁剪和控件同大小
|
||||
Cover,
|
||||
//图片缩放后完整居中显示在控件上
|
||||
//控件会留白
|
||||
Fit,
|
||||
//图片保持原尺寸,
|
||||
//如果图片小于控件: 控件留白,
|
||||
//如果图片大于控件: 控件边界外的部分被裁剪
|
||||
Original
|
||||
};
|
||||
typedef SizeMode ImageSizeMode;
|
||||
|
||||
#if 1
|
||||
#define Align_Top 1
|
||||
#define Align_Bottom 2
|
||||
#define Align_Left 4
|
||||
#define Align_Right 8
|
||||
#define Align_Mid 16
|
||||
#define Align_Center 32
|
||||
#else //GDI
|
||||
#define Align_Top DT_TOP
|
||||
#define Align_Bottom DT_BOTTOM
|
||||
#define Align_Left DT_LEFT
|
||||
#define Align_Right DT_RIGHT
|
||||
#define Align_Mid DT_VCENTER
|
||||
#define Align_Center DT_CENTER
|
||||
#endif
|
||||
/// <summary>
|
||||
/// 水平状态下的对齐方式
|
||||
/// </summary>
|
||||
enum class HAlign :int
|
||||
{
|
||||
Left = Align_Left,
|
||||
Center = Align_Center,
|
||||
Right = Align_Right
|
||||
};
|
||||
EZUI_ENUM_OPERATORS(HAlign, int);
|
||||
|
||||
/// <summary>
|
||||
/// 垂直状态下的对齐方式
|
||||
/// </summary>
|
||||
enum class VAlign :int
|
||||
{
|
||||
Top = Align_Top,
|
||||
Mid = Align_Mid,
|
||||
Bottom = Align_Bottom
|
||||
};
|
||||
EZUI_ENUM_OPERATORS(VAlign, int);
|
||||
|
||||
//包含垂直与水平对齐方式
|
||||
enum class Align :int {
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上顶部对齐,在水平方向上左边对齐。
|
||||
TopLeft = (int)VAlign::Top | (int)HAlign::Left,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上顶部对齐,在水平方向上居中对齐。
|
||||
TopCenter = (int)VAlign::Top | (int)HAlign::Center,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上顶部对齐,在水平方向上右边对齐。
|
||||
TopRight = (int)VAlign::Top | (int)HAlign::Right,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上中间对齐,在水平方向上左边对齐。
|
||||
MiddleLeft = (int)VAlign::Mid | (int)HAlign::Left,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上中间对齐,在水平方向上居中对齐。
|
||||
MiddleCenter = (int)VAlign::Mid | (int)HAlign::Center,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上中间对齐,在水平方向上右边对齐。
|
||||
MiddleRight = (int)VAlign::Mid | (int)HAlign::Right,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上底边对齐,在水平方向上左边对齐。
|
||||
BottomLeft = (int)VAlign::Bottom | (int)HAlign::Left,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上底边对齐,在水平方向上居中对齐。
|
||||
BottomCenter = (int)VAlign::Bottom | (int)HAlign::Center,
|
||||
//
|
||||
// 摘要:
|
||||
// 内容在垂直方向上底边对齐,在水平方向上右边对齐。
|
||||
BottomRight = (int)VAlign::Bottom | (int)HAlign::Right
|
||||
};
|
||||
EZUI_ENUM_OPERATORS(Align, int);
|
||||
|
||||
typedef Align TextAlign;
|
||||
|
||||
enum class FontStyle {
|
||||
NORMAL
|
||||
/* DWRITE_FONT_STYLE_NORMAL
|
||||
字体样式 :正常。
|
||||
DWRITE_FONT_STYLE_OBLIQUE
|
||||
字体样式 :倾斜。
|
||||
DWRITE_FONT_STYLE_ITALIC
|
||||
字体样式 :斜体。 */
|
||||
};
|
||||
|
||||
//描边样式
|
||||
enum class StrokeStyle
|
||||
{
|
||||
None,//无
|
||||
Solid,//实线
|
||||
Dash//虚线
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
class __EzUI__Size
|
||||
{
|
||||
public:
|
||||
T Width;
|
||||
T Height;
|
||||
public:
|
||||
__EzUI__Size()
|
||||
{
|
||||
Width = Height = 0;
|
||||
}
|
||||
__EzUI__Size(const __EzUI__Size& __Size)
|
||||
{
|
||||
Width = __Size.Width;
|
||||
Height = __Size.Height;
|
||||
}
|
||||
__EzUI__Size(T width,
|
||||
T height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
bool operator!=(const __EzUI__Size& _right) const
|
||||
{
|
||||
return !(Width == _right.Width && Height == _right.Height);
|
||||
}
|
||||
void Scale(float scale) {
|
||||
Width = (Width * scale) + 0.5;
|
||||
Height = (Height * scale) + 0.5;
|
||||
}
|
||||
bool Equals(const __EzUI__Size& sz) const
|
||||
{
|
||||
return (Width == sz.Width) && (Height == sz.Height);
|
||||
}
|
||||
bool Empty() const
|
||||
{
|
||||
return (Width == 0 && Height == 0);
|
||||
}
|
||||
__EzUI__Size operator+(const __EzUI__Size& sz) const
|
||||
{
|
||||
return __EzUI__Size(Width + sz.Width,
|
||||
Height + sz.Height);
|
||||
}
|
||||
__EzUI__Size operator-(const __EzUI__Size& sz) const
|
||||
{
|
||||
return __EzUI__Size(Width - sz.Width,
|
||||
Height - sz.Height);
|
||||
}
|
||||
|
||||
bool operator==(const __EzUI__Size& _right) const
|
||||
{
|
||||
return Equals(_right);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class __EzUI__Point
|
||||
{
|
||||
public:
|
||||
T X;
|
||||
T Y;
|
||||
public:
|
||||
__EzUI__Point()
|
||||
{
|
||||
X = Y = 0;
|
||||
}
|
||||
|
||||
__EzUI__Point(const __EzUI__Point& __Point)
|
||||
{
|
||||
X = __Point.X;
|
||||
Y = __Point.Y;
|
||||
}
|
||||
|
||||
__EzUI__Point(const __EzUI__Size<T>& __Size)
|
||||
{
|
||||
X = __Size.Width;
|
||||
Y = __Size.Height;
|
||||
}
|
||||
|
||||
__EzUI__Point(T x,
|
||||
T y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
void Scale(float scale) {
|
||||
X = (X * scale) + 0.5;
|
||||
Y = (Y * scale) + 0.5;
|
||||
}
|
||||
bool Equals(const __EzUI__Point& __Point)const
|
||||
{
|
||||
return (X == __Point.X) && (Y == __Point.Y);
|
||||
}
|
||||
__EzUI__Point operator+(const __EzUI__Point& __Point) const
|
||||
{
|
||||
return __Point(X + __Point.X,
|
||||
Y + __Point.Y);
|
||||
}
|
||||
__EzUI__Point operator-(const __EzUI__Point& __Point) const
|
||||
{
|
||||
return __Point(X - __Point.X,
|
||||
Y - __Point.Y);
|
||||
}
|
||||
bool operator==(const __EzUI__Point& __Point) const
|
||||
{
|
||||
return Equals(__Point);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class __EzUI__Rect
|
||||
{
|
||||
public:
|
||||
T X;
|
||||
T Y;
|
||||
T Width;
|
||||
T Height;
|
||||
public:
|
||||
|
||||
__EzUI__Rect()
|
||||
{
|
||||
X = Y = Width = Height = 0;
|
||||
}
|
||||
|
||||
__EzUI__Rect(T x,
|
||||
T y,
|
||||
T width,
|
||||
T height)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
__EzUI__Rect(const RECT& rect) {
|
||||
X = rect.left;
|
||||
Y = rect.top;
|
||||
Width = rect.right - rect.left;
|
||||
Height = rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
__EzUI__Rect(const __EzUI__Point<T>& location, const __EzUI__Size<T>& size) {
|
||||
X = location.X;
|
||||
Y = location.Y;
|
||||
Width = size.Width;
|
||||
Height = size.Height;
|
||||
}
|
||||
|
||||
__EzUI__Point<T> GetLocation() const
|
||||
{
|
||||
return __EzUI__Point<T>{ X, Y };
|
||||
}
|
||||
|
||||
__EzUI__Size<T> GetSize() const
|
||||
{
|
||||
return __EzUI__Size<T>(Width, Height);
|
||||
}
|
||||
|
||||
RECT ToRECT() const {
|
||||
return RECT{ (LONG)GetLeft(), (LONG)GetTop(), (LONG)GetRight(), (LONG)GetBottom() };
|
||||
}
|
||||
|
||||
T GetLeft() const
|
||||
{
|
||||
return X;
|
||||
}
|
||||
|
||||
T GetTop() const
|
||||
{
|
||||
return Y;
|
||||
}
|
||||
T GetRight() const
|
||||
{
|
||||
return X + Width;
|
||||
}
|
||||
T GetBottom() const
|
||||
{
|
||||
return Y + Height;
|
||||
}
|
||||
bool IsEmptyArea() const
|
||||
{
|
||||
return (Width <= 0) || (Height <= 0);
|
||||
}
|
||||
|
||||
virtual const __EzUI__Rect& Scale(float scale) {
|
||||
X = T((X * scale) + 0.5);
|
||||
Y = T((Y * scale) + 0.5);
|
||||
Width = T((Width * scale) + 0.5);
|
||||
Height = T((Height * scale) + 0.5);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Equals(const __EzUI__Rect& __Rect) const
|
||||
{
|
||||
return X == __Rect.X &&
|
||||
Y == __Rect.Y &&
|
||||
Width == __Rect.Width &&
|
||||
Height == __Rect.Height;
|
||||
}
|
||||
|
||||
bool operator == (const __EzUI__Rect& right) {
|
||||
return Equals(right);
|
||||
}
|
||||
|
||||
__EzUI__Rect& operator+=(T value) {
|
||||
X -= value;
|
||||
Y -= value;
|
||||
Width += value * 2;
|
||||
Height += value * 2;
|
||||
return *this;
|
||||
}
|
||||
__EzUI__Rect& operator-=(T value) {
|
||||
X += value;
|
||||
Y += value;
|
||||
Width -= value * 2;
|
||||
Height -= value * 2;
|
||||
return *this;
|
||||
}
|
||||
__EzUI__Rect operator+(T value) const {
|
||||
__EzUI__Rect out = *this;
|
||||
out += value;
|
||||
return out;
|
||||
}
|
||||
__EzUI__Rect operator-(T value) const {
|
||||
__EzUI__Rect out = *this;
|
||||
out -= value;
|
||||
return out;
|
||||
}
|
||||
|
||||
bool Contains(T x,
|
||||
T y) const
|
||||
{
|
||||
return x >= X && x < X + Width &&
|
||||
y >= Y && y < Y + Height;
|
||||
}
|
||||
|
||||
bool Contains(const __EzUI__Point<T>& pt) const
|
||||
{
|
||||
return Contains(pt.X, pt.Y);
|
||||
}
|
||||
|
||||
bool Contains(const __EzUI__Rect& __Rect) const
|
||||
{
|
||||
return (X <= __Rect.X) && (__Rect.GetRight() <= GetRight()) &&
|
||||
(Y <= __Rect.Y) && (__Rect.GetBottom() <= GetBottom());
|
||||
|
||||
}
|
||||
|
||||
void Inflate(T dx,
|
||||
T dy)
|
||||
{
|
||||
X -= dx;
|
||||
Y -= dy;
|
||||
Width += 2 * dx;
|
||||
Height += 2 * dy;
|
||||
}
|
||||
|
||||
void Inflate(const __EzUI__Point<T>& point)
|
||||
{
|
||||
Inflate(point.X, point.Y);
|
||||
}
|
||||
|
||||
bool Intersect(const __EzUI__Rect& __Rect)
|
||||
{
|
||||
return Intersect(*this, *this, __Rect);
|
||||
}
|
||||
|
||||
static bool Intersect(__EzUI__Rect& c,
|
||||
const __EzUI__Rect& a,
|
||||
const __EzUI__Rect& b)
|
||||
{
|
||||
T right = min(a.GetRight(), b.GetRight());
|
||||
T bottom = min(a.GetBottom(), b.GetBottom());
|
||||
T left = max(a.GetLeft(), b.GetLeft());
|
||||
T top = max(a.GetTop(), b.GetTop());
|
||||
|
||||
c.X = left;
|
||||
c.Y = top;
|
||||
c.Width = right - left;
|
||||
c.Height = bottom - top;
|
||||
return !c.IsEmptyArea();
|
||||
}
|
||||
|
||||
bool IntersectsWith(const __EzUI__Rect& __Rect) const
|
||||
{
|
||||
return (GetLeft() < __Rect.GetRight() &&
|
||||
GetTop() < __Rect.GetBottom() &&
|
||||
GetRight() > __Rect.GetLeft() &&
|
||||
GetBottom() > __Rect.GetTop());
|
||||
}
|
||||
|
||||
static bool Union(__EzUI__Rect& c,
|
||||
const __EzUI__Rect& a,
|
||||
const __EzUI__Rect& b)
|
||||
{
|
||||
|
||||
if (a.IsEmptyArea()) {
|
||||
c = b;
|
||||
return !c.IsEmptyArea();
|
||||
}
|
||||
if (b.IsEmptyArea()) {
|
||||
c = a;
|
||||
return !c.IsEmptyArea();
|
||||
}
|
||||
|
||||
T right = max(a.GetRight(), b.GetRight());
|
||||
T bottom = max(a.GetBottom(), b.GetBottom());
|
||||
T left = min(a.GetLeft(), b.GetLeft());
|
||||
T top = min(a.GetTop(), b.GetTop());
|
||||
|
||||
c.X = left;
|
||||
c.Y = top;
|
||||
c.Width = right - left;
|
||||
c.Height = bottom - top;
|
||||
return !c.IsEmptyArea();
|
||||
}
|
||||
void Offset(const __EzUI__Point<T>& point)
|
||||
{
|
||||
Offset(point.X, point.Y);
|
||||
}
|
||||
void Offset(T dx,
|
||||
T dy)
|
||||
{
|
||||
X += dx;
|
||||
Y += dy;
|
||||
}
|
||||
virtual ~__EzUI__Rect() {}
|
||||
};
|
||||
|
||||
class __EzUI__Color
|
||||
{
|
||||
protected:
|
||||
uint32_t BGRA = 0;
|
||||
public:
|
||||
__EzUI__Color() {}
|
||||
__EzUI__Color(
|
||||
const uint8_t& r,
|
||||
const uint8_t& g,
|
||||
const uint8_t& b,
|
||||
const uint8_t& a = 255)
|
||||
{
|
||||
BGRA |= static_cast<uint32_t>(b); // 蓝色占最低8位
|
||||
BGRA |= static_cast<uint32_t>(g) << 8; // 绿色占第2字节
|
||||
BGRA |= static_cast<uint32_t>(r) << 16; // 红色占第3字节
|
||||
BGRA |= static_cast<uint32_t>(a) << 24; // Alpha 占最高字节
|
||||
}
|
||||
__EzUI__Color(uint32_t bgra)
|
||||
{
|
||||
BGRA = bgra;
|
||||
}
|
||||
virtual ~__EzUI__Color() {}
|
||||
uint8_t GetR() const {
|
||||
return (BGRA >> 16) & 0xFF;
|
||||
}
|
||||
uint8_t GetG() const {
|
||||
return (BGRA >> 8) & 0xFF;
|
||||
}
|
||||
uint8_t GetB() const {
|
||||
return BGRA & 0xFF;
|
||||
}
|
||||
uint8_t GetA() const {
|
||||
return (BGRA >> 24) & 0xFF;
|
||||
}
|
||||
uint32_t GetValue() const
|
||||
{
|
||||
return BGRA;
|
||||
}
|
||||
void SetValue(uint32_t bgra)
|
||||
{
|
||||
BGRA = bgra;
|
||||
}
|
||||
void SetR(uint8_t value) {
|
||||
BGRA = (BGRA & 0xFF00FFFF) | (uint32_t(value) << 16);
|
||||
}
|
||||
void SetG(uint8_t value) {
|
||||
BGRA = (BGRA & 0xFFFF00FF) | (uint32_t(value) << 8);
|
||||
}
|
||||
void SetB(uint8_t value) {
|
||||
BGRA = (BGRA & 0xFFFFFF00) | uint32_t(value);
|
||||
}
|
||||
void SetA(uint8_t value) {
|
||||
BGRA = (BGRA & 0x00FFFFFF) | (uint32_t(value) << 24);
|
||||
}
|
||||
|
||||
public:
|
||||
// Common color constants (BGRA format)
|
||||
enum : uint32_t
|
||||
{
|
||||
Transparent = 0x00000000, // 全透明
|
||||
Red = 0xFFFF0000, // 红色
|
||||
Yellow = 0xFFFFFF00, // 黄色
|
||||
Blue = 0xFF0000FF, // 蓝色
|
||||
Black = 0xFF000000, // 黑色
|
||||
White = 0xFFFFFFFF, // 白色
|
||||
Green = 0xFF008000, // 绿色
|
||||
Orange = 0xFFFFA500, // 橙色
|
||||
Purple = 0xFF800080, // 紫色
|
||||
Gray = 0xFF808080 // 灰色
|
||||
};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class __EzUI__Line {
|
||||
public:
|
||||
__EzUI__Point<T> pointA;
|
||||
__EzUI__Point<T> pointB;
|
||||
public:
|
||||
__EzUI__Line() {
|
||||
pointA.X = 0;
|
||||
pointA.Y = 0;
|
||||
pointB.X = 0;
|
||||
pointB.Y = 0;
|
||||
}
|
||||
__EzUI__Line(const __EzUI__Point<T>& _pointA, const __EzUI__Point<T>& _pointB) {
|
||||
this->pointA = _pointA;
|
||||
this->pointB = _pointB;
|
||||
}
|
||||
};
|
||||
|
||||
typedef __EzUI__Point<int> Point;
|
||||
typedef __EzUI__Point<float> PointF;
|
||||
typedef __EzUI__Line<int> Line;
|
||||
typedef __EzUI__Line<float> LineF;
|
||||
typedef __EzUI__Size<int> Size;
|
||||
typedef __EzUI__Rect<int> Rect;
|
||||
|
||||
class SizeF :public __EzUI__Size<float> {
|
||||
public:
|
||||
SizeF()
|
||||
{
|
||||
Width = Height = 0;
|
||||
}
|
||||
SizeF(float width,
|
||||
float height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
SizeF(const SizeF& __Size)
|
||||
{
|
||||
Width = __Size.Width;
|
||||
Height = __Size.Height;
|
||||
}
|
||||
SizeF(const Size& __Size)
|
||||
{
|
||||
Width = (float)__Size.Width;
|
||||
Height = (float)__Size.Height;
|
||||
}
|
||||
};
|
||||
|
||||
class RectF :public __EzUI__Rect<float> {
|
||||
public:
|
||||
RectF() {
|
||||
this->X = 0;
|
||||
this->Y = 0;
|
||||
this->Width = 0;
|
||||
this->Height = 0;
|
||||
}
|
||||
RectF(const Rect& rect) {
|
||||
this->X = (float)rect.X;
|
||||
this->Y = (float)rect.Y;
|
||||
this->Width = (float)rect.Width;
|
||||
this->Height = (float)rect.Height;
|
||||
}
|
||||
RectF(const RectF& rect) {
|
||||
this->X = rect.X;
|
||||
this->Y = rect.Y;
|
||||
this->Width = rect.Width;
|
||||
this->Height = rect.Height;
|
||||
}
|
||||
RectF(float x, float y, float width, float height) {
|
||||
this->X = x;
|
||||
this->Y = y;
|
||||
this->Width = width;
|
||||
this->Height = height;
|
||||
}
|
||||
virtual const RectF& Scale(float scale) {
|
||||
X = (X * scale);
|
||||
Y = (Y * scale);
|
||||
Width = (Width * scale);
|
||||
Height = (Height * scale);
|
||||
return *this;
|
||||
}
|
||||
//转换
|
||||
static RectF Transformation(SizeMode sizeMode, const RectF& container, const SizeF& contentSize) {
|
||||
if (sizeMode == SizeMode::Stretch) {
|
||||
return container;
|
||||
}
|
||||
//容器数据
|
||||
float containerWidth = container.Width;
|
||||
float containerHeight = container.Height;
|
||||
float containerRatio = containerWidth / containerHeight;//宽高比
|
||||
//内容数据
|
||||
float contentWidth = contentSize.Width;
|
||||
float contentHeight = contentSize.Height;
|
||||
float contentRatio = contentWidth / contentHeight; //宽高比
|
||||
|
||||
if (sizeMode == SizeMode::Fit) {
|
||||
if (containerRatio < contentRatio) {
|
||||
float zoomHeight = containerWidth / contentWidth * contentHeight;
|
||||
float y = (containerHeight - zoomHeight) / 2.0f + container.Y;
|
||||
return RectF(container.X, y, containerWidth, zoomHeight);
|
||||
}
|
||||
else {
|
||||
float zoomWidth = containerHeight / contentHeight * contentWidth;
|
||||
float x = (containerWidth - zoomWidth) / 2.0f + container.X;
|
||||
return RectF(x, container.Y, zoomWidth, containerHeight);
|
||||
}
|
||||
}
|
||||
if (sizeMode == SizeMode::Cover) {
|
||||
if (containerRatio < contentRatio) {
|
||||
//1000 670 容器大小
|
||||
//1000 300 内容大小
|
||||
//2233 670 缩放后的内容大小
|
||||
float zoomWidth = containerHeight / contentHeight * contentWidth;//内容应该这么宽才对
|
||||
float x = (zoomWidth - containerWidth) / 2.0f;
|
||||
return RectF(container.X - x, container.Y, zoomWidth, containerHeight);
|
||||
}
|
||||
else {
|
||||
//1000 600 容器大小
|
||||
//400 600 内容大小
|
||||
//1000 1500 缩放后的内容大小
|
||||
float zoomHeight = containerWidth / contentWidth * contentHeight;//内容应该这么高才对
|
||||
float y = (zoomHeight - containerHeight) / 2.0f;
|
||||
return RectF(container.X, container.Y - y, containerWidth, zoomHeight);
|
||||
}
|
||||
}
|
||||
//按照内容原大小居中显示
|
||||
if (sizeMode == SizeMode::Original) {
|
||||
float x = (container.Width - contentSize.Width) / 2.0f;
|
||||
float y = (container.Height - contentSize.Height) / 2.0f;
|
||||
return RectF(x, y, contentSize.Width, contentSize.Height);
|
||||
}
|
||||
return container;
|
||||
}
|
||||
virtual ~RectF() {};
|
||||
};
|
||||
|
||||
//可以控制值开关的模板类
|
||||
template<typename T>
|
||||
class Value {
|
||||
bool m_enable = false;
|
||||
T m_value{};
|
||||
public:
|
||||
Value() = default;
|
||||
Value(const T& value) : m_value(value), m_enable(true) {}
|
||||
Value& operator=(const T& value) {
|
||||
m_value = value;
|
||||
m_enable = true;
|
||||
return *this;
|
||||
}
|
||||
Value(const Value& rightValue)
|
||||
: m_value(rightValue.m_value), m_enable(rightValue.m_enable) {
|
||||
}
|
||||
Value& operator=(const Value& rightValue) {
|
||||
if (this != &rightValue) {
|
||||
m_value = rightValue.m_value;
|
||||
m_enable = rightValue.m_enable;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
void Set(const T& value) { m_value = value; }
|
||||
void SetEnabled(bool bEnable) { m_enable = bEnable; }
|
||||
bool IsEnabled() const { return m_enable; }
|
||||
operator T() const { return m_enable ? m_value : T{}; }
|
||||
T& operator->() { return m_value; }
|
||||
};
|
||||
|
||||
|
||||
struct Distance {
|
||||
public:
|
||||
int16_t Left, Top, Right, Bottom;
|
||||
Distance() {
|
||||
Left = Top = Right = Bottom = 0;
|
||||
}
|
||||
Distance(int16_t distanceAll) {
|
||||
Left = Top = Right = Bottom = distanceAll;
|
||||
}
|
||||
Distance& operator=(int16_t distanceAll) {
|
||||
Left = Top = Right = Bottom = distanceAll;
|
||||
return *this;
|
||||
}
|
||||
void Scale(float scale) {
|
||||
Top = int16_t(Top * scale + 0.5);
|
||||
Bottom = int16_t(Bottom * scale + 0.5);
|
||||
Left = int16_t(Left * scale + 0.5);
|
||||
Right = int16_t(Right * scale + 0.5);
|
||||
}
|
||||
//获取垂直所占空间
|
||||
int16_t GetVSpace() const {
|
||||
return Top + Bottom;
|
||||
}
|
||||
//获取水平所占空间
|
||||
int16_t GetHSpace() const {
|
||||
return Left + Right;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class IImage {
|
||||
protected:
|
||||
int m_frameCount = 0;//总帧数
|
||||
int m_framePos = 0;//当前帧率索引
|
||||
public:
|
||||
Rect Clip;//取出图像部分区域进行绘制
|
||||
Point DrawPosition;//绘制在owner矩形坐标
|
||||
ezui::Size DrawSize;//绘制在owner矩形的大小
|
||||
ImageSizeMode SizeMode = ImageSizeMode::Fit;// 图像显示模式
|
||||
public:
|
||||
virtual ~IImage() {}
|
||||
int FrameCount() {
|
||||
return m_frameCount;
|
||||
}
|
||||
//跳转到下一帧 并且获取下一帧的延迟
|
||||
virtual int NextFrame() = 0;
|
||||
};
|
||||
|
||||
};
|
||||
50
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Resource.h
vendored
Normal file
50
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Resource.h
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include "UIString.h"
|
||||
|
||||
namespace ezui {
|
||||
/// <summary>
|
||||
/// 框架中的资源类
|
||||
/// </summary>
|
||||
class UI_EXPORT Resource {
|
||||
public:
|
||||
struct Entry {
|
||||
std::streampos Offset = 0;//偏移
|
||||
std::streamsize Size = 0;//大小
|
||||
UIString Name;//名称
|
||||
};
|
||||
//资源文件读取流
|
||||
class UI_EXPORT ReadStream {
|
||||
std::streampos m_pos = 0;
|
||||
std::streamsize m_count = 0;
|
||||
const char* m_ptr = NULL;
|
||||
std::ifstream* m_ifs = NULL;
|
||||
public:
|
||||
ReadStream(HRSRC hRsrc);
|
||||
ReadStream(const UIString& fileName);
|
||||
void seekg(std::streampos pos);
|
||||
void read(char* buf, std::streamsize count);
|
||||
std::streampos tellg();
|
||||
const std::streamsize size();
|
||||
virtual ~ReadStream();
|
||||
};
|
||||
private:
|
||||
ReadStream* m_rStream = NULL;
|
||||
void UnPackage();
|
||||
bool m_isGood = false;
|
||||
public:
|
||||
const std::list<Entry> Items;
|
||||
bool IsGood();
|
||||
//对资源目录进行打包
|
||||
static bool Package(const UIString& dir, const UIString& outFile, const std::function<void(const UIString&, int, int)>& packCallback = NULL);
|
||||
public:
|
||||
virtual ~Resource();
|
||||
//从本地文件创建资源对象
|
||||
Resource(const UIString& resFile);
|
||||
//使用windows内置资源文件创建资源对象
|
||||
Resource(HRSRC hRsrc);
|
||||
//寻找资源中的文件
|
||||
bool GetFile(const UIString& fileName, std::string* out);
|
||||
//传入item直接返回数据
|
||||
void GetFile(const Entry& item, std::string* out);
|
||||
};
|
||||
};
|
||||
73
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/ScrollBar.h
vendored
Normal file
73
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/ScrollBar.h
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
#include "Animation.h"
|
||||
namespace ezui {
|
||||
class UI_EXPORT ScrollBar :public Control {
|
||||
friend class VScrollBar;
|
||||
friend class HScrollBar;
|
||||
friend class Control;
|
||||
private:
|
||||
//鼠标是否已经按下
|
||||
bool m_mouseDown = false;
|
||||
//上一次鼠标命中的坐标
|
||||
int m_lastPoint = 0;
|
||||
//滚动条当前的坐标
|
||||
double m_sliderPos = 0;
|
||||
//滚动条的长度
|
||||
int m_sliderLength = 0;
|
||||
//滚动条每滚动一次的比率
|
||||
double m_rollRate = 0;
|
||||
//父容器内的坐标偏移
|
||||
int m_offset = 0;
|
||||
//父容器的内容长度
|
||||
int m_contentLength = 0;
|
||||
//父容器可见长度(容器自身长度)
|
||||
int m_viewLength = 0;
|
||||
//溢出容器的长度
|
||||
int m_overflowLength = 0;
|
||||
|
||||
//int _old_viewLength = 0;
|
||||
//int _old_contentLength = 0;
|
||||
//int _old_offset = 0;
|
||||
float m_velocity = 0; // 当前滚动速度
|
||||
Animation m_amt;//动画
|
||||
private:
|
||||
void Init();
|
||||
public:
|
||||
//滚动条计算出偏移之后的回调函数
|
||||
std::function<void(int)> OffsetCallback = NULL;
|
||||
//滚动事件 arg1:发送者 arg2:滚动百分比 arg3:滚动类型
|
||||
std::function<void(ScrollBar*, float, Event)> Scroll = NULL;
|
||||
protected:
|
||||
virtual void OnBackgroundPaint(PaintEventArgs& arg)override;
|
||||
virtual void OnForePaint(PaintEventArgs& args) override;
|
||||
virtual void OnMouseDown(const MouseEventArgs& arg)override;
|
||||
virtual void OnMouseUp(const MouseEventArgs& arg)override;
|
||||
virtual void OnMouseLeave(const MouseEventArgs& arg) override;
|
||||
virtual void OnMouseWheel(const MouseEventArgs& arg)override;
|
||||
virtual void GetInfo(int* viewLength, int* contentLength, int* scrollBarLength) = 0;
|
||||
virtual void OnParentSize(const Size& parentSize) = 0;
|
||||
void ScrollTo(int offset, const Event& type);
|
||||
//刷新滚动条状态,根据内容长度和视口长度重新计算滑块参数
|
||||
void Recalc();
|
||||
public:
|
||||
//滚动到指定控件可见位置
|
||||
virtual void ScrollTo(Control* ctl) = 0;
|
||||
//按照百分比滚动 0.0f~1.0f
|
||||
void ScrollTo(float scrollRate);
|
||||
//获取当前滚动到的位置 进度的百分比
|
||||
float ScrollPos();
|
||||
//获取滑块的矩形
|
||||
virtual Rect GetSliderRect() = 0;//
|
||||
//滚动条是否已经绘制且显示
|
||||
bool IsDraw();
|
||||
//重置滚动条数据到起点(不执行重绘)
|
||||
void Reset();
|
||||
//滚动条是否能够滚动
|
||||
bool Scrollable();
|
||||
//当父控件发生内容发生改变 请调用刷新滚动条
|
||||
void RefreshScroll();
|
||||
ScrollBar(Object* ownerObject = NULL);
|
||||
virtual ~ScrollBar();
|
||||
};
|
||||
};
|
||||
33
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/ShadowBox.h
vendored
Normal file
33
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/ShadowBox.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include "Window.h"
|
||||
#include "Bitmap.h"
|
||||
|
||||
namespace ezui {
|
||||
class UI_EXPORT ShadowBox
|
||||
{
|
||||
private:
|
||||
Size m_lastSize;
|
||||
int m_lastShadowMargin = 0;
|
||||
Bitmap* m_bufBitmap = NULL;
|
||||
HWND m_hWnd = NULL;
|
||||
HWND m_mainHWnd = NULL;
|
||||
WORD m_radius = 0;
|
||||
WindowContext* m_publicData = NULL;
|
||||
//窗口透明度
|
||||
float m_opacity = 0.0f;
|
||||
private:
|
||||
bool SetShadow(Bitmap* bitmap, int iSize, float radius);
|
||||
protected:
|
||||
virtual LRESULT WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
virtual void OnSize(const Size& sz);
|
||||
public:
|
||||
ShadowBox(int width, int height, HWND mainHwnd);//构造函数
|
||||
virtual ~ShadowBox();
|
||||
//在父窗口发生改变的时候更新阴影区域
|
||||
virtual void Update(int shadowMargin, int radius);
|
||||
//更新透明度
|
||||
void Update(float opacity);
|
||||
HWND Hwnd();
|
||||
HDC GetDC();
|
||||
};
|
||||
};
|
||||
24
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Spacer.h
vendored
Normal file
24
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/Spacer.h
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
|
||||
namespace ezui {
|
||||
//添加弹簧无需用户手动释放(不可在栈上创建弹簧对象)
|
||||
class UI_EXPORT Spacer :public Control {
|
||||
public:
|
||||
Spacer();
|
||||
virtual bool IsSpacer()override final;
|
||||
virtual ~Spacer();
|
||||
};
|
||||
//具有绝对高度的 的弹簧
|
||||
class UI_EXPORT VSpacer :public Spacer {
|
||||
public:
|
||||
virtual ~VSpacer();
|
||||
VSpacer(int fixedHeight = 0);
|
||||
};
|
||||
//具有绝对宽度的 的弹簧
|
||||
class UI_EXPORT HSpacer :public Spacer {
|
||||
public:
|
||||
virtual ~HSpacer();
|
||||
HSpacer(int fixedWidth = 0);
|
||||
};
|
||||
};
|
||||
38
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/TabLayout.h
vendored
Normal file
38
demo/Adminstor/ThirdParty/EzUI2/include/EzUI/TabLayout.h
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
#include "Timer.h"
|
||||
#include "Animation.h"
|
||||
namespace ezui {
|
||||
//滑动方向
|
||||
enum class SlideDirection {
|
||||
Horizontal, // 横向滑动(比如从左滑到右)
|
||||
Vertical // 纵向滑动(比如从上滑到底)
|
||||
};
|
||||
class UI_EXPORT TabLayout :
|
||||
public Control
|
||||
{
|
||||
private:
|
||||
int m_pageIndex = 0;
|
||||
Animation m_amt;
|
||||
std::vector<int> m_initial;
|
||||
SlideDirection m_dlideDirection;
|
||||
void Sort();
|
||||
void Init();
|
||||
protected:
|
||||
virtual void OnLayout()override;
|
||||
virtual void SetAttribute(const UIString& key, const UIString& value)override;
|
||||
public:
|
||||
TabLayout(Object* ownerObject = NULL);
|
||||
virtual ~TabLayout();
|
||||
virtual void RemoveChild(Control* ctl, bool freeCtl = false)override;
|
||||
virtual Control* AddChild(Control* childCtl)override;
|
||||
//设置当前显示页
|
||||
void SetPageIndex(int index);
|
||||
//动画方式滑动到某一页
|
||||
void SlideToPage(int index, SlideDirection dlideDirection = SlideDirection::Horizontal, int durationMs = 300);
|
||||
void SetPage(Control* ctrl);
|
||||
Control* GetPage();
|
||||
//获取当前页索引
|
||||
int GetPageIndex();
|
||||
};
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user