initial commit

This commit is contained in:
Ysm-04
2025-09-07 00:19:40 +08:00
commit d62d8a90d6
25 changed files with 2995 additions and 0 deletions

95
src/Canvas.cpp Normal file
View File

@@ -0,0 +1,95 @@
#include "Canvas.h"
Canvas::Canvas(int x, int y, int width, int height)
:Control(x, y, width, height) {}
void Canvas::draw()
{
saveStyle();
setlinecolor(canvasBorderClor);//设置线色
setfillcolor(canvasBkClor);//设置填充色
setfillstyle((int)canvasFillMode);//设置填充模式
setlinestyle((int)canvasLineStyle, canvaslinewidth);
//根据画布形状绘制
switch (shape)
{
case StellarX::controlShape::RECTANGLE:
fillrectangle(x, y, width, height);//有边框填充矩形
break;
case StellarX::controlShape::B_RECTANGLE:
solidrectangle(x, y, width, height);//无边框填充矩形
break;
case StellarX::controlShape::ROUND_RECTANGLE:
fillroundrect(x, y, width, height, 20, 20);//有边框填充圆角矩形
break;
case StellarX::controlShape::B_ROUND_RECTANGLE:
solidroundrect(x, y, width, height, 20, 20);//无边框填充圆角矩形
break;
}
// 绘制所有子控件
for (auto& control : controls)
control->draw();
restoreStyle();
}
void Canvas::handleEvent(const ExMessage& msg)
{
for (auto& control : controls) {
control->handleEvent(msg);
}
}
void Canvas::addControl(std::unique_ptr<Control> control)
{
controls.push_back(std::move(control));
}
void Canvas::setShape(StellarX::controlShape shape)
{
switch (shape)
{
case StellarX::controlShape::RECTANGLE:
case StellarX::controlShape::B_RECTANGLE:
case StellarX::controlShape::ROUND_RECTANGLE:
case StellarX::controlShape::B_ROUND_RECTANGLE:
this->shape = shape;
break;
case StellarX::controlShape::CIRCLE:
case StellarX::controlShape::B_CIRCLE:
case StellarX::controlShape::ELLIPSE:
case StellarX::controlShape::B_ELLIPSE:
this->shape = StellarX::controlShape::RECTANGLE;
break;
}
}
void Canvas::setcanvasfillMode(StellarX::fillMode mode)
{
this->canvasFillMode = mode;
}
void Canvas::setBorderColor(COLORREF color)
{
this->canvasBorderClor = color;
}
void Canvas::setCanvasBkColor(COLORREF color)
{
this->canvasBkClor = color;
}
void Canvas::setcanvasLineStyle(StellarX::lineStyle style)
{
this->canvasLineStyle = style;
}
void Canvas::setlinewidth(int width)
{
this->canvaslinewidth = width;
}