initial commit
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
|
||||
class button : public Control
|
||||
class Button : public Control
|
||||
{
|
||||
|
||||
std::string text; // 按钮上的文字
|
||||
@@ -25,27 +25,26 @@ class button : public Control
|
||||
COLORREF buttonHoverColor; // 按钮被鼠标悬停的颜色
|
||||
COLORREF buttonBorderColor = RGB(0,0,0);// 按钮边框颜色
|
||||
|
||||
StellarX::buttonMode mode; // 按钮模式
|
||||
StellarX::controlShape shape; // 按钮形状
|
||||
StellarX::ButtonMode mode; // 按钮模式
|
||||
StellarX::ControlShape shape; // 按钮形状
|
||||
|
||||
int buttonFillMode = BS_SOLID; //按钮填充模式
|
||||
StellarX::fillStyle buttonFillIma = StellarX::fillStyle::BDiagonal; //按钮填充图案
|
||||
StellarX::FillStyle buttonFillIma = StellarX::FillStyle::BDiagonal; //按钮填充图案
|
||||
IMAGE* buttonFileIMAGE = nullptr; //按钮填充图像
|
||||
|
||||
int ROUND_RECTANGLEwidth = 20; //构成圆角矩形的圆角的椭圆的宽度。
|
||||
int ROUND_RECTANGLEheight = 20; //构成圆角矩形的圆角的椭圆的高度。
|
||||
|
||||
|
||||
std::function<void()> onClickCallback; //回调函数
|
||||
std::function<void()> onToggleOnCallback; //TOGGLE模式下的回调函数
|
||||
std::function<void()> onToggleOffCallback; //TOGGLE模式下的回调函数
|
||||
|
||||
StellarX::controlText oldStyle = textStyle; // 按钮文字样式
|
||||
StellarX::ControlText oldStyle = textStyle; // 按钮文字样式
|
||||
int oldtext_width = -1;
|
||||
int oldtext_height = -1;
|
||||
int text_width = 0;
|
||||
int text_height = 0;
|
||||
public:
|
||||
StellarX::controlText textStyle; // 按钮文字样式
|
||||
StellarX::ControlText textStyle; // 按钮文字样式
|
||||
|
||||
public:
|
||||
/*************************************************************************/
|
||||
@@ -53,18 +52,18 @@ public:
|
||||
/*************************************************************************/
|
||||
|
||||
//默认按钮颜色
|
||||
button(int x, int y, int width, int height, const std::string text,
|
||||
StellarX::buttonMode mode = StellarX::buttonMode::NORMAL, StellarX::controlShape shape = StellarX::controlShape::RECTANGLE);
|
||||
Button(int x, int y, int width, int height, const std::string text,
|
||||
StellarX::ButtonMode mode = StellarX::ButtonMode::NORMAL, StellarX::ControlShape shape = StellarX::ControlShape::RECTANGLE);
|
||||
//自定义按钮未被点击和被点击颜色
|
||||
button(int x, int y, int width, int height, const std::string text,
|
||||
COLORREF ct, COLORREF cf, StellarX::buttonMode mode = StellarX::buttonMode::NORMAL,
|
||||
StellarX::controlShape shape = StellarX::controlShape::RECTANGLE);
|
||||
Button(int x, int y, int width, int height, const std::string text,
|
||||
COLORREF ct, COLORREF cf, StellarX::ButtonMode mode = StellarX::ButtonMode::NORMAL,
|
||||
StellarX::ControlShape shape = StellarX::ControlShape::RECTANGLE);
|
||||
//自定义按钮颜色和悬停颜色
|
||||
button(int x, int y, int width, int height, const std::string text,
|
||||
Button(int x, int y, int width, int height, const std::string text,
|
||||
COLORREF ct, COLORREF cf,COLORREF ch,
|
||||
StellarX::buttonMode mode = StellarX::buttonMode::NORMAL, StellarX::controlShape shape = StellarX::controlShape::RECTANGLE);
|
||||
StellarX::ButtonMode mode = StellarX::ButtonMode::NORMAL, StellarX::ControlShape shape = StellarX::ControlShape::RECTANGLE);
|
||||
//析构函数 释放图形指针内存
|
||||
~button();
|
||||
~Button();
|
||||
|
||||
/*************************************************************************/
|
||||
/********************************Set方法**********************************/
|
||||
@@ -78,7 +77,7 @@ public:
|
||||
//设置回调函数
|
||||
//************************************
|
||||
// 名称: setOnClickListener | setOnToggleOnListener | setOnToggleOffListener
|
||||
// 全名: button::setOnClickListener
|
||||
// 全名: Button::setOnClickListener
|
||||
// 访问: public
|
||||
// 返回类型: void
|
||||
// Parameter: const std::function<> & & callback 设置回调函数 传入回调函数名即可,不需要传入(),不需要传入参数,不需要传入返回值
|
||||
@@ -90,7 +89,7 @@ public:
|
||||
//设置TOGGLE模式下取消点击的回调函数
|
||||
void setOnToggleOffListener(const std::function<void()>&& callback);
|
||||
//设置按钮模式
|
||||
void setbuttonMode(StellarX::buttonMode mode);
|
||||
void setbuttonMode(StellarX::ButtonMode mode);
|
||||
//设置圆角矩形椭圆宽度
|
||||
int setROUND_RECTANGLEwidth(int width);
|
||||
//设置圆角矩形椭圆高度
|
||||
@@ -98,16 +97,16 @@ public:
|
||||
//设置按钮填充模式
|
||||
void setFillMode(int mode);
|
||||
//设置按钮填充图案
|
||||
void setFillIma(StellarX::fillStyle ima);
|
||||
void setFillIma(StellarX::FillStyle ima);
|
||||
//设置按钮填充图像
|
||||
void setFillIma(std::string imaName);
|
||||
//设置按钮边框颜色
|
||||
void setbuttonBorder(COLORREF Border);
|
||||
void setButtonBorder(COLORREF Border);
|
||||
//设置按钮文本
|
||||
void setbuttonText(const char* text);
|
||||
void setbuttonText(std::string text);
|
||||
void setButtonText(const char* text);
|
||||
void setButtonText(std::string text);
|
||||
//设置按钮形状
|
||||
void setbuttonShape(StellarX::controlShape shape);
|
||||
void setButtonShape(StellarX::ControlShape shape);
|
||||
|
||||
//判断按钮是否被点击
|
||||
bool isClicked() const;
|
||||
@@ -117,28 +116,28 @@ public:
|
||||
/*************************************************************************/
|
||||
|
||||
//获取按钮文字
|
||||
std::string getbuttonText() const;
|
||||
const char* getbuttonText_c() const;
|
||||
std::string getButtonText() const;
|
||||
const char* getButtonText_c() const;
|
||||
//获取按钮模式
|
||||
StellarX::buttonMode getbuttonMode() const;
|
||||
StellarX::ButtonMode getButtonMode() const;
|
||||
//获取按钮形状
|
||||
StellarX::controlShape getbuttonShape() const;
|
||||
StellarX::ControlShape getButtonShape() const;
|
||||
//获取按钮填充模式
|
||||
int getFillMode() const;
|
||||
//获取按钮填充图案
|
||||
StellarX::fillStyle getFillIma() const;
|
||||
StellarX::FillStyle getFillIma() const;
|
||||
//获取按钮填充图像
|
||||
IMAGE* getFillImaImage() const;
|
||||
//获取按钮边框颜色
|
||||
COLORREF getbuttonBorder() const;
|
||||
COLORREF getButtonBorder() const;
|
||||
//获取按钮文字颜色
|
||||
COLORREF getbuttonTxtColor() const;
|
||||
COLORREF getButtonTextColor() const;
|
||||
//获取按钮文字样式
|
||||
StellarX::controlText getbuttonTextStyle() const;
|
||||
StellarX::ControlText getButtonTextStyle() const;
|
||||
|
||||
private:
|
||||
//初始化按钮
|
||||
void initButton(const std::string text, StellarX::buttonMode mode, StellarX::controlShape shape, COLORREF ct, COLORREF cf, COLORREF ch);
|
||||
void initButton(const std::string text, StellarX::ButtonMode mode, StellarX::ControlShape shape, COLORREF ct, COLORREF cf, COLORREF ch);
|
||||
//判断鼠标是否在圆形按钮内
|
||||
bool isMouseInCircle(int mouseX, int mouseY, int x, int y, int radius);
|
||||
//判断鼠标是否在椭圆按钮内
|
||||
|
||||
@@ -6,15 +6,16 @@
|
||||
// - 将事件传递给子控件
|
||||
// - 提供统一的背景和边框
|
||||
// 使用场景: 用于分组相关控件或实现复杂布局
|
||||
|
||||
class Canvas : public Control
|
||||
{
|
||||
private:
|
||||
std::vector<std::unique_ptr<Control>> controls;
|
||||
|
||||
StellarX::controlShape shape = StellarX::controlShape::RECTANGLE; //容器形状
|
||||
StellarX::ControlShape shape = StellarX::ControlShape::RECTANGLE; //容器形状
|
||||
|
||||
StellarX::fillMode canvasFillMode = StellarX::fillMode::Solid; //容器填充模式
|
||||
StellarX::lineStyle canvasLineStyle = StellarX::lineStyle::Solid; //线型
|
||||
StellarX::FillMode canvasFillMode = StellarX::FillMode::Solid; //容器填充模式
|
||||
StellarX::LineStyle canvasLineStyle = StellarX::LineStyle::Solid; //线型
|
||||
int canvaslinewidth = 1; //线宽
|
||||
|
||||
COLORREF canvasBorderClor = RGB(0, 0, 0);//边框颜色
|
||||
@@ -30,17 +31,17 @@ public:
|
||||
void addControl(std::unique_ptr<Control> control);
|
||||
|
||||
//设置容器样式
|
||||
void setShape(StellarX::controlShape shape);
|
||||
void setShape(StellarX::ControlShape shape);
|
||||
//设置容器填充模式
|
||||
void setcanvasfillMode(StellarX::fillMode mode);
|
||||
void setCanvasfillMode(StellarX::FillMode mode);
|
||||
//设置容器边框颜色
|
||||
void setBorderColor(COLORREF color);
|
||||
//设置填充颜色
|
||||
void setCanvasBkColor(COLORREF color);
|
||||
//设置线形
|
||||
void setcanvasLineStyle(StellarX::lineStyle style);
|
||||
void setCanvasLineStyle(StellarX::LineStyle style);
|
||||
//设置线段宽度
|
||||
void setlinewidth(int width);
|
||||
void setLinewidth(int width);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* \文件: Control.h
|
||||
* \描述: 控件基类,所有控件都继承自此类。
|
||||
* 提供了控件的一些基本属性和方法。
|
||||
*
|
||||
* \作者: 我在人间做废物
|
||||
*
|
||||
* \作者: 我在人间做废物
|
||||
* \日期: September 2025
|
||||
*********************************************************************/
|
||||
#include <vector>
|
||||
@@ -15,66 +15,49 @@
|
||||
#include <functional>
|
||||
#include <initializer_list>
|
||||
#include "CoreTypes.h"
|
||||
/**
|
||||
* @类名称: Control
|
||||
* @功能描述: 控件基类,所有控件都继承自此类。
|
||||
* 提供了控件的一些基本属性和方法。
|
||||
*
|
||||
* @成员说明:
|
||||
* int x, y, width, height; // 控件的基本属性
|
||||
*
|
||||
* LOGFONT currentFont; //保存当前字体样式和颜色
|
||||
* COLORREF currentColor = 0;
|
||||
* COLORREF currentBkColor = 0; //保存当前填充色
|
||||
* COLORREF currentBorderColor = 0;//边框颜色
|
||||
* LINESTYLE* currentLineStyle = new LINESTYLE; //保存当前线型
|
||||
*
|
||||
* Control():x(0), y(0), width(0), height(0) {}
|
||||
* Control(int x, int y, int width, int height) :x(x),y(y),width(width),height(height){}
|
||||
* virtual void draw() = 0; // 绘制控件
|
||||
* virtual void handleEvent(const ExMessage& msg) = 0; // 处理事件
|
||||
* virtual ~Control() { delete currentLineStyle; }
|
||||
*
|
||||
* //保存当前字体样式和颜色
|
||||
* void saveStyle();
|
||||
* //恢复默认字体样式和颜色
|
||||
* void restoreStyle();
|
||||
*
|
||||
* @使用示例:
|
||||
* Control* ctrl = new Button(10, 10, 100, 50, "Click Me");
|
||||
* ctrl->draw();
|
||||
* delete ctrl;
|
||||
*
|
||||
* @备注:
|
||||
* 这是一个抽象基类,不能直接实例化。
|
||||
* 所有具体的控件类都必须实现draw和handleEvent方法。
|
||||
*/
|
||||
class Control
|
||||
|
||||
class Control
|
||||
{
|
||||
protected:
|
||||
int x, y, width, height; // 控件的基本属性
|
||||
int x, y; // 左上角坐标
|
||||
int width, height; // 控件尺寸
|
||||
|
||||
StellarX::RouRectangle rouRectangleSize; // 圆角矩形椭圆宽度和高度
|
||||
|
||||
LOGFONT currentFont; // 保存当前字体样式和颜色
|
||||
COLORREF currentColor = 0;
|
||||
COLORREF currentBkColor = 0; // 保存当前填充色
|
||||
COLORREF currentBorderColor = 0; // 边框颜色
|
||||
LINESTYLE* currentLineStyle = new LINESTYLE; // 保存当前线型
|
||||
|
||||
LOGFONT currentFont; //保存当前字体样式和颜色
|
||||
COLORREF currentColor = 0;
|
||||
COLORREF currentBkColor = 0; //保存当前填充色
|
||||
COLORREF currentBorderColor = 0;//边框颜色
|
||||
LINESTYLE* currentLineStyle = new LINESTYLE; //保存当前线型
|
||||
public:
|
||||
Control(const Control&) = delete; // 禁用拷贝构造
|
||||
Control& operator=(const Control&) = delete; // 禁用拷贝赋值
|
||||
Control(Control&&) = default; // 允许移动构造
|
||||
Control& operator=(Control&&) = default; // 允许移动赋值
|
||||
Control():x(0), y(0), width(100), height(100) {}
|
||||
Control(int x, int y, int width, int height) :x(x),y(y),width(x + width),height(y + height){}
|
||||
|
||||
virtual void draw() = 0; // 绘制控件
|
||||
virtual void handleEvent(const ExMessage& msg) = 0; // 处理事件
|
||||
virtual ~Control() {
|
||||
delete currentLineStyle; currentLineStyle = nullptr; }
|
||||
|
||||
Control(const Control&) = delete;
|
||||
Control& operator=(const Control&) = delete;
|
||||
Control(Control&&) = default;
|
||||
Control& operator=(Control&&) = default;
|
||||
|
||||
Control() : x(0), y(0), width(100), height(100) {}
|
||||
Control(int x, int y, int width, int height)
|
||||
: x(x), y(y), width(width), height(height) {
|
||||
}
|
||||
|
||||
virtual ~Control() {
|
||||
delete currentLineStyle;
|
||||
currentLineStyle = nullptr;
|
||||
}
|
||||
|
||||
// 获取位置和尺寸
|
||||
int getX() const { return x; }
|
||||
int getY() const { return y; }
|
||||
int getWidth() const { return width; }
|
||||
int getHeight() const { return height; }
|
||||
int getRight() const { return x + width; }
|
||||
int getBottom() const { return y + height; }
|
||||
|
||||
virtual void draw() = 0;
|
||||
virtual void handleEvent(const ExMessage& msg) = 0;
|
||||
|
||||
protected:
|
||||
//保存当前样式和颜色
|
||||
void saveStyle();
|
||||
//恢复默认样式和颜色
|
||||
void restoreStyle();
|
||||
};
|
||||
};
|
||||
@@ -38,7 +38,7 @@ namespace StellarX
|
||||
* 此枚举类仅支持图案填充模式
|
||||
* 枚举类在使用时,需要使用::进行调用,还要注意大小写
|
||||
*/
|
||||
enum class fillStyle {
|
||||
enum class FillStyle {
|
||||
Horizontal = HS_HORIZONTAL, // 水平线
|
||||
Vertical = HS_VERTICAL, // 垂直线
|
||||
FDiagonal = HS_FDIAGONAL, // 反斜线
|
||||
@@ -47,7 +47,7 @@ namespace StellarX
|
||||
DiagCross = HS_DIAGCROSS // 网格
|
||||
};
|
||||
/**
|
||||
* @枚举类名称: fillMode
|
||||
* @枚举类名称: FillMode
|
||||
* @功能描述: 用来定义控件填充模式的枚举类
|
||||
*
|
||||
* @详细说明:
|
||||
@@ -65,12 +65,12 @@ namespace StellarX
|
||||
*
|
||||
* @使用示例:
|
||||
* // 示例代码展示如何使用此枚举类
|
||||
* fillMode var = fillMode::Solid;
|
||||
* FillMode var = FillMode::Solid;
|
||||
*
|
||||
* @备注:
|
||||
* 枚举类在使用时,需要使用::进行调用,还要注意大小写
|
||||
*/
|
||||
enum class fillMode
|
||||
enum class FillMode
|
||||
{
|
||||
Solid = BS_SOLID, //固实填充
|
||||
Null = BS_NULL, // 不填充
|
||||
@@ -98,12 +98,12 @@ namespace StellarX
|
||||
*
|
||||
* @使用示例:
|
||||
* // 示例代码展示如何使用此枚举类
|
||||
* lineStyle var = lineStyle::Solid;
|
||||
* LineStyle var = LineStyle::Solid;
|
||||
*
|
||||
* @备注:
|
||||
* 枚举类在使用时,需要使用::进行调用,还要注意大小写
|
||||
*/
|
||||
enum class lineStyle {
|
||||
enum class LineStyle {
|
||||
Solid = PS_SOLID, // 实线
|
||||
Dash = PS_DASH, // 虚线
|
||||
Dot = PS_DOT, // 点线
|
||||
@@ -113,7 +113,7 @@ namespace StellarX
|
||||
};
|
||||
|
||||
/**
|
||||
* @结构体名称: controlText
|
||||
* @结构体名称: ControlText
|
||||
* @功能描述: 控件字体样式 可以自定义不同的样式
|
||||
*
|
||||
* @详细说明:
|
||||
@@ -131,10 +131,10 @@ namespace StellarX
|
||||
* bool bUnderline = false; - 是否下划线
|
||||
* bool bStrikeOut = false; - 是否删除线
|
||||
|
||||
* bool operator!=(const controlText& text);
|
||||
* controlText& operator=(const controlText& text
|
||||
* bool operator!=(const ControlText& text);
|
||||
* ControlText& operator=(const ControlText& text
|
||||
*/
|
||||
struct controlText
|
||||
struct ControlText
|
||||
{
|
||||
int nHeight = 0; //- 字体高度
|
||||
int nWidth = 0; //- 字体宽度 如果为0则自适应
|
||||
@@ -147,13 +147,13 @@ namespace StellarX
|
||||
bool bUnderline = false; //- 是否下划线
|
||||
bool bStrikeOut = false; //- 是否删除线
|
||||
|
||||
bool operator!=(const controlText& text);
|
||||
controlText& operator=(const controlText& text);
|
||||
bool operator!=(const ControlText& text);
|
||||
ControlText& operator=(const ControlText& text);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @枚举名称: controlShape
|
||||
* @枚举名称: ControlShape
|
||||
* @功能描述: 枚举控件的不同几何样式
|
||||
*
|
||||
* @详细说明:
|
||||
@@ -174,12 +174,12 @@ namespace StellarX
|
||||
* B_ELLIPSE //无边框椭圆
|
||||
*
|
||||
* @使用示例:
|
||||
* controlShape shape = ELLIPSE;
|
||||
* ControlShape shape = ELLIPSE;
|
||||
*
|
||||
* @备注:
|
||||
* 按钮类支持所有形状,部分控件只支持部分形状,具体请参考控件类。
|
||||
*/
|
||||
enum class controlShape
|
||||
enum class ControlShape
|
||||
{
|
||||
RECTANGLE = 1, //有边框矩形
|
||||
B_RECTANGLE, //无边框矩形
|
||||
@@ -194,7 +194,7 @@ namespace StellarX
|
||||
B_ELLIPSE //无边框椭圆
|
||||
};
|
||||
/**
|
||||
* @枚举类名称: textBoxmode
|
||||
* @枚举类名称: TextBoxmode
|
||||
* @功能描述: 定义了文本框的两种模式
|
||||
*
|
||||
* @详细说明:
|
||||
@@ -206,19 +206,19 @@ namespace StellarX
|
||||
*
|
||||
* @使用示例:
|
||||
* // 示例代码展示如何使用此枚举类
|
||||
* StellarX::textBoxmode var = EnumClassName::VALUE1;
|
||||
* StellarX::TextBoxmode var = EnumClassName::VALUE1;
|
||||
*
|
||||
* @备注:
|
||||
* 枚举类的特性、与普通枚举的区别
|
||||
*/
|
||||
enum class textBoxmode
|
||||
enum class TextBoxmode
|
||||
{
|
||||
INPUT_MODE, // 用户可输入模式
|
||||
READONLY_MODE // 只读模式
|
||||
};
|
||||
|
||||
/**
|
||||
* @枚举名称: buttonMode
|
||||
* @枚举名称: ButtonMode
|
||||
* @功能描述: brief
|
||||
*
|
||||
* @详细说明:
|
||||
@@ -231,13 +231,18 @@ namespace StellarX
|
||||
* DISABLED - 禁用模式,按钮不可点击,显示为灰色,文本显示删除线。
|
||||
*
|
||||
* @使用示例:
|
||||
* button b1(100, 100, 120, 120, "测试按钮", RGB(128, 0, 0), RGB(255, 9, 9));
|
||||
* Button b1(100, 100, 120, 120, "测试按钮", RGB(128, 0, 0), RGB(255, 9, 9));
|
||||
*
|
||||
*/
|
||||
enum class buttonMode
|
||||
enum class ButtonMode
|
||||
{
|
||||
NORMAL = 1,
|
||||
TOGGLE,
|
||||
DISABLED
|
||||
NORMAL = 1, //普通模式,点击后触发回调,但不会保持状态。
|
||||
TOGGLE, //切换模式,点击后会在选中和未选中之间切换,触发不同的回调函数。
|
||||
DISABLED //禁用模式,按钮不可点击,显示为灰色,文本显示删除线。
|
||||
};
|
||||
struct RouRectangle
|
||||
{
|
||||
int ROUND_RECTANGLEwidth = 20; //构成圆角矩形的圆角的椭圆的宽度。
|
||||
int ROUND_RECTANGLEheight = 20; //构成圆角矩形的圆角的椭圆的高度。
|
||||
};
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* 内部包含顺序经过精心设计,确保所有依赖关系正确解析。
|
||||
*
|
||||
* @作者: 我在人间做废物
|
||||
* @邮箱: [您的邮箱或联系方式]
|
||||
* @邮箱: [3150131407@qq.com][]
|
||||
* @仓库: https://github.com/yourusername/stellarx
|
||||
*
|
||||
* @许可证: MIT License
|
||||
@@ -30,8 +30,8 @@
|
||||
#include "CoreTypes.h"
|
||||
#include "Control.h"
|
||||
#include"Button.h"
|
||||
#include"window.h"
|
||||
#include"label.h"
|
||||
#include"textBox.h"
|
||||
#include"Window.h"
|
||||
#include"Label.h"
|
||||
#include"TextBox.h"
|
||||
#include"Canvas.h"
|
||||
#include"table.h"
|
||||
#include"Table.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// - 不支持用户交互(无事件处理)
|
||||
// - 自动适应文本内容大小
|
||||
|
||||
class label : public Control
|
||||
class Label : public Control
|
||||
{
|
||||
std::string text; //标签文本
|
||||
COLORREF textColor; //标签文本颜色
|
||||
@@ -16,18 +16,18 @@ class label : public Control
|
||||
//标签事件处理(标签无事件)不实现具体代码
|
||||
void handleEvent(const ExMessage& msg) override {}
|
||||
public:
|
||||
StellarX::controlText textStyle; //标签文本样式
|
||||
StellarX::ControlText textStyle; //标签文本样式
|
||||
public:
|
||||
label();
|
||||
label(int x, int y, std::string text = "标签",COLORREF textcolor = BLACK, COLORREF bkColor= RGB(255,255,255));
|
||||
Label();
|
||||
Label(int x, int y, std::string text = "标签",COLORREF textcolor = BLACK, COLORREF bkColor= RGB(255,255,255));
|
||||
//绘标签
|
||||
void draw() override;
|
||||
//设置标签背景是否透明
|
||||
void setTxtdisap(bool key);
|
||||
void setTextdisap(bool key);
|
||||
//设置标签文本颜色
|
||||
void setTxtColor(COLORREF color);
|
||||
void setTextColor(COLORREF color);
|
||||
//设置标签背景颜色
|
||||
void setTxtBkColor(COLORREF color);
|
||||
void setTextBkColor(COLORREF color);
|
||||
//设置标签文本
|
||||
void setText(std::string text);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* @文件: table.h
|
||||
* @文件: Table.h
|
||||
* @摘要: 高级表格控件,支持分页显示
|
||||
* @描述:
|
||||
* 提供完整的数据表格功能,包括表头、数据行、分页和导航按钮。
|
||||
@@ -19,9 +19,9 @@
|
||||
#pragma once
|
||||
#include "Control.h"
|
||||
#include "Button.h"
|
||||
#include "label.h"
|
||||
#include "Label.h"
|
||||
|
||||
class table :public Control
|
||||
class Table :public Control
|
||||
{
|
||||
private:
|
||||
std::vector<std::vector<std::string>> data; // 表格数据
|
||||
@@ -44,9 +44,9 @@ private:
|
||||
bool isNeedDrawHeaders = true; // 是否需要绘制表头
|
||||
bool isNeedCellSize = true; // 是否需要计算单元格尺寸
|
||||
|
||||
button* prevButton = nullptr; // 上一页按钮
|
||||
button* nextButton = nullptr; // 下一页按钮
|
||||
label* pageNum = nullptr; //页码文本
|
||||
Button* prevButton = nullptr; // 上一页按钮
|
||||
Button* nextButton = nullptr; // 下一页按钮
|
||||
Label* pageNum = nullptr; //页码文本
|
||||
|
||||
int dX = x, dY = y; // 单元格的开始坐标
|
||||
int uX = x, uY = y; // 单元格的结束坐标
|
||||
@@ -54,8 +54,8 @@ private:
|
||||
int pX = 0; //标签左上角坐标
|
||||
int pY = 0; //标签左上角坐标
|
||||
|
||||
StellarX::fillMode tableFillMode = StellarX::fillMode::Solid; //填充模式
|
||||
StellarX::lineStyle tableLineStyle = StellarX::lineStyle::Solid; // 线型
|
||||
StellarX::FillMode tableFillMode = StellarX::FillMode::Solid; //填充模式
|
||||
StellarX::LineStyle tableLineStyle = StellarX::LineStyle::Solid; // 线型
|
||||
COLORREF tableBorderClor = RGB(0, 0, 0); // 表格边框颜色
|
||||
COLORREF tableBkClor = RGB(255, 255, 255); // 表格背景颜色
|
||||
|
||||
@@ -68,11 +68,11 @@ private:
|
||||
void drawPageNum(); //绘制页码信息
|
||||
void drawButton(); //绘制翻页按钮
|
||||
public:
|
||||
StellarX::controlText textStyle; // 文本样式
|
||||
StellarX::ControlText textStyle; // 文本样式
|
||||
|
||||
public:
|
||||
table(int x, int y);
|
||||
~table();
|
||||
Table(int x, int y);
|
||||
~Table();
|
||||
|
||||
// 绘制表格
|
||||
void draw() override;
|
||||
@@ -91,15 +91,15 @@ public:
|
||||
//设置是否显示翻页按钮
|
||||
void showPageButton(bool isShow);
|
||||
//设置表格边框颜色
|
||||
void settableBorder(COLORREF color);
|
||||
void setTableBorder(COLORREF color);
|
||||
//设置表格背景颜色
|
||||
void settableBk(COLORREF color);
|
||||
void setTableBk(COLORREF color);
|
||||
//设置填充模式
|
||||
void settableFillMode(StellarX::fillMode mode);
|
||||
void setTableFillMode(StellarX::FillMode mode);
|
||||
//设置线型
|
||||
void settableLineStyle(StellarX::lineStyle style);
|
||||
void setTableLineStyle(StellarX::LineStyle style);
|
||||
//设置边框宽度
|
||||
void settableBorderWidth(int width);
|
||||
void setTableBorderWidth(int width);
|
||||
|
||||
//************************** 获取属性 *****************************/
|
||||
|
||||
@@ -112,19 +112,19 @@ public:
|
||||
//获取是否显示翻页按钮
|
||||
bool getShowPageButton() const;
|
||||
//获取表格边框颜色
|
||||
COLORREF gettableBorder() const;
|
||||
COLORREF getTableBorder() const;
|
||||
//获取表格背景颜色
|
||||
COLORREF gettableBk() const;
|
||||
COLORREF getTableBk() const;
|
||||
//获取填充模式
|
||||
StellarX::fillMode gettableFillMode() const;
|
||||
StellarX::FillMode getTableFillMode() const;
|
||||
//获取线型
|
||||
StellarX::lineStyle gettableLineStyle() const;
|
||||
StellarX::LineStyle getTableLineStyle() const;
|
||||
//获取表头
|
||||
std::vector<std::string> getHeaders () const;
|
||||
//获取表格数据
|
||||
std::vector<std::vector<std::string>> getData() const;
|
||||
//获取表格边框宽度
|
||||
int gettableBorderWidth() const;
|
||||
int getTableBorderWidth() const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
// - 在INPUT_MODE下点击会调用EasyX的InputBox
|
||||
// - 在READONLY_MODE下点击会显示信息对话框
|
||||
// - 最大字符长度受maxCharLen限制
|
||||
class textBox : public Control
|
||||
|
||||
class TextBox : public Control
|
||||
{
|
||||
std::string text; //文本
|
||||
StellarX::textBoxmode mode; //模式
|
||||
StellarX::controlShape shape; //形状
|
||||
StellarX::TextBoxmode mode; //模式
|
||||
StellarX::ControlShape shape; //形状
|
||||
bool dirty = true; //是否重绘
|
||||
bool click = false; //是否点击
|
||||
int maxCharLen = 10;//最大字符长度
|
||||
@@ -18,25 +19,25 @@ class textBox : public Control
|
||||
COLORREF textBoxBorderClor = RGB(0,0,0); //边框颜色
|
||||
|
||||
public:
|
||||
StellarX::controlText textStyle; //文本样式
|
||||
StellarX::ControlText textStyle; //文本样式
|
||||
|
||||
textBox(int x, int y, int width, int height, std::string text = "", StellarX::textBoxmode mode = StellarX::textBoxmode::INPUT_MODE, StellarX::controlShape shape = StellarX::controlShape::RECTANGLE);
|
||||
TextBox(int x, int y, int width, int height, std::string text = "", StellarX::TextBoxmode mode = StellarX::TextBoxmode::INPUT_MODE, StellarX::ControlShape shape = StellarX::ControlShape::RECTANGLE);
|
||||
void draw() override;
|
||||
void handleEvent(const ExMessage& msg) override;
|
||||
//设置模式
|
||||
|
||||
void setMode(StellarX::textBoxmode mode);
|
||||
void setMode(StellarX::TextBoxmode mode);
|
||||
//设置可输入最大字符长度
|
||||
void setmaxCharLen(int len);
|
||||
void setMaxCharLen(int len);
|
||||
//设置形状
|
||||
void settextBoxshape(StellarX::controlShape shape);
|
||||
void setTextBoxshape(StellarX::ControlShape shape);
|
||||
//设置边框颜色
|
||||
void settextBoxBorder(COLORREF color);
|
||||
void setTextBoxBorder(COLORREF color);
|
||||
//设置背景颜色
|
||||
void settextBoxBk(COLORREF color);
|
||||
void setTextBoxBk(COLORREF color);
|
||||
|
||||
//获取文本
|
||||
std::string gettext();
|
||||
std::string getText() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
//#define EX_NOMINIMIZE 3 - 禁用绘图窗口的最小化按钮。
|
||||
//#define EX_SHOWCONSOLE 4 - 显示控制台窗口。
|
||||
/*******************************************************************************
|
||||
* @类: window
|
||||
* @类: Window
|
||||
* @摘要: 应用程序主窗口类
|
||||
* @描述:
|
||||
* 负责创建和管理应用程序的主窗口,是所有控件的根容器。
|
||||
@@ -17,7 +17,7 @@
|
||||
* - 使用 BeginBatchDraw()/EndBatchDraw() 实现双缓冲
|
||||
* - 使用 getmessage() 处理消息循环
|
||||
******************************************************************************/
|
||||
class window
|
||||
class Window
|
||||
{
|
||||
int width; //窗口宽度
|
||||
int height; //窗口高度
|
||||
@@ -29,10 +29,10 @@ class window
|
||||
std::vector<std::unique_ptr<Control>> controls; //控件管理
|
||||
|
||||
public:
|
||||
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 = "窗口");
|
||||
~window();
|
||||
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 = "窗口");
|
||||
~Window();
|
||||
//绘制窗口
|
||||
void draw();
|
||||
void draw(std::string pImgFile);
|
||||
|
||||
Reference in New Issue
Block a user