diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1ff0c42..0000000 --- a/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index 05225a3..f3e0fd2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,11 @@ -build/ -demo/ -_temp/ -_bin/ -temp/ -bin/ -.vs/ -*.lib \ No newline at end of file +/build +/demo +/_temp +/_bin +/temp +/bin +/.vs +*.db +*.gitignore +*.gitattributes +*.tlog \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md index 921db2b..093b4b8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -23,6 +23,13 @@ cmake -B build -DBUILD_SHARED_LIBS=ON # 仅构建库(不构建 demo) cmake -B build -DBUILD_DEMO=OFF + +# 编译为静态库 +cmake --build build/vs2022_x86 --target EzUI --config Debug +cmake --build build/vs2022_x86 --target EzUI --config Release +cmake --build build/vs2022_x64 --target EzUI --config Debug +cmake --build build/vs2022_x64 --target EzUI --config Release + ``` ## 核心架构 @@ -37,8 +44,11 @@ cmake -B build -DBUILD_DEMO=OFF 所有控件继承自 `Control` 基类,核心控件包括: - 基础控件:`Label`, `Button`, `TextBox`, `PictureBox` - 选择控件:`CheckBox`, `RadioButton`, `ComboBox` -- 布局容器:`HLayout`, `VLayout`, `HListView`, `VListView`, `TileListView`, `TabLayout` -- 功能控件:`ScrollBar`, `Menu`, `NotifyIcon`, `ProgressBar`, `TreeView`, `Spacer` +- 数据控件:`TableView`, `TreeView`, `ListView` 系列 +- 布局容器:`HLayout`, `VLayout`, `HListView`, `VListView`, `TileListView`, `TabLayout`, `PagedListView` +- 功能控件:`ScrollBar`, `Menu`, `NotifyIcon`, `ProgressBar`, `Spacer`, `IFrame`, `ShadowBox` +- 表格控件:`TableView` +- 动画:`Animation` - 类似 Qt 的过渡动画系统 ### 布局系统 - **尺寸优先级**:比例尺寸 (`SetRateWidth/Height`) > 绝对尺寸 (`SetFixedSize`) > 控件内容大小 @@ -51,6 +61,8 @@ cmake -B build -DBUILD_DEMO=OFF - `UISelector` - CSS 选择器匹配系统 - `Direct2DRender` - Direct2D 绘图实现 - `RenderTypes` - 颜色、对齐方式等绘图类型 +- `UIDef` - 框架内使用的宏定义集合 +- `EzUI.h` - 框架主接口头文件,定义事件类、枚举、全局资源等核心结构 ### 事件系统 - 支持事件冒泡机制,可实现事件捕获与穿透 @@ -67,6 +79,18 @@ cmake -B build -DBUILD_DEMO=OFF - 控件树内存由父控件自动管理:`Attach`/`Detach` - 图片资源通过 `PtrManager` 自动释放 - XML 布局加载后由 `UIManager` 管理生命周期 +- `add_resource_package` 函数支持资源打包为 `.res` 文件 + +### 调试技巧 +- 在 Debug 模式下运行时,按下 `F11` 可实时查看布局信息,高亮显示控件边界 + +## Demo 项目 + +- `helloWorld` - 基础示例 +- `QQ` - 仿 QQ 登录界面(含资源打包) +- `kugou` - 酷狗音乐播放器(含 VLC 依赖和资源打包) +- `ResPackage` - 资源打包工具 +- `Adminstor` / `DemoUi` - 管理界面示例 ## 开发约定 @@ -74,4 +98,5 @@ cmake -B build -DBUILD_DEMO=OFF - 源文件位于 `sources/` 目录 - 一切皆控件,纯代码组合 UI - 使用 CSS 驱动视觉,结构与样式分离 -- 中文注释,中文沟通 +- XML 解析使用 `tinyxml` 库 + diff --git a/demo/Adminstor/Adminstor/DemoUi.rc b/demo/Adminstor/Adminstor/DemoUi.rc index ff26827..c38195b 100644 Binary files a/demo/Adminstor/Adminstor/DemoUi.rc and b/demo/Adminstor/Adminstor/DemoUi.rc differ diff --git a/demo/Adminstor/Adminstor/Resource.h b/demo/Adminstor/Adminstor/Resource.h index 10beec9..8d5a39d 100644 --- a/demo/Adminstor/Adminstor/Resource.h +++ b/demo/Adminstor/Adminstor/Resource.h @@ -2,16 +2,6 @@ // Microsoft Visual C++ 生成的包含文件。 // 供 DemoUi.rc 使用 // +#define IDI_SMALL 101 #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 diff --git a/demo/Adminstor/Adminstor/loginForm.cpp b/demo/Adminstor/Adminstor/loginForm.cpp index 43ca279..e8c7e1f 100644 --- a/demo/Adminstor/Adminstor/loginForm.cpp +++ b/demo/Adminstor/Adminstor/loginForm.cpp @@ -50,6 +50,10 @@ loginForm::loginForm() :LayeredWindow(320, 448) { umg.LoadXml("res/loginForm.htm");//加载xml里面的控件与样式 umg.SetupUI(this); + + // 通过资源ID加载图标 (在 app.rc 中定义 IDI_SMALL=101) + HICON hIco = (HICON)::LoadImageW(GetModuleHandleW(nullptr), MAKEINTRESOURCEW(IDI_SMALL), IMAGE_ICON, 32, 32, 0); + if (hIco) SetIcon(hIco); } loginForm::~loginForm() diff --git a/demo/Adminstor/Adminstor/mainForm.cpp b/demo/Adminstor/Adminstor/mainForm.cpp index 31cefe4..9e51546 100644 --- a/demo/Adminstor/Adminstor/mainForm.cpp +++ b/demo/Adminstor/Adminstor/mainForm.cpp @@ -105,10 +105,6 @@ void mainForm::OnNotify(Control* sender, EventArgs& args) break; default: break; - } - if (args.EventType == Event::OnMouseDown) { - - } __super::OnNotify(sender, args); } @@ -118,6 +114,27 @@ void mainForm::OnClose(bool& close) Application::Exit(); } +void mainForm::OnMouseUp(ezui::MouseButton mbtn, const ezui::Point& point) +{ + if (mbtn == ezui::MouseButton::Right) { + // 右键弹起处理(可实现右键单击) + TableView* tableView = (TableView*)FindControl("tableViewAdmin"); //获取表格控件 + if (tableView) { + //表格 + int pRow = tableView->GetHoverRow(); //当前行号 + int pCol = tableView->GetHoverCol(); //当前列号 + if (pRow < 0 || pCol < 0) return; // 说明不在表格区域内 + + UIString celContent = tableView->GetData(pRow, pCol); + //std::cout << "单元格内容: " << celContent.ansi() << std::endl; + std::cout << "行列号为 (" << pRow << ", " << pCol << ") 当前列宽: " << tableView->GetColumnWidth(pCol) << std::endl; + + } + } + ezui::Window::OnMouseUp(mbtn, point); +} + +// UI初始化 mainForm::mainForm() :LayeredWindow(1500, 750) { SetResizable(true); // 启用窗口大小调整 @@ -125,6 +142,10 @@ mainForm::mainForm() :LayeredWindow(1500, 750) umg.LoadXml("res/mainForm.htm");//加载xml里面的控件与样式 umg.SetupUI(this); + // 通过资源ID加载图标 (在 app.rc 中定义 IDI_SMALL=101) + HICON hIco = (HICON)::LoadImageW(GetModuleHandleW(nullptr), MAKEINTRESOURCEW(IDI_SMALL), IMAGE_ICON, 32, 32, 0); + if (hIco) SetIcon(hIco); + // 如果是debug模式则创建控制台窗口用于输出调试信息 #ifdef _DEBUG AllocConsole(); @@ -134,7 +155,6 @@ mainForm::mainForm() :LayeredWindow(1500, 750) std::cout << "调试模式控制台已启动!" << std::endl; #endif - // 初始化设置表格各项属性 TableView* tableView = (TableView*)FindControl("tableViewAdmin"); //获取表格控件 if (tableView) { @@ -149,18 +169,9 @@ mainForm::mainForm() :LayeredWindow(1500, 750) for(int i = 0; i < withs.size(); i++) tableView->SetColumnWidth(i, withs[i]); - // 鼠标右键单击的回调 - tableView->RightClick = [tableView](int row, int col) { - int pRow = tableView->GetHoverRow(); //当前行号 - int pCol = tableView->GetHoverCol(); //当前列号 - UIString celContent = tableView->GetData(pRow, pCol); - //std::cout << "单元格内容: " << celContent.ansi() << std::endl; - std::cout << "当前列宽: " << tableView->GetColumnWidth(pCol) << std::endl; - }; - // 单元格编辑完成(编辑结束时触发,提供旧值与新值) tableView->CellEditFinished = [](int row, int col, const UIString& oldValue, const UIString& newValue) { - std::cout << "完成编辑单元格内容: " << newValue.ansi() << ", " << oldValue.ansi() << std::endl; + //std::cout << "完成编辑单元格内容: " << newValue.ansi() << ", " << oldValue.ansi() << std::endl; }; } diff --git a/demo/Adminstor/Adminstor/mainForm.h b/demo/Adminstor/Adminstor/mainForm.h index 10b2a16..092e473 100644 --- a/demo/Adminstor/Adminstor/mainForm.h +++ b/demo/Adminstor/Adminstor/mainForm.h @@ -12,6 +12,7 @@ private: protected: virtual void OnNotify(Control* sender, EventArgs& args)override;//重载事件通知 virtual void OnClose(bool& close)override;//当窗口关闭的时候 + virtual void OnMouseUp(ezui::MouseButton mbtn, const ezui::Point& point) override; // 鼠标抬起 public: //ui管理类 UIManager umg; diff --git a/demo/Adminstor/Adminstor/small.ico b/demo/Adminstor/Adminstor/small.ico index b3ec03b..9af4529 100644 Binary files a/demo/Adminstor/Adminstor/small.ico and b/demo/Adminstor/Adminstor/small.ico differ