feat: add a new awesome feature

This commit is contained in:
Ysm-04
2025-09-22 15:08:49 +08:00
parent bd4588731b
commit 9f2b175b17
25 changed files with 1962 additions and 616 deletions
+41 -16
View File
@@ -1,34 +1,40 @@
#pragma once
#include "Control.h"
//窗口模式
//#define EX_DBLCLKS 1 - 在绘图窗口中支持鼠标双击事件。
//#define EX_NOCLOSE 2 - 禁用绘图窗口的关闭按钮。
//#define EX_NOMINIMIZE 3 - 禁用绘图窗口的最小化按钮。
//#define EX_SHOWCONSOLE 4 - 显示控制台窗口。
#pragma once
#include"Control.h"
/*******************************************************************************
* @类: Window
* @摘要: 应用程序主窗口类
* @摘要: 应用程序主窗口类,管理窗口生命周期和消息循环
* @描述:
* 负责创建和管理应用程序主窗口,所有控件的根容器。
* 处理消息循环、事件分发和窗口生命周期管理
* 创建和管理应用程序主窗口,作为所有控件的根容器。
* 处理消息分发、事件循环和渲染调度
*
* @重要说明:
* - 使用 initgraph() 创建窗口
* - 使用 BeginBatchDraw()/EndBatchDraw() 实现双缓冲
* - 使用 getmessage() 处理消息循环
* @特性:
* - 多种窗口模式配置(双缓冲、控制台等)
* - 背景图片和颜色支持
* - 集成的对话框管理系统
* - 完整的消息处理循环
* - 控件和对话框的生命周期管理
*
* @使用场景: 应用程序主窗口,GUI程序的入口和核心
* @所属框架: 星垣(StellarX) GUI框架
* @作者: 我在人间做废物
******************************************************************************/
class Window
{
int width; //窗口宽度
int height; //窗口高度
int width; //窗口宽度
int height; //窗口高度
int windowMode = NULL; //窗口模式
HWND hWnd = NULL; //窗口句柄
std::string headline; //窗口标题
COLORREF wBkcolor = BLACK; //窗口背景
IMAGE* background = nullptr; //窗口背景图片
std::vector<std::unique_ptr<Control>> controls; //控件管理
std::vector<std::unique_ptr<Control>> dialogs; //对话框管理
public:
bool dialogClose = false; //是否有对话框关闭
Window(int width, int height, int mode);
Window(int width, int height, int mode, COLORREF bkcloc);
Window(int width, int height, int mode , COLORREF bkcloc, std::string headline = "窗口");
@@ -47,6 +53,25 @@ public:
void setHeadline(std::string headline);
//添加控件
void addControl(std::unique_ptr<Control> control);
//添加对话框
void addDialog(std::unique_ptr<Control> dialogs);
//检查是否已有对话框显示用于去重,防止工厂模式调用非模态对话框,多次打开污染对话框背景快照
bool hasNonModalDialogWithCaption(const std::string& caption) const;
//获取窗口句柄
HWND getHwnd() const;
//获取窗口宽度
int getWidth() const;
//获取窗口高度
int getHeight() const;
//获取窗口标题
std::string getHeadline() const;
//获取窗口背景颜色
COLORREF getBkcolor() const;
//获取窗口背景图片
IMAGE* getBkImage() const;
//获取控件管理
std::vector<std::unique_ptr<Control>>& getControls();
};