diff options
Diffstat (limited to 'fpdfsdk/pdfwindow')
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_ComboBox.cpp | 6 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Edit.cpp | 30 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_EditCtrl.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_ScrollBar.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Utils.cpp | 68 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Utils.h | 6 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Wnd.cpp | 52 | ||||
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Wnd.h | 20 |
8 files changed, 82 insertions, 104 deletions
diff --git a/fpdfsdk/pdfwindow/PWL_ComboBox.cpp b/fpdfsdk/pdfwindow/PWL_ComboBox.cpp index aa0db4b291..f49016123a 100644 --- a/fpdfsdk/pdfwindow/PWL_ComboBox.cpp +++ b/fpdfsdk/pdfwindow/PWL_ComboBox.cpp @@ -303,7 +303,7 @@ void CPWL_ComboBox::CreateEdit(const PWL_CREATEPARAM& cp) { ecp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0); ecp.dwBorderWidth = 0; - ecp.nBorderStyle = PBS_SOLID; + ecp.nBorderStyle = BorderStyle::SOLID; m_pEdit->Create(ecp); } @@ -319,7 +319,7 @@ void CPWL_ComboBox::CreateButton(const PWL_CREATEPARAM& cp) { bcp.sBackgroundColor = PWL_SCROLLBAR_BKCOLOR; bcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR; bcp.dwBorderWidth = 2; - bcp.nBorderStyle = PBS_BEVELED; + bcp.nBorderStyle = BorderStyle::BEVELED; bcp.eCursorType = FXCT_ARROW; m_pButton->Create(bcp); @@ -334,7 +334,7 @@ void CPWL_ComboBox::CreateListBox(const PWL_CREATEPARAM& cp) { lcp.pParentWnd = this; lcp.dwFlags = PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PLBS_HOVERSEL | PWS_VSCROLL; - lcp.nBorderStyle = PBS_SOLID; + lcp.nBorderStyle = BorderStyle::SOLID; lcp.dwBorderWidth = 1; lcp.eCursorType = FXCT_ARROW; lcp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0); diff --git a/fpdfsdk/pdfwindow/PWL_Edit.cpp b/fpdfsdk/pdfwindow/PWL_Edit.cpp index ae95570d6c..e39b6c13c7 100644 --- a/fpdfsdk/pdfwindow/PWL_Edit.cpp +++ b/fpdfsdk/pdfwindow/PWL_Edit.cpp @@ -199,7 +199,7 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { if (nCharArray > 0) { switch (GetBorderStyle()) { - case PBS_SOLID: { + case BorderStyle::SOLID: { sLine << "q\n" << GetBorderWidth() << " w\n" << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) .AsStringC() @@ -215,8 +215,9 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { } sLine << "Q\n"; - } break; - case PBS_DASH: { + break; + } + case BorderStyle::DASH: { sLine << "q\n" << GetBorderWidth() << " w\n" << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) .AsStringC() @@ -234,7 +235,10 @@ void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { } sLine << "Q\n"; - } break; + break; + } + default: + break; } } @@ -318,7 +322,7 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, if (nCharArray > 0 && nCharArraySafe.IsValid()) { switch (GetBorderStyle()) { - case PBS_SOLID: { + case BorderStyle::SOLID: { CFX_GraphStateData gsd; gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); @@ -337,13 +341,15 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top, FXPT_LINETO); } - if (path.GetPointCount() > 0) + if (path.GetPointCount() > 0) { pDevice->DrawPath( &path, pUser2Device, &gsd, 0, CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), FXFILL_ALTERNATE); - } break; - case PBS_DASH: { + } + break; + } + case BorderStyle::DASH: { CFX_GraphStateData gsd; gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); @@ -367,12 +373,16 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top, FXPT_LINETO); } - if (path.GetPointCount() > 0) + if (path.GetPointCount() > 0) { pDevice->DrawPath( &path, pUser2Device, &gsd, 0, CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), FXFILL_ALTERNATE); - } break; + } + break; + } + default: + break; } } diff --git a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp index 88046a2d86..aa653929bd 100644 --- a/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp +++ b/fpdfsdk/pdfwindow/PWL_EditCtrl.cpp @@ -128,7 +128,7 @@ void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM& cp) { ecp.pParentWnd = this; ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP; ecp.dwBorderWidth = 0; - ecp.nBorderStyle = PBS_SOLID; + ecp.nBorderStyle = BorderStyle::SOLID; ecp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0); m_pEditCaret->Create(ecp); diff --git a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp index 385ff44f4a..9532244bc9 100644 --- a/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp +++ b/fpdfsdk/pdfwindow/PWL_ScrollBar.cpp @@ -852,7 +852,7 @@ void CPWL_ScrollBar::CreateButtons(const PWL_CREATEPARAM& cp) { PWL_CREATEPARAM scp = cp; scp.pParentWnd = this; scp.dwBorderWidth = 2; - scp.nBorderStyle = PBS_BEVELED; + scp.nBorderStyle = BorderStyle::BEVELED; scp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PWS_NOREFRESHCLIP; diff --git a/fpdfsdk/pdfwindow/PWL_Utils.cpp b/fpdfsdk/pdfwindow/PWL_Utils.cpp index 60949abd4e..e4232db5e8 100644 --- a/fpdfsdk/pdfwindow/PWL_Utils.cpp +++ b/fpdfsdk/pdfwindow/PWL_Utils.cpp @@ -714,7 +714,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, const CPWL_Color& color, const CPWL_Color& crLeftTop, const CPWL_Color& crRightBottom, - int32_t nStyle, + BorderStyle nStyle, const CPWL_Dash& dash) { CFX_ByteTextBuf sAppStream; CFX_ByteString sColor; @@ -731,7 +731,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, switch (nStyle) { default: - case PBS_SOLID: + case BorderStyle::SOLID: sColor = CPWL_Utils::GetColorAppStream(color, TRUE); if (sColor.GetLength() > 0) { sAppStream << sColor; @@ -743,7 +743,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, sAppStream << "f*\n"; } break; - case PBS_DASH: + case BorderStyle::DASH: sColor = CPWL_Utils::GetColorAppStream(color, FALSE); if (sColor.GetLength() > 0) { sAppStream << sColor; @@ -762,8 +762,8 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, << " l S\n"; } break; - case PBS_BEVELED: - case PBS_INSET: + case BorderStyle::BEVELED: + case BorderStyle::INSET: sColor = CPWL_Utils::GetColorAppStream(crLeftTop, TRUE); if (sColor.GetLength() > 0) { sAppStream << sColor; @@ -808,7 +808,7 @@ CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, << fTop - fBottom - fHalfWidth * 2 << " re f*\n"; } break; - case PBS_UNDERLINED: + case BorderStyle::UNDERLINE: sColor = CPWL_Utils::GetColorAppStream(color, FALSE); if (sColor.GetLength() > 0) { sAppStream << sColor; @@ -831,7 +831,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( const CPWL_Color& color, const CPWL_Color& crLeftTop, const CPWL_Color& crRightBottom, - int32_t nStyle, + BorderStyle nStyle, const CPWL_Dash& dash) { CFX_ByteTextBuf sAppStream; CFX_ByteString sColor; @@ -841,8 +841,8 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( switch (nStyle) { default: - case PBS_SOLID: - case PBS_UNDERLINED: { + case BorderStyle::SOLID: + case BorderStyle::UNDERLINE: { sColor = CPWL_Utils::GetColorAppStream(color, FALSE); if (sColor.GetLength() > 0) { sAppStream << "q\n" << fWidth << " w\n" << sColor @@ -851,7 +851,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( << " S\nQ\n"; } } break; - case PBS_DASH: { + case BorderStyle::DASH: { sColor = CPWL_Utils::GetColorAppStream(color, FALSE); if (sColor.GetLength() > 0) { sAppStream << "q\n" << fWidth << " w\n" @@ -862,7 +862,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( << " S\nQ\n"; } } break; - case PBS_BEVELED: { + case BorderStyle::BEVELED: { FX_FLOAT fHalfWidth = fWidth / 2.0f; sColor = CPWL_Utils::GetColorAppStream(color, FALSE); @@ -889,7 +889,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( << " S\nQ\n"; } } break; - case PBS_INSET: { + case BorderStyle::INSET: { FX_FLOAT fHalfWidth = fWidth / 2.0f; sColor = CPWL_Utils::GetColorAppStream(color, FALSE); @@ -1078,11 +1078,12 @@ CFX_ByteString CPWL_Utils::GetDropButtonAppStream(const CFX_FloatRect& rcBBox) { << rcBBox.top - rcBBox.bottom << " re f\n"; sAppStream << "Q\n"; - sAppStream << "q\n" << CPWL_Utils::GetBorderAppStream( - rcBBox, 2, CPWL_Color(COLORTYPE_GRAY, 0), - CPWL_Color(COLORTYPE_GRAY, 1), - CPWL_Color(COLORTYPE_GRAY, 0.5), PBS_BEVELED, - CPWL_Dash(3, 0, 0)) + sAppStream << "q\n" + << CPWL_Utils::GetBorderAppStream( + rcBBox, 2, CPWL_Color(COLORTYPE_GRAY, 0), + CPWL_Color(COLORTYPE_GRAY, 1), + CPWL_Color(COLORTYPE_GRAY, 0.5), BorderStyle::BEVELED, + CPWL_Dash(3, 0, 0)) << "Q\n"; CFX_FloatPoint ptCenter = CFX_FloatPoint((rcBBox.left + rcBBox.right) / 2, @@ -1322,7 +1323,7 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, const CPWL_Color& color, const CPWL_Color& crLeftTop, const CPWL_Color& crRightBottom, - int32_t nStyle, + BorderStyle nStyle, int32_t nTransparancy) { FX_FLOAT fLeft = rect.left; FX_FLOAT fRight = rect.right; @@ -1334,7 +1335,7 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, switch (nStyle) { default: - case PBS_SOLID: { + case BorderStyle::SOLID: { CFX_PathData path; path.AppendRect(fLeft, fBottom, fRight, fTop); path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth, @@ -1342,8 +1343,9 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, pDevice->DrawPath(&path, pUser2Device, NULL, PWLColorToFXColor(color, nTransparancy), 0, FXFILL_ALTERNATE); - } break; - case PBS_DASH: { + break; + } + case BorderStyle::DASH: { CFX_PathData path; path.SetPointCount(5); @@ -1368,9 +1370,10 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, pDevice->DrawPath(&path, pUser2Device, &gsd, 0, PWLColorToFXColor(color, nTransparancy), FXFILL_WINDING); - } break; - case PBS_BEVELED: - case PBS_INSET: { + break; + } + case BorderStyle::BEVELED: + case BorderStyle::INSET: { CFX_GraphStateData gsd; gsd.m_LineWidth = fHalfWidth; @@ -1423,8 +1426,9 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, pDevice->DrawPath(&path, pUser2Device, &gsd, PWLColorToFXColor(color, nTransparancy), 0, FXFILL_ALTERNATE); - } break; - case PBS_UNDERLINED: { + break; + } + case BorderStyle::UNDERLINE: { CFX_PathData path; path.SetPointCount(2); @@ -1437,16 +1441,8 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, pDevice->DrawPath(&path, pUser2Device, &gsd, 0, PWLColorToFXColor(color, nTransparancy), FXFILL_ALTERNATE); - } break; - case PBS_SHADOW: { - CFX_PathData path; - path.AppendRect(fLeft, fBottom, fRight, fTop); - path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth, - fTop - fWidth); - pDevice->DrawPath(&path, pUser2Device, NULL, - PWLColorToFXColor(color, nTransparancy / 2), 0, - FXFILL_ALTERNATE); - } break; + break; + } } } } diff --git a/fpdfsdk/pdfwindow/PWL_Utils.h b/fpdfsdk/pdfwindow/PWL_Utils.h index cdef768cfa..8ab08a857e 100644 --- a/fpdfsdk/pdfwindow/PWL_Utils.h +++ b/fpdfsdk/pdfwindow/PWL_Utils.h @@ -136,7 +136,7 @@ class CPWL_Utils { const CPWL_Color& color, const CPWL_Color& crLeftTop, const CPWL_Color& crRightBottom, - int32_t nStyle, + BorderStyle nStyle, const CPWL_Dash& dash); static CFX_ByteString GetCircleBorderAppStream( const CFX_FloatRect& rect, @@ -144,7 +144,7 @@ class CPWL_Utils { const CPWL_Color& color, const CPWL_Color& crLeftTop, const CPWL_Color& crRightBottom, - int32_t nStyle, + BorderStyle nStyle, const CPWL_Dash& dash); static CFX_ByteString GetRectFillAppStream(const CFX_FloatRect& rect, const CPWL_Color& color); @@ -213,7 +213,7 @@ class CPWL_Utils { const CPWL_Color& color, const CPWL_Color& crLeftTop, const CPWL_Color& crRightBottom, - int32_t nStyle, + BorderStyle nStyle, int32_t nTransparancy); static void DrawFillArea(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device, diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/pdfwindow/PWL_Wnd.cpp index bb424ffa43..310f2f3f90 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.cpp +++ b/fpdfsdk/pdfwindow/PWL_Wnd.cpp @@ -585,11 +585,11 @@ CPWL_Color CPWL_Wnd::GetTextStrokeColor() const { return m_sPrivateParam.sTextStrokeColor; } -int32_t CPWL_Wnd::GetBorderStyle() const { +BorderStyle CPWL_Wnd::GetBorderStyle() const { return m_sPrivateParam.nBorderStyle; } -void CPWL_Wnd::SetBorderStyle(int32_t nBorderStyle) { +void CPWL_Wnd::SetBorderStyle(BorderStyle nBorderStyle) { if (HasFlag(PWS_BORDER)) m_sPrivateParam.nBorderStyle = nBorderStyle; } @@ -819,46 +819,26 @@ IPVT_FontMap* CPWL_Wnd::GetFontMap() const { return m_sPrivateParam.pFontMap; } -CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(int32_t nBorderStyle) const { - CPWL_Color color; - +CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(BorderStyle nBorderStyle) const { switch (nBorderStyle) { - case PBS_SOLID: - break; - case PBS_DASH: - break; - case PBS_BEVELED: - color = CPWL_Color(COLORTYPE_GRAY, 1); - break; - case PBS_INSET: - color = CPWL_Color(COLORTYPE_GRAY, 0.5f); - break; - case PBS_UNDERLINED: - break; + case BorderStyle::BEVELED: + return CPWL_Color(COLORTYPE_GRAY, 1); + case BorderStyle::INSET: + return CPWL_Color(COLORTYPE_GRAY, 0.5f); + default: + return CPWL_Color(); } - - return color; } -CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(int32_t nBorderStyle) const { - CPWL_Color color; - +CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(BorderStyle nBorderStyle) const { switch (nBorderStyle) { - case PBS_SOLID: - break; - case PBS_DASH: - break; - case PBS_BEVELED: - color = CPWL_Utils::DevideColor(GetBackgroundColor(), 2); - break; - case PBS_INSET: - color = CPWL_Color(COLORTYPE_GRAY, 0.75f); - break; - case PBS_UNDERLINED: - break; + case BorderStyle::BEVELED: + return CPWL_Utils::DevideColor(GetBackgroundColor(), 2); + case BorderStyle::INSET: + return CPWL_Color(COLORTYPE_GRAY, 0.75f); + default: + return CPWL_Color(); } - - return color; } int32_t CPWL_Wnd::GetTransparency() { diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.h b/fpdfsdk/pdfwindow/PWL_Wnd.h index 319e6da9a4..c8552fb985 100644 --- a/fpdfsdk/pdfwindow/PWL_Wnd.h +++ b/fpdfsdk/pdfwindow/PWL_Wnd.h @@ -68,14 +68,6 @@ class IPWL_Provider; #define PRES_MULTIPAGES 0x0200L #define PRES_TEXTOVERFLOW 0x0400L -// border style -#define PBS_SOLID 0 -#define PBS_DASH 1 -#define PBS_BEVELED 2 -#define PBS_INSET 3 -#define PBS_UNDERLINED 4 -#define PBS_SHADOW 5 - // notification messages #define PNM_ADDCHILD 0x00000000L #define PNM_REMOVECHILD 0x00000001L @@ -203,7 +195,7 @@ struct PWL_CREATEPARAM { dwFlags(0), sBackgroundColor(), hAttachedWnd(NULL), - nBorderStyle(PBS_SOLID), + nBorderStyle(BorderStyle::SOLID), dwBorderWidth(1), sBorderColor(), sTextColor(), @@ -225,7 +217,7 @@ struct PWL_CREATEPARAM { uint32_t dwFlags; // optional CPWL_Color sBackgroundColor; // optional FX_HWND hAttachedWnd; // required for no-reader framework - int32_t nBorderStyle; // optional + BorderStyle nBorderStyle; // optional int32_t dwBorderWidth; // optional CPWL_Color sBorderColor; // optional CPWL_Color sTextColor; // optional @@ -322,14 +314,14 @@ class CPWL_Wnd : public CPWL_TimerHandler { virtual CPWL_Color GetTextStrokeColor() const; virtual FX_FLOAT GetFontSize() const; virtual int32_t GetInnerBorderWidth() const; - virtual CPWL_Color GetBorderLeftTopColor(int32_t nBorderStyle) const; - virtual CPWL_Color GetBorderRightBottomColor(int32_t nBorderStyle) const; + virtual CPWL_Color GetBorderLeftTopColor(BorderStyle nBorderStyle) const; + virtual CPWL_Color GetBorderRightBottomColor(BorderStyle nBorderStyle) const; virtual void SetFontSize(FX_FLOAT fFontSize); void SetBackgroundColor(const CPWL_Color& color); void SetClipRect(const CFX_FloatRect& rect); - void SetBorderStyle(int32_t eBorderStyle); + void SetBorderStyle(BorderStyle eBorderStyle); virtual CFX_FloatRect GetWindowRect() const; virtual CFX_FloatRect GetClientRect() const; @@ -341,7 +333,7 @@ class CPWL_Wnd : public CPWL_TimerHandler { void RemoveFlag(uint32_t dwFlags); const CFX_FloatRect& GetClipRect() const; CPWL_Wnd* GetParentWindow() const; - int32_t GetBorderStyle() const; + BorderStyle GetBorderStyle() const; const CPWL_Dash& GetBorderDash() const; void* GetAttachedData() const; |