summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/pdfwindow
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2016-03-14 13:51:24 -0400
committerDan Sinclair <dsinclair@chromium.org>2016-03-14 13:51:24 -0400
commitf766ad219f66543654520f6a1955836f519e26d1 (patch)
tree2edf8bc93b89503a3669f7add5b6c2a407b8a78c /fpdfsdk/src/pdfwindow
parent54b0abed08048008498471e39b7c72b034474090 (diff)
downloadpdfium-f766ad219f66543654520f6a1955836f519e26d1.tar.xz
Move fpdfsdk/src up to fpdfsdk/.
This CL moves the files in fpdfsdk/src/ up one level to fpdfsdk/ and fixes up the include paths, include guards and build files. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1799773002 .
Diffstat (limited to 'fpdfsdk/src/pdfwindow')
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Button.cpp41
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Caret.cpp160
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp651
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Edit.cpp1190
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp629
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_FontMap.cpp499
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Icon.cpp223
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_IconList.cpp501
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Label.cpp150
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_ListBox.cpp533
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp204
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Note.cpp1512
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp1197
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Signature.cpp177
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp82
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Utils.cpp3681
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Wnd.cpp1041
17 files changed, 0 insertions, 12471 deletions
diff --git a/fpdfsdk/src/pdfwindow/PWL_Button.cpp b/fpdfsdk/src/pdfwindow/PWL_Button.cpp
deleted file mode 100644
index 2c6c36c047..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_Button.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_Button.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-
-CPWL_Button::CPWL_Button() : m_bMouseDown(FALSE) {}
-
-CPWL_Button::~CPWL_Button() {
-}
-
-CFX_ByteString CPWL_Button::GetClassName() const {
- return "CPWL_Button";
-}
-
-void CPWL_Button::OnCreate(PWL_CREATEPARAM& cp) {
- cp.eCursorType = FXCT_HAND;
-}
-
-FX_BOOL CPWL_Button::OnLButtonDown(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonDown(point, nFlag);
-
- m_bMouseDown = TRUE;
- SetCapture();
-
- return TRUE;
-}
-
-FX_BOOL CPWL_Button::OnLButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonUp(point, nFlag);
-
- ReleaseCapture();
- m_bMouseDown = FALSE;
-
- return TRUE;
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_Caret.cpp b/fpdfsdk/src/pdfwindow/PWL_Caret.cpp
deleted file mode 100644
index 320b2bf62f..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_Caret.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_Caret.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-
-#define PWL_CARET_FLASHINTERVAL 500
-
-CPWL_Caret::CPWL_Caret()
- : m_bFlash(FALSE),
- m_ptHead(0, 0),
- m_ptFoot(0, 0),
- m_fWidth(0.4f),
- m_nDelay(0) {}
-
-CPWL_Caret::~CPWL_Caret() {}
-
-CFX_ByteString CPWL_Caret::GetClassName() const {
- return "CPWL_Caret";
-}
-
-void CPWL_Caret::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- GetCaretApp(sAppStream, CFX_FloatPoint(0.0f, 0.0f));
-}
-
-void CPWL_Caret::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- if (IsVisible() && m_bFlash) {
- CFX_FloatRect rcRect = GetCaretRect();
- CFX_FloatRect rcClip = GetClipRect();
-
- CFX_PathData path;
-
- path.SetPointCount(2);
-
- FX_FLOAT fCaretX = rcRect.left + m_fWidth * 0.5f;
- FX_FLOAT fCaretTop = rcRect.top;
- FX_FLOAT fCaretBottom = rcRect.bottom;
-
- if (!rcClip.IsEmpty()) {
- rcRect.Intersect(rcClip);
- if (!rcRect.IsEmpty()) {
- fCaretTop = rcRect.top;
- fCaretBottom = rcRect.bottom;
- path.SetPoint(0, fCaretX, fCaretBottom, FXPT_MOVETO);
- path.SetPoint(1, fCaretX, fCaretTop, FXPT_LINETO);
- } else {
- return;
- }
- } else {
- path.SetPoint(0, fCaretX, fCaretBottom, FXPT_MOVETO);
- path.SetPoint(1, fCaretX, fCaretTop, FXPT_LINETO);
- }
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = m_fWidth;
-
- pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0),
- FXFILL_ALTERNATE);
- }
-}
-
-void CPWL_Caret::GetCaretApp(CFX_ByteTextBuf& sAppStream,
- const CFX_FloatPoint& ptOffset) {
- if (IsVisible() && m_bFlash) {
- CFX_ByteTextBuf sCaret;
-
- CFX_FloatRect rcRect = GetCaretRect();
- CFX_FloatRect rcClip = GetClipRect();
-
- rcRect = CPWL_Utils::OffsetRect(rcRect, ptOffset.x, ptOffset.y);
- rcClip = CPWL_Utils::OffsetRect(rcClip, ptOffset.x, ptOffset.y);
-
- sCaret << "q\n";
- if (!rcClip.IsEmpty()) {
- sCaret << rcClip.left << " " << rcClip.bottom + 2.5f << " "
- << rcClip.right - rcClip.left << " "
- << rcClip.top - rcClip.bottom - 4.5f << " re W n\n";
- }
- sCaret << m_fWidth << " w\n0 G\n";
- sCaret << rcRect.left + m_fWidth / 2 << " " << rcRect.bottom << " m\n";
- sCaret << rcRect.left + m_fWidth / 2 << " " << rcRect.top << " l S\nQ\n";
-
- sAppStream << sCaret;
- }
-}
-
-CFX_ByteString CPWL_Caret::GetCaretAppearanceStream(
- const CFX_FloatPoint& ptOffset) {
- CFX_ByteTextBuf sCaret;
- GetCaretApp(sCaret, ptOffset);
- return sCaret.GetByteString();
-}
-
-void CPWL_Caret::TimerProc() {
- if (m_nDelay > 0) {
- m_nDelay--;
- } else {
- m_bFlash = !m_bFlash;
- InvalidateRect();
- }
-}
-
-CFX_FloatRect CPWL_Caret::GetCaretRect() const {
- return CFX_FloatRect(m_ptFoot.x, m_ptFoot.y, m_ptHead.x + m_fWidth,
- m_ptHead.y);
-}
-
-void CPWL_Caret::SetCaret(FX_BOOL bVisible,
- const CFX_FloatPoint& ptHead,
- const CFX_FloatPoint& ptFoot) {
- if (bVisible) {
- if (IsVisible()) {
- if (m_ptHead.x != ptHead.x || m_ptHead.y != ptHead.y ||
- m_ptFoot.x != ptFoot.x || m_ptFoot.y != ptFoot.y) {
- m_ptHead = ptHead;
- m_ptFoot = ptFoot;
-
- m_bFlash = TRUE;
- Move(m_rcInvalid, FALSE, TRUE);
- }
- } else {
- m_ptHead = ptHead;
- m_ptFoot = ptFoot;
-
- EndTimer();
- BeginTimer(PWL_CARET_FLASHINTERVAL);
-
- CPWL_Wnd::SetVisible(TRUE);
- m_bFlash = TRUE;
-
- Move(m_rcInvalid, FALSE, TRUE);
- }
- } else {
- m_ptHead = CFX_FloatPoint(0, 0);
- m_ptFoot = CFX_FloatPoint(0, 0);
-
- m_bFlash = FALSE;
- if (IsVisible()) {
- EndTimer();
- CPWL_Wnd::SetVisible(FALSE);
- }
- }
-}
-
-void CPWL_Caret::InvalidateRect(CFX_FloatRect* pRect) {
- if (pRect) {
- CFX_FloatRect rcRefresh = CPWL_Utils::InflateRect(*pRect, 0.5f);
- rcRefresh.top += 1;
- rcRefresh.bottom -= 1;
-
- CPWL_Wnd::InvalidateRect(&rcRefresh);
- } else {
- CPWL_Wnd::InvalidateRect(pRect);
- }
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
deleted file mode 100644
index 6edd6bdd85..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
+++ /dev/null
@@ -1,651 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_ComboBox.h"
-
-#include "fpdfsdk/include/pdfwindow/PWL_Edit.h"
-#include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h"
-#include "fpdfsdk/include/pdfwindow/PWL_ListBox.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-#include "public/fpdf_fwlevent.h"
-
-#define PWLCB_DEFAULTFONTSIZE 12.0f
-
-#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
-#define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
-
-FX_BOOL CPWL_CBListBox::OnLButtonUp(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonUp(point, nFlag);
-
- if (m_bMouseDown) {
- ReleaseCapture();
- m_bMouseDown = FALSE;
-
- if (ClientHitTest(point)) {
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_LBUTTONUP, 0,
- PWL_MAKEDWORD(point.x, point.y));
- }
-
- FX_BOOL bExit = FALSE;
- OnNotifySelChanged(FALSE, bExit, nFlag);
- if (bExit)
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_CBListBox::OnKeyDownWithExit(FX_WORD nChar,
- FX_BOOL& bExit,
- FX_DWORD nFlag) {
- if (!m_pList)
- return FALSE;
-
- switch (nChar) {
- default:
- return FALSE;
- case FWL_VKEY_Up:
- case FWL_VKEY_Down:
- case FWL_VKEY_Home:
- case FWL_VKEY_Left:
- case FWL_VKEY_End:
- case FWL_VKEY_Right:
- break;
- }
-
- switch (nChar) {
- case FWL_VKEY_Up:
- m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Down:
- m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Home:
- m_pList->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Left:
- m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_End:
- m_pList->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Right:
- m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Delete:
- break;
- }
-
- OnNotifySelChanged(TRUE, bExit, nFlag);
-
- return TRUE;
-}
-
-FX_BOOL CPWL_CBListBox::OnCharWithExit(FX_WORD nChar,
- FX_BOOL& bExit,
- FX_DWORD nFlag) {
- if (!m_pList)
- return FALSE;
-
- if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)))
- return FALSE;
-
- if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow()) {
- pComboBox->SetSelectText();
- }
-
- OnNotifySelChanged(TRUE, bExit, nFlag);
-
- return TRUE;
-}
-
-void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
-
- CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect();
-
- if (IsVisible() && !rectWnd.IsEmpty()) {
- CFX_ByteTextBuf sButton;
-
- CFX_FloatPoint ptCenter = GetCenterPoint();
-
- CFX_FloatPoint pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
- ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CFX_FloatPoint pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
- ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CFX_FloatPoint pt3(ptCenter.x,
- ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
-
- if (IsFloatBigger(rectWnd.right - rectWnd.left,
- PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
- IsFloatBigger(rectWnd.top - rectWnd.bottom,
- PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
- sButton << "0 g\n";
- sButton << pt1.x << " " << pt1.y << " m\n";
- sButton << pt2.x << " " << pt2.y << " l\n";
- sButton << pt3.x << " " << pt3.y << " l\n";
- sButton << pt1.x << " " << pt1.y << " l f\n";
-
- sAppStream << "q\n" << sButton << "Q\n";
- }
- }
-}
-
-void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
-
- CFX_FloatRect rectWnd = CPWL_Wnd::GetWindowRect();
-
- if (IsVisible() && !rectWnd.IsEmpty()) {
- CFX_FloatPoint ptCenter = GetCenterPoint();
-
- CFX_FloatPoint pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,
- ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CFX_FloatPoint pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,
- ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CFX_FloatPoint pt3(ptCenter.x,
- ptCenter.y - PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
-
- if (IsFloatBigger(rectWnd.right - rectWnd.left,
- PWL_CBBUTTON_TRIANGLE_HALFLEN * 2) &&
- IsFloatBigger(rectWnd.top - rectWnd.bottom,
- PWL_CBBUTTON_TRIANGLE_HALFLEN)) {
- CFX_PathData path;
-
- path.SetPointCount(4);
- path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO);
- path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO);
- path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO);
- path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO);
-
- pDevice->DrawPath(&path, pUser2Device, NULL,
- CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_BLACKCOLOR,
- GetTransparency()),
- 0, FXFILL_ALTERNATE);
- }
- }
-}
-
-FX_BOOL CPWL_CBButton::OnLButtonDown(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonDown(point, nFlag);
-
- SetCapture();
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_LBUTTONDOWN, 0,
- PWL_MAKEDWORD(point.x, point.y));
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_CBButton::OnLButtonUp(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonUp(point, nFlag);
-
- ReleaseCapture();
-
- return TRUE;
-}
-
-CPWL_ComboBox::CPWL_ComboBox()
- : m_pEdit(NULL),
- m_pButton(NULL),
- m_pList(NULL),
- m_bPopup(FALSE),
- m_nPopupWhere(0),
- m_nSelectItem(-1),
- m_pFillerNotify(NULL) {}
-
-CFX_ByteString CPWL_ComboBox::GetClassName() const {
- return "CPWL_ComboBox";
-}
-
-void CPWL_ComboBox::OnCreate(PWL_CREATEPARAM& cp) {
- cp.dwFlags &= ~PWS_HSCROLL;
- cp.dwFlags &= ~PWS_VSCROLL;
-}
-
-void CPWL_ComboBox::SetFocus() {
- if (m_pEdit)
- m_pEdit->SetFocus();
-}
-
-void CPWL_ComboBox::KillFocus() {
- SetPopup(FALSE);
- CPWL_Wnd::KillFocus();
-}
-
-CFX_WideString CPWL_ComboBox::GetText() const {
- if (m_pEdit) {
- return m_pEdit->GetText();
- }
- return CFX_WideString();
-}
-
-void CPWL_ComboBox::SetText(const FX_WCHAR* text) {
- if (m_pEdit)
- m_pEdit->SetText(text);
-}
-
-void CPWL_ComboBox::AddString(const FX_WCHAR* str) {
- if (m_pList)
- m_pList->AddString(str);
-}
-
-int32_t CPWL_ComboBox::GetSelect() const {
- return m_nSelectItem;
-}
-
-void CPWL_ComboBox::SetSelect(int32_t nItemIndex) {
- if (m_pList)
- m_pList->Select(nItemIndex);
-
- m_pEdit->SetText(m_pList->GetText().c_str());
-
- m_nSelectItem = nItemIndex;
-}
-
-void CPWL_ComboBox::SetEditSel(int32_t nStartChar, int32_t nEndChar) {
- if (m_pEdit) {
- m_pEdit->SetSel(nStartChar, nEndChar);
- }
-}
-
-void CPWL_ComboBox::GetEditSel(int32_t& nStartChar, int32_t& nEndChar) const {
- nStartChar = -1;
- nEndChar = -1;
-
- if (m_pEdit) {
- m_pEdit->GetSel(nStartChar, nEndChar);
- }
-}
-
-void CPWL_ComboBox::Clear() {
- if (m_pEdit) {
- m_pEdit->Clear();
- }
-}
-
-void CPWL_ComboBox::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- CreateEdit(cp);
- CreateButton(cp);
- CreateListBox(cp);
-}
-
-void CPWL_ComboBox::CreateEdit(const PWL_CREATEPARAM& cp) {
- if (!m_pEdit) {
- m_pEdit = new CPWL_CBEdit;
- m_pEdit->AttachFFLData(m_pFormFiller);
-
- PWL_CREATEPARAM ecp = cp;
- ecp.pParentWnd = this;
- ecp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PES_CENTER |
- PES_AUTOSCROLL | PES_UNDO;
-
- if (HasFlag(PWS_AUTOFONTSIZE))
- ecp.dwFlags |= PWS_AUTOFONTSIZE;
-
- if (!HasFlag(PCBS_ALLOWCUSTOMTEXT))
- ecp.dwFlags |= PWS_READONLY;
-
- ecp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0);
- ecp.dwBorderWidth = 0;
- ecp.nBorderStyle = PBS_SOLID;
-
- m_pEdit->Create(ecp);
- }
-}
-
-void CPWL_ComboBox::CreateButton(const PWL_CREATEPARAM& cp) {
- if (!m_pButton) {
- m_pButton = new CPWL_CBButton;
-
- PWL_CREATEPARAM bcp = cp;
- bcp.pParentWnd = this;
- bcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGROUND;
- bcp.sBackgroundColor = PWL_SCROLLBAR_BKCOLOR;
- bcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR;
- bcp.dwBorderWidth = 2;
- bcp.nBorderStyle = PBS_BEVELED;
- bcp.eCursorType = FXCT_ARROW;
-
- m_pButton->Create(bcp);
- }
-}
-
-void CPWL_ComboBox::CreateListBox(const PWL_CREATEPARAM& cp) {
- if (!m_pList) {
- m_pList = new CPWL_CBListBox;
- m_pList->AttachFFLData(m_pFormFiller);
- PWL_CREATEPARAM lcp = cp;
- lcp.pParentWnd = this;
- lcp.dwFlags =
- PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PLBS_HOVERSEL | PWS_VSCROLL;
- lcp.nBorderStyle = PBS_SOLID;
- lcp.dwBorderWidth = 1;
- lcp.eCursorType = FXCT_ARROW;
- lcp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0);
-
- if (cp.dwFlags & PWS_AUTOFONTSIZE)
- lcp.fFontSize = PWLCB_DEFAULTFONTSIZE;
- else
- lcp.fFontSize = cp.fFontSize;
-
- if (cp.sBorderColor.nColorType == COLORTYPE_TRANSPARENT)
- lcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR;
-
- if (cp.sBackgroundColor.nColorType == COLORTYPE_TRANSPARENT)
- lcp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
-
- m_pList->Create(lcp);
- }
-}
-
-void CPWL_ComboBox::RePosChildWnd() {
- CFX_FloatRect rcClient = GetClientRect();
-
- if (m_bPopup) {
- CFX_FloatRect rclient = GetClientRect();
- CFX_FloatRect rcButton = rclient;
- CFX_FloatRect rcEdit = rcClient;
- CFX_FloatRect rcList = CPWL_Wnd::GetWindowRect();
-
- FX_FLOAT fOldWindowHeight = m_rcOldWindow.Height();
- FX_FLOAT fOldClientHeight = fOldWindowHeight - GetBorderWidth() * 2;
-
- switch (m_nPopupWhere) {
- case 0:
- rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
-
- if (rcButton.left < rclient.left)
- rcButton.left = rclient.left;
-
- rcButton.bottom = rcButton.top - fOldClientHeight;
-
- rcEdit.right = rcButton.left - 1.0f;
-
- if (rcEdit.left < rclient.left)
- rcEdit.left = rclient.left;
-
- if (rcEdit.right < rcEdit.left)
- rcEdit.right = rcEdit.left;
-
- rcEdit.bottom = rcEdit.top - fOldClientHeight;
-
- rcList.top -= fOldWindowHeight;
-
- break;
- case 1:
- rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
-
- if (rcButton.left < rclient.left)
- rcButton.left = rclient.left;
-
- rcButton.top = rcButton.bottom + fOldClientHeight;
-
- rcEdit.right = rcButton.left - 1.0f;
-
- if (rcEdit.left < rclient.left)
- rcEdit.left = rclient.left;
-
- if (rcEdit.right < rcEdit.left)
- rcEdit.right = rcEdit.left;
-
- rcEdit.top = rcEdit.bottom + fOldClientHeight;
-
- rcList.bottom += fOldWindowHeight;
-
- break;
- }
-
- if (m_pButton)
- m_pButton->Move(rcButton, TRUE, FALSE);
-
- if (m_pEdit)
- m_pEdit->Move(rcEdit, TRUE, FALSE);
-
- if (m_pList) {
- m_pList->SetVisible(TRUE);
- m_pList->Move(rcList, TRUE, FALSE);
- m_pList->ScrollToListItem(m_nSelectItem);
- }
- } else {
- CFX_FloatRect rcButton = rcClient;
-
- rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
-
- if (rcButton.left < rcClient.left)
- rcButton.left = rcClient.left;
-
- if (m_pButton)
- m_pButton->Move(rcButton, TRUE, FALSE);
-
- CFX_FloatRect rcEdit = rcClient;
- rcEdit.right = rcButton.left - 1.0f;
-
- if (rcEdit.left < rcClient.left)
- rcEdit.left = rcClient.left;
-
- if (rcEdit.right < rcEdit.left)
- rcEdit.right = rcEdit.left;
-
- if (m_pEdit)
- m_pEdit->Move(rcEdit, TRUE, FALSE);
-
- if (m_pList)
- m_pList->SetVisible(FALSE);
- }
-}
-
-void CPWL_ComboBox::SelectAll() {
- if (m_pEdit && HasFlag(PCBS_ALLOWCUSTOMTEXT))
- m_pEdit->SelectAll();
-}
-
-CFX_FloatRect CPWL_ComboBox::GetFocusRect() const {
- return CFX_FloatRect();
-}
-
-void CPWL_ComboBox::SetPopup(FX_BOOL bPopup) {
- if (!m_pList)
- return;
- if (bPopup == m_bPopup)
- return;
- FX_FLOAT fListHeight = m_pList->GetContentRect().Height();
- if (!IsFloatBigger(fListHeight, 0.0f))
- return;
-
- if (bPopup) {
- if (m_pFillerNotify) {
-#ifdef PDF_ENABLE_XFA
- FX_BOOL bExit = FALSE;
- m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, 0);
- if (bExit)
- return;
-#endif // PDF_ENABLE_XFA
- int32_t nWhere = 0;
- FX_FLOAT fPopupRet = 0.0f;
- FX_FLOAT fPopupMin = 0.0f;
- if (m_pList->GetCount() > 3)
- fPopupMin =
- m_pList->GetFirstHeight() * 3 + m_pList->GetBorderWidth() * 2;
- FX_FLOAT fPopupMax = fListHeight + m_pList->GetBorderWidth() * 2;
- m_pFillerNotify->QueryWherePopup(GetAttachedData(), fPopupMin, fPopupMax,
- nWhere, fPopupRet);
-
- if (IsFloatBigger(fPopupRet, 0.0f)) {
- m_bPopup = bPopup;
-
- CFX_FloatRect rcWindow = CPWL_Wnd::GetWindowRect();
- m_rcOldWindow = rcWindow;
- switch (nWhere) {
- default:
- case 0:
- rcWindow.bottom -= fPopupRet;
- break;
- case 1:
- rcWindow.top += fPopupRet;
- break;
- }
-
- m_nPopupWhere = nWhere;
- Move(rcWindow, TRUE, TRUE);
-#ifdef PDF_ENABLE_XFA
- bExit = FALSE;
- m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, 0);
- if (bExit)
- return;
-#endif // PDF_ENABLE_XFA
- }
- }
- } else {
- m_bPopup = bPopup;
- Move(m_rcOldWindow, TRUE, TRUE);
- }
-}
-
-FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) {
- if (!m_pList)
- return FALSE;
- if (!m_pEdit)
- return FALSE;
-
- m_nSelectItem = -1;
-
- switch (nChar) {
- case FWL_VKEY_Up:
- if (m_pList->GetCurSel() > 0) {
- FX_BOOL bExit = FALSE;
-#ifdef PDF_ENABLE_XFA
- if (m_pFillerNotify) {
- m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
- if (bExit)
- return FALSE;
- bExit = FALSE;
- m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
- if (bExit)
- return FALSE;
- }
-#endif // PDF_ENABLE_XFA
- if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) {
- if (bExit)
- return FALSE;
- SetSelectText();
- }
- }
- return TRUE;
- case FWL_VKEY_Down:
- if (m_pList->GetCurSel() < m_pList->GetCount() - 1) {
- FX_BOOL bExit = FALSE;
-#ifdef PDF_ENABLE_XFA
- if (m_pFillerNotify) {
- m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
- if (bExit)
- return FALSE;
- bExit = FALSE;
- m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
- if (bExit)
- return FALSE;
- }
-#endif // PDF_ENABLE_XFA
- if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) {
- if (bExit)
- return FALSE;
- SetSelectText();
- }
- }
- return TRUE;
- }
-
- if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
- return m_pEdit->OnKeyDown(nChar, nFlag);
-
- return FALSE;
-}
-
-FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
- if (!m_pList)
- return FALSE;
-
- if (!m_pEdit)
- return FALSE;
-
- m_nSelectItem = -1;
- if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
- return m_pEdit->OnChar(nChar, nFlag);
-
- FX_BOOL bExit = FALSE;
-#ifdef PDF_ENABLE_XFA
- if (m_pFillerNotify) {
- m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
- if (bExit)
- return FALSE;
-
- m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
- if (bExit)
- return FALSE;
- }
-#endif // PDF_ENABLE_XFA
- return m_pList->OnCharWithExit(nChar, bExit, nFlag) ? bExit : FALSE;
-}
-
-void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd,
- FX_DWORD msg,
- intptr_t wParam,
- intptr_t lParam) {
- switch (msg) {
- case PNM_LBUTTONDOWN:
- if (pWnd == m_pButton) {
- SetPopup(!m_bPopup);
- return;
- }
- break;
- case PNM_LBUTTONUP:
- if (m_pEdit && m_pList) {
- if (pWnd == m_pList) {
- SetSelectText();
- SelectAll();
- m_pEdit->SetFocus();
- SetPopup(FALSE);
- return;
- }
- }
- }
-
- CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
-}
-
-FX_BOOL CPWL_ComboBox::IsPopup() const {
- return m_bPopup;
-}
-
-void CPWL_ComboBox::SetSelectText() {
- CFX_WideString swText = m_pList->GetText();
- m_pEdit->SelectAll();
- m_pEdit->ReplaceSel(m_pList->GetText().c_str());
- m_pEdit->SelectAll();
-
- m_nSelectItem = m_pList->GetCurSel();
-}
-
-void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) {
- m_pFillerNotify = pNotify;
-
- if (m_pEdit)
- m_pEdit->SetFillerNotify(pNotify);
-
- if (m_pList)
- m_pList->SetFillerNotify(pNotify);
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
deleted file mode 100644
index c4a5bf03fd..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
+++ /dev/null
@@ -1,1190 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_Edit.h"
-
-#include <vector>
-
-#include "core/include/fxcrt/fx_safe_types.h"
-#include "core/include/fxcrt/fx_xml.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Caret.h"
-#include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h"
-#include "fpdfsdk/include/pdfwindow/PWL_FontMap.h"
-#include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-#include "public/fpdf_fwlevent.h"
-#include "third_party/base/stl_util.h"
-
-CPWL_Edit::CPWL_Edit()
- : m_pFillerNotify(NULL), m_pSpellCheck(NULL), m_bFocus(FALSE) {
- m_pFormFiller = NULL;
-}
-
-CPWL_Edit::~CPWL_Edit() {
- ASSERT(m_bFocus == FALSE);
-}
-
-CFX_ByteString CPWL_Edit::GetClassName() const {
- return PWL_CLASSNAME_EDIT;
-}
-
-void CPWL_Edit::OnDestroy() {}
-
-void CPWL_Edit::SetText(const FX_WCHAR* csText) {
- CFX_WideString swText = csText;
-
- if (HasFlag(PES_RICH)) {
- CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText);
-
- if (CXML_Element* pXML =
- CXML_Element::Parse(sValue.c_str(), sValue.GetLength())) {
- int32_t nCount = pXML->CountChildren();
- FX_BOOL bFirst = TRUE;
-
- swText.Empty();
-
- for (int32_t i = 0; i < nCount; i++) {
- if (CXML_Element* pSubElement = pXML->GetElement(i)) {
- CFX_ByteString tag = pSubElement->GetTagName();
- if (tag.EqualNoCase("p")) {
- int nChild = pSubElement->CountChildren();
- CFX_WideString swSection;
- for (int32_t j = 0; j < nChild; j++) {
- swSection += pSubElement->GetContent(j);
- }
-
- if (bFirst)
- bFirst = FALSE;
- else
- swText += FWL_VKEY_Return;
- swText += swSection;
- }
- }
- }
-
- delete pXML;
- }
- }
-
- m_pEdit->SetText(swText.c_str());
-}
-
-void CPWL_Edit::RePosChildWnd() {
- if (CPWL_ScrollBar* pVSB = GetVScrollBar()) {
- CFX_FloatRect rcWindow = m_rcOldWindow;
- CFX_FloatRect rcVScroll =
- CFX_FloatRect(rcWindow.right, rcWindow.bottom,
- rcWindow.right + PWL_SCROLLBAR_WIDTH, rcWindow.top);
- pVSB->Move(rcVScroll, TRUE, FALSE);
- }
-
- if (m_pEditCaret && !HasFlag(PES_TEXTOVERFLOW))
- m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect(
- GetClientRect(), 1.0f)); // +1 for caret beside border
-
- CPWL_EditCtrl::RePosChildWnd();
-}
-
-CFX_FloatRect CPWL_Edit::GetClientRect() const {
- CFX_FloatRect rcClient = CPWL_Utils::DeflateRect(
- GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
-
- if (CPWL_ScrollBar* pVSB = GetVScrollBar()) {
- if (pVSB->IsVisible()) {
- rcClient.right -= PWL_SCROLLBAR_WIDTH;
- }
- }
-
- return rcClient;
-}
-
-void CPWL_Edit::SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat,
- FX_BOOL bPaint) {
- m_pEdit->SetAlignmentH((int32_t)nFormat, bPaint);
-}
-
-void CPWL_Edit::SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat,
- FX_BOOL bPaint) {
- m_pEdit->SetAlignmentV((int32_t)nFormat, bPaint);
-}
-
-FX_BOOL CPWL_Edit::CanSelectAll() const {
- return GetSelectWordRange() != m_pEdit->GetWholeWordRange();
-}
-
-FX_BOOL CPWL_Edit::CanClear() const {
- return !IsReadOnly() && m_pEdit->IsSelected();
-}
-
-FX_BOOL CPWL_Edit::CanCopy() const {
- return !HasFlag(PES_PASSWORD) && !HasFlag(PES_NOREAD) &&
- m_pEdit->IsSelected();
-}
-
-FX_BOOL CPWL_Edit::CanCut() const {
- return CanCopy() && !IsReadOnly();
-}
-
-FX_BOOL CPWL_Edit::CanPaste() const {
- if (IsReadOnly())
- return FALSE;
-
- CFX_WideString swClipboard;
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- swClipboard = pSH->GetClipboardText(GetAttachedHWnd());
-
- return !swClipboard.IsEmpty();
-}
-
-void CPWL_Edit::CopyText() {
- if (!CanCopy())
- return;
-
- CFX_WideString str = m_pEdit->GetSelText();
-
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- pSH->SetClipboardText(GetAttachedHWnd(), str);
-}
-
-void CPWL_Edit::PasteText() {
- if (!CanPaste())
- return;
-
- CFX_WideString swClipboard;
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- swClipboard = pSH->GetClipboardText(GetAttachedHWnd());
-
- if (m_pFillerNotify) {
- FX_BOOL bRC = TRUE;
- FX_BOOL bExit = FALSE;
- CFX_WideString strChangeEx;
- int nSelStart = 0;
- int nSelEnd = 0;
- GetSel(nSelStart, nSelEnd);
- m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swClipboard,
- strChangeEx, nSelStart, nSelEnd, TRUE,
- bRC, bExit, 0);
- if (!bRC)
- return;
- if (bExit)
- return;
- }
-
- if (swClipboard.GetLength() > 0) {
- Clear();
- InsertText(swClipboard.c_str());
- }
-}
-
-void CPWL_Edit::CutText() {
- if (!CanCut())
- return;
-
- CFX_WideString str = m_pEdit->GetSelText();
-
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- pSH->SetClipboardText(GetAttachedHWnd(), str);
-
- m_pEdit->Clear();
-}
-
-void CPWL_Edit::OnCreated() {
- CPWL_EditCtrl::OnCreated();
-
- if (CPWL_ScrollBar* pScroll = GetVScrollBar()) {
- pScroll->RemoveFlag(PWS_AUTOTRANSPARENT);
- pScroll->SetTransparency(255);
- }
-
- SetParamByFlag();
-
- m_rcOldWindow = GetWindowRect();
-
- m_pEdit->SetOprNotify(this);
- m_pEdit->EnableOprNotify(TRUE);
-}
-
-void CPWL_Edit::SetParamByFlag() {
- if (HasFlag(PES_RIGHT)) {
- m_pEdit->SetAlignmentH(2, FALSE);
- } else if (HasFlag(PES_MIDDLE)) {
- m_pEdit->SetAlignmentH(1, FALSE);
- } else {
- m_pEdit->SetAlignmentH(0, FALSE);
- }
-
- if (HasFlag(PES_BOTTOM)) {
- m_pEdit->SetAlignmentV(2, FALSE);
- } else if (HasFlag(PES_CENTER)) {
- m_pEdit->SetAlignmentV(1, FALSE);
- } else {
- m_pEdit->SetAlignmentV(0, FALSE);
- }
-
- if (HasFlag(PES_PASSWORD)) {
- m_pEdit->SetPasswordChar('*', FALSE);
- }
-
- m_pEdit->SetMultiLine(HasFlag(PES_MULTILINE), FALSE);
- m_pEdit->SetAutoReturn(HasFlag(PES_AUTORETURN), FALSE);
- m_pEdit->SetAutoFontSize(HasFlag(PWS_AUTOFONTSIZE), FALSE);
- m_pEdit->SetAutoScroll(HasFlag(PES_AUTOSCROLL), FALSE);
- m_pEdit->EnableUndo(HasFlag(PES_UNDO));
-
- if (HasFlag(PES_TEXTOVERFLOW)) {
- SetClipRect(CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f));
- m_pEdit->SetTextOverflow(TRUE, FALSE);
- } else {
- if (m_pEditCaret) {
- m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect(
- GetClientRect(), 1.0f)); // +1 for caret beside border
- }
- }
-
- if (HasFlag(PES_SPELLCHECK)) {
- m_pSpellCheck = GetCreationParam().pSpellCheck;
- }
-}
-
-void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
-
- CFX_FloatRect rcClient = GetClientRect();
- CFX_ByteTextBuf sLine;
-
- int32_t nCharArray = m_pEdit->GetCharArray();
-
- if (nCharArray > 0) {
- switch (GetBorderStyle()) {
- case PBS_SOLID: {
- sLine << "q\n" << GetBorderWidth() << " w\n"
- << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE)
- << " 2 J 0 j\n";
-
- for (int32_t i = 1; i < nCharArray; i++) {
- sLine << rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * i
- << " " << rcClient.bottom << " m\n"
- << rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * i
- << " " << rcClient.top << " l S\n";
- }
-
- sLine << "Q\n";
- } break;
- case PBS_DASH: {
- sLine << "q\n" << GetBorderWidth() << " w\n"
- << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE)
- << " 2 J 0 j\n"
- << "[" << GetBorderDash().nDash << " " << GetBorderDash().nGap
- << "] " << GetBorderDash().nPhase << " d\n";
-
- for (int32_t i = 1; i < nCharArray; i++) {
- sLine << rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * i
- << " " << rcClient.bottom << " m\n"
- << rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * i
- << " " << rcClient.top << " l S\n";
- }
-
- sLine << "Q\n";
- } break;
- }
- }
-
- sAppStream << sLine;
-
- CFX_ByteTextBuf sText;
-
- CFX_FloatPoint ptOffset = CFX_FloatPoint(0.0f, 0.0f);
-
- CPVT_WordRange wrWhole = m_pEdit->GetWholeWordRange();
- CPVT_WordRange wrSelect = GetSelectWordRange();
- CPVT_WordRange wrVisible =
- (HasFlag(PES_TEXTOVERFLOW) ? wrWhole : m_pEdit->GetVisibleWordRange());
- CPVT_WordRange wrSelBefore(wrWhole.BeginPos, wrSelect.BeginPos);
- CPVT_WordRange wrSelAfter(wrSelect.EndPos, wrWhole.EndPos);
-
- CPVT_WordRange wrTemp =
- CPWL_Utils::OverlapWordRange(GetSelectWordRange(), wrVisible);
- CFX_ByteString sEditSel =
- CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wrTemp);
-
- if (sEditSel.GetLength() > 0)
- sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR)
- << sEditSel;
-
- wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelBefore);
- CFX_ByteString sEditBefore = CPWL_Utils::GetEditAppStream(
- m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY),
- m_pEdit->GetPasswordChar());
-
- if (sEditBefore.GetLength() > 0)
- sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor())
- << sEditBefore << "ET\n";
-
- wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelect);
- CFX_ByteString sEditMid = CPWL_Utils::GetEditAppStream(
- m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY),
- m_pEdit->GetPasswordChar());
-
- if (sEditMid.GetLength() > 0)
- sText << "BT\n"
- << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY, 1))
- << sEditMid << "ET\n";
-
- wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelAfter);
- CFX_ByteString sEditAfter = CPWL_Utils::GetEditAppStream(
- m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY),
- m_pEdit->GetPasswordChar());
-
- if (sEditAfter.GetLength() > 0)
- sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor())
- << sEditAfter << "ET\n";
-
- if (HasFlag(PES_SPELLCHECK)) {
- CFX_ByteString sSpellCheck = CPWL_Utils::GetSpellCheckAppStream(
- m_pEdit, m_pSpellCheck, ptOffset, &wrVisible);
- if (sSpellCheck.GetLength() > 0)
- sText << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB, 1, 0, 0),
- FALSE)
- << sSpellCheck;
- }
-
- if (sText.GetLength() > 0) {
- CFX_FloatRect rcClient = GetClientRect();
- sAppStream << "q\n/Tx BMC\n";
-
- if (!HasFlag(PES_TEXTOVERFLOW))
- sAppStream << rcClient.left << " " << rcClient.bottom << " "
- << rcClient.right - rcClient.left << " "
- << rcClient.top - rcClient.bottom << " re W n\n";
-
- sAppStream << sText;
-
- sAppStream << "EMC\nQ\n";
- }
-}
-
-void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
-
- CFX_FloatRect rcClient = GetClientRect();
- CFX_ByteTextBuf sLine;
-
- int32_t nCharArray = m_pEdit->GetCharArray();
- FX_SAFE_INT32 nCharArraySafe = nCharArray;
- nCharArraySafe -= 1;
- nCharArraySafe *= 2;
-
- if (nCharArray > 0 && nCharArraySafe.IsValid()) {
- switch (GetBorderStyle()) {
- case PBS_SOLID: {
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
-
- CFX_PathData path;
- path.SetPointCount(nCharArraySafe.ValueOrDie());
-
- for (int32_t i = 0; i < nCharArray - 1; i++) {
- path.SetPoint(
- i * 2,
- rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
- rcClient.bottom, FXPT_MOVETO);
- path.SetPoint(
- i * 2 + 1,
- rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
- rcClient.top, FXPT_LINETO);
- }
- if (path.GetPointCount() > 0)
- pDevice->DrawPath(
- &path, pUser2Device, &gsd, 0,
- CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255),
- FXFILL_ALTERNATE);
- } break;
- case PBS_DASH: {
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
-
- gsd.SetDashCount(2);
- gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().nDash;
- gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().nGap;
- gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase;
-
- CFX_PathData path;
- path.SetPointCount(nCharArraySafe.ValueOrDie());
-
- for (int32_t i = 0; i < nCharArray - 1; i++) {
- path.SetPoint(
- i * 2,
- rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
- rcClient.bottom, FXPT_MOVETO);
- path.SetPoint(
- i * 2 + 1,
- rcClient.left +
- ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
- rcClient.top, FXPT_LINETO);
- }
- if (path.GetPointCount() > 0)
- pDevice->DrawPath(
- &path, pUser2Device, &gsd, 0,
- CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255),
- FXFILL_ALTERNATE);
- } break;
- }
- }
-
- CFX_FloatRect rcClip;
- CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange();
- CPVT_WordRange* pRange = NULL;
-
- if (!HasFlag(PES_TEXTOVERFLOW)) {
- rcClip = GetClientRect();
- pRange = &wrRange;
- }
- IFX_SystemHandler* pSysHandler = GetSystemHandler();
- IFX_Edit::DrawEdit(
- pDevice, pUser2Device, m_pEdit,
- CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
- CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()),
- rcClip, CFX_FloatPoint(0.0f, 0.0f), pRange, pSysHandler, m_pFormFiller);
-
- if (HasFlag(PES_SPELLCHECK)) {
- CPWL_Utils::DrawEditSpellCheck(pDevice, pUser2Device, m_pEdit, rcClip,
- CFX_FloatPoint(0.0f, 0.0f), pRange,
- GetCreationParam().pSpellCheck);
- }
-}
-
-FX_BOOL CPWL_Edit::OnLButtonDown(const CFX_FloatPoint& point, FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonDown(point, nFlag);
-
- if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) {
- if (m_bMouseDown)
- InvalidateRect();
-
- m_bMouseDown = TRUE;
- SetCapture();
-
- m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_Edit::OnLButtonDblClk(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonDblClk(point, nFlag);
-
- if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) {
- m_pEdit->SelectAll();
- }
-
- return TRUE;
-}
-
-#define WM_PWLEDIT_UNDO 0x01
-#define WM_PWLEDIT_REDO 0x02
-#define WM_PWLEDIT_CUT 0x03
-#define WM_PWLEDIT_COPY 0x04
-#define WM_PWLEDIT_PASTE 0x05
-#define WM_PWLEDIT_DELETE 0x06
-#define WM_PWLEDIT_SELECTALL 0x07
-#define WM_PWLEDIT_SUGGEST 0x08
-
-FX_BOOL CPWL_Edit::OnRButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) {
- if (m_bMouseDown)
- return FALSE;
-
- CPWL_Wnd::OnRButtonUp(point, nFlag);
-
- if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point))
- return TRUE;
-
- IFX_SystemHandler* pSH = GetSystemHandler();
- if (!pSH)
- return FALSE;
-
- SetFocus();
-
- CPVT_WordRange wrLatin = GetLatinWordsRange(point);
- CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin);
-
- FX_HMENU hPopup = pSH->CreatePopupMenu();
- if (!hPopup)
- return FALSE;
-
- std::vector<CFX_ByteString> sSuggestWords;
- CFX_FloatPoint ptPopup = point;
-
- if (!IsReadOnly()) {
- if (HasFlag(PES_SPELLCHECK) && !swLatin.IsEmpty()) {
- if (m_pSpellCheck) {
- CFX_ByteString sLatin = CFX_ByteString::FromUnicode(swLatin);
- if (!m_pSpellCheck->CheckWord(sLatin)) {
- m_pSpellCheck->SuggestWords(sLatin, sSuggestWords);
-
- int32_t nSuggest = pdfium::CollectionSize<int32_t>(sSuggestWords);
- for (int32_t nWord = 0; nWord < nSuggest; nWord++) {
- pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SUGGEST + nWord,
- sSuggestWords[nWord].UTF8Decode());
- }
- if (nSuggest > 0)
- pSH->AppendMenuItem(hPopup, 0, L"");
-
- ptPopup = GetWordRightBottomPoint(wrLatin.EndPos);
- }
- }
- }
- }
-
- IPWL_Provider* pProvider = GetProvider();
-
- if (HasFlag(PES_UNDO)) {
- pSH->AppendMenuItem(
- hPopup, WM_PWLEDIT_UNDO,
- pProvider ? pProvider->LoadPopupMenuString(0) : L"&Undo");
- pSH->AppendMenuItem(
- hPopup, WM_PWLEDIT_REDO,
- pProvider ? pProvider->LoadPopupMenuString(1) : L"&Redo");
- pSH->AppendMenuItem(hPopup, 0, L"");
-
- if (!m_pEdit->CanUndo())
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_UNDO, FALSE);
- if (!m_pEdit->CanRedo())
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_REDO, FALSE);
- }
-
- pSH->AppendMenuItem(hPopup, WM_PWLEDIT_CUT,
- pProvider ? pProvider->LoadPopupMenuString(2) : L"Cu&t");
- pSH->AppendMenuItem(hPopup, WM_PWLEDIT_COPY,
- pProvider ? pProvider->LoadPopupMenuString(3) : L"&Copy");
- pSH->AppendMenuItem(
- hPopup, WM_PWLEDIT_PASTE,
- pProvider ? pProvider->LoadPopupMenuString(4) : L"&Paste");
- pSH->AppendMenuItem(
- hPopup, WM_PWLEDIT_DELETE,
- pProvider ? pProvider->LoadPopupMenuString(5) : L"&Delete");
-
- CFX_WideString swText = pSH->GetClipboardText(GetAttachedHWnd());
- if (swText.IsEmpty())
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
-
- if (!m_pEdit->IsSelected()) {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
- }
-
- if (IsReadOnly()) {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
- }
-
- if (HasFlag(PES_PASSWORD)) {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
- }
-
- if (HasFlag(PES_NOREAD)) {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
- }
-
- pSH->AppendMenuItem(hPopup, 0, L"");
- pSH->AppendMenuItem(
- hPopup, WM_PWLEDIT_SELECTALL,
- pProvider ? pProvider->LoadPopupMenuString(6) : L"&Select All");
-
- if (m_pEdit->GetTotalWords() == 0) {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_SELECTALL, FALSE);
- }
-
- int32_t x, y;
- PWLtoWnd(ptPopup, x, y);
- pSH->ClientToScreen(GetAttachedHWnd(), x, y);
- pSH->SetCursor(FXCT_ARROW);
- int32_t nCmd = pSH->TrackPopupMenu(hPopup, x, y, GetAttachedHWnd());
-
- switch (nCmd) {
- case WM_PWLEDIT_UNDO:
- Undo();
- break;
- case WM_PWLEDIT_REDO:
- Redo();
- break;
- case WM_PWLEDIT_CUT:
- CutText();
- break;
- case WM_PWLEDIT_COPY:
- CopyText();
- break;
- case WM_PWLEDIT_PASTE:
- PasteText();
- break;
- case WM_PWLEDIT_DELETE:
- Clear();
- break;
- case WM_PWLEDIT_SELECTALL:
- SelectAll();
- break;
- case WM_PWLEDIT_SUGGEST + 0:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
- m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[0].UTF8Decode().c_str());
- break;
- case WM_PWLEDIT_SUGGEST + 1:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
- m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[1].UTF8Decode().c_str());
- break;
- case WM_PWLEDIT_SUGGEST + 2:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
- m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[2].UTF8Decode().c_str());
- break;
- case WM_PWLEDIT_SUGGEST + 3:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
- m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[3].UTF8Decode().c_str());
- break;
- case WM_PWLEDIT_SUGGEST + 4:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
- m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[4].UTF8Decode().c_str());
- break;
- default:
- break;
- }
-
- pSH->DestroyMenu(hPopup);
-
- return TRUE;
-}
-
-void CPWL_Edit::OnSetFocus() {
- SetEditCaret(TRUE);
-
- if (!IsReadOnly()) {
- if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler())
- pFocusHandler->OnSetFocus(this);
- }
-
- m_bFocus = TRUE;
-}
-
-void CPWL_Edit::OnKillFocus() {
- ShowVScrollBar(FALSE);
-
- m_pEdit->SelectNone();
- SetCaret(FALSE, CFX_FloatPoint(0.0f, 0.0f), CFX_FloatPoint(0.0f, 0.0f));
-
- SetCharSet(0);
-
- if (!IsReadOnly()) {
- if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler())
- pFocusHandler->OnKillFocus(this);
- }
-
- m_bFocus = FALSE;
-}
-
-void CPWL_Edit::SetHorzScale(int32_t nHorzScale, FX_BOOL bPaint /* = TRUE*/) {
- m_pEdit->SetHorzScale(nHorzScale, bPaint);
-}
-
-void CPWL_Edit::SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint /* = TRUE*/) {
- m_pEdit->SetCharSpace(fCharSpace, bPaint);
-}
-
-void CPWL_Edit::SetLineLeading(FX_FLOAT fLineLeading,
- FX_BOOL bPaint /* = TRUE*/) {
- m_pEdit->SetLineLeading(fLineLeading, bPaint);
-}
-
-CFX_ByteString CPWL_Edit::GetSelectAppearanceStream(
- const CFX_FloatPoint& ptOffset) const {
- CPVT_WordRange wr = GetSelectWordRange();
- return CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wr);
-}
-
-CPVT_WordRange CPWL_Edit::GetSelectWordRange() const {
- if (m_pEdit->IsSelected()) {
- int32_t nStart = -1;
- int32_t nEnd = -1;
-
- m_pEdit->GetSel(nStart, nEnd);
-
- CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStart);
- CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEnd);
-
- return CPVT_WordRange(wpStart, wpEnd);
- }
-
- return CPVT_WordRange();
-}
-
-CFX_ByteString CPWL_Edit::GetTextAppearanceStream(
- const CFX_FloatPoint& ptOffset) const {
- CFX_ByteTextBuf sRet;
- CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset);
-
- if (sEdit.GetLength() > 0) {
- sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit
- << "ET\n";
- }
-
- return sRet.GetByteString();
-}
-
-CFX_ByteString CPWL_Edit::GetCaretAppearanceStream(
- const CFX_FloatPoint& ptOffset) const {
- if (m_pEditCaret)
- return m_pEditCaret->GetCaretAppearanceStream(ptOffset);
-
- return CFX_ByteString();
-}
-
-CFX_FloatPoint CPWL_Edit::GetWordRightBottomPoint(
- const CPVT_WordPlace& wpWord) {
- CFX_FloatPoint pt(0.0f, 0.0f);
-
- if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) {
- CPVT_WordPlace wpOld = pIterator->GetAt();
- pIterator->SetAt(wpWord);
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- pt = CFX_FloatPoint(word.ptWord.x + word.fWidth,
- word.ptWord.y + word.fDescent);
- }
-
- pIterator->SetAt(wpOld);
- }
-
- return pt;
-}
-
-FX_BOOL CPWL_Edit::IsTextFull() const {
- return m_pEdit->IsTextFull();
-}
-
-FX_FLOAT CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont,
- const CFX_FloatRect& rcPlate,
- int32_t nCharArray) {
- if (pFont && !pFont->IsStandardFont()) {
- FX_RECT rcBBox;
- pFont->GetFontBBox(rcBBox);
-
- CFX_FloatRect rcCell = rcPlate;
- FX_FLOAT xdiv = rcCell.Width() / nCharArray * 1000.0f / rcBBox.Width();
- FX_FLOAT ydiv = -rcCell.Height() * 1000.0f / rcBBox.Height();
-
- return xdiv < ydiv ? xdiv : ydiv;
- }
-
- return 0.0f;
-}
-
-void CPWL_Edit::SetCharArray(int32_t nCharArray) {
- if (HasFlag(PES_CHARARRAY) && nCharArray > 0) {
- m_pEdit->SetCharArray(nCharArray);
- m_pEdit->SetTextOverflow(TRUE);
-
- if (HasFlag(PWS_AUTOFONTSIZE)) {
- if (IFX_Edit_FontMap* pFontMap = GetFontMap()) {
- FX_FLOAT fFontSize = GetCharArrayAutoFontSize(
- pFontMap->GetPDFFont(0), GetClientRect(), nCharArray);
- if (fFontSize > 0.0f) {
- m_pEdit->SetAutoFontSize(FALSE);
- m_pEdit->SetFontSize(fFontSize);
- }
- }
- }
- }
-}
-
-void CPWL_Edit::SetLimitChar(int32_t nLimitChar) {
- m_pEdit->SetLimitChar(nLimitChar);
-}
-
-void CPWL_Edit::ReplaceSel(const FX_WCHAR* csText) {
- m_pEdit->Clear();
- m_pEdit->InsertText(csText);
-}
-
-CFX_FloatRect CPWL_Edit::GetFocusRect() const {
- return CFX_FloatRect();
-}
-
-void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow) {
- if (CPWL_ScrollBar* pScroll = GetVScrollBar()) {
- if (bShow) {
- if (!pScroll->IsVisible()) {
- pScroll->SetVisible(TRUE);
- CFX_FloatRect rcWindow = GetWindowRect();
- m_rcOldWindow = rcWindow;
- rcWindow.right += PWL_SCROLLBAR_WIDTH;
- Move(rcWindow, TRUE, TRUE);
- }
- } else {
- if (pScroll->IsVisible()) {
- pScroll->SetVisible(FALSE);
- Move(m_rcOldWindow, TRUE, TRUE);
- }
- }
- }
-}
-
-FX_BOOL CPWL_Edit::IsVScrollBarVisible() const {
- if (CPWL_ScrollBar* pScroll = GetVScrollBar()) {
- return pScroll->IsVisible();
- }
-
- return FALSE;
-}
-
-void CPWL_Edit::EnableSpellCheck(FX_BOOL bEnabled) {
- if (bEnabled)
- AddFlag(PES_SPELLCHECK);
- else
- RemoveFlag(PES_SPELLCHECK);
-}
-
-FX_BOOL CPWL_Edit::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) {
- if (m_bMouseDown)
- return TRUE;
-
- if (nChar == FWL_VKEY_Delete) {
- if (m_pFillerNotify) {
- FX_BOOL bRC = TRUE;
- FX_BOOL bExit = FALSE;
- CFX_WideString strChange;
- CFX_WideString strChangeEx;
-
- int nSelStart = 0;
- int nSelEnd = 0;
- GetSel(nSelStart, nSelEnd);
-
- if (nSelStart == nSelEnd)
- nSelEnd = nSelStart + 1;
- m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), strChange,
- strChangeEx, nSelStart, nSelEnd, TRUE,
- bRC, bExit, nFlag);
- if (!bRC)
- return FALSE;
- if (bExit)
- return FALSE;
- }
- }
-
- FX_BOOL bRet = CPWL_EditCtrl::OnKeyDown(nChar, nFlag);
-
- // In case of implementation swallow the OnKeyDown event.
- if (IsProceedtoOnChar(nChar, nFlag))
- return TRUE;
-
- return bRet;
-}
-
-/**
-*In case of implementation swallow the OnKeyDown event.
-*If the event is swallowed, implementation may do other unexpected things, which
-*is not the control means to do.
-*/
-FX_BOOL CPWL_Edit::IsProceedtoOnChar(FX_WORD nKeyCode, FX_DWORD nFlag) {
- FX_BOOL bCtrl = IsCTRLpressed(nFlag);
- FX_BOOL bAlt = IsALTpressed(nFlag);
- if (bCtrl && !bAlt) {
- // hot keys for edit control.
- switch (nKeyCode) {
- case 'C':
- case 'V':
- case 'X':
- case 'A':
- case 'Z':
- return TRUE;
- default:
- break;
- }
- }
- // control characters.
- switch (nKeyCode) {
- case FWL_VKEY_Escape:
- case FWL_VKEY_Back:
- case FWL_VKEY_Return:
- case FWL_VKEY_Space:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-FX_BOOL CPWL_Edit::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
- if (m_bMouseDown)
- return TRUE;
-
- FX_BOOL bRC = TRUE;
- FX_BOOL bExit = FALSE;
-
- if (!IsCTRLpressed(nFlag)) {
- if (m_pFillerNotify) {
- CFX_WideString swChange;
-
- int nSelStart = 0;
- int nSelEnd = 0;
- GetSel(nSelStart, nSelEnd);
-
- switch (nChar) {
- case FWL_VKEY_Back:
- if (nSelStart == nSelEnd)
- nSelStart = nSelEnd - 1;
- break;
- case FWL_VKEY_Return:
- break;
- default:
- swChange += nChar;
- break;
- }
-
- CFX_WideString strChangeEx;
- m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swChange,
- strChangeEx, nSelStart, nSelEnd, TRUE,
- bRC, bExit, nFlag);
- }
- }
-
- if (!bRC)
- return TRUE;
- if (bExit)
- return FALSE;
-
- if (IFX_Edit_FontMap* pFontMap = GetFontMap()) {
- int32_t nOldCharSet = GetCharSet();
- int32_t nNewCharSet = pFontMap->CharSetFromUnicode(nChar, DEFAULT_CHARSET);
- if (nOldCharSet != nNewCharSet) {
- SetCharSet(nNewCharSet);
- }
- }
-
- return CPWL_EditCtrl::OnChar(nChar, nFlag);
-}
-
-FX_BOOL CPWL_Edit::OnMouseWheel(short zDelta,
- const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- if (HasFlag(PES_MULTILINE)) {
- CFX_FloatPoint ptScroll = GetScrollPos();
-
- if (zDelta > 0) {
- ptScroll.y += GetFontSize();
- } else {
- ptScroll.y -= GetFontSize();
- }
- SetScrollPos(ptScroll);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-void CPWL_Edit::OnInsertReturn(const CPVT_WordPlace& place,
- const CPVT_WordPlace& oldplace) {
- if (HasFlag(PES_SPELLCHECK)) {
- m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace),
- GetLatinWordsRange(place)));
- }
-
- if (m_pEditNotify) {
- m_pEditNotify->OnInsertReturn(place, oldplace);
- }
-}
-
-void CPWL_Edit::OnBackSpace(const CPVT_WordPlace& place,
- const CPVT_WordPlace& oldplace) {
- if (HasFlag(PES_SPELLCHECK)) {
- m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace),
- GetLatinWordsRange(place)));
- }
-
- if (m_pEditNotify) {
- m_pEditNotify->OnBackSpace(place, oldplace);
- }
-}
-
-void CPWL_Edit::OnDelete(const CPVT_WordPlace& place,
- const CPVT_WordPlace& oldplace) {
- if (HasFlag(PES_SPELLCHECK)) {
- m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace),
- GetLatinWordsRange(place)));
- }
-
- if (m_pEditNotify) {
- m_pEditNotify->OnDelete(place, oldplace);
- }
-}
-
-void CPWL_Edit::OnClear(const CPVT_WordPlace& place,
- const CPVT_WordPlace& oldplace) {
- if (HasFlag(PES_SPELLCHECK)) {
- m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace),
- GetLatinWordsRange(place)));
- }
-
- if (m_pEditNotify) {
- m_pEditNotify->OnClear(place, oldplace);
- }
-}
-
-void CPWL_Edit::OnInsertWord(const CPVT_WordPlace& place,
- const CPVT_WordPlace& oldplace) {
- if (HasFlag(PES_SPELLCHECK)) {
- m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace),
- GetLatinWordsRange(place)));
- }
-
- if (m_pEditNotify) {
- m_pEditNotify->OnInsertWord(place, oldplace);
- }
-}
-
-void CPWL_Edit::OnSetText(const CPVT_WordPlace& place,
- const CPVT_WordPlace& oldplace) {}
-
-void CPWL_Edit::OnInsertText(const CPVT_WordPlace& place,
- const CPVT_WordPlace& oldplace) {
- if (HasFlag(PES_SPELLCHECK)) {
- m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace),
- GetLatinWordsRange(place)));
- }
-
- if (m_pEditNotify) {
- m_pEditNotify->OnInsertText(place, oldplace);
- }
-}
-
-void CPWL_Edit::OnAddUndo(IFX_Edit_UndoItem* pUndoItem) {
- if (m_pEditNotify) {
- m_pEditNotify->OnAddUndo(this);
- }
-}
-
-CPVT_WordRange CPWL_Edit::CombineWordRange(const CPVT_WordRange& wr1,
- const CPVT_WordRange& wr2) {
- CPVT_WordRange wrRet;
-
- if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) {
- wrRet.BeginPos = wr1.BeginPos;
- } else {
- wrRet.BeginPos = wr2.BeginPos;
- }
-
- if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) {
- wrRet.EndPos = wr2.EndPos;
- } else {
- wrRet.EndPos = wr1.EndPos;
- }
-
- return wrRet;
-}
-
-CPVT_WordRange CPWL_Edit::GetLatinWordsRange(
- const CFX_FloatPoint& point) const {
- return GetSameWordsRange(m_pEdit->SearchWordPlace(point), TRUE, FALSE);
-}
-
-CPVT_WordRange CPWL_Edit::GetLatinWordsRange(
- const CPVT_WordPlace& place) const {
- return GetSameWordsRange(place, TRUE, FALSE);
-}
-
-CPVT_WordRange CPWL_Edit::GetArabicWordsRange(
- const CPVT_WordPlace& place) const {
- return GetSameWordsRange(place, FALSE, TRUE);
-}
-
-#define PWL_ISARABICWORD(word) \
- ((word >= 0x0600 && word <= 0x06FF) || (word >= 0xFB50 && word <= 0xFEFC))
-
-CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace& place,
- FX_BOOL bLatin,
- FX_BOOL bArabic) const {
- CPVT_WordRange range;
-
- if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) {
- CPVT_Word wordinfo;
- CPVT_WordPlace wpStart(place), wpEnd(place);
- pIterator->SetAt(place);
-
- if (bLatin) {
- while (pIterator->NextWord()) {
- if (!pIterator->GetWord(wordinfo) ||
- !FX_EDIT_ISLATINWORD(wordinfo.Word)) {
- break;
- }
-
- wpEnd = pIterator->GetAt();
- }
- } else if (bArabic) {
- while (pIterator->NextWord()) {
- if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word))
- break;
-
- wpEnd = pIterator->GetAt();
- }
- }
-
- pIterator->SetAt(place);
-
- if (bLatin) {
- do {
- if (!pIterator->GetWord(wordinfo) ||
- !FX_EDIT_ISLATINWORD(wordinfo.Word)) {
- break;
- }
-
- wpStart = pIterator->GetAt();
- } while (pIterator->PrevWord());
- } else if (bArabic) {
- do {
- if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word))
- break;
-
- wpStart = pIterator->GetAt();
- } while (pIterator->PrevWord());
- }
-
- range.Set(wpStart, wpEnd);
- }
-
- return range;
-}
-
-void CPWL_Edit::GeneratePageObjects(
- CPDF_PageObjectHolder* pObjectHolder,
- const CFX_FloatPoint& ptOffset,
- CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) {
- IFX_Edit::GeneratePageObjects(
- pObjectHolder, m_pEdit, ptOffset, NULL,
- CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
- ObjArray);
-}
-
-void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder,
- const CFX_FloatPoint& ptOffset) {
- CFX_ArrayTemplate<CPDF_TextObject*> ObjArray;
- IFX_Edit::GeneratePageObjects(
- pObjectHolder, m_pEdit, ptOffset, NULL,
- CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
- ObjArray);
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp b/fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp
deleted file mode 100644
index 10b5d6c04f..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp
+++ /dev/null
@@ -1,629 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h"
-
-#include "fpdfsdk/include/pdfwindow/PWL_Caret.h"
-#include "fpdfsdk/include/pdfwindow/PWL_FontMap.h"
-#include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-#include "public/fpdf_fwlevent.h"
-
-#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
-#define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
-
-CPWL_EditCtrl::CPWL_EditCtrl()
- : m_pEdit(NULL),
- m_pEditCaret(NULL),
- m_bMouseDown(FALSE),
- m_pEditNotify(NULL),
- m_nCharSet(DEFAULT_CHARSET),
- m_nCodePage(0) {
- m_pEdit = IFX_Edit::NewEdit();
- ASSERT(m_pEdit);
-}
-
-CPWL_EditCtrl::~CPWL_EditCtrl() {
- IFX_Edit::DelEdit(m_pEdit);
-}
-
-void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp) {
- cp.eCursorType = FXCT_VBEAM;
-}
-
-void CPWL_EditCtrl::OnCreated() {
- SetFontSize(GetCreationParam().fFontSize);
-
- m_pEdit->SetFontMap(GetFontMap());
- m_pEdit->SetNotify(this);
- m_pEdit->Initialize();
-}
-
-FX_BOOL CPWL_EditCtrl::IsWndHorV() {
- CFX_Matrix mt = GetWindowMatrix();
- CFX_FloatPoint point1(0, 1);
- CFX_FloatPoint point2(1, 1);
-
- mt.Transform(point1.x, point1.y);
- mt.Transform(point2.x, point2.y);
-
- return point2.y == point1.y;
-}
-
-void CPWL_EditCtrl::SetCursor() {
- if (IsValid()) {
- if (IFX_SystemHandler* pSH = GetSystemHandler()) {
- if (IsWndHorV())
- pSH->SetCursor(FXCT_VBEAM);
- else
- pSH->SetCursor(FXCT_HBEAM);
- }
- }
-}
-
-void CPWL_EditCtrl::RePosChildWnd() {
- m_pEdit->SetPlateRect(GetClientRect());
-}
-
-void CPWL_EditCtrl::OnNotify(CPWL_Wnd* pWnd,
- FX_DWORD msg,
- intptr_t wParam,
- intptr_t lParam) {
- CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
-
- switch (msg) {
- case PNM_SETSCROLLINFO:
- switch (wParam) {
- case SBT_VSCROLL:
- if (CPWL_Wnd* pChild = GetVScrollBar()) {
- pChild->OnNotify(pWnd, PNM_SETSCROLLINFO, wParam, lParam);
- }
- break;
- }
- break;
- case PNM_SETSCROLLPOS:
- switch (wParam) {
- case SBT_VSCROLL:
- if (CPWL_Wnd* pChild = GetVScrollBar()) {
- pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam);
- }
- break;
- }
- break;
- case PNM_SCROLLWINDOW: {
- FX_FLOAT fPos = *(FX_FLOAT*)lParam;
- switch (wParam) {
- case SBT_VSCROLL:
- m_pEdit->SetScrollPos(
- CFX_FloatPoint(m_pEdit->GetScrollPos().x, fPos));
- break;
- }
- } break;
- case PNM_SETCARETINFO: {
- if (PWL_CARET_INFO* pCaretInfo = (PWL_CARET_INFO*)wParam) {
- SetCaret(pCaretInfo->bVisible, pCaretInfo->ptHead, pCaretInfo->ptFoot);
- }
- } break;
- }
-}
-
-void CPWL_EditCtrl::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- if (!IsReadOnly())
- CreateEditCaret(cp);
-}
-
-void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM& cp) {
- if (!m_pEditCaret) {
- m_pEditCaret = new CPWL_Caret;
- m_pEditCaret->SetInvalidRect(GetClientRect());
-
- PWL_CREATEPARAM ecp = cp;
- ecp.pParentWnd = this;
- ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP;
- ecp.dwBorderWidth = 0;
- ecp.nBorderStyle = PBS_SOLID;
- ecp.rcRectWnd = CFX_FloatRect(0, 0, 0, 0);
-
- m_pEditCaret->Create(ecp);
- }
-}
-
-void CPWL_EditCtrl::SetFontSize(FX_FLOAT fFontSize) {
- m_pEdit->SetFontSize(fFontSize);
-}
-
-FX_FLOAT CPWL_EditCtrl::GetFontSize() const {
- return m_pEdit->GetFontSize();
-}
-
-FX_BOOL CPWL_EditCtrl::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) {
- if (m_bMouseDown)
- return TRUE;
-
- FX_BOOL bRet = CPWL_Wnd::OnKeyDown(nChar, nFlag);
-
- // FILTER
- switch (nChar) {
- default:
- return FALSE;
- case FWL_VKEY_Delete:
- case FWL_VKEY_Up:
- case FWL_VKEY_Down:
- case FWL_VKEY_Left:
- case FWL_VKEY_Right:
- case FWL_VKEY_Home:
- case FWL_VKEY_End:
- case FWL_VKEY_Insert:
- case 'C':
- case 'V':
- case 'X':
- case 'A':
- case 'Z':
- case 'c':
- case 'v':
- case 'x':
- case 'a':
- case 'z':
- break;
- }
-
- if (nChar == FWL_VKEY_Delete) {
- if (m_pEdit->IsSelected())
- nChar = FWL_VKEY_Unknown;
- }
-
- switch (nChar) {
- case FWL_VKEY_Delete:
- Delete();
- return TRUE;
- case FWL_VKEY_Insert:
- if (IsSHIFTpressed(nFlag))
- PasteText();
- return TRUE;
- case FWL_VKEY_Up:
- m_pEdit->OnVK_UP(IsSHIFTpressed(nFlag), FALSE);
- return TRUE;
- case FWL_VKEY_Down:
- m_pEdit->OnVK_DOWN(IsSHIFTpressed(nFlag), FALSE);
- return TRUE;
- case FWL_VKEY_Left:
- m_pEdit->OnVK_LEFT(IsSHIFTpressed(nFlag), FALSE);
- return TRUE;
- case FWL_VKEY_Right:
- m_pEdit->OnVK_RIGHT(IsSHIFTpressed(nFlag), FALSE);
- return TRUE;
- case FWL_VKEY_Home:
- m_pEdit->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- return TRUE;
- case FWL_VKEY_End:
- m_pEdit->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- return TRUE;
- case FWL_VKEY_Unknown:
- if (!IsSHIFTpressed(nFlag))
- Clear();
- else
- CutText();
- return TRUE;
- default:
- break;
- }
-
- return bRet;
-}
-
-FX_BOOL CPWL_EditCtrl::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
- if (m_bMouseDown)
- return TRUE;
-
- CPWL_Wnd::OnChar(nChar, nFlag);
-
- // FILTER
- switch (nChar) {
- case 0x0A:
- case 0x1B:
- return FALSE;
- default:
- break;
- }
-
- FX_BOOL bCtrl = IsCTRLpressed(nFlag);
- FX_BOOL bAlt = IsALTpressed(nFlag);
- FX_BOOL bShift = IsSHIFTpressed(nFlag);
-
- FX_WORD word = nChar;
-
- if (bCtrl && !bAlt) {
- switch (nChar) {
- case 'C' - 'A' + 1:
- CopyText();
- return TRUE;
- case 'V' - 'A' + 1:
- PasteText();
- return TRUE;
- case 'X' - 'A' + 1:
- CutText();
- return TRUE;
- case 'A' - 'A' + 1:
- SelectAll();
- return TRUE;
- case 'Z' - 'A' + 1:
- if (bShift)
- Redo();
- else
- Undo();
- return TRUE;
- default:
- if (nChar < 32)
- return FALSE;
- }
- }
-
- if (IsReadOnly())
- return TRUE;
-
- if (m_pEdit->IsSelected() && word == FWL_VKEY_Back)
- word = FWL_VKEY_Unknown;
-
- Clear();
-
- switch (word) {
- case FWL_VKEY_Back:
- Backspace();
- break;
- case FWL_VKEY_Return:
- InsertReturn();
- break;
- case FWL_VKEY_Unknown:
- break;
- default:
- if (IsINSERTpressed(nFlag))
- Delete();
- InsertWord(word, GetCharSet());
- break;
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_EditCtrl::OnLButtonDown(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonDown(point, nFlag);
-
- if (ClientHitTest(point)) {
- if (m_bMouseDown)
- InvalidateRect();
-
- m_bMouseDown = TRUE;
- SetCapture();
-
- m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_EditCtrl::OnLButtonUp(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonUp(point, nFlag);
-
- if (m_bMouseDown) {
- // can receive keybord message
- if (ClientHitTest(point) && !IsFocused())
- SetFocus();
-
- ReleaseCapture();
- m_bMouseDown = FALSE;
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_EditCtrl::OnMouseMove(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CPWL_Wnd::OnMouseMove(point, nFlag);
-
- if (m_bMouseDown)
- m_pEdit->OnMouseMove(point, FALSE, FALSE);
-
- return TRUE;
-}
-
-CFX_FloatRect CPWL_EditCtrl::GetContentRect() const {
- return m_pEdit->GetContentRect();
-}
-
-void CPWL_EditCtrl::SetEditCaret(FX_BOOL bVisible) {
- CFX_FloatPoint ptHead(0, 0), ptFoot(0, 0);
-
- if (bVisible) {
- GetCaretInfo(ptHead, ptFoot);
- }
-
- CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace();
- IOnSetCaret(bVisible, ptHead, ptFoot, wpTemp);
-}
-
-void CPWL_EditCtrl::GetCaretInfo(CFX_FloatPoint& ptHead,
- CFX_FloatPoint& ptFoot) const {
- if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) {
- pIterator->SetAt(m_pEdit->GetCaret());
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word)) {
- ptHead.x = word.ptWord.x + word.fWidth;
- ptHead.y = word.ptWord.y + word.fAscent;
- ptFoot.x = word.ptWord.x + word.fWidth;
- ptFoot.y = word.ptWord.y + word.fDescent;
- } else if (pIterator->GetLine(line)) {
- ptHead.x = line.ptLine.x;
- ptHead.y = line.ptLine.y + line.fLineAscent;
- ptFoot.x = line.ptLine.x;
- ptFoot.y = line.ptLine.y + line.fLineDescent;
- }
- }
-}
-
-void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const {
- CFX_FloatPoint ptHead(0, 0), ptFoot(0, 0);
-
- GetCaretInfo(ptHead, ptFoot);
-
- PWLtoWnd(ptHead, x, y);
-}
-
-void CPWL_EditCtrl::SetCaret(FX_BOOL bVisible,
- const CFX_FloatPoint& ptHead,
- const CFX_FloatPoint& ptFoot) {
- if (m_pEditCaret) {
- if (!IsFocused() || m_pEdit->IsSelected())
- bVisible = FALSE;
-
- m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot);
- }
-}
-
-CFX_WideString CPWL_EditCtrl::GetText() const {
- return m_pEdit->GetText();
-}
-
-void CPWL_EditCtrl::SetSel(int32_t nStartChar, int32_t nEndChar) {
- m_pEdit->SetSel(nStartChar, nEndChar);
-}
-
-void CPWL_EditCtrl::GetSel(int32_t& nStartChar, int32_t& nEndChar) const {
- m_pEdit->GetSel(nStartChar, nEndChar);
-}
-
-void CPWL_EditCtrl::Clear() {
- if (!IsReadOnly())
- m_pEdit->Clear();
-}
-
-void CPWL_EditCtrl::SelectAll() {
- m_pEdit->SelectAll();
-}
-
-void CPWL_EditCtrl::Paint() {
- if (m_pEdit)
- m_pEdit->Paint();
-}
-
-void CPWL_EditCtrl::EnableRefresh(FX_BOOL bRefresh) {
- if (m_pEdit)
- m_pEdit->EnableRefresh(bRefresh);
-}
-
-int32_t CPWL_EditCtrl::GetCaret() const {
- if (m_pEdit)
- return m_pEdit->GetCaret();
-
- return -1;
-}
-
-void CPWL_EditCtrl::SetCaret(int32_t nPos) {
- if (m_pEdit)
- m_pEdit->SetCaret(nPos);
-}
-
-int32_t CPWL_EditCtrl::GetTotalWords() const {
- if (m_pEdit)
- return m_pEdit->GetTotalWords();
-
- return 0;
-}
-
-void CPWL_EditCtrl::SetScrollPos(const CFX_FloatPoint& point) {
- if (m_pEdit)
- m_pEdit->SetScrollPos(point);
-}
-
-CFX_FloatPoint CPWL_EditCtrl::GetScrollPos() const {
- if (m_pEdit)
- return m_pEdit->GetScrollPos();
-
- return CFX_FloatPoint(0.0f, 0.0f);
-}
-
-CPDF_Font* CPWL_EditCtrl::GetCaretFont() const {
- int32_t nFontIndex = 0;
-
- if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) {
- pIterator->SetAt(m_pEdit->GetCaret());
- CPVT_Word word;
- CPVT_Section section;
- if (pIterator->GetWord(word)) {
- nFontIndex = word.nFontIndex;
- } else if (HasFlag(PES_RICH)) {
- if (pIterator->GetSection(section)) {
- nFontIndex = section.WordProps.nFontIndex;
- }
- }
- }
-
- if (IFX_Edit_FontMap* pFontMap = GetFontMap())
- return pFontMap->GetPDFFont(nFontIndex);
-
- return NULL;
-}
-
-FX_FLOAT CPWL_EditCtrl::GetCaretFontSize() const {
- FX_FLOAT fFontSize = GetFontSize();
-
- if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) {
- pIterator->SetAt(m_pEdit->GetCaret());
- CPVT_Word word;
- CPVT_Section section;
- if (pIterator->GetWord(word)) {
- fFontSize = word.fFontSize;
- } else if (HasFlag(PES_RICH)) {
- if (pIterator->GetSection(section)) {
- fFontSize = section.WordProps.fFontSize;
- }
- }
- }
-
- return fFontSize;
-}
-
-void CPWL_EditCtrl::SetText(const FX_WCHAR* csText) {
- m_pEdit->SetText(csText);
-}
-
-void CPWL_EditCtrl::CopyText() {}
-
-void CPWL_EditCtrl::PasteText() {}
-
-void CPWL_EditCtrl::CutText() {}
-
-void CPWL_EditCtrl::ShowVScrollBar(FX_BOOL bShow) {}
-
-void CPWL_EditCtrl::InsertText(const FX_WCHAR* csText) {
- if (!IsReadOnly())
- m_pEdit->InsertText(csText);
-}
-
-void CPWL_EditCtrl::InsertWord(FX_WORD word, int32_t nCharset) {
- if (!IsReadOnly())
- m_pEdit->InsertWord(word, nCharset);
-}
-
-void CPWL_EditCtrl::InsertReturn() {
- if (!IsReadOnly())
- m_pEdit->InsertReturn();
-}
-
-void CPWL_EditCtrl::Delete() {
- if (!IsReadOnly())
- m_pEdit->Delete();
-}
-
-void CPWL_EditCtrl::Backspace() {
- if (!IsReadOnly())
- m_pEdit->Backspace();
-}
-
-FX_BOOL CPWL_EditCtrl::CanUndo() const {
- return !IsReadOnly() && m_pEdit->CanUndo();
-}
-
-FX_BOOL CPWL_EditCtrl::CanRedo() const {
- return !IsReadOnly() && m_pEdit->CanRedo();
-}
-
-void CPWL_EditCtrl::Redo() {
- if (CanRedo())
- m_pEdit->Redo();
-}
-
-void CPWL_EditCtrl::Undo() {
- if (CanUndo())
- m_pEdit->Undo();
-}
-
-void CPWL_EditCtrl::IOnSetScrollInfoY(FX_FLOAT fPlateMin,
- FX_FLOAT fPlateMax,
- FX_FLOAT fContentMin,
- FX_FLOAT fContentMax,
- FX_FLOAT fSmallStep,
- FX_FLOAT fBigStep) {
- PWL_SCROLL_INFO Info;
-
- Info.fPlateWidth = fPlateMax - fPlateMin;
- Info.fContentMin = fContentMin;
- Info.fContentMax = fContentMax;
- Info.fSmallStep = fSmallStep;
- Info.fBigStep = fBigStep;
-
- OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&Info);
-
- if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) ||
- IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) {
- ShowVScrollBar(FALSE);
- } else {
- ShowVScrollBar(TRUE);
- }
-}
-
-void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy) {
- OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy);
-}
-
-void CPWL_EditCtrl::IOnSetCaret(FX_BOOL bVisible,
- const CFX_FloatPoint& ptHead,
- const CFX_FloatPoint& ptFoot,
- const CPVT_WordPlace& place) {
- PWL_CARET_INFO cInfo;
- cInfo.bVisible = bVisible;
- cInfo.ptHead = ptHead;
- cInfo.ptFoot = ptFoot;
-
- OnNotify(this, PNM_SETCARETINFO, (intptr_t)&cInfo, (intptr_t)NULL);
-}
-
-void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps& secProps,
- const CPVT_WordProps& wordProps) {}
-
-void CPWL_EditCtrl::IOnContentChange(const CFX_FloatRect& rcContent) {
- if (IsValid()) {
- if (m_pEditNotify) {
- m_pEditNotify->OnContentChange(rcContent);
- }
- }
-}
-
-void CPWL_EditCtrl::IOnInvalidateRect(CFX_FloatRect* pRect) {
- InvalidateRect(pRect);
-}
-
-int32_t CPWL_EditCtrl::GetCharSet() const {
- return m_nCharSet < 0 ? DEFAULT_CHARSET : m_nCharSet;
-}
-
-void CPWL_EditCtrl::GetTextRange(const CFX_FloatRect& rect,
- int32_t& nStartChar,
- int32_t& nEndChar) const {
- nStartChar = m_pEdit->WordPlaceToWordIndex(
- m_pEdit->SearchWordPlace(CFX_FloatPoint(rect.left, rect.top)));
- nEndChar = m_pEdit->WordPlaceToWordIndex(
- m_pEdit->SearchWordPlace(CFX_FloatPoint(rect.right, rect.bottom)));
-}
-
-CFX_WideString CPWL_EditCtrl::GetText(int32_t& nStartChar,
- int32_t& nEndChar) const {
- CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar);
- CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar);
- return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd));
-}
-
-void CPWL_EditCtrl::SetReadyToInput() {
- if (m_bMouseDown) {
- ReleaseCapture();
- m_bMouseDown = FALSE;
- }
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp b/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
deleted file mode 100644
index 0a70357efd..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
+++ /dev/null
@@ -1,499 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_FontMap.h"
-
-#include "core/include/fpdfapi/cpdf_document.h"
-#include "core/include/fpdfapi/fpdf_module.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-
-namespace {
-
-const char kDefaultFontName[] = "Helvetica";
-
-const char* const g_sDEStandardFontName[] = {"Courier",
- "Courier-Bold",
- "Courier-BoldOblique",
- "Courier-Oblique",
- "Helvetica",
- "Helvetica-Bold",
- "Helvetica-BoldOblique",
- "Helvetica-Oblique",
- "Times-Roman",
- "Times-Bold",
- "Times-Italic",
- "Times-BoldItalic",
- "Symbol",
- "ZapfDingbats"};
-
-} // namespace
-
-CPWL_FontMap::CPWL_FontMap(IFX_SystemHandler* pSystemHandler)
- : m_pPDFDoc(NULL), m_pSystemHandler(pSystemHandler) {
- ASSERT(m_pSystemHandler);
-}
-
-CPWL_FontMap::~CPWL_FontMap() {
- delete m_pPDFDoc;
- m_pPDFDoc = NULL;
-
- Empty();
-}
-
-void CPWL_FontMap::SetSystemHandler(IFX_SystemHandler* pSystemHandler) {
- m_pSystemHandler = pSystemHandler;
-}
-
-CPDF_Document* CPWL_FontMap::GetDocument() {
- if (!m_pPDFDoc) {
- if (CPDF_ModuleMgr::Get()) {
- m_pPDFDoc = new CPDF_Document;
- m_pPDFDoc->CreateNewDoc();
- }
- }
-
- return m_pPDFDoc;
-}
-
-CPDF_Font* CPWL_FontMap::GetPDFFont(int32_t nFontIndex) {
- if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) {
- return pData->pFont;
- }
- }
-
- return NULL;
-}
-
-CFX_ByteString CPWL_FontMap::GetPDFFontAlias(int32_t nFontIndex) {
- if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) {
- return pData->sFontName;
- }
- }
-
- return "";
-}
-
-FX_BOOL CPWL_FontMap::KnowWord(int32_t nFontIndex, FX_WORD word) {
- if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) {
- if (m_aData.GetAt(nFontIndex)) {
- return CharCodeFromUnicode(nFontIndex, word) >= 0;
- }
- }
-
- return FALSE;
-}
-
-int32_t CPWL_FontMap::GetWordFontIndex(FX_WORD word,
- int32_t nCharset,
- int32_t nFontIndex) {
- if (nFontIndex > 0) {
- if (KnowWord(nFontIndex, word))
- return nFontIndex;
- } else {
- if (const CPWL_FontMap_Data* pData = GetFontMapData(0)) {
- if (nCharset == DEFAULT_CHARSET || pData->nCharset == SYMBOL_CHARSET ||
- nCharset == pData->nCharset) {
- if (KnowWord(0, word))
- return 0;
- }
- }
- }
-
- int32_t nNewFontIndex =
- GetFontIndex(GetNativeFontName(nCharset), nCharset, TRUE);
- if (nNewFontIndex >= 0) {
- if (KnowWord(nNewFontIndex, word))
- return nNewFontIndex;
- }
- nNewFontIndex = GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE);
- if (nNewFontIndex >= 0) {
- if (KnowWord(nNewFontIndex, word))
- return nNewFontIndex;
- }
- return -1;
-}
-
-int32_t CPWL_FontMap::CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word) {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) {
- if (pData->pFont) {
- if (pData->pFont->IsUnicodeCompatible()) {
- int nCharCode = pData->pFont->CharCodeFromUnicode(word);
- pData->pFont->GlyphFromCharCode(nCharCode);
- return nCharCode;
- }
- if (word < 0xFF)
- return word;
- }
- }
- return -1;
-}
-
-CFX_ByteString CPWL_FontMap::GetNativeFontName(int32_t nCharset) {
- // searching native font is slow, so we must save time
- for (int32_t i = 0, sz = m_aNativeFont.GetSize(); i < sz; i++) {
- if (CPWL_FontMap_Native* pData = m_aNativeFont.GetAt(i)) {
- if (pData->nCharset == nCharset)
- return pData->sFontName;
- }
- }
-
- CFX_ByteString sNew = GetNativeFont(nCharset);
-
- if (!sNew.IsEmpty()) {
- CPWL_FontMap_Native* pNewData = new CPWL_FontMap_Native;
- pNewData->nCharset = nCharset;
- pNewData->sFontName = sNew;
-
- m_aNativeFont.Add(pNewData);
- }
-
- return sNew;
-}
-
-void CPWL_FontMap::Empty() {
- {
- for (int32_t i = 0, sz = m_aData.GetSize(); i < sz; i++)
- delete m_aData.GetAt(i);
-
- m_aData.RemoveAll();
- }
- {
- for (int32_t i = 0, sz = m_aNativeFont.GetSize(); i < sz; i++)
- delete m_aNativeFont.GetAt(i);
-
- m_aNativeFont.RemoveAll();
- }
-}
-
-void CPWL_FontMap::Initialize() {
- GetFontIndex(kDefaultFontName, ANSI_CHARSET, FALSE);
-}
-
-FX_BOOL CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName) {
- for (int32_t i = 0; i < FX_ArraySize(g_sDEStandardFontName); ++i) {
- if (sFontName == g_sDEStandardFontName[i])
- return TRUE;
- }
-
- return FALSE;
-}
-
-int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName,
- int32_t nCharset) {
- for (int32_t i = 0, sz = m_aData.GetSize(); i < sz; i++) {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(i)) {
- if (nCharset == DEFAULT_CHARSET || nCharset == pData->nCharset) {
- if (sFontName.IsEmpty() || pData->sFontName == sFontName)
- return i;
- }
- }
- }
-
- return -1;
-}
-
-int32_t CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName,
- int32_t nCharset,
- FX_BOOL bFind) {
- int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCharset);
- if (nFontIndex >= 0)
- return nFontIndex;
-
- CFX_ByteString sAlias;
- CPDF_Font* pFont = NULL;
- if (bFind)
- pFont = FindFontSameCharset(sAlias, nCharset);
-
- if (!pFont) {
- CFX_ByteString sTemp = sFontName;
- pFont = AddFontToDocument(GetDocument(), sTemp, nCharset);
- sAlias = EncodeFontAlias(sTemp, nCharset);
- }
- AddedFont(pFont, sAlias);
- return AddFontData(pFont, sAlias, nCharset);
-}
-
-int32_t CPWL_FontMap::GetPWLFontIndex(FX_WORD word, int32_t nCharset) {
- int32_t nFind = -1;
-
- for (int32_t i = 0, sz = m_aData.GetSize(); i < sz; i++) {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(i)) {
- if (pData->nCharset == nCharset) {
- nFind = i;
- break;
- }
- }
- }
-
- CPDF_Font* pNewFont = GetPDFFont(nFind);
-
- if (!pNewFont)
- return -1;
-
- CFX_ByteString sAlias = EncodeFontAlias("Arial_Chrome", nCharset);
- AddedFont(pNewFont, sAlias);
-
- return AddFontData(pNewFont, sAlias, nCharset);
-}
-
-CPDF_Font* CPWL_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias,
- int32_t nCharset) {
- return NULL;
-}
-
-int32_t CPWL_FontMap::AddFontData(CPDF_Font* pFont,
- const CFX_ByteString& sFontAlias,
- int32_t nCharset) {
- CPWL_FontMap_Data* pNewData = new CPWL_FontMap_Data;
- pNewData->pFont = pFont;
- pNewData->sFontName = sFontAlias;
- pNewData->nCharset = nCharset;
-
- m_aData.Add(pNewData);
-
- return m_aData.GetSize() - 1;
-}
-
-void CPWL_FontMap::AddedFont(CPDF_Font* pFont,
- const CFX_ByteString& sFontAlias) {}
-
-CFX_ByteString CPWL_FontMap::GetFontName(int32_t nFontIndex) {
- if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) {
- return pData->sFontName;
- }
- }
-
- return "";
-}
-
-CFX_ByteString CPWL_FontMap::GetNativeFont(int32_t nCharset) {
- if (nCharset == DEFAULT_CHARSET)
- nCharset = GetNativeCharset();
-
- CFX_ByteString sFontName = GetDefaultFontByCharset(nCharset);
- if (m_pSystemHandler) {
- if (m_pSystemHandler->FindNativeTrueTypeFont(nCharset, sFontName))
- return sFontName;
-
- sFontName = m_pSystemHandler->GetNativeTrueTypeFont(nCharset);
- }
- return sFontName;
-}
-
-CPDF_Font* CPWL_FontMap::AddFontToDocument(CPDF_Document* pDoc,
- CFX_ByteString& sFontName,
- uint8_t nCharset) {
- if (IsStandardFont(sFontName))
- return AddStandardFont(pDoc, sFontName);
-
- return AddSystemFont(pDoc, sFontName, nCharset);
-}
-
-CPDF_Font* CPWL_FontMap::AddStandardFont(CPDF_Document* pDoc,
- CFX_ByteString& sFontName) {
- if (!pDoc)
- return NULL;
-
- CPDF_Font* pFont = NULL;
-
- if (sFontName == "ZapfDingbats") {
- pFont = pDoc->AddStandardFont(sFontName, NULL);
- } else {
- CPDF_FontEncoding fe(PDFFONT_ENCODING_WINANSI);
- pFont = pDoc->AddStandardFont(sFontName, &fe);
- }
-
- return pFont;
-}
-
-CPDF_Font* CPWL_FontMap::AddSystemFont(CPDF_Document* pDoc,
- CFX_ByteString& sFontName,
- uint8_t nCharset) {
- if (!pDoc)
- return NULL;
-
- if (sFontName.IsEmpty())
- sFontName = GetNativeFont(nCharset);
- if (nCharset == DEFAULT_CHARSET)
- nCharset = GetNativeCharset();
-
- if (m_pSystemHandler)
- return m_pSystemHandler->AddNativeTrueTypeFontToPDF(pDoc, sFontName,
- nCharset);
-
- return NULL;
-}
-
-CFX_ByteString CPWL_FontMap::EncodeFontAlias(const CFX_ByteString& sFontName,
- int32_t nCharset) {
- CFX_ByteString sPostfix;
- sPostfix.Format("_%02X", nCharset);
- return EncodeFontAlias(sFontName) + sPostfix;
-}
-
-CFX_ByteString CPWL_FontMap::EncodeFontAlias(const CFX_ByteString& sFontName) {
- CFX_ByteString sRet = sFontName;
- sRet.Remove(' ');
- return sRet;
-}
-
-int32_t CPWL_FontMap::GetFontMapCount() const {
- return m_aData.GetSize();
-}
-
-const CPWL_FontMap_Data* CPWL_FontMap::GetFontMapData(int32_t nIndex) const {
- if (nIndex >= 0 && nIndex < m_aData.GetSize()) {
- return m_aData.GetAt(nIndex);
- }
-
- return NULL;
-}
-
-int32_t CPWL_FontMap::GetNativeCharset() {
- uint8_t nCharset = ANSI_CHARSET;
- int32_t iCodePage = FXSYS_GetACP();
- switch (iCodePage) {
- case 932: // Japan
- nCharset = SHIFTJIS_CHARSET;
- break;
- case 936: // Chinese (PRC, Singapore)
- nCharset = GB2312_CHARSET;
- break;
- case 950: // Chinese (Taiwan; Hong Kong SAR, PRC)
- nCharset = GB2312_CHARSET;
- break;
- case 1252: // Windows 3.1 Latin 1 (US, Western Europe)
- nCharset = ANSI_CHARSET;
- break;
- case 874: // Thai
- nCharset = THAI_CHARSET;
- break;
- case 949: // Korean
- nCharset = HANGUL_CHARSET;
- break;
- case 1200: // Unicode (BMP of ISO 10646)
- nCharset = ANSI_CHARSET;
- break;
- case 1250: // Windows 3.1 Eastern European
- nCharset = EASTEUROPE_CHARSET;
- break;
- case 1251: // Windows 3.1 Cyrillic
- nCharset = RUSSIAN_CHARSET;
- break;
- case 1253: // Windows 3.1 Greek
- nCharset = GREEK_CHARSET;
- break;
- case 1254: // Windows 3.1 Turkish
- nCharset = TURKISH_CHARSET;
- break;
- case 1255: // Hebrew
- nCharset = HEBREW_CHARSET;
- break;
- case 1256: // Arabic
- nCharset = ARABIC_CHARSET;
- break;
- case 1257: // Baltic
- nCharset = BALTIC_CHARSET;
- break;
- case 1258: // Vietnamese
- nCharset = VIETNAMESE_CHARSET;
- break;
- case 1361: // Korean(Johab)
- nCharset = JOHAB_CHARSET;
- break;
- }
- return nCharset;
-}
-
-const CPWL_FontMap::CharsetFontMap CPWL_FontMap::defaultTTFMap[] = {
- {ANSI_CHARSET, "Helvetica"}, {GB2312_CHARSET, "SimSun"},
- {CHINESEBIG5_CHARSET, "MingLiU"}, {SHIFTJIS_CHARSET, "MS Gothic"},
- {HANGUL_CHARSET, "Batang"}, {RUSSIAN_CHARSET, "Arial"},
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
- {EASTEUROPE_CHARSET, "Arial"},
-#else
- {EASTEUROPE_CHARSET, "Tahoma"},
-#endif
- {ARABIC_CHARSET, "Arial"}, {-1, NULL}};
-
-CFX_ByteString CPWL_FontMap::GetDefaultFontByCharset(int32_t nCharset) {
- int i = 0;
- while (defaultTTFMap[i].charset != -1) {
- if (nCharset == defaultTTFMap[i].charset)
- return defaultTTFMap[i].fontname;
- ++i;
- }
- return "";
-}
-
-int32_t CPWL_FontMap::CharSetFromUnicode(FX_WORD word, int32_t nOldCharset) {
- if (m_pSystemHandler && (-1 != m_pSystemHandler->GetCharSet()))
- return m_pSystemHandler->GetCharSet();
- // to avoid CJK Font to show ASCII
- if (word < 0x7F)
- return ANSI_CHARSET;
- // follow the old charset
- if (nOldCharset != DEFAULT_CHARSET)
- return nOldCharset;
-
- // find new charset
- if ((word >= 0x4E00 && word <= 0x9FA5) ||
- (word >= 0xE7C7 && word <= 0xE7F3) ||
- (word >= 0x3000 && word <= 0x303F) ||
- (word >= 0x2000 && word <= 0x206F)) {
- return GB2312_CHARSET;
- }
-
- if (((word >= 0x3040) && (word <= 0x309F)) ||
- ((word >= 0x30A0) && (word <= 0x30FF)) ||
- ((word >= 0x31F0) && (word <= 0x31FF)) ||
- ((word >= 0xFF00) && (word <= 0xFFEF))) {
- return SHIFTJIS_CHARSET;
- }
-
- if (((word >= 0xAC00) && (word <= 0xD7AF)) ||
- ((word >= 0x1100) && (word <= 0x11FF)) ||
- ((word >= 0x3130) && (word <= 0x318F))) {
- return HANGUL_CHARSET;
- }
-
- if (word >= 0x0E00 && word <= 0x0E7F)
- return THAI_CHARSET;
-
- if ((word >= 0x0370 && word <= 0x03FF) || (word >= 0x1F00 && word <= 0x1FFF))
- return GREEK_CHARSET;
-
- if ((word >= 0x0600 && word <= 0x06FF) || (word >= 0xFB50 && word <= 0xFEFC))
- return ARABIC_CHARSET;
-
- if (word >= 0x0590 && word <= 0x05FF)
- return HEBREW_CHARSET;
-
- if (word >= 0x0400 && word <= 0x04FF)
- return RUSSIAN_CHARSET;
-
- if (word >= 0x0100 && word <= 0x024F)
- return EASTEUROPE_CHARSET;
-
- if (word >= 0x1E00 && word <= 0x1EFF)
- return VIETNAMESE_CHARSET;
-
- return ANSI_CHARSET;
-}
-
-CPWL_DocFontMap::CPWL_DocFontMap(IFX_SystemHandler* pSystemHandler,
- CPDF_Document* pAttachedDoc)
- : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {}
-
-CPWL_DocFontMap::~CPWL_DocFontMap() {}
-
-CPDF_Document* CPWL_DocFontMap::GetDocument() {
- return m_pAttachedDoc;
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_Icon.cpp b/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
deleted file mode 100644
index 2a33b96cf9..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "core/include/fpdfapi/cpdf_array.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Icon.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-
-CPWL_Image::CPWL_Image() : m_pPDFStream(NULL) {}
-
-CPWL_Image::~CPWL_Image() {}
-
-CFX_ByteString CPWL_Image::GetImageAppStream() {
- CFX_ByteTextBuf sAppStream;
-
- CFX_ByteString sAlias = GetImageAlias();
- CFX_FloatRect rcPlate = GetClientRect();
- CFX_Matrix mt;
- mt.SetReverse(GetImageMatrix());
-
- FX_FLOAT fHScale = 1.0f;
- FX_FLOAT fVScale = 1.0f;
- GetScale(fHScale, fVScale);
-
- FX_FLOAT fx = 0.0f;
- FX_FLOAT fy = 0.0f;
- GetImageOffset(fx, fy);
-
- if (m_pPDFStream && sAlias.GetLength() > 0) {
- sAppStream << "q\n";
- sAppStream << rcPlate.left << " " << rcPlate.bottom << " "
- << rcPlate.right - rcPlate.left << " "
- << rcPlate.top - rcPlate.bottom << " re W n\n";
-
- sAppStream << fHScale << " 0 0 " << fVScale << " " << rcPlate.left + fx
- << " " << rcPlate.bottom + fy << " cm\n";
- sAppStream << mt.GetA() << " " << mt.GetB() << " " << mt.GetC() << " "
- << mt.GetD() << " " << mt.GetE() << " " << mt.GetF() << " cm\n";
-
- sAppStream << "0 g 0 G 1 w /" << sAlias << " Do\n"
- << "Q\n";
- }
-
- return sAppStream.GetByteString();
-}
-
-void CPWL_Image::SetPDFStream(CPDF_Stream* pStream) {
- m_pPDFStream = pStream;
-}
-
-CPDF_Stream* CPWL_Image::GetPDFStream() {
- return m_pPDFStream;
-}
-
-void CPWL_Image::GetImageSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
- fWidth = 0.0f;
- fHeight = 0.0f;
-
- if (m_pPDFStream) {
- if (CPDF_Dictionary* pDict = m_pPDFStream->GetDict()) {
- CFX_FloatRect rect = pDict->GetRectBy("BBox");
-
- fWidth = rect.right - rect.left;
- fHeight = rect.top - rect.bottom;
- }
- }
-}
-
-CFX_Matrix CPWL_Image::GetImageMatrix() {
- if (m_pPDFStream) {
- if (CPDF_Dictionary* pDict = m_pPDFStream->GetDict()) {
- return pDict->GetMatrixBy("Matrix");
- }
- }
-
- return CFX_Matrix();
-}
-
-CFX_ByteString CPWL_Image::GetImageAlias() {
- if (!m_sImageAlias.IsEmpty())
- return m_sImageAlias;
-
- if (m_pPDFStream) {
- if (CPDF_Dictionary* pDict = m_pPDFStream->GetDict()) {
- return pDict->GetStringBy("Name");
- }
- }
-
- return CFX_ByteString();
-}
-
-void CPWL_Image::SetImageAlias(const FX_CHAR* sImageAlias) {
- m_sImageAlias = sImageAlias;
-}
-
-void CPWL_Image::GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale) {
- fHScale = 1.0f;
- fVScale = 1.0f;
-}
-
-void CPWL_Image::GetImageOffset(FX_FLOAT& x, FX_FLOAT& y) {
- x = 0.0f;
- y = 0.0f;
-}
-
-CPWL_Icon::CPWL_Icon() : m_pIconFit(NULL) {}
-
-CPWL_Icon::~CPWL_Icon() {}
-
-int32_t CPWL_Icon::GetScaleMethod() {
- if (m_pIconFit)
- return m_pIconFit->GetScaleMethod();
-
- return 0;
-}
-
-FX_BOOL CPWL_Icon::IsProportionalScale() {
- if (m_pIconFit)
- return m_pIconFit->IsProportionalScale();
-
- return FALSE;
-}
-
-void CPWL_Icon::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) {
- if (m_pIconFit) {
- fLeft = 0.0f;
- fBottom = 0.0f;
- CPDF_Array* pA =
- m_pIconFit->GetDict() ? m_pIconFit->GetDict()->GetArrayBy("A") : NULL;
- if (pA) {
- FX_DWORD dwCount = pA->GetCount();
- if (dwCount > 0)
- fLeft = pA->GetNumberAt(0);
- if (dwCount > 1)
- fBottom = pA->GetNumberAt(1);
- }
- } else {
- fLeft = 0.0f;
- fBottom = 0.0f;
- }
-}
-
-FX_BOOL CPWL_Icon::GetFittingBounds() {
- if (m_pIconFit)
- return m_pIconFit->GetFittingBounds();
-
- return FALSE;
-}
-
-void CPWL_Icon::GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale) {
- fHScale = 1.0f;
- fVScale = 1.0f;
-
- if (m_pPDFStream) {
- FX_FLOAT fImageWidth, fImageHeight;
- FX_FLOAT fPlateWidth, fPlateHeight;
-
- CFX_FloatRect rcPlate = GetClientRect();
- fPlateWidth = rcPlate.right - rcPlate.left;
- fPlateHeight = rcPlate.top - rcPlate.bottom;
-
- GetImageSize(fImageWidth, fImageHeight);
-
- int32_t nScaleMethod = GetScaleMethod();
-
- switch (nScaleMethod) {
- default:
- case 0:
- fHScale = fPlateWidth / PWL_MAX(fImageWidth, 1.0f);
- fVScale = fPlateHeight / PWL_MAX(fImageHeight, 1.0f);
- break;
- case 1:
- if (fPlateWidth < fImageWidth)
- fHScale = fPlateWidth / PWL_MAX(fImageWidth, 1.0f);
- if (fPlateHeight < fImageHeight)
- fVScale = fPlateHeight / PWL_MAX(fImageHeight, 1.0f);
- break;
- case 2:
- if (fPlateWidth > fImageWidth)
- fHScale = fPlateWidth / PWL_MAX(fImageWidth, 1.0f);
- if (fPlateHeight > fImageHeight)
- fVScale = fPlateHeight / PWL_MAX(fImageHeight, 1.0f);
- break;
- case 3:
- break;
- }
-
- FX_FLOAT fMinScale;
- if (IsProportionalScale()) {
- fMinScale = PWL_MIN(fHScale, fVScale);
- fHScale = fMinScale;
- fVScale = fMinScale;
- }
- }
-}
-
-void CPWL_Icon::GetImageOffset(FX_FLOAT& x, FX_FLOAT& y) {
- FX_FLOAT fLeft, fBottom;
-
- GetIconPosition(fLeft, fBottom);
- x = 0.0f;
- y = 0.0f;
-
- FX_FLOAT fImageWidth, fImageHeight;
- GetImageSize(fImageWidth, fImageHeight);
-
- FX_FLOAT fHScale, fVScale;
- GetScale(fHScale, fVScale);
-
- FX_FLOAT fImageFactWidth = fImageWidth * fHScale;
- FX_FLOAT fImageFactHeight = fImageHeight * fVScale;
-
- FX_FLOAT fPlateWidth, fPlateHeight;
- CFX_FloatRect rcPlate = GetClientRect();
- fPlateWidth = rcPlate.right - rcPlate.left;
- fPlateHeight = rcPlate.top - rcPlate.bottom;
-
- x = (fPlateWidth - fImageFactWidth) * fLeft;
- y = (fPlateHeight - fImageFactHeight) * fBottom;
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_IconList.cpp b/fpdfsdk/src/pdfwindow/PWL_IconList.cpp
deleted file mode 100644
index 7dc8ba9f44..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_IconList.cpp
+++ /dev/null
@@ -1,501 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_IconList.h"
-
-#include "fpdfsdk/include/pdfwindow/PWL_Label.h"
-#include "fpdfsdk/include/pdfwindow/PWL_ListCtrl.h"
-#include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-#include "public/fpdf_fwlevent.h"
-
-#define PWL_IconList_ITEM_ICON_LEFTMARGIN 10.0f
-#define PWL_IconList_ITEM_WIDTH 20.0f
-#define PWL_IconList_ITEM_HEIGHT 20.0f
-#define PWL_IconList_ITEM_SPACE 4.0f
-
-CPWL_IconList_Item::CPWL_IconList_Item()
- : m_nIconIndex(-1), m_pData(NULL), m_bSelected(FALSE), m_pText(NULL) {}
-
-CPWL_IconList_Item::~CPWL_IconList_Item() {}
-
-CFX_ByteString CPWL_IconList_Item::GetClassName() const {
- return "CPWL_IconList_Item";
-}
-
-FX_FLOAT CPWL_IconList_Item::GetItemHeight(FX_FLOAT fLimitWidth) {
- return PWL_IconList_ITEM_HEIGHT;
-}
-
-void CPWL_IconList_Item::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CFX_FloatRect rcClient = GetClientRect();
-
- if (m_bSelected) {
- if (IsEnabled()) {
- CPWL_Utils::DrawFillRect(
- pDevice, pUser2Device, rcClient,
- CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_SELBACKCOLOR,
- GetTransparency()));
- } else {
- CPWL_Utils::DrawFillRect(
- pDevice, pUser2Device, rcClient,
- CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_LIGHTGRAYCOLOR,
- GetTransparency()));
- }
- }
-
- CFX_FloatRect rcIcon = rcClient;
- rcIcon.left += PWL_IconList_ITEM_ICON_LEFTMARGIN;
- rcIcon.right = rcIcon.left + PWL_IconList_ITEM_WIDTH;
-
- CPWL_Utils::DrawIconAppStream(pDevice, pUser2Device, m_nIconIndex, rcIcon,
- m_crIcon, m_pText->GetTextColor(),
- GetTransparency());
-}
-
-void CPWL_IconList_Item::SetSelect(FX_BOOL bSelected) {
- m_bSelected = bSelected;
-
- if (bSelected)
- m_pText->SetTextColor(PWL_DEFAULT_WHITECOLOR);
- else
- m_pText->SetTextColor(PWL_DEFAULT_BLACKCOLOR);
-}
-
-FX_BOOL CPWL_IconList_Item::IsSelected() const {
- return m_bSelected;
-}
-
-void CPWL_IconList_Item::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- m_pText = new CPWL_Label;
-
- PWL_CREATEPARAM lcp = cp;
- lcp.pParentWnd = this;
- lcp.dwFlags = PWS_CHILD | PWS_VISIBLE | PES_LEFT | PES_CENTER;
- lcp.sTextColor = PWL_DEFAULT_BLACKCOLOR;
- lcp.fFontSize = 12;
- m_pText->Create(lcp);
-}
-
-void CPWL_IconList_Item::SetData(void* pData) {
- m_pData = pData;
-}
-
-void CPWL_IconList_Item::SetIcon(int32_t nIconIndex) {
- m_nIconIndex = nIconIndex;
-}
-
-void CPWL_IconList_Item::SetText(const CFX_WideString& str) {
- m_pText->SetText(str.c_str());
-}
-
-CFX_WideString CPWL_IconList_Item::GetText() const {
- return m_pText->GetText();
-}
-
-void CPWL_IconList_Item::RePosChildWnd() {
- CFX_FloatRect rcClient = GetClientRect();
-
- rcClient.left +=
- (PWL_IconList_ITEM_ICON_LEFTMARGIN + PWL_IconList_ITEM_WIDTH +
- PWL_IconList_ITEM_ICON_LEFTMARGIN);
-
- m_pText->Move(rcClient, TRUE, FALSE);
-}
-
-void CPWL_IconList_Item::SetIconFillColor(const CPWL_Color& color) {
- m_crIcon = color;
-}
-
-void CPWL_IconList_Item::OnEnabled() {
- if (m_bSelected)
- m_pText->SetTextColor(PWL_DEFAULT_WHITECOLOR);
- else
- m_pText->SetTextColor(PWL_DEFAULT_BLACKCOLOR);
-
- InvalidateRect();
-}
-
-void CPWL_IconList_Item::OnDisabled() {
- m_pText->SetTextColor(PWL_DEFAULT_HEAVYGRAYCOLOR);
-
- InvalidateRect();
-}
-
-CPWL_IconList_Content::CPWL_IconList_Content(int32_t nListCount)
- : m_nSelectIndex(-1),
- m_pNotify(NULL),
- m_bEnableNotify(TRUE),
- m_bMouseDown(FALSE),
- m_nListCount(nListCount) {}
-
-CPWL_IconList_Content::~CPWL_IconList_Content() {}
-
-void CPWL_IconList_Content::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- for (int32_t i = 0; i < m_nListCount; i++) {
- CPWL_IconList_Item* pNewItem = new CPWL_IconList_Item();
-
- PWL_CREATEPARAM icp = cp;
- icp.pParentWnd = this;
- icp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_NOREFRESHCLIP;
- pNewItem->Create(icp);
- }
-
- SetItemSpace(PWL_IconList_ITEM_SPACE);
- ResetContent(0);
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- CFX_FloatRect rcScroll = GetScrollArea();
- GetScrollPos();
-
- PWL_SCROLL_INFO sInfo;
- sInfo.fContentMin = rcScroll.bottom;
- sInfo.fContentMax = rcScroll.top;
- sInfo.fPlateWidth = GetClientRect().Height();
- sInfo.fSmallStep = 13.0f;
- sInfo.fBigStep = sInfo.fPlateWidth;
-
- pParent->OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&sInfo);
- }
-}
-
-FX_BOOL CPWL_IconList_Content::OnLButtonDown(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- SetFocus();
-
- SetCapture();
- m_bMouseDown = TRUE;
-
- int32_t nItemIndex = FindItemIndex(point);
- SetSelect(nItemIndex);
- ScrollToItem(nItemIndex);
-
- return TRUE;
-}
-
-FX_BOOL CPWL_IconList_Content::OnLButtonUp(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- m_bMouseDown = FALSE;
- ReleaseCapture();
-
- return TRUE;
-}
-
-FX_BOOL CPWL_IconList_Content::OnMouseMove(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- if (m_bMouseDown) {
- int32_t nItemIndex = FindItemIndex(point);
- SetSelect(nItemIndex);
- ScrollToItem(nItemIndex);
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_IconList_Content::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) {
- switch (nChar) {
- case FWL_VKEY_Up:
- if (m_nSelectIndex > 0) {
- int32_t nItemIndex = m_nSelectIndex - 1;
- SetSelect(nItemIndex);
- ScrollToItem(nItemIndex);
- }
- return TRUE;
- case FWL_VKEY_Down:
- if (m_nSelectIndex < m_nListCount - 1) {
- int32_t nItemIndex = m_nSelectIndex + 1;
- SetSelect(nItemIndex);
- ScrollToItem(nItemIndex);
- }
- return TRUE;
- }
-
- return FALSE;
-}
-
-int32_t CPWL_IconList_Content::FindItemIndex(const CFX_FloatPoint& point) {
- int32_t nIndex = 0;
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- CFX_FloatRect rcWnd = pChild->ChildToParent(pChild->GetWindowRect());
-
- if (point.y < rcWnd.top) {
- nIndex = i;
- }
- }
- }
-
- return nIndex;
-}
-
-void CPWL_IconList_Content::ScrollToItem(int32_t nItemIndex) {
- CFX_FloatRect rcClient = GetClientRect();
-
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex)) {
- CFX_FloatRect rcOrigin = pItem->GetWindowRect();
- CFX_FloatRect rcWnd = pItem->ChildToParent(rcOrigin);
-
- if (!(rcWnd.bottom > rcClient.bottom && rcWnd.top < rcClient.top)) {
- CFX_FloatPoint ptScroll = GetScrollPos();
-
- if (rcWnd.top > rcClient.top) {
- ptScroll.y = rcOrigin.top;
- } else if (rcWnd.bottom < rcClient.bottom) {
- ptScroll.y = rcOrigin.bottom + rcClient.Height();
- }
-
- SetScrollPos(ptScroll);
- ResetFace();
- InvalidateRect();
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
- (intptr_t)&ptScroll.y);
- }
- }
- }
-}
-
-void CPWL_IconList_Content::SetSelect(int32_t nIndex) {
- if (m_nSelectIndex != nIndex) {
- SelectItem(m_nSelectIndex, FALSE);
- SelectItem(nIndex, TRUE);
- m_nSelectIndex = nIndex;
-
- if (IPWL_IconList_Notify* pNotify = GetNotify())
- pNotify->OnNoteListSelChanged(nIndex);
- }
-}
-
-int32_t CPWL_IconList_Content::GetSelect() const {
- return m_nSelectIndex;
-}
-
-IPWL_IconList_Notify* CPWL_IconList_Content::GetNotify() const {
- if (m_bEnableNotify)
- return m_pNotify;
- return NULL;
-}
-
-void CPWL_IconList_Content::SetNotify(IPWL_IconList_Notify* pNotify) {
- m_pNotify = pNotify;
-}
-
-void CPWL_IconList_Content::EnableNotify(FX_BOOL bNotify) {
- m_bEnableNotify = bNotify;
-}
-
-void CPWL_IconList_Content::SelectItem(int32_t nItemIndex, FX_BOOL bSelect) {
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex)) {
- pItem->SetSelect(bSelect);
- pItem->InvalidateRect();
- }
-}
-
-CPWL_IconList_Item* CPWL_IconList_Content::GetListItem(
- int32_t nItemIndex) const {
- if (nItemIndex >= 0 && nItemIndex < m_aChildren.GetSize()) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(nItemIndex)) {
- if (pChild->GetClassName() == "CPWL_IconList_Item") {
- return (CPWL_IconList_Item*)pChild;
- }
- }
- }
-
- return NULL;
-}
-
-void CPWL_IconList_Content::SetListData(int32_t nItemIndex, void* pData) {
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- pItem->SetData(pData);
-}
-
-void CPWL_IconList_Content::SetListIcon(int32_t nItemIndex,
- int32_t nIconIndex) {
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- pItem->SetIcon(nIconIndex);
-}
-
-void CPWL_IconList_Content::SetListString(int32_t nItemIndex,
- const CFX_WideString& str) {
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- pItem->SetText(str);
-}
-
-CFX_WideString CPWL_IconList_Content::GetListString(int32_t nItemIndex) const {
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- return pItem->GetText();
-
- return L"";
-}
-
-void CPWL_IconList_Content::SetIconFillColor(const CPWL_Color& color) {
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- if (pChild->GetClassName() == "CPWL_IconList_Item") {
- CPWL_IconList_Item* pItem = (CPWL_IconList_Item*)pChild;
- pItem->SetIconFillColor(color);
- pItem->InvalidateRect();
- }
- }
- }
-}
-
-CPWL_IconList::CPWL_IconList(int32_t nListCount)
- : m_pListContent(NULL), m_nListCount(nListCount) {}
-
-CPWL_IconList::~CPWL_IconList() {}
-
-void CPWL_IconList::RePosChildWnd() {
- CPWL_Wnd::RePosChildWnd();
-
- if (m_pListContent)
- m_pListContent->Move(GetClientRect(), TRUE, FALSE);
-}
-
-void CPWL_IconList::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- m_pListContent = new CPWL_IconList_Content(m_nListCount);
-
- PWL_CREATEPARAM ccp = cp;
- ccp.pParentWnd = this;
- ccp.dwFlags = PWS_CHILD | PWS_VISIBLE;
- m_pListContent->Create(ccp);
-}
-
-void CPWL_IconList::OnCreated() {
- if (CPWL_ScrollBar* pScrollBar = GetVScrollBar()) {
- pScrollBar->RemoveFlag(PWS_AUTOTRANSPARENT);
- pScrollBar->SetTransparency(255);
- pScrollBar->SetNotifyForever(TRUE);
- }
-}
-
-void CPWL_IconList::OnNotify(CPWL_Wnd* pWnd,
- FX_DWORD msg,
- intptr_t wParam,
- intptr_t lParam) {
- CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
-
- if (wParam == SBT_VSCROLL) {
- switch (msg) {
- case PNM_SETSCROLLINFO:
- if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) {
- if (CPWL_ScrollBar* pScrollBar = GetVScrollBar()) {
- if (pInfo->fContentMax - pInfo->fContentMin > pInfo->fPlateWidth) {
- if (!pScrollBar->IsVisible()) {
- pScrollBar->SetVisible(TRUE);
- RePosChildWnd();
- } else {
- }
- } else {
- if (pScrollBar->IsVisible()) {
- pScrollBar->SetVisible(FALSE);
- RePosChildWnd();
- }
-
- if (m_pListContent)
- m_pListContent->SetScrollPos(CFX_FloatPoint(0.0f, 0.0f));
- }
-
- pScrollBar->OnNotify(pWnd, PNM_SETSCROLLINFO, wParam, lParam);
- }
- }
- return;
- case PNM_SCROLLWINDOW:
- if (m_pListContent) {
- m_pListContent->SetScrollPos(
- CFX_FloatPoint(0.0f, *(FX_FLOAT*)lParam));
- m_pListContent->ResetFace();
- m_pListContent->InvalidateRect(NULL);
- }
- return;
- case PNM_SETSCROLLPOS:
- if (CPWL_ScrollBar* pScrollBar = GetVScrollBar())
- pScrollBar->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam);
- return;
- }
- }
-}
-
-void CPWL_IconList::SetSelect(int32_t nIndex) {
- m_pListContent->SetSelect(nIndex);
-}
-
-void CPWL_IconList::SetTopItem(int32_t nIndex) {
- m_pListContent->ScrollToItem(nIndex);
-}
-
-int32_t CPWL_IconList::GetSelect() const {
- return m_pListContent->GetSelect();
-}
-
-void CPWL_IconList::SetNotify(IPWL_IconList_Notify* pNotify) {
- m_pListContent->SetNotify(pNotify);
-}
-
-void CPWL_IconList::EnableNotify(FX_BOOL bNotify) {
- m_pListContent->EnableNotify(bNotify);
-}
-
-void CPWL_IconList::SetListData(int32_t nItemIndex, void* pData) {
- m_pListContent->SetListData(nItemIndex, pData);
-}
-
-void CPWL_IconList::SetListIcon(int32_t nItemIndex, int32_t nIconIndex) {
- m_pListContent->SetListIcon(nItemIndex, nIconIndex);
-}
-
-void CPWL_IconList::SetListString(int32_t nItemIndex,
- const CFX_WideString& str) {
- m_pListContent->SetListString(nItemIndex, str);
-}
-
-CFX_WideString CPWL_IconList::GetListString(int32_t nItemIndex) const {
- return m_pListContent->GetListString(nItemIndex);
-}
-
-void CPWL_IconList::SetIconFillColor(const CPWL_Color& color) {
- m_pListContent->SetIconFillColor(color);
-}
-
-FX_BOOL CPWL_IconList::OnMouseWheel(short zDelta,
- const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CFX_FloatPoint ptScroll = m_pListContent->GetScrollPos();
- CFX_FloatRect rcScroll = m_pListContent->GetScrollArea();
- CFX_FloatRect rcContents = m_pListContent->GetClientRect();
-
- if (rcScroll.top - rcScroll.bottom > rcContents.Height()) {
- CFX_FloatPoint ptNew = ptScroll;
-
- if (zDelta > 0)
- ptNew.y += 30;
- else
- ptNew.y -= 30;
-
- if (ptNew.y > rcScroll.top)
- ptNew.y = rcScroll.top;
- if (ptNew.y < rcScroll.bottom + rcContents.Height())
- ptNew.y = rcScroll.bottom + rcContents.Height();
- if (ptNew.y < rcScroll.bottom)
- ptNew.y = rcScroll.bottom;
-
- if (ptNew.y != ptScroll.y) {
- m_pListContent->SetScrollPos(ptNew);
- m_pListContent->ResetFace();
- m_pListContent->InvalidateRect(NULL);
-
- if (CPWL_ScrollBar* pScrollBar = GetVScrollBar())
- pScrollBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
- (intptr_t)&ptNew.y);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_Label.cpp b/fpdfsdk/src/pdfwindow/PWL_Label.cpp
deleted file mode 100644
index 5f8d2d8685..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_Label.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_Label.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-
-CPWL_Label::CPWL_Label() : m_pEdit(NULL) {
- m_pEdit = IFX_Edit::NewEdit();
- ASSERT(m_pEdit);
-}
-
-CPWL_Label::~CPWL_Label() {
- IFX_Edit::DelEdit(m_pEdit);
-}
-
-CFX_ByteString CPWL_Label::GetClassName() const {
- return "CPWL_Label";
-}
-
-void CPWL_Label::OnCreated() {
- SetParamByFlag();
- SetFontSize(GetCreationParam().fFontSize);
-
- m_pEdit->SetFontMap(GetFontMap());
- m_pEdit->Initialize();
-
- if (HasFlag(PES_TEXTOVERFLOW)) {
- SetClipRect(CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f));
- m_pEdit->SetTextOverflow(TRUE);
- }
-}
-
-void CPWL_Label::SetText(const FX_WCHAR* csText) {
- m_pEdit->SetText(csText);
-}
-
-void CPWL_Label::RePosChildWnd() {
- m_pEdit->SetPlateRect(GetClientRect());
-}
-
-void CPWL_Label::SetFontSize(FX_FLOAT fFontSize) {
- m_pEdit->SetFontSize(fFontSize);
-}
-
-FX_FLOAT CPWL_Label::GetFontSize() const {
- return m_pEdit->GetFontSize();
-}
-
-void CPWL_Label::SetParamByFlag() {
- if (HasFlag(PES_LEFT)) {
- m_pEdit->SetAlignmentH(0);
- } else if (HasFlag(PES_MIDDLE)) {
- m_pEdit->SetAlignmentH(1);
- } else if (HasFlag(PES_RIGHT)) {
- m_pEdit->SetAlignmentH(2);
- } else {
- m_pEdit->SetAlignmentH(0);
- }
-
- if (HasFlag(PES_TOP)) {
- m_pEdit->SetAlignmentV(0);
- } else if (HasFlag(PES_CENTER)) {
- m_pEdit->SetAlignmentV(1);
- } else if (HasFlag(PES_BOTTOM)) {
- m_pEdit->SetAlignmentV(2);
- } else {
- m_pEdit->SetAlignmentV(0);
- }
-
- if (HasFlag(PES_PASSWORD)) {
- m_pEdit->SetPasswordChar('*');
- }
-
- m_pEdit->SetMultiLine(HasFlag(PES_MULTILINE));
- m_pEdit->SetAutoReturn(HasFlag(PES_AUTORETURN));
- m_pEdit->SetAutoFontSize(HasFlag(PWS_AUTOFONTSIZE));
- m_pEdit->SetAutoScroll(HasFlag(PES_AUTOSCROLL));
-}
-
-void CPWL_Label::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
-
- GetClientRect();
-
- CFX_FloatRect rcClip;
- CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange();
- CPVT_WordRange* pRange = NULL;
-
- if (!HasFlag(PES_TEXTOVERFLOW)) {
- rcClip = GetClientRect();
- pRange = &wrRange;
- }
- IFX_SystemHandler* pSysHandler = GetSystemHandler();
- IFX_Edit::DrawEdit(
- pDevice, pUser2Device, m_pEdit,
- CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
- CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()),
- rcClip, CFX_FloatPoint(0.0f, 0.0f), pRange, pSysHandler, NULL);
-}
-
-void CPWL_Label::SetHorzScale(int32_t nHorzScale) {
- m_pEdit->SetHorzScale(nHorzScale);
-}
-
-void CPWL_Label::SetCharSpace(FX_FLOAT fCharSpace) {
- m_pEdit->SetCharSpace(fCharSpace);
-}
-
-CFX_FloatRect CPWL_Label::GetContentRect() const {
- return m_pEdit->GetContentRect();
-}
-
-void CPWL_Label::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
-
- sAppStream << GetTextAppearanceStream(CFX_FloatPoint(0.0f, 0.0f));
-}
-
-CFX_ByteString CPWL_Label::GetTextAppearanceStream(
- const CFX_FloatPoint& ptOffset) const {
- CFX_ByteTextBuf sRet;
- CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset);
-
- if (sEdit.GetLength() > 0) {
- sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit
- << "ET\n";
- }
-
- return sRet.GetByteString();
-}
-
-CFX_WideString CPWL_Label::GetText() const {
- return m_pEdit->GetText();
-}
-
-void CPWL_Label::SetLimitChar(int32_t nLimitChar) {
- m_pEdit->SetLimitChar(nLimitChar);
-}
-
-int32_t CPWL_Label::GetTotalWords() {
- if (m_pEdit)
- return m_pEdit->GetTotalWords();
-
- return 0;
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_ListBox.cpp b/fpdfsdk/src/pdfwindow/PWL_ListBox.cpp
deleted file mode 100644
index 2c0b79d2f1..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_ListBox.cpp
+++ /dev/null
@@ -1,533 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_ListBox.h"
-
-#include "fpdfsdk/include/pdfwindow/PWL_Edit.h"
-#include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h"
-#include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-#include "public/fpdf_fwlevent.h"
-
-#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
-#define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
-
-CPWL_List_Notify::CPWL_List_Notify(CPWL_ListBox* pList) : m_pList(pList) {
- ASSERT(m_pList);
-}
-
-CPWL_List_Notify::~CPWL_List_Notify() {}
-
-void CPWL_List_Notify::IOnSetScrollInfoY(FX_FLOAT fPlateMin,
- FX_FLOAT fPlateMax,
- FX_FLOAT fContentMin,
- FX_FLOAT fContentMax,
- FX_FLOAT fSmallStep,
- FX_FLOAT fBigStep) {
- PWL_SCROLL_INFO Info;
-
- Info.fPlateWidth = fPlateMax - fPlateMin;
- Info.fContentMin = fContentMin;
- Info.fContentMax = fContentMax;
- Info.fSmallStep = fSmallStep;
- Info.fBigStep = fBigStep;
-
- m_pList->OnNotify(m_pList, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&Info);
-
- if (CPWL_ScrollBar* pScroll = m_pList->GetVScrollBar()) {
- if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) ||
- IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) {
- if (pScroll->IsVisible()) {
- pScroll->SetVisible(FALSE);
- m_pList->RePosChildWnd();
- }
- } else {
- if (!pScroll->IsVisible()) {
- pScroll->SetVisible(TRUE);
- m_pList->RePosChildWnd();
- }
- }
- }
-}
-
-void CPWL_List_Notify::IOnSetScrollPosY(FX_FLOAT fy) {
- m_pList->OnNotify(m_pList, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy);
-}
-
-void CPWL_List_Notify::IOnInvalidateRect(CFX_FloatRect* pRect) {
- m_pList->InvalidateRect(pRect);
-}
-
-CPWL_ListBox::CPWL_ListBox()
- : m_pList(NULL),
- m_pListNotify(NULL),
- m_bMouseDown(FALSE),
- m_bHoverSel(FALSE),
- m_pFillerNotify(NULL) {
- m_pList = IFX_List::NewList();
-}
-
-CPWL_ListBox::~CPWL_ListBox() {
- IFX_List::DelList(m_pList);
- delete m_pListNotify;
- m_pListNotify = NULL;
-}
-
-CFX_ByteString CPWL_ListBox::GetClassName() const {
- return "CPWL_ListBox";
-}
-
-void CPWL_ListBox::OnCreated() {
- if (m_pList) {
- delete m_pListNotify;
-
- m_pList->SetFontMap(GetFontMap());
- m_pList->SetNotify(m_pListNotify = new CPWL_List_Notify(this));
-
- SetHoverSel(HasFlag(PLBS_HOVERSEL));
- m_pList->SetMultipleSel(HasFlag(PLBS_MULTIPLESEL));
- m_pList->SetFontSize(GetCreationParam().fFontSize);
-
- m_bHoverSel = HasFlag(PLBS_HOVERSEL);
- }
-}
-
-void CPWL_ListBox::OnDestroy() {
- delete m_pListNotify;
- m_pListNotify = NULL;
-}
-
-void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
-
- CFX_ByteTextBuf sListItems;
-
- if (m_pList) {
- CFX_FloatRect rcPlate = m_pList->GetPlateRect();
- for (int32_t i = 0, sz = m_pList->GetCount(); i < sz; i++) {
- CFX_FloatRect rcItem = m_pList->GetItemRect(i);
-
- if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom)
- continue;
-
- CFX_FloatPoint ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f);
- if (m_pList->IsItemSelected(i)) {
- sListItems << CPWL_Utils::GetRectFillAppStream(
- rcItem, PWL_DEFAULT_SELBACKCOLOR);
- CFX_ByteString sItem =
- CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset);
- if (sItem.GetLength() > 0) {
- sListItems << "BT\n"
- << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELTEXTCOLOR)
- << sItem << "ET\n";
- }
- } else {
- CFX_ByteString sItem =
- CPWL_Utils::GetEditAppStream(m_pList->GetItemEdit(i), ptOffset);
- if (sItem.GetLength() > 0) {
- sListItems << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor())
- << sItem << "ET\n";
- }
- }
- }
- }
-
- if (sListItems.GetLength() > 0) {
- CFX_ByteTextBuf sClip;
- CFX_FloatRect rcClient = GetClientRect();
-
- sClip << "q\n";
- sClip << rcClient.left << " " << rcClient.bottom << " "
- << rcClient.right - rcClient.left << " "
- << rcClient.top - rcClient.bottom << " re W n\n";
-
- sClip << sListItems << "Q\n";
-
- sAppStream << "/Tx BMC\n" << sClip << "EMC\n";
- }
-}
-
-void CPWL_ListBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
-
- if (m_pList) {
- CFX_FloatRect rcPlate = m_pList->GetPlateRect();
- CFX_FloatRect rcList = GetListRect();
- CFX_FloatRect rcClient = GetClientRect();
-
- for (int32_t i = 0, sz = m_pList->GetCount(); i < sz; i++) {
- CFX_FloatRect rcItem = m_pList->GetItemRect(i);
- if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom)
- continue;
-
- CFX_FloatPoint ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f);
- if (IFX_Edit* pEdit = m_pList->GetItemEdit(i)) {
- CFX_FloatRect rcContent = pEdit->GetContentRect();
- if (rcContent.Width() > rcClient.Width())
- rcItem.Intersect(rcList);
- else
- rcItem.Intersect(rcClient);
- }
-
- if (m_pList->IsItemSelected(i)) {
- IFX_SystemHandler* pSysHandler = GetSystemHandler();
- if (pSysHandler && pSysHandler->IsSelectionImplemented()) {
- IFX_Edit::DrawEdit(
- pDevice, pUser2Device, m_pList->GetItemEdit(i),
- CPWL_Utils::PWLColorToFXColor(GetTextColor()),
- CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()), rcList,
- ptOffset, NULL, pSysHandler, m_pFormFiller);
- pSysHandler->OutputSelectedRect(m_pFormFiller, rcItem);
- } else {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcItem,
- ArgbEncode(255, 0, 51, 113));
- IFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i),
- ArgbEncode(255, 255, 255, 255), 0, rcList,
- ptOffset, NULL, pSysHandler, m_pFormFiller);
- }
- } else {
- IFX_SystemHandler* pSysHandler = GetSystemHandler();
- IFX_Edit::DrawEdit(pDevice, pUser2Device, m_pList->GetItemEdit(i),
- CPWL_Utils::PWLColorToFXColor(GetTextColor()),
- CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor()),
- rcList, ptOffset, NULL, pSysHandler, NULL);
- }
- }
- }
-}
-
-FX_BOOL CPWL_ListBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) {
- CPWL_Wnd::OnKeyDown(nChar, nFlag);
-
- if (!m_pList)
- return FALSE;
-
- switch (nChar) {
- default:
- return FALSE;
- case FWL_VKEY_Up:
- case FWL_VKEY_Down:
- case FWL_VKEY_Home:
- case FWL_VKEY_Left:
- case FWL_VKEY_End:
- case FWL_VKEY_Right:
- break;
- }
-
- switch (nChar) {
- case FWL_VKEY_Up:
- m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Down:
- m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Home:
- m_pList->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Left:
- m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_End:
- m_pList->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Right:
- m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- break;
- case FWL_VKEY_Delete:
- break;
- }
-
- FX_BOOL bExit = FALSE;
- OnNotifySelChanged(TRUE, bExit, nFlag);
-
- return TRUE;
-}
-
-FX_BOOL CPWL_ListBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
- CPWL_Wnd::OnChar(nChar, nFlag);
-
- if (!m_pList)
- return FALSE;
-
- if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)))
- return FALSE;
-
- FX_BOOL bExit = FALSE;
- OnNotifySelChanged(TRUE, bExit, nFlag);
-
- return TRUE;
-}
-
-FX_BOOL CPWL_ListBox::OnLButtonDown(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonDown(point, nFlag);
-
- if (ClientHitTest(point)) {
- m_bMouseDown = TRUE;
- SetFocus();
- SetCapture();
-
- if (m_pList)
- m_pList->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_ListBox::OnLButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonUp(point, nFlag);
-
- if (m_bMouseDown) {
- ReleaseCapture();
- m_bMouseDown = FALSE;
- }
-
- FX_BOOL bExit = FALSE;
- OnNotifySelChanged(FALSE, bExit, nFlag);
-
- return TRUE;
-}
-
-void CPWL_ListBox::SetHoverSel(FX_BOOL bHoverSel) {
- m_bHoverSel = bHoverSel;
-}
-
-FX_BOOL CPWL_ListBox::OnMouseMove(const CFX_FloatPoint& point, FX_DWORD nFlag) {
- CPWL_Wnd::OnMouseMove(point, nFlag);
-
- if (m_bHoverSel && !IsCaptureMouse() && ClientHitTest(point)) {
- if (m_pList)
- m_pList->Select(m_pList->GetItemIndex(point));
- }
-
- if (m_bMouseDown) {
- if (m_pList)
- m_pList->OnMouseMove(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- }
-
- return TRUE;
-}
-
-void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd,
- FX_DWORD msg,
- intptr_t wParam,
- intptr_t lParam) {
- CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
-
- FX_FLOAT fPos;
-
- switch (msg) {
- case PNM_SETSCROLLINFO:
- switch (wParam) {
- case SBT_VSCROLL:
- if (CPWL_Wnd* pChild = GetVScrollBar()) {
- pChild->OnNotify(pWnd, PNM_SETSCROLLINFO, wParam, lParam);
- }
- break;
- }
- break;
- case PNM_SETSCROLLPOS:
- switch (wParam) {
- case SBT_VSCROLL:
- if (CPWL_Wnd* pChild = GetVScrollBar()) {
- pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam);
- }
- break;
- }
- break;
- case PNM_SCROLLWINDOW:
- fPos = *(FX_FLOAT*)lParam;
- switch (wParam) {
- case SBT_VSCROLL:
- if (m_pList)
- m_pList->SetScrollPos(CFX_FloatPoint(0, fPos));
- break;
- }
- break;
- }
-}
-
-void CPWL_ListBox::KillFocus() {
- CPWL_Wnd::KillFocus();
-}
-
-void CPWL_ListBox::RePosChildWnd() {
- CPWL_Wnd::RePosChildWnd();
-
- if (m_pList)
- m_pList->SetPlateRect(GetListRect());
-}
-
-void CPWL_ListBox::OnNotifySelChanged(FX_BOOL bKeyDown,
- FX_BOOL& bExit,
- FX_DWORD nFlag) {
- if (!m_pFillerNotify)
- return;
-
- FX_BOOL bRC = TRUE;
- CFX_WideString swChange = GetText();
- CFX_WideString strChangeEx;
- int nSelStart = 0;
- int nSelEnd = swChange.GetLength();
- m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swChange, strChangeEx,
- nSelStart, nSelEnd, bKeyDown, bRC, bExit,
- nFlag);
-}
-
-CFX_FloatRect CPWL_ListBox::GetFocusRect() const {
- if (m_pList && m_pList->IsMultipleSel()) {
- CFX_FloatRect rcCaret = m_pList->GetItemRect(m_pList->GetCaret());
- rcCaret.Intersect(GetClientRect());
- return rcCaret;
- }
-
- return CPWL_Wnd::GetFocusRect();
-}
-
-void CPWL_ListBox::AddString(const FX_WCHAR* str) {
- if (m_pList) {
- m_pList->AddString(str);
- }
-}
-
-CFX_WideString CPWL_ListBox::GetText() const {
- if (m_pList)
- return m_pList->GetText();
-
- return L"";
-}
-
-void CPWL_ListBox::SetFontSize(FX_FLOAT fFontSize) {
- if (m_pList)
- m_pList->SetFontSize(fFontSize);
-}
-
-FX_FLOAT CPWL_ListBox::GetFontSize() const {
- if (m_pList)
- return m_pList->GetFontSize();
- return 0.0f;
-}
-
-void CPWL_ListBox::Select(int32_t nItemIndex) {
- if (m_pList)
- m_pList->Select(nItemIndex);
-}
-
-void CPWL_ListBox::SetCaret(int32_t nItemIndex) {
- if (m_pList)
- m_pList->SetCaret(nItemIndex);
-}
-
-void CPWL_ListBox::SetTopVisibleIndex(int32_t nItemIndex) {
- if (m_pList)
- m_pList->SetTopItem(nItemIndex);
-}
-
-void CPWL_ListBox::ScrollToListItem(int32_t nItemIndex) {
- if (m_pList)
- m_pList->ScrollToListItem(nItemIndex);
-}
-
-void CPWL_ListBox::ResetContent() {
- if (m_pList)
- m_pList->Empty();
-}
-
-void CPWL_ListBox::Reset() {
- if (m_pList)
- m_pList->Cancel();
-}
-
-FX_BOOL CPWL_ListBox::IsMultipleSel() const {
- if (m_pList)
- return m_pList->IsMultipleSel();
-
- return FALSE;
-}
-
-int32_t CPWL_ListBox::GetCaretIndex() const {
- if (m_pList)
- return m_pList->GetCaret();
-
- return -1;
-}
-
-int32_t CPWL_ListBox::GetCurSel() const {
- if (m_pList)
- return m_pList->GetSelect();
-
- return -1;
-}
-
-FX_BOOL CPWL_ListBox::IsItemSelected(int32_t nItemIndex) const {
- if (m_pList)
- return m_pList->IsItemSelected(nItemIndex);
-
- return FALSE;
-}
-
-int32_t CPWL_ListBox::GetTopVisibleIndex() const {
- if (m_pList) {
- m_pList->ScrollToListItem(m_pList->GetFirstSelected());
- return m_pList->GetTopItem();
- }
-
- return -1;
-}
-
-int32_t CPWL_ListBox::GetCount() const {
- if (m_pList)
- return m_pList->GetCount();
-
- return 0;
-}
-
-int32_t CPWL_ListBox::FindNext(int32_t nIndex, FX_WCHAR nChar) const {
- if (m_pList)
- return m_pList->FindNext(nIndex, nChar);
-
- return nIndex;
-}
-
-CFX_FloatRect CPWL_ListBox::GetContentRect() const {
- if (m_pList)
- return m_pList->GetContentRect();
-
- return CFX_FloatRect();
-}
-
-FX_FLOAT CPWL_ListBox::GetFirstHeight() const {
- if (m_pList)
- return m_pList->GetFirstHeight();
-
- return 0.0f;
-}
-
-CFX_FloatRect CPWL_ListBox::GetListRect() const {
- return CPWL_Utils::DeflateRect(
- GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
-}
-
-FX_BOOL CPWL_ListBox::OnMouseWheel(short zDelta,
- const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- if (!m_pList)
- return FALSE;
-
- if (zDelta < 0) {
- m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- } else {
- m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
- }
-
- FX_BOOL bExit = FALSE;
- OnNotifySelChanged(FALSE, bExit, nFlag);
- return TRUE;
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp b/fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp
deleted file mode 100644
index 7c2c1f4d17..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_ListCtrl.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-
-CPWL_ListCtrl::CPWL_ListCtrl()
- : m_rcContent(0, 0, 0, 0),
- m_ptScroll(0, 0),
- m_fItemSpace(0.0f),
- m_fTopSpace(0.0f),
- m_fBottomSpace(0.0f) {}
-
-CPWL_ListCtrl::~CPWL_ListCtrl() {}
-
-void CPWL_ListCtrl::SetScrollPos(const CFX_FloatPoint& point) {
- m_ptScroll = point;
-
- if (m_ptScroll.x < m_rcContent.left)
- m_ptScroll.x = m_rcContent.left;
-
- if (m_ptScroll.x > m_rcContent.right)
- m_ptScroll.x = m_rcContent.right;
-
- if (m_ptScroll.y > m_rcContent.top)
- m_ptScroll.y = m_rcContent.top;
-
- if (m_ptScroll.y < m_rcContent.bottom)
- m_ptScroll.y = m_rcContent.bottom;
-}
-
-CFX_FloatPoint CPWL_ListCtrl::GetScrollPos() const {
- return m_ptScroll;
-}
-
-CFX_FloatRect CPWL_ListCtrl::GetScrollArea() const {
- return m_rcContent;
-}
-
-void CPWL_ListCtrl::ResetFace() {
- ResetAll(FALSE, 0);
-}
-
-void CPWL_ListCtrl::ResetContent(int32_t nStart) {
- if (nStart < 0)
- nStart = 0;
- if (nStart >= 0 && nStart < m_aChildren.GetSize())
- ResetAll(TRUE, nStart);
-}
-
-FX_FLOAT CPWL_ListCtrl::GetContentsHeight(FX_FLOAT fLimitWidth) {
- FX_FLOAT fRet = m_fTopSpace;
-
- FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
-
- if (fLimitWidth > fBorderWidth * 2) {
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- FX_FLOAT fLeft = pChild->GetItemLeftMargin();
- FX_FLOAT fRight = pChild->GetItemRightMargin();
-
- fRet += pChild->GetItemHeight(fLimitWidth - fBorderWidth * 2 - fLeft -
- fRight);
- fRet += m_fItemSpace;
- }
- }
-
- fRet -= m_fItemSpace;
- }
-
- fRet += m_fBottomSpace;
-
- return fRet;
-}
-
-void CPWL_ListCtrl::ResetAll(FX_BOOL bMove, int32_t nStart) {
- CFX_FloatRect rcClient = GetClientRect();
-
- FX_FLOAT fWidth = rcClient.Width();
-
- FX_FLOAT fy = 0.0f - m_fTopSpace;
-
- if (nStart - 1 >= 0 && nStart - 1 < m_aChildren.GetSize())
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(nStart - 1))
- fy = pChild->GetWindowRect().bottom - m_fItemSpace;
-
- for (int32_t i = nStart, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- FX_FLOAT fLeft = pChild->GetItemLeftMargin();
- FX_FLOAT fRight = pChild->GetItemRightMargin();
-
- pChild->SetChildMatrix(CFX_Matrix(1, 0, 0, 1,
- rcClient.left - m_ptScroll.x,
- rcClient.top - m_ptScroll.y));
-
- if (bMove) {
- FX_FLOAT fItemHeight = pChild->GetItemHeight(fWidth - fLeft - fRight);
- pChild->Move(
- CFX_FloatRect(fLeft, fy - fItemHeight, fWidth - fRight, fy), TRUE,
- FALSE);
- fy -= fItemHeight;
- fy -= m_fItemSpace;
- }
- }
- }
-
- fy += m_fItemSpace;
-
- fy -= m_fBottomSpace;
-
- if (bMove) {
- m_rcContent.left = 0;
- m_rcContent.top = 0;
- m_rcContent.right = fWidth;
- m_rcContent.bottom = fy;
- }
-}
-
-void CPWL_ListCtrl::SetItemSpace(FX_FLOAT fSpace) {
- m_fItemSpace = fSpace;
-}
-
-void CPWL_ListCtrl::SetTopSpace(FX_FLOAT fSpace) {
- m_fTopSpace = fSpace;
-}
-
-void CPWL_ListCtrl::SetBottomSpace(FX_FLOAT fSpace) {
- m_fBottomSpace = fSpace;
-}
-
-void CPWL_ListCtrl::RePosChildWnd() {
- ResetFace();
-}
-
-void CPWL_ListCtrl::DrawChildAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- pDevice->SaveState();
- CFX_FloatRect rcClient = GetClientRect();
- CFX_FloatRect rcTemp = rcClient;
- pUser2Device->TransformRect(rcTemp);
- pDevice->SetClip_Rect(FX_RECT((int32_t)rcTemp.left, (int32_t)rcTemp.bottom,
- (int32_t)rcTemp.right, (int32_t)rcTemp.top));
-
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- CFX_FloatRect rcChild = pChild->ChildToParent(pChild->GetWindowRect());
- if (!(rcChild.top < rcClient.bottom || rcChild.bottom > rcClient.top)) {
- CFX_Matrix mt = pChild->GetChildMatrix();
- if (mt.IsIdentity()) {
- pChild->DrawAppearance(pDevice, pUser2Device);
- } else {
- mt.Concat(*pUser2Device);
- pChild->DrawAppearance(pDevice, &mt);
- }
- }
- }
- }
-
- pDevice->RestoreState();
-}
-
-int32_t CPWL_ListCtrl::GetItemIndex(CPWL_Wnd* pItem) {
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (pItem == m_aChildren.GetAt(i))
- return i;
- }
-
- return -1;
-}
-
-CFX_FloatPoint CPWL_ListCtrl::InToOut(const CFX_FloatPoint& point) const {
- CFX_FloatRect rcClient = GetClientRect();
-
- return CFX_FloatPoint(point.x + rcClient.left - m_ptScroll.x,
- point.y + rcClient.top - m_ptScroll.y);
-}
-
-CFX_FloatPoint CPWL_ListCtrl::OutToIn(const CFX_FloatPoint& point) const {
- CFX_FloatRect rcClient = GetClientRect();
-
- return CFX_FloatPoint(point.x - rcClient.left + m_ptScroll.x,
- point.y - rcClient.top + m_ptScroll.y);
-}
-
-CFX_FloatRect CPWL_ListCtrl::InToOut(const CFX_FloatRect& rect) const {
- CFX_FloatRect rcClient = GetClientRect();
-
- return CFX_FloatRect(rect.left + rcClient.left - m_ptScroll.x,
- rect.bottom + rcClient.top - m_ptScroll.y,
- rect.right + rcClient.left - m_ptScroll.x,
- rect.top + rcClient.top - m_ptScroll.y);
-}
-
-CFX_FloatRect CPWL_ListCtrl::OutToIn(const CFX_FloatRect& rect) const {
- CFX_FloatRect rcClient = GetClientRect();
-
- return CFX_FloatRect(rect.left - rcClient.left + m_ptScroll.x,
- rect.bottom - rcClient.top + m_ptScroll.y,
- rect.right - rcClient.left + m_ptScroll.x,
- rect.top - rcClient.top + m_ptScroll.y);
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_Note.cpp b/fpdfsdk/src/pdfwindow/PWL_Note.cpp
deleted file mode 100644
index 7ba6f6ad66..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_Note.cpp
+++ /dev/null
@@ -1,1512 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_Note.h"
-
-#include "fpdfsdk/include/pdfwindow/PWL_Button.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Caret.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Edit.h"
-#include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Label.h"
-#include "fpdfsdk/include/pdfwindow/PWL_ListCtrl.h"
-#include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-
-#define POPUP_ITEM_HEAD_BOTTOM 3.0f
-#define POPUP_ITEM_BOTTOMWIDTH 1.0f
-#define POPUP_ITEM_SIDEMARGIN 3.0f
-#define POPUP_ITEM_SPACE 4.0f
-#define POPUP_ITEM_TEXT_INDENT 2.0f
-#define POPUP_ITEM_BORDERCOLOR \
- CPWL_Color(COLORTYPE_RGB, 80 / 255.0f, 80 / 255.0f, 80 / 255.0f)
-
-#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
-#define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
-
-CPWL_Note_Options::CPWL_Note_Options() : m_pText(NULL) {}
-
-CPWL_Note_Options::~CPWL_Note_Options() {}
-
-void CPWL_Note_Options::SetTextColor(const CPWL_Color& color) {
- CPWL_Wnd::SetTextColor(color);
-
- if (m_pText)
- m_pText->SetTextColor(color);
-}
-
-void CPWL_Note_Options::RePosChildWnd() {
- if (IsValid()) {
- CFX_FloatRect rcClient = GetClientRect();
-
- if (rcClient.Width() > 15.0f) {
- rcClient.right -= 15.0f;
- m_pText->Move(rcClient, TRUE, FALSE);
- m_pText->SetVisible(TRUE);
- } else {
- m_pText->Move(CFX_FloatRect(0, 0, 0, 0), TRUE, FALSE);
- m_pText->SetVisible(FALSE);
- }
- }
-}
-
-void CPWL_Note_Options::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- m_pText = new CPWL_Label;
- PWL_CREATEPARAM tcp = cp;
- tcp.pParentWnd = this;
- tcp.dwFlags = PWS_CHILD | PWS_VISIBLE;
- m_pText->Create(tcp);
-}
-
-void CPWL_Note_Options::SetText(const CFX_WideString& sText) {
- m_pText->SetText(sText.c_str());
-}
-
-void CPWL_Note_Options::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
-
- CFX_FloatRect rcClient = GetClientRect();
- rcClient.left = rcClient.right - 15.0f;
-
- CFX_FloatPoint ptCenter =
- CFX_FloatPoint((rcClient.left + rcClient.right) * 0.5f,
- (rcClient.top + rcClient.bottom) * 0.5f);
-
- CFX_FloatPoint pt1(ptCenter.x - 2.0f, ptCenter.y + 2.0f * 0.5f);
- CFX_FloatPoint pt2(ptCenter.x + 2.0f, ptCenter.y + 2.0f * 0.5f);
- CFX_FloatPoint pt3(ptCenter.x, ptCenter.y - 3.0f * 0.5f);
-
- CFX_PathData path;
-
- path.SetPointCount(4);
- path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO);
- path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO);
- path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO);
- path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO);
-
- pDevice->DrawPath(
- &path, pUser2Device, NULL,
- CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), 0,
- FXFILL_ALTERNATE);
-}
-
-CFX_FloatRect CPWL_Note_Options::GetContentRect() const {
- CFX_FloatRect rcText = m_pText->GetContentRect();
- rcText.right += 15.0f;
- return rcText;
-}
-
-CPWL_Note_Edit::CPWL_Note_Edit()
- : m_bEnableNotify(TRUE),
- m_fOldItemHeight(0.0f),
- m_bSizeChanged(FALSE),
- m_fOldMin(0.0f),
- m_fOldMax(0.0f) {}
-
-CPWL_Note_Edit::~CPWL_Note_Edit() {}
-
-void CPWL_Note_Edit::RePosChildWnd() {
- m_bEnableNotify = FALSE;
- CPWL_Edit::RePosChildWnd();
- m_bEnableNotify = TRUE;
-
- m_fOldItemHeight = GetContentRect().Height();
-}
-
-void CPWL_Note_Edit::SetText(const FX_WCHAR* csText) {
- m_bEnableNotify = FALSE;
- CPWL_Edit::SetText(csText);
- m_bEnableNotify = TRUE;
- m_fOldItemHeight = GetContentRect().Height();
-}
-
-void CPWL_Note_Edit::OnSetFocus() {
- m_bEnableNotify = FALSE;
- CPWL_Edit::OnSetFocus();
- m_bEnableNotify = TRUE;
-
- EnableSpellCheck(TRUE);
-}
-
-void CPWL_Note_Edit::OnKillFocus() {
- EnableSpellCheck(FALSE);
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) {
- ASSERT(pGrand->GetClassName() == "CPWL_NoteItem");
-
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pGrand;
-
- pNoteItem->OnContentsValidate();
- }
- }
-
- CPWL_Edit::OnKillFocus();
-}
-
-void CPWL_Note_Edit::OnNotify(CPWL_Wnd* pWnd,
- FX_DWORD msg,
- intptr_t wParam,
- intptr_t lParam) {
- if (m_bEnableNotify) {
- if (wParam == SBT_VSCROLL) {
- switch (msg) {
- case PNM_SETSCROLLINFO:
- if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) {
- if (!IsFloatEqual(pInfo->fContentMax, m_fOldMax) ||
- !IsFloatEqual(pInfo->fContentMin, m_fOldMin)) {
- m_bSizeChanged = TRUE;
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- }
-
- m_fOldMax = pInfo->fContentMax;
- m_fOldMin = pInfo->fContentMin;
- return;
- }
- }
- }
- }
- }
-
- CPWL_Edit::OnNotify(pWnd, msg, wParam, lParam);
-
- if (m_bEnableNotify) {
- switch (msg) {
- case PNM_SETCARETINFO:
- if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) {
- PWL_CARET_INFO newInfo = *pInfo;
- newInfo.bVisible = TRUE;
- newInfo.ptHead = ChildToParent(pInfo->ptHead);
- newInfo.ptFoot = ChildToParent(pInfo->ptFoot);
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0);
- }
- }
- break;
- }
- }
-}
-
-FX_FLOAT CPWL_Note_Edit::GetItemHeight(FX_FLOAT fLimitWidth) {
- if (fLimitWidth > 0) {
- if (!m_bSizeChanged)
- return m_fOldItemHeight;
-
- m_bSizeChanged = FALSE;
-
- EnableNotify(FALSE);
- EnableRefresh(FALSE);
- m_pEdit->EnableNotify(FALSE);
-
- Move(CFX_FloatRect(0, 0, fLimitWidth, 0), TRUE, FALSE);
- FX_FLOAT fRet = GetContentRect().Height();
-
- m_pEdit->EnableNotify(TRUE);
- EnableNotify(TRUE);
- EnableRefresh(TRUE);
-
- return fRet;
- }
-
- return 0;
-}
-
-FX_FLOAT CPWL_Note_Edit::GetItemLeftMargin() {
- return POPUP_ITEM_TEXT_INDENT;
-}
-
-FX_FLOAT CPWL_Note_Edit::GetItemRightMargin() {
- return POPUP_ITEM_TEXT_INDENT;
-}
-
-CPWL_Note_LBBox::CPWL_Note_LBBox() {}
-
-CPWL_Note_LBBox::~CPWL_Note_LBBox() {}
-
-void CPWL_Note_LBBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CFX_FloatRect rcClient = GetClientRect();
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = 1.0f;
-
- CFX_PathData pathCross;
-
- pathCross.SetPointCount(4);
- pathCross.SetPoint(0, rcClient.left, rcClient.top, FXPT_MOVETO);
- pathCross.SetPoint(1, rcClient.right, rcClient.bottom, FXPT_LINETO);
- pathCross.SetPoint(2, rcClient.left,
- rcClient.bottom + rcClient.Height() * 0.5f, FXPT_MOVETO);
- pathCross.SetPoint(3, rcClient.left + rcClient.Width() * 0.5f,
- rcClient.bottom, FXPT_LINETO);
-
- pDevice->DrawPath(
- &pathCross, pUser2Device, &gsd, 0,
- CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
- FXFILL_ALTERNATE);
-}
-
-CPWL_Note_RBBox::CPWL_Note_RBBox() {}
-
-CPWL_Note_RBBox::~CPWL_Note_RBBox() {}
-
-void CPWL_Note_RBBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CFX_FloatRect rcClient = GetClientRect();
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = 1.0f;
-
- CFX_PathData pathCross;
-
- pathCross.SetPointCount(4);
- pathCross.SetPoint(0, rcClient.right, rcClient.top, FXPT_MOVETO);
- pathCross.SetPoint(1, rcClient.left, rcClient.bottom, FXPT_LINETO);
- pathCross.SetPoint(2, rcClient.right,
- rcClient.bottom + rcClient.Height() * 0.5f, FXPT_MOVETO);
- pathCross.SetPoint(3, rcClient.left + rcClient.Width() * 0.5f,
- rcClient.bottom, FXPT_LINETO);
-
- pDevice->DrawPath(
- &pathCross, pUser2Device, &gsd, 0,
- CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
- FXFILL_ALTERNATE);
-}
-
-CPWL_Note_Icon::CPWL_Note_Icon() : m_nType(0) {}
-
-CPWL_Note_Icon::~CPWL_Note_Icon() {}
-
-void CPWL_Note_Icon::SetIconType(int32_t nType) {
- m_nType = nType;
-}
-
-void CPWL_Note_Icon::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CPWL_Utils::DrawIconAppStream(pDevice, pUser2Device, m_nType, GetClientRect(),
- GetBackgroundColor(), PWL_DEFAULT_BLACKCOLOR,
- GetTransparency());
-}
-
-CPWL_Note_CloseBox::CPWL_Note_CloseBox() : m_bMouseDown(FALSE) {}
-
-CPWL_Note_CloseBox::~CPWL_Note_CloseBox() {}
-
-void CPWL_Note_CloseBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CPWL_Button::DrawThisAppearance(pDevice, pUser2Device);
-
- CFX_FloatRect rcClient = GetClientRect();
- rcClient = CPWL_Utils::DeflateRect(rcClient, 2.0f);
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = 1.0f;
-
- CFX_PathData pathCross;
-
- if (m_bMouseDown) {
- rcClient.left += 0.5f;
- rcClient.right += 0.5f;
- rcClient.top -= 0.5f;
- rcClient.bottom -= 0.5f;
- }
-
- pathCross.SetPointCount(4);
- pathCross.SetPoint(0, rcClient.left, rcClient.bottom, FXPT_MOVETO);
- pathCross.SetPoint(1, rcClient.right, rcClient.top, FXPT_LINETO);
- pathCross.SetPoint(2, rcClient.left, rcClient.top, FXPT_MOVETO);
- pathCross.SetPoint(3, rcClient.right, rcClient.bottom, FXPT_LINETO);
-
- pDevice->DrawPath(
- &pathCross, pUser2Device, &gsd, 0,
- CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
- FXFILL_ALTERNATE);
-}
-
-FX_BOOL CPWL_Note_CloseBox::OnLButtonDown(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- SetBorderStyle(PBS_INSET);
- InvalidateRect(NULL);
-
- m_bMouseDown = TRUE;
-
- return CPWL_Button::OnLButtonDown(point, nFlag);
-}
-
-FX_BOOL CPWL_Note_CloseBox::OnLButtonUp(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- m_bMouseDown = FALSE;
-
- SetBorderStyle(PBS_BEVELED);
- InvalidateRect(NULL);
-
- return CPWL_Button::OnLButtonUp(point, nFlag);
-}
-
-CPWL_Note_Contents::CPWL_Note_Contents() : m_pEdit(NULL) {}
-
-CPWL_Note_Contents::~CPWL_Note_Contents() {}
-
-CFX_ByteString CPWL_Note_Contents::GetClassName() const {
- return "CPWL_Note_Contents";
-}
-
-void CPWL_Note_Contents::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- m_pEdit = new CPWL_Note_Edit;
- PWL_CREATEPARAM ecp = cp;
- ecp.pParentWnd = this;
- ecp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_MULTILINE | PES_AUTORETURN |
- PES_TEXTOVERFLOW | PES_UNDO | PES_SPELLCHECK;
-
- m_pEdit->EnableNotify(FALSE);
- m_pEdit->Create(ecp);
- m_pEdit->EnableNotify(TRUE);
-}
-
-void CPWL_Note_Contents::SetText(const CFX_WideString& sText) {
- if (m_pEdit) {
- m_pEdit->EnableNotify(FALSE);
- m_pEdit->SetText(sText.c_str());
- m_pEdit->EnableNotify(TRUE);
- OnNotify(m_pEdit, PNM_NOTEEDITCHANGED, 0, 0);
- }
-}
-
-CFX_WideString CPWL_Note_Contents::GetText() const {
- if (m_pEdit)
- return m_pEdit->GetText();
-
- return L"";
-}
-
-CPWL_NoteItem* CPWL_Note_Contents::CreateSubItem() {
- CPWL_NoteItem* pNoteItem = new CPWL_NoteItem;
- PWL_CREATEPARAM icp = GetCreationParam();
- icp.pParentWnd = this;
- icp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_BACKGROUND;
- pNoteItem->Create(icp);
-
- pNoteItem->OnCreateNoteItem();
-
- pNoteItem->ResetSubjectName(m_aChildren.GetSize() - 1);
-
- FX_SYSTEMTIME st;
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- st = pSH->GetLocalTime();
- pNoteItem->SetDateTime(st);
-
- pNoteItem->SetContents(L"");
-
- OnNotify(pNoteItem, PNM_NOTEEDITCHANGED, 0, 0);
-
- return pNoteItem;
-}
-
-int32_t CPWL_Note_Contents::CountSubItems() const {
- return m_aChildren.GetSize() - 1;
-}
-
-IPWL_NoteItem* CPWL_Note_Contents::GetSubItems(int32_t index) const {
- int32_t nIndex = index + 1;
-
- if (nIndex > 0 && nIndex < m_aChildren.GetSize()) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(nIndex)) {
- ASSERT(pChild->GetClassName() == "CPWL_NoteItem");
- CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild;
- return pItem;
- }
- }
- return NULL;
-}
-
-void CPWL_Note_Contents::DeleteSubItem(IPWL_NoteItem* pNoteItem) {
- int32_t nIndex = GetItemIndex((CPWL_NoteItem*)pNoteItem);
-
- if (nIndex > 0) {
- if (CPWL_NoteItem* pPWLNoteItem = (CPWL_NoteItem*)pNoteItem) {
- pPWLNoteItem->KillFocus();
- pPWLNoteItem->Destroy();
- delete pPWLNoteItem;
- }
-
- for (int32_t i = nIndex, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- ASSERT(pChild->GetClassName() == "CPWL_NoteItem");
- CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild;
- pItem->ResetSubjectName(i);
- }
- }
-
- OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- }
-}
-
-IPWL_NoteItem* CPWL_Note_Contents::GetHitNoteItem(const CFX_FloatPoint& point) {
- CFX_FloatPoint pt = ParentToChild(point);
-
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- if (pChild->GetClassName() == "CPWL_NoteItem") {
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild;
- if (IPWL_NoteItem* pRet = pNoteItem->GetHitNoteItem(pt))
- return pRet;
- }
- }
- }
- return NULL;
-}
-
-void CPWL_Note_Contents::OnNotify(CPWL_Wnd* pWnd,
- FX_DWORD msg,
- intptr_t wParam,
- intptr_t lParam) {
- switch (msg) {
- case PNM_NOTEEDITCHANGED: {
- int32_t nIndex = GetItemIndex(pWnd);
- if (nIndex < 0)
- nIndex = 0;
-
- m_pEdit->EnableNotify(FALSE);
- ResetContent(nIndex);
- m_pEdit->EnableNotify(TRUE);
-
- for (int32_t i = nIndex + 1, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- pChild->OnNotify(this, PNM_NOTERESET, 0, 0);
- }
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- }
- }
- return;
- case PNM_SCROLLWINDOW:
- SetScrollPos(CFX_FloatPoint(0.0f, *(FX_FLOAT*)lParam));
- ResetFace();
- InvalidateRect(NULL);
- return;
- case PNM_SETCARETINFO:
- if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) {
- PWL_CARET_INFO newInfo = *pInfo;
- newInfo.bVisible = TRUE;
- newInfo.ptHead = ChildToParent(pInfo->ptHead);
- newInfo.ptFoot = ChildToParent(pInfo->ptFoot);
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0);
- }
- }
- return;
- case PNM_NOTERESET: {
- m_pEdit->EnableNotify(FALSE);
- ResetContent(0);
- m_pEdit->EnableNotify(TRUE);
-
- for (int32_t i = 1, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- pChild->OnNotify(this, PNM_NOTERESET, 0, 0);
- }
-
- m_pEdit->EnableNotify(FALSE);
- ResetContent(0);
- m_pEdit->EnableNotify(TRUE);
- }
- return;
- }
-
- CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
-}
-
-FX_BOOL CPWL_Note_Contents::OnLButtonDown(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- if (CPWL_Wnd::OnLButtonDown(point, nFlag))
- return TRUE;
-
- if (!m_pEdit->IsFocused()) {
- m_pEdit->SetFocus();
- }
-
- return TRUE;
-}
-
-void CPWL_Note_Contents::SetEditFocus(FX_BOOL bLast) {
- if (!m_pEdit->IsFocused()) {
- m_pEdit->SetFocus();
- m_pEdit->SetCaret(bLast ? m_pEdit->GetTotalWords() : 0);
- }
-}
-
-CPWL_Edit* CPWL_Note_Contents::GetEdit() const {
- return m_pEdit;
-}
-
-void CPWL_Note_Contents::EnableModify(FX_BOOL bEnabled) {
- if (!bEnabled)
- m_pEdit->AddFlag(PWS_READONLY);
- else
- m_pEdit->RemoveFlag(PWS_READONLY);
-
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- if (pChild->GetClassName() == "CPWL_NoteItem") {
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild;
- pNoteItem->EnableModify(bEnabled);
- }
- }
- }
-}
-
-void CPWL_Note_Contents::EnableRead(FX_BOOL bEnabled) {
- if (!bEnabled)
- m_pEdit->AddFlag(PES_NOREAD);
- else
- m_pEdit->RemoveFlag(PES_NOREAD);
-
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- if (pChild->GetClassName() == "CPWL_NoteItem") {
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild;
- pNoteItem->EnableRead(bEnabled);
- }
- }
- }
-}
-
-CPWL_NoteItem::CPWL_NoteItem()
- : m_pSubject(NULL),
- m_pDateTime(NULL),
- m_pContents(NULL),
- m_pPrivateData(NULL),
- m_sAuthor(L""),
- m_fOldItemHeight(0.0f),
- m_bSizeChanged(FALSE),
- m_bAllowModify(TRUE) {}
-
-CPWL_NoteItem::~CPWL_NoteItem() {}
-
-CFX_ByteString CPWL_NoteItem::GetClassName() const {
- return "CPWL_NoteItem";
-}
-
-void CPWL_NoteItem::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- CPWL_Color sTextColor;
-
- if (CPWL_Utils::IsBlackOrWhite(GetBackgroundColor()))
- sTextColor = PWL_DEFAULT_WHITECOLOR;
- else
- sTextColor = PWL_DEFAULT_BLACKCOLOR;
-
- m_pSubject = new CPWL_Label;
- PWL_CREATEPARAM scp = cp;
- scp.pParentWnd = this;
- scp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_LEFT | PES_TOP;
- scp.sTextColor = sTextColor;
- m_pSubject->Create(scp);
-
- m_pDateTime = new CPWL_Label;
- PWL_CREATEPARAM dcp = cp;
- dcp.pParentWnd = this;
- dcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_RIGHT | PES_TOP;
- dcp.sTextColor = sTextColor;
- m_pDateTime->Create(dcp);
-
- m_pContents = new CPWL_Note_Contents;
- PWL_CREATEPARAM ccp = cp;
- ccp.pParentWnd = this;
- ccp.sBackgroundColor =
- CPWL_Color(COLORTYPE_RGB, 240 / 255.0f, 240 / 255.0f, 240 / 255.0f);
- ccp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BACKGROUND;
- m_pContents->Create(ccp);
- m_pContents->SetItemSpace(POPUP_ITEM_SPACE);
- m_pContents->SetTopSpace(POPUP_ITEM_SPACE);
- m_pContents->SetBottomSpace(POPUP_ITEM_SPACE);
-}
-
-void CPWL_NoteItem::RePosChildWnd() {
- if (IsValid()) {
- CFX_FloatRect rcClient = GetClientRect();
-
- CFX_FloatRect rcSubject = rcClient;
- rcSubject.left += POPUP_ITEM_TEXT_INDENT;
- rcSubject.top = rcClient.top;
- rcSubject.right =
- PWL_MIN(rcSubject.left + m_pSubject->GetContentRect().Width() + 1.0f,
- rcClient.right);
- rcSubject.bottom = rcSubject.top - m_pSubject->GetContentRect().Height();
- rcSubject.Normalize();
- m_pSubject->Move(rcSubject, TRUE, FALSE);
- m_pSubject->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcSubject));
-
- CFX_FloatRect rcDate = rcClient;
- rcDate.right -= POPUP_ITEM_TEXT_INDENT;
- rcDate.left =
- PWL_MAX(rcDate.right - m_pDateTime->GetContentRect().Width() - 1.0f,
- rcSubject.right);
- rcDate.bottom = rcDate.top - m_pDateTime->GetContentRect().Height();
- rcDate.Normalize();
- m_pDateTime->Move(rcDate, TRUE, FALSE);
- m_pDateTime->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcDate));
-
- CFX_FloatRect rcContents = rcClient;
- rcContents.left += 1.0f;
- rcContents.right -= 1.0f;
- rcContents.top = rcDate.bottom - POPUP_ITEM_HEAD_BOTTOM;
- rcContents.bottom += POPUP_ITEM_BOTTOMWIDTH;
- rcContents.Normalize();
- m_pContents->Move(rcContents, TRUE, FALSE);
- m_pContents->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcContents));
- }
-
- SetClipRect(CPWL_Utils::InflateRect(GetWindowRect(), 1.0f));
-}
-
-void CPWL_NoteItem::SetPrivateData(void* pData) {
- m_pPrivateData = pData;
-}
-
-void CPWL_NoteItem::SetBkColor(const CPWL_Color& color) {
- CPWL_Color sBK = color;
- SetBackgroundColor(sBK);
-
- CPWL_Color sTextColor;
-
- if (CPWL_Utils::IsBlackOrWhite(sBK))
- sTextColor = PWL_DEFAULT_WHITECOLOR;
- else
- sTextColor = PWL_DEFAULT_BLACKCOLOR;
-
- SetTextColor(sTextColor);
- if (m_pSubject)
- m_pSubject->SetTextColor(sTextColor);
- if (m_pDateTime)
- m_pDateTime->SetTextColor(sTextColor);
-
- InvalidateRect(nullptr);
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnSetBkColor(this);
- }
-}
-
-void CPWL_NoteItem::SetSubjectName(const CFX_WideString& sName) {
- if (m_pSubject) {
- m_pSubject->SetText(sName.c_str());
- }
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnSetSubjectName(this);
- }
-}
-
-void CPWL_NoteItem::SetAuthorName(const CFX_WideString& sName) {
- m_sAuthor = sName;
- ResetSubjectName(-1);
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnSetAuthorName(this);
- }
-}
-
-void CPWL_NoteItem::ResetSubjectName(int32_t nItemIndex) {
- if (nItemIndex < 0) {
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- ASSERT(pParent->GetClassName() == "CPWL_Note_Contents");
-
- CPWL_Note_Contents* pContents = (CPWL_Note_Contents*)pParent;
- nItemIndex = pContents->GetItemIndex(this);
- }
- }
-
- const CPWL_Note* pNote = GetNote();
- CFX_WideString sSubject;
- sSubject.Format(pNote->GetReplyString().c_str(), nItemIndex);
-
- if (!m_sAuthor.IsEmpty()) {
- sSubject += L" - ";
- sSubject += m_sAuthor;
- }
- SetSubjectName(sSubject);
- RePosChildWnd();
-}
-
-void CPWL_NoteItem::SetDateTime(FX_SYSTEMTIME time) {
- m_dtNote = time;
-
- CFX_WideString swTime;
- swTime.Format(L"%04d-%02d-%02d %02d:%02d:%02d", time.wYear, time.wMonth,
- time.wDay, time.wHour, time.wMinute, time.wSecond);
- if (m_pDateTime) {
- m_pDateTime->SetText(swTime.c_str());
- }
-
- RePosChildWnd();
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnSetDateTime(this);
- }
-}
-
-void CPWL_NoteItem::SetContents(const CFX_WideString& sContents) {
- if (m_pContents) {
- m_pContents->SetText(sContents);
- }
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnSetContents(this);
- }
-}
-
-CPWL_NoteItem* CPWL_NoteItem::GetParentNoteItem() const {
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) {
- ASSERT(pGrand->GetClassName() == "CPWL_NoteItem");
- return (CPWL_NoteItem*)pGrand;
- }
- }
-
- return NULL;
-}
-
-IPWL_NoteItem* CPWL_NoteItem::GetParentItem() const {
- return GetParentNoteItem();
-}
-
-CPWL_Edit* CPWL_NoteItem::GetEdit() const {
- if (m_pContents)
- return m_pContents->GetEdit();
- return NULL;
-}
-
-void* CPWL_NoteItem::GetPrivateData() const {
- return m_pPrivateData;
-}
-
-CFX_WideString CPWL_NoteItem::GetAuthorName() const {
- return m_sAuthor;
-}
-
-CPWL_Color CPWL_NoteItem::GetBkColor() const {
- return GetBackgroundColor();
-}
-
-CFX_WideString CPWL_NoteItem::GetContents() const {
- if (m_pContents)
- return m_pContents->GetText();
-
- return L"";
-}
-
-FX_SYSTEMTIME CPWL_NoteItem::GetDateTime() const {
- return m_dtNote;
-}
-
-CFX_WideString CPWL_NoteItem::GetSubjectName() const {
- if (m_pSubject)
- return m_pSubject->GetText();
-
- return L"";
-}
-
-CPWL_NoteItem* CPWL_NoteItem::CreateNoteItem() {
- if (m_pContents)
- return m_pContents->CreateSubItem();
-
- return NULL;
-}
-
-IPWL_NoteItem* CPWL_NoteItem::CreateSubItem() {
- return CreateNoteItem();
-}
-
-int32_t CPWL_NoteItem::CountSubItems() const {
- if (m_pContents)
- return m_pContents->CountSubItems();
-
- return 0;
-}
-
-IPWL_NoteItem* CPWL_NoteItem::GetSubItems(int32_t index) const {
- if (m_pContents)
- return m_pContents->GetSubItems(index);
-
- return NULL;
-}
-
-void CPWL_NoteItem::DeleteSubItem(IPWL_NoteItem* pNoteItem) {
- KillFocus();
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnItemDelete(pNoteItem);
- }
-
- if (m_pContents)
- m_pContents->DeleteSubItem(pNoteItem);
-}
-
-IPWL_NoteItem* CPWL_NoteItem::GetHitNoteItem(const CFX_FloatPoint& point) {
- CFX_FloatPoint pt = ParentToChild(point);
-
- if (WndHitTest(pt)) {
- if (m_pContents) {
- if (IPWL_NoteItem* pNoteItem = m_pContents->GetHitNoteItem(pt))
- return pNoteItem;
- }
-
- return this;
- }
-
- return NULL;
-}
-
-IPWL_NoteItem* CPWL_NoteItem::GetFocusedNoteItem() const {
- if (const CPWL_Wnd* pWnd = GetFocused()) {
- if (pWnd->GetClassName() == "CPWL_Edit") {
- if (CPWL_Wnd* pParent = pWnd->GetParentWindow()) {
- ASSERT(pParent->GetClassName() == "CPWL_Note_Contents");
-
- if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) {
- ASSERT(pGrand->GetClassName() == "CPWL_NoteItem");
- return (CPWL_NoteItem*)pGrand;
- }
- }
- }
- }
-
- return NULL;
-}
-
-FX_FLOAT CPWL_NoteItem::GetItemHeight(FX_FLOAT fLimitWidth) {
- if (fLimitWidth > 0) {
- if (!m_bSizeChanged)
- return m_fOldItemHeight;
-
- m_bSizeChanged = FALSE;
-
- FX_FLOAT fRet = m_pDateTime->GetContentRect().Height();
- FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- if (fLimitWidth > fBorderWidth * 2)
- fRet += m_pContents->GetContentsHeight(fLimitWidth - fBorderWidth * 2);
- fRet += POPUP_ITEM_HEAD_BOTTOM + POPUP_ITEM_BOTTOMWIDTH + fBorderWidth * 2;
-
- return m_fOldItemHeight = fRet;
- }
-
- return 0;
-}
-
-FX_FLOAT CPWL_NoteItem::GetItemLeftMargin() {
- return POPUP_ITEM_SIDEMARGIN;
-}
-
-FX_FLOAT CPWL_NoteItem::GetItemRightMargin() {
- return POPUP_ITEM_SIDEMARGIN;
-}
-
-FX_BOOL CPWL_NoteItem::OnLButtonDown(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) {
- SetNoteFocus(FALSE);
- }
-
- CPWL_Wnd::OnLButtonDown(point, nFlag);
-
- return TRUE;
-}
-
-FX_BOOL CPWL_NoteItem::OnRButtonUp(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) {
- SetNoteFocus(FALSE);
- PopupNoteItemMenu(point);
-
- return TRUE;
- }
-
- return CPWL_Wnd::OnRButtonUp(point, nFlag);
-}
-
-void CPWL_NoteItem::OnNotify(CPWL_Wnd* pWnd,
- FX_DWORD msg,
- intptr_t wParam,
- intptr_t lParam) {
- switch (msg) {
- case PNM_NOTEEDITCHANGED:
- m_bSizeChanged = TRUE;
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- }
- return;
- case PNM_SETCARETINFO:
- if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) {
- PWL_CARET_INFO newInfo = *pInfo;
- newInfo.bVisible = TRUE;
- newInfo.ptHead = ChildToParent(pInfo->ptHead);
- newInfo.ptFoot = ChildToParent(pInfo->ptFoot);
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0);
- }
- }
- return;
- case PNM_NOTERESET:
- m_bSizeChanged = TRUE;
- m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
-
- return;
- }
-
- CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
-}
-
-void CPWL_NoteItem::PopupNoteItemMenu(const CFX_FloatPoint& point) {
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- int32_t x, y;
- PWLtoWnd(point, x, y);
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- pSH->ClientToScreen(GetAttachedHWnd(), x, y);
- pNotify->OnPopupMenu(this, x, y);
- }
-}
-
-const CPWL_Note* CPWL_NoteItem::GetNote() const {
- if (const CPWL_Wnd* pRoot = GetRootWnd()) {
- ASSERT(pRoot->GetClassName() == "CPWL_NoteItem");
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pRoot;
- if (pNoteItem->IsTopItem()) {
- return (CPWL_Note*)pNoteItem;
- }
- }
-
- return NULL;
-}
-
-IPWL_NoteNotify* CPWL_NoteItem::GetNoteNotify() const {
- if (const CPWL_Note* pNote = GetNote())
- return pNote->GetNoteNotify();
-
- return NULL;
-}
-
-void CPWL_NoteItem::OnCreateNoteItem() {
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnItemCreate(this);
- }
-}
-
-void CPWL_NoteItem::OnContentsValidate() {
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnSetContents(this);
- }
-}
-
-void CPWL_NoteItem::SetNoteFocus(FX_BOOL bLast) {
- m_pContents->SetEditFocus(bLast);
-}
-
-void CPWL_NoteItem::EnableModify(FX_BOOL bEnabled) {
- m_pContents->EnableModify(bEnabled);
- m_bAllowModify = bEnabled;
-}
-
-void CPWL_NoteItem::EnableRead(FX_BOOL bEnabled) {
- m_pContents->EnableRead(bEnabled);
-}
-
-CPWL_Note::CPWL_Note(IPopup_Note* pPopupNote,
- IPWL_NoteNotify* pNoteNotify,
- IPWL_NoteHandler* pNoteHandler)
- : m_pAuthor(NULL),
- m_pIcon(NULL),
- m_pCloseBox(NULL),
- m_pLBBox(NULL),
- m_pRBBox(NULL),
- m_pContentsBar(NULL),
- m_pOptions(NULL),
- m_pNoteNotify(pNoteNotify),
- m_bResizing(FALSE),
- m_bEnableNotify(TRUE) {}
-
-CPWL_Note::~CPWL_Note() {}
-
-IPWL_NoteItem* CPWL_Note::Reply() {
- return CreateNoteItem();
-}
-
-void CPWL_Note::EnableNotify(FX_BOOL bEnabled) {
- m_bEnableNotify = bEnabled;
-}
-
-void CPWL_Note::RePosChildWnd() {
- RePosNoteChildren();
- m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
- ResetScrollBar();
- m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
- OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- if (const CPWL_Wnd* pWnd = GetFocused()) {
- if (pWnd->GetClassName() == "CPWL_Edit") {
- CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
- pEdit->SetCaret(pEdit->GetCaret());
- }
- }
-}
-
-FX_BOOL CPWL_Note::ResetScrollBar() {
- FX_BOOL bScrollChanged = FALSE;
-
- if (ScrollBarShouldVisible()) {
- if (!m_pContentsBar->IsVisible()) {
- m_pContentsBar->SetVisible(TRUE);
- if (m_pContentsBar->IsVisible()) {
- m_pContentsBar->InvalidateRect(NULL);
- bScrollChanged = TRUE;
- }
- }
- } else {
- if (m_pContentsBar->IsVisible()) {
- m_pContentsBar->SetVisible(FALSE);
- m_pContentsBar->InvalidateRect(NULL);
-
- bScrollChanged = TRUE;
- }
- }
-
- if (bScrollChanged) {
- CFX_FloatRect rcNote = GetClientRect();
- CFX_FloatRect rcContents = m_pContents->GetWindowRect();
- rcContents.right = rcNote.right - 3.0f;
- if (m_pContentsBar->IsVisible())
- rcContents.right -= PWL_SCROLLBAR_WIDTH;
- m_pContents->Move(rcContents, TRUE, TRUE);
- m_pContents->SetScrollPos(CFX_FloatPoint(0.0f, 0.0f));
- m_pContents->InvalidateRect(NULL);
- }
-
- return bScrollChanged;
-}
-
-FX_BOOL CPWL_Note::ScrollBarShouldVisible() {
- CFX_FloatRect rcContentsFact = m_pContents->GetScrollArea();
- CFX_FloatRect rcContentsClient = m_pContents->GetClientRect();
-
- return rcContentsFact.Height() > rcContentsClient.Height();
-}
-
-void CPWL_Note::SetOptionsText(const CFX_WideString& sText) {
- if (m_pOptions)
- m_pOptions->SetText(sText);
-
- RePosNoteChildren();
-}
-
-void CPWL_Note::RePosNoteChildren() {
- if (m_bResizing)
- return;
-
- m_bResizing = TRUE;
-
- if (IsValid()) {
- CFX_FloatRect rcClient = GetClientRect();
-
- CFX_FloatRect rcIcon = rcClient;
- rcIcon.top -= 2.0f;
- rcIcon.right = rcIcon.left + 14.0f;
- rcIcon.bottom = rcIcon.top - 14.0f;
- rcIcon.Normalize();
- m_pIcon->Move(rcIcon, TRUE, FALSE);
- m_pIcon->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcIcon));
-
- CFX_FloatRect rcCloseBox = rcClient;
- rcCloseBox.right -= 1.0f;
- rcCloseBox.top -= 1.0f;
- rcCloseBox.left = rcCloseBox.right - 14.0f;
- rcCloseBox.bottom = rcCloseBox.top - 14.0f;
- rcCloseBox.Normalize();
- m_pCloseBox->Move(rcCloseBox, TRUE, FALSE);
- m_pCloseBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcCloseBox));
-
- CFX_FloatRect rcDate = rcClient;
- rcDate.right = rcCloseBox.left - POPUP_ITEM_TEXT_INDENT;
- rcDate.left =
- PWL_MAX(rcDate.right - m_pDateTime->GetContentRect().Width() - 1.0f,
- rcIcon.right + 1.0f);
- rcDate.top = rcClient.top - 2.0f;
- rcDate.bottom = rcDate.top - m_pDateTime->GetContentRect().Height();
- rcDate.Normalize();
- m_pDateTime->Move(rcDate, TRUE, FALSE);
- m_pDateTime->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcDate));
-
- CFX_FloatRect rcSubject = rcClient;
- rcSubject.top = rcClient.top - 2.0f;
- rcSubject.left = rcIcon.right + POPUP_ITEM_TEXT_INDENT;
- rcSubject.right =
- PWL_MIN(rcSubject.left + m_pSubject->GetContentRect().Width() + 1.0f,
- rcDate.left - 1.0f);
- rcSubject.bottom = rcSubject.top - m_pSubject->GetContentRect().Height();
- rcSubject.Normalize();
- m_pSubject->Move(rcSubject, TRUE, FALSE);
- m_pSubject->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcSubject));
-
- CFX_FloatRect rcOptions = rcClient;
- rcOptions.left =
- PWL_MAX(rcOptions.right - m_pOptions->GetContentRect().Width(),
- rcIcon.right + 1.0f);
- rcOptions.top = rcSubject.bottom - 4.0f;
- rcOptions.bottom = rcOptions.top - m_pOptions->GetContentRect().Height();
- rcOptions.Normalize();
- m_pOptions->Move(rcOptions, TRUE, FALSE);
- m_pOptions->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcOptions));
-
- CFX_FloatRect rcAuthor = rcClient;
- rcAuthor.top = rcSubject.bottom - 4.0f;
- rcAuthor.left = rcSubject.left;
- rcAuthor.right =
- PWL_MIN(rcSubject.left + m_pAuthor->GetContentRect().Width() + 1.0f,
- rcOptions.left - 1.0f);
- rcAuthor.bottom = rcAuthor.top - m_pAuthor->GetContentRect().Height();
- rcAuthor.Normalize();
- m_pAuthor->Move(rcAuthor, TRUE, FALSE);
- m_pAuthor->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcAuthor));
-
- CFX_FloatRect rcLBBox = rcClient;
- rcLBBox.top = rcLBBox.bottom + 7.0f;
- rcLBBox.right = rcLBBox.left + 7.0f;
- rcLBBox.Normalize();
- m_pLBBox->Move(rcLBBox, TRUE, FALSE);
- m_pLBBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcLBBox));
-
- CFX_FloatRect rcRBBox = rcClient;
- rcRBBox.top = rcRBBox.bottom + 7.0f;
- rcRBBox.left = rcRBBox.right - 7.0f;
- rcRBBox.Normalize();
- m_pRBBox->Move(rcRBBox, TRUE, FALSE);
- m_pRBBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcRBBox));
-
- CFX_FloatRect rcContents = rcClient;
- rcContents.top = rcAuthor.bottom - POPUP_ITEM_HEAD_BOTTOM;
- rcContents.left += 3.0f;
- rcContents.right -= 3.0f;
- if (m_pContentsBar->IsVisible())
- rcContents.right -= PWL_SCROLLBAR_WIDTH;
- rcContents.bottom += 14.0f;
- rcContents.Normalize();
- m_pContents->Move(rcContents, FALSE, FALSE);
- m_pContents->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcContents));
-
- CFX_FloatRect rcContentsBar = rcContents;
- rcContentsBar.right = rcClient.right - 3.0f;
- rcContentsBar.left = rcContentsBar.right - PWL_SCROLLBAR_WIDTH;
- rcContentsBar.Normalize();
- m_pContentsBar->Move(rcContentsBar, TRUE, FALSE);
- }
-
- m_bResizing = FALSE;
-}
-
-void CPWL_Note::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- CPWL_NoteItem::CreateChildWnd(cp);
-
- CPWL_Color sTextColor;
-
- if (CPWL_Utils::IsBlackOrWhite(GetBackgroundColor()))
- sTextColor = PWL_DEFAULT_WHITECOLOR;
- else
- sTextColor = PWL_DEFAULT_BLACKCOLOR;
-
- m_pAuthor = new CPWL_Label;
- PWL_CREATEPARAM acp = cp;
- acp.pParentWnd = this;
- acp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_LEFT | PES_TOP;
- acp.sTextColor = sTextColor;
- m_pAuthor->Create(acp);
-
- m_pCloseBox = new CPWL_Note_CloseBox;
- PWL_CREATEPARAM ccp = cp;
- ccp.pParentWnd = this;
- ccp.dwBorderWidth = 2;
- ccp.nBorderStyle = PBS_BEVELED;
- ccp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER;
- ccp.sTextColor = sTextColor;
- m_pCloseBox->Create(ccp);
-
- m_pIcon = new CPWL_Note_Icon;
- PWL_CREATEPARAM icp = cp;
- icp.pParentWnd = this;
- icp.dwFlags = PWS_VISIBLE | PWS_CHILD;
- m_pIcon->Create(icp);
-
- m_pOptions = new CPWL_Note_Options;
- PWL_CREATEPARAM ocp = cp;
- ocp.pParentWnd = this;
- ocp.dwFlags = PWS_CHILD | PWS_VISIBLE;
- ocp.sTextColor = sTextColor;
- m_pOptions->Create(ocp);
-
- m_pLBBox = new CPWL_Note_LBBox;
- PWL_CREATEPARAM lcp = cp;
- lcp.pParentWnd = this;
- lcp.dwFlags = PWS_VISIBLE | PWS_CHILD;
- lcp.eCursorType = FXCT_NESW;
- lcp.sTextColor = sTextColor;
- m_pLBBox->Create(lcp);
-
- m_pRBBox = new CPWL_Note_RBBox;
- PWL_CREATEPARAM rcp = cp;
- rcp.pParentWnd = this;
- rcp.dwFlags = PWS_VISIBLE | PWS_CHILD;
- rcp.eCursorType = FXCT_NWSE;
- rcp.sTextColor = sTextColor;
- m_pRBBox->Create(rcp);
-
- m_pContentsBar = new CPWL_ScrollBar(SBT_VSCROLL);
- PWL_CREATEPARAM scp = cp;
- scp.pParentWnd = this;
- scp.sBackgroundColor =
- CPWL_Color(COLORTYPE_RGB, 240 / 255.0f, 240 / 255.0f, 240 / 255.0f);
- scp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_BACKGROUND;
- m_pContentsBar->Create(scp);
- m_pContentsBar->SetNotifyForever(TRUE);
-}
-
-void CPWL_Note::SetSubjectName(const CFX_WideString& sName) {
- CPWL_NoteItem::SetSubjectName(sName);
- RePosChildWnd();
-}
-
-void CPWL_Note::SetAuthorName(const CFX_WideString& sName) {
- if (m_pAuthor) {
- m_pAuthor->SetText(sName.c_str());
- RePosChildWnd();
- }
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- pNotify->OnSetAuthorName(this);
- }
-}
-
-CFX_WideString CPWL_Note::GetAuthorName() const {
- if (m_pAuthor)
- return m_pAuthor->GetText();
-
- return L"";
-}
-
-FX_BOOL CPWL_Note::OnMouseWheel(short zDelta,
- const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
- CFX_FloatRect rcScroll = m_pContents->GetScrollArea();
- CFX_FloatRect rcContents = m_pContents->GetClientRect();
-
- if (rcScroll.top - rcScroll.bottom > rcContents.Height()) {
- CFX_FloatPoint ptNew = ptScroll;
-
- if (zDelta > 0)
- ptNew.y += 30;
- else
- ptNew.y -= 30;
-
- if (ptNew.y > rcScroll.top)
- ptNew.y = rcScroll.top;
- if (ptNew.y < rcScroll.bottom + rcContents.Height())
- ptNew.y = rcScroll.bottom + rcContents.Height();
- if (ptNew.y < rcScroll.bottom)
- ptNew.y = rcScroll.bottom;
-
- if (ptNew.y != ptScroll.y) {
- m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
- m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
- (intptr_t)&ptNew.y);
- m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
- (intptr_t)&ptNew.y);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-void CPWL_Note::OnNotify(CPWL_Wnd* pWnd,
- FX_DWORD msg,
- intptr_t wParam,
- intptr_t lParam) {
- switch (msg) {
- case PNM_NOTEEDITCHANGED: {
- CFX_FloatRect rcScroll = m_pContents->GetScrollArea();
-
- PWL_SCROLL_INFO sInfo;
- sInfo.fContentMin = rcScroll.bottom;
- sInfo.fContentMax = rcScroll.top;
- sInfo.fPlateWidth = m_pContents->GetClientRect().Height();
- sInfo.fSmallStep = 13.0f;
- sInfo.fBigStep = sInfo.fPlateWidth;
-
- if (FXSYS_memcmp(&m_OldScrollInfo, &sInfo, sizeof(PWL_SCROLL_INFO)) !=
- 0) {
- FX_BOOL bScrollChanged = FALSE;
-
- if (lParam < 3) {
- bScrollChanged = ResetScrollBar();
- if (bScrollChanged) {
- lParam++;
- m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
- OnNotify(this, PNM_NOTEEDITCHANGED, 0, lParam);
- }
- }
-
- if (!bScrollChanged) {
- if (m_pContentsBar->IsVisible()) {
- m_pContentsBar->OnNotify(pWnd, PNM_SETSCROLLINFO, SBT_VSCROLL,
- (intptr_t)&sInfo);
- m_OldScrollInfo = sInfo;
-
- CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
- CFX_FloatPoint ptOld = ptScroll;
-
- if (ptScroll.y > sInfo.fContentMax)
- ptScroll.y = sInfo.fContentMax;
- if (ptScroll.y < sInfo.fContentMin + sInfo.fPlateWidth)
- ptScroll.y = sInfo.fContentMin + sInfo.fPlateWidth;
- if (ptScroll.y < sInfo.fContentMin)
- ptScroll.y = sInfo.fContentMin;
-
- if (ptOld.y != ptScroll.y) {
- m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
- (intptr_t)&ptScroll.y);
- m_pContentsBar->InvalidateRect(NULL);
- m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
- (intptr_t)&ptScroll.y);
- }
- }
- }
- }
- }
-
- m_pContents->InvalidateRect(NULL);
-
- return;
- case PNM_SCROLLWINDOW:
- if (m_pContents)
- m_pContents->OnNotify(pWnd, msg, wParam, lParam);
- return;
- case PNM_SETSCROLLPOS:
- if (m_pContentsBar)
- m_pContentsBar->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam);
- return;
- }
-
- if (msg == PNM_SETCARETINFO && IsValid()) {
- if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) {
- if (m_pContents) {
- CFX_FloatRect rcClient = m_pContents->GetClientRect();
- if (pInfo->ptHead.y > rcClient.top) {
- CFX_FloatPoint pt = m_pContents->OutToIn(pInfo->ptHead);
- m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
- (intptr_t)&pt.y);
-
- CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
- m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
- (intptr_t)&ptScroll.y);
-
- return;
- }
-
- if (pInfo->ptFoot.y < rcClient.bottom) {
- CFX_FloatPoint pt = m_pContents->OutToIn(pInfo->ptFoot);
- pt.y += rcClient.Height();
- m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
- (intptr_t)&pt.y);
-
- CFX_FloatPoint ptScroll = m_pContents->GetScrollPos();
- m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
- (intptr_t)&ptScroll.y);
-
- return;
- }
- }
- }
- }
-
- CPWL_NoteItem::OnNotify(pWnd, msg, wParam, lParam);
-}
-
-void CPWL_Note::SetBkColor(const CPWL_Color& color) {
- CPWL_NoteItem::SetBkColor(color);
-
- CPWL_Color sBK = color;
- CPWL_Color sTextColor;
- if (CPWL_Utils::IsBlackOrWhite(sBK))
- sTextColor = PWL_DEFAULT_WHITECOLOR;
- else
- sTextColor = PWL_DEFAULT_BLACKCOLOR;
-
- if (m_pCloseBox)
- m_pCloseBox->SetTextColor(sTextColor);
- if (m_pAuthor)
- m_pAuthor->SetTextColor(sTextColor);
- if (m_pOptions)
- m_pOptions->SetTextColor(sTextColor);
- if (m_pLBBox)
- m_pLBBox->SetTextColor(sTextColor);
- if (m_pRBBox)
- m_pRBBox->SetTextColor(sTextColor);
-}
-
-FX_BOOL CPWL_Note::OnLButtonDown(const CFX_FloatPoint& point, FX_DWORD nFlag) {
- if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point))) {
- if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
- int32_t x, y;
- PWLtoWnd(point, x, y);
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- pSH->ClientToScreen(GetAttachedHWnd(), x, y);
- KillFocus();
- pNotify->OnPopupMenu(x, y);
-
- return TRUE;
- }
- }
-
- return CPWL_Wnd::OnLButtonDown(point, nFlag);
-}
-
-FX_BOOL CPWL_Note::OnRButtonUp(const CFX_FloatPoint& point, FX_DWORD nFlag) {
- return CPWL_Wnd::OnRButtonUp(point, nFlag);
-}
-
-const CPWL_Note* CPWL_Note::GetNote() const {
- return this;
-}
-
-IPWL_NoteNotify* CPWL_Note::GetNoteNotify() const {
- return m_bEnableNotify ? m_pNoteNotify : nullptr;
-}
-
-void CPWL_Note::SetIconType(int32_t nType) {
- if (m_pIcon)
- m_pIcon->SetIconType(nType);
-}
-
-void CPWL_Note::EnableModify(FX_BOOL bEnabled) {
- m_pContents->EnableModify(bEnabled);
-}
-
-void CPWL_Note::EnableRead(FX_BOOL bEnabled) {
- m_pContents->EnableRead(bEnabled);
-}
-
-CFX_WideString CPWL_Note::GetReplyString() const {
- return m_sReplyString;
-}
-
-void CPWL_Note::SetReplyString(const CFX_WideString& str) {
- m_sReplyString = str;
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp b/fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp
deleted file mode 100644
index 03bf3238fa..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp
+++ /dev/null
@@ -1,1197 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-
-#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
-#define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
-
-PWL_FLOATRANGE::PWL_FLOATRANGE() {
- Default();
-}
-
-PWL_FLOATRANGE::PWL_FLOATRANGE(FX_FLOAT min, FX_FLOAT max) {
- Set(min, max);
-}
-
-void PWL_FLOATRANGE::Default() {
- fMin = 0;
- fMax = 0;
-}
-
-void PWL_FLOATRANGE::Set(FX_FLOAT min, FX_FLOAT max) {
- if (min > max) {
- fMin = max;
- fMax = min;
- } else {
- fMin = min;
- fMax = max;
- }
-}
-
-FX_BOOL PWL_FLOATRANGE::In(FX_FLOAT x) const {
- return (IsFloatBigger(x, fMin) || IsFloatEqual(x, fMin)) &&
- (IsFloatSmaller(x, fMax) || IsFloatEqual(x, fMax));
-}
-
-FX_FLOAT PWL_FLOATRANGE::GetWidth() const {
- return fMax - fMin;
-}
-
-PWL_SCROLL_PRIVATEDATA::PWL_SCROLL_PRIVATEDATA() {
- Default();
-}
-
-void PWL_SCROLL_PRIVATEDATA::Default() {
- ScrollRange.Default();
- fScrollPos = ScrollRange.fMin;
- fClientWidth = 0;
- fBigStep = 10;
- fSmallStep = 1;
-}
-
-void PWL_SCROLL_PRIVATEDATA::SetScrollRange(FX_FLOAT min, FX_FLOAT max) {
- ScrollRange.Set(min, max);
-
- if (IsFloatSmaller(fScrollPos, ScrollRange.fMin))
- fScrollPos = ScrollRange.fMin;
- if (IsFloatBigger(fScrollPos, ScrollRange.fMax))
- fScrollPos = ScrollRange.fMax;
-}
-
-void PWL_SCROLL_PRIVATEDATA::SetClientWidth(FX_FLOAT width) {
- fClientWidth = width;
-}
-
-void PWL_SCROLL_PRIVATEDATA::SetSmallStep(FX_FLOAT step) {
- fSmallStep = step;
-}
-
-void PWL_SCROLL_PRIVATEDATA::SetBigStep(FX_FLOAT step) {
- fBigStep = step;
-}
-
-FX_BOOL PWL_SCROLL_PRIVATEDATA::SetPos(FX_FLOAT pos) {
- if (ScrollRange.In(pos)) {
- fScrollPos = pos;
- return TRUE;
- }
- return FALSE;
-}
-
-void PWL_SCROLL_PRIVATEDATA::AddSmall() {
- if (!SetPos(fScrollPos + fSmallStep))
- SetPos(ScrollRange.fMax);
-}
-
-void PWL_SCROLL_PRIVATEDATA::SubSmall() {
- if (!SetPos(fScrollPos - fSmallStep))
- SetPos(ScrollRange.fMin);
-}
-
-void PWL_SCROLL_PRIVATEDATA::AddBig() {
- if (!SetPos(fScrollPos + fBigStep))
- SetPos(ScrollRange.fMax);
-}
-
-void PWL_SCROLL_PRIVATEDATA::SubBig() {
- if (!SetPos(fScrollPos - fBigStep))
- SetPos(ScrollRange.fMin);
-}
-
-CPWL_SBButton::CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType,
- PWL_SBBUTTON_TYPE eButtonType) {
- m_eScrollBarType = eScrollBarType;
- m_eSBButtonType = eButtonType;
-
- m_bMouseDown = FALSE;
-}
-
-CPWL_SBButton::~CPWL_SBButton() {}
-
-CFX_ByteString CPWL_SBButton::GetClassName() const {
- return "CPWL_SBButton";
-}
-
-void CPWL_SBButton::OnCreate(PWL_CREATEPARAM& cp) {
- cp.eCursorType = FXCT_ARROW;
-}
-
-void CPWL_SBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
-
- if (!IsVisible())
- return;
-
- CFX_ByteTextBuf sButton;
-
- CFX_FloatRect rectWnd = GetWindowRect();
-
- if (rectWnd.IsEmpty())
- return;
-
- sAppStream << "q\n";
-
- CFX_FloatPoint ptCenter = GetCenterPoint();
-
- switch (m_eScrollBarType) {
- case SBT_HSCROLL:
- switch (m_eSBButtonType) {
- case PSBT_MIN: {
- CFX_FloatPoint pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f,
- ptCenter.y);
- CFX_FloatPoint pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f,
- ptCenter.y + PWL_TRIANGLE_HALFLEN);
- CFX_FloatPoint pt3(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f,
- ptCenter.y - PWL_TRIANGLE_HALFLEN);
-
- if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 &&
- rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) {
- sButton << "0 g\n";
- sButton << pt1.x << " " << pt1.y << " m\n";
- sButton << pt2.x << " " << pt2.y << " l\n";
- sButton << pt3.x << " " << pt3.y << " l\n";
- sButton << pt1.x << " " << pt1.y << " l f\n";
-
- sAppStream << sButton;
- }
- } break;
- case PSBT_MAX: {
- CFX_FloatPoint pt1(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f,
- ptCenter.y);
- CFX_FloatPoint pt2(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f,
- ptCenter.y + PWL_TRIANGLE_HALFLEN);
- CFX_FloatPoint pt3(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f,
- ptCenter.y - PWL_TRIANGLE_HALFLEN);
-
- if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 &&
- rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) {
- sButton << "0 g\n";
- sButton << pt1.x << " " << pt1.y << " m\n";
- sButton << pt2.x << " " << pt2.y << " l\n";
- sButton << pt3.x << " " << pt3.y << " l\n";
- sButton << pt1.x << " " << pt1.y << " l f\n";
-
- sAppStream << sButton;
- }
- } break;
- default:
- break;
- }
- break;
- case SBT_VSCROLL:
- switch (m_eSBButtonType) {
- case PSBT_MIN: {
- CFX_FloatPoint pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN,
- ptCenter.y - PWL_TRIANGLE_HALFLEN * 0.5f);
- CFX_FloatPoint pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN,
- ptCenter.y - PWL_TRIANGLE_HALFLEN * 0.5f);
- CFX_FloatPoint pt3(ptCenter.x,
- ptCenter.y + PWL_TRIANGLE_HALFLEN * 0.5f);
-
- if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 &&
- rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) {
- sButton << "0 g\n";
- sButton << pt1.x << " " << pt1.y << " m\n";
- sButton << pt2.x << " " << pt2.y << " l\n";
- sButton << pt3.x << " " << pt3.y << " l\n";
- sButton << pt1.x << " " << pt1.y << " l f\n";
-
- sAppStream << sButton;
- }
- } break;
- case PSBT_MAX: {
- CFX_FloatPoint pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN,
- ptCenter.y + PWL_TRIANGLE_HALFLEN * 0.5f);
- CFX_FloatPoint pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN,
- ptCenter.y + PWL_TRIANGLE_HALFLEN * 0.5f);
- CFX_FloatPoint pt3(ptCenter.x,
- ptCenter.y - PWL_TRIANGLE_HALFLEN * 0.5f);
-
- if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 &&
- rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) {
- sButton << "0 g\n";
- sButton << pt1.x << " " << pt1.y << " m\n";
- sButton << pt2.x << " " << pt2.y << " l\n";
- sButton << pt3.x << " " << pt3.y << " l\n";
- sButton << pt1.x << " " << pt1.y << " l f\n";
-
- sAppStream << sButton;
- }
- } break;
- default:
- break;
- }
- break;
- default:
- break;
- }
-
- sAppStream << "Q\n";
-}
-
-void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- if (!IsVisible())
- return;
-
- CFX_FloatRect rectWnd = GetWindowRect();
- if (rectWnd.IsEmpty())
- return;
-
- CFX_FloatPoint ptCenter = GetCenterPoint();
- int32_t nTransparancy = GetTransparency();
-
- switch (m_eScrollBarType) {
- case SBT_HSCROLL:
- CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
- switch (m_eSBButtonType) {
- case PSBT_MIN: {
- CFX_FloatPoint pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f,
- ptCenter.y);
- CFX_FloatPoint pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f,
- ptCenter.y + PWL_TRIANGLE_HALFLEN);
- CFX_FloatPoint pt3(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f,
- ptCenter.y - PWL_TRIANGLE_HALFLEN);
-
- if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 &&
- rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) {
- CFX_PathData path;
-
- path.SetPointCount(4);
- path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO);
- path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO);
- path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO);
- path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO);
-
- pDevice->DrawPath(&path, pUser2Device, NULL,
- CPWL_Utils::PWLColorToFXColor(
- PWL_DEFAULT_BLACKCOLOR, nTransparancy),
- 0, FXFILL_ALTERNATE);
- }
- } break;
- case PSBT_MAX: {
- CFX_FloatPoint pt1(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f,
- ptCenter.y);
- CFX_FloatPoint pt2(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f,
- ptCenter.y + PWL_TRIANGLE_HALFLEN);
- CFX_FloatPoint pt3(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f,
- ptCenter.y - PWL_TRIANGLE_HALFLEN);
-
- if (rectWnd.right - rectWnd.left > PWL_TRIANGLE_HALFLEN * 2 &&
- rectWnd.top - rectWnd.bottom > PWL_TRIANGLE_HALFLEN) {
- CFX_PathData path;
-
- path.SetPointCount(4);
- path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO);
- path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO);
- path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO);
- path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO);
-
- pDevice->DrawPath(&path, pUser2Device, NULL,
- CPWL_Utils::PWLColorToFXColor(
- PWL_DEFAULT_BLACKCOLOR, nTransparancy),
- 0, FXFILL_ALTERNATE);
- }
- } break;
- default:
- break;
- }
- break;
- case SBT_VSCROLL:
- switch (m_eSBButtonType) {
- case PSBT_MIN: {
- // draw border
- CFX_FloatRect rcDraw = rectWnd;
- CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw,
- ArgbEncode(nTransparancy, 100, 100, 100),
- 0.0f);
-
- // draw inner border
- rcDraw = CPWL_Utils::DeflateRect(rectWnd, 0.5f);
- CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw,
- ArgbEncode(nTransparancy, 255, 255, 255),
- 1.0f);
-
- // draw background
-
- rcDraw = CPWL_Utils::DeflateRect(rectWnd, 1.0f);
-
- if (IsEnabled())
- CPWL_Utils::DrawShadow(pDevice, pUser2Device, TRUE, FALSE, rcDraw,
- nTransparancy, 80, 220);
- else
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcDraw,
- ArgbEncode(255, 255, 255, 255));
-
- // draw arrow
-
- if (rectWnd.top - rectWnd.bottom > 6.0f) {
- FX_FLOAT fX = rectWnd.left + 1.5f;
- FX_FLOAT fY = rectWnd.bottom;
- CFX_FloatPoint pts[7] = {CFX_FloatPoint(fX + 2.5f, fY + 4.0f),
- CFX_FloatPoint(fX + 2.5f, fY + 3.0f),
- CFX_FloatPoint(fX + 4.5f, fY + 5.0f),
- CFX_FloatPoint(fX + 6.5f, fY + 3.0f),
- CFX_FloatPoint(fX + 6.5f, fY + 4.0f),
- CFX_FloatPoint(fX + 4.5f, fY + 6.0f),
- CFX_FloatPoint(fX + 2.5f, fY + 4.0f)};
-
- if (IsEnabled())
- CPWL_Utils::DrawFillArea(
- pDevice, pUser2Device, pts, 7,
- ArgbEncode(nTransparancy, 255, 255, 255));
- else
- CPWL_Utils::DrawFillArea(pDevice, pUser2Device, pts, 7,
- CPWL_Utils::PWLColorToFXColor(
- PWL_DEFAULT_HEAVYGRAYCOLOR, 255));
- }
- } break;
- case PSBT_MAX: {
- // draw border
- CFX_FloatRect rcDraw = rectWnd;
- CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw,
- ArgbEncode(nTransparancy, 100, 100, 100),
- 0.0f);
-
- // draw inner border
- rcDraw = CPWL_Utils::DeflateRect(rectWnd, 0.5f);
- CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw,
- ArgbEncode(nTransparancy, 255, 255, 255),
- 1.0f);
-
- // draw background
- rcDraw = CPWL_Utils::DeflateRect(rectWnd, 1.0f);
- if (IsEnabled())
- CPWL_Utils::DrawShadow(pDevice, pUser2Device, TRUE, FALSE, rcDraw,
- nTransparancy, 80, 220);
- else
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcDraw,
- ArgbEncode(255, 255, 255, 255));
-
- // draw arrow
-
- if (rectWnd.top - rectWnd.bottom > 6.0f) {
- FX_FLOAT fX = rectWnd.left + 1.5f;
- FX_FLOAT fY = rectWnd.bottom;
-
- CFX_FloatPoint pts[7] = {CFX_FloatPoint(fX + 2.5f, fY + 5.0f),
- CFX_FloatPoint(fX + 2.5f, fY + 6.0f),
- CFX_FloatPoint(fX + 4.5f, fY + 4.0f),
- CFX_FloatPoint(fX + 6.5f, fY + 6.0f),
- CFX_FloatPoint(fX + 6.5f, fY + 5.0f),
- CFX_FloatPoint(fX + 4.5f, fY + 3.0f),
- CFX_FloatPoint(fX + 2.5f, fY + 5.0f)};
-
- if (IsEnabled())
- CPWL_Utils::DrawFillArea(
- pDevice, pUser2Device, pts, 7,
- ArgbEncode(nTransparancy, 255, 255, 255));
- else
- CPWL_Utils::DrawFillArea(pDevice, pUser2Device, pts, 7,
- CPWL_Utils::PWLColorToFXColor(
- PWL_DEFAULT_HEAVYGRAYCOLOR, 255));
- }
- } break;
- case PSBT_POS: {
- // draw border
- CFX_FloatRect rcDraw = rectWnd;
- CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw,
- ArgbEncode(nTransparancy, 100, 100, 100),
- 0.0f);
-
- // draw inner border
- rcDraw = CPWL_Utils::DeflateRect(rectWnd, 0.5f);
- CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw,
- ArgbEncode(nTransparancy, 255, 255, 255),
- 1.0f);
-
- if (IsEnabled()) {
- // draw shadow effect
-
- CFX_FloatPoint ptTop =
- CFX_FloatPoint(rectWnd.left, rectWnd.top - 1.0f);
- CFX_FloatPoint ptBottom =
- CFX_FloatPoint(rectWnd.left, rectWnd.bottom + 1.0f);
-
- ptTop.x += 1.5f;
- ptBottom.x += 1.5f;
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom,
- ArgbEncode(nTransparancy, 210, 210, 210),
- 1.0f);
-
- ptTop.x += 1.0f;
- ptBottom.x += 1.0f;
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom,
- ArgbEncode(nTransparancy, 220, 220, 220),
- 1.0f);
-
- ptTop.x += 1.0f;
- ptBottom.x += 1.0f;
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom,
- ArgbEncode(nTransparancy, 240, 240, 240),
- 1.0f);
-
- ptTop.x += 1.0f;
- ptBottom.x += 1.0f;
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom,
- ArgbEncode(nTransparancy, 240, 240, 240),
- 1.0f);
-
- ptTop.x += 1.0f;
- ptBottom.x += 1.0f;
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom,
- ArgbEncode(nTransparancy, 210, 210, 210),
- 1.0f);
-
- ptTop.x += 1.0f;
- ptBottom.x += 1.0f;
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom,
- ArgbEncode(nTransparancy, 180, 180, 180),
- 1.0f);
-
- ptTop.x += 1.0f;
- ptBottom.x += 1.0f;
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom,
- ArgbEncode(nTransparancy, 150, 150, 150),
- 1.0f);
-
- ptTop.x += 1.0f;
- ptBottom.x += 1.0f;
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom,
- ArgbEncode(nTransparancy, 150, 150, 150),
- 1.0f);
-
- ptTop.x += 1.0f;
- ptBottom.x += 1.0f;
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom,
- ArgbEncode(nTransparancy, 180, 180, 180),
- 1.0f);
-
- ptTop.x += 1.0f;
- ptBottom.x += 1.0f;
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptTop, ptBottom,
- ArgbEncode(nTransparancy, 210, 210, 210),
- 1.0f);
- } else {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcDraw,
- ArgbEncode(255, 255, 255, 255));
- }
-
- // draw friction
-
- if (rectWnd.Height() > 8.0f) {
- FX_COLORREF crStroke = ArgbEncode(nTransparancy, 120, 120, 120);
- if (!IsEnabled())
- crStroke = CPWL_Utils::PWLColorToFXColor(
- PWL_DEFAULT_HEAVYGRAYCOLOR, 255);
-
- FX_FLOAT nFrictionWidth = 5.0f;
- FX_FLOAT nFrictionHeight = 5.5f;
-
- CFX_FloatPoint ptLeft =
- CFX_FloatPoint(ptCenter.x - nFrictionWidth / 2.0f,
- ptCenter.y - nFrictionHeight / 2.0f + 0.5f);
- CFX_FloatPoint ptRight =
- CFX_FloatPoint(ptCenter.x + nFrictionWidth / 2.0f,
- ptCenter.y - nFrictionHeight / 2.0f + 0.5f);
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight,
- crStroke, 1.0f);
-
- ptLeft.y += 2.0f;
- ptRight.y += 2.0f;
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight,
- crStroke, 1.0f);
-
- ptLeft.y += 2.0f;
- ptRight.y += 2.0f;
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight,
- crStroke, 1.0f);
- }
- } break;
- default:
- break;
- }
- break;
- default:
- break;
- }
-}
-
-FX_BOOL CPWL_SBButton::OnLButtonDown(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonDown(point, nFlag);
-
- if (CPWL_Wnd* pParent = GetParentWindow())
- pParent->OnNotify(this, PNM_LBUTTONDOWN, 0, (intptr_t)&point);
-
- m_bMouseDown = TRUE;
- SetCapture();
-
- return TRUE;
-}
-
-FX_BOOL CPWL_SBButton::OnLButtonUp(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonUp(point, nFlag);
-
- if (CPWL_Wnd* pParent = GetParentWindow())
- pParent->OnNotify(this, PNM_LBUTTONUP, 0, (intptr_t)&point);
-
- m_bMouseDown = FALSE;
- ReleaseCapture();
-
- return TRUE;
-}
-
-FX_BOOL CPWL_SBButton::OnMouseMove(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CPWL_Wnd::OnMouseMove(point, nFlag);
-
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- pParent->OnNotify(this, PNM_MOUSEMOVE, 0, (intptr_t)&point);
- }
-
- return TRUE;
-}
-
-CPWL_ScrollBar::CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType)
- : m_sbType(sbType),
- m_pMinButton(NULL),
- m_pMaxButton(NULL),
- m_pPosButton(NULL),
- m_bMouseDown(FALSE),
- m_bMinOrMax(FALSE),
- m_bNotifyForever(TRUE) {}
-
-CPWL_ScrollBar::~CPWL_ScrollBar() {}
-
-CFX_ByteString CPWL_ScrollBar::GetClassName() const {
- return "CPWL_ScrollBar";
-}
-
-void CPWL_ScrollBar::OnCreate(PWL_CREATEPARAM& cp) {
- cp.eCursorType = FXCT_ARROW;
-}
-
-void CPWL_ScrollBar::RePosChildWnd() {
- CFX_FloatRect rcClient = GetClientRect();
- CFX_FloatRect rcMinButton, rcMaxButton;
- FX_FLOAT fBWidth = 0;
-
- switch (m_sbType) {
- case SBT_HSCROLL:
- if (rcClient.right - rcClient.left >
- PWL_SCROLLBAR_BUTTON_WIDTH * 2 + PWL_SCROLLBAR_POSBUTTON_MINWIDTH +
- 2) {
- rcMinButton = CFX_FloatRect(rcClient.left, rcClient.bottom,
- rcClient.left + PWL_SCROLLBAR_BUTTON_WIDTH,
- rcClient.top);
- rcMaxButton =
- CFX_FloatRect(rcClient.right - PWL_SCROLLBAR_BUTTON_WIDTH,
- rcClient.bottom, rcClient.right, rcClient.top);
- } else {
- fBWidth = (rcClient.right - rcClient.left -
- PWL_SCROLLBAR_POSBUTTON_MINWIDTH - 2) /
- 2;
-
- if (fBWidth > 0) {
- rcMinButton = CFX_FloatRect(rcClient.left, rcClient.bottom,
- rcClient.left + fBWidth, rcClient.top);
- rcMaxButton = CFX_FloatRect(rcClient.right - fBWidth, rcClient.bottom,
- rcClient.right, rcClient.top);
- } else {
- SetVisible(FALSE);
- }
- }
- break;
- case SBT_VSCROLL:
- if (IsFloatBigger(rcClient.top - rcClient.bottom,
- PWL_SCROLLBAR_BUTTON_WIDTH * 2 +
- PWL_SCROLLBAR_POSBUTTON_MINWIDTH + 2)) {
- rcMinButton = CFX_FloatRect(rcClient.left,
- rcClient.top - PWL_SCROLLBAR_BUTTON_WIDTH,
- rcClient.right, rcClient.top);
- rcMaxButton =
- CFX_FloatRect(rcClient.left, rcClient.bottom, rcClient.right,
- rcClient.bottom + PWL_SCROLLBAR_BUTTON_WIDTH);
- } else {
- fBWidth = (rcClient.top - rcClient.bottom -
- PWL_SCROLLBAR_POSBUTTON_MINWIDTH - 2) /
- 2;
-
- if (IsFloatBigger(fBWidth, 0)) {
- rcMinButton = CFX_FloatRect(rcClient.left, rcClient.top - fBWidth,
- rcClient.right, rcClient.top);
- rcMaxButton =
- CFX_FloatRect(rcClient.left, rcClient.bottom, rcClient.right,
- rcClient.bottom + fBWidth);
- } else {
- SetVisible(FALSE);
- }
- }
- break;
- }
-
- if (m_pMinButton)
- m_pMinButton->Move(rcMinButton, TRUE, FALSE);
- if (m_pMaxButton)
- m_pMaxButton->Move(rcMaxButton, TRUE, FALSE);
- MovePosButton(FALSE);
-}
-
-void CPWL_ScrollBar::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- CFX_FloatRect rectWnd = GetWindowRect();
-
- if (IsVisible() && !rectWnd.IsEmpty()) {
- CFX_ByteTextBuf sButton;
-
- sButton << "q\n";
- sButton << "0 w\n"
- << CPWL_Utils::GetColorAppStream(GetBackgroundColor(), TRUE);
- sButton << rectWnd.left << " " << rectWnd.bottom << " "
- << rectWnd.right - rectWnd.left << " "
- << rectWnd.top - rectWnd.bottom << " re b Q\n";
-
- sAppStream << sButton;
- }
-}
-
-void CPWL_ScrollBar::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CFX_FloatRect rectWnd = GetWindowRect();
-
- if (IsVisible() && !rectWnd.IsEmpty()) {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rectWnd,
- GetBackgroundColor(), GetTransparency());
-
- CPWL_Utils::DrawStrokeLine(
- pDevice, pUser2Device,
- CFX_FloatPoint(rectWnd.left + 2.0f, rectWnd.top - 2.0f),
- CFX_FloatPoint(rectWnd.left + 2.0f, rectWnd.bottom + 2.0f),
- ArgbEncode(GetTransparency(), 100, 100, 100), 1.0f);
-
- CPWL_Utils::DrawStrokeLine(
- pDevice, pUser2Device,
- CFX_FloatPoint(rectWnd.right - 2.0f, rectWnd.top - 2.0f),
- CFX_FloatPoint(rectWnd.right - 2.0f, rectWnd.bottom + 2.0f),
- ArgbEncode(GetTransparency(), 100, 100, 100), 1.0f);
- }
-}
-
-FX_BOOL CPWL_ScrollBar::OnLButtonDown(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonDown(point, nFlag);
-
- if (HasFlag(PWS_AUTOTRANSPARENT)) {
- if (GetTransparency() != 255) {
- SetTransparency(255);
- InvalidateRect();
- }
- }
-
- CFX_FloatRect rcMinArea, rcMaxArea;
-
- if (m_pPosButton && m_pPosButton->IsVisible()) {
- CFX_FloatRect rcClient = GetClientRect();
- CFX_FloatRect rcPosButton = m_pPosButton->GetWindowRect();
-
- switch (m_sbType) {
- case SBT_HSCROLL:
- rcMinArea =
- CFX_FloatRect(rcClient.left + PWL_SCROLLBAR_BUTTON_WIDTH,
- rcClient.bottom, rcPosButton.left, rcClient.top);
- rcMaxArea = CFX_FloatRect(rcPosButton.right, rcClient.bottom,
- rcClient.right - PWL_SCROLLBAR_BUTTON_WIDTH,
- rcClient.top);
-
- break;
- case SBT_VSCROLL:
- rcMinArea =
- CFX_FloatRect(rcClient.left, rcPosButton.top, rcClient.right,
- rcClient.top - PWL_SCROLLBAR_BUTTON_WIDTH);
- rcMaxArea = CFX_FloatRect(rcClient.left,
- rcClient.bottom + PWL_SCROLLBAR_BUTTON_WIDTH,
- rcClient.right, rcPosButton.bottom);
- break;
- }
-
- rcMinArea.Normalize();
- rcMaxArea.Normalize();
-
- if (rcMinArea.Contains(point.x, point.y)) {
- m_sData.SubBig();
- MovePosButton(TRUE);
- NotifyScrollWindow();
- }
-
- if (rcMaxArea.Contains(point.x, point.y)) {
- m_sData.AddBig();
- MovePosButton(TRUE);
- NotifyScrollWindow();
- }
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_ScrollBar::OnLButtonUp(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- CPWL_Wnd::OnLButtonUp(point, nFlag);
-
- if (HasFlag(PWS_AUTOTRANSPARENT)) {
- if (GetTransparency() != PWL_SCROLLBAR_TRANSPARANCY) {
- SetTransparency(PWL_SCROLLBAR_TRANSPARANCY);
- InvalidateRect();
- }
- }
-
- EndTimer();
- m_bMouseDown = FALSE;
-
- return TRUE;
-}
-
-void CPWL_ScrollBar::OnNotify(CPWL_Wnd* pWnd,
- FX_DWORD msg,
- intptr_t wParam,
- intptr_t lParam) {
- CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
-
- switch (msg) {
- case PNM_LBUTTONDOWN:
- if (pWnd == m_pMinButton) {
- OnMinButtonLBDown(*(CFX_FloatPoint*)lParam);
- }
-
- if (pWnd == m_pMaxButton) {
- OnMaxButtonLBDown(*(CFX_FloatPoint*)lParam);
- }
-
- if (pWnd == m_pPosButton) {
- OnPosButtonLBDown(*(CFX_FloatPoint*)lParam);
- }
- break;
- case PNM_LBUTTONUP:
- if (pWnd == m_pMinButton) {
- OnMinButtonLBUp(*(CFX_FloatPoint*)lParam);
- }
-
- if (pWnd == m_pMaxButton) {
- OnMaxButtonLBUp(*(CFX_FloatPoint*)lParam);
- }
-
- if (pWnd == m_pPosButton) {
- OnPosButtonLBUp(*(CFX_FloatPoint*)lParam);
- }
- break;
- case PNM_MOUSEMOVE:
- if (pWnd == m_pMinButton) {
- OnMinButtonMouseMove(*(CFX_FloatPoint*)lParam);
- }
-
- if (pWnd == m_pMaxButton) {
- OnMaxButtonMouseMove(*(CFX_FloatPoint*)lParam);
- }
-
- if (pWnd == m_pPosButton) {
- OnPosButtonMouseMove(*(CFX_FloatPoint*)lParam);
- }
- break;
- case PNM_SETSCROLLINFO: {
- if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) {
- if (FXSYS_memcmp(&m_OriginInfo, pInfo, sizeof(PWL_SCROLL_INFO)) != 0) {
- m_OriginInfo = *pInfo;
- FX_FLOAT fMax =
- pInfo->fContentMax - pInfo->fContentMin - pInfo->fPlateWidth;
- fMax = fMax > 0.0f ? fMax : 0.0f;
- SetScrollRange(0, fMax, pInfo->fPlateWidth);
- SetScrollStep(pInfo->fBigStep, pInfo->fSmallStep);
- }
- }
- } break;
- case PNM_SETSCROLLPOS: {
- FX_FLOAT fPos = *(FX_FLOAT*)lParam;
- switch (m_sbType) {
- case SBT_HSCROLL:
- fPos = fPos - m_OriginInfo.fContentMin;
- break;
- case SBT_VSCROLL:
- fPos = m_OriginInfo.fContentMax - fPos;
- break;
- }
- SetScrollPos(fPos);
- } break;
- }
-}
-
-void CPWL_ScrollBar::CreateButtons(const PWL_CREATEPARAM& cp) {
- PWL_CREATEPARAM scp = cp;
- scp.pParentWnd = this;
- scp.dwBorderWidth = 2;
- scp.nBorderStyle = PBS_BEVELED;
-
- scp.dwFlags =
- PWS_VISIBLE | PWS_CHILD | PWS_BORDER | PWS_BACKGROUND | PWS_NOREFRESHCLIP;
-
- if (!m_pMinButton) {
- m_pMinButton = new CPWL_SBButton(m_sbType, PSBT_MIN);
- m_pMinButton->Create(scp);
- }
-
- if (!m_pMaxButton) {
- m_pMaxButton = new CPWL_SBButton(m_sbType, PSBT_MAX);
- m_pMaxButton->Create(scp);
- }
-
- if (!m_pPosButton) {
- m_pPosButton = new CPWL_SBButton(m_sbType, PSBT_POS);
- m_pPosButton->SetVisible(FALSE);
- m_pPosButton->Create(scp);
- }
-}
-
-FX_FLOAT CPWL_ScrollBar::GetScrollBarWidth() const {
- if (!IsVisible())
- return 0;
-
- return PWL_SCROLLBAR_WIDTH;
-}
-
-void CPWL_ScrollBar::SetScrollRange(FX_FLOAT fMin,
- FX_FLOAT fMax,
- FX_FLOAT fClientWidth) {
- if (m_pPosButton) {
- m_sData.SetScrollRange(fMin, fMax);
- m_sData.SetClientWidth(fClientWidth);
-
- if (IsFloatSmaller(m_sData.ScrollRange.GetWidth(), 0.0f)) {
- m_pPosButton->SetVisible(FALSE);
- } else {
- m_pPosButton->SetVisible(TRUE);
- MovePosButton(TRUE);
- }
- }
-}
-
-void CPWL_ScrollBar::SetScrollPos(FX_FLOAT fPos) {
- FX_FLOAT fOldPos = m_sData.fScrollPos;
-
- m_sData.SetPos(fPos);
-
- if (!IsFloatEqual(m_sData.fScrollPos, fOldPos))
- MovePosButton(TRUE);
-}
-
-void CPWL_ScrollBar::SetScrollStep(FX_FLOAT fBigStep, FX_FLOAT fSmallStep) {
- m_sData.SetBigStep(fBigStep);
- m_sData.SetSmallStep(fSmallStep);
-}
-
-void CPWL_ScrollBar::MovePosButton(FX_BOOL bRefresh) {
- ASSERT(m_pMinButton);
- ASSERT(m_pMaxButton);
-
- if (m_pPosButton->IsVisible()) {
- CFX_FloatRect rcClient;
- CFX_FloatRect rcPosArea, rcPosButton;
-
- rcClient = GetClientRect();
- rcPosArea = GetScrollArea();
-
- FX_FLOAT fLeft, fRight, fTop, fBottom;
-
- switch (m_sbType) {
- case SBT_HSCROLL:
- fLeft = TrueToFace(m_sData.fScrollPos);
- fRight = TrueToFace(m_sData.fScrollPos + m_sData.fClientWidth);
-
- if (fRight - fLeft < PWL_SCROLLBAR_POSBUTTON_MINWIDTH)
- fRight = fLeft + PWL_SCROLLBAR_POSBUTTON_MINWIDTH;
-
- if (fRight > rcPosArea.right) {
- fRight = rcPosArea.right;
- fLeft = fRight - PWL_SCROLLBAR_POSBUTTON_MINWIDTH;
- }
-
- rcPosButton =
- CFX_FloatRect(fLeft, rcPosArea.bottom, fRight, rcPosArea.top);
-
- break;
- case SBT_VSCROLL:
- fBottom = TrueToFace(m_sData.fScrollPos + m_sData.fClientWidth);
- fTop = TrueToFace(m_sData.fScrollPos);
-
- if (IsFloatSmaller(fTop - fBottom, PWL_SCROLLBAR_POSBUTTON_MINWIDTH))
- fBottom = fTop - PWL_SCROLLBAR_POSBUTTON_MINWIDTH;
-
- if (IsFloatSmaller(fBottom, rcPosArea.bottom)) {
- fBottom = rcPosArea.bottom;
- fTop = fBottom + PWL_SCROLLBAR_POSBUTTON_MINWIDTH;
- }
-
- rcPosButton =
- CFX_FloatRect(rcPosArea.left, fBottom, rcPosArea.right, fTop);
-
- break;
- }
-
- m_pPosButton->Move(rcPosButton, TRUE, bRefresh);
- }
-}
-
-void CPWL_ScrollBar::OnMinButtonLBDown(const CFX_FloatPoint& point) {
- m_sData.SubSmall();
- MovePosButton(TRUE);
- NotifyScrollWindow();
-
- m_bMinOrMax = TRUE;
-
- EndTimer();
- BeginTimer(100);
-}
-
-void CPWL_ScrollBar::OnMinButtonLBUp(const CFX_FloatPoint& point) {}
-
-void CPWL_ScrollBar::OnMinButtonMouseMove(const CFX_FloatPoint& point) {}
-
-void CPWL_ScrollBar::OnMaxButtonLBDown(const CFX_FloatPoint& point) {
- m_sData.AddSmall();
- MovePosButton(TRUE);
- NotifyScrollWindow();
-
- m_bMinOrMax = FALSE;
-
- EndTimer();
- BeginTimer(100);
-}
-
-void CPWL_ScrollBar::OnMaxButtonLBUp(const CFX_FloatPoint& point) {}
-
-void CPWL_ScrollBar::OnMaxButtonMouseMove(const CFX_FloatPoint& point) {}
-
-void CPWL_ScrollBar::OnPosButtonLBDown(const CFX_FloatPoint& point) {
- m_bMouseDown = TRUE;
-
- if (m_pPosButton) {
- CFX_FloatRect rcPosButton = m_pPosButton->GetWindowRect();
-
- switch (m_sbType) {
- case SBT_HSCROLL:
- m_nOldPos = point.x;
- m_fOldPosButton = rcPosButton.left;
- break;
- case SBT_VSCROLL:
- m_nOldPos = point.y;
- m_fOldPosButton = rcPosButton.top;
- break;
- }
- }
-}
-
-void CPWL_ScrollBar::OnPosButtonLBUp(const CFX_FloatPoint& point) {
- if (m_bMouseDown) {
- if (!m_bNotifyForever)
- NotifyScrollWindow();
- }
- m_bMouseDown = FALSE;
-}
-
-void CPWL_ScrollBar::OnPosButtonMouseMove(const CFX_FloatPoint& point) {
- FX_FLOAT fOldScrollPos = m_sData.fScrollPos;
-
- FX_FLOAT fNewPos = 0;
-
- switch (m_sbType) {
- case SBT_HSCROLL:
- if (FXSYS_fabs(point.x - m_nOldPos) < 1)
- return;
- fNewPos = FaceToTrue(m_fOldPosButton + point.x - m_nOldPos);
- break;
- case SBT_VSCROLL:
- if (FXSYS_fabs(point.y - m_nOldPos) < 1)
- return;
- fNewPos = FaceToTrue(m_fOldPosButton + point.y - m_nOldPos);
- break;
- }
-
- if (m_bMouseDown) {
- switch (m_sbType) {
- case SBT_HSCROLL:
-
- if (IsFloatSmaller(fNewPos, m_sData.ScrollRange.fMin)) {
- fNewPos = m_sData.ScrollRange.fMin;
- }
-
- if (IsFloatBigger(fNewPos, m_sData.ScrollRange.fMax)) {
- fNewPos = m_sData.ScrollRange.fMax;
- }
-
- m_sData.SetPos(fNewPos);
-
- break;
- case SBT_VSCROLL:
-
- if (IsFloatSmaller(fNewPos, m_sData.ScrollRange.fMin)) {
- fNewPos = m_sData.ScrollRange.fMin;
- }
-
- if (IsFloatBigger(fNewPos, m_sData.ScrollRange.fMax)) {
- fNewPos = m_sData.ScrollRange.fMax;
- }
-
- m_sData.SetPos(fNewPos);
-
- break;
- }
-
- if (!IsFloatEqual(fOldScrollPos, m_sData.fScrollPos)) {
- MovePosButton(TRUE);
-
- if (m_bNotifyForever)
- NotifyScrollWindow();
- }
- }
-}
-
-void CPWL_ScrollBar::NotifyScrollWindow() {
- if (CPWL_Wnd* pParent = GetParentWindow()) {
- FX_FLOAT fPos;
- switch (m_sbType) {
- case SBT_HSCROLL:
- fPos = m_OriginInfo.fContentMin + m_sData.fScrollPos;
- break;
- case SBT_VSCROLL:
- fPos = m_OriginInfo.fContentMax - m_sData.fScrollPos;
- break;
- }
- pParent->OnNotify(this, PNM_SCROLLWINDOW, (intptr_t)m_sbType,
- (intptr_t)&fPos);
- }
-}
-
-CFX_FloatRect CPWL_ScrollBar::GetScrollArea() const {
- CFX_FloatRect rcClient = GetClientRect();
- CFX_FloatRect rcArea;
-
- if (!m_pMinButton || !m_pMaxButton)
- return rcClient;
-
- CFX_FloatRect rcMin = m_pMinButton->GetWindowRect();
- CFX_FloatRect rcMax = m_pMaxButton->GetWindowRect();
-
- FX_FLOAT fMinWidth = rcMin.right - rcMin.left;
- FX_FLOAT fMinHeight = rcMin.top - rcMin.bottom;
- FX_FLOAT fMaxWidth = rcMax.right - rcMax.left;
- FX_FLOAT fMaxHeight = rcMax.top - rcMax.bottom;
-
- switch (m_sbType) {
- case SBT_HSCROLL:
- if (rcClient.right - rcClient.left > fMinWidth + fMaxWidth + 2) {
- rcArea = CFX_FloatRect(rcClient.left + fMinWidth + 1, rcClient.bottom,
- rcClient.right - fMaxWidth - 1, rcClient.top);
- } else {
- rcArea = CFX_FloatRect(rcClient.left + fMinWidth + 1, rcClient.bottom,
- rcClient.left + fMinWidth + 1, rcClient.top);
- }
- break;
- case SBT_VSCROLL:
- if (rcClient.top - rcClient.bottom > fMinHeight + fMaxHeight + 2) {
- rcArea = CFX_FloatRect(rcClient.left, rcClient.bottom + fMinHeight + 1,
- rcClient.right, rcClient.top - fMaxHeight - 1);
- } else {
- rcArea =
- CFX_FloatRect(rcClient.left, rcClient.bottom + fMinHeight + 1,
- rcClient.right, rcClient.bottom + fMinHeight + 1);
- }
- break;
- }
-
- rcArea.Normalize();
-
- return rcArea;
-}
-
-FX_FLOAT CPWL_ScrollBar::TrueToFace(FX_FLOAT fTrue) {
- CFX_FloatRect rcPosArea;
- rcPosArea = GetScrollArea();
-
- FX_FLOAT fFactWidth = m_sData.ScrollRange.GetWidth() + m_sData.fClientWidth;
- fFactWidth = fFactWidth == 0 ? 1 : fFactWidth;
-
- FX_FLOAT fFace = 0;
-
- switch (m_sbType) {
- case SBT_HSCROLL:
- fFace = rcPosArea.left +
- fTrue * (rcPosArea.right - rcPosArea.left) / fFactWidth;
- break;
- case SBT_VSCROLL:
- fFace = rcPosArea.top -
- fTrue * (rcPosArea.top - rcPosArea.bottom) / fFactWidth;
- break;
- }
-
- return fFace;
-}
-
-FX_FLOAT CPWL_ScrollBar::FaceToTrue(FX_FLOAT fFace) {
- CFX_FloatRect rcPosArea;
- rcPosArea = GetScrollArea();
-
- FX_FLOAT fFactWidth = m_sData.ScrollRange.GetWidth() + m_sData.fClientWidth;
- fFactWidth = fFactWidth == 0 ? 1 : fFactWidth;
-
- FX_FLOAT fTrue = 0;
-
- switch (m_sbType) {
- case SBT_HSCROLL:
- fTrue = (fFace - rcPosArea.left) * fFactWidth /
- (rcPosArea.right - rcPosArea.left);
- break;
- case SBT_VSCROLL:
- fTrue = (rcPosArea.top - fFace) * fFactWidth /
- (rcPosArea.top - rcPosArea.bottom);
- break;
- }
-
- return fTrue;
-}
-
-void CPWL_ScrollBar::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- CreateButtons(cp);
-}
-
-void CPWL_ScrollBar::TimerProc() {
- PWL_SCROLL_PRIVATEDATA sTemp = m_sData;
-
- if (m_bMinOrMax)
- m_sData.SubSmall();
- else
- m_sData.AddSmall();
-
- if (FXSYS_memcmp(&m_sData, &sTemp, sizeof(PWL_SCROLL_PRIVATEDATA)) != 0) {
- MovePosButton(TRUE);
- NotifyScrollWindow();
- }
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_Signature.cpp b/fpdfsdk/src/pdfwindow/PWL_Signature.cpp
deleted file mode 100644
index ffb4461878..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_Signature.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_Signature.h"
-
-#include "fpdfsdk/include/pdfwindow/PWL_Icon.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Label.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-
-CPWL_Signature_Image::CPWL_Signature_Image() : m_pImage(NULL) {}
-
-CPWL_Signature_Image::~CPWL_Signature_Image() {}
-
-void CPWL_Signature_Image::SetImage(CFX_DIBSource* pImage) {
- m_pImage = pImage;
-}
-
-CFX_DIBSource* CPWL_Signature_Image::GetImage() {
- return m_pImage;
-}
-
-void CPWL_Signature_Image::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
-
- if (m_pImage) {
- CFX_FloatRect rcClient = GetClientRect();
-
- FX_FLOAT x, y;
- pUser2Device->Transform(rcClient.left, rcClient.top, x, y);
-
- pDevice->StretchDIBits(m_pImage, (int32_t)x, (int32_t)y,
- (int32_t)rcClient.Width(),
- (int32_t)rcClient.Height());
- }
-}
-
-void CPWL_Signature_Image::GetThisAppearanceStream(
- CFX_ByteTextBuf& sAppStream) {
- sAppStream << CPWL_Image::GetImageAppStream();
-}
-
-void CPWL_Signature_Image::GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale) {
- FX_FLOAT fImageW, fImageH;
-
- GetImageSize(fImageW, fImageH);
-
- CFX_FloatRect rcClient = GetClientRect();
-
- fHScale = rcClient.Width() / fImageW;
- fVScale = rcClient.Height() / fImageH;
-}
-
-CPWL_Signature::CPWL_Signature()
- : m_pText(NULL),
- m_pDescription(NULL),
- m_pImage(NULL),
- m_bTextExist(TRUE),
- m_bImageExist(FALSE),
- m_bFlagExist(TRUE) {}
-
-CPWL_Signature::~CPWL_Signature() {}
-
-void CPWL_Signature::SetTextFlag(FX_BOOL bTextExist) {
- m_bTextExist = bTextExist;
-
- RePosChildWnd();
-}
-
-void CPWL_Signature::SetImageFlag(FX_BOOL bImageExist) {
- m_bImageExist = bImageExist;
-
- RePosChildWnd();
-}
-
-void CPWL_Signature::SetFoxitFlag(FX_BOOL bFlagExist) {
- m_bFlagExist = bFlagExist;
-}
-
-void CPWL_Signature::SetText(const FX_WCHAR* sText) {
- m_pText->SetText(sText);
-
- RePosChildWnd();
-}
-
-void CPWL_Signature::SetDescription(const FX_WCHAR* str) {
- m_pDescription->SetText(str);
-
- RePosChildWnd();
-}
-
-void CPWL_Signature::SetImage(CFX_DIBSource* pImage) {
- m_pImage->SetImage(pImage);
-
- RePosChildWnd();
-}
-
-void CPWL_Signature::SetImageStream(CPDF_Stream* pStream,
- const FX_CHAR* sImageAlias) {
- m_pImage->SetPDFStream(pStream);
- m_pImage->SetImageAlias(sImageAlias);
-
- RePosChildWnd();
-}
-
-void CPWL_Signature::RePosChildWnd() {
- CFX_FloatRect rcClient = GetClientRect();
-
- CFX_FloatRect rcText = rcClient;
- CFX_FloatRect rcDescription = rcClient;
-
- FX_BOOL bTextVisible = m_bTextExist && m_pText->GetText().GetLength() > 0;
-
- if ((bTextVisible || m_bImageExist) &&
- m_pDescription->GetText().GetLength() > 0) {
- if (rcClient.Width() >= rcClient.Height()) {
- rcText.right = rcText.left + rcClient.Width() / 2.0f;
- rcDescription.left = rcDescription.right - rcClient.Width() / 2.0f;
- } else {
- rcText.bottom = rcText.top - rcClient.Height() / 2.0f;
- rcDescription.top = rcDescription.bottom + rcClient.Height() / 2.0f;
- }
- }
-
- m_pText->SetVisible(bTextVisible);
- m_pImage->SetVisible(m_bImageExist);
-
- m_pText->Move(rcText, TRUE, FALSE);
- m_pImage->Move(rcText, TRUE, FALSE);
- m_pDescription->Move(rcDescription, TRUE, FALSE);
-}
-
-void CPWL_Signature::CreateChildWnd(const PWL_CREATEPARAM& cp) {
- m_pImage = new CPWL_Signature_Image;
- PWL_CREATEPARAM icp = cp;
- icp.pParentWnd = this;
- icp.dwFlags = PWS_CHILD | PWS_VISIBLE;
- icp.sTextColor = CPWL_Color(COLORTYPE_GRAY, 0);
- m_pImage->Create(icp);
-
- m_pText = new CPWL_Label;
- PWL_CREATEPARAM acp = cp;
- acp.pParentWnd = this;
- acp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_AUTOFONTSIZE | PES_MULTILINE |
- PES_AUTORETURN | PES_MIDDLE | PES_CENTER;
- acp.sTextColor = CPWL_Color(COLORTYPE_GRAY, 0);
- m_pText->Create(acp);
-
- m_pDescription = new CPWL_Label;
- PWL_CREATEPARAM dcp = cp;
- dcp.pParentWnd = this;
- dcp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_AUTOFONTSIZE | PES_MULTILINE |
- PES_AUTORETURN | PES_LEFT | PES_CENTER;
- dcp.sTextColor = CPWL_Color(COLORTYPE_GRAY, 0);
- m_pDescription->Create(dcp);
-}
-
-void CPWL_Signature::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
-
- if (m_bFlagExist) {
- CPWL_Utils::DrawIconAppStream(
- pDevice, pUser2Device, PWL_ICONTYPE_FOXIT,
- CPWL_Utils::GetCenterSquare(GetClientRect()),
- CPWL_Color(COLORTYPE_RGB, 0.91f, 0.855f, 0.92f),
- CPWL_Color(COLORTYPE_TRANSPARENT), 255);
- }
-}
-
-void CPWL_Signature::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp b/fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp
deleted file mode 100644
index c19a233940..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_Button.h"
-#include "fpdfsdk/include/pdfwindow/PWL_SpecialButton.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-
-CPWL_PushButton::CPWL_PushButton() {}
-
-CPWL_PushButton::~CPWL_PushButton() {}
-
-CFX_ByteString CPWL_PushButton::GetClassName() const {
- return "CPWL_PushButton";
-}
-
-CFX_FloatRect CPWL_PushButton::GetFocusRect() const {
- return CPWL_Utils::DeflateRect(GetWindowRect(), (FX_FLOAT)GetBorderWidth());
-}
-
-CPWL_CheckBox::CPWL_CheckBox() : m_bChecked(false) {}
-
-CPWL_CheckBox::~CPWL_CheckBox() {}
-
-CFX_ByteString CPWL_CheckBox::GetClassName() const {
- return "CPWL_CheckBox";
-}
-
-void CPWL_CheckBox::SetCheck(bool bCheck) {
- m_bChecked = bCheck;
-}
-
-bool CPWL_CheckBox::IsChecked() const {
- return m_bChecked;
-}
-
-FX_BOOL CPWL_CheckBox::OnLButtonUp(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- if (IsReadOnly())
- return FALSE;
-
- SetCheck(!IsChecked());
- return TRUE;
-}
-
-FX_BOOL CPWL_CheckBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
- SetCheck(!IsChecked());
- return TRUE;
-}
-
-CPWL_RadioButton::CPWL_RadioButton() : m_bChecked(false) {}
-
-CPWL_RadioButton::~CPWL_RadioButton() {}
-
-CFX_ByteString CPWL_RadioButton::GetClassName() const {
- return "CPWL_RadioButton";
-}
-
-FX_BOOL CPWL_RadioButton::OnLButtonUp(const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- if (IsReadOnly())
- return FALSE;
-
- SetCheck(TRUE);
- return TRUE;
-}
-
-void CPWL_RadioButton::SetCheck(bool bCheck) {
- m_bChecked = bCheck;
-}
-
-bool CPWL_RadioButton::IsChecked() const {
- return m_bChecked;
-}
-
-FX_BOOL CPWL_RadioButton::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
- SetCheck(TRUE);
- return TRUE;
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_Utils.cpp b/fpdfsdk/src/pdfwindow/PWL_Utils.cpp
deleted file mode 100644
index 926ab3f0b7..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_Utils.cpp
+++ /dev/null
@@ -1,3681 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-
-#include <algorithm>
-
-#include "fpdfsdk/include/pdfwindow/PWL_Icon.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-
-#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
-#define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
-#define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
-
-CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData,
- int32_t nCount) {
- CFX_ByteTextBuf csAP;
-
- for (int32_t i = 0; i < nCount; i++) {
- switch (pPathData[i].type) {
- case PWLPT_MOVETO:
- csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " m\n";
- break;
- case PWLPT_LINETO:
- csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " l\n";
- break;
- case PWLPT_BEZIERTO:
- csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " "
- << pPathData[i + 1].point.x << " " << pPathData[i + 1].point.y
- << " " << pPathData[i + 2].point.x << " "
- << pPathData[i + 2].point.y << " c\n";
-
- i += 2;
- break;
- default:
- break;
- }
- }
-
- return csAP.GetByteString();
-}
-
-void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path,
- const CPWL_PathData* pPathData,
- int32_t nCount) {
- path.SetPointCount(nCount);
-
- for (int32_t i = 0; i < nCount; i++) {
- switch (pPathData[i].type) {
- case PWLPT_MOVETO:
- path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y,
- FXPT_MOVETO);
- break;
- case PWLPT_LINETO:
- path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y,
- FXPT_LINETO);
- break;
- case PWLPT_BEZIERTO:
- path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y,
- FXPT_BEZIERTO);
- break;
- default:
- break;
- }
- }
-}
-
-CFX_FloatRect CPWL_Utils::MaxRect(const CFX_FloatRect& rect1,
- const CFX_FloatRect& rect2) {
- CFX_FloatRect rcRet;
-
- rcRet.left = PWL_MIN(rect1.left, rect2.left);
- rcRet.bottom = PWL_MIN(rect1.bottom, rect2.bottom);
- rcRet.right = PWL_MAX(rect1.right, rect2.right);
- rcRet.top = PWL_MAX(rect1.top, rect2.top);
-
- return rcRet;
-}
-
-CFX_FloatRect CPWL_Utils::OffsetRect(const CFX_FloatRect& rect,
- FX_FLOAT x,
- FX_FLOAT y) {
- return CFX_FloatRect(rect.left + x, rect.bottom + y, rect.right + x,
- rect.top + y);
-}
-
-FX_BOOL CPWL_Utils::ContainsRect(const CFX_FloatRect& rcParent,
- const CFX_FloatRect& rcChild) {
- return rcChild.left >= rcParent.left && rcChild.bottom >= rcParent.bottom &&
- rcChild.right <= rcParent.right && rcChild.top <= rcParent.top;
-}
-
-FX_BOOL CPWL_Utils::IntersectRect(const CFX_FloatRect& rect1,
- const CFX_FloatRect& rect2) {
- FX_FLOAT left = rect1.left > rect2.left ? rect1.left : rect2.left;
- FX_FLOAT right = rect1.right < rect2.right ? rect1.right : rect2.right;
- FX_FLOAT bottom = rect1.bottom > rect2.bottom ? rect1.bottom : rect2.bottom;
- FX_FLOAT top = rect1.top < rect2.top ? rect1.top : rect2.top;
-
- return left < right && bottom < top;
-}
-
-CFX_FloatPoint CPWL_Utils::OffsetPoint(const CFX_FloatPoint& point,
- FX_FLOAT x,
- FX_FLOAT y) {
- return CFX_FloatPoint(point.x + x, point.y + y);
-}
-
-CPVT_WordRange CPWL_Utils::OverlapWordRange(const CPVT_WordRange& wr1,
- const CPVT_WordRange& wr2) {
- CPVT_WordRange wrRet;
-
- if (wr2.EndPos.WordCmp(wr1.BeginPos) < 0 ||
- wr2.BeginPos.WordCmp(wr1.EndPos) > 0)
- return wrRet;
- if (wr1.EndPos.WordCmp(wr2.BeginPos) < 0 ||
- wr1.BeginPos.WordCmp(wr2.EndPos) > 0)
- return wrRet;
-
- if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) {
- wrRet.BeginPos = wr2.BeginPos;
- } else {
- wrRet.BeginPos = wr1.BeginPos;
- }
-
- if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) {
- wrRet.EndPos = wr1.EndPos;
- } else {
- wrRet.EndPos = wr2.EndPos;
- }
-
- return wrRet;
-}
-
-CFX_ByteString CPWL_Utils::GetAP_Check(const CFX_FloatRect& crBBox) {
- const FX_FLOAT fWidth = crBBox.right - crBBox.left;
- const FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_Point pts[8][3] = {{CPWL_Point(0.28f, 0.52f), CPWL_Point(0.27f, 0.48f),
- CPWL_Point(0.29f, 0.40f)},
- {CPWL_Point(0.30f, 0.33f), CPWL_Point(0.31f, 0.29f),
- CPWL_Point(0.31f, 0.28f)},
- {CPWL_Point(0.39f, 0.28f), CPWL_Point(0.49f, 0.29f),
- CPWL_Point(0.77f, 0.67f)},
- {CPWL_Point(0.76f, 0.68f), CPWL_Point(0.78f, 0.69f),
- CPWL_Point(0.76f, 0.75f)},
- {CPWL_Point(0.76f, 0.75f), CPWL_Point(0.73f, 0.80f),
- CPWL_Point(0.68f, 0.75f)},
- {CPWL_Point(0.68f, 0.74f), CPWL_Point(0.68f, 0.74f),
- CPWL_Point(0.44f, 0.47f)},
- {CPWL_Point(0.43f, 0.47f), CPWL_Point(0.40f, 0.47f),
- CPWL_Point(0.41f, 0.58f)},
- {CPWL_Point(0.40f, 0.60f), CPWL_Point(0.28f, 0.66f),
- CPWL_Point(0.30f, 0.56f)}};
-
- for (size_t i = 0; i < FX_ArraySize(pts); ++i) {
- for (size_t j = 0; j < FX_ArraySize(pts[0]); ++j) {
- pts[i][j].x = pts[i][j].x * fWidth + crBBox.left;
- pts[i][j].y *= pts[i][j].y * fHeight + crBBox.bottom;
- }
- }
-
- CFX_ByteTextBuf csAP;
- csAP << pts[0][0].x << " " << pts[0][0].y << " m\n";
-
- for (size_t i = 0; i < FX_ArraySize(pts); ++i) {
- size_t nNext = i < FX_ArraySize(pts) - 1 ? i + 1 : 0;
-
- FX_FLOAT px1 = pts[i][1].x - pts[i][0].x;
- FX_FLOAT py1 = pts[i][1].y - pts[i][0].y;
- FX_FLOAT px2 = pts[i][2].x - pts[nNext][0].x;
- FX_FLOAT py2 = pts[i][2].y - pts[nNext][0].y;
-
- csAP << pts[i][0].x + px1 * FX_BEZIER << " "
- << pts[i][0].y + py1 * FX_BEZIER << " "
- << pts[nNext][0].x + px2 * FX_BEZIER << " "
- << pts[nNext][0].y + py2 * FX_BEZIER << " " << pts[nNext][0].x << " "
- << pts[nNext][0].y << " c\n";
- }
-
- return csAP.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetAP_Circle(const CFX_FloatRect& crBBox) {
- CFX_ByteTextBuf csAP;
-
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CFX_FloatPoint pt1(crBBox.left, crBBox.bottom + fHeight / 2);
- CFX_FloatPoint pt2(crBBox.left + fWidth / 2, crBBox.top);
- CFX_FloatPoint pt3(crBBox.right, crBBox.bottom + fHeight / 2);
- CFX_FloatPoint pt4(crBBox.left + fWidth / 2, crBBox.bottom);
-
- csAP << pt1.x << " " << pt1.y << " m\n";
-
- FX_FLOAT px = pt2.x - pt1.x;
- FX_FLOAT py = pt2.y - pt1.y;
-
- csAP << pt1.x << " " << pt1.y + py * FX_BEZIER << " "
- << pt2.x - px * FX_BEZIER << " " << pt2.y << " " << pt2.x << " " << pt2.y
- << " c\n";
-
- px = pt3.x - pt2.x;
- py = pt2.y - pt3.y;
-
- csAP << pt2.x + px * FX_BEZIER << " " << pt2.y << " " << pt3.x << " "
- << pt3.y + py * FX_BEZIER << " " << pt3.x << " " << pt3.y << " c\n";
-
- px = pt3.x - pt4.x;
- py = pt3.y - pt4.y;
-
- csAP << pt3.x << " " << pt3.y - py * FX_BEZIER << " "
- << pt4.x + px * FX_BEZIER << " " << pt4.y << " " << pt4.x << " " << pt4.y
- << " c\n";
-
- px = pt4.x - pt1.x;
- py = pt1.y - pt4.y;
-
- csAP << pt4.x - px * FX_BEZIER << " " << pt4.y << " " << pt1.x << " "
- << pt1.y - py * FX_BEZIER << " " << pt1.x << " " << pt1.y << " c\n";
-
- return csAP.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetAP_Cross(const CFX_FloatRect& crBBox) {
- CFX_ByteTextBuf csAP;
-
- csAP << crBBox.left << " " << crBBox.top << " m\n";
- csAP << crBBox.right << " " << crBBox.bottom << " l\n";
- csAP << crBBox.left << " " << crBBox.bottom << " m\n";
- csAP << crBBox.right << " " << crBBox.top << " l\n";
-
- return csAP.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetAP_Diamond(const CFX_FloatRect& crBBox) {
- CFX_ByteTextBuf csAP;
-
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CFX_FloatPoint pt1(crBBox.left, crBBox.bottom + fHeight / 2);
- CFX_FloatPoint pt2(crBBox.left + fWidth / 2, crBBox.top);
- CFX_FloatPoint pt3(crBBox.right, crBBox.bottom + fHeight / 2);
- CFX_FloatPoint pt4(crBBox.left + fWidth / 2, crBBox.bottom);
-
- csAP << pt1.x << " " << pt1.y << " m\n";
- csAP << pt2.x << " " << pt2.y << " l\n";
- csAP << pt3.x << " " << pt3.y << " l\n";
- csAP << pt4.x << " " << pt4.y << " l\n";
- csAP << pt1.x << " " << pt1.y << " l\n";
-
- return csAP.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetAP_Square(const CFX_FloatRect& crBBox) {
- CFX_ByteTextBuf csAP;
-
- csAP << crBBox.left << " " << crBBox.top << " m\n";
- csAP << crBBox.right << " " << crBBox.top << " l\n";
- csAP << crBBox.right << " " << crBBox.bottom << " l\n";
- csAP << crBBox.left << " " << crBBox.bottom << " l\n";
- csAP << crBBox.left << " " << crBBox.top << " l\n";
-
- return csAP.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetAP_Star(const CFX_FloatRect& crBBox) {
- CFX_ByteTextBuf csAP;
-
- FX_FLOAT fRadius =
- (crBBox.top - crBBox.bottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f));
- CFX_FloatPoint ptCenter = CFX_FloatPoint((crBBox.left + crBBox.right) / 2.0f,
- (crBBox.top + crBBox.bottom) / 2.0f);
-
- FX_FLOAT px[5], py[5];
-
- FX_FLOAT fAngel = FX_PI / 10.0f;
-
- for (int32_t i = 0; i < 5; i++) {
- px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel);
- py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel);
-
- fAngel += FX_PI * 2 / 5.0f;
- }
-
- csAP << px[0] << " " << py[0] << " m\n";
-
- int32_t nNext = 0;
- for (int32_t j = 0; j < 5; j++) {
- nNext += 2;
- if (nNext >= 5)
- nNext -= 5;
- csAP << px[nNext] << " " << py[nNext] << " l\n";
- }
-
- return csAP.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CFX_FloatRect& crBBox,
- FX_FLOAT fRotate) {
- CFX_ByteTextBuf csAP;
-
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CFX_FloatPoint pt1(-fWidth / 2, 0);
- CFX_FloatPoint pt2(0, fHeight / 2);
- CFX_FloatPoint pt3(fWidth / 2, 0);
-
- FX_FLOAT px, py;
-
- csAP << cos(fRotate) << " " << sin(fRotate) << " " << -sin(fRotate) << " "
- << cos(fRotate) << " " << crBBox.left + fWidth / 2 << " "
- << crBBox.bottom + fHeight / 2 << " cm\n";
-
- csAP << pt1.x << " " << pt1.y << " m\n";
-
- px = pt2.x - pt1.x;
- py = pt2.y - pt1.y;
-
- csAP << pt1.x << " " << pt1.y + py * FX_BEZIER << " "
- << pt2.x - px * FX_BEZIER << " " << pt2.y << " " << pt2.x << " " << pt2.y
- << " c\n";
-
- px = pt3.x - pt2.x;
- py = pt2.y - pt3.y;
-
- csAP << pt2.x + px * FX_BEZIER << " " << pt2.y << " " << pt3.x << " "
- << pt3.y + py * FX_BEZIER << " " << pt3.x << " " << pt3.y << " c\n";
-
- return csAP.GetByteString();
-}
-
-CFX_FloatRect CPWL_Utils::InflateRect(const CFX_FloatRect& rcRect,
- FX_FLOAT fSize) {
- if (rcRect.IsEmpty())
- return rcRect;
-
- CFX_FloatRect rcNew(rcRect.left - fSize, rcRect.bottom - fSize,
- rcRect.right + fSize, rcRect.top + fSize);
- rcNew.Normalize();
- return rcNew;
-}
-
-CFX_FloatRect CPWL_Utils::DeflateRect(const CFX_FloatRect& rcRect,
- FX_FLOAT fSize) {
- if (rcRect.IsEmpty())
- return rcRect;
-
- CFX_FloatRect rcNew(rcRect.left + fSize, rcRect.bottom + fSize,
- rcRect.right - fSize, rcRect.top - fSize);
- rcNew.Normalize();
- return rcNew;
-}
-
-CFX_FloatRect CPWL_Utils::ScaleRect(const CFX_FloatRect& rcRect,
- FX_FLOAT fScale) {
- FX_FLOAT fHalfWidth = (rcRect.right - rcRect.left) / 2.0f;
- FX_FLOAT fHalfHeight = (rcRect.top - rcRect.bottom) / 2.0f;
-
- CFX_FloatPoint ptCenter = CFX_FloatPoint((rcRect.left + rcRect.right) / 2,
- (rcRect.top + rcRect.bottom) / 2);
-
- return CFX_FloatRect(
- ptCenter.x - fHalfWidth * fScale, ptCenter.y - fHalfHeight * fScale,
- ptCenter.x + fHalfWidth * fScale, ptCenter.y + fHalfHeight * fScale);
-}
-
-CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CFX_FloatRect& rect,
- const CPWL_Color& color) {
- CFX_ByteTextBuf sAppStream;
-
- CFX_ByteString sColor = GetColorAppStream(color, TRUE);
- if (sColor.GetLength() > 0) {
- sAppStream << "q\n" << sColor;
- sAppStream << rect.left << " " << rect.bottom << " "
- << rect.right - rect.left << " " << rect.top - rect.bottom
- << " re f\nQ\n";
- }
-
- return sAppStream.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetCircleFillAppStream(const CFX_FloatRect& rect,
- const CPWL_Color& color) {
- CFX_ByteTextBuf sAppStream;
-
- CFX_ByteString sColor = GetColorAppStream(color, TRUE);
- if (sColor.GetLength() > 0) {
- sAppStream << "q\n" << sColor << CPWL_Utils::GetAP_Circle(rect) << "f\nQ\n";
- }
-
- return sAppStream.GetByteString();
-}
-
-CFX_FloatRect CPWL_Utils::GetCenterSquare(const CFX_FloatRect& rect) {
- FX_FLOAT fWidth = rect.right - rect.left;
- FX_FLOAT fHeight = rect.top - rect.bottom;
-
- FX_FLOAT fCenterX = (rect.left + rect.right) / 2.0f;
- FX_FLOAT fCenterY = (rect.top + rect.bottom) / 2.0f;
-
- FX_FLOAT fRadius = (fWidth > fHeight) ? fHeight / 2 : fWidth / 2;
-
- return CFX_FloatRect(fCenterX - fRadius, fCenterY - fRadius,
- fCenterX + fRadius, fCenterY + fRadius);
-}
-
-CFX_ByteString CPWL_Utils::GetEditAppStream(IFX_Edit* pEdit,
- const CFX_FloatPoint& ptOffset,
- const CPVT_WordRange* pRange,
- FX_BOOL bContinuous,
- FX_WORD SubWord) {
- return IFX_Edit::GetEditAppearanceStream(pEdit, ptOffset, pRange, bContinuous,
- SubWord);
-}
-
-CFX_ByteString CPWL_Utils::GetEditSelAppStream(IFX_Edit* pEdit,
- const CFX_FloatPoint& ptOffset,
- const CPVT_WordRange* pRange) {
- return IFX_Edit::GetSelectAppearanceStream(pEdit, ptOffset, pRange);
-}
-
-static CFX_ByteString GetSquigglyAppearanceStream(FX_FLOAT fStartX,
- FX_FLOAT fEndX,
- FX_FLOAT fY,
- FX_FLOAT fStep) {
- CFX_ByteTextBuf sRet;
-
- sRet << "0 w\n" << fStartX << " " << fY << " m\n";
-
- FX_FLOAT fx;
- int32_t i;
-
- for (i = 1, fx = fStartX + fStep; fx < fEndX; fx += fStep, i++) {
- sRet << fx << " " << fY + (i & 1) * fStep << " l\n";
- }
-
- sRet << "S\n";
-
- return sRet.GetByteString();
-}
-
-static CFX_ByteString GetWordSpellCheckAppearanceStream(
- IFX_Edit_Iterator* pIterator,
- const CFX_FloatPoint& ptOffset,
- const CPVT_WordRange& wrWord) {
- CFX_ByteTextBuf sRet;
-
- FX_FLOAT fStartX = 0.0f;
- FX_FLOAT fEndX = 0.0f;
- FX_FLOAT fY = 0.0f;
- FX_FLOAT fStep = 0.0f;
-
- FX_BOOL bBreak = FALSE;
-
- if (pIterator) {
- pIterator->SetAt(wrWord.BeginPos);
-
- do {
- CPVT_WordPlace place = pIterator->GetAt();
-
- CPVT_Line line;
- if (pIterator->GetLine(line)) {
- fY = line.ptLine.y;
- fStep = (line.fLineAscent - line.fLineDescent) / 16.0f;
- }
-
- if (place.LineCmp(wrWord.BeginPos) == 0) {
- pIterator->SetAt(wrWord.BeginPos);
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- fStartX = word.ptWord.x;
- }
- } else {
- fStartX = line.ptLine.x;
- }
-
- if (place.LineCmp(wrWord.EndPos) == 0) {
- pIterator->SetAt(wrWord.EndPos);
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- fEndX = word.ptWord.x + word.fWidth;
- }
-
- bBreak = TRUE;
- } else {
- fEndX = line.ptLine.x + line.fLineWidth;
- }
-
- sRet << GetSquigglyAppearanceStream(
- fStartX + ptOffset.x, fEndX + ptOffset.x, fY + ptOffset.y, fStep);
-
- if (bBreak)
- break;
- } while (pIterator->NextLine());
- }
-
- return sRet.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetSpellCheckAppStream(
- IFX_Edit* pEdit,
- IPWL_SpellCheck* pSpellCheck,
- const CFX_FloatPoint& ptOffset,
- const CPVT_WordRange* pRange) {
- CFX_ByteTextBuf sRet;
-
- if (pRange && pRange->IsExist()) {
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- pIterator->SetAt(pRange->BeginPos);
-
- FX_BOOL bLatinWord = FALSE;
- CPVT_WordPlace wpWordStart;
- CFX_ByteString sWord;
-
- CPVT_WordPlace oldplace;
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- if (FX_EDIT_ISLATINWORD(word.Word)) {
- if (!bLatinWord) {
- wpWordStart = place;
- bLatinWord = TRUE;
- }
-
- sWord += (char)word.Word;
- oldplace = place;
- } else {
- if (bLatinWord) {
- if (!pSpellCheck->CheckWord(sWord)) {
- sRet << GetWordSpellCheckAppearanceStream(
- pIterator, ptOffset, CPVT_WordRange(wpWordStart, oldplace));
- pIterator->SetAt(place);
- }
- bLatinWord = FALSE;
- }
-
- sWord.Empty();
- }
- } else {
- if (bLatinWord) {
- if (!pSpellCheck->CheckWord(sWord))
- sRet << GetWordSpellCheckAppearanceStream(
- pIterator, ptOffset, CPVT_WordRange(wpWordStart, oldplace));
- bLatinWord = FALSE;
- sWord.Empty();
- }
- }
- }
-
- if (bLatinWord) {
- if (!pSpellCheck->CheckWord(sWord))
- sRet << GetWordSpellCheckAppearanceStream(
- pIterator, ptOffset, CPVT_WordRange(wpWordStart, oldplace));
-
- bLatinWord = FALSE;
- sWord.Empty();
- }
- }
- }
-
- return sRet.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetTextAppStream(const CFX_FloatRect& rcBBox,
- IFX_Edit_FontMap* pFontMap,
- const CFX_WideString& sText,
- int32_t nAlignmentH,
- int32_t nAlignmentV,
- FX_FLOAT fFontSize,
- FX_BOOL bMultiLine,
- FX_BOOL bAutoReturn,
- const CPWL_Color& crText) {
- CFX_ByteTextBuf sRet;
-
- if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) {
- pEdit->SetFontMap(pFontMap);
- pEdit->SetPlateRect(rcBBox);
- pEdit->SetAlignmentH(nAlignmentH);
- pEdit->SetAlignmentV(nAlignmentV);
- pEdit->SetMultiLine(bMultiLine);
- pEdit->SetAutoReturn(bAutoReturn);
- if (IsFloatZero(fFontSize))
- pEdit->SetAutoFontSize(TRUE);
- else
- pEdit->SetFontSize(fFontSize);
-
- pEdit->Initialize();
- pEdit->SetText(sText.c_str());
-
- CFX_ByteString sEdit =
- CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f));
- if (sEdit.GetLength() > 0) {
- sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit
- << "ET\n";
- }
- IFX_Edit::DelEdit(pEdit);
- }
-
- return sRet.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
- IFX_Edit_FontMap* pFontMap,
- CPDF_Stream* pIconStream,
- CPDF_IconFit& IconFit,
- const CFX_WideString& sLabel,
- const CPWL_Color& crText,
- FX_FLOAT fFontSize,
- int32_t nLayOut) {
- const FX_FLOAT fAutoFontScale = 1.0f / 3.0f;
-
- if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) {
- pEdit->SetFontMap(pFontMap);
- pEdit->SetAlignmentH(1);
- pEdit->SetAlignmentV(1);
- pEdit->SetMultiLine(FALSE);
- pEdit->SetAutoReturn(FALSE);
- if (IsFloatZero(fFontSize))
- pEdit->SetAutoFontSize(TRUE);
- else
- pEdit->SetFontSize(fFontSize);
-
- pEdit->Initialize();
- pEdit->SetText(sLabel.c_str());
-
- CFX_FloatRect rcLabelContent = pEdit->GetContentRect();
- CPWL_Icon Icon;
- PWL_CREATEPARAM cp;
- cp.dwFlags = PWS_VISIBLE;
- Icon.Create(cp);
- Icon.SetIconFit(&IconFit);
- Icon.SetPDFStream(pIconStream);
-
- CFX_FloatRect rcLabel = CFX_FloatRect(0, 0, 0, 0);
- CFX_FloatRect rcIcon = CFX_FloatRect(0, 0, 0, 0);
- FX_FLOAT fWidth = 0.0f;
- FX_FLOAT fHeight = 0.0f;
-
- switch (nLayOut) {
- case PPBL_LABEL:
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- break;
- case PPBL_ICON:
- rcIcon = rcBBox;
- rcLabel = CFX_FloatRect(0, 0, 0, 0);
- break;
- case PPBL_ICONTOPLABELBOTTOM:
-
- if (pIconStream) {
- if (IsFloatZero(fFontSize)) {
- fHeight = rcBBox.top - rcBBox.bottom;
- rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
- rcBBox.bottom + fHeight * fAutoFontScale);
- rcIcon = CFX_FloatRect(rcBBox.left, rcLabel.top, rcBBox.right,
- rcBBox.top);
- } else {
- fHeight = rcLabelContent.Height();
-
- if (rcBBox.bottom + fHeight > rcBBox.top) {
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- rcLabel = rcBBox;
- } else {
- rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
- rcBBox.bottom + fHeight);
- rcIcon = CFX_FloatRect(rcBBox.left, rcLabel.top, rcBBox.right,
- rcBBox.top);
- }
- }
- } else {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- }
-
- break;
- case PPBL_LABELTOPICONBOTTOM:
-
- if (pIconStream) {
- if (IsFloatZero(fFontSize)) {
- fHeight = rcBBox.top - rcBBox.bottom;
- rcLabel = CFX_FloatRect(rcBBox.left,
- rcBBox.top - fHeight * fAutoFontScale,
- rcBBox.right, rcBBox.top);
- rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
- rcLabel.bottom);
- } else {
- fHeight = rcLabelContent.Height();
-
- if (rcBBox.bottom + fHeight > rcBBox.top) {
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- rcLabel = rcBBox;
- } else {
- rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.top - fHeight,
- rcBBox.right, rcBBox.top);
- rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
- rcLabel.bottom);
- }
- }
- } else {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- }
-
- break;
- case PPBL_ICONLEFTLABELRIGHT:
-
- if (pIconStream) {
- if (IsFloatZero(fFontSize)) {
- fWidth = rcBBox.right - rcBBox.left;
- rcLabel = CFX_FloatRect(rcBBox.right - fWidth * fAutoFontScale,
- rcBBox.bottom, rcBBox.right, rcBBox.top);
- rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left,
- rcBBox.top);
-
- if (rcLabelContent.Width() < fWidth * fAutoFontScale) {
- } else {
- if (rcLabelContent.Width() < fWidth) {
- rcLabel =
- CFX_FloatRect(rcBBox.right - rcLabelContent.Width(),
- rcBBox.bottom, rcBBox.right, rcBBox.top);
- rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left,
- rcBBox.top);
- } else {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- }
- }
- } else {
- fWidth = rcLabelContent.Width();
-
- if (rcBBox.left + fWidth > rcBBox.right) {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- } else {
- rcLabel = CFX_FloatRect(rcBBox.right - fWidth, rcBBox.bottom,
- rcBBox.right, rcBBox.top);
- rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left,
- rcBBox.top);
- }
- }
- } else {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- }
-
- break;
- case PPBL_LABELLEFTICONRIGHT:
-
- if (pIconStream) {
- if (IsFloatZero(fFontSize)) {
- fWidth = rcBBox.right - rcBBox.left;
- rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom,
- rcBBox.left + fWidth * fAutoFontScale,
- rcBBox.top);
- rcIcon = CFX_FloatRect(rcLabel.right, rcBBox.bottom, rcBBox.right,
- rcBBox.top);
-
- if (rcLabelContent.Width() < fWidth * fAutoFontScale) {
- } else {
- if (rcLabelContent.Width() < fWidth) {
- rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom,
- rcBBox.left + rcLabelContent.Width(),
- rcBBox.top);
- rcIcon = CFX_FloatRect(rcLabel.right, rcBBox.bottom,
- rcBBox.right, rcBBox.top);
- } else {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- }
- }
- } else {
- fWidth = rcLabelContent.Width();
-
- if (rcBBox.left + fWidth > rcBBox.right) {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- } else {
- rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom,
- rcBBox.left + fWidth, rcBBox.top);
- rcIcon = CFX_FloatRect(rcLabel.right, rcBBox.bottom, rcBBox.right,
- rcBBox.top);
- }
- }
- } else {
- rcLabel = rcBBox;
- rcIcon = CFX_FloatRect(0, 0, 0, 0);
- }
-
- break;
- case PPBL_LABELOVERICON:
- rcLabel = rcBBox;
- rcIcon = rcBBox;
- break;
- }
-
- CFX_ByteTextBuf sAppStream, sTemp;
-
- if (!rcIcon.IsEmpty()) {
- Icon.Move(rcIcon, FALSE, FALSE);
- sTemp << Icon.GetImageAppStream();
- }
-
- Icon.Destroy();
-
- if (!rcLabel.IsEmpty()) {
- pEdit->SetPlateRect(rcLabel);
- CFX_ByteString sEdit =
- CPWL_Utils::GetEditAppStream(pEdit, CFX_FloatPoint(0.0f, 0.0f));
- if (sEdit.GetLength() > 0) {
- sTemp << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit
- << "ET\n";
- }
- }
-
- IFX_Edit::DelEdit(pEdit);
-
- if (sTemp.GetSize() > 0) {
- sAppStream << "q\n" << rcBBox.left << " " << rcBBox.bottom << " "
- << rcBBox.right - rcBBox.left << " "
- << rcBBox.top - rcBBox.bottom << " re W n\n";
- sAppStream << sTemp << "Q\n";
- }
-
- return sAppStream.GetByteString();
- }
-
- return "";
-}
-
-CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color& color,
- const FX_BOOL& bFillOrStroke) {
- CFX_ByteTextBuf sColorStream;
-
- switch (color.nColorType) {
- case COLORTYPE_RGB:
- sColorStream << color.fColor1 << " " << color.fColor2 << " "
- << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG")
- << "\n";
- break;
- case COLORTYPE_GRAY:
- sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G")
- << "\n";
- break;
- case COLORTYPE_CMYK:
- sColorStream << color.fColor1 << " " << color.fColor2 << " "
- << color.fColor3 << " " << color.fColor4 << " "
- << (bFillOrStroke ? "k" : "K") << "\n";
- break;
- }
-
- return sColorStream.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect,
- FX_FLOAT fWidth,
- const CPWL_Color& color,
- const CPWL_Color& crLeftTop,
- const CPWL_Color& crRightBottom,
- int32_t nStyle,
- const CPWL_Dash& dash) {
- CFX_ByteTextBuf sAppStream;
- CFX_ByteString sColor;
-
- FX_FLOAT fLeft = rect.left;
- FX_FLOAT fRight = rect.right;
- FX_FLOAT fTop = rect.top;
- FX_FLOAT fBottom = rect.bottom;
-
- if (fWidth > 0.0f) {
- FX_FLOAT fHalfWidth = fWidth / 2.0f;
-
- sAppStream << "q\n";
-
- switch (nStyle) {
- default:
- case PBS_SOLID:
- sColor = CPWL_Utils::GetColorAppStream(color, TRUE);
- if (sColor.GetLength() > 0) {
- sAppStream << sColor;
- sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " "
- << fTop - fBottom << " re\n";
- sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " "
- << fRight - fLeft - fWidth * 2 << " "
- << fTop - fBottom - fWidth * 2 << " re\n";
- sAppStream << "f*\n";
- }
- break;
- case PBS_DASH:
- sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
- if (sColor.GetLength() > 0) {
- sAppStream << sColor;
- sAppStream << fWidth << " w"
- << " [" << dash.nDash << " " << dash.nGap << "] "
- << dash.nPhase << " d\n";
- sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2
- << " m\n";
- sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2
- << " l\n";
- sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2
- << " l\n";
- sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2
- << " l\n";
- sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2
- << " l S\n";
- }
- break;
- case PBS_BEVELED:
- case PBS_INSET:
- sColor = CPWL_Utils::GetColorAppStream(crLeftTop, TRUE);
- if (sColor.GetLength() > 0) {
- sAppStream << sColor;
- sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth
- << " m\n";
- sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth
- << " l\n";
- sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth
- << " l\n";
- sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
- << " l\n";
- sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
- << " l\n";
- sAppStream << fLeft + fHalfWidth * 2 << " "
- << fBottom + fHalfWidth * 2 << " l f\n";
- }
-
- sColor = CPWL_Utils::GetColorAppStream(crRightBottom, TRUE);
- if (sColor.GetLength() > 0) {
- sAppStream << sColor;
- sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth
- << " m\n";
- sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfWidth
- << " l\n";
- sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth
- << " l\n";
- sAppStream << fLeft + fHalfWidth * 2 << " "
- << fBottom + fHalfWidth * 2 << " l\n";
- sAppStream << fRight - fHalfWidth * 2 << " "
- << fBottom + fHalfWidth * 2 << " l\n";
- sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
- << " l f\n";
- }
-
- sColor = CPWL_Utils::GetColorAppStream(color, TRUE);
- if (sColor.GetLength() > 0) {
- sAppStream << sColor;
- sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " "
- << fTop - fBottom << " re\n";
- sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " "
- << fRight - fLeft - fHalfWidth * 2 << " "
- << fTop - fBottom - fHalfWidth * 2 << " re f*\n";
- }
- break;
- case PBS_UNDERLINED:
- sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
- if (sColor.GetLength() > 0) {
- sAppStream << sColor;
- sAppStream << fWidth << " w\n";
- sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n";
- sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n";
- }
- break;
- }
-
- sAppStream << "Q\n";
- }
-
- return sAppStream.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
- const CFX_FloatRect& rect,
- FX_FLOAT fWidth,
- const CPWL_Color& color,
- const CPWL_Color& crLeftTop,
- const CPWL_Color& crRightBottom,
- int32_t nStyle,
- const CPWL_Dash& dash) {
- CFX_ByteTextBuf sAppStream;
- CFX_ByteString sColor;
-
- if (fWidth > 0.0f) {
- sAppStream << "q\n";
-
- switch (nStyle) {
- default:
- case PBS_SOLID:
- case PBS_UNDERLINED: {
- sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
- if (sColor.GetLength() > 0) {
- sAppStream << "q\n" << fWidth << " w\n" << sColor
- << CPWL_Utils::GetAP_Circle(
- CPWL_Utils::DeflateRect(rect, fWidth / 2.0f))
- << " S\nQ\n";
- }
- } break;
- case PBS_DASH: {
- sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
- if (sColor.GetLength() > 0) {
- sAppStream << "q\n" << fWidth << " w\n"
- << "[" << dash.nDash << " " << dash.nGap << "] "
- << dash.nPhase << " d\n" << sColor
- << CPWL_Utils::GetAP_Circle(
- CPWL_Utils::DeflateRect(rect, fWidth / 2.0f))
- << " S\nQ\n";
- }
- } break;
- case PBS_BEVELED: {
- FX_FLOAT fHalfWidth = fWidth / 2.0f;
-
- sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
- if (sColor.GetLength() > 0) {
- sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
- << CPWL_Utils::GetAP_Circle(rect) << " S\nQ\n";
- }
-
- sColor = CPWL_Utils::GetColorAppStream(crLeftTop, FALSE);
- if (sColor.GetLength() > 0) {
- sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
- << CPWL_Utils::GetAP_HalfCircle(
- CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f),
- FX_PI / 4.0f)
- << " S\nQ\n";
- }
-
- sColor = CPWL_Utils::GetColorAppStream(crRightBottom, FALSE);
- if (sColor.GetLength() > 0) {
- sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
- << CPWL_Utils::GetAP_HalfCircle(
- CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f),
- FX_PI * 5 / 4.0f)
- << " S\nQ\n";
- }
- } break;
- case PBS_INSET: {
- FX_FLOAT fHalfWidth = fWidth / 2.0f;
-
- sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
- if (sColor.GetLength() > 0) {
- sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
- << CPWL_Utils::GetAP_Circle(rect) << " S\nQ\n";
- }
-
- sColor = CPWL_Utils::GetColorAppStream(crLeftTop, FALSE);
- if (sColor.GetLength() > 0) {
- sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
- << CPWL_Utils::GetAP_HalfCircle(
- CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f),
- FX_PI / 4.0f)
- << " S\nQ\n";
- }
-
- sColor = CPWL_Utils::GetColorAppStream(crRightBottom, FALSE);
- if (sColor.GetLength() > 0) {
- sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
- << CPWL_Utils::GetAP_HalfCircle(
- CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f),
- FX_PI * 5 / 4.0f)
- << " S\nQ\n";
- }
- } break;
- }
-
- sAppStream << "Q\n";
- }
-
- return sAppStream.GetByteString();
-}
-
-CPWL_Color CPWL_Utils::SubstractColor(const CPWL_Color& sColor,
- FX_FLOAT fColorSub) {
- CPWL_Color sRet;
- sRet.nColorType = sColor.nColorType;
-
- switch (sColor.nColorType) {
- case COLORTYPE_TRANSPARENT:
- sRet.nColorType = COLORTYPE_RGB;
- sRet.fColor1 = PWL_MAX(1 - fColorSub, 0.0f);
- sRet.fColor2 = PWL_MAX(1 - fColorSub, 0.0f);
- sRet.fColor3 = PWL_MAX(1 - fColorSub, 0.0f);
- break;
- case COLORTYPE_RGB:
- case COLORTYPE_GRAY:
- case COLORTYPE_CMYK:
- sRet.fColor1 = PWL_MAX(sColor.fColor1 - fColorSub, 0.0f);
- sRet.fColor2 = PWL_MAX(sColor.fColor2 - fColorSub, 0.0f);
- sRet.fColor3 = PWL_MAX(sColor.fColor3 - fColorSub, 0.0f);
- sRet.fColor4 = PWL_MAX(sColor.fColor4 - fColorSub, 0.0f);
- break;
- }
-
- return sRet;
-}
-
-CPWL_Color CPWL_Utils::DevideColor(const CPWL_Color& sColor,
- FX_FLOAT fColorDevide) {
- CPWL_Color sRet;
- sRet.nColorType = sColor.nColorType;
-
- switch (sColor.nColorType) {
- case COLORTYPE_TRANSPARENT:
- sRet.nColorType = COLORTYPE_RGB;
- sRet.fColor1 = 1 / fColorDevide;
- sRet.fColor2 = 1 / fColorDevide;
- sRet.fColor3 = 1 / fColorDevide;
- break;
- case COLORTYPE_RGB:
- case COLORTYPE_GRAY:
- case COLORTYPE_CMYK:
- sRet = sColor;
- sRet.fColor1 /= fColorDevide;
- sRet.fColor2 /= fColorDevide;
- sRet.fColor3 /= fColorDevide;
- sRet.fColor4 /= fColorDevide;
- break;
- }
-
- return sRet;
-}
-
-CFX_ByteString CPWL_Utils::GetAppStream_Check(const CFX_FloatRect& rcBBox,
- const CPWL_Color& crText) {
- CFX_ByteTextBuf sAP;
- sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
- << CPWL_Utils::GetAP_Check(rcBBox) << "f\nQ\n";
- return sAP.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CFX_FloatRect& rcBBox,
- const CPWL_Color& crText) {
- CFX_ByteTextBuf sAP;
- sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
- << CPWL_Utils::GetAP_Circle(rcBBox) << "f\nQ\n";
- return sAP.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CFX_FloatRect& rcBBox,
- const CPWL_Color& crText) {
- CFX_ByteTextBuf sAP;
- sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, FALSE)
- << CPWL_Utils::GetAP_Cross(rcBBox) << "S\nQ\n";
- return sAP.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CFX_FloatRect& rcBBox,
- const CPWL_Color& crText) {
- CFX_ByteTextBuf sAP;
- sAP << "q\n1 w\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
- << CPWL_Utils::GetAP_Diamond(rcBBox) << "f\nQ\n";
- return sAP.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetAppStream_Square(const CFX_FloatRect& rcBBox,
- const CPWL_Color& crText) {
- CFX_ByteTextBuf sAP;
- sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
- << CPWL_Utils::GetAP_Square(rcBBox) << "f\nQ\n";
- return sAP.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetAppStream_Star(const CFX_FloatRect& rcBBox,
- const CPWL_Color& crText) {
- CFX_ByteTextBuf sAP;
- sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText, TRUE)
- << CPWL_Utils::GetAP_Star(rcBBox) << "f\nQ\n";
- return sAP.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetCheckBoxAppStream(const CFX_FloatRect& rcBBox,
- int32_t nStyle,
- const CPWL_Color& crText) {
- CFX_FloatRect rcCenter = GetCenterSquare(rcBBox);
- switch (nStyle) {
- default:
- case PCS_CHECK:
- return GetAppStream_Check(rcCenter, crText);
- case PCS_CIRCLE:
- return GetAppStream_Circle(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
- case PCS_CROSS:
- return GetAppStream_Cross(rcCenter, crText);
- case PCS_DIAMOND:
- return GetAppStream_Diamond(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
- case PCS_SQUARE:
- return GetAppStream_Square(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
- case PCS_STAR:
- return GetAppStream_Star(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
- }
-}
-
-CFX_ByteString CPWL_Utils::GetRadioButtonAppStream(const CFX_FloatRect& rcBBox,
- int32_t nStyle,
- const CPWL_Color& crText) {
- CFX_FloatRect rcCenter = GetCenterSquare(rcBBox);
- switch (nStyle) {
- default:
- case PCS_CHECK:
- return GetAppStream_Check(rcCenter, crText);
- case PCS_CIRCLE:
- return GetAppStream_Circle(ScaleRect(rcCenter, 1.0f / 2.0f), crText);
- case PCS_CROSS:
- return GetAppStream_Cross(rcCenter, crText);
- case PCS_DIAMOND:
- return GetAppStream_Diamond(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
- case PCS_SQUARE:
- return GetAppStream_Square(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
- case PCS_STAR:
- return GetAppStream_Star(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
- }
-}
-
-CFX_ByteString CPWL_Utils::GetDropButtonAppStream(const CFX_FloatRect& rcBBox) {
- CFX_ByteTextBuf sAppStream;
-
- if (!rcBBox.IsEmpty()) {
- sAppStream << "q\n" << CPWL_Utils::GetColorAppStream(
- CPWL_Color(COLORTYPE_RGB, 220.0f / 255.0f,
- 220.0f / 255.0f, 220.0f / 255.0f),
- TRUE);
- sAppStream << rcBBox.left << " " << rcBBox.bottom << " "
- << rcBBox.right - rcBBox.left << " "
- << 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))
- << "Q\n";
-
- CFX_FloatPoint ptCenter = CFX_FloatPoint((rcBBox.left + rcBBox.right) / 2,
- (rcBBox.top + rcBBox.bottom) / 2);
- if (IsFloatBigger(rcBBox.right - rcBBox.left, 6) &&
- IsFloatBigger(rcBBox.top - rcBBox.bottom, 6)) {
- sAppStream << "q\n"
- << " 0 g\n";
- sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n";
- sAppStream << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n";
- sAppStream << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n";
- sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n";
- sAppStream << "Q\n";
- }
- }
-
- return sAppStream.GetByteString();
-}
-
-void CPWL_Utils::ConvertCMYK2GRAY(FX_FLOAT dC,
- FX_FLOAT dM,
- FX_FLOAT dY,
- FX_FLOAT dK,
- FX_FLOAT& dGray) {
- if (dC < 0 || dC > 1 || dM < 0 || dM > 1 || dY < 0 || dY > 1 || dK < 0 ||
- dK > 1)
- return;
- dGray = 1.0f - std::min(1.0f, 0.3f * dC + 0.59f * dM + 0.11f * dY + dK);
-}
-
-void CPWL_Utils::ConvertGRAY2CMYK(FX_FLOAT dGray,
- FX_FLOAT& dC,
- FX_FLOAT& dM,
- FX_FLOAT& dY,
- FX_FLOAT& dK) {
- if (dGray < 0 || dGray > 1)
- return;
- dC = 0.0f;
- dM = 0.0f;
- dY = 0.0f;
- dK = 1.0f - dGray;
-}
-
-void CPWL_Utils::ConvertGRAY2RGB(FX_FLOAT dGray,
- FX_FLOAT& dR,
- FX_FLOAT& dG,
- FX_FLOAT& dB) {
- if (dGray < 0 || dGray > 1)
- return;
- dR = dGray;
- dG = dGray;
- dB = dGray;
-}
-
-void CPWL_Utils::ConvertRGB2GRAY(FX_FLOAT dR,
- FX_FLOAT dG,
- FX_FLOAT dB,
- FX_FLOAT& dGray) {
- if (dR < 0 || dR > 1 || dG < 0 || dG > 0 || dB < 0 || dB > 1)
- return;
- dGray = 0.3f * dR + 0.59f * dG + 0.11f * dB;
-}
-
-void CPWL_Utils::ConvertCMYK2RGB(FX_FLOAT dC,
- FX_FLOAT dM,
- FX_FLOAT dY,
- FX_FLOAT dK,
- FX_FLOAT& dR,
- FX_FLOAT& dG,
- FX_FLOAT& dB) {
- if (dC < 0 || dC > 1 || dM < 0 || dM > 1 || dY < 0 || dY > 1 || dK < 0 ||
- dK > 1)
- return;
- dR = 1.0f - std::min(1.0f, dC + dK);
- dG = 1.0f - std::min(1.0f, dM + dK);
- dB = 1.0f - std::min(1.0f, dY + dK);
-}
-
-void CPWL_Utils::ConvertRGB2CMYK(FX_FLOAT dR,
- FX_FLOAT dG,
- FX_FLOAT dB,
- FX_FLOAT& dC,
- FX_FLOAT& dM,
- FX_FLOAT& dY,
- FX_FLOAT& dK) {
- if (dR < 0 || dR > 1 || dG < 0 || dG > 1 || dB < 0 || dB > 1)
- return;
-
- dC = 1.0f - dR;
- dM = 1.0f - dG;
- dY = 1.0f - dB;
- dK = std::min(dC, std::min(dM, dY));
-}
-
-void CPWL_Utils::PWLColorToARGB(const CPWL_Color& color,
- int32_t& alpha,
- FX_FLOAT& red,
- FX_FLOAT& green,
- FX_FLOAT& blue) {
- switch (color.nColorType) {
- case COLORTYPE_TRANSPARENT: {
- alpha = 0;
- } break;
- case COLORTYPE_GRAY: {
- ConvertGRAY2RGB(color.fColor1, red, green, blue);
- } break;
- case COLORTYPE_RGB: {
- red = color.fColor1;
- green = color.fColor2;
- blue = color.fColor3;
- } break;
- case COLORTYPE_CMYK: {
- ConvertCMYK2RGB(color.fColor1, color.fColor2, color.fColor3,
- color.fColor4, red, green, blue);
- } break;
- }
-}
-
-FX_COLORREF CPWL_Utils::PWLColorToFXColor(const CPWL_Color& color,
- int32_t nTransparancy) {
- int32_t nAlpha = nTransparancy;
- FX_FLOAT dRed = 0;
- FX_FLOAT dGreen = 0;
- FX_FLOAT dBlue = 0;
-
- PWLColorToARGB(color, nAlpha, dRed, dGreen, dBlue);
-
- return ArgbEncode(nAlpha, (int32_t)(dRed * 255), (int32_t)(dGreen * 255),
- (int32_t)(dBlue * 255));
-}
-
-void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_FloatRect& rect,
- const FX_COLORREF& color) {
- CFX_PathData path;
- CFX_FloatRect rcTemp(rect);
- path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top);
- pDevice->DrawPath(&path, pUser2Device, NULL, color, 0, FXFILL_WINDING);
-}
-
-void CPWL_Utils::DrawFillArea(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_FloatPoint* pPts,
- int32_t nCount,
- const FX_COLORREF& color) {
- CFX_PathData path;
- path.SetPointCount(nCount);
-
- path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_MOVETO);
- for (int32_t i = 1; i < nCount; i++)
- path.SetPoint(i, pPts[i].x, pPts[i].y, FXPT_LINETO);
-
- pDevice->DrawPath(&path, pUser2Device, NULL, color, 0, FXFILL_ALTERNATE);
-}
-
-void CPWL_Utils::DrawStrokeRect(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_FloatRect& rect,
- const FX_COLORREF& color,
- FX_FLOAT fWidth) {
- CFX_PathData path;
- CFX_FloatRect rcTemp(rect);
- path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top);
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = fWidth;
-
- pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE);
-}
-
-void CPWL_Utils::DrawStrokeLine(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_FloatPoint& ptMoveTo,
- const CFX_FloatPoint& ptLineTo,
- const FX_COLORREF& color,
- FX_FLOAT fWidth) {
- CFX_PathData path;
- path.SetPointCount(2);
- path.SetPoint(0, ptMoveTo.x, ptMoveTo.y, FXPT_MOVETO);
- path.SetPoint(1, ptLineTo.x, ptLineTo.y, FXPT_LINETO);
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = fWidth;
-
- pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE);
-}
-
-void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_FloatRect& rect,
- const CPWL_Color& color,
- int32_t nTransparancy) {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rect,
- PWLColorToFXColor(color, nTransparancy));
-}
-
-void CPWL_Utils::DrawShadow(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- FX_BOOL bVertical,
- FX_BOOL bHorizontal,
- CFX_FloatRect rect,
- int32_t nTransparancy,
- int32_t nStartGray,
- int32_t nEndGray) {
- FX_FLOAT fStepGray = 1.0f;
-
- if (bVertical) {
- fStepGray = (nEndGray - nStartGray) / rect.Height();
-
- for (FX_FLOAT fy = rect.bottom + 0.5f; fy <= rect.top - 0.5f; fy += 1.0f) {
- int32_t nGray = nStartGray + (int32_t)(fStepGray * (fy - rect.bottom));
- CPWL_Utils::DrawStrokeLine(
- pDevice, pUser2Device, CFX_FloatPoint(rect.left, fy),
- CFX_FloatPoint(rect.right, fy),
- ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f);
- }
- }
-
- if (bHorizontal) {
- fStepGray = (nEndGray - nStartGray) / rect.Width();
-
- for (FX_FLOAT fx = rect.left + 0.5f; fx <= rect.right - 0.5f; fx += 1.0f) {
- int32_t nGray = nStartGray + (int32_t)(fStepGray * (fx - rect.left));
- CPWL_Utils::DrawStrokeLine(
- pDevice, pUser2Device, CFX_FloatPoint(fx, rect.bottom),
- CFX_FloatPoint(fx, rect.top),
- ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f);
- }
- }
-}
-
-void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- const CFX_FloatRect& rect,
- FX_FLOAT fWidth,
- const CPWL_Color& color,
- const CPWL_Color& crLeftTop,
- const CPWL_Color& crRightBottom,
- int32_t nStyle,
- int32_t nTransparancy) {
- FX_FLOAT fLeft = rect.left;
- FX_FLOAT fRight = rect.right;
- FX_FLOAT fTop = rect.top;
- FX_FLOAT fBottom = rect.bottom;
-
- if (fWidth > 0.0f) {
- FX_FLOAT fHalfWidth = fWidth / 2.0f;
-
- switch (nStyle) {
- default:
- case PBS_SOLID: {
- 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), 0,
- FXFILL_ALTERNATE);
- } break;
- case PBS_DASH: {
- CFX_PathData path;
-
- path.SetPointCount(5);
- path.SetPoint(0, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f,
- FXPT_MOVETO);
- path.SetPoint(1, fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f,
- FXPT_LINETO);
- path.SetPoint(2, fRight - fWidth / 2.0f, fTop - fWidth / 2.0f,
- FXPT_LINETO);
- path.SetPoint(3, fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f,
- FXPT_LINETO);
- path.SetPoint(4, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f,
- FXPT_LINETO);
-
- CFX_GraphStateData gsd;
- gsd.SetDashCount(2);
- gsd.m_DashArray[0] = 3.0f;
- gsd.m_DashArray[1] = 3.0f;
- gsd.m_DashPhase = 0;
-
- gsd.m_LineWidth = fWidth;
- pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
- PWLColorToFXColor(color, nTransparancy),
- FXFILL_WINDING);
- } break;
- case PBS_BEVELED:
- case PBS_INSET: {
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = fHalfWidth;
-
- CFX_PathData pathLT;
-
- pathLT.SetPointCount(7);
- pathLT.SetPoint(0, fLeft + fHalfWidth, fBottom + fHalfWidth,
- FXPT_MOVETO);
- pathLT.SetPoint(1, fLeft + fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
- pathLT.SetPoint(2, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
- pathLT.SetPoint(3, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2,
- FXPT_LINETO);
- pathLT.SetPoint(4, fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2,
- FXPT_LINETO);
- pathLT.SetPoint(5, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2,
- FXPT_LINETO);
- pathLT.SetPoint(6, fLeft + fHalfWidth, fBottom + fHalfWidth,
- FXPT_LINETO);
-
- pDevice->DrawPath(&pathLT, pUser2Device, &gsd,
- PWLColorToFXColor(crLeftTop, nTransparancy), 0,
- FXFILL_ALTERNATE);
-
- CFX_PathData pathRB;
-
- pathRB.SetPointCount(7);
- pathRB.SetPoint(0, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_MOVETO);
- pathRB.SetPoint(1, fRight - fHalfWidth, fBottom + fHalfWidth,
- FXPT_LINETO);
- pathRB.SetPoint(2, fLeft + fHalfWidth, fBottom + fHalfWidth,
- FXPT_LINETO);
- pathRB.SetPoint(3, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2,
- FXPT_LINETO);
- pathRB.SetPoint(4, fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2,
- FXPT_LINETO);
- pathRB.SetPoint(5, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2,
- FXPT_LINETO);
- pathRB.SetPoint(6, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
-
- pDevice->DrawPath(&pathRB, pUser2Device, &gsd,
- PWLColorToFXColor(crRightBottom, nTransparancy), 0,
- FXFILL_ALTERNATE);
-
- CFX_PathData path;
-
- path.AppendRect(fLeft, fBottom, fRight, fTop);
- path.AppendRect(fLeft + fHalfWidth, fBottom + fHalfWidth,
- fRight - fHalfWidth, fTop - fHalfWidth);
-
- pDevice->DrawPath(&path, pUser2Device, &gsd,
- PWLColorToFXColor(color, nTransparancy), 0,
- FXFILL_ALTERNATE);
- } break;
- case PBS_UNDERLINED: {
- CFX_PathData path;
-
- path.SetPointCount(2);
- path.SetPoint(0, fLeft, fBottom + fWidth / 2, FXPT_MOVETO);
- path.SetPoint(1, fRight, fBottom + fWidth / 2, FXPT_LINETO);
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = fWidth;
-
- 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;
- }
- }
-}
-
-static void AddSquigglyPath(CFX_PathData& PathData,
- FX_FLOAT fStartX,
- FX_FLOAT fEndX,
- FX_FLOAT fY,
- FX_FLOAT fStep) {
- PathData.AddPointCount(1);
- PathData.SetPoint(PathData.GetPointCount() - 1, fStartX, fY, FXPT_MOVETO);
-
- FX_FLOAT fx;
- int32_t i;
-
- for (i = 1, fx = fStartX + fStep; fx < fEndX; fx += fStep, i++) {
- PathData.AddPointCount(1);
- PathData.SetPoint(PathData.GetPointCount() - 1, fx, fY + (i & 1) * fStep,
- FXPT_LINETO);
- }
-}
-
-static void AddSpellCheckObj(CFX_PathData& PathData,
- IFX_Edit* pEdit,
- const CPVT_WordRange& wrWord) {
- FX_FLOAT fStartX = 0.0f;
- FX_FLOAT fEndX = 0.0f;
- FX_FLOAT fY = 0.0f;
- FX_FLOAT fStep = 0.0f;
-
- FX_BOOL bBreak = FALSE;
-
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- pIterator->SetAt(wrWord.BeginPos);
-
- do {
- CPVT_WordPlace place = pIterator->GetAt();
-
- CPVT_Line line;
- if (pIterator->GetLine(line)) {
- fY = line.ptLine.y;
- fStep = (line.fLineAscent - line.fLineDescent) / 16.0f;
- }
-
- if (place.LineCmp(wrWord.BeginPos) == 0) {
- pIterator->SetAt(wrWord.BeginPos);
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- fStartX = word.ptWord.x;
- }
- } else {
- fStartX = line.ptLine.x;
- }
-
- if (place.LineCmp(wrWord.EndPos) == 0) {
- pIterator->SetAt(wrWord.EndPos);
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- fEndX = word.ptWord.x + word.fWidth;
- }
-
- bBreak = TRUE;
- } else {
- fEndX = line.ptLine.x + line.fLineWidth;
- }
-
- AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep);
-
- if (bBreak)
- break;
- } while (pIterator->NextLine());
- }
-}
-
-void CPWL_Utils::DrawEditSpellCheck(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- IFX_Edit* pEdit,
- const CFX_FloatRect& rcClip,
- const CFX_FloatPoint& ptOffset,
- const CPVT_WordRange* pRange,
- IPWL_SpellCheck* pSpellCheck) {
- const FX_COLORREF crSpell = ArgbEncode(255, 255, 0, 0);
-
- // for spellcheck
- FX_BOOL bLatinWord = FALSE;
- CPVT_WordPlace wpWordStart;
- CFX_ByteString sLatinWord;
-
- CFX_PathData pathSpell;
-
- pDevice->SaveState();
-
- if (!rcClip.IsEmpty()) {
- CFX_FloatRect rcTemp = rcClip;
- pUser2Device->TransformRect(rcTemp);
- pDevice->SetClip_Rect(rcTemp.ToFxRect());
- }
-
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
- if (pEdit->GetFontMap()) {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord()) {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0)
- break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word)) {
- if (FX_EDIT_ISLATINWORD(word.Word)) {
- if (!bLatinWord) {
- wpWordStart = place;
- bLatinWord = TRUE;
- }
-
- sLatinWord += (char)word.Word;
- } else {
- if (bLatinWord) {
- if (!sLatinWord.IsEmpty()) {
- if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) {
- AddSpellCheckObj(pathSpell, pEdit,
- CPVT_WordRange(wpWordStart, oldplace));
- pIterator->SetAt(place);
- }
- }
- bLatinWord = FALSE;
- }
-
- sLatinWord.Empty();
- }
-
- oldplace = place;
- } else {
- if (bLatinWord) {
- if (!sLatinWord.IsEmpty()) {
- if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) {
- AddSpellCheckObj(pathSpell, pEdit,
- CPVT_WordRange(wpWordStart, oldplace));
- pIterator->SetAt(place);
- }
- }
- bLatinWord = FALSE;
- }
-
- sLatinWord.Empty();
- }
- }
-
- if (!sLatinWord.IsEmpty()) {
- if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord)) {
- AddSpellCheckObj(pathSpell, pEdit,
- CPVT_WordRange(wpWordStart, oldplace));
- }
- }
- }
- }
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = 0;
- if (pathSpell.GetPointCount() > 0)
- pDevice->DrawPath(&pathSpell, pUser2Device, &gsd, 0, crSpell,
- FXFILL_ALTERNATE);
-
- pDevice->RestoreState();
-}
-
-FX_BOOL CPWL_Utils::IsBlackOrWhite(const CPWL_Color& color) {
- switch (color.nColorType) {
- case COLORTYPE_TRANSPARENT:
- return FALSE;
- case COLORTYPE_GRAY:
- return color.fColor1 < 0.5f;
- case COLORTYPE_RGB:
- return color.fColor1 + color.fColor2 + color.fColor3 < 1.5f;
- case COLORTYPE_CMYK:
- return color.fColor1 + color.fColor2 + color.fColor3 + color.fColor4 >
- 2.0f;
- }
-
- return TRUE;
-}
-
-CPWL_Color CPWL_Utils::GetReverseColor(const CPWL_Color& color) {
- CPWL_Color crRet = color;
-
- switch (color.nColorType) {
- case COLORTYPE_GRAY:
- crRet.fColor1 = 1.0f - crRet.fColor1;
- break;
- case COLORTYPE_RGB:
- crRet.fColor1 = 1.0f - crRet.fColor1;
- crRet.fColor2 = 1.0f - crRet.fColor2;
- crRet.fColor3 = 1.0f - crRet.fColor3;
- break;
- case COLORTYPE_CMYK:
- crRet.fColor1 = 1.0f - crRet.fColor1;
- crRet.fColor2 = 1.0f - crRet.fColor2;
- crRet.fColor3 = 1.0f - crRet.fColor3;
- crRet.fColor4 = 1.0f - crRet.fColor4;
- break;
- }
-
- return crRet;
-}
-
-CFX_ByteString CPWL_Utils::GetIconAppStream(int32_t nType,
- const CFX_FloatRect& rect,
- const CPWL_Color& crFill,
- const CPWL_Color& crStroke) {
- CFX_ByteString sAppStream = CPWL_Utils::GetColorAppStream(crStroke, FALSE);
- sAppStream += CPWL_Utils::GetColorAppStream(crFill, TRUE);
-
- CFX_ByteString sPath;
- CFX_PathData path;
-
- switch (nType) {
- case PWL_ICONTYPE_CHECKMARK:
- GetGraphics_Checkmark(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_CIRCLE:
- GetGraphics_Circle(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_COMMENT:
- GetGraphics_Comment(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_CROSS:
- GetGraphics_Cross(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_HELP:
- GetGraphics_Help(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_INSERTTEXT:
- GetGraphics_InsertText(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_KEY:
- GetGraphics_Key(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_NEWPARAGRAPH:
- GetGraphics_NewParagraph(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_TEXTNOTE:
- GetGraphics_TextNote(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_PARAGRAPH:
- GetGraphics_Paragraph(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_RIGHTARROW:
- GetGraphics_RightArrow(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_RIGHTPOINTER:
- GetGraphics_RightPointer(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_STAR:
- GetGraphics_Star(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_UPARROW:
- GetGraphics_UpArrow(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_UPLEFTARROW:
- GetGraphics_UpLeftArrow(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_GRAPH:
- GetGraphics_Graph(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_PAPERCLIP:
- GetGraphics_Paperclip(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_ATTACHMENT:
- GetGraphics_Attachment(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_TAG:
- GetGraphics_Tag(sPath, path, rect, PWLPT_STREAM);
- break;
- case PWL_ICONTYPE_FOXIT:
- GetGraphics_Foxit(sPath, path, rect, PWLPT_STREAM);
- break;
- }
-
- sAppStream += sPath;
- if (crStroke.nColorType != COLORTYPE_TRANSPARENT)
- sAppStream += "B*\n";
- else
- sAppStream += "f*\n";
-
- return sAppStream;
-}
-
-void CPWL_Utils::DrawIconAppStream(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device,
- int32_t nType,
- const CFX_FloatRect& rect,
- const CPWL_Color& crFill,
- const CPWL_Color& crStroke,
- const int32_t nTransparancy) {
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = 1.0f;
-
- CFX_ByteString sPath;
- CFX_PathData path;
-
- switch (nType) {
- case PWL_ICONTYPE_CHECKMARK:
- GetGraphics_Checkmark(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_CIRCLE:
- GetGraphics_Circle(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_COMMENT:
- GetGraphics_Comment(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_CROSS:
- GetGraphics_Cross(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_HELP:
- GetGraphics_Help(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_INSERTTEXT:
- GetGraphics_InsertText(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_KEY:
- GetGraphics_Key(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_NEWPARAGRAPH:
- GetGraphics_NewParagraph(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_TEXTNOTE:
- GetGraphics_TextNote(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_PARAGRAPH:
- GetGraphics_Paragraph(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_RIGHTARROW:
- GetGraphics_RightArrow(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_RIGHTPOINTER:
- GetGraphics_RightPointer(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_STAR:
- GetGraphics_Star(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_UPARROW:
- GetGraphics_UpArrow(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_UPLEFTARROW:
- GetGraphics_UpLeftArrow(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_GRAPH:
- GetGraphics_Graph(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_PAPERCLIP:
- GetGraphics_Paperclip(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_ATTACHMENT:
- GetGraphics_Attachment(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_TAG:
- GetGraphics_Tag(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_FOXIT:
- GetGraphics_Foxit(sPath, path, rect, PWLPT_PATHDATA);
- break;
- default:
- return;
- }
-
- pDevice->DrawPath(
- &path, pUser2Device, &gsd, PWLColorToFXColor(crFill, nTransparancy),
- PWLColorToFXColor(crStroke, nTransparancy), FXFILL_ALTERNATE);
-}
-
-void CPWL_Utils::GetGraphics_Checkmark(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
- crBBox.bottom + fHeight * 2 / 5.0f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 15.0f +
- FX_BEZIER * (fWidth / 7.0f - fWidth / 15.0f),
- crBBox.bottom + fHeight * 2 / 5.0f +
- FX_BEZIER * (fHeight * 2 / 7.0f - fHeight * 2 / 5.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 4.5f +
- FX_BEZIER * (fWidth / 5.0f - fWidth / 4.5f),
- crBBox.bottom + fHeight / 16.0f +
- FX_BEZIER * (fHeight / 5.0f - fHeight / 16.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 4.5f,
- crBBox.bottom + fHeight / 16.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 4.5f +
- FX_BEZIER * (fWidth / 4.4f - fWidth / 4.5f),
- crBBox.bottom + fHeight / 16.0f -
- FX_BEZIER * fHeight / 16.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f +
- FX_BEZIER * (fWidth / 4.0f - fWidth / 3.0f),
- crBBox.bottom),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f, crBBox.bottom),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f +
- FX_BEZIER * fWidth * (1 / 7.0f + 2 / 15.0f),
- crBBox.bottom + FX_BEZIER * fHeight * 4 / 5.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 14 / 15.0f +
- FX_BEZIER * fWidth * (1 / 7.0f - 7 / 15.0f),
- crBBox.bottom + fHeight * 15 / 16.0f +
- FX_BEZIER * (fHeight * 4 / 5.0f -
- fHeight * 15 / 16.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 14 / 15.0f,
- crBBox.bottom + fHeight * 15 / 16.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(
- crBBox.left + fWidth * 14 / 15.0f +
- FX_BEZIER * (fWidth * 7 / 15.0f - fWidth * 14 / 15.0f),
- crBBox.bottom + fHeight * 15 / 16.0f +
- FX_BEZIER * (fHeight * 8 / 7.0f - fHeight * 15 / 16.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 3.6f +
- FX_BEZIER * (fWidth / 3.4f - fWidth / 3.6f),
- crBBox.bottom + fHeight / 3.5f +
- FX_BEZIER * (fHeight / 3.5f - fHeight / 3.5f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.6f,
- crBBox.bottom + fHeight / 3.5f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 3.6f,
- crBBox.bottom + fHeight / 3.5f +
- FX_BEZIER * (fHeight / 4.0f - fHeight / 3.5f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f +
- FX_BEZIER * (fWidth / 3.5f - fWidth / 15.0f),
- crBBox.bottom + fHeight * 2 / 5.0f +
- FX_BEZIER * (fHeight * 3.5f / 5.0f -
- fHeight * 2 / 5.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
- crBBox.bottom + fHeight * 2 / 5.0f),
- PWLPT_BEZIERTO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 16);
- else
- GetPathDataFromArray(path, PathArray, 16);
-}
-
-void CPWL_Utils::GetGraphics_Circle(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
- crBBox.bottom + fHeight / 2.0f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 15.0f,
- crBBox.bottom + fHeight / 2.0f +
- FX_BEZIER * (fHeight * 14 / 15.0f - fHeight / 2.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f -
- FX_BEZIER * (fWidth / 2.0f - fWidth / 15.0f),
- crBBox.top - fHeight / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f +
- FX_BEZIER * (fWidth * 14 / 15.0f - fWidth / 2.0f),
- crBBox.top - fHeight / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth / 15.0f,
- crBBox.bottom + fHeight / 2.0f +
- FX_BEZIER * (fHeight * 14 / 15.0f - fHeight / 2.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
- crBBox.bottom + fHeight / 2.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth / 15.0f,
- crBBox.bottom + fHeight / 2.0f -
- FX_BEZIER * (fHeight / 2.0f - fHeight / 15.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f +
- FX_BEZIER * (fWidth * 14 / 15.0f - fWidth / 2.0f),
- crBBox.bottom + fHeight / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
- crBBox.bottom + fHeight / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f -
- FX_BEZIER * (fWidth / 2.0f - fWidth / 15.0f),
- crBBox.bottom + fHeight / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 15.0f,
- crBBox.bottom + fHeight / 2.0f -
- FX_BEZIER * (fHeight / 2.0f - fHeight / 15.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
- crBBox.bottom + fHeight / 2.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 3 / 15.0f,
- crBBox.bottom + fHeight / 2.0f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 3 / 15.0f,
- crBBox.bottom + fHeight / 2.0f +
- FX_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f -
- FX_BEZIER * (fWidth / 2.0f - fWidth * 3 / 15.0f),
- crBBox.top - fHeight * 3 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
- crBBox.top - fHeight * 3 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f +
- FX_BEZIER * (fWidth * 4 / 5.0f - fWidth / 2.0f),
- crBBox.top - fHeight * 3 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 3 / 15.0f,
- crBBox.bottom + fHeight / 2.0f +
- FX_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 15.0f,
- crBBox.bottom + fHeight / 2.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 3 / 15.0f,
- crBBox.bottom + fHeight / 2.0f -
- FX_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f +
- FX_BEZIER * (fWidth * 4 / 5.0f - fWidth / 2.0f),
- crBBox.bottom + fHeight * 3 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
- crBBox.bottom + fHeight * 3 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f -
- FX_BEZIER * (fWidth * 4 / 5.0f - fWidth / 2.0f),
- crBBox.bottom + fHeight * 3 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 3 / 15.0f,
- crBBox.bottom + fHeight / 2.0f -
- FX_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 3 / 15.0f,
- crBBox.bottom + fHeight / 2.0f),
- PWLPT_BEZIERTO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 26);
- else
- GetPathDataFromArray(path, PathArray, 26);
-}
-
-void CPWL_Utils::GetGraphics_Comment(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 15.0f, crBBox.top - fHeight / 6.0f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 15.0f,
- crBBox.top - fHeight / 6.0f +
- FX_BEZIER * (fHeight / 6.0f - fHeight / 10.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f -
- FX_BEZIER * fWidth / 15.0f,
- crBBox.top - fHeight / 10.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f,
- crBBox.top - fHeight / 10.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f,
- crBBox.top - fHeight / 10.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f +
- FX_BEZIER * fWidth / 15.0f,
- crBBox.top - fHeight / 10.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth / 15.0f,
- crBBox.top - fHeight / 6 +
- FX_BEZIER * (fHeight / 6.0f - fHeight / 10.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
- crBBox.top - fHeight / 6.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
- crBBox.bottom + fHeight / 3.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
- crBBox.bottom + fHeight * 4 / 15.0f +
- FX_BEZIER * fHeight / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f +
- FX_BEZIER * fWidth / 15.0f,
- crBBox.bottom + fHeight * 4 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f,
- crBBox.bottom + fHeight * 4 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 5 / 15.0f,
- crBBox.bottom + fHeight * 4 / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 5 / 15.0f,
- crBBox.bottom + fHeight * 2 / 15 +
- FX_BEZIER * fHeight * 2 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 5 / 15.0f -
- FX_BEZIER * fWidth * 2 / 15.0f,
- crBBox.bottom + fHeight * 2 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 6 / 30.0f,
- crBBox.bottom + fHeight * 2 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 7 / 30.0f +
- FX_BEZIER * fWidth / 30.0f,
- crBBox.bottom + fHeight * 2 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 7 / 30.0f,
- crBBox.bottom + fHeight * 2 / 15.0f +
- FX_BEZIER * fHeight * 2 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 7 / 30.0f,
- crBBox.bottom + fHeight * 4 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f,
- crBBox.bottom + fHeight * 4 / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f -
- FX_BEZIER * fWidth / 15.0f,
- crBBox.bottom + fHeight * 4 / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
- crBBox.bottom + fHeight / 3.0f -
- FX_BEZIER * fHeight / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
- crBBox.bottom + fHeight / 3.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 15.0f, crBBox.top - fHeight / 6.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f,
- crBBox.top - fHeight * 8 / 30.0f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f,
- crBBox.top - fHeight * 8 / 30.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15,
- crBBox.top - fHeight * 25 / 60.0f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f,
- crBBox.top - fHeight * 25 / 60.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f,
- crBBox.top - fHeight * 17 / 30.0f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 4 / 15.0f,
- crBBox.top - fHeight * 17 / 30.0f),
- PWLPT_LINETO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 30);
- else
- GetPathDataFromArray(path, PathArray, 30);
-}
-
-void CPWL_Utils::GetGraphics_Cross(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
- CPWL_Point center_point(crBBox.left + fWidth / 2,
- crBBox.bottom + fHeight / 2);
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(
- CPWL_Point(center_point.x, center_point.y + fHeight / 10.0f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(center_point.x + fWidth * 0.3f,
- center_point.y + fHeight / 10.0f + fWidth * 0.3f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(center_point.x + fWidth / 10.0f + fWidth * 0.3f,
- center_point.y + fHeight * 0.3f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(center_point.x + fWidth / 10.0f, center_point.y),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(center_point.x + fWidth / 10.0f + fWidth * 0.3f,
- center_point.y - fHeight * 0.3f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(center_point.x + fWidth * 0.3f,
- center_point.y - fHeight / 10.0f - fHeight * 0.3f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(center_point.x, center_point.y - fHeight / 10.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(center_point.x - fWidth * 0.3f,
- center_point.y - fHeight / 10 - fHeight * 0.3f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(center_point.x - fWidth / 10.0f - fWidth * 0.3f,
- center_point.y - fHeight * 0.3f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(center_point.x - fWidth / 10, center_point.y),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(center_point.x - fWidth / 10 - fWidth * 0.3f,
- center_point.y + fHeight * 0.3f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(center_point.x - fWidth * 0.3f,
- center_point.y + fHeight / 10.0f + fHeight * 0.3f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(center_point.x, center_point.y + fHeight / 10.0f),
- PWLPT_LINETO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 13);
- else
- GetPathDataFromArray(path, PathArray, 13);
-}
-
-void CPWL_Utils::GetGraphics_Help(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60.0f,
- crBBox.bottom + fHeight / 2.0f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 60.0f,
- crBBox.bottom + fHeight / 2.0f +
- FX_BEZIER * (fHeight / 60.0f - fHeight / 2.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f -
- FX_BEZIER * (fWidth / 2.0f - fWidth / 60.0f),
- crBBox.bottom + fHeight / 60.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
- crBBox.bottom + fHeight / 60.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f +
- FX_BEZIER * fWidth * 29 / 60.0f,
- crBBox.bottom + fHeight / 60.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth / 60.0f,
- crBBox.bottom + fHeight / 2.0f +
- FX_BEZIER * (fHeight / 60.0f - fHeight / 2.0f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 60.0f,
- crBBox.bottom + fHeight / 2.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 60.0f,
- crBBox.bottom + fHeight / 2.0f +
- FX_BEZIER * fHeight * 29 / 60.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f +
- FX_BEZIER * fWidth * 29 / 60.0f,
- crBBox.top - fHeight / 60.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 60.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f -
- FX_BEZIER * fWidth * 29 / 60.0f,
- crBBox.top - fHeight / 60.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60.0f,
- crBBox.bottom + fHeight / 2.0f +
- FX_BEZIER * fHeight * 29 / 60.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60.0f,
- crBBox.bottom + fHeight / 2.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.27f,
- crBBox.top - fHeight * 0.36f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.27f,
- crBBox.top - fHeight * 0.36f +
- FX_BEZIER * fHeight * 0.23f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.5f - FX_BEZIER * fWidth * 0.23f,
- crBBox.bottom + fHeight * 0.87f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.5f,
- crBBox.bottom + fHeight * 0.87f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.5f + FX_BEZIER * fWidth * 0.23f,
- crBBox.bottom + fHeight * 0.87f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.27f,
- crBBox.top - fHeight * 0.36f +
- FX_BEZIER * fHeight * 0.23f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.27f,
- crBBox.top - fHeight * 0.36f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.27f - fWidth * 0.08f * 0.2f,
- crBBox.top - fHeight * 0.36f - fHeight * 0.15f * 0.7f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.35f + fWidth * 0.08f * 0.2f,
- crBBox.top - fHeight * 0.51f + fHeight * 0.15f * 0.2f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.35f,
- crBBox.top - fHeight * 0.51f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.35f - fWidth * 0.1f * 0.5f,
- crBBox.top - fHeight * 0.51f - fHeight * 0.15f * 0.3f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.45f - fWidth * 0.1f * 0.5f,
- crBBox.top - fHeight * 0.68f + fHeight * 0.15f * 0.5f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.45f,
- crBBox.top - fHeight * 0.68f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.45f,
- crBBox.bottom + fHeight * 0.30f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.45f,
- crBBox.bottom + fHeight * 0.30f - fWidth * 0.1f * 0.7f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.55f,
- crBBox.bottom + fHeight * 0.30f - fWidth * 0.1f * 0.7f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.55f,
- crBBox.bottom + fHeight * 0.30f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.55f,
- crBBox.top - fHeight * 0.66f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.55f - fWidth * 0.1f * 0.05f,
- crBBox.top - fHeight * 0.66f + fHeight * 0.18f * 0.5f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.45f - fWidth * 0.1f * 0.05f,
- crBBox.top - fHeight * 0.48f - fHeight * 0.18f * 0.3f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.45f,
- crBBox.top - fHeight * 0.48f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.45f + fWidth * 0.08f * 0.2f,
- crBBox.top - fHeight * 0.48f + fHeight * 0.18f * 0.2f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.37f - fWidth * 0.08f * 0.2f,
- crBBox.top - fHeight * 0.36f - fHeight * 0.18f * 0.7f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.37f,
- crBBox.top - fHeight * 0.36f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.37f,
- crBBox.top - fHeight * 0.36f +
- FX_BEZIER * fHeight * 0.13f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.5f + FX_BEZIER * fWidth * 0.13f,
- crBBox.bottom + fHeight * 0.77f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.5f,
- crBBox.bottom + fHeight * 0.77f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.5f - FX_BEZIER * fWidth * 0.13f,
- crBBox.bottom + fHeight * 0.77f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.37f,
- crBBox.top - fHeight * 0.36f +
- FX_BEZIER * fHeight * 0.13f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.37f,
- crBBox.top - fHeight * 0.36f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.37f,
- crBBox.top - fHeight * 0.36f - fWidth * 0.1f * 0.6f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.27f,
- crBBox.top - fHeight * 0.36f - fWidth * 0.1f * 0.6f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.27f,
- crBBox.top - fHeight * 0.36f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.56f,
- crBBox.bottom + fHeight * 0.13f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.56f,
- crBBox.bottom + fHeight * 0.13f +
- FX_BEZIER * fHeight * 0.055f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f -
- FX_BEZIER * fWidth * 0.095f,
- crBBox.bottom + fHeight * 0.185f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f,
- crBBox.bottom + fHeight * 0.185f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f +
- FX_BEZIER * fWidth * 0.065f,
- crBBox.bottom + fHeight * 0.185f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.44f,
- crBBox.bottom + fHeight * 0.13f +
- FX_BEZIER * fHeight * 0.055f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.44f,
- crBBox.bottom + fHeight * 0.13f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.44f,
- crBBox.bottom + fHeight * 0.13f -
- FX_BEZIER * fHeight * 0.055f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f +
- FX_BEZIER * fWidth * 0.065f,
- crBBox.bottom + fHeight * 0.075f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f,
- crBBox.bottom + fHeight * 0.075f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f -
- FX_BEZIER * fWidth * 0.065f,
- crBBox.bottom + fHeight * 0.075f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.56f,
- crBBox.bottom + fHeight * 0.13f -
- FX_BEZIER * fHeight * 0.055f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.56f,
- crBBox.bottom + fHeight * 0.13f),
- PWLPT_BEZIERTO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 59);
- else
- GetPathDataFromArray(path, PathArray, 59);
-}
-
-void CPWL_Utils::GetGraphics_InsertText(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 10, crBBox.bottom + fHeight / 10),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2, crBBox.top - fHeight * 2 / 15),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth / 10, crBBox.bottom + fHeight / 10),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 10, crBBox.bottom + fHeight / 10),
- PWLPT_LINETO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 4);
- else
- GetPathDataFromArray(path, PathArray, 4);
-}
-
-void CPWL_Utils::GetGraphics_Key(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
- FX_FLOAT k = -fHeight / fWidth;
- CPWL_Point tail;
- CPWL_Point CicleCenter;
- tail.x = crBBox.left + fWidth * 0.9f;
- tail.y = k * (tail.x - crBBox.right) + crBBox.bottom;
- CicleCenter.x = crBBox.left + fWidth * 0.15f;
- CicleCenter.y = k * (CicleCenter.x - crBBox.right) + crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(
- CPWL_Point(tail.x + fWidth / 30.0f, -fWidth / 30.0f / k + tail.y),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(tail.x + fWidth / 30.0f - fWidth * 0.18f,
- -k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f + fWidth * 0.07f,
- -fWidth * 0.07f / k - k * fWidth * 0.18f -
- fWidth / 30 / k + tail.y),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 +
- fWidth * 0.07f,
- -fWidth * 0.07f / k - k * fWidth / 20 -
- k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(
- tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20,
- -k * fWidth / 20 - k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(
- tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 - fWidth / 15,
- -k * fWidth / 15 - k * fWidth / 20 - k * fWidth * 0.18f -
- fWidth / 30 / k + tail.y),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 -
- fWidth / 15 + fWidth * 0.07f,
- -fWidth * 0.07f / k - k * fWidth / 15 - k * fWidth / 20 -
- k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 -
- fWidth / 15 - fWidth / 20 + fWidth * 0.07f,
- -fWidth * 0.07f / k + -k * fWidth / 20 + -k * fWidth / 15 -
- k * fWidth / 20 - k * fWidth * 0.18f -
- fWidth / 30 / k + tail.y),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 -
- fWidth / 15 - fWidth / 20,
- -k * fWidth / 20 + -k * fWidth / 15 - k * fWidth / 20 -
- k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.45f,
- -k * fWidth * 0.45f - fWidth / 30 / k + tail.y),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.45f + fWidth * 0.2f,
- -fWidth * 0.4f / k - k * fWidth * 0.45f - fWidth / 30 / k +
- tail.y),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth * 0.2f,
- -fWidth * 0.1f / k + CicleCenter.y),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(CicleCenter.x, CicleCenter.y), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(CicleCenter.x - fWidth / 60.0f,
- -k * fWidth / 60 + CicleCenter.y),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(CicleCenter.x - fWidth / 60,
- -k * fWidth / 60 + CicleCenter.y),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(CicleCenter.x, CicleCenter.y), PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(CicleCenter.x - fWidth * 0.22f,
- fWidth * 0.35f / k + CicleCenter.y - fHeight * 0.05f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(tail.x - fWidth / 30 - fWidth * 0.45f - fWidth * 0.18f,
- fWidth * 0.05f / k - k * fWidth * 0.45f + fWidth / 30 / k +
- tail.y - fHeight * 0.05f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(tail.x - fWidth / 30.0f - fWidth * 0.45f,
- -k * fWidth * 0.45f + fWidth / 30.0f / k + tail.y),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(tail.x - fWidth / 30.0f, fWidth / 30.0f / k + tail.y),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(tail.x + fWidth / 30, -fWidth / 30 / k + tail.y),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth * 0.08f,
- k * fWidth * 0.08f + CicleCenter.y),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(CicleCenter.x + fWidth * 0.08f + fWidth * 0.1f,
- -fWidth * 0.1f / k + k * fWidth * 0.08f + CicleCenter.y),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(CicleCenter.x + fWidth * 0.22f + fWidth * 0.1f,
- k * fWidth * 0.22f + CicleCenter.y - fWidth * 0.1f / k),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth * 0.22f,
- k * fWidth * 0.22f + CicleCenter.y),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(CicleCenter.x + fWidth * 0.22f - fWidth * 0.1f,
- fWidth * 0.1f / k + k * fWidth * 0.22f + CicleCenter.y),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(CicleCenter.x + fWidth * 0.08f - fWidth * 0.1f,
- fWidth * 0.1f / k + k * fWidth * 0.08f + CicleCenter.y),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth * 0.08f,
- k * fWidth * 0.08f + CicleCenter.y),
- PWLPT_BEZIERTO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 28);
- else
- GetPathDataFromArray(path, PathArray, 28);
-}
-
-void CPWL_Utils::GetGraphics_NewParagraph(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 20.0f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 10.0f, crBBox.top - fHeight / 2.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
- crBBox.top - fHeight / 2.0f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 20.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.12f,
- crBBox.top - fHeight * 17 / 30.0f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.12f,
- crBBox.bottom + fHeight / 10.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.22f,
- crBBox.bottom + fHeight / 10.0f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.22f,
- crBBox.top - fHeight * 17 / 30.0f - fWidth * 0.14f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.38f,
- crBBox.bottom + fHeight / 10.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.48f,
- crBBox.bottom + fHeight / 10.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.48f,
- crBBox.top - fHeight * 17 / 30.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.38f,
- crBBox.top - fHeight * 17 / 30.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.38f,
- crBBox.bottom + fWidth * 0.24f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.22f,
- crBBox.top - fHeight * 17 / 30.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.12f,
- crBBox.top - fHeight * 17 / 30.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
- crBBox.bottom + fHeight / 10.0f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
- crBBox.bottom + fHeight / 10.0f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.7f,
- crBBox.bottom + fHeight / 10.0f + fHeight / 7.0f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.97f,
- crBBox.bottom + fHeight / 10.0f + fHeight / 7.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.97f,
- crBBox.top - fHeight * 17 / 30.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
- crBBox.top - fHeight * 17 / 30.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
- crBBox.top - fHeight * 17 / 30.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
- crBBox.bottom + fHeight / 10.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
- crBBox.bottom + fHeight / 7 + fHeight * 0.18f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.85f,
- crBBox.bottom + fHeight / 7 + fHeight * 0.18f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.85f,
- crBBox.top - fHeight * 17 / 30.0f - fHeight * 0.08f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.7f,
- crBBox.top - fHeight * 17 / 30.0f - fHeight * 0.08f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
- crBBox.bottom + fHeight / 7 + fHeight * 0.18f),
- PWLPT_LINETO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 28);
- else
- GetPathDataFromArray(path, PathArray, 28);
-}
-
-void CPWL_Utils::GetGraphics_TextNote(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
- crBBox.bottom + fHeight / 15.0f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 7 / 10.0f,
- crBBox.bottom + fHeight * 4 / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
- crBBox.bottom + fHeight * 4 / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
- crBBox.top - fHeight / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 10.0f,
- crBBox.top - fHeight / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 10.0f,
- crBBox.bottom + fHeight / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
- crBBox.bottom + fHeight / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
- crBBox.bottom + fHeight * 4 / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
- crBBox.bottom + fHeight / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
- crBBox.bottom + fHeight * 4 / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
- crBBox.bottom + fHeight * 4 / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 5.0f,
- crBBox.top - fHeight * 4 / 15.0f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 5.0f,
- crBBox.top - fHeight * 4 / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 5.0f,
- crBBox.top - fHeight * 7 / 15.0f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 5.0f,
- crBBox.top - fHeight * 7 / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 5.0f,
- crBBox.top - fHeight * 10 / 15.0f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
- crBBox.top - fHeight * 10 / 15.0f),
- PWLPT_LINETO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 17);
- else
- GetPathDataFromArray(path, PathArray, 17);
-}
-
-void CPWL_Utils::GetGraphics_Paragraph(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.7f, crBBox.top - fHeight / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
- crBBox.bottom + fHeight / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.634f,
- crBBox.bottom + fHeight / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.634f,
- crBBox.top - fHeight * 2 / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.566f,
- crBBox.top - fHeight * 2 / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.566f,
- crBBox.bottom + fHeight / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
- crBBox.bottom + fHeight / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
- crBBox.top - fHeight / 15.0f - fHeight * 0.4f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.2f,
- crBBox.top - fHeight / 15.0f - fHeight * 0.4f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.2f, crBBox.top - fHeight / 15.0f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
- PWLPT_BEZIERTO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 12);
- else
- GetPathDataFromArray(path, PathArray, 12);
-}
-
-void CPWL_Utils::GetGraphics_RightArrow(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
- crBBox.top - fHeight / 2.0f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f + fWidth / 8.0f,
- crBBox.bottom + fHeight / 5.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
- crBBox.bottom + fHeight / 5.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f - fWidth * 0.15f,
- crBBox.top - fHeight / 2.0f - fWidth / 25.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.1f,
- crBBox.top - fHeight / 2.0f - fWidth / 25.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.1f,
- crBBox.top - fHeight / 2.0f + fWidth / 25.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f - fWidth * 0.15f,
- crBBox.top - fHeight / 2.0f + fWidth / 25.0f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 5.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f + fWidth / 8.0f,
- crBBox.top - fHeight / 5.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
- crBBox.top - fHeight / 2.0f),
- PWLPT_LINETO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 10);
- else
- GetPathDataFromArray(path, PathArray, 10);
-}
-
-void CPWL_Utils::GetGraphics_RightPointer(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30.0f,
- crBBox.top - fHeight / 2.0f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 30.0f,
- crBBox.bottom + fHeight / 6.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 4 / 15.0f,
- crBBox.top - fHeight / 2.0f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 30.0f, crBBox.top - fHeight / 6.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30.0f,
- crBBox.top - fHeight / 2.0f),
- PWLPT_LINETO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 5);
- else
- GetPathDataFromArray(path, PathArray, 5);
-}
-
-void CPWL_Utils::GetGraphics_Star(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fLongRadius =
- (crBBox.top - crBBox.bottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f));
- fLongRadius = fLongRadius * 0.7f;
- FX_FLOAT fShortRadius = fLongRadius * 0.55f;
- CFX_FloatPoint ptCenter = CFX_FloatPoint((crBBox.left + crBBox.right) / 2.0f,
- (crBBox.top + crBBox.bottom) / 2.0f);
-
- FX_FLOAT px1[5], py1[5];
- FX_FLOAT px2[5], py2[5];
-
- FX_FLOAT fAngel = FX_PI / 10.0f;
-
- for (int32_t i = 0; i < 5; i++) {
- px1[i] = ptCenter.x + fLongRadius * (FX_FLOAT)cos(fAngel);
- py1[i] = ptCenter.y + fLongRadius * (FX_FLOAT)sin(fAngel);
-
- fAngel += FX_PI * 2 / 5.0f;
- }
-
- fAngel = FX_PI / 5.0f + FX_PI / 10.0f;
-
- for (int32_t j = 0; j < 5; j++) {
- px2[j] = ptCenter.x + fShortRadius * (FX_FLOAT)cos(fAngel);
- py2[j] = ptCenter.y + fShortRadius * (FX_FLOAT)sin(fAngel);
-
- fAngel += FX_PI * 2 / 5.0f;
- }
-
- CPWL_PathData PathArray[11];
- PathArray[0] = CPWL_PathData(CPWL_Point(px1[0], py1[0]), PWLPT_MOVETO);
- PathArray[1] = CPWL_PathData(CPWL_Point(px2[0], py2[0]), PWLPT_LINETO);
-
- for (int32_t k = 0; k < 4; k++) {
- PathArray[(k + 1) * 2] =
- CPWL_PathData(CPWL_Point(px1[k + 1], py1[k + 1]), PWLPT_LINETO);
- PathArray[(k + 1) * 2 + 1] =
- CPWL_PathData(CPWL_Point(px2[k + 1], py2[k + 1]), PWLPT_LINETO);
- }
-
- PathArray[10] = CPWL_PathData(CPWL_Point(px1[0], py1[0]), PWLPT_LINETO);
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 11);
- else
- GetPathDataFromArray(path, PathArray, 11);
-}
-
-void CPWL_Utils::GetGraphics_UpArrow(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
- crBBox.top - fWidth * 3 / 5.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
- crBBox.top - fWidth * 3 / 5.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
- crBBox.bottom + fHeight / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.4f,
- crBBox.bottom + fHeight / 15.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.4f,
- crBBox.top - fWidth * 3 / 5.0f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 10, crBBox.top - fWidth * 3 / 5.0f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
- PWLPT_LINETO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 8);
- else
- GetPathDataFromArray(path, PathArray, 8);
-}
-
-void CPWL_Utils::GetGraphics_UpLeftArrow(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
- CPWL_Point leftup(crBBox.left, crBBox.top);
- CPWL_Point rightdown(crBBox.right, crBBox.bottom);
- FX_FLOAT k = -fHeight / fWidth;
- CPWL_Point tail;
- tail.x = crBBox.left + fWidth * 4 / 5.0f;
- tail.y = k * (tail.x - crBBox.right) + rightdown.y;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(
- CPWL_Point(
- crBBox.left + fWidth / 20.0f,
- k * (crBBox.left + fWidth / 20.0f - rightdown.x) + rightdown.y),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(fHeight * 17 / 60.0f / k + tail.x +
- fWidth / 10.0f + fWidth / 5.0f,
- -fWidth / 5.0f / k + tail.y -
- fWidth / 10.0f / k + fHeight * 17 / 60.0f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(fHeight * 17 / 60.0f / k + tail.x + fWidth / 10.0f,
- tail.y - fWidth / 10.0f / k + fHeight * 17 / 60.0f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(tail.x + fWidth / 10.0f, tail.y - fWidth / 10.0f / k),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(tail.x - fWidth / 10.0f, tail.y + fWidth / 10.0f / k),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(fHeight * 17 / 60.0f / k + tail.x - fWidth / 10.0f,
- tail.y + fWidth / 10.0f / k + fHeight * 17 / 60.0f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(fHeight * 17 / 60.0f / k + tail.x -
- fWidth / 10.0f - fWidth / 5.0f,
- fWidth / 5.0f / k + tail.y + fWidth / 10.0f / k +
- fHeight * 17 / 60.0f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(
- crBBox.left + fWidth / 20.0f,
- k * (crBBox.left + fWidth / 20.0f - rightdown.x) + rightdown.y),
- PWLPT_LINETO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 8);
- else
- GetPathDataFromArray(path, PathArray, 8);
-}
-
-void CPWL_Utils::GetGraphics_Graph(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.05f, crBBox.top - fWidth * 0.15f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.25f,
- crBBox.top - fHeight * 0.15f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.275f,
- crBBox.bottom + fHeight * 0.08f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.05f,
- crBBox.bottom + fHeight * 0.08f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.05f, crBBox.top - fWidth * 0.15f),
- PWLPT_LINETO),
-
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.275f,
- crBBox.top - fWidth * 0.45f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.475f,
- crBBox.top - fWidth * 0.45f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.475f,
- crBBox.bottom + fHeight * 0.08f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.275f,
- crBBox.bottom + fHeight * 0.08f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.275f,
- crBBox.top - fWidth * 0.45f),
- PWLPT_LINETO),
-
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.5f, crBBox.top - fHeight * 0.05f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.7f, crBBox.top - fHeight * 0.05f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
- crBBox.bottom + fHeight * 0.08f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.5f,
- crBBox.bottom + fHeight * 0.08f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.5f, crBBox.top - fHeight * 0.05f),
- PWLPT_LINETO),
-
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.725f,
- crBBox.top - fWidth * 0.35f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.925f,
- crBBox.top - fWidth * 0.35f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.925f,
- crBBox.bottom + fHeight * 0.08f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.725f,
- crBBox.bottom + fHeight * 0.08f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.725f,
- crBBox.top - fWidth * 0.35f),
- PWLPT_LINETO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 20);
- else
- GetPathDataFromArray(path, PathArray, 20);
-}
-
-void CPWL_Utils::GetGraphics_Paperclip(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 60, crBBox.top - fHeight * 0.25f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60,
- crBBox.bottom + fHeight * 0.25f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60,
- crBBox.bottom + fHeight * 0.25f -
- fWidth * 57 / 60.0f * 0.35f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30,
- crBBox.bottom + fHeight * 0.25f -
- fWidth * 57 / 60.0f * 0.35f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30,
- crBBox.bottom + fHeight * 0.25f),
- PWLPT_BEZIERTO),
-
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth / 30, crBBox.top - fHeight * 0.33f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth / 30,
- crBBox.top - fHeight * 0.33f + fHeight / 15 * 0.5f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth / 30 - fWidth * 0.12f,
- crBBox.top - fHeight * 0.33f + fHeight / 15 * 0.5f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30 - fWidth * 0.12f,
- crBBox.top - fHeight * 0.33f),
- PWLPT_BEZIERTO),
-
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30 - fWidth * 0.12f,
- crBBox.bottom + fHeight * 0.2f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth / 30 - fWidth * 0.12f,
- crBBox.bottom + fHeight * 0.2f -
- (fWidth * 57 / 60.0f - fWidth * 0.24f) * 0.25f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 60 + fWidth * 0.12f,
- crBBox.bottom + fHeight * 0.2f -
- (fWidth * 57 / 60.0f - fWidth * 0.24f) * 0.25f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60 + fWidth * 0.12f,
- crBBox.bottom + fHeight * 0.2f),
- PWLPT_BEZIERTO),
-
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60 + fWidth * 0.12f,
- crBBox.top - fHeight * 0.2f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 60 + fWidth * 0.12f,
- crBBox.top - fHeight * 0.2f +
- (fWidth * 11 / 12.0f - fWidth * 0.36f) * 0.25f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.24f,
- crBBox.top - fHeight * 0.2f +
- (fWidth * 11 / 12.0f - fWidth * 0.36f) * 0.25f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.24f,
- crBBox.top - fHeight * 0.2f),
- PWLPT_BEZIERTO),
-
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.24f,
- crBBox.bottom + fHeight * 0.25f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.24f,
- crBBox.bottom + fHeight * 0.25f -
- (fWidth * 14 / 15.0f - fWidth * 0.53f) * 0.25f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.29f,
- crBBox.bottom + fHeight * 0.25f -
- (fWidth * 14 / 15.0f - fWidth * 0.53f) * 0.25f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.29f,
- crBBox.bottom + fHeight * 0.25f),
- PWLPT_BEZIERTO),
-
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.29f,
- crBBox.top - fHeight * 0.33f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.29f,
- crBBox.top - fHeight * 0.33f + fWidth * 0.12f * 0.35f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.17f,
- crBBox.top - fHeight * 0.33f + fWidth * 0.12f * 0.35f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.17f,
- crBBox.top - fHeight * 0.33f),
- PWLPT_BEZIERTO),
-
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.17f,
- crBBox.bottom + fHeight * 0.3f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.17f,
- crBBox.bottom + fHeight * 0.3f -
- fWidth * (14 / 15.0f - 0.29f) * 0.35f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.12f,
- crBBox.bottom + fHeight * 0.3f -
- fWidth * (14 / 15.0f - 0.29f) * 0.35f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.12f,
- crBBox.bottom + fHeight * 0.3f),
- PWLPT_BEZIERTO),
-
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.12f,
- crBBox.top - fHeight * 0.25f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.12f,
- crBBox.top - fHeight * 0.25f +
- fWidth * 0.35f * (11 / 12.0f - 0.12f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60,
- crBBox.top - fHeight * 0.25f +
- fWidth * 0.35f * (11 / 12.0f - 0.12f)),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth / 60, crBBox.top - fHeight * 0.25f),
- PWLPT_BEZIERTO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 33);
- else
- GetPathDataFromArray(path, PathArray, 33);
-}
-
-void CPWL_Utils::GetGraphics_Attachment(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.25f, crBBox.top - fHeight * 0.1f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.23f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.5f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.4f,
- crBBox.top - fHeight * 0.5f + fWidth * 0.04f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
- crBBox.top - fHeight * 0.5f + fWidth * 0.04f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.6f, crBBox.top - fHeight * 0.5f),
- PWLPT_BEZIERTO),
-
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.6f, crBBox.top - fHeight * 0.23f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.25f,
- crBBox.top - fHeight * 0.1f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.25f, crBBox.top - fHeight * 0.1f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.23f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.6f, crBBox.top - fHeight * 0.23f),
- PWLPT_LINETO),
-
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.5f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.4f - fWidth * 0.25f * 0.4f,
- crBBox.top - fHeight * 0.5f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.15f,
- crBBox.top - fHeight * 0.65f + fHeight * 0.15f * 0.4f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.15f,
- crBBox.top - fHeight * 0.65f),
- PWLPT_BEZIERTO),
-
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.15f,
- crBBox.top - fHeight * 0.65f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.15f,
- crBBox.top - fHeight * 0.65f + fHeight * 0.15f * 0.4f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.6f + fWidth * 0.25f * 0.4f,
- crBBox.top - fHeight * 0.5f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.6f, crBBox.top - fHeight * 0.5f),
- PWLPT_BEZIERTO),
-
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
- crBBox.top - fHeight * 0.5f + fWidth * 0.04f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.4f,
- crBBox.top - fHeight * 0.5f + fWidth * 0.04f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.5f),
- PWLPT_BEZIERTO),
-
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.5f, crBBox.top - fHeight * 0.65f),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.5f,
- crBBox.bottom + fHeight * 0.1f),
- PWLPT_LINETO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 24);
- else
- GetPathDataFromArray(path, PathArray, 24);
-}
-
-void CPWL_Utils::GetGraphics_Tag(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.1f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.1f, crBBox.top - fHeight * 0.5f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.3f,
- crBBox.bottom + fHeight * 0.1f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.1f,
- crBBox.bottom + fHeight * 0.1f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.1f, crBBox.top - fHeight * 0.1f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.1f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.3f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.2f, crBBox.top - fHeight * 0.3f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.5f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.2f, crBBox.top - fHeight * 0.5f),
- PWLPT_LINETO),
- CPWL_PathData(
- CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.7f),
- PWLPT_MOVETO),
- CPWL_PathData(
- CPWL_Point(crBBox.right - fWidth * 0.2f, crBBox.top - fHeight * 0.7f),
- PWLPT_LINETO)};
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 12);
- else
- GetPathDataFromArray(path, PathArray, 12);
-}
-
-void CPWL_Utils::GetGraphics_Foxit(CFX_ByteString& sPathData,
- CFX_PathData& path,
- const CFX_FloatRect& crBBox,
- const PWL_PATH_TYPE type) {
- FX_FLOAT fOutWidth = crBBox.right - crBBox.left;
- FX_FLOAT fOutHeight = crBBox.top - crBBox.bottom;
-
- CFX_FloatRect crInBox = crBBox;
- crInBox.left = crBBox.left + fOutWidth * 0.08f;
- crInBox.right = crBBox.right - fOutWidth * 0.08f;
- crInBox.top = crBBox.top - fOutHeight * 0.08f;
- crInBox.bottom = crBBox.bottom + fOutHeight * 0.08f;
-
- FX_FLOAT fWidth = crInBox.right - crInBox.left;
- FX_FLOAT fHeight = crInBox.top - crInBox.bottom;
-
- CPWL_PathData PathArray[] = {
- CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top), PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.45f, crInBox.top),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.45f,
- crInBox.top - FX_BEZIER * fHeight * 0.4f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crInBox.left + fWidth * 0.45f - FX_BEZIER * fWidth * 0.45f,
- crInBox.top - fHeight * 0.4f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight * 0.4f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top), PWLPT_LINETO),
-
- CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f, crInBox.top),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.75f, crInBox.top),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.75f,
- crInBox.top - FX_BEZIER * fHeight * 0.7f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crInBox.left + fWidth * 0.75f - FX_BEZIER * fWidth * 0.75f,
- crInBox.top - fHeight * 0.7f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight * 0.7f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight * 0.55f),
- PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crInBox.left + FX_BEZIER * fWidth * 0.60f,
- crInBox.top - fHeight * 0.55f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f,
- crInBox.top - FX_BEZIER * fHeight * 0.55f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f, crInBox.top),
- PWLPT_BEZIERTO),
-
- CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.90f, crInBox.top),
- PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.90f,
- crInBox.top - FX_BEZIER * fHeight * 0.85f),
- PWLPT_BEZIERTO),
- CPWL_PathData(
- CPWL_Point(crInBox.left + fWidth * 0.90f - FX_BEZIER * fWidth * 0.90f,
- crInBox.top - fHeight * 0.85f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight * 0.85f),
- PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crInBox.left, crInBox.bottom), PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crInBox.right, crInBox.bottom), PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crInBox.right, crInBox.top), PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.90f, crInBox.top),
- PWLPT_LINETO),
- };
-
- if (type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 23);
- else
- GetPathDataFromArray(path, PathArray, 23);
-}
-
-void CPWL_Color::ConvertColorType(int32_t other_nColorType) {
- switch (other_nColorType) {
- case COLORTYPE_TRANSPARENT:
- break;
- case COLORTYPE_GRAY:
- switch (other_nColorType) {
- case COLORTYPE_RGB:
- CPWL_Utils::ConvertGRAY2RGB(fColor1, fColor1, fColor2, fColor3);
- break;
- case COLORTYPE_CMYK:
- CPWL_Utils::ConvertGRAY2CMYK(fColor1, fColor1, fColor2, fColor3,
- fColor4);
- break;
- }
- break;
- case COLORTYPE_RGB:
- switch (other_nColorType) {
- case COLORTYPE_GRAY:
- CPWL_Utils::ConvertRGB2GRAY(fColor1, fColor2, fColor3, fColor1);
- break;
- case COLORTYPE_CMYK:
- CPWL_Utils::ConvertRGB2CMYK(fColor1, fColor2, fColor3, fColor1,
- fColor2, fColor3, fColor4);
- break;
- }
- break;
- case COLORTYPE_CMYK:
- switch (other_nColorType) {
- case COLORTYPE_GRAY:
- CPWL_Utils::ConvertCMYK2GRAY(fColor1, fColor2, fColor3, fColor4,
- fColor1);
- break;
- case COLORTYPE_RGB:
- CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4,
- fColor1, fColor2, fColor3);
- break;
- }
- break;
- }
- nColorType = other_nColorType;
-}
diff --git a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
deleted file mode 100644
index 28bd0e04ed..0000000000
--- a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
+++ /dev/null
@@ -1,1041 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include <map>
-
-#include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
-#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
-
-static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap() {
- // Leak the object at shutdown.
- static auto timeMap = new std::map<int32_t, CPWL_Timer*>;
- return *timeMap;
-}
-
-CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached,
- IFX_SystemHandler* pSystemHandler)
- : m_nTimerID(0), m_pAttached(pAttached), m_pSystemHandler(pSystemHandler) {
- ASSERT(m_pAttached);
- ASSERT(m_pSystemHandler);
-}
-
-CPWL_Timer::~CPWL_Timer() {
- KillPWLTimer();
-}
-
-int32_t CPWL_Timer::SetPWLTimer(int32_t nElapse) {
- if (m_nTimerID != 0)
- KillPWLTimer();
- m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc);
-
- GetPWLTimeMap()[m_nTimerID] = this;
- return m_nTimerID;
-}
-
-void CPWL_Timer::KillPWLTimer() {
- if (m_nTimerID == 0)
- return;
-
- m_pSystemHandler->KillTimer(m_nTimerID);
- GetPWLTimeMap().erase(m_nTimerID);
- m_nTimerID = 0;
-}
-
-void CPWL_Timer::TimerProc(int32_t idEvent) {
- auto it = GetPWLTimeMap().find(idEvent);
- if (it == GetPWLTimeMap().end())
- return;
-
- CPWL_Timer* pTimer = it->second;
- if (pTimer->m_pAttached)
- pTimer->m_pAttached->TimerProc();
-}
-
-CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL) {}
-
-CPWL_TimerHandler::~CPWL_TimerHandler() {
- delete m_pTimer;
-}
-
-void CPWL_TimerHandler::BeginTimer(int32_t nElapse) {
- if (!m_pTimer)
- m_pTimer = new CPWL_Timer(this, GetSystemHandler());
-
- if (m_pTimer)
- m_pTimer->SetPWLTimer(nElapse);
-}
-
-void CPWL_TimerHandler::EndTimer() {
- if (m_pTimer)
- m_pTimer->KillPWLTimer();
-}
-
-void CPWL_TimerHandler::TimerProc() {}
-
-class CPWL_MsgControl {
- friend class CPWL_Wnd;
-
- public:
- explicit CPWL_MsgControl(CPWL_Wnd* pWnd) {
- m_pCreatedWnd = pWnd;
- Default();
- }
-
- ~CPWL_MsgControl() {
- Default();
- }
-
- void Default() {
- m_aMousePath.RemoveAll();
- m_aKeyboardPath.RemoveAll();
- m_pMainMouseWnd = NULL;
- m_pMainKeyboardWnd = NULL;
- }
-
- FX_BOOL IsWndCreated(const CPWL_Wnd* pWnd) const {
- return m_pCreatedWnd == pWnd;
- }
-
- FX_BOOL IsMainCaptureMouse(const CPWL_Wnd* pWnd) const {
- return pWnd == m_pMainMouseWnd;
- }
-
- FX_BOOL IsWndCaptureMouse(const CPWL_Wnd* pWnd) const {
- if (pWnd) {
- for (int32_t i = 0, sz = m_aMousePath.GetSize(); i < sz; i++) {
- if (m_aMousePath.GetAt(i) == pWnd)
- return TRUE;
- }
- }
-
- return FALSE;
- }
-
- FX_BOOL IsMainCaptureKeyboard(const CPWL_Wnd* pWnd) const {
- return pWnd == m_pMainKeyboardWnd;
- }
-
- FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const {
- if (pWnd) {
- for (int32_t i = 0, sz = m_aKeyboardPath.GetSize(); i < sz; i++) {
- if (m_aKeyboardPath.GetAt(i) == pWnd)
- return TRUE;
- }
- }
-
- return FALSE;
- }
-
- void SetFocus(CPWL_Wnd* pWnd) {
- m_aKeyboardPath.RemoveAll();
-
- if (pWnd) {
- m_pMainKeyboardWnd = pWnd;
-
- CPWL_Wnd* pParent = pWnd;
- while (pParent) {
- m_aKeyboardPath.Add(pParent);
- pParent = pParent->GetParentWindow();
- }
-
- pWnd->OnSetFocus();
- }
- }
-
- void KillFocus() {
- if (m_aKeyboardPath.GetSize() > 0)
- if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0))
- pWnd->OnKillFocus();
-
- m_pMainKeyboardWnd = NULL;
- m_aKeyboardPath.RemoveAll();
- }
-
- void SetCapture(CPWL_Wnd* pWnd) {
- m_aMousePath.RemoveAll();
-
- if (pWnd) {
- m_pMainMouseWnd = pWnd;
-
- CPWL_Wnd* pParent = pWnd;
- while (pParent) {
- m_aMousePath.Add(pParent);
- pParent = pParent->GetParentWindow();
- }
- }
- }
-
- void ReleaseCapture() {
- m_pMainMouseWnd = NULL;
- m_aMousePath.RemoveAll();
- }
-
- private:
- CFX_ArrayTemplate<CPWL_Wnd*> m_aMousePath;
- CFX_ArrayTemplate<CPWL_Wnd*> m_aKeyboardPath;
- CPWL_Wnd* m_pCreatedWnd;
- CPWL_Wnd* m_pMainMouseWnd;
- CPWL_Wnd* m_pMainKeyboardWnd;
-};
-
-CPWL_Wnd::CPWL_Wnd()
- : m_pVScrollBar(NULL),
- m_rcWindow(),
- m_rcClip(),
- m_bCreated(FALSE),
- m_bVisible(FALSE),
- m_bNotifying(FALSE),
- m_bEnabled(TRUE) {}
-
-CPWL_Wnd::~CPWL_Wnd() {
- ASSERT(m_bCreated == FALSE);
-}
-
-CFX_ByteString CPWL_Wnd::GetClassName() const {
- return "CPWL_Wnd";
-}
-
-void CPWL_Wnd::Create(const PWL_CREATEPARAM& cp) {
- if (!IsValid()) {
- m_sPrivateParam = cp;
-
- OnCreate(m_sPrivateParam);
-
- m_sPrivateParam.rcRectWnd.Normalize();
- m_rcWindow = m_sPrivateParam.rcRectWnd;
- m_rcClip = CPWL_Utils::InflateRect(m_rcWindow, 1.0f);
-
- CreateMsgControl();
-
- if (m_sPrivateParam.pParentWnd)
- m_sPrivateParam.pParentWnd->OnNotify(this, PNM_ADDCHILD);
-
- PWL_CREATEPARAM ccp = m_sPrivateParam;
-
- ccp.dwFlags &= 0xFFFF0000L; // remove sub styles
- ccp.mtChild = CFX_Matrix(1, 0, 0, 1, 0, 0);
-
- CreateScrollBar(ccp);
- CreateChildWnd(ccp);
-
- m_bVisible = HasFlag(PWS_VISIBLE);
-
- OnCreated();
-
- RePosChildWnd();
- m_bCreated = TRUE;
- }
-}
-
-void CPWL_Wnd::OnCreate(PWL_CREATEPARAM& cp) {}
-
-void CPWL_Wnd::OnCreated() {}
-
-void CPWL_Wnd::OnDestroy() {}
-
-void CPWL_Wnd::InvalidateFocusHandler(IPWL_FocusHandler* handler) {
- if (m_sPrivateParam.pFocusHandler == handler)
- m_sPrivateParam.pFocusHandler = nullptr;
-}
-
-void CPWL_Wnd::InvalidateProvider(IPWL_Provider* provider) {
- if (m_sPrivateParam.pProvider == provider)
- m_sPrivateParam.pProvider = nullptr;
-}
-
-void CPWL_Wnd::Destroy() {
- KillFocus();
-
- OnDestroy();
-
- if (m_bCreated) {
- for (int32_t i = m_aChildren.GetSize() - 1; i >= 0; i--) {
- if (CPWL_Wnd* pChild = m_aChildren[i]) {
- pChild->Destroy();
- delete pChild;
- pChild = NULL;
- }
- }
-
- if (m_sPrivateParam.pParentWnd)
- m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD);
- m_bCreated = FALSE;
- }
-
- DestroyMsgControl();
-
- FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM));
- m_aChildren.RemoveAll();
- m_pVScrollBar = NULL;
-}
-
-void CPWL_Wnd::Move(const CFX_FloatRect& rcNew,
- FX_BOOL bReset,
- FX_BOOL bRefresh) {
- if (IsValid()) {
- CFX_FloatRect rcOld = GetWindowRect();
-
- m_rcWindow = rcNew;
- m_rcWindow.Normalize();
-
- if (rcOld.left != rcNew.left || rcOld.right != rcNew.right ||
- rcOld.top != rcNew.top || rcOld.bottom != rcNew.bottom) {
- if (bReset) {
- RePosChildWnd();
- }
- }
- if (bRefresh) {
- InvalidateRectMove(rcOld, rcNew);
- }
-
- m_sPrivateParam.rcRectWnd = m_rcWindow;
- }
-}
-
-void CPWL_Wnd::InvalidateRectMove(const CFX_FloatRect& rcOld,
- const CFX_FloatRect& rcNew) {
- CFX_FloatRect rcUnion = rcOld;
- rcUnion.Union(rcNew);
-
- InvalidateRect(&rcUnion);
-}
-
-void CPWL_Wnd::GetAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- if (IsValid() && IsVisible()) {
- GetThisAppearanceStream(sAppStream);
- GetChildAppearanceStream(sAppStream);
- }
-}
-
-// if don't set,Get default apperance stream
-void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- CFX_FloatRect rectWnd = GetWindowRect();
- if (!rectWnd.IsEmpty()) {
- CFX_ByteTextBuf sThis;
-
- if (HasFlag(PWS_BACKGROUND))
- sThis << CPWL_Utils::GetRectFillAppStream(rectWnd, GetBackgroundColor());
-
- if (HasFlag(PWS_BORDER)) {
- sThis << CPWL_Utils::GetBorderAppStream(
- rectWnd, (FX_FLOAT)GetBorderWidth(), GetBorderColor(),
- GetBorderLeftTopColor(GetBorderStyle()),
- GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(),
- GetBorderDash());
- }
-
- sAppStream << sThis;
- }
-}
-
-void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf& sAppStream) {
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- pChild->GetAppearanceStream(sAppStream);
- }
- }
-}
-
-void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- if (IsValid() && IsVisible()) {
- DrawThisAppearance(pDevice, pUser2Device);
- DrawChildAppearance(pDevice, pUser2Device);
- }
-}
-
-void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- CFX_FloatRect rectWnd = GetWindowRect();
- if (!rectWnd.IsEmpty()) {
- if (HasFlag(PWS_BACKGROUND)) {
- CFX_FloatRect rcClient = CPWL_Utils::DeflateRect(
- rectWnd, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient,
- GetBackgroundColor(), GetTransparency());
- }
-
- if (HasFlag(PWS_BORDER))
- CPWL_Utils::DrawBorder(pDevice, pUser2Device, rectWnd,
- (FX_FLOAT)GetBorderWidth(), GetBorderColor(),
- GetBorderLeftTopColor(GetBorderStyle()),
- GetBorderRightBottomColor(GetBorderStyle()),
- GetBorderStyle(), GetTransparency());
- }
-}
-
-void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice,
- CFX_Matrix* pUser2Device) {
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- CFX_Matrix mt = pChild->GetChildMatrix();
- if (mt.IsIdentity()) {
- pChild->DrawAppearance(pDevice, pUser2Device);
- } else {
- mt.Concat(*pUser2Device);
- pChild->DrawAppearance(pDevice, &mt);
- }
- }
- }
-}
-
-void CPWL_Wnd::InvalidateRect(CFX_FloatRect* pRect) {
- if (IsValid()) {
- CFX_FloatRect rcRefresh = pRect ? *pRect : GetWindowRect();
-
- if (!HasFlag(PWS_NOREFRESHCLIP)) {
- CFX_FloatRect rcClip = GetClipRect();
- if (!rcClip.IsEmpty()) {
- rcRefresh.Intersect(rcClip);
- }
- }
-
- FX_RECT rcWin = PWLtoWnd(rcRefresh);
- rcWin.left -= PWL_INVALIDATE_INFLATE;
- rcWin.top -= PWL_INVALIDATE_INFLATE;
- rcWin.right += PWL_INVALIDATE_INFLATE;
- rcWin.bottom += PWL_INVALIDATE_INFLATE;
-
- if (IFX_SystemHandler* pSH = GetSystemHandler()) {
- if (FX_HWND hWnd = GetAttachedHWnd()) {
- pSH->InvalidateRect(hWnd, rcWin);
- }
- }
- }
-}
-
-#define PWL_IMPLEMENT_KEY_METHOD(key_method_name) \
- FX_BOOL CPWL_Wnd::key_method_name(FX_WORD nChar, FX_DWORD nFlag) { \
- if (IsValid() && IsVisible() && IsEnabled()) { \
- if (IsWndCaptureKeyboard(this)) { \
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \
- if (IsWndCaptureKeyboard(pChild)) { \
- return pChild->key_method_name(nChar, nFlag); \
- } \
- } \
- } \
- } \
- } \
- return FALSE; \
- }
-
-#define PWL_IMPLEMENT_MOUSE_METHOD(mouse_method_name) \
- FX_BOOL CPWL_Wnd::mouse_method_name(const CFX_FloatPoint& point, \
- FX_DWORD nFlag) { \
- if (IsValid() && IsVisible() && IsEnabled()) { \
- if (IsWndCaptureMouse(this)) { \
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \
- if (IsWndCaptureMouse(pChild)) { \
- return pChild->mouse_method_name(pChild->ParentToChild(point), \
- nFlag); \
- } \
- } \
- } \
- SetCursor(); \
- } else { \
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \
- if (pChild->WndHitTest(pChild->ParentToChild(point))) { \
- return pChild->mouse_method_name(pChild->ParentToChild(point), \
- nFlag); \
- } \
- } \
- } \
- if (WndHitTest(point)) \
- SetCursor(); \
- } \
- } \
- return FALSE; \
- }
-
-PWL_IMPLEMENT_KEY_METHOD(OnKeyDown)
-PWL_IMPLEMENT_KEY_METHOD(OnKeyUp)
-PWL_IMPLEMENT_KEY_METHOD(OnChar)
-
-PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDblClk)
-PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDown)
-PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonUp)
-PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDblClk)
-PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDown)
-PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonUp)
-PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonDown)
-PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonUp)
-PWL_IMPLEMENT_MOUSE_METHOD(OnMouseMove)
-
-FX_BOOL CPWL_Wnd::OnMouseWheel(short zDelta,
- const CFX_FloatPoint& point,
- FX_DWORD nFlag) {
- if (IsValid() && IsVisible() && IsEnabled()) {
- SetCursor();
- if (IsWndCaptureKeyboard(this)) {
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- if (IsWndCaptureKeyboard(pChild)) {
- return pChild->OnMouseWheel(zDelta, pChild->ParentToChild(point),
- nFlag);
- }
- }
- }
- }
- }
- return FALSE;
-}
-
-void CPWL_Wnd::AddChild(CPWL_Wnd* pWnd) {
- m_aChildren.Add(pWnd);
-}
-
-void CPWL_Wnd::RemoveChild(CPWL_Wnd* pWnd) {
- for (int32_t i = m_aChildren.GetSize() - 1; i >= 0; i--) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- if (pChild == pWnd) {
- m_aChildren.RemoveAt(i);
- break;
- }
- }
- }
-}
-
-void CPWL_Wnd::OnNotify(CPWL_Wnd* pWnd,
- FX_DWORD msg,
- intptr_t wParam,
- intptr_t lParam) {
- switch (msg) {
- case PNM_ADDCHILD:
- AddChild(pWnd);
- break;
- case PNM_REMOVECHILD:
- RemoveChild(pWnd);
- break;
- default:
- break;
- }
-}
-
-FX_BOOL CPWL_Wnd::IsValid() const {
- return m_bCreated;
-}
-
-const PWL_CREATEPARAM& CPWL_Wnd::GetCreationParam() const {
- return m_sPrivateParam;
-}
-
-CPWL_Wnd* CPWL_Wnd::GetParentWindow() const {
- return m_sPrivateParam.pParentWnd;
-}
-
-CFX_FloatRect CPWL_Wnd::GetWindowRect() const {
- return m_rcWindow;
-}
-
-CFX_FloatRect CPWL_Wnd::GetClientRect() const {
- CFX_FloatRect rcWindow = GetWindowRect();
- CFX_FloatRect rcClient = CPWL_Utils::DeflateRect(
- rcWindow, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
- if (CPWL_ScrollBar* pVSB = GetVScrollBar())
- rcClient.right -= pVSB->GetScrollBarWidth();
-
- rcClient.Normalize();
- return rcWindow.Contains(rcClient) ? rcClient : CFX_FloatRect();
-}
-
-CFX_FloatPoint CPWL_Wnd::GetCenterPoint() const {
- CFX_FloatRect rcClient = GetClientRect();
- return CFX_FloatPoint((rcClient.left + rcClient.right) * 0.5f,
- (rcClient.top + rcClient.bottom) * 0.5f);
-}
-
-FX_BOOL CPWL_Wnd::HasFlag(FX_DWORD dwFlags) const {
- return (m_sPrivateParam.dwFlags & dwFlags) != 0;
-}
-
-void CPWL_Wnd::RemoveFlag(FX_DWORD dwFlags) {
- m_sPrivateParam.dwFlags &= ~dwFlags;
-}
-
-void CPWL_Wnd::AddFlag(FX_DWORD dwFlags) {
- m_sPrivateParam.dwFlags |= dwFlags;
-}
-
-CPWL_Color CPWL_Wnd::GetBackgroundColor() const {
- return m_sPrivateParam.sBackgroundColor;
-}
-
-void CPWL_Wnd::SetBackgroundColor(const CPWL_Color& color) {
- m_sPrivateParam.sBackgroundColor = color;
-}
-
-void CPWL_Wnd::SetTextColor(const CPWL_Color& color) {
- m_sPrivateParam.sTextColor = color;
-}
-
-void CPWL_Wnd::SetTextStrokeColor(const CPWL_Color& color) {
- m_sPrivateParam.sTextStrokeColor = color;
-}
-
-CPWL_Color CPWL_Wnd::GetTextColor() const {
- return m_sPrivateParam.sTextColor;
-}
-
-CPWL_Color CPWL_Wnd::GetTextStrokeColor() const {
- return m_sPrivateParam.sTextStrokeColor;
-}
-
-int32_t CPWL_Wnd::GetBorderStyle() const {
- return m_sPrivateParam.nBorderStyle;
-}
-
-void CPWL_Wnd::SetBorderStyle(int32_t nBorderStyle) {
- if (HasFlag(PWS_BORDER))
- m_sPrivateParam.nBorderStyle = nBorderStyle;
-}
-
-int32_t CPWL_Wnd::GetBorderWidth() const {
- if (HasFlag(PWS_BORDER))
- return m_sPrivateParam.dwBorderWidth;
-
- return 0;
-}
-
-int32_t CPWL_Wnd::GetInnerBorderWidth() const {
- return 0;
-}
-
-CPWL_Color CPWL_Wnd::GetBorderColor() const {
- if (HasFlag(PWS_BORDER))
- return m_sPrivateParam.sBorderColor;
-
- return CPWL_Color();
-}
-
-const CPWL_Dash& CPWL_Wnd::GetBorderDash() const {
- return m_sPrivateParam.sDash;
-}
-
-void* CPWL_Wnd::GetAttachedData() const {
- return m_sPrivateParam.pAttachedData;
-}
-
-CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const {
- if (HasFlag(PWS_VSCROLL))
- return m_pVScrollBar;
-
- return NULL;
-}
-
-void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM& cp) {
- CreateVScrollBar(cp);
-}
-
-void CPWL_Wnd::CreateVScrollBar(const PWL_CREATEPARAM& cp) {
- if (!m_pVScrollBar && HasFlag(PWS_VSCROLL)) {
- PWL_CREATEPARAM scp = cp;
-
- // flags
- scp.dwFlags =
- PWS_CHILD | PWS_BACKGROUND | PWS_AUTOTRANSPARENT | PWS_NOREFRESHCLIP;
-
- scp.pParentWnd = this;
- scp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
- scp.eCursorType = FXCT_ARROW;
- scp.nTransparency = PWL_SCROLLBAR_TRANSPARANCY;
-
- m_pVScrollBar = new CPWL_ScrollBar(SBT_VSCROLL);
- m_pVScrollBar->Create(scp);
- }
-}
-
-void CPWL_Wnd::SetCapture() {
- if (CPWL_MsgControl* pMsgCtrl = GetMsgControl())
- pMsgCtrl->SetCapture(this);
-}
-
-void CPWL_Wnd::ReleaseCapture() {
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++)
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- pChild->ReleaseCapture();
-
- if (CPWL_MsgControl* pMsgCtrl = GetMsgControl())
- pMsgCtrl->ReleaseCapture();
-}
-
-void CPWL_Wnd::SetFocus() {
- if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) {
- if (!pMsgCtrl->IsMainCaptureKeyboard(this))
- pMsgCtrl->KillFocus();
- pMsgCtrl->SetFocus(this);
- }
-}
-
-void CPWL_Wnd::KillFocus() {
- if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) {
- if (pMsgCtrl->IsWndCaptureKeyboard(this))
- pMsgCtrl->KillFocus();
- }
-}
-
-void CPWL_Wnd::OnSetFocus() {}
-
-void CPWL_Wnd::OnKillFocus() {}
-
-FX_BOOL CPWL_Wnd::WndHitTest(const CFX_FloatPoint& point) const {
- return IsValid() && IsVisible() && GetWindowRect().Contains(point.x, point.y);
-}
-
-FX_BOOL CPWL_Wnd::ClientHitTest(const CFX_FloatPoint& point) const {
- return IsValid() && IsVisible() && GetClientRect().Contains(point.x, point.y);
-}
-
-const CPWL_Wnd* CPWL_Wnd::GetRootWnd() const {
- if (m_sPrivateParam.pParentWnd)
- return m_sPrivateParam.pParentWnd->GetRootWnd();
-
- return this;
-}
-
-void CPWL_Wnd::SetVisible(FX_BOOL bVisible) {
- if (IsValid()) {
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- pChild->SetVisible(bVisible);
- }
- }
-
- if (bVisible != m_bVisible) {
- m_bVisible = bVisible;
- RePosChildWnd();
- InvalidateRect();
- }
- }
-}
-
-void CPWL_Wnd::SetClipRect(const CFX_FloatRect& rect) {
- m_rcClip = rect;
- m_rcClip.Normalize();
-}
-
-const CFX_FloatRect& CPWL_Wnd::GetClipRect() const {
- return m_rcClip;
-}
-
-FX_BOOL CPWL_Wnd::IsReadOnly() const {
- return HasFlag(PWS_READONLY);
-}
-
-void CPWL_Wnd::RePosChildWnd() {
- CFX_FloatRect rcContent = CPWL_Utils::DeflateRect(
- GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
-
- CPWL_ScrollBar* pVSB = GetVScrollBar();
-
- CFX_FloatRect rcVScroll =
- CFX_FloatRect(rcContent.right - PWL_SCROLLBAR_WIDTH, rcContent.bottom,
- rcContent.right - 1.0f, rcContent.top);
-
- if (pVSB)
- pVSB->Move(rcVScroll, TRUE, FALSE);
-}
-
-void CPWL_Wnd::CreateChildWnd(const PWL_CREATEPARAM& cp) {}
-
-void CPWL_Wnd::SetCursor() {
- if (IsValid()) {
- if (IFX_SystemHandler* pSH = GetSystemHandler()) {
- int32_t nCursorType = GetCreationParam().eCursorType;
- pSH->SetCursor(nCursorType);
- }
- }
-}
-
-void CPWL_Wnd::CreateMsgControl() {
- if (!m_sPrivateParam.pMsgControl)
- m_sPrivateParam.pMsgControl = new CPWL_MsgControl(this);
-}
-
-void CPWL_Wnd::DestroyMsgControl() {
- if (CPWL_MsgControl* pMsgControl = GetMsgControl())
- if (pMsgControl->IsWndCreated(this))
- delete pMsgControl;
-}
-
-CPWL_MsgControl* CPWL_Wnd::GetMsgControl() const {
- return m_sPrivateParam.pMsgControl;
-}
-
-FX_BOOL CPWL_Wnd::IsCaptureMouse() const {
- return IsWndCaptureMouse(this);
-}
-
-FX_BOOL CPWL_Wnd::IsWndCaptureMouse(const CPWL_Wnd* pWnd) const {
- if (CPWL_MsgControl* pCtrl = GetMsgControl())
- return pCtrl->IsWndCaptureMouse(pWnd);
-
- return FALSE;
-}
-
-FX_BOOL CPWL_Wnd::IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const {
- if (CPWL_MsgControl* pCtrl = GetMsgControl())
- return pCtrl->IsWndCaptureKeyboard(pWnd);
-
- return FALSE;
-}
-
-FX_BOOL CPWL_Wnd::IsFocused() const {
- if (CPWL_MsgControl* pCtrl = GetMsgControl())
- return pCtrl->IsMainCaptureKeyboard(this);
-
- return FALSE;
-}
-
-CFX_FloatRect CPWL_Wnd::GetFocusRect() const {
- return CPWL_Utils::InflateRect(GetWindowRect(), 1);
-}
-
-FX_FLOAT CPWL_Wnd::GetFontSize() const {
- return m_sPrivateParam.fFontSize;
-}
-
-void CPWL_Wnd::SetFontSize(FX_FLOAT fFontSize) {
- m_sPrivateParam.fFontSize = fFontSize;
-}
-
-IFX_SystemHandler* CPWL_Wnd::GetSystemHandler() const {
- return m_sPrivateParam.pSystemHandler;
-}
-
-IPWL_FocusHandler* CPWL_Wnd::GetFocusHandler() const {
- return m_sPrivateParam.pFocusHandler;
-}
-
-IPWL_Provider* CPWL_Wnd::GetProvider() const {
- return m_sPrivateParam.pProvider;
-}
-
-IFX_Edit_FontMap* CPWL_Wnd::GetFontMap() const {
- return m_sPrivateParam.pFontMap;
-}
-
-CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(int32_t nBorderStyle) const {
- CPWL_Color color;
-
- 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;
- }
-
- return color;
-}
-
-CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(int32_t nBorderStyle) const {
- CPWL_Color color;
-
- 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;
- }
-
- return color;
-}
-
-int32_t CPWL_Wnd::GetTransparency() {
- return m_sPrivateParam.nTransparency;
-}
-
-void CPWL_Wnd::SetTransparency(int32_t nTransparency) {
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- pChild->SetTransparency(nTransparency);
- }
- }
-
- m_sPrivateParam.nTransparency = nTransparency;
-}
-
-CFX_Matrix CPWL_Wnd::GetWindowMatrix() const {
- CFX_Matrix mt = GetChildToRoot();
-
- if (IPWL_Provider* pProvider = GetProvider()) {
- mt.Concat(pProvider->GetWindowMatrix(GetAttachedData()));
- return mt;
- }
-
- return mt;
-}
-
-void CPWL_Wnd::PWLtoWnd(const CFX_FloatPoint& point,
- int32_t& x,
- int32_t& y) const {
- CFX_Matrix mt = GetWindowMatrix();
- CFX_FloatPoint pt = point;
- mt.Transform(pt.x, pt.y);
- x = (int32_t)(pt.x + 0.5);
- y = (int32_t)(pt.y + 0.5);
-}
-
-FX_RECT CPWL_Wnd::PWLtoWnd(const CFX_FloatRect& rect) const {
- CFX_FloatRect rcTemp = rect;
- CFX_Matrix mt = GetWindowMatrix();
- mt.TransformRect(rcTemp);
- return FX_RECT((int32_t)(rcTemp.left + 0.5), (int32_t)(rcTemp.bottom + 0.5),
- (int32_t)(rcTemp.right + 0.5), (int32_t)(rcTemp.top + 0.5));
-}
-
-FX_HWND CPWL_Wnd::GetAttachedHWnd() const {
- return m_sPrivateParam.hAttachedWnd;
-}
-
-CFX_FloatPoint CPWL_Wnd::ChildToParent(const CFX_FloatPoint& point) const {
- CFX_Matrix mt = GetChildMatrix();
- if (mt.IsIdentity())
- return point;
-
- CFX_FloatPoint pt = point;
- mt.Transform(pt.x, pt.y);
- return pt;
-}
-
-CFX_FloatRect CPWL_Wnd::ChildToParent(const CFX_FloatRect& rect) const {
- CFX_Matrix mt = GetChildMatrix();
- if (mt.IsIdentity())
- return rect;
-
- CFX_FloatRect rc = rect;
- mt.TransformRect(rc);
- return rc;
-}
-
-CFX_FloatPoint CPWL_Wnd::ParentToChild(const CFX_FloatPoint& point) const {
- CFX_Matrix mt = GetChildMatrix();
- if (mt.IsIdentity())
- return point;
-
- mt.SetReverse(mt);
- CFX_FloatPoint pt = point;
- mt.Transform(pt.x, pt.y);
- return pt;
-}
-
-CFX_FloatRect CPWL_Wnd::ParentToChild(const CFX_FloatRect& rect) const {
- CFX_Matrix mt = GetChildMatrix();
- if (mt.IsIdentity())
- return rect;
-
- mt.SetReverse(mt);
- CFX_FloatRect rc = rect;
- mt.TransformRect(rc);
- return rc;
-}
-
-CFX_Matrix CPWL_Wnd::GetChildToRoot() const {
- CFX_Matrix mt(1, 0, 0, 1, 0, 0);
- if (HasFlag(PWS_CHILD)) {
- const CPWL_Wnd* pParent = this;
- while (pParent) {
- mt.Concat(pParent->GetChildMatrix());
- pParent = pParent->GetParentWindow();
- }
- }
- return mt;
-}
-
-CFX_Matrix CPWL_Wnd::GetChildMatrix() const {
- if (HasFlag(PWS_CHILD))
- return m_sPrivateParam.mtChild;
-
- return CFX_Matrix(1, 0, 0, 1, 0, 0);
-}
-
-void CPWL_Wnd::SetChildMatrix(const CFX_Matrix& mt) {
- m_sPrivateParam.mtChild = mt;
-}
-
-const CPWL_Wnd* CPWL_Wnd::GetFocused() const {
- if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) {
- return pMsgCtrl->m_pMainKeyboardWnd;
- }
-
- return NULL;
-}
-
-void CPWL_Wnd::EnableWindow(FX_BOOL bEnable) {
- if (m_bEnabled != bEnable) {
- for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
- pChild->EnableWindow(bEnable);
- }
- }
-
- m_bEnabled = bEnable;
-
- if (bEnable)
- OnEnabled();
- else
- OnDisabled();
- }
-}
-
-FX_BOOL CPWL_Wnd::IsEnabled() {
- return m_bEnabled;
-}
-
-void CPWL_Wnd::OnEnabled() {}
-
-void CPWL_Wnd::OnDisabled() {}
-
-FX_BOOL CPWL_Wnd::IsCTRLpressed(FX_DWORD nFlag) const {
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
- return pSystemHandler->IsCTRLKeyDown(nFlag);
- }
-
- return FALSE;
-}
-
-FX_BOOL CPWL_Wnd::IsSHIFTpressed(FX_DWORD nFlag) const {
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
- return pSystemHandler->IsSHIFTKeyDown(nFlag);
- }
-
- return FALSE;
-}
-
-FX_BOOL CPWL_Wnd::IsALTpressed(FX_DWORD nFlag) const {
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
- return pSystemHandler->IsALTKeyDown(nFlag);
- }
-
- return FALSE;
-}
-
-FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const {
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
- return pSystemHandler->IsINSERTKeyDown(nFlag);
- }
-
- return FALSE;
-}