Skip to content

Commit

Permalink
控件的边线支持borderstyle属性
Browse files Browse the repository at this point in the history
  • Loading branch information
qdtroy committed Jul 29, 2022
1 parent 0798ff9 commit bfa997c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions DuiLib/Core/UIRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ namespace DuiLib {


// 绘制及填充圆角矩形
void GdiplusDrawRoundRect(HDC hDC, float x, float y, float width, float height, float arcSize, float lineWidth, Gdiplus::Color lineColor, bool fillPath, Gdiplus::Color fillColor)
void GdiplusDrawRoundRect(HDC hDC, float x, float y, float width, float height, float arcSize, float lineWidth, Gdiplus::Color lineColor, bool fillPath, Gdiplus::Color fillColor, int nStyle)
{
float arcDiameter = arcSize * 2;
// 创建GDI+对象
Expand All @@ -1525,6 +1525,7 @@ namespace DuiLib {

//创建画笔
Gdiplus::Pen pen(lineColor, lineWidth);
pen.SetDashStyle((Gdiplus::DashStyle)nStyle);
// 绘制矩形
g.DrawPath(&pen, &roundRectPath);

Expand Down Expand Up @@ -1657,7 +1658,7 @@ namespace DuiLib {
{
#ifdef USE_GDI_RENDER
ASSERT(::GetObjectType(hDC) == OBJ_DC || ::GetObjectType(hDC) == OBJ_MEMDC);
HPEN hPen = ::CreatePen(PS_SOLID | PS_INSIDEFRAME, nSize, RGB(GetBValue(dwPenColor), GetGValue(dwPenColor), GetRValue(dwPenColor)));
HPEN hPen = ::CreatePen(nStyle | PS_INSIDEFRAME, nSize, RGB(GetBValue(dwPenColor), GetGValue(dwPenColor), GetRValue(dwPenColor)));
HPEN hOldPen = (HPEN)::SelectObject(hDC, hPen);
::SelectObject(hDC, ::GetStockObject(HOLLOW_BRUSH));
::Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
Expand All @@ -1668,12 +1669,13 @@ namespace DuiLib {
Gdiplus::Graphics graphics(hDC);
Gdiplus::Pen pen(Gdiplus::Color(dwPenColor), (Gdiplus::REAL)nSize);
pen.SetAlignment(Gdiplus::PenAlignmentInset);
pen.SetDashStyle((Gdiplus::DashStyle)nStyle);

graphics.DrawRectangle(&pen, rc.left, rc.top, rc.right - rc.left - 1, rc.bottom - rc.top - 1);
#endif
}

void CRenderEngine::DrawRoundRect(HDC hDC, const RECT& rc, int nSize, int width, int height, DWORD dwPenColor,int nStyle /*= PS_SOLID*/)
void CRenderEngine::DrawRoundRect(HDC hDC, const RECT& rc, int nSize, int width, int height, DWORD dwPenColor, int nStyle /*= PS_SOLID*/)
{
#ifdef USE_GDI_RENDER
ASSERT(::GetObjectType(hDC)==OBJ_DC || ::GetObjectType(hDC)==OBJ_MEMDC);
Expand All @@ -1684,7 +1686,7 @@ namespace DuiLib {
::SelectObject(hDC, hOldPen);
::DeleteObject(hPen);
#else
GdiplusDrawRoundRect(hDC, rc.left, rc.top, rc.right - rc.left - 1, rc.bottom - rc.top - 1, width / 2, nSize, Gdiplus::Color(dwPenColor), false, Gdiplus::Color(dwPenColor));
GdiplusDrawRoundRect(hDC, rc.left, rc.top, rc.right - rc.left - 1, rc.bottom - rc.top - 1, width / 2, nSize, Gdiplus::Color(dwPenColor), false, Gdiplus::Color(dwPenColor), nStyle);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion bin/skin/duidemo/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

<Loading name="loading" width="64" height="64" time="50" color="0xffffff00" />
<Container width="64" height="64">
<Button name="autobtn" textcolor="#FF000000" bkimage="logo.jpg" bordercolor="#FFFF6666" bordersize="2" borderround="64,64"/>
<Button name="autobtn" textcolor="#FF000000" bkimage="logo.jpg" bordercolor="#FFFF6666" bordersize="2" borderround="64,64" borderstyle="2"/>
</Container>

</HorizontalLayout>
Expand Down

0 comments on commit bfa997c

Please sign in to comment.