| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fwl/theme/cfwl_widgettp.h" | 7 #include "xfa/fwl/theme/cfwl_widgettp.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 const float kLineHeight = 12.0f; | 30 const float kLineHeight = 12.0f; |
| 31 const float kScrollBarWidth = 17.0f; | 31 const float kScrollBarWidth = 17.0f; |
| 32 const float kCXBorder = 1.0f; | 32 const float kCXBorder = 1.0f; |
| 33 const float kCYBorder = 1.0f; | 33 const float kCYBorder = 1.0f; |
| 34 | 34 |
| 35 #define FWLTHEME_CAPACITY_TextSelColor (ArgbEncode(255, 153, 193, 218)) | 35 #define FWLTHEME_CAPACITY_TextSelColor (ArgbEncode(255, 153, 193, 218)) |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 bool CFWL_WidgetTP::IsValidWidget(IFWL_Widget* pWidget) { | 39 bool CFWL_WidgetTP::IsValidWidget(IFWL_Widget* pWidget) { |
| 40 return FALSE; | 40 return false; |
| 41 } | 41 } |
| 42 | 42 |
| 43 uint32_t CFWL_WidgetTP::GetThemeID(IFWL_Widget* pWidget) { | 43 uint32_t CFWL_WidgetTP::GetThemeID(IFWL_Widget* pWidget) { |
| 44 return m_dwThemeID; | 44 return m_dwThemeID; |
| 45 } | 45 } |
| 46 | 46 |
| 47 uint32_t CFWL_WidgetTP::SetThemeID(IFWL_Widget* pWidget, uint32_t dwThemeID) { | 47 uint32_t CFWL_WidgetTP::SetThemeID(IFWL_Widget* pWidget, uint32_t dwThemeID) { |
| 48 uint32_t dwOld = m_dwThemeID; | 48 uint32_t dwOld = m_dwThemeID; |
| 49 m_dwThemeID = dwThemeID; | 49 m_dwThemeID = dwThemeID; |
| 50 if (CFWL_ArrowData::HasInstance()) | 50 if (CFWL_ArrowData::HasInstance()) |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 FX_ARGB beginColor, | 411 FX_ARGB beginColor, |
| 412 FX_ARGB endColor, | 412 FX_ARGB endColor, |
| 413 CFX_Path* path, | 413 CFX_Path* path, |
| 414 int32_t fillMode, | 414 int32_t fillMode, |
| 415 CFX_Matrix* pMatrix) { | 415 CFX_Matrix* pMatrix) { |
| 416 if (!pGraphics || !path) | 416 if (!pGraphics || !path) |
| 417 return; | 417 return; |
| 418 | 418 |
| 419 CFX_PointF begPoint(fx1, fy1); | 419 CFX_PointF begPoint(fx1, fy1); |
| 420 CFX_PointF endPoint(fx2, fy2); | 420 CFX_PointF endPoint(fx2, fy2); |
| 421 CFX_Shading shading(begPoint, endPoint, FALSE, FALSE, beginColor, endColor); | 421 CFX_Shading shading(begPoint, endPoint, false, false, beginColor, endColor); |
| 422 pGraphics->SaveGraphState(); | 422 pGraphics->SaveGraphState(); |
| 423 CFX_Color color1(&shading); | 423 CFX_Color color1(&shading); |
| 424 pGraphics->SetFillColor(&color1); | 424 pGraphics->SetFillColor(&color1); |
| 425 pGraphics->FillPath(path, fillMode, pMatrix); | 425 pGraphics->FillPath(path, fillMode, pMatrix); |
| 426 pGraphics->RestoreGraphState(); | 426 pGraphics->RestoreGraphState(); |
| 427 } | 427 } |
| 428 | 428 |
| 429 void CFWL_WidgetTP::DrawAnnulusRect(CFX_Graphics* pGraphics, | 429 void CFWL_WidgetTP::DrawAnnulusRect(CFX_Graphics* pGraphics, |
| 430 FX_ARGB fillColor, | 430 FX_ARGB fillColor, |
| 431 const CFX_RectF* pRect, | 431 const CFX_RectF* pRect, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 path.Create(); | 489 path.Create(); |
| 490 path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); | 490 path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); |
| 491 pGraphics->StrokePath(&path, pMatrix); | 491 pGraphics->StrokePath(&path, pMatrix); |
| 492 pGraphics->RestoreGraphState(); | 492 pGraphics->RestoreGraphState(); |
| 493 } | 493 } |
| 494 #define FWLTHEME_ARROW_Denominator 3 | 494 #define FWLTHEME_ARROW_Denominator 3 |
| 495 void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, | 495 void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, |
| 496 const CFX_RectF* pRect, | 496 const CFX_RectF* pRect, |
| 497 FWLTHEME_DIRECTION eDict, | 497 FWLTHEME_DIRECTION eDict, |
| 498 FX_ARGB argbFill, | 498 FX_ARGB argbFill, |
| 499 FX_BOOL bPressed, | 499 bool bPressed, |
| 500 CFX_Matrix* pMatrix) { | 500 CFX_Matrix* pMatrix) { |
| 501 CFX_RectF rtArrow(*pRect); | 501 CFX_RectF rtArrow(*pRect); |
| 502 CFX_Path path; | 502 CFX_Path path; |
| 503 path.Create(); | 503 path.Create(); |
| 504 FX_FLOAT fBtn = | 504 FX_FLOAT fBtn = |
| 505 std::min(pRect->width, pRect->height) / FWLTHEME_ARROW_Denominator; | 505 std::min(pRect->width, pRect->height) / FWLTHEME_ARROW_Denominator; |
| 506 rtArrow.left = pRect->left + (pRect->width - fBtn) / 2; | 506 rtArrow.left = pRect->left + (pRect->width - fBtn) / 2; |
| 507 rtArrow.top = pRect->top + (pRect->height - fBtn) / 2; | 507 rtArrow.top = pRect->top + (pRect->height - fBtn) / 2; |
| 508 rtArrow.width = fBtn; | 508 rtArrow.width = fBtn; |
| 509 rtArrow.height = fBtn; | 509 rtArrow.height = fBtn; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 pGraphics->SetFillColor(&cr); | 545 pGraphics->SetFillColor(&cr); |
| 546 pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); | 546 pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); |
| 547 pGraphics->RestoreGraphState(); | 547 pGraphics->RestoreGraphState(); |
| 548 } | 548 } |
| 549 | 549 |
| 550 void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, | 550 void CFWL_WidgetTP::DrawArrow(CFX_Graphics* pGraphics, |
| 551 const CFX_RectF* pRect, | 551 const CFX_RectF* pRect, |
| 552 FWLTHEME_DIRECTION eDict, | 552 FWLTHEME_DIRECTION eDict, |
| 553 FX_ARGB argSign, | 553 FX_ARGB argSign, |
| 554 CFX_Matrix* pMatrix) { | 554 CFX_Matrix* pMatrix) { |
| 555 FX_BOOL bVert = | 555 bool bVert = |
| 556 (eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down); | 556 (eDict == FWLTHEME_DIRECTION_Up || eDict == FWLTHEME_DIRECTION_Down); |
| 557 FX_FLOAT fLeft = | 557 FX_FLOAT fLeft = |
| 558 (FX_FLOAT)(((pRect->width - (bVert ? 9 : 6)) / 2 + pRect->left) + 0.5); | 558 (FX_FLOAT)(((pRect->width - (bVert ? 9 : 6)) / 2 + pRect->left) + 0.5); |
| 559 FX_FLOAT fTop = | 559 FX_FLOAT fTop = |
| 560 (FX_FLOAT)(((pRect->height - (bVert ? 6 : 9)) / 2 + pRect->top) + 0.5); | 560 (FX_FLOAT)(((pRect->height - (bVert ? 6 : 9)) / 2 + pRect->top) + 0.5); |
| 561 CFX_Path path; | 561 CFX_Path path; |
| 562 path.Create(); | 562 path.Create(); |
| 563 switch (eDict) { | 563 switch (eDict) { |
| 564 case FWLTHEME_DIRECTION_Down: { | 564 case FWLTHEME_DIRECTION_Down: { |
| 565 path.MoveTo(fLeft, fTop + 1); | 565 path.MoveTo(fLeft, fTop + 1); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 } | 642 } |
| 643 | 643 |
| 644 CFWL_ArrowData::CFWL_ArrowData() : m_pColorData(nullptr) { | 644 CFWL_ArrowData::CFWL_ArrowData() : m_pColorData(nullptr) { |
| 645 SetColorData(0); | 645 SetColorData(0); |
| 646 } | 646 } |
| 647 | 647 |
| 648 CFWL_FontData::CFWL_FontData() : m_dwStyles(0), m_dwCodePage(0) {} | 648 CFWL_FontData::CFWL_FontData() : m_dwStyles(0), m_dwCodePage(0) {} |
| 649 | 649 |
| 650 CFWL_FontData::~CFWL_FontData() {} | 650 CFWL_FontData::~CFWL_FontData() {} |
| 651 | 651 |
| 652 FX_BOOL CFWL_FontData::Equal(const CFX_WideStringC& wsFontFamily, | 652 bool CFWL_FontData::Equal(const CFX_WideStringC& wsFontFamily, |
| 653 uint32_t dwFontStyles, | 653 uint32_t dwFontStyles, |
| 654 uint16_t wCodePage) { | 654 uint16_t wCodePage) { |
| 655 return m_wsFamily == wsFontFamily && m_dwStyles == dwFontStyles && | 655 return m_wsFamily == wsFontFamily && m_dwStyles == dwFontStyles && |
| 656 m_dwCodePage == wCodePage; | 656 m_dwCodePage == wCodePage; |
| 657 } | 657 } |
| 658 | 658 |
| 659 FX_BOOL CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily, | 659 bool CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily, |
| 660 uint32_t dwFontStyles, | 660 uint32_t dwFontStyles, |
| 661 uint16_t dwCodePage) { | 661 uint16_t dwCodePage) { |
| 662 m_wsFamily = wsFontFamily; | 662 m_wsFamily = wsFontFamily; |
| 663 m_dwStyles = dwFontStyles; | 663 m_dwStyles = dwFontStyles; |
| 664 m_dwCodePage = dwCodePage; | 664 m_dwCodePage = dwCodePage; |
| 665 if (!m_pFontMgr) { | 665 if (!m_pFontMgr) { |
| 666 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 666 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 667 m_pFontMgr = IFGAS_FontMgr::Create(FX_GetDefFontEnumerator()); | 667 m_pFontMgr = IFGAS_FontMgr::Create(FX_GetDefFontEnumerator()); |
| 668 #else | 668 #else |
| 669 m_pFontSource.reset(new CFX_FontSourceEnum_File); | 669 m_pFontSource.reset(new CFX_FontSourceEnum_File); |
| 670 m_pFontMgr = IFGAS_FontMgr::Create(m_pFontSource.get()); | 670 m_pFontMgr = IFGAS_FontMgr::Create(m_pFontSource.get()); |
| 671 #endif | 671 #endif |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 CFWL_FontManager::DestroyInstance(); | 710 CFWL_FontManager::DestroyInstance(); |
| 711 } | 711 } |
| 712 | 712 |
| 713 uint32_t FWL_GetThemeLayout(uint32_t dwThemeID) { | 713 uint32_t FWL_GetThemeLayout(uint32_t dwThemeID) { |
| 714 return 0xffff0000 & dwThemeID; | 714 return 0xffff0000 & dwThemeID; |
| 715 } | 715 } |
| 716 | 716 |
| 717 uint32_t FWL_GetThemeColor(uint32_t dwThemeID) { | 717 uint32_t FWL_GetThemeColor(uint32_t dwThemeID) { |
| 718 return 0x0000ffff & dwThemeID; | 718 return 0x0000ffff & dwThemeID; |
| 719 } | 719 } |
| OLD | NEW |