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 "fpdfsdk/include/pdfwindow/PDFWindow.h" | 7 #include "fpdfsdk/include/pdfwindow/PDFWindow.h" |
8 #include "fpdfsdk/include/pdfwindow/PWL_Icon.h" | 8 #include "fpdfsdk/include/pdfwindow/PWL_Icon.h" |
9 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" | 9 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" |
10 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" | 10 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" |
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 FX_FLOAT dGreen = 0; | 1382 FX_FLOAT dGreen = 0; |
1383 FX_FLOAT dBlue = 0; | 1383 FX_FLOAT dBlue = 0; |
1384 | 1384 |
1385 PWLColorToARGB(color, nAlpha, dRed, dGreen, dBlue); | 1385 PWLColorToARGB(color, nAlpha, dRed, dGreen, dBlue); |
1386 | 1386 |
1387 return ArgbEncode(nAlpha, (int32_t)(dRed * 255), (int32_t)(dGreen * 255), | 1387 return ArgbEncode(nAlpha, (int32_t)(dRed * 255), (int32_t)(dGreen * 255), |
1388 (int32_t)(dBlue * 255)); | 1388 (int32_t)(dBlue * 255)); |
1389 } | 1389 } |
1390 | 1390 |
1391 void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice, | 1391 void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice, |
1392 CPDF_Matrix* pUser2Device, | 1392 CFX_Matrix* pUser2Device, |
1393 const CPDF_Rect& rect, | 1393 const CPDF_Rect& rect, |
1394 const FX_COLORREF& color) { | 1394 const FX_COLORREF& color) { |
1395 CFX_PathData path; | 1395 CFX_PathData path; |
1396 CPDF_Rect rcTemp(rect); | 1396 CPDF_Rect rcTemp(rect); |
1397 path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top); | 1397 path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top); |
1398 pDevice->DrawPath(&path, pUser2Device, NULL, color, 0, FXFILL_WINDING); | 1398 pDevice->DrawPath(&path, pUser2Device, NULL, color, 0, FXFILL_WINDING); |
1399 } | 1399 } |
1400 | 1400 |
1401 void CPWL_Utils::DrawFillArea(CFX_RenderDevice* pDevice, | 1401 void CPWL_Utils::DrawFillArea(CFX_RenderDevice* pDevice, |
1402 CPDF_Matrix* pUser2Device, | 1402 CFX_Matrix* pUser2Device, |
1403 const CPDF_Point* pPts, | 1403 const CPDF_Point* pPts, |
1404 int32_t nCount, | 1404 int32_t nCount, |
1405 const FX_COLORREF& color) { | 1405 const FX_COLORREF& color) { |
1406 CFX_PathData path; | 1406 CFX_PathData path; |
1407 path.SetPointCount(nCount); | 1407 path.SetPointCount(nCount); |
1408 | 1408 |
1409 path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_MOVETO); | 1409 path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_MOVETO); |
1410 for (int32_t i = 1; i < nCount; i++) | 1410 for (int32_t i = 1; i < nCount; i++) |
1411 path.SetPoint(i, pPts[i].x, pPts[i].y, FXPT_LINETO); | 1411 path.SetPoint(i, pPts[i].x, pPts[i].y, FXPT_LINETO); |
1412 | 1412 |
1413 pDevice->DrawPath(&path, pUser2Device, NULL, color, 0, FXFILL_ALTERNATE); | 1413 pDevice->DrawPath(&path, pUser2Device, NULL, color, 0, FXFILL_ALTERNATE); |
1414 } | 1414 } |
1415 | 1415 |
1416 void CPWL_Utils::DrawStrokeRect(CFX_RenderDevice* pDevice, | 1416 void CPWL_Utils::DrawStrokeRect(CFX_RenderDevice* pDevice, |
1417 CPDF_Matrix* pUser2Device, | 1417 CFX_Matrix* pUser2Device, |
1418 const CPDF_Rect& rect, | 1418 const CPDF_Rect& rect, |
1419 const FX_COLORREF& color, | 1419 const FX_COLORREF& color, |
1420 FX_FLOAT fWidth) { | 1420 FX_FLOAT fWidth) { |
1421 CFX_PathData path; | 1421 CFX_PathData path; |
1422 CPDF_Rect rcTemp(rect); | 1422 CPDF_Rect rcTemp(rect); |
1423 path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top); | 1423 path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top); |
1424 | 1424 |
1425 CFX_GraphStateData gsd; | 1425 CFX_GraphStateData gsd; |
1426 gsd.m_LineWidth = fWidth; | 1426 gsd.m_LineWidth = fWidth; |
1427 | 1427 |
1428 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE); | 1428 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE); |
1429 } | 1429 } |
1430 | 1430 |
1431 void CPWL_Utils::DrawStrokeLine(CFX_RenderDevice* pDevice, | 1431 void CPWL_Utils::DrawStrokeLine(CFX_RenderDevice* pDevice, |
1432 CPDF_Matrix* pUser2Device, | 1432 CFX_Matrix* pUser2Device, |
1433 const CPDF_Point& ptMoveTo, | 1433 const CPDF_Point& ptMoveTo, |
1434 const CPDF_Point& ptLineTo, | 1434 const CPDF_Point& ptLineTo, |
1435 const FX_COLORREF& color, | 1435 const FX_COLORREF& color, |
1436 FX_FLOAT fWidth) { | 1436 FX_FLOAT fWidth) { |
1437 CFX_PathData path; | 1437 CFX_PathData path; |
1438 path.SetPointCount(2); | 1438 path.SetPointCount(2); |
1439 path.SetPoint(0, ptMoveTo.x, ptMoveTo.y, FXPT_MOVETO); | 1439 path.SetPoint(0, ptMoveTo.x, ptMoveTo.y, FXPT_MOVETO); |
1440 path.SetPoint(1, ptLineTo.x, ptLineTo.y, FXPT_LINETO); | 1440 path.SetPoint(1, ptLineTo.x, ptLineTo.y, FXPT_LINETO); |
1441 | 1441 |
1442 CFX_GraphStateData gsd; | 1442 CFX_GraphStateData gsd; |
1443 gsd.m_LineWidth = fWidth; | 1443 gsd.m_LineWidth = fWidth; |
1444 | 1444 |
1445 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE); | 1445 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE); |
1446 } | 1446 } |
1447 | 1447 |
1448 void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice, | 1448 void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice, |
1449 CPDF_Matrix* pUser2Device, | 1449 CFX_Matrix* pUser2Device, |
1450 const CPDF_Rect& rect, | 1450 const CPDF_Rect& rect, |
1451 const CPWL_Color& color, | 1451 const CPWL_Color& color, |
1452 int32_t nTransparancy) { | 1452 int32_t nTransparancy) { |
1453 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rect, | 1453 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rect, |
1454 PWLColorToFXColor(color, nTransparancy)); | 1454 PWLColorToFXColor(color, nTransparancy)); |
1455 } | 1455 } |
1456 | 1456 |
1457 void CPWL_Utils::DrawShadow(CFX_RenderDevice* pDevice, | 1457 void CPWL_Utils::DrawShadow(CFX_RenderDevice* pDevice, |
1458 CPDF_Matrix* pUser2Device, | 1458 CFX_Matrix* pUser2Device, |
1459 FX_BOOL bVertical, | 1459 FX_BOOL bVertical, |
1460 FX_BOOL bHorizontal, | 1460 FX_BOOL bHorizontal, |
1461 CPDF_Rect rect, | 1461 CPDF_Rect rect, |
1462 int32_t nTransparancy, | 1462 int32_t nTransparancy, |
1463 int32_t nStartGray, | 1463 int32_t nStartGray, |
1464 int32_t nEndGray) { | 1464 int32_t nEndGray) { |
1465 FX_FLOAT fStepGray = 1.0f; | 1465 FX_FLOAT fStepGray = 1.0f; |
1466 | 1466 |
1467 if (bVertical) { | 1467 if (bVertical) { |
1468 fStepGray = (nEndGray - nStartGray) / rect.Height(); | 1468 fStepGray = (nEndGray - nStartGray) / rect.Height(); |
(...skipping 14 matching lines...) Expand all Loading... |
1483 int32_t nGray = nStartGray + (int32_t)(fStepGray * (fx - rect.left)); | 1483 int32_t nGray = nStartGray + (int32_t)(fStepGray * (fx - rect.left)); |
1484 CPWL_Utils::DrawStrokeLine( | 1484 CPWL_Utils::DrawStrokeLine( |
1485 pDevice, pUser2Device, CPDF_Point(fx, rect.bottom), | 1485 pDevice, pUser2Device, CPDF_Point(fx, rect.bottom), |
1486 CPDF_Point(fx, rect.top), | 1486 CPDF_Point(fx, rect.top), |
1487 ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f); | 1487 ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f); |
1488 } | 1488 } |
1489 } | 1489 } |
1490 } | 1490 } |
1491 | 1491 |
1492 void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, | 1492 void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, |
1493 CPDF_Matrix* pUser2Device, | 1493 CFX_Matrix* pUser2Device, |
1494 const CPDF_Rect& rect, | 1494 const CPDF_Rect& rect, |
1495 FX_FLOAT fWidth, | 1495 FX_FLOAT fWidth, |
1496 const CPWL_Color& color, | 1496 const CPWL_Color& color, |
1497 const CPWL_Color& crLeftTop, | 1497 const CPWL_Color& crLeftTop, |
1498 const CPWL_Color& crRightBottom, | 1498 const CPWL_Color& crRightBottom, |
1499 int32_t nStyle, | 1499 int32_t nStyle, |
1500 const CPWL_Dash& dash, | 1500 const CPWL_Dash& dash, |
1501 int32_t nTransparancy) { | 1501 int32_t nTransparancy) { |
1502 FX_FLOAT fLeft = rect.left; | 1502 FX_FLOAT fLeft = rect.left; |
1503 FX_FLOAT fRight = rect.right; | 1503 FX_FLOAT fRight = rect.right; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 | 1690 |
1691 AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep); | 1691 AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep); |
1692 | 1692 |
1693 if (bBreak) | 1693 if (bBreak) |
1694 break; | 1694 break; |
1695 } while (pIterator->NextLine()); | 1695 } while (pIterator->NextLine()); |
1696 } | 1696 } |
1697 } | 1697 } |
1698 | 1698 |
1699 void CPWL_Utils::DrawEditSpellCheck(CFX_RenderDevice* pDevice, | 1699 void CPWL_Utils::DrawEditSpellCheck(CFX_RenderDevice* pDevice, |
1700 CPDF_Matrix* pUser2Device, | 1700 CFX_Matrix* pUser2Device, |
1701 IFX_Edit* pEdit, | 1701 IFX_Edit* pEdit, |
1702 const CPDF_Rect& rcClip, | 1702 const CPDF_Rect& rcClip, |
1703 const CPDF_Point& ptOffset, | 1703 const CPDF_Point& ptOffset, |
1704 const CPVT_WordRange* pRange, | 1704 const CPVT_WordRange* pRange, |
1705 IPWL_SpellCheck* pSpellCheck) { | 1705 IPWL_SpellCheck* pSpellCheck) { |
1706 const FX_COLORREF crSpell = ArgbEncode(255, 255, 0, 0); | 1706 const FX_COLORREF crSpell = ArgbEncode(255, 255, 0, 0); |
1707 | 1707 |
1708 // for spellcheck | 1708 // for spellcheck |
1709 FX_BOOL bLatinWord = FALSE; | 1709 FX_BOOL bLatinWord = FALSE; |
1710 CPVT_WordPlace wpWordStart; | 1710 CPVT_WordPlace wpWordStart; |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1913 sAppStream += sPath; | 1913 sAppStream += sPath; |
1914 if (crStroke.nColorType != COLORTYPE_TRANSPARENT) | 1914 if (crStroke.nColorType != COLORTYPE_TRANSPARENT) |
1915 sAppStream += "B*\n"; | 1915 sAppStream += "B*\n"; |
1916 else | 1916 else |
1917 sAppStream += "f*\n"; | 1917 sAppStream += "f*\n"; |
1918 | 1918 |
1919 return sAppStream; | 1919 return sAppStream; |
1920 } | 1920 } |
1921 | 1921 |
1922 void CPWL_Utils::DrawIconAppStream(CFX_RenderDevice* pDevice, | 1922 void CPWL_Utils::DrawIconAppStream(CFX_RenderDevice* pDevice, |
1923 CPDF_Matrix* pUser2Device, | 1923 CFX_Matrix* pUser2Device, |
1924 int32_t nType, | 1924 int32_t nType, |
1925 const CPDF_Rect& rect, | 1925 const CPDF_Rect& rect, |
1926 const CPWL_Color& crFill, | 1926 const CPWL_Color& crFill, |
1927 const CPWL_Color& crStroke, | 1927 const CPWL_Color& crStroke, |
1928 const int32_t nTransparancy) { | 1928 const int32_t nTransparancy) { |
1929 CFX_GraphStateData gsd; | 1929 CFX_GraphStateData gsd; |
1930 gsd.m_LineWidth = 1.0f; | 1930 gsd.m_LineWidth = 1.0f; |
1931 | 1931 |
1932 CFX_ByteString sPath; | 1932 CFX_ByteString sPath; |
1933 CFX_PathData path; | 1933 CFX_PathData path; |
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3704 break; | 3704 break; |
3705 case COLORTYPE_RGB: | 3705 case COLORTYPE_RGB: |
3706 CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4, | 3706 CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4, |
3707 fColor1, fColor2, fColor3); | 3707 fColor1, fColor2, fColor3); |
3708 break; | 3708 break; |
3709 } | 3709 } |
3710 break; | 3710 break; |
3711 } | 3711 } |
3712 nColorType = other_nColorType; | 3712 nColorType = other_nColorType; |
3713 } | 3713 } |
OLD | NEW |