diff --git a/控件 API 文档 (StellarX GUI Framework Controls API Documentation).md b/控件 API 文档 (StellarX GUI Framework Controls API Documentation).md index 4d591b6..90ec84e 100644 --- a/控件 API 文档 (StellarX GUI Framework Controls API Documentation).md +++ b/控件 API 文档 (StellarX GUI Framework Controls API Documentation).md @@ -1,2651 +1,687 @@ -# StellarX GUI 框架控件 API 文档 (StellarX GUI Framework Controls API Documentation) +# StellarX GUI Framework API Documentation (中英双语) -## Control 类 (抽象基类) +## CoreTypes(基础类型) -**描述:** `Control` 是所有控件的抽象基类,定义了通用的属性和接口,包括位置、尺寸、可见性、重绘标记等基础功能。它提供绘图状态的保存与恢复机制,确保控件的绘制操作不影响全局绘图状态。此外还声明了一系列供子类实现的纯虚函数(如 `draw()` 和 `handleEvent()`),并禁止拷贝(支持移动语义)以防止意外的复制开销。一般情况下,`Control` 不直接实例化,而是作为其他具体控件的父类存在。 +**CoreTypes** 模块定义了 StellarX 框架中使用的所有基础枚举和结构体类型,以确保类型一致性(Core types module defines all fundamental enums and structs used in the StellarX framework to ensure type consistency)。主要包括以下内容: -**Description:** `Control` is the abstract base class for all controls, defining common properties and interfaces such as position, size, visibility, and the “dirty” flag for redraw. It provides mechanisms to save and restore drawing state to ensure a control’s drawing operations do not affect the global canvas state. It also declares a set of pure virtual functions for subclasses to implement (e.g. `draw()` for rendering and `handleEvent()` for event handling), and it disables copying (but supports move semantics) to prevent accidental heavy copy operations. Typically, `Control` is not instantiated directly; it serves as a base class for concrete controls. +- **FillStyle(填充图案样式)**:定义控件填充图案的枚举类型。例如 Horizontal 表示水平线填充,Vertical 表示垂直线,FDiagonal 表示反斜线,BDiagonal 表示正斜线,Cross 表示十字,DiagCross 表示网格。(Defines patterns for filling control backgrounds. For example, Horizontal for horizontal lines, Vertical for vertical lines, FDiagonal for forward diagonal lines, BDiagonal for backward diagonal lines, Cross for crosshatch, DiagCross for grid pattern.)默认填充图案为水平线 (The default pattern is horizontal line)。 -**特性 (Features):** +- **FillMode(填充模式)**:定义控件背景的填充模式,包括纯色、无填充、图案填充、自定义图案、自定义图片填充等。(Defines how control backgrounds are filled: solid color, no fill, hatched pattern, custom pattern, or custom image fill, etc.)例如 Solid(固实填充),Null(不填充),Hatched(图案填充),Pattern(自定义图案),DibPattern(自定义图像)。默认填充模式为 Solid 固实填充 (default is solid fill)。 -- 定义控件的基本属性(坐标、尺寸、脏标记等)并提供对应的存取方法 *(Defines basic properties of a control – position, size, “dirty” redraw flag, etc. – and provides getters/setters for them.)* -- 提供绘图状态管理接口(如 `saveStyle()` / `restoreStyle()`)用于在控件绘制前后保存和恢复全局画笔状态 *(Provides drawing state management (e.g. `saveStyle()` / `restoreStyle()`) to save and restore the global drawing state before and after control rendering.)* -- 声明纯虚函数接口,如 `draw()`(绘制控件)和 `handleEvent()`(处理事件),所有具体控件都需实现 *(Declares pure virtual functions such as `draw()` (to draw the control) and `handleEvent()` (to handle input events), which all concrete control subclasses must implement.)* -- 禁止拷贝构造和赋值(但支持移动语义),防止控件被不小心复制 *(Copy construction and assignment are disabled (move semantics are supported) to prevent unintended copying of controls.)* +- **LineStyle(线型样式)**:定义控件边框的线型风格枚举。例如 Solid 表示实线,Dash 表示虚线,Dot 表示点线,DashDot 表示点划线,DashDotDot 表示双点划线,Null 表示无边框线。(Defines line style for control borders. For example, Solid for solid line, Dash for dashed line, Dot for dotted line, DashDot for dash-dot line, DashDotDot for double dash-dot, Null for no border line.)默认边框线型为实线 (default line style is solid)。 -```mermaid -classDiagram - class Control { - +int getX() - +int getY() - +int getWidth() - +int getHeight() - +int getRight() - +int getBottom() - +int getLocalX() - +int getLocalY() - +int getLocalWidth() - +int getLocalHeight() - +void setX(int) - +void setY(int) - +void setWidth(int) - +void setHeight(int) - +void setIsVisible(bool) - +bool isVisible() - +void setDirty(bool) - +bool isDirty() - +void updateBackground() - +virtual void draw() = 0 - +virtual bool handleEvent(const ExMessage&) = 0 - <> - } - class Canvas { - +void addControl(std::unique_ptr) - +void removeControl(Control*) - +void clearAllControls() - +void setCanvasBkColor(COLORREF) - +void setBorderColor(COLORREF) - +void setShape(ControlShape) - +void setCanvasFillMode(FillMode) - +void setCanvasLineStyle(LineStyle) - +void setAnchor(AnchorMode) - +void adaptiveLayout() - } - class Label { - +void setText(string) - +void setTextBkColor(COLORREF) - +void setTextdisap(bool) - } - class Button { - +void setOnClickListener(function) - +void setOnToggleOnListener(function) - +void setOnToggleOffListener(function) - +void setTooltipText(string) - +void setTooltipOffset(int, int) - } - class TextBox { - +string getText() - +void setText(string) - +void setMaxCharLen(size_t) - +void setMode(TextBoxMode) - } - class TabControl { - +void add(pair< unique_ptr