diff --git a/README_en-US.md b/README_en-US.md
index f8093eb8..66bd5587 100644
--- a/README_en-US.md
+++ b/README_en-US.md
@@ -43,7 +43,7 @@ Enter the `NIM_Duilib_Framework/samples` directory,Open `samples.sln` with Vis
├─`libs` Static library output directories, include CEF static library.
├─`samples` Samples of Duilib.
├─`third_party` Third party for CEF.
-├─`toolkits`
+├─`toolkits`
│ ├─`base` Base libraries.
│ ├─`duilib` Duilib core, depend on base project.
│ ├─`shared` Utils, such as logs/string/path utils.
@@ -52,5 +52,5 @@ Enter the `NIM_Duilib_Framework/samples` directory,Open `samples.sln` with Vis
## Communication
- Question: Read the [Documentation](docs/SUMMARY.md) and [Samples code](samples/README.md) to help you.
- - Report: File a bug in GitHub issues
+ - Report: File a bug in GitHub issues.
- Suggestion: Request a new feature in Github issues.
diff --git a/bin/resources/themes/default/controls/controls.xml b/bin/resources/themes/default/controls/controls.xml
index 313aa251..2c18df9e 100644
--- a/bin/resources/themes/default/controls/controls.xml
+++ b/bin/resources/themes/default/controls/controls.xml
@@ -34,12 +34,10 @@
-
-
+
-
diff --git a/samples/controls/controls.vcxproj b/samples/controls/controls.vcxproj
index 5196225d..246ad58a 100644
--- a/samples/controls/controls.vcxproj
+++ b/samples/controls/controls.vcxproj
@@ -207,9 +207,6 @@
{0149ba6e-3c0a-426d-aa0a-0b9ec7742f19}
-
-
-
diff --git a/samples/controls/controls.vcxproj.filters b/samples/controls/controls.vcxproj.filters
index 845e3a3d..c47272db 100644
--- a/samples/controls/controls.vcxproj.filters
+++ b/samples/controls/controls.vcxproj.filters
@@ -55,7 +55,4 @@
资源文件
-
-
-
\ No newline at end of file
diff --git a/tool_kits/duilib/Core/Control.cpp b/tool_kits/duilib/Core/Control.cpp
index 3188d204..35664df7 100644
--- a/tool_kits/duilib/Core/Control.cpp
+++ b/tool_kits/duilib/Core/Control.cpp
@@ -1428,10 +1428,43 @@ void Control::PaintBorder(IRenderContext* pRender)
dwBorderColor = GlobalManager::GetTextColor(m_strBorderColor);
}
- if(dwBorderColor != 0) {
- //жǷҪԲǾ
- if ((m_cxyBorderRound.cx > 0 || m_cxyBorderRound.cy > 0) && m_nBorderSize > 0)
- {
+ if (dwBorderColor != 0) {
+ if (m_rcBorderSize.left > 0 || m_rcBorderSize.top > 0 || m_rcBorderSize.right > 0 || m_rcBorderSize.bottom > 0) {
+ UiRect rcBorder;
+ if (m_rcBorderSize.left > 0) {
+ rcBorder = m_rcItem;
+ rcBorder.right = rcBorder.left = m_rcItem.left + m_rcBorderSize.left / 2;
+ if (m_rcBorderSize.left == 1) {
+ rcBorder.bottom -= 1;
+ }
+ pRender->DrawLine(rcBorder, m_rcBorderSize.left, dwBorderColor);
+ }
+ if (m_rcBorderSize.top > 0) {
+ rcBorder = m_rcItem;
+ rcBorder.bottom = rcBorder.top = m_rcItem.top + m_rcBorderSize.top / 2;
+ if (m_rcBorderSize.top == 1) {
+ rcBorder.right -= 1;
+ }
+ pRender->DrawLine(rcBorder, m_rcBorderSize.top, dwBorderColor);
+ }
+ if (m_rcBorderSize.right > 0) {
+ rcBorder = m_rcItem;
+ rcBorder.left = rcBorder.right = m_rcItem.right - (m_rcBorderSize.right + 1) / 2;
+ if (m_rcBorderSize.right == 1) {
+ rcBorder.bottom -= 1;
+ }
+ pRender->DrawLine(rcBorder, m_rcBorderSize.right, dwBorderColor);
+ }
+ if (m_rcBorderSize.bottom > 0) {
+ rcBorder = m_rcItem;
+ rcBorder.top = rcBorder.bottom = m_rcItem.bottom - (m_rcBorderSize.bottom + 1) / 2;
+ if (m_rcBorderSize.bottom == 1) {
+ rcBorder.right -= 1;
+ }
+ pRender->DrawLine(rcBorder, m_rcBorderSize.bottom, dwBorderColor);
+ }
+ }
+ else if (m_nBorderSize > 0) {
UiRect rcDraw = m_rcItem;
int nDeltaValue = m_nBorderSize / 2;
rcDraw.top += nDeltaValue;
@@ -1444,60 +1477,11 @@ void Control::PaintBorder(IRenderContext* pRender)
if (m_nBorderSize % 2 != 0) {
rcDraw.right -= 1;
}
- pRender->DrawRoundRect(rcDraw, m_cxyBorderRound, m_nBorderSize, dwBorderColor);
- }
- else
- {
- if (m_rcBorderSize.left > 0 || m_rcBorderSize.top > 0 || m_rcBorderSize.right > 0 || m_rcBorderSize.bottom > 0) {
- UiRect rcBorder;
- if (m_rcBorderSize.left > 0) {
- rcBorder = m_rcItem;
- rcBorder.right = rcBorder.left = m_rcItem.left + m_rcBorderSize.left / 2;
- if (m_rcBorderSize.left == 1) {
- rcBorder.bottom -= 1;
- }
- pRender->DrawLine(rcBorder, m_rcBorderSize.left, dwBorderColor);
- }
- if (m_rcBorderSize.top > 0) {
- rcBorder = m_rcItem;
- rcBorder.bottom = rcBorder.top = m_rcItem.top + m_rcBorderSize.top / 2;
- if (m_rcBorderSize.top == 1) {
- rcBorder.right -= 1;
- }
- pRender->DrawLine(rcBorder, m_rcBorderSize.top, dwBorderColor);
- }
- if (m_rcBorderSize.right > 0) {
- rcBorder = m_rcItem;
- rcBorder.left = rcBorder.right = m_rcItem.right - (m_rcBorderSize.right + 1) / 2;
- if (m_rcBorderSize.right == 1) {
- rcBorder.bottom -= 1;
- }
- pRender->DrawLine(rcBorder, m_rcBorderSize.right, dwBorderColor);
- }
- if (m_rcBorderSize.bottom > 0) {
- rcBorder = m_rcItem;
- rcBorder.top = rcBorder.bottom = m_rcItem.bottom - (m_rcBorderSize.bottom + 1) / 2;
- if (m_rcBorderSize.bottom == 1) {
- rcBorder.right -= 1;
- }
- pRender->DrawLine(rcBorder, m_rcBorderSize.bottom, dwBorderColor);
- }
- }
- else if (m_nBorderSize > 0) {
- UiRect rcDraw = m_rcItem;
- int nDeltaValue = m_nBorderSize / 2;
- rcDraw.top += nDeltaValue;
- rcDraw.bottom -= nDeltaValue;
- if (m_nBorderSize % 2 != 0) {
- rcDraw.bottom -= 1;
- }
- rcDraw.left += nDeltaValue;
- rcDraw.right -= nDeltaValue;
- if (m_nBorderSize % 2 != 0) {
- rcDraw.right -= 1;
- }
+
+ if (m_cxyBorderRound.cx > 0 || m_cxyBorderRound.cy > 0)
+ pRender->DrawRoundRect(rcDraw, m_cxyBorderRound, m_nBorderSize, dwBorderColor);
+ else
pRender->DrawRect(rcDraw, m_nBorderSize, dwBorderColor);
- }
}
}
}
diff --git a/tool_kits/duilib/Render/IRender.h b/tool_kits/duilib/Render/IRender.h
index 24b03a45..f1325b3f 100644
--- a/tool_kits/duilib/Render/IRender.h
+++ b/tool_kits/duilib/Render/IRender.h
@@ -204,7 +204,7 @@ public:
virtual void DrawLine(const IPen* pen, int x1, int y1, int x2, int y2) = 0;
virtual void DrawBezier(const IPen* pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) = 0;
virtual void DrawRect(const UiRect& rc, int nSize, DWORD dwPenColor) = 0;
- virtual void DrawRoundRect(const UiRect& rc, const SIZE& round, int nSize, DWORD dwPenColor) = 0;
+ virtual void DrawRoundRect(const UiRect& rc, const CSize& roundSize, int nSize, DWORD dwPenColor) = 0;
virtual void DrawText(const UiRect& rc, const std::wstring& strText, DWORD dwTextColor, const std::wstring& strFontId, UINT uStyle, BYTE uFade = 255, bool bLineLimit = false) = 0;
diff --git a/tool_kits/duilib/Render/Render.cpp b/tool_kits/duilib/Render/Render.cpp
index 469967cd..452a85a2 100644
--- a/tool_kits/duilib/Render/Render.cpp
+++ b/tool_kits/duilib/Render/Render.cpp
@@ -4,7 +4,7 @@ namespace ui {
static inline void DrawFunction(HDC hDC, bool bTransparent, UiRect rcDest, HDC hdcSrc, UiRect rcSrc, bool bAlphaChannel, int uFade)
{
- if (bTransparent || bAlphaChannel || uFade < 255
+ if (bTransparent || bAlphaChannel || uFade < 255
|| (rcSrc.GetWidth() == rcDest.GetWidth() && rcSrc.GetHeight() == rcDest.GetHeight())) {
BLENDFUNCTION ftn = { AC_SRC_OVER, 0, uFade, AC_SRC_ALPHA };
::AlphaBlend(hDC, rcDest.left, rcDest.top, rcDest.GetWidth(), rcDest.GetHeight(),
@@ -24,7 +24,7 @@ RenderContext_GdiPlus::RenderContext_GdiPlus()
HDC hDC = ::GetDC(NULL);
m_hDC = ::CreateCompatibleDC(hDC);
::ReleaseDC(NULL, hDC);
- ASSERT(m_hDC);
+ ASSERT(m_hDC);
}
RenderContext_GdiPlus::~RenderContext_GdiPlus()
@@ -189,23 +189,23 @@ void RenderContext_GdiPlus::DrawImage(const UiRect& rcPaint, HBITMAP hBitmap, bo
const UiRect& rcImageDest, const UiRect& rcImageSource, const UiRect& rcCorners, BYTE uFade /*= 255*/, bool xtiled /*= false*/, bool ytiled /*= false*/)
{
UiRect rcTestTemp;
- if( !::IntersectRect(&rcTestTemp, &rcImageDest, &rcPaint) ) return;
+ if (!::IntersectRect(&rcTestTemp, &rcImageDest, &rcPaint)) return;
- ASSERT(::GetObjectType(m_hDC)==OBJ_DC || ::GetObjectType(m_hDC)==OBJ_MEMDC);
+ ASSERT(::GetObjectType(m_hDC) == OBJ_DC || ::GetObjectType(m_hDC) == OBJ_MEMDC);
- if( hBitmap == NULL ) return;
+ if (hBitmap == NULL) return;
HDC hCloneDC = ::CreateCompatibleDC(m_hDC);
HBITMAP hOldBitmap = (HBITMAP) ::SelectObject(hCloneDC, hBitmap);
- int stretchBltMode = ::SetStretchBltMode(m_hDC, HALFTONE);
+ int stretchBltMode = ::SetStretchBltMode(m_hDC, HALFTONE);
- UiRect rcTemp;
+ UiRect rcTemp;
UiRect rcSource;
- UiRect rcDest;
+ UiRect rcDest;
UiRect rcDpiCorner = rcCorners;
DpiManager::GetInstance()->ScaleRect(rcDpiCorner);
- // middle
+ // middle
rcDest.left = rcImageDest.left + rcDpiCorner.left;
rcDest.top = rcImageDest.top + rcDpiCorner.top;
rcDest.right = rcImageDest.right - rcDpiCorner.right;
@@ -214,31 +214,31 @@ void RenderContext_GdiPlus::DrawImage(const UiRect& rcPaint, HBITMAP hBitmap, bo
rcSource.top = rcImageSource.top + rcCorners.top;
rcSource.right = rcImageSource.right - rcCorners.right;
rcSource.bottom = rcImageSource.bottom - rcCorners.bottom;
- if( ::IntersectRect(&rcTemp, &rcPaint, &rcDest) ) {
- if( !xtiled && !ytiled ) {
- DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
- }
- else if( xtiled && ytiled ) {
- LONG lWidth = rcImageSource.right - rcImageSource.left - rcCorners.left - rcCorners.right;
- LONG lHeight = rcImageSource.bottom - rcImageSource.top - rcCorners.top - rcCorners.bottom;
- int iTimesX = (rcDest.right - rcDest.left + lWidth - 1) / lWidth;
- int iTimesY = (rcDest.bottom - rcDest.top + lHeight - 1) / lHeight;
- for( int j = 0; j < iTimesY; ++j ) {
- LONG lDestTop = rcDest.top + lHeight * j;
- LONG lDestBottom = rcDest.top + lHeight * (j + 1);
- LONG lDrawHeight = lHeight;
- if( lDestBottom > rcDest.bottom ) {
- lDrawHeight -= lDestBottom - rcDest.bottom;
- lDestBottom = rcDest.bottom;
- }
- for( int i = 0; i < iTimesX; ++i ) {
- LONG lDestLeft = rcDest.left + lWidth * i;
- LONG lDestRight = rcDest.left + lWidth * (i + 1);
- LONG lDrawWidth = lWidth;
- if( lDestRight > rcDest.right ) {
- lDrawWidth -= lDestRight - rcDest.right;
- lDestRight = rcDest.right;
- }
+ if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) {
+ if (!xtiled && !ytiled) {
+ DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
+ }
+ else if (xtiled && ytiled) {
+ LONG lWidth = rcImageSource.right - rcImageSource.left - rcCorners.left - rcCorners.right;
+ LONG lHeight = rcImageSource.bottom - rcImageSource.top - rcCorners.top - rcCorners.bottom;
+ int iTimesX = (rcDest.right - rcDest.left + lWidth - 1) / lWidth;
+ int iTimesY = (rcDest.bottom - rcDest.top + lHeight - 1) / lHeight;
+ for (int j = 0; j < iTimesY; ++j) {
+ LONG lDestTop = rcDest.top + lHeight * j;
+ LONG lDestBottom = rcDest.top + lHeight * (j + 1);
+ LONG lDrawHeight = lHeight;
+ if (lDestBottom > rcDest.bottom) {
+ lDrawHeight -= lDestBottom - rcDest.bottom;
+ lDestBottom = rcDest.bottom;
+ }
+ for (int i = 0; i < iTimesX; ++i) {
+ LONG lDestLeft = rcDest.left + lWidth * i;
+ LONG lDestRight = rcDest.left + lWidth * (i + 1);
+ LONG lDrawWidth = lWidth;
+ if (lDestRight > rcDest.right) {
+ lDrawWidth -= lDestRight - rcDest.right;
+ lDestRight = rcDest.right;
+ }
rcDest.left = rcDest.left + lWidth * i;
rcDest.top = rcDest.top + lHeight * j;
rcDest.right = rcDest.left + lDestRight - lDestLeft;
@@ -247,21 +247,21 @@ void RenderContext_GdiPlus::DrawImage(const UiRect& rcPaint, HBITMAP hBitmap, bo
rcSource.top = rcImageSource.top + rcCorners.top;
rcSource.right = rcSource.left + lDrawWidth;
rcSource.bottom = rcSource.top + lDrawHeight;
- DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
- }
- }
- }
- else if( xtiled ) {
- LONG lWidth = rcImageSource.right - rcImageSource.left - rcCorners.left - rcCorners.right;
- int iTimes = (rcDest.right - rcDest.left + lWidth - 1) / lWidth;
- for( int i = 0; i < iTimes; ++i ) {
- LONG lDestLeft = rcDest.left + lWidth * i;
- LONG lDestRight = rcDest.left + lWidth * (i + 1);
- LONG lDrawWidth = lWidth;
- if( lDestRight > rcDest.right ) {
- lDrawWidth -= lDestRight - rcDest.right;
- lDestRight = rcDest.right;
- }
+ DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
+ }
+ }
+ }
+ else if (xtiled) {
+ LONG lWidth = rcImageSource.right - rcImageSource.left - rcCorners.left - rcCorners.right;
+ int iTimes = (rcDest.right - rcDest.left + lWidth - 1) / lWidth;
+ for (int i = 0; i < iTimes; ++i) {
+ LONG lDestLeft = rcDest.left + lWidth * i;
+ LONG lDestRight = rcDest.left + lWidth * (i + 1);
+ LONG lDrawWidth = lWidth;
+ if (lDestRight > rcDest.right) {
+ lDrawWidth -= lDestRight - rcDest.right;
+ lDestRight = rcDest.right;
+ }
rcDest.left = lDestLeft;
rcDest.top = rcDest.top;
rcDest.right = lDestRight;
@@ -271,19 +271,19 @@ void RenderContext_GdiPlus::DrawImage(const UiRect& rcPaint, HBITMAP hBitmap, bo
rcSource.right = rcSource.left + lDrawWidth;
rcSource.bottom = rcImageSource.bottom - rcCorners.bottom;
DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
- }
- }
- else { // ytiled
- LONG lHeight = rcImageSource.bottom - rcImageSource.top - rcCorners.top - rcCorners.bottom;
- int iTimes = (rcDest.bottom - rcDest.top + lHeight - 1) / lHeight;
- for( int i = 0; i < iTimes; ++i ) {
- LONG lDestTop = rcDest.top + lHeight * i;
- LONG lDestBottom = rcDest.top + lHeight * (i + 1);
- LONG lDrawHeight = lHeight;
- if( lDestBottom > rcDest.bottom ) {
- lDrawHeight -= lDestBottom - rcDest.bottom;
- lDestBottom = rcDest.bottom;
- }
+ }
+ }
+ else { // ytiled
+ LONG lHeight = rcImageSource.bottom - rcImageSource.top - rcCorners.top - rcCorners.bottom;
+ int iTimes = (rcDest.bottom - rcDest.top + lHeight - 1) / lHeight;
+ for (int i = 0; i < iTimes; ++i) {
+ LONG lDestTop = rcDest.top + lHeight * i;
+ LONG lDestBottom = rcDest.top + lHeight * (i + 1);
+ LONG lDrawHeight = lHeight;
+ if (lDestBottom > rcDest.bottom) {
+ lDrawHeight -= lDestBottom - rcDest.bottom;
+ lDestBottom = rcDest.bottom;
+ }
rcDest.left = rcDest.left;
rcDest.top = rcDest.top + lHeight * i;
rcDest.right = rcDest.left + rcDest.right;
@@ -292,56 +292,56 @@ void RenderContext_GdiPlus::DrawImage(const UiRect& rcPaint, HBITMAP hBitmap, bo
rcSource.top = rcImageSource.top + rcCorners.top;
rcSource.right = rcImageSource.right - rcCorners.right;
rcSource.bottom = rcSource.top + lDrawHeight;
- DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
- }
- }
- }
+ DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
+ }
+ }
+ }
- // left-top
- if( rcCorners.left > 0 && rcCorners.top > 0 ) {
- rcDest.left = rcImageDest.left;
- rcDest.top = rcImageDest.top;
+ // left-top
+ if (rcCorners.left > 0 && rcCorners.top > 0) {
+ rcDest.left = rcImageDest.left;
+ rcDest.top = rcImageDest.top;
rcDest.right = rcImageDest.left + rcDpiCorner.left;
rcDest.bottom = rcImageDest.top + rcDpiCorner.top;
rcSource.left = rcImageSource.left;
rcSource.top = rcImageSource.top;
rcSource.right = rcImageSource.left + rcCorners.left;
rcSource.bottom = rcImageSource.top + rcCorners.top;
- if( ::IntersectRect(&rcTemp, &rcPaint, &rcDest) ) {
- DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
- }
- }
- // top
- if( rcCorners.top > 0 ) {
+ if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) {
+ DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
+ }
+ }
+ // top
+ if (rcCorners.top > 0) {
rcDest.left = rcImageDest.left + rcDpiCorner.left;
- rcDest.top = rcImageDest.top;
+ rcDest.top = rcImageDest.top;
rcDest.right = rcImageDest.right - rcDpiCorner.right;
rcDest.bottom = rcImageDest.top + rcDpiCorner.top;
rcSource.left = rcImageSource.left + rcCorners.left;
rcSource.top = rcImageSource.top;
rcSource.right = rcImageSource.right - rcCorners.right;
rcSource.bottom = rcImageSource.top + rcCorners.top;
- if( ::IntersectRect(&rcTemp, &rcPaint, &rcDest) ) {
- DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
- }
- }
- // right-top
- if( rcCorners.right > 0 && rcCorners.top > 0 ) {
+ if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) {
+ DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
+ }
+ }
+ // right-top
+ if (rcCorners.right > 0 && rcCorners.top > 0) {
rcDest.left = rcImageDest.right - rcDpiCorner.right;
- rcDest.top = rcImageDest.top;
- rcDest.right = rcImageDest.right;
+ rcDest.top = rcImageDest.top;
+ rcDest.right = rcImageDest.right;
rcDest.bottom = rcImageDest.top + rcDpiCorner.top;
rcSource.left = rcImageSource.right - rcCorners.right;
rcSource.top = rcImageSource.top;
rcSource.right = rcImageSource.right;
rcSource.bottom = rcImageSource.top + rcCorners.top;
- if( ::IntersectRect(&rcTemp, &rcPaint, &rcDest) ) {
- DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
- }
- }
- // left
- if( rcCorners.left > 0 ) {
- rcDest.left = rcImageDest.left;
+ if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) {
+ DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
+ }
+ }
+ // left
+ if (rcCorners.left > 0) {
+ rcDest.left = rcImageDest.left;
rcDest.top = rcImageDest.top + rcDpiCorner.top;
rcDest.right = rcImageDest.left + rcDpiCorner.left;
rcDest.bottom = rcImageDest.bottom - rcDpiCorner.bottom;
@@ -349,54 +349,54 @@ void RenderContext_GdiPlus::DrawImage(const UiRect& rcPaint, HBITMAP hBitmap, bo
rcSource.top = rcImageSource.top + rcCorners.top;
rcSource.right = rcImageSource.left + rcCorners.left;
rcSource.bottom = rcImageSource.bottom - rcCorners.bottom;
- if( ::IntersectRect(&rcTemp, &rcPaint, &rcDest) ) {
- DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
- }
- }
- // right
- if( rcCorners.right > 0 ) {
+ if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) {
+ DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
+ }
+ }
+ // right
+ if (rcCorners.right > 0) {
rcDest.left = rcImageDest.right - rcDpiCorner.right;
rcDest.top = rcImageDest.top + rcDpiCorner.top;
- rcDest.right = rcImageDest.right;
+ rcDest.right = rcImageDest.right;
rcDest.bottom = rcImageDest.bottom - rcDpiCorner.bottom;
rcSource.left = rcImageSource.right - rcCorners.right;
rcSource.top = rcImageSource.top + rcCorners.top;
rcSource.right = rcImageSource.right;
rcSource.bottom = rcImageSource.bottom - rcCorners.bottom;
- if( ::IntersectRect(&rcTemp, &rcPaint, &rcDest) ) {
- DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
- }
- }
- // left-bottom
- if( rcCorners.left > 0 && rcCorners.bottom > 0 ) {
- rcDest.left = rcImageDest.left;
+ if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) {
+ DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
+ }
+ }
+ // left-bottom
+ if (rcCorners.left > 0 && rcCorners.bottom > 0) {
+ rcDest.left = rcImageDest.left;
rcDest.top = rcImageDest.bottom - rcDpiCorner.bottom;
rcDest.right = rcImageDest.left + rcDpiCorner.left;
- rcDest.bottom = rcImageDest.bottom;
+ rcDest.bottom = rcImageDest.bottom;
rcSource.left = rcImageSource.left;
rcSource.top = rcImageSource.bottom - rcCorners.bottom;
rcSource.right = rcImageSource.left + rcCorners.left;
rcSource.bottom = rcImageSource.bottom;
- if( ::IntersectRect(&rcTemp, &rcPaint, &rcDest) ) {
- DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
- }
- }
- // bottom
- if( rcCorners.bottom > 0 ) {
+ if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) {
+ DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
+ }
+ }
+ // bottom
+ if (rcCorners.bottom > 0) {
rcDest.left = rcImageDest.left + rcDpiCorner.left;
rcDest.top = rcImageDest.bottom - rcDpiCorner.bottom;
rcDest.right = rcImageDest.right - rcDpiCorner.right;
- rcDest.bottom = rcImageDest.bottom;
+ rcDest.bottom = rcImageDest.bottom;
rcSource.left = rcImageSource.left + rcCorners.left;
rcSource.top = rcImageSource.bottom - rcCorners.bottom;
rcSource.right = rcImageSource.right - rcCorners.right;
rcSource.bottom = rcImageSource.bottom;
- if( ::IntersectRect(&rcTemp, &rcPaint, &rcDest) ) {
- DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
- }
- }
- // right-bottom
- if( rcCorners.right > 0 && rcCorners.bottom > 0 ) {
+ if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) {
+ DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
+ }
+ }
+ // right-bottom
+ if (rcCorners.right > 0 && rcCorners.bottom > 0) {
rcDest.left = rcImageDest.right - rcDpiCorner.right;
rcDest.top = rcImageDest.bottom - rcDpiCorner.bottom;
rcDest.right = rcImageDest.right;
@@ -405,14 +405,14 @@ void RenderContext_GdiPlus::DrawImage(const UiRect& rcPaint, HBITMAP hBitmap, bo
rcSource.top = rcImageSource.bottom - rcCorners.bottom;
rcSource.right = rcImageSource.right;
rcSource.bottom = rcImageSource.bottom;
- if( ::IntersectRect(&rcTemp, &rcPaint, &rcDest) ) {
+ if (::IntersectRect(&rcTemp, &rcPaint, &rcDest)) {
DrawFunction(m_hDC, m_bTransparent, rcDest, hCloneDC, rcSource, bAlphaChannel, uFade);
- }
- }
+ }
+ }
::SetStretchBltMode(m_hDC, stretchBltMode);
- ::SelectObject(hCloneDC, hOldBitmap);
- ::DeleteDC(hCloneDC);
+ ::SelectObject(hCloneDC, hOldBitmap);
+ ::DeleteDC(hCloneDC);
}
void RenderContext_GdiPlus::DrawColor(const UiRect& rc, DWORD dwColor, BYTE uFade)
@@ -442,7 +442,7 @@ void RenderContext_GdiPlus::DrawColor(const UiRect& rc, const std::wstring& colo
DrawColor(rc, dwColor, uFade);
}
-void RenderContext_GdiPlus::DrawLine( const UiRect& rc, int nSize, DWORD dwPenColor)
+void RenderContext_GdiPlus::DrawLine(const UiRect& rc, int nSize, DWORD dwPenColor)
{
Gdiplus::Graphics graphics(m_hDC);
Gdiplus::Pen pen(Gdiplus::Color(dwPenColor), (Gdiplus::REAL)nSize);
@@ -471,39 +471,36 @@ void RenderContext_GdiPlus::DrawRect(const UiRect& rc, int nSize, DWORD dwPenCol
}
-void RenderContext_GdiPlus::DrawRoundRect(const UiRect& rc, const SIZE& round, int nSize, DWORD dwPenColor)
+void RenderContext_GdiPlus::DrawRoundRect(const UiRect& rc, const CSize& roundSize, int nSize, DWORD dwPenColor)
{
Gdiplus::Graphics graphics(m_hDC);
graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
Gdiplus::Pen pen(Gdiplus::Color(dwPenColor), (Gdiplus::REAL)nSize);
- //ü±߿ʱȫһ
- UiRect _rc = rc;
- _rc.left += 1;
- _rc.top += 1;
- _rc.right -= 1;
- _rc.bottom -= 1;
- //ˢ
- Gdiplus::SolidBrush brShadow(Gdiplus::Color(0,0, 0, 0));
+
+ // ü±߿ʱȫһ
+ // UiRect rcInflate = rc;
+ // rcInflate.Inflate({ -1, -1, -1, -1 });
+
Gdiplus::GraphicsPath pPath;
- pPath.AddArc(_rc.left, _rc.top, round.cx, round.cy, 180, 90);
- pPath.AddLine(_rc.left + round.cx, _rc.top, _rc.right - round.cx, _rc.top);
- pPath.AddArc(_rc.right - round.cx, _rc.top, round.cx, round.cy, 270, 90);
- pPath.AddLine(_rc.right, _rc.top + round.cy, _rc.right, _rc.bottom - round.cy);
- pPath.AddArc(_rc.right - round.cx, _rc.bottom - round.cy, round.cx, round.cy, 0, 90);
- pPath.AddLine(_rc.right - round.cx, _rc.bottom, _rc.left + round.cx, _rc.bottom);
- pPath.AddArc(_rc.left, _rc.bottom - round.cy, round.cx, round.cy, 90, 90);
- pPath.AddLine(_rc.left, _rc.bottom - round.cy, _rc.left, _rc.top + round.cy);
+ pPath.AddArc(rc.left, rc.top, roundSize.cx, roundSize.cy, 180, 90);
+ pPath.AddLine(rc.left + roundSize.cx, rc.top, rc.right - roundSize.cx, rc.top);
+ pPath.AddArc(rc.right - roundSize.cx, rc.top, roundSize.cx, roundSize.cy, 270, 90);
+ pPath.AddLine(rc.right, rc.top + roundSize.cy, rc.right, rc.bottom - roundSize.cy);
+ pPath.AddArc(rc.right - roundSize.cx, rc.bottom - roundSize.cy, roundSize.cx, roundSize.cy, 0, 90);
+ pPath.AddLine(rc.right - roundSize.cx, rc.bottom, rc.left + roundSize.cx, rc.bottom);
+ pPath.AddArc(rc.left, rc.bottom - roundSize.cy, roundSize.cx, roundSize.cy, 90, 90);
+ pPath.AddLine(rc.left, rc.bottom - roundSize.cy, rc.left, rc.top + roundSize.cy);
pPath.CloseFigure();
- graphics.FillPath(&brShadow, &pPath);
+
graphics.DrawPath(&pen, &pPath);
}
void RenderContext_GdiPlus::DrawText(const UiRect& rc, const std::wstring& strText, DWORD dwTextColor, const std::wstring& strFontId, UINT uStyle, BYTE uFade /*= 255*/, bool bLineLimit /*= false*/)
{
- ASSERT(::GetObjectType(m_hDC)==OBJ_DC || ::GetObjectType(m_hDC)==OBJ_MEMDC);
- if( strText.empty() ) return;
+ ASSERT(::GetObjectType(m_hDC) == OBJ_DC || ::GetObjectType(m_hDC) == OBJ_MEMDC);
+ if (strText.empty()) return;
- Gdiplus::Graphics graphics( m_hDC );
+ Gdiplus::Graphics graphics(m_hDC);
Gdiplus::Font font(m_hDC, GlobalManager::GetFont(strFontId));
Gdiplus::RectF rcPaint((Gdiplus::REAL)rc.left, (Gdiplus::REAL)rc.top, (Gdiplus::REAL)(rc.right - rc.left), (Gdiplus::REAL)(rc.bottom - rc.top));
int alpha = dwTextColor >> 24;
@@ -621,7 +618,7 @@ ui::UiRect RenderContext_GdiPlus::MeasureText(const std::wstring& strText, const
Gdiplus::RectF rcText((Gdiplus::REAL)0, (Gdiplus::REAL)0, (Gdiplus::REAL)width, height);
graphics.MeasureString(strText.c_str(), (int)strText.length(), &font, rcText, &stringFormat, &bounds);
}
-
+
UiRect rc(int(bounds.GetLeft()), int(bounds.GetTop()), int(bounds.GetRight() + 1), int(bounds.GetBottom() + 1));
return rc;
}
diff --git a/tool_kits/duilib/Render/Render.h b/tool_kits/duilib/Render/Render.h
index 68f17365..871d51cf 100644
--- a/tool_kits/duilib/Render/Render.h
+++ b/tool_kits/duilib/Render/Render.h
@@ -51,7 +51,7 @@ public:
virtual void DrawLine(const IPen* pen, int x1, int y1, int x2, int y2) override;
virtual void DrawBezier(const IPen* pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) override;
virtual void DrawRect(const UiRect& rc, int nSize, DWORD dwPenColor) override;
- virtual void DrawRoundRect(const UiRect& rc, const SIZE& round, int nSize, DWORD dwPenColor) override;
+ virtual void DrawRoundRect(const UiRect& rc, const CSize& roundSize, int nSize, DWORD dwPenColor) override;
virtual void DrawText(const UiRect& rc, const std::wstring& strText, DWORD dwTextColor, const std::wstring& strFontId, UINT uStyle, BYTE uFade = 255, bool bLineLimit = false) override;
virtual void DrawEllipse(const UiRect& rc, int nSize, DWORD dwColor) override;