Convert all line endings to LF.
diff --git a/fpdfsdk/src/pdfwindow/PWL_Button.cpp b/fpdfsdk/src/pdfwindow/PWL_Button.cpp
index c71e5cc..f95469a 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Button.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Button.cpp
@@ -1,53 +1,53 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_Button.h"
-#include "../../include/pdfwindow/PWL_Utils.h"
-
-/* ------------------------------- CPWL_Button ---------------------------------- */
-
-CPWL_Button::CPWL_Button() :
- m_bMouseDown(FALSE)
-{
-}
-
-CPWL_Button::~CPWL_Button()
-{
-// PWL_TRACE("~CPWL_Button\n");
-}
-
-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 CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonDown(point, nFlag);
-
- m_bMouseDown = TRUE;
- SetCapture();
-
- return TRUE;
-}
-
-FX_BOOL CPWL_Button::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonUp(point, nFlag);
-
- ReleaseCapture();
- m_bMouseDown = FALSE;
-
- return TRUE;
-}
-
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_Button.h"
+#include "../../include/pdfwindow/PWL_Utils.h"
+
+/* ------------------------------- CPWL_Button ---------------------------------- */
+
+CPWL_Button::CPWL_Button() :
+ m_bMouseDown(FALSE)
+{
+}
+
+CPWL_Button::~CPWL_Button()
+{
+// PWL_TRACE("~CPWL_Button\n");
+}
+
+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 CPDF_Point & point, FX_DWORD nFlag)
+{
+ CPWL_Wnd::OnLButtonDown(point, nFlag);
+
+ m_bMouseDown = TRUE;
+ SetCapture();
+
+ return TRUE;
+}
+
+FX_BOOL CPWL_Button::OnLButtonUp(const CPDF_Point & 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
index e54538e..cdc7d57 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Caret.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Caret.cpp
@@ -1,197 +1,197 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_Caret.h"
-#include "../../include/pdfwindow/PWL_Utils.h"
-
-#define PWL_CARET_FLASHINTERVAL 500
-
-//////////////////////////////////////////////////////////////////////
-// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
-
-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,CPDF_Point(0.0f,0.0f));
-}
-
-void CPWL_Caret::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- if (IsVisible() && m_bFlash)
- {
- CPDF_Rect rcRect = GetCaretRect();
- CPDF_Rect 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 CPDF_Point & ptOffset)
-{
- if (IsVisible() && m_bFlash)
- {
- CFX_ByteTextBuf sCaret;
-
- CPDF_Rect rcRect = GetCaretRect();
- CPDF_Rect 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 CPDF_Point & 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();
- }
-}
-
-CPDF_Rect CPWL_Caret::GetCaretRect() const
-{
- return CPDF_Rect(m_ptFoot.x,
- m_ptFoot.y,
- m_ptHead.x + this->m_fWidth,
- m_ptHead.y);
-}
-
-void CPWL_Caret::SetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const CPDF_Point & 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)
- {
- this->m_ptHead = ptHead;
- this->m_ptFoot = ptFoot;
-
- m_bFlash = TRUE;
- //Move(GetCaretRect(),FALSE,TRUE);
- Move(m_rcInvalid, FALSE, TRUE);
- }
- }
- else
- {
- this->m_ptHead = ptHead;
- this->m_ptFoot = ptFoot;
-
- EndTimer();
- BeginTimer(PWL_CARET_FLASHINTERVAL);
-
- CPWL_Wnd::SetVisible(TRUE);
- m_bFlash = TRUE;
-
- //Move(GetCaretRect(),FALSE,TRUE);
- Move(m_rcInvalid, FALSE, TRUE);
- }
- }
- else
- {
- this->m_ptHead = CPDF_Point(0,0);
- this->m_ptFoot = CPDF_Point(0,0);
-
- m_bFlash = FALSE;
- if (IsVisible())
- {
- EndTimer();
- CPWL_Wnd::SetVisible(FALSE);
- }
- }
-}
-
-void CPWL_Caret::InvalidateRect(CPDF_Rect * pRect)
-{
- if (pRect)
- {
- CPDF_Rect rcRefresh = CPWL_Utils::InflateRect(*pRect,0.5f);
- rcRefresh.top += 1;
- rcRefresh.bottom -= 1;
-
- CPWL_Wnd::InvalidateRect(&rcRefresh);
- }
- else
- CPWL_Wnd::InvalidateRect(pRect);
-}
-
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_Caret.h"
+#include "../../include/pdfwindow/PWL_Utils.h"
+
+#define PWL_CARET_FLASHINTERVAL 500
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+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,CPDF_Point(0.0f,0.0f));
+}
+
+void CPWL_Caret::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
+{
+ if (IsVisible() && m_bFlash)
+ {
+ CPDF_Rect rcRect = GetCaretRect();
+ CPDF_Rect 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 CPDF_Point & ptOffset)
+{
+ if (IsVisible() && m_bFlash)
+ {
+ CFX_ByteTextBuf sCaret;
+
+ CPDF_Rect rcRect = GetCaretRect();
+ CPDF_Rect 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 CPDF_Point & 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();
+ }
+}
+
+CPDF_Rect CPWL_Caret::GetCaretRect() const
+{
+ return CPDF_Rect(m_ptFoot.x,
+ m_ptFoot.y,
+ m_ptHead.x + this->m_fWidth,
+ m_ptHead.y);
+}
+
+void CPWL_Caret::SetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const CPDF_Point & 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)
+ {
+ this->m_ptHead = ptHead;
+ this->m_ptFoot = ptFoot;
+
+ m_bFlash = TRUE;
+ //Move(GetCaretRect(),FALSE,TRUE);
+ Move(m_rcInvalid, FALSE, TRUE);
+ }
+ }
+ else
+ {
+ this->m_ptHead = ptHead;
+ this->m_ptFoot = ptFoot;
+
+ EndTimer();
+ BeginTimer(PWL_CARET_FLASHINTERVAL);
+
+ CPWL_Wnd::SetVisible(TRUE);
+ m_bFlash = TRUE;
+
+ //Move(GetCaretRect(),FALSE,TRUE);
+ Move(m_rcInvalid, FALSE, TRUE);
+ }
+ }
+ else
+ {
+ this->m_ptHead = CPDF_Point(0,0);
+ this->m_ptFoot = CPDF_Point(0,0);
+
+ m_bFlash = FALSE;
+ if (IsVisible())
+ {
+ EndTimer();
+ CPWL_Wnd::SetVisible(FALSE);
+ }
+ }
+}
+
+void CPWL_Caret::InvalidateRect(CPDF_Rect * pRect)
+{
+ if (pRect)
+ {
+ CPDF_Rect 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
index 7650a23..020765a 100644
--- a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
@@ -1,662 +1,662 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_EditCtrl.h"
-#include "../../include/pdfwindow/PWL_Edit.h"
-#include "../../include/pdfwindow/PWL_ListBox.h"
-#include "../../include/pdfwindow/PWL_ComboBox.h"
-#include "../../include/pdfwindow/PWL_Utils.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))
-
-
-/* ---------------------------- CPWL_CBListBox ---------------------------- */
-
-FX_BOOL CPWL_CBListBox::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonUp(point,nFlag);
-
- if (m_bMouseDown)
- {
- ReleaseCapture();
- m_bMouseDown = FALSE;
-
- if (this->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::OnKeyDown(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::OnChar(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;
-}
-
-/* ---------------------------- CPWL_CBButton ---------------------------- */
-
-void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
-{
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
-
- CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();
-
- if (IsVisible() && !rectWnd.IsEmpty())
- {
- CFX_ByteTextBuf sButton;
-
- CPDF_Point ptCenter = this->GetCenterPoint();
-
- CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CPDF_Point 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, CPDF_Matrix* pUser2Device)
-{
- CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
-
- CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();
-
- if (IsVisible() && !rectWnd.IsEmpty())
- {
- CPDF_Point ptCenter = this->GetCenterPoint();
-
- CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
- CPDF_Point 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 CPDF_Point & 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 CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonUp(point, nFlag);
-
- ReleaseCapture();
-
- return TRUE;
-}
-
-/* ---------------------------- CPWL_ComboBox ---------------------------- */
-
-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(FX_LPCWSTR text)
-{
- if (m_pEdit)
- m_pEdit->SetText(text);
-}
-
-void CPWL_ComboBox::AddString(FX_LPCWSTR string)
-{
- if (m_pList)
- m_pList->AddString(string);
-}
-
-FX_INT32 CPWL_ComboBox::GetSelect() const
-{
- return m_nSelectItem;
-}
-
-void CPWL_ComboBox::SetSelect(FX_INT32 nItemIndex)
-{
- if (m_pList)
- m_pList->Select(nItemIndex);
-
- m_pEdit->SetText(m_pList->GetText());
-
- m_nSelectItem = nItemIndex;
-}
-
-void CPWL_ComboBox::SetEditSel(FX_INT32 nStartChar,FX_INT32 nEndChar)
-{
- if (m_pEdit)
- {
- m_pEdit->SetSel(nStartChar,nEndChar);
- }
-}
-
-void CPWL_ComboBox::GetEditSel(FX_INT32 & nStartChar, FX_INT32 & 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 = CPDF_Rect(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 = CPDF_Rect(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()
-{
- CPDF_Rect rcClient = GetClientRect();
-
- if (m_bPopup)
- {
- CPDF_Rect rclient = GetClientRect();
- CPDF_Rect rcButton = rclient;
- CPDF_Rect rcEdit = rcClient;
- CPDF_Rect 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
- {
- CPDF_Rect 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);
-
- CPDF_Rect 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();
-}
-
-CPDF_Rect CPWL_ComboBox::GetFocusRect() const
-{
- return CPDF_Rect();
-}
-
-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)
- {
- FX_INT32 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;
-
- CPDF_Rect 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);
- }
- }
- }
- 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;
- if (m_pList->OnKeyDown(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;
- if (m_pList->OnKeyDown(nChar,bExit,nFlag))
- {
- if (bExit) return FALSE;
- SetSelectText();
- }
- }
- return TRUE;
- }
-
- if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
- return m_pEdit->OnKeyDown(nChar,nFlag);
- else
- 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;
- FX_BOOL bExit = FALSE;
-
- if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
- {
- return m_pEdit->OnChar(nChar,nFlag);
- }
- else
- {
- if (m_pList->OnChar(nChar,bExit,nFlag))
- {
- return bExit;
- }
- else
- return FALSE;
- }
-}
-
-void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_INTPTR 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());
- m_pEdit->SelectAll();
-
- m_nSelectItem = m_pList->GetCurSel();
-}
-
-FX_BOOL CPWL_ComboBox::IsModified() const
-{
- return m_pEdit->IsModified();
-}
-
-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);
-}
-
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_EditCtrl.h"
+#include "../../include/pdfwindow/PWL_Edit.h"
+#include "../../include/pdfwindow/PWL_ListBox.h"
+#include "../../include/pdfwindow/PWL_ComboBox.h"
+#include "../../include/pdfwindow/PWL_Utils.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))
+
+
+/* ---------------------------- CPWL_CBListBox ---------------------------- */
+
+FX_BOOL CPWL_CBListBox::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
+{
+ CPWL_Wnd::OnLButtonUp(point,nFlag);
+
+ if (m_bMouseDown)
+ {
+ ReleaseCapture();
+ m_bMouseDown = FALSE;
+
+ if (this->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::OnKeyDown(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::OnChar(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;
+}
+
+/* ---------------------------- CPWL_CBButton ---------------------------- */
+
+void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
+{
+ CPWL_Wnd::GetThisAppearanceStream(sAppStream);
+
+ CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();
+
+ if (IsVisible() && !rectWnd.IsEmpty())
+ {
+ CFX_ByteTextBuf sButton;
+
+ CPDF_Point ptCenter = this->GetCenterPoint();
+
+ CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CPDF_Point 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, CPDF_Matrix* pUser2Device)
+{
+ CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
+
+ CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();
+
+ if (IsVisible() && !rectWnd.IsEmpty())
+ {
+ CPDF_Point ptCenter = this->GetCenterPoint();
+
+ CPDF_Point pt1(ptCenter.x - PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CPDF_Point pt2(ptCenter.x + PWL_CBBUTTON_TRIANGLE_HALFLEN,ptCenter.y + PWL_CBBUTTON_TRIANGLE_HALFLEN * 0.5f);
+ CPDF_Point 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 CPDF_Point & 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 CPDF_Point & point, FX_DWORD nFlag)
+{
+ CPWL_Wnd::OnLButtonUp(point, nFlag);
+
+ ReleaseCapture();
+
+ return TRUE;
+}
+
+/* ---------------------------- CPWL_ComboBox ---------------------------- */
+
+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(FX_LPCWSTR text)
+{
+ if (m_pEdit)
+ m_pEdit->SetText(text);
+}
+
+void CPWL_ComboBox::AddString(FX_LPCWSTR string)
+{
+ if (m_pList)
+ m_pList->AddString(string);
+}
+
+FX_INT32 CPWL_ComboBox::GetSelect() const
+{
+ return m_nSelectItem;
+}
+
+void CPWL_ComboBox::SetSelect(FX_INT32 nItemIndex)
+{
+ if (m_pList)
+ m_pList->Select(nItemIndex);
+
+ m_pEdit->SetText(m_pList->GetText());
+
+ m_nSelectItem = nItemIndex;
+}
+
+void CPWL_ComboBox::SetEditSel(FX_INT32 nStartChar,FX_INT32 nEndChar)
+{
+ if (m_pEdit)
+ {
+ m_pEdit->SetSel(nStartChar,nEndChar);
+ }
+}
+
+void CPWL_ComboBox::GetEditSel(FX_INT32 & nStartChar, FX_INT32 & 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 = CPDF_Rect(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 = CPDF_Rect(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()
+{
+ CPDF_Rect rcClient = GetClientRect();
+
+ if (m_bPopup)
+ {
+ CPDF_Rect rclient = GetClientRect();
+ CPDF_Rect rcButton = rclient;
+ CPDF_Rect rcEdit = rcClient;
+ CPDF_Rect 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
+ {
+ CPDF_Rect 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);
+
+ CPDF_Rect 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();
+}
+
+CPDF_Rect CPWL_ComboBox::GetFocusRect() const
+{
+ return CPDF_Rect();
+}
+
+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)
+ {
+ FX_INT32 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;
+
+ CPDF_Rect 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);
+ }
+ }
+ }
+ 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;
+ if (m_pList->OnKeyDown(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;
+ if (m_pList->OnKeyDown(nChar,bExit,nFlag))
+ {
+ if (bExit) return FALSE;
+ SetSelectText();
+ }
+ }
+ return TRUE;
+ }
+
+ if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
+ return m_pEdit->OnKeyDown(nChar,nFlag);
+ else
+ 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;
+ FX_BOOL bExit = FALSE;
+
+ if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
+ {
+ return m_pEdit->OnChar(nChar,nFlag);
+ }
+ else
+ {
+ if (m_pList->OnChar(nChar,bExit,nFlag))
+ {
+ return bExit;
+ }
+ else
+ return FALSE;
+ }
+}
+
+void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_INTPTR 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());
+ m_pEdit->SelectAll();
+
+ m_nSelectItem = m_pList->GetCurSel();
+}
+
+FX_BOOL CPWL_ComboBox::IsModified() const
+{
+ return m_pEdit->IsModified();
+}
+
+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
index 87ddd87..df59c2c 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
@@ -1,1316 +1,1316 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_EditCtrl.h"
-#include "../../include/pdfwindow/PWL_Edit.h"
-#include "../../include/pdfwindow/PWL_ScrollBar.h"
-#include "../../include/pdfwindow/PWL_Utils.h"
-#include "../../include/pdfwindow/PWL_Caret.h"
-#include "../../include/pdfwindow/PWL_FontMap.h"
-
-/* ---------------------------- CPWL_Edit ------------------------------ */
-
-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(FX_LPCWSTR csText)
-{
- CFX_WideString swText = csText;
-
- if (HasFlag(PES_RICH))
- {
- CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText);
-
- if (CXML_Element * pXML = CXML_Element::Parse((FX_LPCSTR)sValue,sValue.GetLength()))
- {
- FX_INT32 nCount = pXML->CountChildren();
- FX_BOOL bFirst = TRUE;
-
- swText.Empty();
-
- for (FX_INT32 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(FX_INT32 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);
-}
-
-void CPWL_Edit::RePosChildWnd()
-{
- if (CPWL_ScrollBar * pVSB = this->GetVScrollBar())
- {
- //if (pVSB->IsVisible())
- {
- CPDF_Rect rcWindow = m_rcOldWindow;
- CPDF_Rect rcVScroll = CPDF_Rect(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();
-}
-
-CPDF_Rect CPWL_Edit::GetClientRect() const
-{
- CPDF_Rect rcClient = CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
-
- if (CPWL_ScrollBar * pVSB = this->GetVScrollBar())
- {
- if (pVSB->IsVisible())
- {
- rcClient.right -= PWL_SCROLLBAR_WIDTH;
- }
- }
-
- return rcClient;
-}
-
-void CPWL_Edit::SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pEdit->SetAlignmentH((FX_INT32)nFormat, bPaint);
-}
-
-void CPWL_Edit::SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pEdit->SetAlignmentV((FX_INT32)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(TRUE, GetAttachedData(), 0 , swClipboard, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExit, 0);
- if (!bRC) return;
- if (bExit) return;
- }
-
- if (swClipboard.GetLength() > 0)
- {
- Clear();
- InsertText(swClipboard);
- }
-
- if (m_pFillerNotify)
- {
- FX_BOOL bExit = FALSE;
- m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit,0);
- if (bExit) return;
- }
-}
-
-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(CPDF_Rect(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);
-
- CPDF_Rect rcClient = GetClientRect();
- CFX_ByteTextBuf sLine;
-
- FX_INT32 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 (FX_INT32 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 (FX_INT32 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;
-
- CPDF_Point ptOffset = CPDF_Point(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)
- {
- CPDF_Rect rcClient = this->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, CPDF_Matrix* pUser2Device)
-{
- CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
-
- CPDF_Rect rcClient = GetClientRect();
- CFX_ByteTextBuf sLine;
-
- FX_INT32 nCharArray = m_pEdit->GetCharArray();
-
- if (nCharArray > 0)
- {
- switch (GetBorderStyle())
- {
- case PBS_SOLID:
- {
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
-
- CFX_PathData path;
- path.SetPointCount((nCharArray-1)*2);
-
- for (FX_INT32 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((nCharArray-1)*2);
-
- for (FX_INT32 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;
- }
- }
-
- CPDF_Rect 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(),this->GetTransparency()),
- CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(),this->GetTransparency()),
- rcClip,CPDF_Point(0.0f,0.0f),pRange, pSysHandler, m_pFormFiller);
-
- if (HasFlag(PES_SPELLCHECK))
- {
- CPWL_Utils::DrawEditSpellCheck(pDevice,pUser2Device,m_pEdit,rcClip,
- CPDF_Point(0.0f,0.0f),pRange, this->GetCreationParam().pSpellCheck);
- }
-}
-
-FX_BOOL CPWL_Edit::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonDown(point,nFlag);
-
- if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point))
- {
- if (m_bMouseDown)
- this->InvalidateRect();
-
- m_bMouseDown = TRUE;
- SetCapture();
-
- m_pEdit->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_Edit::OnLButtonDblClk(const CPDF_Point & 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 CPDF_Point & 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;
-
- this->SetFocus();
-
- CPVT_WordRange wrLatin = GetLatinWordsRange(point);
- CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin);
-
- FX_HMENU hPopup = pSH->CreatePopupMenu();
- if (!hPopup) return FALSE;
-
- CFX_ByteStringArray sSuggestWords;
- CPDF_Point 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);
-
- FX_INT32 nSuggest = sSuggestWords.GetSize();
-
- for (FX_INT32 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 = this->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(this->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);
- }
-
- FX_INT32 x, y;
- PWLtoWnd(ptPopup, x, y);
- pSH->ClientToScreen(GetAttachedHWnd(), x, y);
- pSH->SetCursor(FXCT_ARROW);
- FX_INT32 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:
- this->CutText();
- break;
- case WM_PWLEDIT_COPY:
- this->CopyText();
- break;
- case WM_PWLEDIT_PASTE:
- this->PasteText();
- break;
- case WM_PWLEDIT_DELETE:
- this->Clear();
- break;
- case WM_PWLEDIT_SELECTALL:
- this->SelectAll();
- break;
- case WM_PWLEDIT_SUGGEST + 0:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[0].UTF8Decode());
- break;
- case WM_PWLEDIT_SUGGEST + 1:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[1].UTF8Decode());
- break;
- case WM_PWLEDIT_SUGGEST + 2:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[2].UTF8Decode());
- break;
- case WM_PWLEDIT_SUGGEST + 3:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[3].UTF8Decode());
- break;
- case WM_PWLEDIT_SUGGEST + 4:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[4].UTF8Decode());
- 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, CPDF_Point(0.0f,0.0f), CPDF_Point(0.0f,0.0f));
-
- SetCharSet(0);
-
- if (!IsReadOnly())
- {
- if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler())
- pFocusHandler->OnKillFocus(this);
- }
-
- m_bFocus = FALSE;
-}
-
-void CPWL_Edit::SetHorzScale(FX_INT32 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 CPDF_Point & ptOffset) const
-{
- CPVT_WordRange wr = GetSelectWordRange();
- return CPWL_Utils::GetEditSelAppStream(m_pEdit,ptOffset,&wr);
-}
-
-CPVT_WordRange CPWL_Edit::GetSelectWordRange() const
-{
- if (m_pEdit->IsSelected())
- {
- FX_INT32 nStart = -1;
- FX_INT32 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 CPDF_Point & 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 CPDF_Point & ptOffset) const
-{
- if (m_pEditCaret)
- return m_pEditCaret->GetCaretAppearanceStream(ptOffset);
-
- return CFX_ByteString();
-}
-
-CPDF_Point CPWL_Edit::GetWordRightBottomPoint(const CPVT_WordPlace& wpWord)
-{
- CPDF_Point 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 = CPDF_Point(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 CPDF_Rect& rcPlate, FX_INT32 nCharArray)
-{
- if (pFont && !pFont->IsStandardFont())
- {
- FX_RECT rcBBox;
- pFont->GetFontBBox(rcBBox);
-
- CPDF_Rect 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(FX_INT32 nCharArray)
-{
- if (HasFlag(PES_CHARARRAY) && nCharArray > 0)
- {
- m_pEdit->SetCharArray(nCharArray);
- m_pEdit->SetTextOverflow(TRUE);
-
- if (HasFlag(PWS_AUTOFONTSIZE))
- {
- if (IFX_Edit_FontMap* pFontMap = this->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(FX_INT32 nLimitChar)
-{
- m_pEdit->SetLimitChar(nLimitChar);
-}
-
-void CPWL_Edit::ReplaceSel(FX_LPCWSTR csText)
-{
- m_pEdit->Clear();
- m_pEdit->InsertText(csText);
-}
-
-CPDF_Rect CPWL_Edit::GetFocusRect() const
-{
- return CPDF_Rect();
-}
-
-void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow)
-{
- if (CPWL_ScrollBar * pScroll = GetVScrollBar())
- {
- if (bShow)
- {
- if (!pScroll->IsVisible())
- {
- pScroll->SetVisible(TRUE);
- CPDF_Rect 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(TRUE, GetAttachedData(), FWL_VKEY_Delete, strChange, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExit, nFlag);
- if (!bRC) return FALSE;
- if (bExit) return FALSE;
- }
- }
-
- FX_BOOL bRet = CPWL_EditCtrl::OnKeyDown(nChar, nFlag);
-
- if (nChar == FWL_VKEY_Delete)
- {
- if (m_pFillerNotify)
- {
- FX_BOOL bExit = FALSE;
- m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit,nFlag);
- if (bExit) return FALSE;
- }
- }
-
- //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:
- break;
- }
- 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;
-
- FX_BOOL bCtrl = IsCTRLpressed(nFlag);
- if (!bCtrl)
- {
- if (m_pFillerNotify)
- {
- CFX_WideString swChange;
- FX_INT32 nKeyCode;
-
- int nSelStart = 0;
- int nSelEnd = 0;
- GetSel(nSelStart, nSelEnd);
-
- switch (nChar)
- {
- case FWL_VKEY_Back:
- nKeyCode = nChar;
- if (nSelStart == nSelEnd)
- nSelStart = nSelEnd - 1;
- break;
- case FWL_VKEY_Return:
- nKeyCode = nChar;
- break;
- default:
- nKeyCode = 0;
- swChange += nChar;
- break;
- }
-
- CFX_WideString strChangeEx;
- m_pFillerNotify->OnBeforeKeyStroke(TRUE, GetAttachedData(), nKeyCode, swChange, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExit, nFlag);
- }
- }
-
- if (!bRC) return TRUE;
- if (bExit) return FALSE;
-
- if (IFX_Edit_FontMap * pFontMap = GetFontMap())
- {
- FX_INT32 nOldCharSet = GetCharSet();
- FX_INT32 nNewCharSet = pFontMap->CharSetFromUnicode(nChar, DEFAULT_CHARSET);
- if(nOldCharSet != nNewCharSet)
- {
- SetCharSet(nNewCharSet);
- }
- }
- FX_BOOL bRet = CPWL_EditCtrl::OnChar(nChar,nFlag);
-
- if (!bCtrl)
- {
- if (m_pFillerNotify)
- {
- m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit,nFlag);
- if (bExit) return FALSE;
- }
- }
-
- return bRet;
-}
-
-FX_BOOL CPWL_Edit::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag)
-{
- if (HasFlag(PES_MULTILINE))
- {
- CPDF_Point ptScroll = GetScrollPos();
-
- if (zDelta > 0)
- {
- ptScroll.y += this->GetFontSize();
- }
- else
- {
- ptScroll.y -= this->GetFontSize();
- }
- this->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 CPDF_Point& 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))
- {
- wpEnd = pIterator->GetAt();
- continue;
- }
- else
- break;
- };
- }
- else if (bArabic)
- {
- while (pIterator->NextWord())
- {
- if (pIterator->GetWord(wordinfo) && PWL_ISARABICWORD(wordinfo.Word))
- {
- wpEnd = pIterator->GetAt();
- continue;
- }
- else
- break;
- };
- }
-
- pIterator->SetAt(place);
-
- if (bLatin)
- {
- do
- {
- if (pIterator->GetWord(wordinfo) && FX_EDIT_ISLATINWORD(wordinfo.Word))
- {
- continue;
- }
- else
- {
- wpStart = pIterator->GetAt();
- break;
- }
- }
- while (pIterator->PrevWord());
- }
- else if (bArabic)
- {
- do
- {
- if (pIterator->GetWord(wordinfo) && PWL_ISARABICWORD(wordinfo.Word))
- {
- continue;
- }
- else
- {
- wpStart = pIterator->GetAt();
- break;
- }
- }
- while (pIterator->PrevWord());
- }
-
- range.Set(wpStart,wpEnd);
- }
-
- return range;
-}
-
-void CPWL_Edit::AjustArabicWords(const CPVT_WordRange& wr)
-{
-}
-
-void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects,
- const CPDF_Point& ptOffset, CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray)
-{
- IFX_Edit::GeneratePageObjects(pPageObjects, m_pEdit, ptOffset, NULL, CPWL_Utils::PWLColorToFXColor(GetTextColor(),GetTransparency()), ObjArray);
-}
-
-void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects,
- const CPDF_Point& ptOffset)
-{
- CFX_ArrayTemplate<CPDF_TextObject*> ObjArray;
- IFX_Edit::GeneratePageObjects(pPageObjects, m_pEdit, ptOffset, NULL, CPWL_Utils::PWLColorToFXColor(GetTextColor(),GetTransparency()), ObjArray);
-}
-
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_EditCtrl.h"
+#include "../../include/pdfwindow/PWL_Edit.h"
+#include "../../include/pdfwindow/PWL_ScrollBar.h"
+#include "../../include/pdfwindow/PWL_Utils.h"
+#include "../../include/pdfwindow/PWL_Caret.h"
+#include "../../include/pdfwindow/PWL_FontMap.h"
+
+/* ---------------------------- CPWL_Edit ------------------------------ */
+
+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(FX_LPCWSTR csText)
+{
+ CFX_WideString swText = csText;
+
+ if (HasFlag(PES_RICH))
+ {
+ CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText);
+
+ if (CXML_Element * pXML = CXML_Element::Parse((FX_LPCSTR)sValue,sValue.GetLength()))
+ {
+ FX_INT32 nCount = pXML->CountChildren();
+ FX_BOOL bFirst = TRUE;
+
+ swText.Empty();
+
+ for (FX_INT32 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(FX_INT32 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);
+}
+
+void CPWL_Edit::RePosChildWnd()
+{
+ if (CPWL_ScrollBar * pVSB = this->GetVScrollBar())
+ {
+ //if (pVSB->IsVisible())
+ {
+ CPDF_Rect rcWindow = m_rcOldWindow;
+ CPDF_Rect rcVScroll = CPDF_Rect(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();
+}
+
+CPDF_Rect CPWL_Edit::GetClientRect() const
+{
+ CPDF_Rect rcClient = CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
+
+ if (CPWL_ScrollBar * pVSB = this->GetVScrollBar())
+ {
+ if (pVSB->IsVisible())
+ {
+ rcClient.right -= PWL_SCROLLBAR_WIDTH;
+ }
+ }
+
+ return rcClient;
+}
+
+void CPWL_Edit::SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat, FX_BOOL bPaint/* = TRUE*/)
+{
+ m_pEdit->SetAlignmentH((FX_INT32)nFormat, bPaint);
+}
+
+void CPWL_Edit::SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat, FX_BOOL bPaint/* = TRUE*/)
+{
+ m_pEdit->SetAlignmentV((FX_INT32)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(TRUE, GetAttachedData(), 0 , swClipboard, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExit, 0);
+ if (!bRC) return;
+ if (bExit) return;
+ }
+
+ if (swClipboard.GetLength() > 0)
+ {
+ Clear();
+ InsertText(swClipboard);
+ }
+
+ if (m_pFillerNotify)
+ {
+ FX_BOOL bExit = FALSE;
+ m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit,0);
+ if (bExit) return;
+ }
+}
+
+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(CPDF_Rect(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);
+
+ CPDF_Rect rcClient = GetClientRect();
+ CFX_ByteTextBuf sLine;
+
+ FX_INT32 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 (FX_INT32 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 (FX_INT32 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;
+
+ CPDF_Point ptOffset = CPDF_Point(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)
+ {
+ CPDF_Rect rcClient = this->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, CPDF_Matrix* pUser2Device)
+{
+ CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
+
+ CPDF_Rect rcClient = GetClientRect();
+ CFX_ByteTextBuf sLine;
+
+ FX_INT32 nCharArray = m_pEdit->GetCharArray();
+
+ if (nCharArray > 0)
+ {
+ switch (GetBorderStyle())
+ {
+ case PBS_SOLID:
+ {
+ CFX_GraphStateData gsd;
+ gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
+
+ CFX_PathData path;
+ path.SetPointCount((nCharArray-1)*2);
+
+ for (FX_INT32 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((nCharArray-1)*2);
+
+ for (FX_INT32 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;
+ }
+ }
+
+ CPDF_Rect 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(),this->GetTransparency()),
+ CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(),this->GetTransparency()),
+ rcClip,CPDF_Point(0.0f,0.0f),pRange, pSysHandler, m_pFormFiller);
+
+ if (HasFlag(PES_SPELLCHECK))
+ {
+ CPWL_Utils::DrawEditSpellCheck(pDevice,pUser2Device,m_pEdit,rcClip,
+ CPDF_Point(0.0f,0.0f),pRange, this->GetCreationParam().pSpellCheck);
+ }
+}
+
+FX_BOOL CPWL_Edit::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
+{
+ CPWL_Wnd::OnLButtonDown(point,nFlag);
+
+ if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point))
+ {
+ if (m_bMouseDown)
+ this->InvalidateRect();
+
+ m_bMouseDown = TRUE;
+ SetCapture();
+
+ m_pEdit->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
+ }
+
+ return TRUE;
+}
+
+FX_BOOL CPWL_Edit::OnLButtonDblClk(const CPDF_Point & 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 CPDF_Point & 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;
+
+ this->SetFocus();
+
+ CPVT_WordRange wrLatin = GetLatinWordsRange(point);
+ CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin);
+
+ FX_HMENU hPopup = pSH->CreatePopupMenu();
+ if (!hPopup) return FALSE;
+
+ CFX_ByteStringArray sSuggestWords;
+ CPDF_Point 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);
+
+ FX_INT32 nSuggest = sSuggestWords.GetSize();
+
+ for (FX_INT32 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 = this->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(this->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);
+ }
+
+ FX_INT32 x, y;
+ PWLtoWnd(ptPopup, x, y);
+ pSH->ClientToScreen(GetAttachedHWnd(), x, y);
+ pSH->SetCursor(FXCT_ARROW);
+ FX_INT32 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:
+ this->CutText();
+ break;
+ case WM_PWLEDIT_COPY:
+ this->CopyText();
+ break;
+ case WM_PWLEDIT_PASTE:
+ this->PasteText();
+ break;
+ case WM_PWLEDIT_DELETE:
+ this->Clear();
+ break;
+ case WM_PWLEDIT_SELECTALL:
+ this->SelectAll();
+ break;
+ case WM_PWLEDIT_SUGGEST + 0:
+ SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
+ ReplaceSel(sSuggestWords[0].UTF8Decode());
+ break;
+ case WM_PWLEDIT_SUGGEST + 1:
+ SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
+ ReplaceSel(sSuggestWords[1].UTF8Decode());
+ break;
+ case WM_PWLEDIT_SUGGEST + 2:
+ SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
+ ReplaceSel(sSuggestWords[2].UTF8Decode());
+ break;
+ case WM_PWLEDIT_SUGGEST + 3:
+ SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
+ ReplaceSel(sSuggestWords[3].UTF8Decode());
+ break;
+ case WM_PWLEDIT_SUGGEST + 4:
+ SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
+ ReplaceSel(sSuggestWords[4].UTF8Decode());
+ 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, CPDF_Point(0.0f,0.0f), CPDF_Point(0.0f,0.0f));
+
+ SetCharSet(0);
+
+ if (!IsReadOnly())
+ {
+ if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler())
+ pFocusHandler->OnKillFocus(this);
+ }
+
+ m_bFocus = FALSE;
+}
+
+void CPWL_Edit::SetHorzScale(FX_INT32 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 CPDF_Point & ptOffset) const
+{
+ CPVT_WordRange wr = GetSelectWordRange();
+ return CPWL_Utils::GetEditSelAppStream(m_pEdit,ptOffset,&wr);
+}
+
+CPVT_WordRange CPWL_Edit::GetSelectWordRange() const
+{
+ if (m_pEdit->IsSelected())
+ {
+ FX_INT32 nStart = -1;
+ FX_INT32 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 CPDF_Point & 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 CPDF_Point & ptOffset) const
+{
+ if (m_pEditCaret)
+ return m_pEditCaret->GetCaretAppearanceStream(ptOffset);
+
+ return CFX_ByteString();
+}
+
+CPDF_Point CPWL_Edit::GetWordRightBottomPoint(const CPVT_WordPlace& wpWord)
+{
+ CPDF_Point 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 = CPDF_Point(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 CPDF_Rect& rcPlate, FX_INT32 nCharArray)
+{
+ if (pFont && !pFont->IsStandardFont())
+ {
+ FX_RECT rcBBox;
+ pFont->GetFontBBox(rcBBox);
+
+ CPDF_Rect 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(FX_INT32 nCharArray)
+{
+ if (HasFlag(PES_CHARARRAY) && nCharArray > 0)
+ {
+ m_pEdit->SetCharArray(nCharArray);
+ m_pEdit->SetTextOverflow(TRUE);
+
+ if (HasFlag(PWS_AUTOFONTSIZE))
+ {
+ if (IFX_Edit_FontMap* pFontMap = this->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(FX_INT32 nLimitChar)
+{
+ m_pEdit->SetLimitChar(nLimitChar);
+}
+
+void CPWL_Edit::ReplaceSel(FX_LPCWSTR csText)
+{
+ m_pEdit->Clear();
+ m_pEdit->InsertText(csText);
+}
+
+CPDF_Rect CPWL_Edit::GetFocusRect() const
+{
+ return CPDF_Rect();
+}
+
+void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow)
+{
+ if (CPWL_ScrollBar * pScroll = GetVScrollBar())
+ {
+ if (bShow)
+ {
+ if (!pScroll->IsVisible())
+ {
+ pScroll->SetVisible(TRUE);
+ CPDF_Rect 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(TRUE, GetAttachedData(), FWL_VKEY_Delete, strChange, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExit, nFlag);
+ if (!bRC) return FALSE;
+ if (bExit) return FALSE;
+ }
+ }
+
+ FX_BOOL bRet = CPWL_EditCtrl::OnKeyDown(nChar, nFlag);
+
+ if (nChar == FWL_VKEY_Delete)
+ {
+ if (m_pFillerNotify)
+ {
+ FX_BOOL bExit = FALSE;
+ m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit,nFlag);
+ if (bExit) return FALSE;
+ }
+ }
+
+ //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:
+ break;
+ }
+ 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;
+
+ FX_BOOL bCtrl = IsCTRLpressed(nFlag);
+ if (!bCtrl)
+ {
+ if (m_pFillerNotify)
+ {
+ CFX_WideString swChange;
+ FX_INT32 nKeyCode;
+
+ int nSelStart = 0;
+ int nSelEnd = 0;
+ GetSel(nSelStart, nSelEnd);
+
+ switch (nChar)
+ {
+ case FWL_VKEY_Back:
+ nKeyCode = nChar;
+ if (nSelStart == nSelEnd)
+ nSelStart = nSelEnd - 1;
+ break;
+ case FWL_VKEY_Return:
+ nKeyCode = nChar;
+ break;
+ default:
+ nKeyCode = 0;
+ swChange += nChar;
+ break;
+ }
+
+ CFX_WideString strChangeEx;
+ m_pFillerNotify->OnBeforeKeyStroke(TRUE, GetAttachedData(), nKeyCode, swChange, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExit, nFlag);
+ }
+ }
+
+ if (!bRC) return TRUE;
+ if (bExit) return FALSE;
+
+ if (IFX_Edit_FontMap * pFontMap = GetFontMap())
+ {
+ FX_INT32 nOldCharSet = GetCharSet();
+ FX_INT32 nNewCharSet = pFontMap->CharSetFromUnicode(nChar, DEFAULT_CHARSET);
+ if(nOldCharSet != nNewCharSet)
+ {
+ SetCharSet(nNewCharSet);
+ }
+ }
+ FX_BOOL bRet = CPWL_EditCtrl::OnChar(nChar,nFlag);
+
+ if (!bCtrl)
+ {
+ if (m_pFillerNotify)
+ {
+ m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit,nFlag);
+ if (bExit) return FALSE;
+ }
+ }
+
+ return bRet;
+}
+
+FX_BOOL CPWL_Edit::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag)
+{
+ if (HasFlag(PES_MULTILINE))
+ {
+ CPDF_Point ptScroll = GetScrollPos();
+
+ if (zDelta > 0)
+ {
+ ptScroll.y += this->GetFontSize();
+ }
+ else
+ {
+ ptScroll.y -= this->GetFontSize();
+ }
+ this->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 CPDF_Point& 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))
+ {
+ wpEnd = pIterator->GetAt();
+ continue;
+ }
+ else
+ break;
+ };
+ }
+ else if (bArabic)
+ {
+ while (pIterator->NextWord())
+ {
+ if (pIterator->GetWord(wordinfo) && PWL_ISARABICWORD(wordinfo.Word))
+ {
+ wpEnd = pIterator->GetAt();
+ continue;
+ }
+ else
+ break;
+ };
+ }
+
+ pIterator->SetAt(place);
+
+ if (bLatin)
+ {
+ do
+ {
+ if (pIterator->GetWord(wordinfo) && FX_EDIT_ISLATINWORD(wordinfo.Word))
+ {
+ continue;
+ }
+ else
+ {
+ wpStart = pIterator->GetAt();
+ break;
+ }
+ }
+ while (pIterator->PrevWord());
+ }
+ else if (bArabic)
+ {
+ do
+ {
+ if (pIterator->GetWord(wordinfo) && PWL_ISARABICWORD(wordinfo.Word))
+ {
+ continue;
+ }
+ else
+ {
+ wpStart = pIterator->GetAt();
+ break;
+ }
+ }
+ while (pIterator->PrevWord());
+ }
+
+ range.Set(wpStart,wpEnd);
+ }
+
+ return range;
+}
+
+void CPWL_Edit::AjustArabicWords(const CPVT_WordRange& wr)
+{
+}
+
+void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects,
+ const CPDF_Point& ptOffset, CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray)
+{
+ IFX_Edit::GeneratePageObjects(pPageObjects, m_pEdit, ptOffset, NULL, CPWL_Utils::PWLColorToFXColor(GetTextColor(),GetTransparency()), ObjArray);
+}
+
+void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects,
+ const CPDF_Point& ptOffset)
+{
+ CFX_ArrayTemplate<CPDF_TextObject*> ObjArray;
+ IFX_Edit::GeneratePageObjects(pPageObjects, 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
index 2562822..90a198a 100644
--- a/fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp
@@ -1,728 +1,728 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_EditCtrl.h"
-#include "../../include/pdfwindow/PWL_ScrollBar.h"
-#include "../../include/pdfwindow/PWL_Utils.h"
-#include "../../include/pdfwindow/PWL_Caret.h"
-#include "../../include/pdfwindow/PWL_FontMap.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::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 != NULL);
-}
-
-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(this->GetCreationParam().fFontSize);
-
- m_pEdit->SetFontMap(this->GetFontMap());
- m_pEdit->SetNotify(this);
- m_pEdit->Initialize();
-}
-
-FX_BOOL CPWL_EditCtrl::IsWndHorV()
-{
- CPDF_Matrix mt = GetWindowMatrix();
- CPDF_Point point1(0,1);
- CPDF_Point 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, FX_INTPTR wParam, FX_INTPTR 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(CPDF_Point(m_pEdit->GetScrollPos().x,fPos));
- break;
- }
- }
- break;
- case PNM_SETCARETINFO:
- {
- if (PWL_CARET_INFO * pCaretInfo = (PWL_CARET_INFO *)wParam)
- {
- this->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 = CPDF_Rect(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:
- this->CopyText();
- return TRUE;
- case 'V' - 'A' + 1:
- this->PasteText();
- return TRUE;
- case 'X' - 'A' + 1:
- this->CutText();
- return TRUE;
- case 'A' - 'A' + 1:
- this->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, this->GetCharSet());
- break;
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_EditCtrl::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonDown(point,nFlag);
-
- if (ClientHitTest(point))
- {
- if (m_bMouseDown)
- this->InvalidateRect();
-
- m_bMouseDown = TRUE;
- SetCapture();
-
- m_pEdit->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_EditCtrl::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonUp(point,nFlag);
-
- if (m_bMouseDown)
- {
- //can receive keybord message
- if (ClientHitTest(point) && !this->IsFocused())
- SetFocus();
-
- ReleaseCapture();
- m_bMouseDown = FALSE;
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_EditCtrl::OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnMouseMove(point,nFlag);
-
- if (m_bMouseDown)
- m_pEdit->OnMouseMove(point,FALSE,FALSE);
-
- return TRUE;
-}
-
-CPDF_Rect CPWL_EditCtrl::GetContentRect() const
-{
- return m_pEdit->GetContentRect();
-}
-
-void CPWL_EditCtrl::SetEditCaret(FX_BOOL bVisible)
-{
- CPDF_Point ptHead(0,0),ptFoot(0,0);
-
- if (bVisible)
- {
- GetCaretInfo(ptHead,ptFoot);
- }
-
- CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace();
- this->IOnSetCaret(bVisible,ptHead,ptFoot,wpTemp);
-}
-
-void CPWL_EditCtrl::GetCaretInfo(CPDF_Point & ptHead, CPDF_Point & 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(FX_INT32& x, FX_INT32& y) const
-{
- CPDF_Point ptHead(0,0), ptFoot(0,0);
-
- GetCaretInfo(ptHead,ptFoot);
-
- PWLtoWnd(ptHead, x, y);
-}
-
-void CPWL_EditCtrl::SetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const CPDF_Point & ptFoot)
-{
- if (m_pEditCaret)
- {
- if (!IsFocused() || m_pEdit->IsSelected())
- bVisible = FALSE;
-
- m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot);
- }
-}
-
-FX_BOOL CPWL_EditCtrl::IsModified() const
-{
- return m_pEdit->IsModified();
-}
-
-CFX_WideString CPWL_EditCtrl::GetText() const
-{
- return m_pEdit->GetText();
-}
-
-void CPWL_EditCtrl::SetSel(FX_INT32 nStartChar,FX_INT32 nEndChar)
-{
- m_pEdit->SetSel(nStartChar, nEndChar);
-}
-
-void CPWL_EditCtrl::GetSel(FX_INT32 & nStartChar, FX_INT32 & 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);
-}
-
-FX_INT32 CPWL_EditCtrl::GetCaret() const
-{
- if (m_pEdit)
- return m_pEdit->GetCaret();
-
- return -1;
-}
-
-void CPWL_EditCtrl::SetCaret(FX_INT32 nPos)
-{
- if (m_pEdit)
- m_pEdit->SetCaret(nPos);
-}
-
-FX_INT32 CPWL_EditCtrl::GetTotalWords() const
-{
- if (m_pEdit)
- return m_pEdit->GetTotalWords();
-
- return 0;
-}
-
-void CPWL_EditCtrl::SetScrollPos(const CPDF_Point& point)
-{
- if (m_pEdit)
- m_pEdit->SetScrollPos(point);
-}
-
-CPDF_Point CPWL_EditCtrl::GetScrollPos() const
-{
- if (m_pEdit)
- return m_pEdit->GetScrollPos();
-
- return CPDF_Point(0.0f, 0.0f);
-}
-
-CPDF_Font * CPWL_EditCtrl::GetCaretFont() const
-{
- FX_INT32 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);
- else
- 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(FX_LPCWSTR 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(FX_LPCWSTR csText)
-{
- if (!IsReadOnly())
- m_pEdit->InsertText(csText);
-}
-
-void CPWL_EditCtrl::InsertWord(FX_WORD word, FX_INT32 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;
-
- this->OnNotify(this,PNM_SETSCROLLINFO,SBT_VSCROLL,(FX_INTPTR)&Info);
-
-// PWL_TRACE("set scroll info:%f\n",fContentMax - fContentMin);
-
- if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fContentMin)
- || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.fContentMin))
- {
- this->ShowVScrollBar(FALSE);
- }
- else
- {
- this->ShowVScrollBar(TRUE);
- }
-}
-
-void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy)
-{
-// PWL_TRACE("set scroll position:%f\n",fy);
- this->OnNotify(this,PNM_SETSCROLLPOS,SBT_VSCROLL,(FX_INTPTR)&fy);
-}
-
-void CPWL_EditCtrl::IOnSetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const CPDF_Point & ptFoot, const CPVT_WordPlace& place)
-{
- PWL_CARET_INFO cInfo;
- cInfo.bVisible = bVisible;
- cInfo.ptHead = ptHead;
- cInfo.ptFoot = ptFoot;
-
- this->OnNotify(this,PNM_SETCARETINFO,(FX_INTPTR)&cInfo,(FX_INTPTR)NULL);
-}
-
-void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps & secProps, const CPVT_WordProps & wordProps)
-{
-}
-
-void CPWL_EditCtrl::IOnContentChange(const CPDF_Rect& rcContent)
-{
- if (this->IsValid())
- {
- if (m_pEditNotify)
- {
- m_pEditNotify->OnContentChange(rcContent);
- }
- }
-}
-
-void CPWL_EditCtrl::IOnInvalidateRect(CPDF_Rect * pRect)
-{
- this->InvalidateRect(pRect);
-}
-
-FX_INT32 CPWL_EditCtrl::GetCharSet() const
-{
- if (m_nCharSet < 0)
- return DEFAULT_CHARSET;
- else
- return m_nCharSet;
-}
-
-void CPWL_EditCtrl::GetTextRange(const CPDF_Rect& rect, FX_INT32 & nStartChar, FX_INT32 & nEndChar) const
-{
- nStartChar = m_pEdit->WordPlaceToWordIndex(m_pEdit->SearchWordPlace(CPDF_Point(rect.left, rect.top)));
- nEndChar = m_pEdit->WordPlaceToWordIndex(m_pEdit->SearchWordPlace(CPDF_Point(rect.right, rect.bottom)));
-}
-
-CFX_WideString CPWL_EditCtrl::GetText(FX_INT32 & nStartChar, FX_INT32 & 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;
- }
-}
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_EditCtrl.h"
+#include "../../include/pdfwindow/PWL_ScrollBar.h"
+#include "../../include/pdfwindow/PWL_Utils.h"
+#include "../../include/pdfwindow/PWL_Caret.h"
+#include "../../include/pdfwindow/PWL_FontMap.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::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 != NULL);
+}
+
+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(this->GetCreationParam().fFontSize);
+
+ m_pEdit->SetFontMap(this->GetFontMap());
+ m_pEdit->SetNotify(this);
+ m_pEdit->Initialize();
+}
+
+FX_BOOL CPWL_EditCtrl::IsWndHorV()
+{
+ CPDF_Matrix mt = GetWindowMatrix();
+ CPDF_Point point1(0,1);
+ CPDF_Point 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, FX_INTPTR wParam, FX_INTPTR 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(CPDF_Point(m_pEdit->GetScrollPos().x,fPos));
+ break;
+ }
+ }
+ break;
+ case PNM_SETCARETINFO:
+ {
+ if (PWL_CARET_INFO * pCaretInfo = (PWL_CARET_INFO *)wParam)
+ {
+ this->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 = CPDF_Rect(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:
+ this->CopyText();
+ return TRUE;
+ case 'V' - 'A' + 1:
+ this->PasteText();
+ return TRUE;
+ case 'X' - 'A' + 1:
+ this->CutText();
+ return TRUE;
+ case 'A' - 'A' + 1:
+ this->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, this->GetCharSet());
+ break;
+ }
+
+ return TRUE;
+}
+
+FX_BOOL CPWL_EditCtrl::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
+{
+ CPWL_Wnd::OnLButtonDown(point,nFlag);
+
+ if (ClientHitTest(point))
+ {
+ if (m_bMouseDown)
+ this->InvalidateRect();
+
+ m_bMouseDown = TRUE;
+ SetCapture();
+
+ m_pEdit->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
+ }
+
+ return TRUE;
+}
+
+FX_BOOL CPWL_EditCtrl::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
+{
+ CPWL_Wnd::OnLButtonUp(point,nFlag);
+
+ if (m_bMouseDown)
+ {
+ //can receive keybord message
+ if (ClientHitTest(point) && !this->IsFocused())
+ SetFocus();
+
+ ReleaseCapture();
+ m_bMouseDown = FALSE;
+ }
+
+ return TRUE;
+}
+
+FX_BOOL CPWL_EditCtrl::OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag)
+{
+ CPWL_Wnd::OnMouseMove(point,nFlag);
+
+ if (m_bMouseDown)
+ m_pEdit->OnMouseMove(point,FALSE,FALSE);
+
+ return TRUE;
+}
+
+CPDF_Rect CPWL_EditCtrl::GetContentRect() const
+{
+ return m_pEdit->GetContentRect();
+}
+
+void CPWL_EditCtrl::SetEditCaret(FX_BOOL bVisible)
+{
+ CPDF_Point ptHead(0,0),ptFoot(0,0);
+
+ if (bVisible)
+ {
+ GetCaretInfo(ptHead,ptFoot);
+ }
+
+ CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace();
+ this->IOnSetCaret(bVisible,ptHead,ptFoot,wpTemp);
+}
+
+void CPWL_EditCtrl::GetCaretInfo(CPDF_Point & ptHead, CPDF_Point & 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(FX_INT32& x, FX_INT32& y) const
+{
+ CPDF_Point ptHead(0,0), ptFoot(0,0);
+
+ GetCaretInfo(ptHead,ptFoot);
+
+ PWLtoWnd(ptHead, x, y);
+}
+
+void CPWL_EditCtrl::SetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const CPDF_Point & ptFoot)
+{
+ if (m_pEditCaret)
+ {
+ if (!IsFocused() || m_pEdit->IsSelected())
+ bVisible = FALSE;
+
+ m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot);
+ }
+}
+
+FX_BOOL CPWL_EditCtrl::IsModified() const
+{
+ return m_pEdit->IsModified();
+}
+
+CFX_WideString CPWL_EditCtrl::GetText() const
+{
+ return m_pEdit->GetText();
+}
+
+void CPWL_EditCtrl::SetSel(FX_INT32 nStartChar,FX_INT32 nEndChar)
+{
+ m_pEdit->SetSel(nStartChar, nEndChar);
+}
+
+void CPWL_EditCtrl::GetSel(FX_INT32 & nStartChar, FX_INT32 & 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);
+}
+
+FX_INT32 CPWL_EditCtrl::GetCaret() const
+{
+ if (m_pEdit)
+ return m_pEdit->GetCaret();
+
+ return -1;
+}
+
+void CPWL_EditCtrl::SetCaret(FX_INT32 nPos)
+{
+ if (m_pEdit)
+ m_pEdit->SetCaret(nPos);
+}
+
+FX_INT32 CPWL_EditCtrl::GetTotalWords() const
+{
+ if (m_pEdit)
+ return m_pEdit->GetTotalWords();
+
+ return 0;
+}
+
+void CPWL_EditCtrl::SetScrollPos(const CPDF_Point& point)
+{
+ if (m_pEdit)
+ m_pEdit->SetScrollPos(point);
+}
+
+CPDF_Point CPWL_EditCtrl::GetScrollPos() const
+{
+ if (m_pEdit)
+ return m_pEdit->GetScrollPos();
+
+ return CPDF_Point(0.0f, 0.0f);
+}
+
+CPDF_Font * CPWL_EditCtrl::GetCaretFont() const
+{
+ FX_INT32 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);
+ else
+ 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(FX_LPCWSTR 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(FX_LPCWSTR csText)
+{
+ if (!IsReadOnly())
+ m_pEdit->InsertText(csText);
+}
+
+void CPWL_EditCtrl::InsertWord(FX_WORD word, FX_INT32 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;
+
+ this->OnNotify(this,PNM_SETSCROLLINFO,SBT_VSCROLL,(FX_INTPTR)&Info);
+
+// PWL_TRACE("set scroll info:%f\n",fContentMax - fContentMin);
+
+ if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fContentMin)
+ || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.fContentMin))
+ {
+ this->ShowVScrollBar(FALSE);
+ }
+ else
+ {
+ this->ShowVScrollBar(TRUE);
+ }
+}
+
+void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy)
+{
+// PWL_TRACE("set scroll position:%f\n",fy);
+ this->OnNotify(this,PNM_SETSCROLLPOS,SBT_VSCROLL,(FX_INTPTR)&fy);
+}
+
+void CPWL_EditCtrl::IOnSetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const CPDF_Point & ptFoot, const CPVT_WordPlace& place)
+{
+ PWL_CARET_INFO cInfo;
+ cInfo.bVisible = bVisible;
+ cInfo.ptHead = ptHead;
+ cInfo.ptFoot = ptFoot;
+
+ this->OnNotify(this,PNM_SETCARETINFO,(FX_INTPTR)&cInfo,(FX_INTPTR)NULL);
+}
+
+void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps & secProps, const CPVT_WordProps & wordProps)
+{
+}
+
+void CPWL_EditCtrl::IOnContentChange(const CPDF_Rect& rcContent)
+{
+ if (this->IsValid())
+ {
+ if (m_pEditNotify)
+ {
+ m_pEditNotify->OnContentChange(rcContent);
+ }
+ }
+}
+
+void CPWL_EditCtrl::IOnInvalidateRect(CPDF_Rect * pRect)
+{
+ this->InvalidateRect(pRect);
+}
+
+FX_INT32 CPWL_EditCtrl::GetCharSet() const
+{
+ if (m_nCharSet < 0)
+ return DEFAULT_CHARSET;
+ else
+ return m_nCharSet;
+}
+
+void CPWL_EditCtrl::GetTextRange(const CPDF_Rect& rect, FX_INT32 & nStartChar, FX_INT32 & nEndChar) const
+{
+ nStartChar = m_pEdit->WordPlaceToWordIndex(m_pEdit->SearchWordPlace(CPDF_Point(rect.left, rect.top)));
+ nEndChar = m_pEdit->WordPlaceToWordIndex(m_pEdit->SearchWordPlace(CPDF_Point(rect.right, rect.bottom)));
+}
+
+CFX_WideString CPWL_EditCtrl::GetText(FX_INT32 & nStartChar, FX_INT32 & 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
index 1e2259f..c656f0c 100644
--- a/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
@@ -1,601 +1,601 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_FontMap.h"
-
-#define DEFAULT_FONT_NAME "Helvetica"
-
-/* ------------------------------ CPWL_FontMap ------------------------------ */
-
-CPWL_FontMap::CPWL_FontMap(IFX_SystemHandler* pSystemHandler) :
- m_pPDFDoc(NULL),
- m_pSystemHandler(pSystemHandler)
-{
- ASSERT(m_pSystemHandler != NULL);
-}
-
-CPWL_FontMap::~CPWL_FontMap()
-{
- if (m_pPDFDoc)
- {
- 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 = FX_NEW CPDF_Document;
- m_pPDFDoc->CreateNewDoc();
- }
- }
-
- return m_pPDFDoc;
-}
-
-CPDF_Font* CPWL_FontMap::GetPDFFont(FX_INT32 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(FX_INT32 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(FX_INT32 nFontIndex, FX_WORD word)
-{
- if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
- {
- if (m_aData.GetAt(nFontIndex))
- {
- return CharCodeFromUnicode(nFontIndex, word) >= 0;
- }
- }
-
- return FALSE;
-}
-
-FX_INT32 CPWL_FontMap::GetWordFontIndex(FX_WORD word, FX_INT32 nCharset, FX_INT32 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;
- }
- }
- }
- }
-
- FX_INT32 nNewFontIndex = -1;
-
- nNewFontIndex = this->GetFontIndex(GetNativeFontName(nCharset), nCharset, TRUE);
- if (nNewFontIndex >= 0)
- {
- if (KnowWord(nNewFontIndex, word))
- return nNewFontIndex;
- }
-
- nNewFontIndex = this->GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE);
- if (nNewFontIndex >= 0)
- {
- if (KnowWord(nNewFontIndex, word))
- return nNewFontIndex;
- }
-
- return -1;
-}
-
-FX_INT32 CPWL_FontMap::CharCodeFromUnicode(FX_INT32 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;
- }
- else
- {
- if (word < 0xFF)
- return word;
- }
- }
- }
-
- return -1;
-}
-
-CFX_ByteString CPWL_FontMap::GetNativeFontName(FX_INT32 nCharset)
-{
- //searching native font is slow, so we must save time
- for (FX_INT32 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 (FX_INT32 i=0, sz=m_aData.GetSize(); i<sz; i++)
- delete m_aData.GetAt(i);
-
- m_aData.RemoveAll();
- }
- {
- for (FX_INT32 i=0, sz=m_aNativeFont.GetSize(); i<sz; i++)
- delete m_aNativeFont.GetAt(i);
-
- m_aNativeFont.RemoveAll();
- }
-}
-
-void CPWL_FontMap::Initial(FX_LPCSTR fontname)
-{
- CFX_ByteString sFontName = fontname;
-
- if (sFontName.IsEmpty())
- sFontName = DEFAULT_FONT_NAME;
-
- GetFontIndex(sFontName, ANSI_CHARSET, FALSE);
-
- //GetFontIndex(this->GetNativeFontName(nCharset), nCharset);
-}
-
-
-/*
-List of currently supported standard fonts:
-Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique
-Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique
-Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic
-Symbol, ZapfDingbats
-*/
-
-const char* 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"};
-
-FX_BOOL CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName)
-{
- for (FX_INT32 i=0; i<14; i++)
- {
- if (sFontName == g_sDEStandardFontName[i])
- return TRUE;
- }
-
- return FALSE;
-}
-
-FX_INT32 CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, FX_INT32 nCharset)
-{
- for (FX_INT32 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;
-}
-
-FX_INT32 CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName, FX_INT32 nCharset, FX_BOOL bFind)
-{
- FX_INT32 nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCharset);
- if (nFontIndex >= 0) return nFontIndex;
-
-// nFontIndex = FindFont("", 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);
-
- /*
- if (FindFont(sAlias))
- {
- sAlias = EncodeFontAlias(sTemp, nCharset);
- }
- else
- */
- {
- sAlias = EncodeFontAlias(sTemp, nCharset);
- }
- }
-
- AddedFont(pFont, sAlias);
-
- return AddFontData(pFont, sAlias, nCharset);
-}
-
-FX_INT32 CPWL_FontMap::GetPWLFontIndex(FX_WORD word, FX_INT32 nCharset)
-{
- FX_INT32 nFind = -1;
-
- for (FX_INT32 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;
-
- /*
- if (CPDF_Font* pFont = GetPDFFont(nFind))
- {
- PWLFont.AddWordToFontDict(pFontDict, word);
- }
- */
-
-#ifdef FOXIT_CHROME_BUILD
- CFX_ByteString sAlias = EncodeFontAlias("Arial_Chrome", nCharset);
-#else
- CFX_ByteString sAlias = EncodeFontAlias("Arial_Foxit", nCharset);
-#endif
- AddedFont(pNewFont, sAlias);
-
- return AddFontData(pNewFont, sAlias, nCharset);
-}
-
-CPDF_Font* CPWL_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, FX_INT32 nCharset)
-{
- return NULL;
-}
-
-FX_INT32 CPWL_FontMap::AddFontData(CPDF_Font* pFont, const CFX_ByteString& sFontAlias, FX_INT32 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(FX_INT32 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(FX_INT32 nCharset)
-{
- CFX_ByteString sFontName;
-
- if (nCharset == DEFAULT_CHARSET)
- nCharset = GetNativeCharset();
-
- 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, FX_BYTE nCharset)
-{
- if (IsStandardFont(sFontName))
- return AddStandardFont(pDoc, sFontName);
- else
- 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, FX_BYTE 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, FX_INT32 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;
-}
-
-FX_INT32 CPWL_FontMap::GetFontMapCount() const
-{
- return m_aData.GetSize();
-}
-
-const CPWL_FontMap_Data* CPWL_FontMap::GetFontMapData(FX_INT32 nIndex) const
-{
- if (nIndex >=0 && nIndex < m_aData.GetSize())
- {
- return m_aData.GetAt(nIndex);
- }
-
- return NULL;
-}
-
-FX_INT32 CPWL_FontMap::GetNativeCharset()
-{
- FX_BYTE nCharset = ANSI_CHARSET;
- FX_INT32 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" },
- { EASTEUROPE_CHARSET, "Tahoma" },
- { ARABIC_CHARSET, "Arial" },
- { -1, NULL }
-};
-
-CFX_ByteString CPWL_FontMap::GetDefaultFontByCharset(FX_INT32 nCharset)
-{
- int i = 0;
- while (defaultTTFMap[i].charset != -1) {
- if (nCharset == defaultTTFMap[i].charset)
- return defaultTTFMap[i].fontname;
- ++i;
- }
- return "";
-}
-
-FX_INT32 CPWL_FontMap::CharSetFromUnicode(FX_WORD word, FX_INT32 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::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;
-}
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_FontMap.h"
+
+#define DEFAULT_FONT_NAME "Helvetica"
+
+/* ------------------------------ CPWL_FontMap ------------------------------ */
+
+CPWL_FontMap::CPWL_FontMap(IFX_SystemHandler* pSystemHandler) :
+ m_pPDFDoc(NULL),
+ m_pSystemHandler(pSystemHandler)
+{
+ ASSERT(m_pSystemHandler != NULL);
+}
+
+CPWL_FontMap::~CPWL_FontMap()
+{
+ if (m_pPDFDoc)
+ {
+ 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 = FX_NEW CPDF_Document;
+ m_pPDFDoc->CreateNewDoc();
+ }
+ }
+
+ return m_pPDFDoc;
+}
+
+CPDF_Font* CPWL_FontMap::GetPDFFont(FX_INT32 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(FX_INT32 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(FX_INT32 nFontIndex, FX_WORD word)
+{
+ if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
+ {
+ if (m_aData.GetAt(nFontIndex))
+ {
+ return CharCodeFromUnicode(nFontIndex, word) >= 0;
+ }
+ }
+
+ return FALSE;
+}
+
+FX_INT32 CPWL_FontMap::GetWordFontIndex(FX_WORD word, FX_INT32 nCharset, FX_INT32 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;
+ }
+ }
+ }
+ }
+
+ FX_INT32 nNewFontIndex = -1;
+
+ nNewFontIndex = this->GetFontIndex(GetNativeFontName(nCharset), nCharset, TRUE);
+ if (nNewFontIndex >= 0)
+ {
+ if (KnowWord(nNewFontIndex, word))
+ return nNewFontIndex;
+ }
+
+ nNewFontIndex = this->GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE);
+ if (nNewFontIndex >= 0)
+ {
+ if (KnowWord(nNewFontIndex, word))
+ return nNewFontIndex;
+ }
+
+ return -1;
+}
+
+FX_INT32 CPWL_FontMap::CharCodeFromUnicode(FX_INT32 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;
+ }
+ else
+ {
+ if (word < 0xFF)
+ return word;
+ }
+ }
+ }
+
+ return -1;
+}
+
+CFX_ByteString CPWL_FontMap::GetNativeFontName(FX_INT32 nCharset)
+{
+ //searching native font is slow, so we must save time
+ for (FX_INT32 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 (FX_INT32 i=0, sz=m_aData.GetSize(); i<sz; i++)
+ delete m_aData.GetAt(i);
+
+ m_aData.RemoveAll();
+ }
+ {
+ for (FX_INT32 i=0, sz=m_aNativeFont.GetSize(); i<sz; i++)
+ delete m_aNativeFont.GetAt(i);
+
+ m_aNativeFont.RemoveAll();
+ }
+}
+
+void CPWL_FontMap::Initial(FX_LPCSTR fontname)
+{
+ CFX_ByteString sFontName = fontname;
+
+ if (sFontName.IsEmpty())
+ sFontName = DEFAULT_FONT_NAME;
+
+ GetFontIndex(sFontName, ANSI_CHARSET, FALSE);
+
+ //GetFontIndex(this->GetNativeFontName(nCharset), nCharset);
+}
+
+
+/*
+List of currently supported standard fonts:
+Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique
+Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique
+Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic
+Symbol, ZapfDingbats
+*/
+
+const char* 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"};
+
+FX_BOOL CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName)
+{
+ for (FX_INT32 i=0; i<14; i++)
+ {
+ if (sFontName == g_sDEStandardFontName[i])
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+FX_INT32 CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, FX_INT32 nCharset)
+{
+ for (FX_INT32 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;
+}
+
+FX_INT32 CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName, FX_INT32 nCharset, FX_BOOL bFind)
+{
+ FX_INT32 nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCharset);
+ if (nFontIndex >= 0) return nFontIndex;
+
+// nFontIndex = FindFont("", 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);
+
+ /*
+ if (FindFont(sAlias))
+ {
+ sAlias = EncodeFontAlias(sTemp, nCharset);
+ }
+ else
+ */
+ {
+ sAlias = EncodeFontAlias(sTemp, nCharset);
+ }
+ }
+
+ AddedFont(pFont, sAlias);
+
+ return AddFontData(pFont, sAlias, nCharset);
+}
+
+FX_INT32 CPWL_FontMap::GetPWLFontIndex(FX_WORD word, FX_INT32 nCharset)
+{
+ FX_INT32 nFind = -1;
+
+ for (FX_INT32 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;
+
+ /*
+ if (CPDF_Font* pFont = GetPDFFont(nFind))
+ {
+ PWLFont.AddWordToFontDict(pFontDict, word);
+ }
+ */
+
+#ifdef FOXIT_CHROME_BUILD
+ CFX_ByteString sAlias = EncodeFontAlias("Arial_Chrome", nCharset);
+#else
+ CFX_ByteString sAlias = EncodeFontAlias("Arial_Foxit", nCharset);
+#endif
+ AddedFont(pNewFont, sAlias);
+
+ return AddFontData(pNewFont, sAlias, nCharset);
+}
+
+CPDF_Font* CPWL_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, FX_INT32 nCharset)
+{
+ return NULL;
+}
+
+FX_INT32 CPWL_FontMap::AddFontData(CPDF_Font* pFont, const CFX_ByteString& sFontAlias, FX_INT32 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(FX_INT32 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(FX_INT32 nCharset)
+{
+ CFX_ByteString sFontName;
+
+ if (nCharset == DEFAULT_CHARSET)
+ nCharset = GetNativeCharset();
+
+ 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, FX_BYTE nCharset)
+{
+ if (IsStandardFont(sFontName))
+ return AddStandardFont(pDoc, sFontName);
+ else
+ 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, FX_BYTE 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, FX_INT32 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;
+}
+
+FX_INT32 CPWL_FontMap::GetFontMapCount() const
+{
+ return m_aData.GetSize();
+}
+
+const CPWL_FontMap_Data* CPWL_FontMap::GetFontMapData(FX_INT32 nIndex) const
+{
+ if (nIndex >=0 && nIndex < m_aData.GetSize())
+ {
+ return m_aData.GetAt(nIndex);
+ }
+
+ return NULL;
+}
+
+FX_INT32 CPWL_FontMap::GetNativeCharset()
+{
+ FX_BYTE nCharset = ANSI_CHARSET;
+ FX_INT32 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" },
+ { EASTEUROPE_CHARSET, "Tahoma" },
+ { ARABIC_CHARSET, "Arial" },
+ { -1, NULL }
+};
+
+CFX_ByteString CPWL_FontMap::GetDefaultFontByCharset(FX_INT32 nCharset)
+{
+ int i = 0;
+ while (defaultTTFMap[i].charset != -1) {
+ if (nCharset == defaultTTFMap[i].charset)
+ return defaultTTFMap[i].fontname;
+ ++i;
+ }
+ return "";
+}
+
+FX_INT32 CPWL_FontMap::CharSetFromUnicode(FX_WORD word, FX_INT32 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::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
index a859a52..b85b845 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
@@ -1,272 +1,272 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_Icon.h"
-#include "../../include/pdfwindow/PWL_Utils.h"
-
-/* ------------------------------- CPWL_Image ---------------------------------- */
-
-CPWL_Image::CPWL_Image() : m_pPDFStream(NULL)
-{
-}
-
-CPWL_Image::~CPWL_Image()
-{
-}
-
-CFX_ByteString CPWL_Image::GetImageAppStream()
-{
- CFX_ByteTextBuf sAppStream;
-
- CFX_ByteString sAlias = this->GetImageAlias();
- CPDF_Rect rcPlate = GetClientRect();
- CPDF_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 this->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())
- {
- CPDF_Rect rect = pDict->GetRect("BBox");
-
- fWidth = rect.right - rect.left;
- fHeight = rect.top - rect.bottom;
- }
- }
-}
-
-CPDF_Matrix CPWL_Image::GetImageMatrix()
-{
- if (m_pPDFStream)
- {
- if (CPDF_Dictionary * pDict = m_pPDFStream->GetDict())
- {
- return pDict->GetMatrix("Matrix");
- }
- }
-
- return CPDF_Matrix();
-}
-
-CFX_ByteString CPWL_Image::GetImageAlias()
-{
- if (m_sImageAlias.IsEmpty())
- {
- if (m_pPDFStream)
- {
- if (CPDF_Dictionary * pDict = m_pPDFStream->GetDict())
- {
- return pDict->GetString("Name");
- }
- }
- }
- else
- return m_sImageAlias;
-
- return CFX_ByteString();
-}
-
-void CPWL_Image::SetImageAlias(FX_LPCSTR 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::CPWL_Icon() : m_pIconFit(NULL)
-{
-}
-
-CPWL_Icon::~CPWL_Icon()
-{
-}
-
-FX_INT32 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)
- {
- //m_pIconFit->GetIconPosition(fLeft,fBottom);
- fLeft = 0.0f;
- fBottom = 0.0f;
- CPDF_Array* pA = m_pIconFit->m_pDict->GetArray("A");
- if (pA != NULL)
- {
- FX_DWORD dwCount = pA->GetCount();
- if (dwCount > 0) fLeft = pA->GetNumber(0);
- if (dwCount > 1) fBottom = pA->GetNumber(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;
-
- CPDF_Rect rcPlate = this->GetClientRect();
- fPlateWidth = rcPlate.right - rcPlate.left;
- fPlateHeight = rcPlate.top - rcPlate.bottom;
-
- GetImageSize(fImageWidth,fImageHeight);
-
- FX_INT32 nScaleMethod = this->GetScaleMethod();
-
- /*
- enum ScaleMethod
- {
- Always = 0, //A, Always scale
- Bigger, //B, Scale only when the icon is bigger than the annotation rectangle
- Smaller, //S, Scale only when the icon is smaller then the annotation rectangle
- Never //N, Never scale
- };
- */
-
- 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;
-
- this->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;
- CPDF_Rect rcPlate = this->GetClientRect();
- fPlateWidth = rcPlate.right - rcPlate.left;
- fPlateHeight = rcPlate.top - rcPlate.bottom;
-
- x = (fPlateWidth - fImageFactWidth) * fLeft;
- y = (fPlateHeight - fImageFactHeight) * fBottom;
-}
-
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_Icon.h"
+#include "../../include/pdfwindow/PWL_Utils.h"
+
+/* ------------------------------- CPWL_Image ---------------------------------- */
+
+CPWL_Image::CPWL_Image() : m_pPDFStream(NULL)
+{
+}
+
+CPWL_Image::~CPWL_Image()
+{
+}
+
+CFX_ByteString CPWL_Image::GetImageAppStream()
+{
+ CFX_ByteTextBuf sAppStream;
+
+ CFX_ByteString sAlias = this->GetImageAlias();
+ CPDF_Rect rcPlate = GetClientRect();
+ CPDF_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 this->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())
+ {
+ CPDF_Rect rect = pDict->GetRect("BBox");
+
+ fWidth = rect.right - rect.left;
+ fHeight = rect.top - rect.bottom;
+ }
+ }
+}
+
+CPDF_Matrix CPWL_Image::GetImageMatrix()
+{
+ if (m_pPDFStream)
+ {
+ if (CPDF_Dictionary * pDict = m_pPDFStream->GetDict())
+ {
+ return pDict->GetMatrix("Matrix");
+ }
+ }
+
+ return CPDF_Matrix();
+}
+
+CFX_ByteString CPWL_Image::GetImageAlias()
+{
+ if (m_sImageAlias.IsEmpty())
+ {
+ if (m_pPDFStream)
+ {
+ if (CPDF_Dictionary * pDict = m_pPDFStream->GetDict())
+ {
+ return pDict->GetString("Name");
+ }
+ }
+ }
+ else
+ return m_sImageAlias;
+
+ return CFX_ByteString();
+}
+
+void CPWL_Image::SetImageAlias(FX_LPCSTR 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::CPWL_Icon() : m_pIconFit(NULL)
+{
+}
+
+CPWL_Icon::~CPWL_Icon()
+{
+}
+
+FX_INT32 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)
+ {
+ //m_pIconFit->GetIconPosition(fLeft,fBottom);
+ fLeft = 0.0f;
+ fBottom = 0.0f;
+ CPDF_Array* pA = m_pIconFit->m_pDict->GetArray("A");
+ if (pA != NULL)
+ {
+ FX_DWORD dwCount = pA->GetCount();
+ if (dwCount > 0) fLeft = pA->GetNumber(0);
+ if (dwCount > 1) fBottom = pA->GetNumber(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;
+
+ CPDF_Rect rcPlate = this->GetClientRect();
+ fPlateWidth = rcPlate.right - rcPlate.left;
+ fPlateHeight = rcPlate.top - rcPlate.bottom;
+
+ GetImageSize(fImageWidth,fImageHeight);
+
+ FX_INT32 nScaleMethod = this->GetScaleMethod();
+
+ /*
+ enum ScaleMethod
+ {
+ Always = 0, //A, Always scale
+ Bigger, //B, Scale only when the icon is bigger than the annotation rectangle
+ Smaller, //S, Scale only when the icon is smaller then the annotation rectangle
+ Never //N, Never scale
+ };
+ */
+
+ 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;
+
+ this->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;
+ CPDF_Rect rcPlate = this->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
index 09b6678..7231790 100644
--- a/fpdfsdk/src/pdfwindow/PWL_IconList.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_IconList.cpp
@@ -1,592 +1,592 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_ListCtrl.h"
-#include "../../include/pdfwindow/PWL_IconList.h"
-#include "../../include/pdfwindow/PWL_Utils.h"
-#include "../../include/pdfwindow/PWL_ScrollBar.h"
-#include "../../include/pdfwindow/PWL_Label.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::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, CPDF_Matrix* pUser2Device)
-{
- CPDF_Rect rcClient = GetClientRect();
-
- if (m_bSelected)
- {
- if (this->IsEnabled())
- {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient,
- CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_SELBACKCOLOR,this->GetTransparency()));
- }
- else
- {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient,
- CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_LIGHTGRAYCOLOR,this->GetTransparency()));
- }
- }
-
- CPDF_Rect 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(), this->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(FX_INT32 nIconIndex)
-{
- m_nIconIndex = nIconIndex;
-}
-
-void CPWL_IconList_Item::SetText(const CFX_WideString& str)
-{
- m_pText->SetText(str);
-}
-
-CFX_WideString CPWL_IconList_Item::GetText() const
-{
- return m_pText->GetText();
-}
-
-void CPWL_IconList_Item::RePosChildWnd()
-{
- CPDF_Rect 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);
-
- this->InvalidateRect();
-}
-
-void CPWL_IconList_Item::OnDisabled()
-{
- m_pText->SetTextColor(PWL_DEFAULT_HEAVYGRAYCOLOR);
-
- this->InvalidateRect();
-}
-
-/* ----------------- CPWL_IconList_Content ----------------- */
-
-CPWL_IconList_Content::CPWL_IconList_Content(FX_INT32 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 (FX_INT32 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);
- }
-
- this->SetItemSpace(PWL_IconList_ITEM_SPACE);
- this->ResetContent(0);
-
- if (CPWL_Wnd * pParent = this->GetParentWindow())
- {
- CPDF_Rect rcScroll = this->GetScrollArea();
- this->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, (FX_INTPTR)&sInfo);
- }
-}
-
-FX_BOOL CPWL_IconList_Content::OnLButtonDown(const CPDF_Point & point)
-{
- SetFocus();
-
- SetCapture();
- m_bMouseDown = TRUE;
-
- FX_INT32 nItemIndex = FindItemIndex(point);
- SetSelect(nItemIndex);
- ScrollToItem(nItemIndex);
-
- return TRUE;
-}
-
-FX_BOOL CPWL_IconList_Content::OnLButtonUp(const CPDF_Point & point)
-{
- m_bMouseDown = FALSE;
- ReleaseCapture();
-
- return TRUE;
-}
-
-FX_BOOL CPWL_IconList_Content::OnMouseMove(const CPDF_Point & point)
-{
- if (m_bMouseDown)
- {
- FX_INT32 nItemIndex = FindItemIndex(point);
- SetSelect(nItemIndex);
- ScrollToItem(nItemIndex);
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_IconList_Content::OnKeyDown(FX_WORD nChar)
-{
- switch (nChar)
- {
- case FWL_VKEY_Up:
- if (m_nSelectIndex > 0)
- {
- FX_INT32 nItemIndex = m_nSelectIndex - 1;
- SetSelect(nItemIndex);
- ScrollToItem(nItemIndex);
- }
- return TRUE;
- case FWL_VKEY_Down:
- if (m_nSelectIndex < m_nListCount-1)
- {
- FX_INT32 nItemIndex = m_nSelectIndex + 1;
- SetSelect(nItemIndex);
- ScrollToItem(nItemIndex);
- }
- return TRUE;
- }
-
- return FALSE;
-}
-
-FX_INT32 CPWL_IconList_Content::FindItemIndex(const CPDF_Point& point)
-{
- FX_INT32 nIndex = 0;
- for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
- {
- CPDF_Rect rcWnd = pChild->ChildToParent(pChild->GetWindowRect());
-
- if (point.y < rcWnd.top)
- {
- nIndex = i;
- }
- }
- }
-
- return nIndex;
-}
-
-void CPWL_IconList_Content::ScrollToItem(FX_INT32 nItemIndex)
-{
- CPDF_Rect rcClient = GetClientRect();
-
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- {
- CPDF_Rect rcOrigin = pItem->GetWindowRect();
- CPDF_Rect rcWnd = pItem->ChildToParent(rcOrigin);
-
- if (!(rcWnd.bottom > rcClient.bottom && rcWnd.top < rcClient.top))
- {
- CPDF_Point ptScroll = GetScrollPos();
-
- if (rcWnd.top > rcClient.top)
- {
- ptScroll.y = rcOrigin.top;
- }
- else if (rcWnd.bottom < rcClient.bottom)
- {
- ptScroll.y = rcOrigin.bottom + rcClient.Height();
- }
-
- this->SetScrollPos(ptScroll);
- this->ResetFace();
- this->InvalidateRect();
- if (CPWL_Wnd* pParent = this->GetParentWindow())
- {
- pParent->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y);
- }
- }
- }
-}
-
-void CPWL_IconList_Content::SetSelect(FX_INT32 nIndex)
-{
- if (m_nSelectIndex != nIndex)
- {
- SelectItem(m_nSelectIndex, FALSE);
- SelectItem(nIndex, TRUE);
- m_nSelectIndex = nIndex;
-
- if (IPWL_IconList_Notify* pNotify = GetNotify())
- pNotify->OnNoteListSelChanged(nIndex);
- }
-}
-
-FX_INT32 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(FX_INT32 nItemIndex, FX_BOOL bSelect)
-{
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- {
- pItem->SetSelect(bSelect);
- pItem->InvalidateRect();
- }
-}
-
-CPWL_IconList_Item* CPWL_IconList_Content::GetListItem(FX_INT32 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(FX_INT32 nItemIndex, void* pData)
-{
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- pItem->SetData(pData);
-}
-
-void CPWL_IconList_Content::SetListIcon(FX_INT32 nItemIndex, FX_INT32 nIconIndex)
-{
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- pItem->SetIcon(nIconIndex);
-}
-
-void CPWL_IconList_Content::SetListString(FX_INT32 nItemIndex, const CFX_WideString& str)
-{
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- pItem->SetText(str);
-}
-
-CFX_WideString CPWL_IconList_Content::GetListString(FX_INT32 nItemIndex) const
-{
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- return pItem->GetText();
-
- return L"";
-}
-
-void CPWL_IconList_Content::SetIconFillColor(const CPWL_Color& color)
-{
- for (FX_INT32 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::CPWL_IconList(FX_INT32 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 = this->GetVScrollBar())
- {
- pScrollBar->RemoveFlag(PWS_AUTOTRANSPARENT);
- pScrollBar->SetTransparency(255);
- pScrollBar->SetNotifyForever(TRUE);
- }
-}
-
-void CPWL_IconList::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_INTPTR 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 = this->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(CPDF_Point(0.0f,0.0f));
- }
-
- pScrollBar->OnNotify(pWnd,PNM_SETSCROLLINFO,wParam,lParam);
- }
- }
- return;
- case PNM_SCROLLWINDOW:
- if (m_pListContent)
- {
- m_pListContent->SetScrollPos(CPDF_Point(0.0f, *(FX_FLOAT*)lParam));
- m_pListContent->ResetFace();
- m_pListContent->InvalidateRect(NULL);
- }
- return;
- case PNM_SETSCROLLPOS:
- if (CPWL_ScrollBar* pScrollBar = this->GetVScrollBar())
- pScrollBar->OnNotify(pWnd,PNM_SETSCROLLPOS,wParam,lParam);
- return;
- }
- }
-}
-
-void CPWL_IconList::SetSelect(FX_INT32 nIndex)
-{
- m_pListContent->SetSelect(nIndex);
-}
-
-void CPWL_IconList::SetTopItem(FX_INT32 nIndex)
-{
- m_pListContent->ScrollToItem(nIndex);
-}
-
-FX_INT32 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(FX_INT32 nItemIndex, void* pData)
-{
- m_pListContent->SetListData(nItemIndex, pData);
-}
-
-void CPWL_IconList::SetListIcon(FX_INT32 nItemIndex, FX_INT32 nIconIndex)
-{
- m_pListContent->SetListIcon(nItemIndex, nIconIndex);
-}
-
-void CPWL_IconList::SetListString(FX_INT32 nItemIndex, const CFX_WideString& str)
-{
- m_pListContent->SetListString(nItemIndex, str);
-}
-
-CFX_WideString CPWL_IconList::GetListString(FX_INT32 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 CPDF_Point & point)
-{
- CPDF_Point ptScroll = m_pListContent->GetScrollPos();
- CPDF_Rect rcScroll = m_pListContent->GetScrollArea();
- CPDF_Rect rcContents = m_pListContent->GetClientRect();
-
- if (rcScroll.top - rcScroll.bottom > rcContents.Height())
- {
- CPDF_Point 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 = this->GetVScrollBar())
- pScrollBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptNew.y);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_ListCtrl.h"
+#include "../../include/pdfwindow/PWL_IconList.h"
+#include "../../include/pdfwindow/PWL_Utils.h"
+#include "../../include/pdfwindow/PWL_ScrollBar.h"
+#include "../../include/pdfwindow/PWL_Label.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::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, CPDF_Matrix* pUser2Device)
+{
+ CPDF_Rect rcClient = GetClientRect();
+
+ if (m_bSelected)
+ {
+ if (this->IsEnabled())
+ {
+ CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient,
+ CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_SELBACKCOLOR,this->GetTransparency()));
+ }
+ else
+ {
+ CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient,
+ CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_LIGHTGRAYCOLOR,this->GetTransparency()));
+ }
+ }
+
+ CPDF_Rect 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(), this->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(FX_INT32 nIconIndex)
+{
+ m_nIconIndex = nIconIndex;
+}
+
+void CPWL_IconList_Item::SetText(const CFX_WideString& str)
+{
+ m_pText->SetText(str);
+}
+
+CFX_WideString CPWL_IconList_Item::GetText() const
+{
+ return m_pText->GetText();
+}
+
+void CPWL_IconList_Item::RePosChildWnd()
+{
+ CPDF_Rect 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);
+
+ this->InvalidateRect();
+}
+
+void CPWL_IconList_Item::OnDisabled()
+{
+ m_pText->SetTextColor(PWL_DEFAULT_HEAVYGRAYCOLOR);
+
+ this->InvalidateRect();
+}
+
+/* ----------------- CPWL_IconList_Content ----------------- */
+
+CPWL_IconList_Content::CPWL_IconList_Content(FX_INT32 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 (FX_INT32 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);
+ }
+
+ this->SetItemSpace(PWL_IconList_ITEM_SPACE);
+ this->ResetContent(0);
+
+ if (CPWL_Wnd * pParent = this->GetParentWindow())
+ {
+ CPDF_Rect rcScroll = this->GetScrollArea();
+ this->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, (FX_INTPTR)&sInfo);
+ }
+}
+
+FX_BOOL CPWL_IconList_Content::OnLButtonDown(const CPDF_Point & point)
+{
+ SetFocus();
+
+ SetCapture();
+ m_bMouseDown = TRUE;
+
+ FX_INT32 nItemIndex = FindItemIndex(point);
+ SetSelect(nItemIndex);
+ ScrollToItem(nItemIndex);
+
+ return TRUE;
+}
+
+FX_BOOL CPWL_IconList_Content::OnLButtonUp(const CPDF_Point & point)
+{
+ m_bMouseDown = FALSE;
+ ReleaseCapture();
+
+ return TRUE;
+}
+
+FX_BOOL CPWL_IconList_Content::OnMouseMove(const CPDF_Point & point)
+{
+ if (m_bMouseDown)
+ {
+ FX_INT32 nItemIndex = FindItemIndex(point);
+ SetSelect(nItemIndex);
+ ScrollToItem(nItemIndex);
+ }
+
+ return TRUE;
+}
+
+FX_BOOL CPWL_IconList_Content::OnKeyDown(FX_WORD nChar)
+{
+ switch (nChar)
+ {
+ case FWL_VKEY_Up:
+ if (m_nSelectIndex > 0)
+ {
+ FX_INT32 nItemIndex = m_nSelectIndex - 1;
+ SetSelect(nItemIndex);
+ ScrollToItem(nItemIndex);
+ }
+ return TRUE;
+ case FWL_VKEY_Down:
+ if (m_nSelectIndex < m_nListCount-1)
+ {
+ FX_INT32 nItemIndex = m_nSelectIndex + 1;
+ SetSelect(nItemIndex);
+ ScrollToItem(nItemIndex);
+ }
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+FX_INT32 CPWL_IconList_Content::FindItemIndex(const CPDF_Point& point)
+{
+ FX_INT32 nIndex = 0;
+ for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++)
+ {
+ if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
+ {
+ CPDF_Rect rcWnd = pChild->ChildToParent(pChild->GetWindowRect());
+
+ if (point.y < rcWnd.top)
+ {
+ nIndex = i;
+ }
+ }
+ }
+
+ return nIndex;
+}
+
+void CPWL_IconList_Content::ScrollToItem(FX_INT32 nItemIndex)
+{
+ CPDF_Rect rcClient = GetClientRect();
+
+ if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
+ {
+ CPDF_Rect rcOrigin = pItem->GetWindowRect();
+ CPDF_Rect rcWnd = pItem->ChildToParent(rcOrigin);
+
+ if (!(rcWnd.bottom > rcClient.bottom && rcWnd.top < rcClient.top))
+ {
+ CPDF_Point ptScroll = GetScrollPos();
+
+ if (rcWnd.top > rcClient.top)
+ {
+ ptScroll.y = rcOrigin.top;
+ }
+ else if (rcWnd.bottom < rcClient.bottom)
+ {
+ ptScroll.y = rcOrigin.bottom + rcClient.Height();
+ }
+
+ this->SetScrollPos(ptScroll);
+ this->ResetFace();
+ this->InvalidateRect();
+ if (CPWL_Wnd* pParent = this->GetParentWindow())
+ {
+ pParent->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y);
+ }
+ }
+ }
+}
+
+void CPWL_IconList_Content::SetSelect(FX_INT32 nIndex)
+{
+ if (m_nSelectIndex != nIndex)
+ {
+ SelectItem(m_nSelectIndex, FALSE);
+ SelectItem(nIndex, TRUE);
+ m_nSelectIndex = nIndex;
+
+ if (IPWL_IconList_Notify* pNotify = GetNotify())
+ pNotify->OnNoteListSelChanged(nIndex);
+ }
+}
+
+FX_INT32 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(FX_INT32 nItemIndex, FX_BOOL bSelect)
+{
+ if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
+ {
+ pItem->SetSelect(bSelect);
+ pItem->InvalidateRect();
+ }
+}
+
+CPWL_IconList_Item* CPWL_IconList_Content::GetListItem(FX_INT32 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(FX_INT32 nItemIndex, void* pData)
+{
+ if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
+ pItem->SetData(pData);
+}
+
+void CPWL_IconList_Content::SetListIcon(FX_INT32 nItemIndex, FX_INT32 nIconIndex)
+{
+ if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
+ pItem->SetIcon(nIconIndex);
+}
+
+void CPWL_IconList_Content::SetListString(FX_INT32 nItemIndex, const CFX_WideString& str)
+{
+ if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
+ pItem->SetText(str);
+}
+
+CFX_WideString CPWL_IconList_Content::GetListString(FX_INT32 nItemIndex) const
+{
+ if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
+ return pItem->GetText();
+
+ return L"";
+}
+
+void CPWL_IconList_Content::SetIconFillColor(const CPWL_Color& color)
+{
+ for (FX_INT32 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::CPWL_IconList(FX_INT32 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 = this->GetVScrollBar())
+ {
+ pScrollBar->RemoveFlag(PWS_AUTOTRANSPARENT);
+ pScrollBar->SetTransparency(255);
+ pScrollBar->SetNotifyForever(TRUE);
+ }
+}
+
+void CPWL_IconList::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_INTPTR 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 = this->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(CPDF_Point(0.0f,0.0f));
+ }
+
+ pScrollBar->OnNotify(pWnd,PNM_SETSCROLLINFO,wParam,lParam);
+ }
+ }
+ return;
+ case PNM_SCROLLWINDOW:
+ if (m_pListContent)
+ {
+ m_pListContent->SetScrollPos(CPDF_Point(0.0f, *(FX_FLOAT*)lParam));
+ m_pListContent->ResetFace();
+ m_pListContent->InvalidateRect(NULL);
+ }
+ return;
+ case PNM_SETSCROLLPOS:
+ if (CPWL_ScrollBar* pScrollBar = this->GetVScrollBar())
+ pScrollBar->OnNotify(pWnd,PNM_SETSCROLLPOS,wParam,lParam);
+ return;
+ }
+ }
+}
+
+void CPWL_IconList::SetSelect(FX_INT32 nIndex)
+{
+ m_pListContent->SetSelect(nIndex);
+}
+
+void CPWL_IconList::SetTopItem(FX_INT32 nIndex)
+{
+ m_pListContent->ScrollToItem(nIndex);
+}
+
+FX_INT32 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(FX_INT32 nItemIndex, void* pData)
+{
+ m_pListContent->SetListData(nItemIndex, pData);
+}
+
+void CPWL_IconList::SetListIcon(FX_INT32 nItemIndex, FX_INT32 nIconIndex)
+{
+ m_pListContent->SetListIcon(nItemIndex, nIconIndex);
+}
+
+void CPWL_IconList::SetListString(FX_INT32 nItemIndex, const CFX_WideString& str)
+{
+ m_pListContent->SetListString(nItemIndex, str);
+}
+
+CFX_WideString CPWL_IconList::GetListString(FX_INT32 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 CPDF_Point & point)
+{
+ CPDF_Point ptScroll = m_pListContent->GetScrollPos();
+ CPDF_Rect rcScroll = m_pListContent->GetScrollArea();
+ CPDF_Rect rcContents = m_pListContent->GetClientRect();
+
+ if (rcScroll.top - rcScroll.bottom > rcContents.Height())
+ {
+ CPDF_Point 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 = this->GetVScrollBar())
+ pScrollBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptNew.y);
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
diff --git a/fpdfsdk/src/pdfwindow/PWL_Label.cpp b/fpdfsdk/src/pdfwindow/PWL_Label.cpp
index e1b8522..18580f3 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Label.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Label.cpp
@@ -1,187 +1,187 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_Label.h"
-#include "../../include/pdfwindow/PWL_Utils.h"
-
-/* ---------------------------- CPWL_Label ------------------------------ */
-
-CPWL_Label::CPWL_Label() : m_pEdit(NULL)
-{
- m_pEdit = IFX_Edit::NewEdit();
-
- ASSERT(m_pEdit != NULL);
-}
-
-CPWL_Label::~CPWL_Label()
-{
- IFX_Edit::DelEdit(m_pEdit);
-}
-
-CFX_ByteString CPWL_Label::GetClassName() const
-{
- return "CPWL_Label";
-}
-
-void CPWL_Label::OnCreated()
-{
- SetParamByFlag();
- SetFontSize(this->GetCreationParam().fFontSize);
-
- m_pEdit->SetFontMap(this->GetFontMap());
- m_pEdit->Initialize();
-
- if (HasFlag(PES_TEXTOVERFLOW))
- {
- SetClipRect(CPDF_Rect(0.0f,0.0f,0.0f,0.0f));
- m_pEdit->SetTextOverflow(TRUE);
- }
-}
-
-void CPWL_Label::SetText(FX_LPCWSTR 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, CPDF_Matrix* pUser2Device)
-{
- CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
-
- GetClientRect();
-
- CPDF_Rect 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(), this->GetTransparency()),
- CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), this->GetTransparency()),
- rcClip, CPDF_Point(0.0f,0.0f), pRange,pSysHandler, NULL);
-}
-
-void CPWL_Label::SetHorzScale(FX_INT32 nHorzScale)
-{
- m_pEdit->SetHorzScale(nHorzScale);
-}
-
-void CPWL_Label::SetCharSpace(FX_FLOAT fCharSpace)
-{
- m_pEdit->SetCharSpace(fCharSpace);
-}
-
-CPDF_Rect CPWL_Label::GetContentRect() const
-{
- return m_pEdit->GetContentRect();
-}
-
-void CPWL_Label::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
-{
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
-
- sAppStream << GetTextAppearanceStream(CPDF_Point(0.0f, 0.0f));
-}
-
-CFX_ByteString CPWL_Label::GetTextAppearanceStream(const CPDF_Point & 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(FX_INT32 nLimitChar)
-{
- m_pEdit->SetLimitChar(nLimitChar);
-}
-
-FX_INT32 CPWL_Label::GetTotalWords()
-{
- if (m_pEdit)
- return m_pEdit->GetTotalWords();
-
- return 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_Label.h"
+#include "../../include/pdfwindow/PWL_Utils.h"
+
+/* ---------------------------- CPWL_Label ------------------------------ */
+
+CPWL_Label::CPWL_Label() : m_pEdit(NULL)
+{
+ m_pEdit = IFX_Edit::NewEdit();
+
+ ASSERT(m_pEdit != NULL);
+}
+
+CPWL_Label::~CPWL_Label()
+{
+ IFX_Edit::DelEdit(m_pEdit);
+}
+
+CFX_ByteString CPWL_Label::GetClassName() const
+{
+ return "CPWL_Label";
+}
+
+void CPWL_Label::OnCreated()
+{
+ SetParamByFlag();
+ SetFontSize(this->GetCreationParam().fFontSize);
+
+ m_pEdit->SetFontMap(this->GetFontMap());
+ m_pEdit->Initialize();
+
+ if (HasFlag(PES_TEXTOVERFLOW))
+ {
+ SetClipRect(CPDF_Rect(0.0f,0.0f,0.0f,0.0f));
+ m_pEdit->SetTextOverflow(TRUE);
+ }
+}
+
+void CPWL_Label::SetText(FX_LPCWSTR 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, CPDF_Matrix* pUser2Device)
+{
+ CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
+
+ GetClientRect();
+
+ CPDF_Rect 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(), this->GetTransparency()),
+ CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), this->GetTransparency()),
+ rcClip, CPDF_Point(0.0f,0.0f), pRange,pSysHandler, NULL);
+}
+
+void CPWL_Label::SetHorzScale(FX_INT32 nHorzScale)
+{
+ m_pEdit->SetHorzScale(nHorzScale);
+}
+
+void CPWL_Label::SetCharSpace(FX_FLOAT fCharSpace)
+{
+ m_pEdit->SetCharSpace(fCharSpace);
+}
+
+CPDF_Rect CPWL_Label::GetContentRect() const
+{
+ return m_pEdit->GetContentRect();
+}
+
+void CPWL_Label::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
+{
+ CPWL_Wnd::GetThisAppearanceStream(sAppStream);
+
+ sAppStream << GetTextAppearanceStream(CPDF_Point(0.0f, 0.0f));
+}
+
+CFX_ByteString CPWL_Label::GetTextAppearanceStream(const CPDF_Point & 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(FX_INT32 nLimitChar)
+{
+ m_pEdit->SetLimitChar(nLimitChar);
+}
+
+FX_INT32 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
index 951ed93..035d819 100644
--- a/fpdfsdk/src/pdfwindow/PWL_ListBox.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_ListBox.cpp
@@ -1,632 +1,632 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_ListBox.h"
-#include "../../include/pdfwindow/PWL_Utils.h"
-#include "../../include/pdfwindow/PWL_ScrollBar.h"
-#include "../../include/pdfwindow/PWL_EditCtrl.h"
-#include "../../include/pdfwindow/PWL_Edit.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_List_Notify(CPWL_ListBox* pList) : m_pList(pList)
-{
- ASSERT(m_pList != NULL);
-}
-
-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,(FX_INTPTR)&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,(FX_INTPTR)&fy);
-}
-
-void CPWL_List_Notify::IOnInvalidateRect(CPDF_Rect * pRect)
-{
- m_pList->InvalidateRect(pRect);
-}
-
-/* --------------------------- CPWL_ListBox ---------------------------- */
-
-CPWL_ListBox::CPWL_ListBox() :
- m_pList(NULL),
- m_pListNotify(NULL),
- m_bMouseDown(FALSE),
- m_bHoverSel(FALSE),
- m_pFillerNotify(NULL)
-{
- m_pList = IFX_List::NewList();
-
- ASSERT(m_pList != NULL);
-}
-
-CPWL_ListBox::~CPWL_ListBox()
-{
- IFX_List::DelList(m_pList);
-
- if (m_pListNotify)
- {
- delete m_pListNotify;
- m_pListNotify = NULL;
- }
-}
-
-CFX_ByteString CPWL_ListBox::GetClassName() const
-{
- return "CPWL_ListBox";
-}
-
-void CPWL_ListBox::OnCreated()
-{
- if (m_pList)
- {
- if (m_pListNotify) 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(this->GetCreationParam().fFontSize);
-
- m_bHoverSel = HasFlag(PLBS_HOVERSEL);
- }
-}
-
-void CPWL_ListBox::OnDestroy()
-{
- if (m_pListNotify)
- {
- delete m_pListNotify;
- m_pListNotify = NULL;
- }
-}
-
-void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
-{
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
-
- CFX_ByteTextBuf sListItems;
-
- if (m_pList)
- {
- CPDF_Rect rcPlate = m_pList->GetPlateRect();
- for (FX_INT32 i=0,sz=m_pList->GetCount(); i<sz; i++)
- {
- CPDF_Rect rcItem = m_pList->GetItemRect(i);
-
- if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom) continue;
-
- CPDF_Point 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;
- CPDF_Rect rcClient = this->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, CPDF_Matrix* pUser2Device)
-{
- CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
-
- if (m_pList)
- {
- CPDF_Rect rcPlate = m_pList->GetPlateRect();
- CPDF_Rect rcList = GetListRect();
- CPDF_Rect rcClient = GetClientRect();
-
- for (FX_INT32 i=0,sz=m_pList->GetCount(); i<sz; i++)
- {
- CPDF_Rect rcItem = m_pList->GetItemRect(i);
- if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom) continue;
-
- CPDF_Point ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f);
- if (IFX_Edit* pEdit = m_pList->GetItemEdit(i))
- {
- CPDF_Rect rcContent = pEdit->GetContentRect();
- if (rcContent.Width() > rcClient.Width())
- rcItem.Intersect(rcList);
- else
- rcItem.Intersect(rcClient);
- }
-
- if (m_pList->IsItemSelected(i))
- {
- // CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcItem, ArgbEncode(255,0,51,113));
- 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 CPDF_Point & 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 CPDF_Point & 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 CPDF_Point & 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, FX_INTPTR wParam, FX_INTPTR 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(CPDF_Point(0,fPos));
- break;
- }
- break;
- }
-}
-
-void CPWL_ListBox::KillFocus()
-{
- CPWL_Wnd::KillFocus();
-
- /*
- if (this->IsMultipleSel())
- {
- for(FX_INT32 i=0;i<this->GetCount();i++)
- {
- if (this->IsListItemSelected(i))
- {
- if (!IsListItemVisible(i))
- this->ScrollToListItem(i);
- break;
- }
- }
- }
- else
- {
- if (!IsListItemVisible(this->GetCurSel()))
- this->ScrollToListItem(this->GetCurSel());
- }
-
- SetListItemCaret(m_nCaretIndex,FALSE);
- */
-}
-
-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)
- {
- FX_BOOL bRC = TRUE;
- CFX_WideString swChange = GetText();
- CFX_WideString strChangeEx;
- int nSelStart = 0;
- int nSelEnd = swChange.GetLength();
- m_pFillerNotify->OnBeforeKeyStroke(FALSE, GetAttachedData(), 0, swChange, strChangeEx, nSelStart, nSelEnd, bKeyDown, bRC, bExit, nFlag);
- if (bExit) return;
-
- m_pFillerNotify->OnAfterKeyStroke(FALSE, GetAttachedData(), bExit,nFlag);
- }
-}
-
-CPDF_Rect CPWL_ListBox::GetFocusRect() const
-{
- if (m_pList && m_pList->IsMultipleSel())
- {
- CPDF_Rect rcCaret = m_pList->GetItemRect(m_pList->GetCaret());
- rcCaret.Intersect(GetClientRect());
- return rcCaret;
- }
-
- return CPWL_Wnd::GetFocusRect();
-}
-
-void CPWL_ListBox::AddString(FX_LPCWSTR string)
-{
- if (m_pList)
- {
- m_pList->AddString(string);
- }
-}
-
-void CPWL_ListBox::SetText(FX_LPCWSTR csText,FX_BOOL bRefresh)
-{
- //return CPDF_List::SetText(csText,bRefresh);
-}
-
-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(FX_INT32 nItemIndex)
-{
- if (m_pList)
- m_pList->Select(nItemIndex);
-}
-
-void CPWL_ListBox::SetCaret(FX_INT32 nItemIndex)
-{
- if (m_pList)
- m_pList->SetCaret(nItemIndex);
-}
-
-void CPWL_ListBox::SetTopVisibleIndex(FX_INT32 nItemIndex)
-{
- if (m_pList)
- m_pList->SetTopItem(nItemIndex);
-}
-
-void CPWL_ListBox::ScrollToListItem(FX_INT32 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;
-}
-
-FX_INT32 CPWL_ListBox::GetCaretIndex() const
-{
- if (m_pList)
- return m_pList->GetCaret();
-
- return -1;
-}
-
-FX_INT32 CPWL_ListBox::GetCurSel() const
-{
- if (m_pList)
- return m_pList->GetSelect();
-
- return -1;
-}
-
-FX_BOOL CPWL_ListBox::IsItemSelected(FX_INT32 nItemIndex) const
-{
- if (m_pList)
- return m_pList->IsItemSelected(nItemIndex);
-
- return FALSE;
-}
-
-FX_INT32 CPWL_ListBox::GetTopVisibleIndex() const
-{
- if (m_pList)
- {
- m_pList->ScrollToListItem(m_pList->GetFirstSelected());
- return m_pList->GetTopItem();
- }
-
- return -1;
-}
-
-FX_INT32 CPWL_ListBox::GetCount() const
-{
- if (m_pList)
- return m_pList->GetCount();
-
- return 0;
-}
-
-FX_INT32 CPWL_ListBox::FindNext(FX_INT32 nIndex,FX_WCHAR nChar) const
-{
- if (m_pList)
- return m_pList->FindNext(nIndex,nChar);
-
- return nIndex;
-}
-
-CPDF_Rect CPWL_ListBox::GetContentRect() const
-{
- if (m_pList)
- return m_pList->GetContentRect();
-
- return CPDF_Rect();
-}
-
-FX_FLOAT CPWL_ListBox::GetFirstHeight() const
-{
- if (m_pList)
- return m_pList->GetFirstHeight();
-
- return 0.0f;
-}
-
-CPDF_Rect CPWL_ListBox::GetListRect() const
-{
- return CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
-}
-
-FX_BOOL CPWL_ListBox::OnMouseWheel(short zDelta, const CPDF_Point & 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;
-}
-
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_ListBox.h"
+#include "../../include/pdfwindow/PWL_Utils.h"
+#include "../../include/pdfwindow/PWL_ScrollBar.h"
+#include "../../include/pdfwindow/PWL_EditCtrl.h"
+#include "../../include/pdfwindow/PWL_Edit.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_List_Notify(CPWL_ListBox* pList) : m_pList(pList)
+{
+ ASSERT(m_pList != NULL);
+}
+
+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,(FX_INTPTR)&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,(FX_INTPTR)&fy);
+}
+
+void CPWL_List_Notify::IOnInvalidateRect(CPDF_Rect * pRect)
+{
+ m_pList->InvalidateRect(pRect);
+}
+
+/* --------------------------- CPWL_ListBox ---------------------------- */
+
+CPWL_ListBox::CPWL_ListBox() :
+ m_pList(NULL),
+ m_pListNotify(NULL),
+ m_bMouseDown(FALSE),
+ m_bHoverSel(FALSE),
+ m_pFillerNotify(NULL)
+{
+ m_pList = IFX_List::NewList();
+
+ ASSERT(m_pList != NULL);
+}
+
+CPWL_ListBox::~CPWL_ListBox()
+{
+ IFX_List::DelList(m_pList);
+
+ if (m_pListNotify)
+ {
+ delete m_pListNotify;
+ m_pListNotify = NULL;
+ }
+}
+
+CFX_ByteString CPWL_ListBox::GetClassName() const
+{
+ return "CPWL_ListBox";
+}
+
+void CPWL_ListBox::OnCreated()
+{
+ if (m_pList)
+ {
+ if (m_pListNotify) 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(this->GetCreationParam().fFontSize);
+
+ m_bHoverSel = HasFlag(PLBS_HOVERSEL);
+ }
+}
+
+void CPWL_ListBox::OnDestroy()
+{
+ if (m_pListNotify)
+ {
+ delete m_pListNotify;
+ m_pListNotify = NULL;
+ }
+}
+
+void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
+{
+ CPWL_Wnd::GetThisAppearanceStream(sAppStream);
+
+ CFX_ByteTextBuf sListItems;
+
+ if (m_pList)
+ {
+ CPDF_Rect rcPlate = m_pList->GetPlateRect();
+ for (FX_INT32 i=0,sz=m_pList->GetCount(); i<sz; i++)
+ {
+ CPDF_Rect rcItem = m_pList->GetItemRect(i);
+
+ if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom) continue;
+
+ CPDF_Point 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;
+ CPDF_Rect rcClient = this->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, CPDF_Matrix* pUser2Device)
+{
+ CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
+
+ if (m_pList)
+ {
+ CPDF_Rect rcPlate = m_pList->GetPlateRect();
+ CPDF_Rect rcList = GetListRect();
+ CPDF_Rect rcClient = GetClientRect();
+
+ for (FX_INT32 i=0,sz=m_pList->GetCount(); i<sz; i++)
+ {
+ CPDF_Rect rcItem = m_pList->GetItemRect(i);
+ if (rcItem.bottom > rcPlate.top || rcItem.top < rcPlate.bottom) continue;
+
+ CPDF_Point ptOffset(rcItem.left, (rcItem.top + rcItem.bottom) * 0.5f);
+ if (IFX_Edit* pEdit = m_pList->GetItemEdit(i))
+ {
+ CPDF_Rect rcContent = pEdit->GetContentRect();
+ if (rcContent.Width() > rcClient.Width())
+ rcItem.Intersect(rcList);
+ else
+ rcItem.Intersect(rcClient);
+ }
+
+ if (m_pList->IsItemSelected(i))
+ {
+ // CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcItem, ArgbEncode(255,0,51,113));
+ 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 CPDF_Point & 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 CPDF_Point & 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 CPDF_Point & 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, FX_INTPTR wParam, FX_INTPTR 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(CPDF_Point(0,fPos));
+ break;
+ }
+ break;
+ }
+}
+
+void CPWL_ListBox::KillFocus()
+{
+ CPWL_Wnd::KillFocus();
+
+ /*
+ if (this->IsMultipleSel())
+ {
+ for(FX_INT32 i=0;i<this->GetCount();i++)
+ {
+ if (this->IsListItemSelected(i))
+ {
+ if (!IsListItemVisible(i))
+ this->ScrollToListItem(i);
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (!IsListItemVisible(this->GetCurSel()))
+ this->ScrollToListItem(this->GetCurSel());
+ }
+
+ SetListItemCaret(m_nCaretIndex,FALSE);
+ */
+}
+
+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)
+ {
+ FX_BOOL bRC = TRUE;
+ CFX_WideString swChange = GetText();
+ CFX_WideString strChangeEx;
+ int nSelStart = 0;
+ int nSelEnd = swChange.GetLength();
+ m_pFillerNotify->OnBeforeKeyStroke(FALSE, GetAttachedData(), 0, swChange, strChangeEx, nSelStart, nSelEnd, bKeyDown, bRC, bExit, nFlag);
+ if (bExit) return;
+
+ m_pFillerNotify->OnAfterKeyStroke(FALSE, GetAttachedData(), bExit,nFlag);
+ }
+}
+
+CPDF_Rect CPWL_ListBox::GetFocusRect() const
+{
+ if (m_pList && m_pList->IsMultipleSel())
+ {
+ CPDF_Rect rcCaret = m_pList->GetItemRect(m_pList->GetCaret());
+ rcCaret.Intersect(GetClientRect());
+ return rcCaret;
+ }
+
+ return CPWL_Wnd::GetFocusRect();
+}
+
+void CPWL_ListBox::AddString(FX_LPCWSTR string)
+{
+ if (m_pList)
+ {
+ m_pList->AddString(string);
+ }
+}
+
+void CPWL_ListBox::SetText(FX_LPCWSTR csText,FX_BOOL bRefresh)
+{
+ //return CPDF_List::SetText(csText,bRefresh);
+}
+
+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(FX_INT32 nItemIndex)
+{
+ if (m_pList)
+ m_pList->Select(nItemIndex);
+}
+
+void CPWL_ListBox::SetCaret(FX_INT32 nItemIndex)
+{
+ if (m_pList)
+ m_pList->SetCaret(nItemIndex);
+}
+
+void CPWL_ListBox::SetTopVisibleIndex(FX_INT32 nItemIndex)
+{
+ if (m_pList)
+ m_pList->SetTopItem(nItemIndex);
+}
+
+void CPWL_ListBox::ScrollToListItem(FX_INT32 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;
+}
+
+FX_INT32 CPWL_ListBox::GetCaretIndex() const
+{
+ if (m_pList)
+ return m_pList->GetCaret();
+
+ return -1;
+}
+
+FX_INT32 CPWL_ListBox::GetCurSel() const
+{
+ if (m_pList)
+ return m_pList->GetSelect();
+
+ return -1;
+}
+
+FX_BOOL CPWL_ListBox::IsItemSelected(FX_INT32 nItemIndex) const
+{
+ if (m_pList)
+ return m_pList->IsItemSelected(nItemIndex);
+
+ return FALSE;
+}
+
+FX_INT32 CPWL_ListBox::GetTopVisibleIndex() const
+{
+ if (m_pList)
+ {
+ m_pList->ScrollToListItem(m_pList->GetFirstSelected());
+ return m_pList->GetTopItem();
+ }
+
+ return -1;
+}
+
+FX_INT32 CPWL_ListBox::GetCount() const
+{
+ if (m_pList)
+ return m_pList->GetCount();
+
+ return 0;
+}
+
+FX_INT32 CPWL_ListBox::FindNext(FX_INT32 nIndex,FX_WCHAR nChar) const
+{
+ if (m_pList)
+ return m_pList->FindNext(nIndex,nChar);
+
+ return nIndex;
+}
+
+CPDF_Rect CPWL_ListBox::GetContentRect() const
+{
+ if (m_pList)
+ return m_pList->GetContentRect();
+
+ return CPDF_Rect();
+}
+
+FX_FLOAT CPWL_ListBox::GetFirstHeight() const
+{
+ if (m_pList)
+ return m_pList->GetFirstHeight();
+
+ return 0.0f;
+}
+
+CPDF_Rect CPWL_ListBox::GetListRect() const
+{
+ return CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
+}
+
+FX_BOOL CPWL_ListBox::OnMouseWheel(short zDelta, const CPDF_Point & 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
index 603bb4a..9ac18fd 100644
--- a/fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp
@@ -1,245 +1,245 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_ListCtrl.h"
-
-/* ---------------------------- CPWL_ListCtrl ---------------------------- */
-
-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 CPDF_Point& 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;
-}
-
-CPDF_Point CPWL_ListCtrl::GetScrollPos() const
-{
- return m_ptScroll;
-}
-
-CPDF_Rect CPWL_ListCtrl::GetScrollArea() const
-{
- return m_rcContent;
-}
-
-void CPWL_ListCtrl::ResetFace()
-{
- ResetAll(FALSE, 0);
-}
-
-void CPWL_ListCtrl::ResetContent(FX_INT32 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)this->GetBorderWidth();
-
- if (fLimitWidth > fBorderWidth* 2)
- {
- for (FX_INT32 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, FX_INT32 nStart)
-{
- CPDF_Rect 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 (FX_INT32 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(
- CPDF_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(CPDF_Rect(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, CPDF_Matrix* pUser2Device)
-{
- pDevice->SaveState();
- CPDF_Rect rcClient = GetClientRect();
- CPDF_Rect rcTemp = rcClient;
- pUser2Device->TransformRect(rcTemp);
- FX_RECT rcClip((FX_INT32)rcTemp.left,
- (FX_INT32)rcTemp.bottom,
- (FX_INT32)rcTemp.right,
- (FX_INT32)rcTemp.top);
-
- pDevice->SetClip_Rect(&rcClip);
-
- for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
- {
- CPDF_Rect rcChild = pChild->ChildToParent(pChild->GetWindowRect());
- if (!(rcChild.top < rcClient.bottom || rcChild.bottom > rcClient.top))
- {
- CPDF_Matrix mt = pChild->GetChildMatrix();
- if (mt.IsIdentity())
- {
- pChild->DrawAppearance(pDevice,pUser2Device);
- }
- else
- {
- mt.Concat(*pUser2Device);
- pChild->DrawAppearance(pDevice,&mt);
- }
- }
- }
- }
-
- pDevice->RestoreState();
-}
-
-FX_INT32 CPWL_ListCtrl::GetItemIndex(CPWL_Wnd* pItem)
-{
- for (FX_INT32 i=0, sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (pItem == m_aChildren.GetAt(i))
- return i;
- }
-
- return -1;
-}
-
-CPDF_Point CPWL_ListCtrl::InToOut(const CPDF_Point& point) const
-{
- CPDF_Rect rcClient = GetClientRect();
-
- return CPDF_Point(point.x + rcClient.left - m_ptScroll.x,
- point.y + rcClient.top - m_ptScroll.y);
-}
-
-CPDF_Point CPWL_ListCtrl::OutToIn(const CPDF_Point& point) const
-{
- CPDF_Rect rcClient = GetClientRect();
-
- return CPDF_Point(point.x - rcClient.left + m_ptScroll.x,
- point.y - rcClient.top + m_ptScroll.y);
-}
-
-CPDF_Rect CPWL_ListCtrl::InToOut(const CPDF_Rect& rect) const
-{
- CPDF_Rect rcClient = GetClientRect();
-
- return CPDF_Rect(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);
-}
-
-CPDF_Rect CPWL_ListCtrl::OutToIn(const CPDF_Rect& rect) const
-{
- CPDF_Rect rcClient = GetClientRect();
-
- return CPDF_Rect(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);
-}
-
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_ListCtrl.h"
+
+/* ---------------------------- CPWL_ListCtrl ---------------------------- */
+
+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 CPDF_Point& 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;
+}
+
+CPDF_Point CPWL_ListCtrl::GetScrollPos() const
+{
+ return m_ptScroll;
+}
+
+CPDF_Rect CPWL_ListCtrl::GetScrollArea() const
+{
+ return m_rcContent;
+}
+
+void CPWL_ListCtrl::ResetFace()
+{
+ ResetAll(FALSE, 0);
+}
+
+void CPWL_ListCtrl::ResetContent(FX_INT32 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)this->GetBorderWidth();
+
+ if (fLimitWidth > fBorderWidth* 2)
+ {
+ for (FX_INT32 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, FX_INT32 nStart)
+{
+ CPDF_Rect 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 (FX_INT32 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(
+ CPDF_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(CPDF_Rect(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, CPDF_Matrix* pUser2Device)
+{
+ pDevice->SaveState();
+ CPDF_Rect rcClient = GetClientRect();
+ CPDF_Rect rcTemp = rcClient;
+ pUser2Device->TransformRect(rcTemp);
+ FX_RECT rcClip((FX_INT32)rcTemp.left,
+ (FX_INT32)rcTemp.bottom,
+ (FX_INT32)rcTemp.right,
+ (FX_INT32)rcTemp.top);
+
+ pDevice->SetClip_Rect(&rcClip);
+
+ for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++)
+ {
+ if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
+ {
+ CPDF_Rect rcChild = pChild->ChildToParent(pChild->GetWindowRect());
+ if (!(rcChild.top < rcClient.bottom || rcChild.bottom > rcClient.top))
+ {
+ CPDF_Matrix mt = pChild->GetChildMatrix();
+ if (mt.IsIdentity())
+ {
+ pChild->DrawAppearance(pDevice,pUser2Device);
+ }
+ else
+ {
+ mt.Concat(*pUser2Device);
+ pChild->DrawAppearance(pDevice,&mt);
+ }
+ }
+ }
+ }
+
+ pDevice->RestoreState();
+}
+
+FX_INT32 CPWL_ListCtrl::GetItemIndex(CPWL_Wnd* pItem)
+{
+ for (FX_INT32 i=0, sz=m_aChildren.GetSize(); i<sz; i++)
+ {
+ if (pItem == m_aChildren.GetAt(i))
+ return i;
+ }
+
+ return -1;
+}
+
+CPDF_Point CPWL_ListCtrl::InToOut(const CPDF_Point& point) const
+{
+ CPDF_Rect rcClient = GetClientRect();
+
+ return CPDF_Point(point.x + rcClient.left - m_ptScroll.x,
+ point.y + rcClient.top - m_ptScroll.y);
+}
+
+CPDF_Point CPWL_ListCtrl::OutToIn(const CPDF_Point& point) const
+{
+ CPDF_Rect rcClient = GetClientRect();
+
+ return CPDF_Point(point.x - rcClient.left + m_ptScroll.x,
+ point.y - rcClient.top + m_ptScroll.y);
+}
+
+CPDF_Rect CPWL_ListCtrl::InToOut(const CPDF_Rect& rect) const
+{
+ CPDF_Rect rcClient = GetClientRect();
+
+ return CPDF_Rect(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);
+}
+
+CPDF_Rect CPWL_ListCtrl::OutToIn(const CPDF_Rect& rect) const
+{
+ CPDF_Rect rcClient = GetClientRect();
+
+ return CPDF_Rect(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
index 3c6d866..5929a35 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Note.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Note.cpp
@@ -1,1779 +1,1779 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_Button.h"
-#include "../../include/pdfwindow/PWL_EditCtrl.h"
-#include "../../include/pdfwindow/PWL_Edit.h"
-#include "../../include/pdfwindow/PWL_ListCtrl.h"
-#include "../../include/pdfwindow/PWL_ScrollBar.h"
-#include "../../include/pdfwindow/PWL_Note.h"
-#include "../../include/pdfwindow/PWL_Label.h"
-#include "../../include/pdfwindow/PWL_Edit.h"
-#include "../../include/pdfwindow/PWL_ScrollBar.h"
-#include "../../include/pdfwindow/PWL_Utils.h"
-#include "../../include/pdfwindow/PWL_Caret.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::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 (this->IsValid())
- {
- ASSERT(m_pText != NULL);
-
- CPDF_Rect 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(CPDF_Rect(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);
-}
-
-void CPWL_Note_Options::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
-
- CPDF_Rect rcClient = GetClientRect();
- rcClient.left = rcClient.right - 15.0f;
-
- CPDF_Point ptCenter = CPDF_Point((rcClient.left + rcClient.right) * 0.5f, (rcClient.top + rcClient.bottom) * 0.5f);
-
- CPDF_Point pt1(ptCenter.x - 2.0f, ptCenter.y + 2.0f * 0.5f);
- CPDF_Point pt2(ptCenter.x + 2.0f, ptCenter.y + 2.0f * 0.5f);
- CPDF_Point 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);
-}
-
-CPDF_Rect CPWL_Note_Options::GetContentRect() const
-{
- ASSERT(m_pText != NULL);
-
- CPDF_Rect rcText = m_pText->GetContentRect();
- rcText.right += 15.0f;
- return rcText;
-}
-
-/* ------------------------------- CPWL_Note_Edit ------------------------------ */
-
-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 = this->GetContentRect().Height();
-}
-
-void CPWL_Note_Edit::SetText(FX_LPCWSTR csText)
-{
- m_bEnableNotify = FALSE;
- CPWL_Edit::SetText(csText);
- m_bEnableNotify = TRUE;
- m_fOldItemHeight = this->GetContentRect().Height();
-}
-
-void CPWL_Note_Edit::OnSetFocus()
-{
- m_bEnableNotify = FALSE;
- CPWL_Edit::OnSetFocus();
- m_bEnableNotify = TRUE;
-
- this->EnableSpellCheck(TRUE);
-}
-
-void CPWL_Note_Edit::OnKillFocus()
-{
- this->EnableSpellCheck(FALSE);
-
- if (CPWL_Wnd* pParent = this->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, FX_INTPTR wParam, FX_INTPTR 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 = this->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 = this->ChildToParent(pInfo->ptHead);
- newInfo.ptFoot = this->ChildToParent(pInfo->ptFoot);
-
- if (CPWL_Wnd * pParent = this->GetParentWindow())
- {
- pParent->OnNotify(this, PNM_SETCARETINFO, (FX_INTPTR)&newInfo, 0);
- }
- }
- break;
- }
- }
-}
-
-FX_FLOAT CPWL_Note_Edit::GetItemHeight(FX_FLOAT fLimitWidth)
-{
- if (fLimitWidth > 0)
- {
- if (!m_bSizeChanged)
- return m_fOldItemHeight;
-
- m_bSizeChanged = FALSE;
-
- this->EnableNotify(FALSE);
- this->EnableRefresh(FALSE);
- m_pEdit->EnableNotify(FALSE);
-
- //CPDF_Rect rcOld = this->GetWindowRect();
-
- this->Move(CPDF_Rect(0,0,fLimitWidth,0), TRUE, FALSE);
- FX_FLOAT fRet = this->GetContentRect().Height();
-
- //this->Move(rcOld, TRUE, FALSE);
-
- m_pEdit->EnableNotify(TRUE);
- this->EnableNotify(TRUE);
- this->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::~CPWL_Note_LBBox()
-{
-}
-
-void CPWL_Note_LBBox::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- CPDF_Rect rcClient = this->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(),this->GetTransparency()), FXFILL_ALTERNATE);
-}
-
-/* -------------------------------- CPWL_Note_RBBox --------------------------------*/
-
-CPWL_Note_RBBox::CPWL_Note_RBBox()
-{
-}
-
-CPWL_Note_RBBox::~CPWL_Note_RBBox()
-{
-}
-
-void CPWL_Note_RBBox::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- CPDF_Rect rcClient = this->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(),this->GetTransparency()), FXFILL_ALTERNATE);
-}
-
-/* --------------------------------- CPWL_Note_Icon ---------------------------------- */
-
-CPWL_Note_Icon::CPWL_Note_Icon() : m_nType(0)
-{
-}
-
-CPWL_Note_Icon::~CPWL_Note_Icon()
-{
-}
-
-void CPWL_Note_Icon::SetIconType(FX_INT32 nType)
-{
- m_nType = nType;
-}
-
-void CPWL_Note_Icon::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- CPWL_Utils::DrawIconAppStream(pDevice, pUser2Device, m_nType, GetClientRect(),
- this->GetBackgroundColor(), PWL_DEFAULT_BLACKCOLOR, this->GetTransparency());
-}
-
-/* --------------------------------- CPWL_Note_CloseBox ---------------------------------- */
-
-CPWL_Note_CloseBox::CPWL_Note_CloseBox() : m_bMouseDown(FALSE)
-{
-}
-
-CPWL_Note_CloseBox::~CPWL_Note_CloseBox()
-{
-}
-
-void CPWL_Note_CloseBox::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- CPWL_Button::DrawThisAppearance(pDevice, pUser2Device);
-
- CPDF_Rect rcClient = this->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(),this->GetTransparency()), FXFILL_ALTERNATE);
-}
-
-FX_BOOL CPWL_Note_CloseBox::OnLButtonDown(const CPDF_Point & 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 CPDF_Point & point, FX_DWORD nFlag)
-{
- m_bMouseDown = FALSE;
-
- SetBorderStyle(PBS_BEVELED);
- InvalidateRect(NULL);
-
- return CPWL_Button::OnLButtonUp(point,nFlag);
-}
-
-/* ------------------------------ CPWL_Note_Contents ------------------------------- */
-
-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);
- 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 = this->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 = this->GetSystemHandler())
- st = pSH->GetLocalTime();
- pNoteItem->SetDateTime(st);
-
- pNoteItem->SetContents(L"");
-
- this->OnNotify(pNoteItem, PNM_NOTEEDITCHANGED, 0, 0);
-
- return pNoteItem;
-}
-
-FX_INT32 CPWL_Note_Contents::CountSubItems() const
-{
- return m_aChildren.GetSize() - 1;
-}
-
-IPWL_NoteItem* CPWL_Note_Contents::GetSubItems(FX_INT32 index) const
-{
- FX_INT32 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)
-{
- FX_INT32 nIndex = this->GetItemIndex((CPWL_NoteItem*)pNoteItem);
-
- if (nIndex > 0)
- {
- if (CPWL_NoteItem* pPWLNoteItem = (CPWL_NoteItem*)pNoteItem)
- {
- pPWLNoteItem->KillFocus();
- pPWLNoteItem->Destroy();
- delete pPWLNoteItem;
- }
-
- for (FX_INT32 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);
- }
- }
-
- this->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- }
-}
-
-IPWL_NoteItem* CPWL_Note_Contents::GetHitNoteItem(const CPDF_Point& point)
-{
- CPDF_Point pt = this->ParentToChild(point);
-
- for (FX_INT32 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, FX_INTPTR wParam, FX_INTPTR lParam)
-{
- switch (msg)
- {
- case PNM_NOTEEDITCHANGED:
- {
- FX_INT32 nIndex = this->GetItemIndex(pWnd);
- if (nIndex < 0) nIndex = 0;
-
- m_pEdit->EnableNotify(FALSE);
- this->ResetContent(nIndex);
- m_pEdit->EnableNotify(TRUE);
-
- for (FX_INT32 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 = this->GetParentWindow())
- {
- pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- }
- }
- return;
- case PNM_SCROLLWINDOW:
- this->SetScrollPos(CPDF_Point(0.0f, *(FX_FLOAT*)lParam));
- this->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 = this->ChildToParent(pInfo->ptHead);
- newInfo.ptFoot = this->ChildToParent(pInfo->ptFoot);
-
- if (CPWL_Wnd * pParent = this->GetParentWindow())
- {
- pParent->OnNotify(this, PNM_SETCARETINFO, (FX_INTPTR)&newInfo, 0);
- }
- }
- return;
- case PNM_NOTERESET:
- {
- m_pEdit->EnableNotify(FALSE);
- this->ResetContent(0);
- m_pEdit->EnableNotify(TRUE);
-
- for (FX_INT32 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);
- this->ResetContent(0);
- m_pEdit->EnableNotify(TRUE);
- }
- return;
- }
-
- CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
-}
-
-FX_BOOL CPWL_Note_Contents::OnLButtonDown(const CPDF_Point & 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 (FX_INT32 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 (FX_INT32 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::CPWL_NoteItem() :
- m_pPrivateData(NULL),
- m_pSubject(NULL),
- m_pDateTime(NULL),
- m_pContents(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(this->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 = PWL_DEFAULT_WHITECOLOR;
- 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 (this->IsValid())
- {
- ASSERT(m_pSubject != NULL);
- ASSERT(m_pDateTime != NULL);
- ASSERT(m_pContents != NULL);
-
- CPDF_Rect rcClient = GetClientRect();
-
- CPDF_Rect 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));
-
- CPDF_Rect 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));
-
- CPDF_Rect 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;
- this->SetBackgroundColor(sBK);
-
- CPWL_Color sTextColor;
-
- if (CPWL_Utils::IsBlackOrWhite(sBK))
- sTextColor = PWL_DEFAULT_WHITECOLOR;
- else
- sTextColor = PWL_DEFAULT_BLACKCOLOR;
-
- this->SetTextColor(sTextColor);
- if (m_pSubject)
- m_pSubject->SetTextColor(sTextColor);
- if (m_pDateTime)
- m_pDateTime->SetTextColor(sTextColor);
-
- this->InvalidateRect(NULL);
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify())
- {
- pNotify->OnSetBkColor(this);
- }
-}
-
-void CPWL_NoteItem::SetSubjectName(const CFX_WideString& sName)
-{
- if (m_pSubject)
- {
- m_pSubject->SetText(sName);
- }
-
- 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(FX_INT32 nItemIndex)
-{
- if (nItemIndex < 0)
- {
- if (CPWL_Wnd* pParent = this->GetParentWindow())
- {
- ASSERT(pParent->GetClassName() == "CPWL_Note_Contents");
-
- CPWL_Note_Contents* pContents = (CPWL_Note_Contents*)pParent;
- nItemIndex = pContents->GetItemIndex(this);
- }
- }
-
- const CPWL_Note* pNote = GetNote();
- ASSERT(pNote != NULL);
-
- CFX_WideString sSubject;
- sSubject.Format(pNote->GetReplyString(), nItemIndex);
-
- if (!m_sAuthor.IsEmpty())
- {
-
- sSubject += L" - ";
- sSubject += m_sAuthor;
- }
- this->SetSubjectName(sSubject);
- this->RePosChildWnd();
-}
-
-void CPWL_NoteItem::SetDateTime(FX_SYSTEMTIME time)
-{
- m_dtNote = time;
-
- CFX_WideString swTime;
- swTime.Format((FX_LPCWSTR)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);
- }
-
- this->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 = this->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 this->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();
-}
-
-FX_INT32 CPWL_NoteItem::CountSubItems() const
-{
- if (m_pContents)
- return m_pContents->CountSubItems();
-
- return 0;
-}
-
-IPWL_NoteItem* CPWL_NoteItem::GetSubItems(FX_INT32 index) const
-{
- if (m_pContents)
- return m_pContents->GetSubItems(index);
-
- return NULL;
-}
-
-void CPWL_NoteItem::DeleteSubItem(IPWL_NoteItem* pNoteItem)
-{
- this->KillFocus();
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify())
- {
- pNotify->OnItemDelete(pNoteItem);
- }
-
- if (m_pContents)
- m_pContents->DeleteSubItem(pNoteItem);
-}
-
-IPWL_NoteItem* CPWL_NoteItem::GetHitNoteItem(const CPDF_Point& point)
-{
- CPDF_Point pt = this->ParentToChild(point);
-
- if (this->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 = this->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;
-
- ASSERT(m_pSubject != NULL);
- ASSERT(m_pDateTime != NULL);
- ASSERT(m_pContents != NULL);
-
- FX_FLOAT fRet = m_pDateTime->GetContentRect().Height();
- FX_FLOAT fBorderWidth = (FX_FLOAT)this->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 CPDF_Point& 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 CPDF_Point & 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, FX_INTPTR wParam, FX_INTPTR lParam)
-{
- switch (msg)
- {
- case PNM_NOTEEDITCHANGED:
- m_bSizeChanged = TRUE;
-
- if (CPWL_Wnd* pParent = this->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 = this->ChildToParent(pInfo->ptHead);
- newInfo.ptFoot = this->ChildToParent(pInfo->ptFoot);
-
- if (CPWL_Wnd * pParent = this->GetParentWindow())
- {
- pParent->OnNotify(this, PNM_SETCARETINFO, (FX_INTPTR)&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 CPDF_Point& point)
-{
- if (IPWL_NoteNotify* pNotify = GetNoteNotify())
- {
- FX_INT32 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 = this->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::CPWL_Note(IPopup_Note* pPopupNote, IPWL_NoteNotify* pNoteNotify, IPWL_NoteHandler* pNoteHandler) :
- m_pAuthor(NULL),
- m_pIcon(NULL),
- m_pCloseBox(NULL),
- m_pContentsBar(NULL),
- m_pLBBox(NULL),
- m_pRBBox(NULL),
- m_pOptions(NULL),
- m_bResizing(FALSE),
- m_rcCaption(0,0,0,0),
- m_pNoteNotify(pNoteNotify),
- m_bEnalbleNotify(TRUE),
- m_pPopupNote(pPopupNote),
- m_pNoteHandler(pNoteHandler)
-{
-}
-
-CPWL_Note::~CPWL_Note()
-{
-}
-
-IPWL_NoteItem* CPWL_Note::Reply()
-{
- return CreateNoteItem();
-}
-
-void CPWL_Note::EnableNotify(FX_BOOL bEnabled)
-{
- m_bEnalbleNotify = bEnabled;
-}
-
-void CPWL_Note::RePosChildWnd()
-{
- RePosNoteChildren();
- m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
- ResetScrollBar();
- m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
- this->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- //ͬ²½
- if (const CPWL_Wnd* pWnd = this->GetFocused())
- {
- if (pWnd->GetClassName() == "CPWL_Edit")
- {
- CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
- pEdit->SetCaret(pEdit->GetCaret());
- }
- }
- //CPDF_Point ptNew = m_pContents->GetScrollPos();
- //m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptNew.y);
-}
-
-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)
- {
- CPDF_Rect rcNote = this->GetClientRect();
- CPDF_Rect 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(CPDF_Point(0.0f,0.0f));
- m_pContents->InvalidateRect(NULL);
- }
-
- return bScrollChanged;
-}
-
-FX_BOOL CPWL_Note::ScrollBarShouldVisible()
-{
- CPDF_Rect rcContentsFact = m_pContents->GetScrollArea();
- CPDF_Rect 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 (this->IsValid())
- {
- ASSERT(m_pSubject != NULL);
- ASSERT(m_pDateTime != NULL);
- ASSERT(m_pContents != NULL);
- ASSERT(m_pAuthor != NULL);
- ASSERT(m_pCloseBox != NULL);
- ASSERT(m_pIcon != NULL);
- ASSERT(m_pLBBox != NULL);
- ASSERT(m_pRBBox != NULL);
- ASSERT(m_pContentsBar != NULL);
- ASSERT(m_pOptions != NULL);
-
- CPDF_Rect rcClient = GetClientRect();
-
- CPDF_Rect 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));
-
- CPDF_Rect 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));
-
- CPDF_Rect 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));
-
- CPDF_Rect 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));
-
- CPDF_Rect 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));
-
- CPDF_Rect 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));
-
- CPDF_Rect 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));
-
- CPDF_Rect 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));
-
- CPDF_Rect 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));
-
- CPDF_Rect rcContentsBar = rcContents;
- rcContentsBar.right = rcClient.right - 3.0f;
- rcContentsBar.left = rcContentsBar.right - PWL_SCROLLBAR_WIDTH;
- rcContentsBar.Normalize();
- m_pContentsBar->Move(rcContentsBar, TRUE, FALSE);
-
- m_rcCaption = rcClient;
- m_rcCaption.bottom = rcContents.top;
- }
-
- m_bResizing = FALSE;
-}
-
-//0-normal / 1-caption / 2-leftbottom corner / 3-rightbottom corner / 4-close / 5-options
-FX_INT32 CPWL_Note::NoteHitTest(const CPDF_Point& point) const
-{
- ASSERT(m_pSubject != NULL);
- ASSERT(m_pDateTime != NULL);
- ASSERT(m_pContents != NULL);
- ASSERT(m_pAuthor != NULL);
- ASSERT(m_pIcon != NULL);
- ASSERT(m_pContentsBar != NULL);
-
- ASSERT(m_pCloseBox != NULL);
- ASSERT(m_pLBBox != NULL);
- ASSERT(m_pRBBox != NULL);
- ASSERT(m_pOptions != NULL);
-
- GetClientRect();
-
- if (m_pSubject->WndHitTest(m_pSubject->ParentToChild(point))) return 1;
- if (m_pDateTime->WndHitTest(m_pDateTime->ParentToChild(point))) return 1;
- if (m_pAuthor->WndHitTest(m_pAuthor->ParentToChild(point))) return 1;
- if (m_pIcon->WndHitTest(m_pIcon->ParentToChild(point))) return 1;
-
- if (m_pContents->WndHitTest(m_pContents->ParentToChild(point))) return 0;
- if (m_pContentsBar->WndHitTest(m_pContentsBar->ParentToChild(point))) return 0;
-
- if (m_pCloseBox->WndHitTest(m_pCloseBox->ParentToChild(point))) return 4;
- if (m_pLBBox->WndHitTest(m_pLBBox->ParentToChild(point))) return 2;
- if (m_pRBBox->WndHitTest(m_pRBBox->ParentToChild(point))) return 3;
- if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point))) return 5;
-
- return 1;
-}
-
-void CPWL_Note::CreateChildWnd(const PWL_CREATEPARAM & cp)
-{
- CPWL_NoteItem::CreateChildWnd(cp);
-
- CPWL_Color sTextColor;
-
- if (CPWL_Utils::IsBlackOrWhite(this->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);
- 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 CPDF_Point & point, FX_DWORD nFlag)
-{
- CPDF_Point ptScroll = m_pContents->GetScrollPos();
- CPDF_Rect rcScroll = m_pContents->GetScrollArea();
- CPDF_Rect rcContents = m_pContents->GetClientRect();
-
- if (rcScroll.top - rcScroll.bottom > rcContents.Height())
- {
- CPDF_Point 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, (FX_INTPTR)&ptNew.y);
- m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptNew.y);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-void CPWL_Note::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_INTPTR lParam)
-{
- switch (msg)
- {
- case PNM_NOTEEDITCHANGED:
- {
- CPDF_Rect 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) //·ÀÖ¹ËÀÑ»· mantis:15759
- {
- bScrollChanged = ResetScrollBar();
- if (bScrollChanged)
- {
- lParam++;
- m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
- this->OnNotify(this, PNM_NOTEEDITCHANGED, 0, lParam);
- }
- }
-
- if (!bScrollChanged)
- {
- if (m_pContentsBar->IsVisible())
- {
- m_pContentsBar->OnNotify(pWnd, PNM_SETSCROLLINFO, SBT_VSCROLL, (FX_INTPTR)&sInfo);
- m_OldScrollInfo = sInfo;
-
- CPDF_Point ptScroll = m_pContents->GetScrollPos();
- CPDF_Point 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, (FX_INTPTR)&ptScroll.y);
- m_pContentsBar->InvalidateRect(NULL);
- m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&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)
- {
- CPDF_Rect rcClient = m_pContents->GetClientRect();
- if (pInfo->ptHead.y > rcClient.top)
- {
- CPDF_Point pt = m_pContents->OutToIn(pInfo->ptHead);
- m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&pt.y);
-
- CPDF_Point ptScroll = m_pContents->GetScrollPos();
- m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y);
-
- return;
- }
-
- if (pInfo->ptFoot.y < rcClient.bottom)
- {
- CPDF_Point pt = m_pContents->OutToIn(pInfo->ptFoot);
- pt.y += rcClient.Height();
- m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&pt.y);
-
- CPDF_Point ptScroll = m_pContents->GetScrollPos();
- m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&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 CPDF_Point& point, FX_DWORD nFlag)
-{
- if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point)))
- {
- if (IPWL_NoteNotify* pNotify = this->GetNoteNotify())
- {
- FX_INT32 x, y;
- PWLtoWnd(point, x, y);
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- pSH->ClientToScreen(GetAttachedHWnd(), x, y);
- this->KillFocus();
- pNotify->OnPopupMenu(x, y);
-
- return TRUE;
- }
- }
-
- return CPWL_Wnd::OnLButtonDown(point,nFlag);
-}
-
-FX_BOOL CPWL_Note::OnRButtonUp(const CPDF_Point & 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
-{
- if (m_bEnalbleNotify)
- return m_pNoteNotify;
-
- return NULL;
-}
-
-void CPWL_Note::SetIconType(FX_INT32 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& string)
-{
- m_sReplyString = string;
-}
-
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_Button.h"
+#include "../../include/pdfwindow/PWL_EditCtrl.h"
+#include "../../include/pdfwindow/PWL_Edit.h"
+#include "../../include/pdfwindow/PWL_ListCtrl.h"
+#include "../../include/pdfwindow/PWL_ScrollBar.h"
+#include "../../include/pdfwindow/PWL_Note.h"
+#include "../../include/pdfwindow/PWL_Label.h"
+#include "../../include/pdfwindow/PWL_Edit.h"
+#include "../../include/pdfwindow/PWL_ScrollBar.h"
+#include "../../include/pdfwindow/PWL_Utils.h"
+#include "../../include/pdfwindow/PWL_Caret.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::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 (this->IsValid())
+ {
+ ASSERT(m_pText != NULL);
+
+ CPDF_Rect 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(CPDF_Rect(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);
+}
+
+void CPWL_Note_Options::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
+{
+ CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
+
+ CPDF_Rect rcClient = GetClientRect();
+ rcClient.left = rcClient.right - 15.0f;
+
+ CPDF_Point ptCenter = CPDF_Point((rcClient.left + rcClient.right) * 0.5f, (rcClient.top + rcClient.bottom) * 0.5f);
+
+ CPDF_Point pt1(ptCenter.x - 2.0f, ptCenter.y + 2.0f * 0.5f);
+ CPDF_Point pt2(ptCenter.x + 2.0f, ptCenter.y + 2.0f * 0.5f);
+ CPDF_Point 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);
+}
+
+CPDF_Rect CPWL_Note_Options::GetContentRect() const
+{
+ ASSERT(m_pText != NULL);
+
+ CPDF_Rect rcText = m_pText->GetContentRect();
+ rcText.right += 15.0f;
+ return rcText;
+}
+
+/* ------------------------------- CPWL_Note_Edit ------------------------------ */
+
+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 = this->GetContentRect().Height();
+}
+
+void CPWL_Note_Edit::SetText(FX_LPCWSTR csText)
+{
+ m_bEnableNotify = FALSE;
+ CPWL_Edit::SetText(csText);
+ m_bEnableNotify = TRUE;
+ m_fOldItemHeight = this->GetContentRect().Height();
+}
+
+void CPWL_Note_Edit::OnSetFocus()
+{
+ m_bEnableNotify = FALSE;
+ CPWL_Edit::OnSetFocus();
+ m_bEnableNotify = TRUE;
+
+ this->EnableSpellCheck(TRUE);
+}
+
+void CPWL_Note_Edit::OnKillFocus()
+{
+ this->EnableSpellCheck(FALSE);
+
+ if (CPWL_Wnd* pParent = this->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, FX_INTPTR wParam, FX_INTPTR 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 = this->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 = this->ChildToParent(pInfo->ptHead);
+ newInfo.ptFoot = this->ChildToParent(pInfo->ptFoot);
+
+ if (CPWL_Wnd * pParent = this->GetParentWindow())
+ {
+ pParent->OnNotify(this, PNM_SETCARETINFO, (FX_INTPTR)&newInfo, 0);
+ }
+ }
+ break;
+ }
+ }
+}
+
+FX_FLOAT CPWL_Note_Edit::GetItemHeight(FX_FLOAT fLimitWidth)
+{
+ if (fLimitWidth > 0)
+ {
+ if (!m_bSizeChanged)
+ return m_fOldItemHeight;
+
+ m_bSizeChanged = FALSE;
+
+ this->EnableNotify(FALSE);
+ this->EnableRefresh(FALSE);
+ m_pEdit->EnableNotify(FALSE);
+
+ //CPDF_Rect rcOld = this->GetWindowRect();
+
+ this->Move(CPDF_Rect(0,0,fLimitWidth,0), TRUE, FALSE);
+ FX_FLOAT fRet = this->GetContentRect().Height();
+
+ //this->Move(rcOld, TRUE, FALSE);
+
+ m_pEdit->EnableNotify(TRUE);
+ this->EnableNotify(TRUE);
+ this->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::~CPWL_Note_LBBox()
+{
+}
+
+void CPWL_Note_LBBox::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
+{
+ CPDF_Rect rcClient = this->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(),this->GetTransparency()), FXFILL_ALTERNATE);
+}
+
+/* -------------------------------- CPWL_Note_RBBox --------------------------------*/
+
+CPWL_Note_RBBox::CPWL_Note_RBBox()
+{
+}
+
+CPWL_Note_RBBox::~CPWL_Note_RBBox()
+{
+}
+
+void CPWL_Note_RBBox::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
+{
+ CPDF_Rect rcClient = this->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(),this->GetTransparency()), FXFILL_ALTERNATE);
+}
+
+/* --------------------------------- CPWL_Note_Icon ---------------------------------- */
+
+CPWL_Note_Icon::CPWL_Note_Icon() : m_nType(0)
+{
+}
+
+CPWL_Note_Icon::~CPWL_Note_Icon()
+{
+}
+
+void CPWL_Note_Icon::SetIconType(FX_INT32 nType)
+{
+ m_nType = nType;
+}
+
+void CPWL_Note_Icon::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
+{
+ CPWL_Utils::DrawIconAppStream(pDevice, pUser2Device, m_nType, GetClientRect(),
+ this->GetBackgroundColor(), PWL_DEFAULT_BLACKCOLOR, this->GetTransparency());
+}
+
+/* --------------------------------- CPWL_Note_CloseBox ---------------------------------- */
+
+CPWL_Note_CloseBox::CPWL_Note_CloseBox() : m_bMouseDown(FALSE)
+{
+}
+
+CPWL_Note_CloseBox::~CPWL_Note_CloseBox()
+{
+}
+
+void CPWL_Note_CloseBox::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
+{
+ CPWL_Button::DrawThisAppearance(pDevice, pUser2Device);
+
+ CPDF_Rect rcClient = this->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(),this->GetTransparency()), FXFILL_ALTERNATE);
+}
+
+FX_BOOL CPWL_Note_CloseBox::OnLButtonDown(const CPDF_Point & 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 CPDF_Point & point, FX_DWORD nFlag)
+{
+ m_bMouseDown = FALSE;
+
+ SetBorderStyle(PBS_BEVELED);
+ InvalidateRect(NULL);
+
+ return CPWL_Button::OnLButtonUp(point,nFlag);
+}
+
+/* ------------------------------ CPWL_Note_Contents ------------------------------- */
+
+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);
+ 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 = this->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 = this->GetSystemHandler())
+ st = pSH->GetLocalTime();
+ pNoteItem->SetDateTime(st);
+
+ pNoteItem->SetContents(L"");
+
+ this->OnNotify(pNoteItem, PNM_NOTEEDITCHANGED, 0, 0);
+
+ return pNoteItem;
+}
+
+FX_INT32 CPWL_Note_Contents::CountSubItems() const
+{
+ return m_aChildren.GetSize() - 1;
+}
+
+IPWL_NoteItem* CPWL_Note_Contents::GetSubItems(FX_INT32 index) const
+{
+ FX_INT32 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)
+{
+ FX_INT32 nIndex = this->GetItemIndex((CPWL_NoteItem*)pNoteItem);
+
+ if (nIndex > 0)
+ {
+ if (CPWL_NoteItem* pPWLNoteItem = (CPWL_NoteItem*)pNoteItem)
+ {
+ pPWLNoteItem->KillFocus();
+ pPWLNoteItem->Destroy();
+ delete pPWLNoteItem;
+ }
+
+ for (FX_INT32 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);
+ }
+ }
+
+ this->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
+ }
+}
+
+IPWL_NoteItem* CPWL_Note_Contents::GetHitNoteItem(const CPDF_Point& point)
+{
+ CPDF_Point pt = this->ParentToChild(point);
+
+ for (FX_INT32 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, FX_INTPTR wParam, FX_INTPTR lParam)
+{
+ switch (msg)
+ {
+ case PNM_NOTEEDITCHANGED:
+ {
+ FX_INT32 nIndex = this->GetItemIndex(pWnd);
+ if (nIndex < 0) nIndex = 0;
+
+ m_pEdit->EnableNotify(FALSE);
+ this->ResetContent(nIndex);
+ m_pEdit->EnableNotify(TRUE);
+
+ for (FX_INT32 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 = this->GetParentWindow())
+ {
+ pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
+ }
+ }
+ return;
+ case PNM_SCROLLWINDOW:
+ this->SetScrollPos(CPDF_Point(0.0f, *(FX_FLOAT*)lParam));
+ this->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 = this->ChildToParent(pInfo->ptHead);
+ newInfo.ptFoot = this->ChildToParent(pInfo->ptFoot);
+
+ if (CPWL_Wnd * pParent = this->GetParentWindow())
+ {
+ pParent->OnNotify(this, PNM_SETCARETINFO, (FX_INTPTR)&newInfo, 0);
+ }
+ }
+ return;
+ case PNM_NOTERESET:
+ {
+ m_pEdit->EnableNotify(FALSE);
+ this->ResetContent(0);
+ m_pEdit->EnableNotify(TRUE);
+
+ for (FX_INT32 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);
+ this->ResetContent(0);
+ m_pEdit->EnableNotify(TRUE);
+ }
+ return;
+ }
+
+ CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
+}
+
+FX_BOOL CPWL_Note_Contents::OnLButtonDown(const CPDF_Point & 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 (FX_INT32 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 (FX_INT32 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::CPWL_NoteItem() :
+ m_pPrivateData(NULL),
+ m_pSubject(NULL),
+ m_pDateTime(NULL),
+ m_pContents(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(this->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 = PWL_DEFAULT_WHITECOLOR;
+ 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 (this->IsValid())
+ {
+ ASSERT(m_pSubject != NULL);
+ ASSERT(m_pDateTime != NULL);
+ ASSERT(m_pContents != NULL);
+
+ CPDF_Rect rcClient = GetClientRect();
+
+ CPDF_Rect 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));
+
+ CPDF_Rect 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));
+
+ CPDF_Rect 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;
+ this->SetBackgroundColor(sBK);
+
+ CPWL_Color sTextColor;
+
+ if (CPWL_Utils::IsBlackOrWhite(sBK))
+ sTextColor = PWL_DEFAULT_WHITECOLOR;
+ else
+ sTextColor = PWL_DEFAULT_BLACKCOLOR;
+
+ this->SetTextColor(sTextColor);
+ if (m_pSubject)
+ m_pSubject->SetTextColor(sTextColor);
+ if (m_pDateTime)
+ m_pDateTime->SetTextColor(sTextColor);
+
+ this->InvalidateRect(NULL);
+
+ if (IPWL_NoteNotify* pNotify = GetNoteNotify())
+ {
+ pNotify->OnSetBkColor(this);
+ }
+}
+
+void CPWL_NoteItem::SetSubjectName(const CFX_WideString& sName)
+{
+ if (m_pSubject)
+ {
+ m_pSubject->SetText(sName);
+ }
+
+ 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(FX_INT32 nItemIndex)
+{
+ if (nItemIndex < 0)
+ {
+ if (CPWL_Wnd* pParent = this->GetParentWindow())
+ {
+ ASSERT(pParent->GetClassName() == "CPWL_Note_Contents");
+
+ CPWL_Note_Contents* pContents = (CPWL_Note_Contents*)pParent;
+ nItemIndex = pContents->GetItemIndex(this);
+ }
+ }
+
+ const CPWL_Note* pNote = GetNote();
+ ASSERT(pNote != NULL);
+
+ CFX_WideString sSubject;
+ sSubject.Format(pNote->GetReplyString(), nItemIndex);
+
+ if (!m_sAuthor.IsEmpty())
+ {
+
+ sSubject += L" - ";
+ sSubject += m_sAuthor;
+ }
+ this->SetSubjectName(sSubject);
+ this->RePosChildWnd();
+}
+
+void CPWL_NoteItem::SetDateTime(FX_SYSTEMTIME time)
+{
+ m_dtNote = time;
+
+ CFX_WideString swTime;
+ swTime.Format((FX_LPCWSTR)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);
+ }
+
+ this->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 = this->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 this->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();
+}
+
+FX_INT32 CPWL_NoteItem::CountSubItems() const
+{
+ if (m_pContents)
+ return m_pContents->CountSubItems();
+
+ return 0;
+}
+
+IPWL_NoteItem* CPWL_NoteItem::GetSubItems(FX_INT32 index) const
+{
+ if (m_pContents)
+ return m_pContents->GetSubItems(index);
+
+ return NULL;
+}
+
+void CPWL_NoteItem::DeleteSubItem(IPWL_NoteItem* pNoteItem)
+{
+ this->KillFocus();
+
+ if (IPWL_NoteNotify* pNotify = GetNoteNotify())
+ {
+ pNotify->OnItemDelete(pNoteItem);
+ }
+
+ if (m_pContents)
+ m_pContents->DeleteSubItem(pNoteItem);
+}
+
+IPWL_NoteItem* CPWL_NoteItem::GetHitNoteItem(const CPDF_Point& point)
+{
+ CPDF_Point pt = this->ParentToChild(point);
+
+ if (this->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 = this->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;
+
+ ASSERT(m_pSubject != NULL);
+ ASSERT(m_pDateTime != NULL);
+ ASSERT(m_pContents != NULL);
+
+ FX_FLOAT fRet = m_pDateTime->GetContentRect().Height();
+ FX_FLOAT fBorderWidth = (FX_FLOAT)this->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 CPDF_Point& 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 CPDF_Point & 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, FX_INTPTR wParam, FX_INTPTR lParam)
+{
+ switch (msg)
+ {
+ case PNM_NOTEEDITCHANGED:
+ m_bSizeChanged = TRUE;
+
+ if (CPWL_Wnd* pParent = this->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 = this->ChildToParent(pInfo->ptHead);
+ newInfo.ptFoot = this->ChildToParent(pInfo->ptFoot);
+
+ if (CPWL_Wnd * pParent = this->GetParentWindow())
+ {
+ pParent->OnNotify(this, PNM_SETCARETINFO, (FX_INTPTR)&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 CPDF_Point& point)
+{
+ if (IPWL_NoteNotify* pNotify = GetNoteNotify())
+ {
+ FX_INT32 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 = this->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::CPWL_Note(IPopup_Note* pPopupNote, IPWL_NoteNotify* pNoteNotify, IPWL_NoteHandler* pNoteHandler) :
+ m_pAuthor(NULL),
+ m_pIcon(NULL),
+ m_pCloseBox(NULL),
+ m_pContentsBar(NULL),
+ m_pLBBox(NULL),
+ m_pRBBox(NULL),
+ m_pOptions(NULL),
+ m_bResizing(FALSE),
+ m_rcCaption(0,0,0,0),
+ m_pNoteNotify(pNoteNotify),
+ m_bEnalbleNotify(TRUE),
+ m_pPopupNote(pPopupNote),
+ m_pNoteHandler(pNoteHandler)
+{
+}
+
+CPWL_Note::~CPWL_Note()
+{
+}
+
+IPWL_NoteItem* CPWL_Note::Reply()
+{
+ return CreateNoteItem();
+}
+
+void CPWL_Note::EnableNotify(FX_BOOL bEnabled)
+{
+ m_bEnalbleNotify = bEnabled;
+}
+
+void CPWL_Note::RePosChildWnd()
+{
+ RePosNoteChildren();
+ m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
+ ResetScrollBar();
+ m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
+ this->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
+ //ͬ²½
+ if (const CPWL_Wnd* pWnd = this->GetFocused())
+ {
+ if (pWnd->GetClassName() == "CPWL_Edit")
+ {
+ CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
+ pEdit->SetCaret(pEdit->GetCaret());
+ }
+ }
+ //CPDF_Point ptNew = m_pContents->GetScrollPos();
+ //m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptNew.y);
+}
+
+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)
+ {
+ CPDF_Rect rcNote = this->GetClientRect();
+ CPDF_Rect 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(CPDF_Point(0.0f,0.0f));
+ m_pContents->InvalidateRect(NULL);
+ }
+
+ return bScrollChanged;
+}
+
+FX_BOOL CPWL_Note::ScrollBarShouldVisible()
+{
+ CPDF_Rect rcContentsFact = m_pContents->GetScrollArea();
+ CPDF_Rect 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 (this->IsValid())
+ {
+ ASSERT(m_pSubject != NULL);
+ ASSERT(m_pDateTime != NULL);
+ ASSERT(m_pContents != NULL);
+ ASSERT(m_pAuthor != NULL);
+ ASSERT(m_pCloseBox != NULL);
+ ASSERT(m_pIcon != NULL);
+ ASSERT(m_pLBBox != NULL);
+ ASSERT(m_pRBBox != NULL);
+ ASSERT(m_pContentsBar != NULL);
+ ASSERT(m_pOptions != NULL);
+
+ CPDF_Rect rcClient = GetClientRect();
+
+ CPDF_Rect 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));
+
+ CPDF_Rect 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));
+
+ CPDF_Rect 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));
+
+ CPDF_Rect 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));
+
+ CPDF_Rect 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));
+
+ CPDF_Rect 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));
+
+ CPDF_Rect 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));
+
+ CPDF_Rect 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));
+
+ CPDF_Rect 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));
+
+ CPDF_Rect rcContentsBar = rcContents;
+ rcContentsBar.right = rcClient.right - 3.0f;
+ rcContentsBar.left = rcContentsBar.right - PWL_SCROLLBAR_WIDTH;
+ rcContentsBar.Normalize();
+ m_pContentsBar->Move(rcContentsBar, TRUE, FALSE);
+
+ m_rcCaption = rcClient;
+ m_rcCaption.bottom = rcContents.top;
+ }
+
+ m_bResizing = FALSE;
+}
+
+//0-normal / 1-caption / 2-leftbottom corner / 3-rightbottom corner / 4-close / 5-options
+FX_INT32 CPWL_Note::NoteHitTest(const CPDF_Point& point) const
+{
+ ASSERT(m_pSubject != NULL);
+ ASSERT(m_pDateTime != NULL);
+ ASSERT(m_pContents != NULL);
+ ASSERT(m_pAuthor != NULL);
+ ASSERT(m_pIcon != NULL);
+ ASSERT(m_pContentsBar != NULL);
+
+ ASSERT(m_pCloseBox != NULL);
+ ASSERT(m_pLBBox != NULL);
+ ASSERT(m_pRBBox != NULL);
+ ASSERT(m_pOptions != NULL);
+
+ GetClientRect();
+
+ if (m_pSubject->WndHitTest(m_pSubject->ParentToChild(point))) return 1;
+ if (m_pDateTime->WndHitTest(m_pDateTime->ParentToChild(point))) return 1;
+ if (m_pAuthor->WndHitTest(m_pAuthor->ParentToChild(point))) return 1;
+ if (m_pIcon->WndHitTest(m_pIcon->ParentToChild(point))) return 1;
+
+ if (m_pContents->WndHitTest(m_pContents->ParentToChild(point))) return 0;
+ if (m_pContentsBar->WndHitTest(m_pContentsBar->ParentToChild(point))) return 0;
+
+ if (m_pCloseBox->WndHitTest(m_pCloseBox->ParentToChild(point))) return 4;
+ if (m_pLBBox->WndHitTest(m_pLBBox->ParentToChild(point))) return 2;
+ if (m_pRBBox->WndHitTest(m_pRBBox->ParentToChild(point))) return 3;
+ if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point))) return 5;
+
+ return 1;
+}
+
+void CPWL_Note::CreateChildWnd(const PWL_CREATEPARAM & cp)
+{
+ CPWL_NoteItem::CreateChildWnd(cp);
+
+ CPWL_Color sTextColor;
+
+ if (CPWL_Utils::IsBlackOrWhite(this->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);
+ 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 CPDF_Point & point, FX_DWORD nFlag)
+{
+ CPDF_Point ptScroll = m_pContents->GetScrollPos();
+ CPDF_Rect rcScroll = m_pContents->GetScrollArea();
+ CPDF_Rect rcContents = m_pContents->GetClientRect();
+
+ if (rcScroll.top - rcScroll.bottom > rcContents.Height())
+ {
+ CPDF_Point 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, (FX_INTPTR)&ptNew.y);
+ m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptNew.y);
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+void CPWL_Note::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_INTPTR lParam)
+{
+ switch (msg)
+ {
+ case PNM_NOTEEDITCHANGED:
+ {
+ CPDF_Rect 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) //·ÀÖ¹ËÀÑ»· mantis:15759
+ {
+ bScrollChanged = ResetScrollBar();
+ if (bScrollChanged)
+ {
+ lParam++;
+ m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
+ this->OnNotify(this, PNM_NOTEEDITCHANGED, 0, lParam);
+ }
+ }
+
+ if (!bScrollChanged)
+ {
+ if (m_pContentsBar->IsVisible())
+ {
+ m_pContentsBar->OnNotify(pWnd, PNM_SETSCROLLINFO, SBT_VSCROLL, (FX_INTPTR)&sInfo);
+ m_OldScrollInfo = sInfo;
+
+ CPDF_Point ptScroll = m_pContents->GetScrollPos();
+ CPDF_Point 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, (FX_INTPTR)&ptScroll.y);
+ m_pContentsBar->InvalidateRect(NULL);
+ m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&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)
+ {
+ CPDF_Rect rcClient = m_pContents->GetClientRect();
+ if (pInfo->ptHead.y > rcClient.top)
+ {
+ CPDF_Point pt = m_pContents->OutToIn(pInfo->ptHead);
+ m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&pt.y);
+
+ CPDF_Point ptScroll = m_pContents->GetScrollPos();
+ m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y);
+
+ return;
+ }
+
+ if (pInfo->ptFoot.y < rcClient.bottom)
+ {
+ CPDF_Point pt = m_pContents->OutToIn(pInfo->ptFoot);
+ pt.y += rcClient.Height();
+ m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&pt.y);
+
+ CPDF_Point ptScroll = m_pContents->GetScrollPos();
+ m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&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 CPDF_Point& point, FX_DWORD nFlag)
+{
+ if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point)))
+ {
+ if (IPWL_NoteNotify* pNotify = this->GetNoteNotify())
+ {
+ FX_INT32 x, y;
+ PWLtoWnd(point, x, y);
+ if (IFX_SystemHandler* pSH = GetSystemHandler())
+ pSH->ClientToScreen(GetAttachedHWnd(), x, y);
+ this->KillFocus();
+ pNotify->OnPopupMenu(x, y);
+
+ return TRUE;
+ }
+ }
+
+ return CPWL_Wnd::OnLButtonDown(point,nFlag);
+}
+
+FX_BOOL CPWL_Note::OnRButtonUp(const CPDF_Point & 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
+{
+ if (m_bEnalbleNotify)
+ return m_pNoteNotify;
+
+ return NULL;
+}
+
+void CPWL_Note::SetIconType(FX_INT32 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& string)
+{
+ m_sReplyString = string;
+}
+
diff --git a/fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp b/fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp
index d51de4d..772e184 100644
--- a/fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp
@@ -1,1353 +1,1353 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_ScrollBar.h"
-#include "../../include/pdfwindow/PWL_Utils.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::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::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::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;
-
- CPDF_Rect rectWnd = GetWindowRect();
-
- if (rectWnd.IsEmpty()) return;
-
- sAppStream << "q\n";
-
- CPDF_Point ptCenter = this->GetCenterPoint();
-
- switch (this->m_eScrollBarType)
- {
- case SBT_HSCROLL:
- switch (this->m_eSBButtonType)
- {
- case PSBT_MIN:
- {
- CPDF_Point pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y);
- CPDF_Point pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y + PWL_TRIANGLE_HALFLEN);
- CPDF_Point 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:
- {
- CPDF_Point pt1(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y);
- CPDF_Point pt2(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y + PWL_TRIANGLE_HALFLEN);
- CPDF_Point 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(this->m_eSBButtonType)
- {
- case PSBT_MIN:
- {
- CPDF_Point pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN,ptCenter.y - PWL_TRIANGLE_HALFLEN * 0.5f);
- CPDF_Point pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN,ptCenter.y - PWL_TRIANGLE_HALFLEN * 0.5f);
- CPDF_Point 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:
- {
- CPDF_Point pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN,ptCenter.y + PWL_TRIANGLE_HALFLEN * 0.5f);
- CPDF_Point pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN,ptCenter.y + PWL_TRIANGLE_HALFLEN * 0.5f);
- CPDF_Point 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, CPDF_Matrix* pUser2Device)
-{
- if (!IsVisible()) return;
-
- CPDF_Rect rectWnd = GetWindowRect();
- if (rectWnd.IsEmpty()) return;
-
- CPDF_Point ptCenter = this->GetCenterPoint();
- FX_INT32 nTransparancy = this->GetTransparency();
-
- switch (this->m_eScrollBarType)
- {
- case SBT_HSCROLL:
- CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
- switch (this->m_eSBButtonType)
- {
- case PSBT_MIN:
- {
- CPDF_Point pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y);
- CPDF_Point pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y + PWL_TRIANGLE_HALFLEN);
- CPDF_Point 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:
- {
- CPDF_Point pt1(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y);
- CPDF_Point pt2(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y + PWL_TRIANGLE_HALFLEN);
- CPDF_Point 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(this->m_eSBButtonType)
- {
- case PSBT_MIN:
- {
- //draw border
- CPDF_Rect 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 (this->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;
- CPDF_Point pts[7] = {
- CPDF_Point(fX+2.5f, fY+4.0f),
- CPDF_Point(fX+2.5f, fY+3.0f),
- CPDF_Point(fX+4.5f, fY+5.0f),
- CPDF_Point(fX+6.5f, fY+3.0f),
- CPDF_Point(fX+6.5f, fY+4.0f),
- CPDF_Point(fX+4.5f, fY+6.0f),
- CPDF_Point(fX+2.5f, fY+4.0f)};
-
-
- if (this->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
- CPDF_Rect 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 (this->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;
-
- CPDF_Point pts[7] = {
- CPDF_Point(fX+2.5f, fY+5.0f),
- CPDF_Point(fX+2.5f, fY+6.0f),
- CPDF_Point(fX+4.5f, fY+4.0f),
- CPDF_Point(fX+6.5f, fY+6.0f),
- CPDF_Point(fX+6.5f, fY+5.0f),
- CPDF_Point(fX+4.5f, fY+3.0f),
- CPDF_Point(fX+2.5f, fY+5.0f)};
-
-
- if (this->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:
- {
- //CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
-
- //draw border
- CPDF_Rect 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 (this->IsEnabled())
- {
- //draw shadow effect
-
- CPDF_Point ptTop = CPDF_Point(rectWnd.left,rectWnd.top-1.0f);
- CPDF_Point ptBottom = CPDF_Point(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 (!this->IsEnabled())
- crStroke = CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_HEAVYGRAYCOLOR,255);
-
- FX_FLOAT nFrictionWidth = 5.0f;
- FX_FLOAT nFrictionHeight = 5.5f;
-
- CPDF_Point ptLeft = CPDF_Point(ptCenter.x - nFrictionWidth / 2.0f, ptCenter.y - nFrictionHeight / 2.0f + 0.5f);
- CPDF_Point ptRight = CPDF_Point(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);
-
- /*
- ptLeft.y += 1.5f;
- ptRight.y += 1.5f;
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight,
- ArgbEncode(nTransparancy,150,150,150),1.0f);
- */
- }
- }
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
-}
-
-FX_BOOL CPWL_SBButton::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonDown(point,nFlag);
-
- if (CPWL_Wnd * pParent = GetParentWindow())
- pParent->OnNotify(this,PNM_LBUTTONDOWN,0,(FX_INTPTR)&point);
-
- m_bMouseDown = TRUE;
- SetCapture();
-
- return TRUE;
-}
-
-FX_BOOL CPWL_SBButton::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonUp(point,nFlag);
-
- if (CPWL_Wnd * pParent = GetParentWindow())
- pParent->OnNotify(this,PNM_LBUTTONUP,0,(FX_INTPTR)&point);
-
- m_bMouseDown = FALSE;
- ReleaseCapture();
-
- return TRUE;
-}
-
-FX_BOOL CPWL_SBButton::OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnMouseMove(point,nFlag);
-
- if (CPWL_Wnd * pParent = GetParentWindow())
- {
- pParent->OnNotify(this,PNM_MOUSEMOVE,0,(FX_INTPTR)&point);
-
- /*
- if (m_bMouseDown && (m_eSBButtonType == PSBT_MIN || m_eSBButtonType == PSBT_MAX))
- {
- if (!pParent->OnNotify(this,PNM_LBUTTONDOWN,nFlags,(FX_INTPTR)&point))
- return FALSE;
- }
- */
- }
-
- return TRUE;
-}
-
-/* ------------------------------- CPWL_ScrollBar ---------------------------------- */
-
-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()
-{
- CPDF_Rect rcClient = this->GetClientRect();
-
-/*
- switch(m_sbType)
- {
- case SBT_HSCROLL:
- if (rcClient.right - rcClient.left < PWL_SCROLLBAR_WIDTH ||
- rcClient.top - rcClient.bottom < PWL_SCROLLBAR_WIDTH)
- {
- SetVisible(FALSE);
- }
- break;
- case SBT_VSCROLL:
- if (rcClient.right - rcClient.left < PWL_SCROLLBAR_WIDTH ||
- rcClient.top - rcClient.bottom < PWL_SCROLLBAR_WIDTH)
- {
- SetVisible(FALSE);
- }
- break;
- }
-*/
- CPDF_Rect 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 = CPDF_Rect(rcClient.left,rcClient.bottom,
- rcClient.left + PWL_SCROLLBAR_BUTTON_WIDTH,rcClient.top);
- rcMaxButton = CPDF_Rect(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 = CPDF_Rect(rcClient.left,rcClient.bottom,
- rcClient.left + fBWidth,rcClient.top);
- rcMaxButton = CPDF_Rect(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 = CPDF_Rect(rcClient.left,rcClient.top - PWL_SCROLLBAR_BUTTON_WIDTH,
- rcClient.right,rcClient.top);
- rcMaxButton = CPDF_Rect(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 = CPDF_Rect(rcClient.left,rcClient.top - fBWidth,
- rcClient.right,rcClient.top);
- rcMaxButton = CPDF_Rect(rcClient.left,rcClient.bottom,
- rcClient.right,rcClient.bottom + fBWidth);
- }
- else SetVisible(FALSE);
- }
- break;
- }
-
-// if (IsVisible())
- {
- 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)
-{
- CPDF_Rect 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, CPDF_Matrix* pUser2Device)
-{
-// CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
- CPDF_Rect rectWnd = GetWindowRect();
-
- if (IsVisible() && !rectWnd.IsEmpty())
- {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rectWnd, this->GetBackgroundColor(), GetTransparency());
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device,
- CPDF_Point(rectWnd.left+2.0f,rectWnd.top-2.0f), CPDF_Point(rectWnd.left+2.0f,rectWnd.bottom+2.0f),
- ArgbEncode(this->GetTransparency(),100,100,100),1.0f);
-
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device,
- CPDF_Point(rectWnd.right-2.0f,rectWnd.top-2.0f), CPDF_Point(rectWnd.right-2.0f,rectWnd.bottom+2.0f),
- ArgbEncode(this->GetTransparency(),100,100,100),1.0f);
- }
-}
-
-FX_BOOL CPWL_ScrollBar::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonDown(point,nFlag);
-
- //SetFocus();
-
- if (HasFlag(PWS_AUTOTRANSPARENT))
- {
- if (GetTransparency() != 255)
- {
- SetTransparency(255);
- InvalidateRect();
- }
- }
-
- CPDF_Rect rcMinArea,rcMaxArea;
-
- if (m_pPosButton && m_pPosButton->IsVisible())
- {
- CPDF_Rect rcClient = this->GetClientRect();
- CPDF_Rect rcPosButton = m_pPosButton->GetWindowRect();
-
- switch (m_sbType)
- {
- case SBT_HSCROLL:
- rcMinArea = CPDF_Rect(rcClient.left + PWL_SCROLLBAR_BUTTON_WIDTH,rcClient.bottom,
- rcPosButton.left,rcClient.top);
- rcMaxArea = CPDF_Rect(rcPosButton.right,rcClient.bottom,
- rcClient.right - PWL_SCROLLBAR_BUTTON_WIDTH,rcClient.top);
-
- break;
- case SBT_VSCROLL:
- rcMinArea = CPDF_Rect(rcClient.left,rcPosButton.top,
- rcClient.right,rcClient.top - PWL_SCROLLBAR_BUTTON_WIDTH);
- rcMaxArea = CPDF_Rect(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 CPDF_Point & 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, FX_INTPTR wParam, FX_INTPTR lParam)
-{
- CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam);
-
- switch (msg)
- {
- case PNM_LBUTTONDOWN:
- if (pWnd == m_pMinButton)
- {
- OnMinButtonLBDown(*(CPDF_Point*)lParam);
- }
-
- if (pWnd == m_pMaxButton)
- {
- OnMaxButtonLBDown(*(CPDF_Point*)lParam);
- }
-
- if (pWnd == m_pPosButton)
- {
- OnPosButtonLBDown(*(CPDF_Point*)lParam);
- }
- break;
- case PNM_LBUTTONUP:
- if (pWnd == m_pMinButton)
- {
- OnMinButtonLBUp(*(CPDF_Point*)lParam);
- }
-
- if (pWnd == m_pMaxButton)
- {
- OnMaxButtonLBUp(*(CPDF_Point*)lParam);
- }
-
- if (pWnd == m_pPosButton)
- {
- OnPosButtonLBUp(*(CPDF_Point*)lParam);
- }
- break;
- case PNM_MOUSEMOVE:
- if (pWnd == m_pMinButton)
- {
- OnMinButtonMouseMove(*(CPDF_Point*)lParam);
- }
-
- if (pWnd == m_pMaxButton)
- {
- OnMaxButtonMouseMove(*(CPDF_Point*)lParam);
- }
-
- if (pWnd == m_pPosButton)
- {
- OnPosButtonMouseMove(*(CPDF_Point*)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;
- this->SetScrollRange(0,fMax, pInfo->fPlateWidth);
- this->SetScrollStep(pInfo->fBigStep,pInfo->fSmallStep);
- }
- }
- }
- break;
- case PNM_SETSCROLLPOS:
- {
- FX_FLOAT fPos = *(FX_FLOAT*)lParam;
- switch (this->m_sbType)
- {
- case SBT_HSCROLL:
- fPos = fPos - m_OriginInfo.fContentMin;
- break;
- case SBT_VSCROLL:
- fPos = m_OriginInfo.fContentMax - fPos;
- break;
- }
- this->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_pPosButton != NULL);
- ASSERT (m_pMinButton != NULL);
- ASSERT (m_pMaxButton != NULL);
-
- if (m_pPosButton->IsVisible())
- {
-
-
-
-
- CPDF_Rect rcClient;
- CPDF_Rect rcPosArea,rcPosButton;
-
- rcClient = this->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 = CPDF_Rect(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 = CPDF_Rect(rcPosArea.left,
- fBottom,
- rcPosArea.right,
- fTop);
-
- break;
- }
-
- m_pPosButton->Move(rcPosButton,TRUE,bRefresh);
- }
-}
-
-void CPWL_ScrollBar::OnMinButtonLBDown(const CPDF_Point & point)
-{
- m_sData.SubSmall();
- MovePosButton(TRUE);
- NotifyScrollWindow();
-
- m_bMinOrMax = TRUE;
-
- EndTimer();
- BeginTimer(100);
-}
-
-void CPWL_ScrollBar::OnMinButtonLBUp(const CPDF_Point & point)
-{
-}
-
-void CPWL_ScrollBar::OnMinButtonMouseMove(const CPDF_Point & point)
-{
-}
-
-void CPWL_ScrollBar::OnMaxButtonLBDown(const CPDF_Point & point)
-{
- m_sData.AddSmall();
- MovePosButton(TRUE);
- NotifyScrollWindow();
-
- m_bMinOrMax = FALSE;
-
- EndTimer();
- BeginTimer(100);
-}
-
-void CPWL_ScrollBar::OnMaxButtonLBUp(const CPDF_Point & point)
-{
-}
-
-void CPWL_ScrollBar::OnMaxButtonMouseMove(const CPDF_Point & point)
-{
-}
-
-void CPWL_ScrollBar::OnPosButtonLBDown(const CPDF_Point & point)
-{
- m_bMouseDown = TRUE;
-
- if (m_pPosButton)
- {
- CPDF_Rect 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 CPDF_Point & point)
-{
- if (m_bMouseDown)
- {
- if (!m_bNotifyForever)
- NotifyScrollWindow();
- }
- m_bMouseDown = FALSE;
-}
-
-void CPWL_ScrollBar::OnPosButtonMouseMove(const CPDF_Point & 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 = this->GetParentWindow())
- {
- FX_FLOAT fPos;
- switch (this->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,(FX_INTPTR)m_sbType,(FX_INTPTR)&fPos);
- }
-}
-
-CPDF_Rect CPWL_ScrollBar::GetScrollArea() const
-{
- CPDF_Rect rcClient = GetClientRect();
- CPDF_Rect rcArea;
-
- if (!m_pMinButton || !m_pMaxButton)return rcClient;
-
- CPDF_Rect rcMin = m_pMinButton->GetWindowRect();
- CPDF_Rect 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 = CPDF_Rect(rcClient.left + fMinWidth + 1,rcClient.bottom,
- rcClient.right - fMaxWidth - 1,rcClient.top);
- }
- else
- {
- rcArea = CPDF_Rect(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 = CPDF_Rect(rcClient.left,rcClient.bottom + fMinHeight + 1,
- rcClient.right,rcClient.top - fMaxHeight - 1);
- }
- else
- {
- rcArea = CPDF_Rect(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)
-{
- CPDF_Rect 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)
-{
- CPDF_Rect 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();
- }
-}
-
-/*
-void CPWL_ScrollBar::OnSetFocus()
-{
- if (GetTransparency() != 255)
- {
- SetTransparency(255);
- InvalidateRect();
- }
-}
-
-void CPWL_ScrollBar::OnKillFocus()
-{
- if (GetTransparency() != PWL_SCROLLBAR_TRANSPARANCY)
- {
- SetTransparency(PWL_SCROLLBAR_TRANSPARANCY);
- InvalidateRect();
- }
-}
-*/
-
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_ScrollBar.h"
+#include "../../include/pdfwindow/PWL_Utils.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::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::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::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;
+
+ CPDF_Rect rectWnd = GetWindowRect();
+
+ if (rectWnd.IsEmpty()) return;
+
+ sAppStream << "q\n";
+
+ CPDF_Point ptCenter = this->GetCenterPoint();
+
+ switch (this->m_eScrollBarType)
+ {
+ case SBT_HSCROLL:
+ switch (this->m_eSBButtonType)
+ {
+ case PSBT_MIN:
+ {
+ CPDF_Point pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y);
+ CPDF_Point pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y + PWL_TRIANGLE_HALFLEN);
+ CPDF_Point 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:
+ {
+ CPDF_Point pt1(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y);
+ CPDF_Point pt2(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y + PWL_TRIANGLE_HALFLEN);
+ CPDF_Point 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(this->m_eSBButtonType)
+ {
+ case PSBT_MIN:
+ {
+ CPDF_Point pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN,ptCenter.y - PWL_TRIANGLE_HALFLEN * 0.5f);
+ CPDF_Point pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN,ptCenter.y - PWL_TRIANGLE_HALFLEN * 0.5f);
+ CPDF_Point 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:
+ {
+ CPDF_Point pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN,ptCenter.y + PWL_TRIANGLE_HALFLEN * 0.5f);
+ CPDF_Point pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN,ptCenter.y + PWL_TRIANGLE_HALFLEN * 0.5f);
+ CPDF_Point 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, CPDF_Matrix* pUser2Device)
+{
+ if (!IsVisible()) return;
+
+ CPDF_Rect rectWnd = GetWindowRect();
+ if (rectWnd.IsEmpty()) return;
+
+ CPDF_Point ptCenter = this->GetCenterPoint();
+ FX_INT32 nTransparancy = this->GetTransparency();
+
+ switch (this->m_eScrollBarType)
+ {
+ case SBT_HSCROLL:
+ CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
+ switch (this->m_eSBButtonType)
+ {
+ case PSBT_MIN:
+ {
+ CPDF_Point pt1(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y);
+ CPDF_Point pt2(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y + PWL_TRIANGLE_HALFLEN);
+ CPDF_Point 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:
+ {
+ CPDF_Point pt1(ptCenter.x + PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y);
+ CPDF_Point pt2(ptCenter.x - PWL_TRIANGLE_HALFLEN * 0.5f,ptCenter.y + PWL_TRIANGLE_HALFLEN);
+ CPDF_Point 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(this->m_eSBButtonType)
+ {
+ case PSBT_MIN:
+ {
+ //draw border
+ CPDF_Rect 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 (this->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;
+ CPDF_Point pts[7] = {
+ CPDF_Point(fX+2.5f, fY+4.0f),
+ CPDF_Point(fX+2.5f, fY+3.0f),
+ CPDF_Point(fX+4.5f, fY+5.0f),
+ CPDF_Point(fX+6.5f, fY+3.0f),
+ CPDF_Point(fX+6.5f, fY+4.0f),
+ CPDF_Point(fX+4.5f, fY+6.0f),
+ CPDF_Point(fX+2.5f, fY+4.0f)};
+
+
+ if (this->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
+ CPDF_Rect 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 (this->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;
+
+ CPDF_Point pts[7] = {
+ CPDF_Point(fX+2.5f, fY+5.0f),
+ CPDF_Point(fX+2.5f, fY+6.0f),
+ CPDF_Point(fX+4.5f, fY+4.0f),
+ CPDF_Point(fX+6.5f, fY+6.0f),
+ CPDF_Point(fX+6.5f, fY+5.0f),
+ CPDF_Point(fX+4.5f, fY+3.0f),
+ CPDF_Point(fX+2.5f, fY+5.0f)};
+
+
+ if (this->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:
+ {
+ //CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
+
+ //draw border
+ CPDF_Rect 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 (this->IsEnabled())
+ {
+ //draw shadow effect
+
+ CPDF_Point ptTop = CPDF_Point(rectWnd.left,rectWnd.top-1.0f);
+ CPDF_Point ptBottom = CPDF_Point(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 (!this->IsEnabled())
+ crStroke = CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_HEAVYGRAYCOLOR,255);
+
+ FX_FLOAT nFrictionWidth = 5.0f;
+ FX_FLOAT nFrictionHeight = 5.5f;
+
+ CPDF_Point ptLeft = CPDF_Point(ptCenter.x - nFrictionWidth / 2.0f, ptCenter.y - nFrictionHeight / 2.0f + 0.5f);
+ CPDF_Point ptRight = CPDF_Point(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);
+
+ /*
+ ptLeft.y += 1.5f;
+ ptRight.y += 1.5f;
+
+ CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight,
+ ArgbEncode(nTransparancy,150,150,150),1.0f);
+ */
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+FX_BOOL CPWL_SBButton::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
+{
+ CPWL_Wnd::OnLButtonDown(point,nFlag);
+
+ if (CPWL_Wnd * pParent = GetParentWindow())
+ pParent->OnNotify(this,PNM_LBUTTONDOWN,0,(FX_INTPTR)&point);
+
+ m_bMouseDown = TRUE;
+ SetCapture();
+
+ return TRUE;
+}
+
+FX_BOOL CPWL_SBButton::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
+{
+ CPWL_Wnd::OnLButtonUp(point,nFlag);
+
+ if (CPWL_Wnd * pParent = GetParentWindow())
+ pParent->OnNotify(this,PNM_LBUTTONUP,0,(FX_INTPTR)&point);
+
+ m_bMouseDown = FALSE;
+ ReleaseCapture();
+
+ return TRUE;
+}
+
+FX_BOOL CPWL_SBButton::OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag)
+{
+ CPWL_Wnd::OnMouseMove(point,nFlag);
+
+ if (CPWL_Wnd * pParent = GetParentWindow())
+ {
+ pParent->OnNotify(this,PNM_MOUSEMOVE,0,(FX_INTPTR)&point);
+
+ /*
+ if (m_bMouseDown && (m_eSBButtonType == PSBT_MIN || m_eSBButtonType == PSBT_MAX))
+ {
+ if (!pParent->OnNotify(this,PNM_LBUTTONDOWN,nFlags,(FX_INTPTR)&point))
+ return FALSE;
+ }
+ */
+ }
+
+ return TRUE;
+}
+
+/* ------------------------------- CPWL_ScrollBar ---------------------------------- */
+
+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()
+{
+ CPDF_Rect rcClient = this->GetClientRect();
+
+/*
+ switch(m_sbType)
+ {
+ case SBT_HSCROLL:
+ if (rcClient.right - rcClient.left < PWL_SCROLLBAR_WIDTH ||
+ rcClient.top - rcClient.bottom < PWL_SCROLLBAR_WIDTH)
+ {
+ SetVisible(FALSE);
+ }
+ break;
+ case SBT_VSCROLL:
+ if (rcClient.right - rcClient.left < PWL_SCROLLBAR_WIDTH ||
+ rcClient.top - rcClient.bottom < PWL_SCROLLBAR_WIDTH)
+ {
+ SetVisible(FALSE);
+ }
+ break;
+ }
+*/
+ CPDF_Rect 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 = CPDF_Rect(rcClient.left,rcClient.bottom,
+ rcClient.left + PWL_SCROLLBAR_BUTTON_WIDTH,rcClient.top);
+ rcMaxButton = CPDF_Rect(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 = CPDF_Rect(rcClient.left,rcClient.bottom,
+ rcClient.left + fBWidth,rcClient.top);
+ rcMaxButton = CPDF_Rect(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 = CPDF_Rect(rcClient.left,rcClient.top - PWL_SCROLLBAR_BUTTON_WIDTH,
+ rcClient.right,rcClient.top);
+ rcMaxButton = CPDF_Rect(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 = CPDF_Rect(rcClient.left,rcClient.top - fBWidth,
+ rcClient.right,rcClient.top);
+ rcMaxButton = CPDF_Rect(rcClient.left,rcClient.bottom,
+ rcClient.right,rcClient.bottom + fBWidth);
+ }
+ else SetVisible(FALSE);
+ }
+ break;
+ }
+
+// if (IsVisible())
+ {
+ 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)
+{
+ CPDF_Rect 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, CPDF_Matrix* pUser2Device)
+{
+// CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
+ CPDF_Rect rectWnd = GetWindowRect();
+
+ if (IsVisible() && !rectWnd.IsEmpty())
+ {
+ CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rectWnd, this->GetBackgroundColor(), GetTransparency());
+
+ CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device,
+ CPDF_Point(rectWnd.left+2.0f,rectWnd.top-2.0f), CPDF_Point(rectWnd.left+2.0f,rectWnd.bottom+2.0f),
+ ArgbEncode(this->GetTransparency(),100,100,100),1.0f);
+
+ CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device,
+ CPDF_Point(rectWnd.right-2.0f,rectWnd.top-2.0f), CPDF_Point(rectWnd.right-2.0f,rectWnd.bottom+2.0f),
+ ArgbEncode(this->GetTransparency(),100,100,100),1.0f);
+ }
+}
+
+FX_BOOL CPWL_ScrollBar::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
+{
+ CPWL_Wnd::OnLButtonDown(point,nFlag);
+
+ //SetFocus();
+
+ if (HasFlag(PWS_AUTOTRANSPARENT))
+ {
+ if (GetTransparency() != 255)
+ {
+ SetTransparency(255);
+ InvalidateRect();
+ }
+ }
+
+ CPDF_Rect rcMinArea,rcMaxArea;
+
+ if (m_pPosButton && m_pPosButton->IsVisible())
+ {
+ CPDF_Rect rcClient = this->GetClientRect();
+ CPDF_Rect rcPosButton = m_pPosButton->GetWindowRect();
+
+ switch (m_sbType)
+ {
+ case SBT_HSCROLL:
+ rcMinArea = CPDF_Rect(rcClient.left + PWL_SCROLLBAR_BUTTON_WIDTH,rcClient.bottom,
+ rcPosButton.left,rcClient.top);
+ rcMaxArea = CPDF_Rect(rcPosButton.right,rcClient.bottom,
+ rcClient.right - PWL_SCROLLBAR_BUTTON_WIDTH,rcClient.top);
+
+ break;
+ case SBT_VSCROLL:
+ rcMinArea = CPDF_Rect(rcClient.left,rcPosButton.top,
+ rcClient.right,rcClient.top - PWL_SCROLLBAR_BUTTON_WIDTH);
+ rcMaxArea = CPDF_Rect(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 CPDF_Point & 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, FX_INTPTR wParam, FX_INTPTR lParam)
+{
+ CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam);
+
+ switch (msg)
+ {
+ case PNM_LBUTTONDOWN:
+ if (pWnd == m_pMinButton)
+ {
+ OnMinButtonLBDown(*(CPDF_Point*)lParam);
+ }
+
+ if (pWnd == m_pMaxButton)
+ {
+ OnMaxButtonLBDown(*(CPDF_Point*)lParam);
+ }
+
+ if (pWnd == m_pPosButton)
+ {
+ OnPosButtonLBDown(*(CPDF_Point*)lParam);
+ }
+ break;
+ case PNM_LBUTTONUP:
+ if (pWnd == m_pMinButton)
+ {
+ OnMinButtonLBUp(*(CPDF_Point*)lParam);
+ }
+
+ if (pWnd == m_pMaxButton)
+ {
+ OnMaxButtonLBUp(*(CPDF_Point*)lParam);
+ }
+
+ if (pWnd == m_pPosButton)
+ {
+ OnPosButtonLBUp(*(CPDF_Point*)lParam);
+ }
+ break;
+ case PNM_MOUSEMOVE:
+ if (pWnd == m_pMinButton)
+ {
+ OnMinButtonMouseMove(*(CPDF_Point*)lParam);
+ }
+
+ if (pWnd == m_pMaxButton)
+ {
+ OnMaxButtonMouseMove(*(CPDF_Point*)lParam);
+ }
+
+ if (pWnd == m_pPosButton)
+ {
+ OnPosButtonMouseMove(*(CPDF_Point*)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;
+ this->SetScrollRange(0,fMax, pInfo->fPlateWidth);
+ this->SetScrollStep(pInfo->fBigStep,pInfo->fSmallStep);
+ }
+ }
+ }
+ break;
+ case PNM_SETSCROLLPOS:
+ {
+ FX_FLOAT fPos = *(FX_FLOAT*)lParam;
+ switch (this->m_sbType)
+ {
+ case SBT_HSCROLL:
+ fPos = fPos - m_OriginInfo.fContentMin;
+ break;
+ case SBT_VSCROLL:
+ fPos = m_OriginInfo.fContentMax - fPos;
+ break;
+ }
+ this->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_pPosButton != NULL);
+ ASSERT (m_pMinButton != NULL);
+ ASSERT (m_pMaxButton != NULL);
+
+ if (m_pPosButton->IsVisible())
+ {
+
+
+
+
+ CPDF_Rect rcClient;
+ CPDF_Rect rcPosArea,rcPosButton;
+
+ rcClient = this->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 = CPDF_Rect(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 = CPDF_Rect(rcPosArea.left,
+ fBottom,
+ rcPosArea.right,
+ fTop);
+
+ break;
+ }
+
+ m_pPosButton->Move(rcPosButton,TRUE,bRefresh);
+ }
+}
+
+void CPWL_ScrollBar::OnMinButtonLBDown(const CPDF_Point & point)
+{
+ m_sData.SubSmall();
+ MovePosButton(TRUE);
+ NotifyScrollWindow();
+
+ m_bMinOrMax = TRUE;
+
+ EndTimer();
+ BeginTimer(100);
+}
+
+void CPWL_ScrollBar::OnMinButtonLBUp(const CPDF_Point & point)
+{
+}
+
+void CPWL_ScrollBar::OnMinButtonMouseMove(const CPDF_Point & point)
+{
+}
+
+void CPWL_ScrollBar::OnMaxButtonLBDown(const CPDF_Point & point)
+{
+ m_sData.AddSmall();
+ MovePosButton(TRUE);
+ NotifyScrollWindow();
+
+ m_bMinOrMax = FALSE;
+
+ EndTimer();
+ BeginTimer(100);
+}
+
+void CPWL_ScrollBar::OnMaxButtonLBUp(const CPDF_Point & point)
+{
+}
+
+void CPWL_ScrollBar::OnMaxButtonMouseMove(const CPDF_Point & point)
+{
+}
+
+void CPWL_ScrollBar::OnPosButtonLBDown(const CPDF_Point & point)
+{
+ m_bMouseDown = TRUE;
+
+ if (m_pPosButton)
+ {
+ CPDF_Rect 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 CPDF_Point & point)
+{
+ if (m_bMouseDown)
+ {
+ if (!m_bNotifyForever)
+ NotifyScrollWindow();
+ }
+ m_bMouseDown = FALSE;
+}
+
+void CPWL_ScrollBar::OnPosButtonMouseMove(const CPDF_Point & 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 = this->GetParentWindow())
+ {
+ FX_FLOAT fPos;
+ switch (this->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,(FX_INTPTR)m_sbType,(FX_INTPTR)&fPos);
+ }
+}
+
+CPDF_Rect CPWL_ScrollBar::GetScrollArea() const
+{
+ CPDF_Rect rcClient = GetClientRect();
+ CPDF_Rect rcArea;
+
+ if (!m_pMinButton || !m_pMaxButton)return rcClient;
+
+ CPDF_Rect rcMin = m_pMinButton->GetWindowRect();
+ CPDF_Rect 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 = CPDF_Rect(rcClient.left + fMinWidth + 1,rcClient.bottom,
+ rcClient.right - fMaxWidth - 1,rcClient.top);
+ }
+ else
+ {
+ rcArea = CPDF_Rect(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 = CPDF_Rect(rcClient.left,rcClient.bottom + fMinHeight + 1,
+ rcClient.right,rcClient.top - fMaxHeight - 1);
+ }
+ else
+ {
+ rcArea = CPDF_Rect(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)
+{
+ CPDF_Rect 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)
+{
+ CPDF_Rect 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();
+ }
+}
+
+/*
+void CPWL_ScrollBar::OnSetFocus()
+{
+ if (GetTransparency() != 255)
+ {
+ SetTransparency(255);
+ InvalidateRect();
+ }
+}
+
+void CPWL_ScrollBar::OnKillFocus()
+{
+ if (GetTransparency() != PWL_SCROLLBAR_TRANSPARANCY)
+ {
+ SetTransparency(PWL_SCROLLBAR_TRANSPARANCY);
+ InvalidateRect();
+ }
+}
+*/
+
diff --git a/fpdfsdk/src/pdfwindow/PWL_Signature.cpp b/fpdfsdk/src/pdfwindow/PWL_Signature.cpp
index 36297f3..5d79ce9 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Signature.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Signature.cpp
@@ -1,220 +1,220 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_Icon.h"
-#include "../../include/pdfwindow/PWL_Signature.h"
-#include "../../include/pdfwindow/PWL_Label.h"
-#include "../../include/pdfwindow/PWL_Utils.h"
-
-/* --------------------------------- CPWL_Signature_Image --------------------------------- */
-
-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, CPDF_Matrix* pUser2Device)
-{
- CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
-
- if (m_pImage)
- {
- CPDF_Rect rcClient = GetClientRect();
-
- FX_FLOAT x, y;
- pUser2Device->Transform(rcClient.left, rcClient.top, x, y);
-
- pDevice->StretchDIBits(m_pImage, (FX_INT32)x, (FX_INT32)y,
- (FX_INT32)rcClient.Width(), (FX_INT32)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);
-
- CPDF_Rect rcClient = GetClientRect();
-
- fHScale = rcClient.Width() / fImageW;
- fVScale = rcClient.Height() / fImageH;
-}
-
-/* --------------------------------- CPWL_Signature --------------------------------- */
-
-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(FX_LPCWSTR sText)
-{
- m_pText->SetText(sText);
-
- RePosChildWnd();
-}
-
-void CPWL_Signature::SetDescription(FX_LPCWSTR string)
-{
- m_pDescription->SetText(string);
-
- RePosChildWnd();
-}
-
-void CPWL_Signature::SetImage(CFX_DIBSource* pImage)
-{
- m_pImage->SetImage(pImage);
-
- RePosChildWnd();
-}
-
-void CPWL_Signature::SetImageStream(CPDF_Stream * pStream, FX_LPCSTR sImageAlias)
-{
- m_pImage->SetPDFStream(pStream);
- m_pImage->SetImageAlias(sImageAlias);
-
- RePosChildWnd();
-}
-
-void CPWL_Signature::RePosChildWnd()
-{
- CPDF_Rect rcClient = GetClientRect();
-
- CPDF_Rect rcText = rcClient;
- CPDF_Rect 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, CPDF_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);
-
- /*
- CPDF_Rect rcClient = GetClientRect();
-
- CFX_PathData path;
-
- path.SetPointCount(2);
- path.SetPoint(0, rcClient.left, (rcClient.top + rcClient.bottom) * 0.5f, FXPT_MOVETO);
- path.SetPoint(1, rcClient.right, (rcClient.top + rcClient.bottom) * 0.5f, FXPT_LINETO);
-
- CFX_GraphStateData gsd;
- gsd.SetDashCount(2);
- gsd.m_DashArray[0] = 6.0f;
- gsd.m_DashArray[1] = 6.0f;
- gsd.m_DashPhase = 0;
-
- gsd.m_LineWidth = 10.0f;
- pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255,255,0,0), FXFILL_ALTERNATE);
- */
-}
-
-void CPWL_Signature::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
-{
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
-}
-
-
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_Icon.h"
+#include "../../include/pdfwindow/PWL_Signature.h"
+#include "../../include/pdfwindow/PWL_Label.h"
+#include "../../include/pdfwindow/PWL_Utils.h"
+
+/* --------------------------------- CPWL_Signature_Image --------------------------------- */
+
+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, CPDF_Matrix* pUser2Device)
+{
+ CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
+
+ if (m_pImage)
+ {
+ CPDF_Rect rcClient = GetClientRect();
+
+ FX_FLOAT x, y;
+ pUser2Device->Transform(rcClient.left, rcClient.top, x, y);
+
+ pDevice->StretchDIBits(m_pImage, (FX_INT32)x, (FX_INT32)y,
+ (FX_INT32)rcClient.Width(), (FX_INT32)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);
+
+ CPDF_Rect rcClient = GetClientRect();
+
+ fHScale = rcClient.Width() / fImageW;
+ fVScale = rcClient.Height() / fImageH;
+}
+
+/* --------------------------------- CPWL_Signature --------------------------------- */
+
+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(FX_LPCWSTR sText)
+{
+ m_pText->SetText(sText);
+
+ RePosChildWnd();
+}
+
+void CPWL_Signature::SetDescription(FX_LPCWSTR string)
+{
+ m_pDescription->SetText(string);
+
+ RePosChildWnd();
+}
+
+void CPWL_Signature::SetImage(CFX_DIBSource* pImage)
+{
+ m_pImage->SetImage(pImage);
+
+ RePosChildWnd();
+}
+
+void CPWL_Signature::SetImageStream(CPDF_Stream * pStream, FX_LPCSTR sImageAlias)
+{
+ m_pImage->SetPDFStream(pStream);
+ m_pImage->SetImageAlias(sImageAlias);
+
+ RePosChildWnd();
+}
+
+void CPWL_Signature::RePosChildWnd()
+{
+ CPDF_Rect rcClient = GetClientRect();
+
+ CPDF_Rect rcText = rcClient;
+ CPDF_Rect 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, CPDF_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);
+
+ /*
+ CPDF_Rect rcClient = GetClientRect();
+
+ CFX_PathData path;
+
+ path.SetPointCount(2);
+ path.SetPoint(0, rcClient.left, (rcClient.top + rcClient.bottom) * 0.5f, FXPT_MOVETO);
+ path.SetPoint(1, rcClient.right, (rcClient.top + rcClient.bottom) * 0.5f, FXPT_LINETO);
+
+ CFX_GraphStateData gsd;
+ gsd.SetDashCount(2);
+ gsd.m_DashArray[0] = 6.0f;
+ gsd.m_DashArray[1] = 6.0f;
+ gsd.m_DashPhase = 0;
+
+ gsd.m_LineWidth = 10.0f;
+ pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255,255,0,0), FXFILL_ALTERNATE);
+ */
+}
+
+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
index aabf503..287fec1 100644
--- a/fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp
@@ -1,110 +1,110 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_Button.h"
-#include "../../include/pdfwindow/PWL_SpecialButton.h"
-#include "../../include/pdfwindow/PWL_Utils.h"
-
-/* --------------------------- CPWL_PushButton ---------------------------- */
-
-CPWL_PushButton::CPWL_PushButton()
-{
-}
-
-CPWL_PushButton::~CPWL_PushButton()
-{
-}
-
-CFX_ByteString CPWL_PushButton::GetClassName() const
-{
- return "CPWL_PushButton";
-}
-
-CPDF_Rect CPWL_PushButton::GetFocusRect() const
-{
- return CPWL_Utils::DeflateRect(this->GetWindowRect(),(FX_FLOAT)GetBorderWidth());
-}
-
-/* --------------------------- CPWL_CheckBox ---------------------------- */
-
-CPWL_CheckBox::CPWL_CheckBox() : m_bChecked(FALSE)
-{
-}
-
-CPWL_CheckBox::~CPWL_CheckBox()
-{
-}
-
-CFX_ByteString CPWL_CheckBox::GetClassName() const
-{
- return "CPWL_CheckBox";
-}
-
-void CPWL_CheckBox::SetCheck(FX_BOOL bCheck)
-{
- m_bChecked = bCheck;
-}
-
-FX_BOOL CPWL_CheckBox::IsChecked() const
-{
- return m_bChecked;
-}
-
-FX_BOOL CPWL_CheckBox::OnLButtonUp(const CPDF_Point & point)
-{
- if (IsReadOnly()) return FALSE;
-
- SetCheck(!IsChecked());
- return TRUE;
-}
-
-FX_BOOL CPWL_CheckBox::OnChar(FX_WORD nChar)
-{
- SetCheck(!IsChecked());
- return TRUE;
-}
-
-/* --------------------------- CPWL_RadioButton ---------------------------- */
-
-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 CPDF_Point & point)
-{
- if (IsReadOnly()) return FALSE;
-
- SetCheck(TRUE);
- return TRUE;
-}
-
-void CPWL_RadioButton::SetCheck(FX_BOOL bCheck)
-{
- m_bChecked = bCheck;
-}
-
-FX_BOOL CPWL_RadioButton::IsChecked() const
-{
- return m_bChecked;
-}
-
-FX_BOOL CPWL_RadioButton::OnChar(FX_WORD nChar)
-{
- SetCheck(TRUE);
- return TRUE;
-}
-
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_Button.h"
+#include "../../include/pdfwindow/PWL_SpecialButton.h"
+#include "../../include/pdfwindow/PWL_Utils.h"
+
+/* --------------------------- CPWL_PushButton ---------------------------- */
+
+CPWL_PushButton::CPWL_PushButton()
+{
+}
+
+CPWL_PushButton::~CPWL_PushButton()
+{
+}
+
+CFX_ByteString CPWL_PushButton::GetClassName() const
+{
+ return "CPWL_PushButton";
+}
+
+CPDF_Rect CPWL_PushButton::GetFocusRect() const
+{
+ return CPWL_Utils::DeflateRect(this->GetWindowRect(),(FX_FLOAT)GetBorderWidth());
+}
+
+/* --------------------------- CPWL_CheckBox ---------------------------- */
+
+CPWL_CheckBox::CPWL_CheckBox() : m_bChecked(FALSE)
+{
+}
+
+CPWL_CheckBox::~CPWL_CheckBox()
+{
+}
+
+CFX_ByteString CPWL_CheckBox::GetClassName() const
+{
+ return "CPWL_CheckBox";
+}
+
+void CPWL_CheckBox::SetCheck(FX_BOOL bCheck)
+{
+ m_bChecked = bCheck;
+}
+
+FX_BOOL CPWL_CheckBox::IsChecked() const
+{
+ return m_bChecked;
+}
+
+FX_BOOL CPWL_CheckBox::OnLButtonUp(const CPDF_Point & point)
+{
+ if (IsReadOnly()) return FALSE;
+
+ SetCheck(!IsChecked());
+ return TRUE;
+}
+
+FX_BOOL CPWL_CheckBox::OnChar(FX_WORD nChar)
+{
+ SetCheck(!IsChecked());
+ return TRUE;
+}
+
+/* --------------------------- CPWL_RadioButton ---------------------------- */
+
+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 CPDF_Point & point)
+{
+ if (IsReadOnly()) return FALSE;
+
+ SetCheck(TRUE);
+ return TRUE;
+}
+
+void CPWL_RadioButton::SetCheck(FX_BOOL bCheck)
+{
+ m_bChecked = bCheck;
+}
+
+FX_BOOL CPWL_RadioButton::IsChecked() const
+{
+ return m_bChecked;
+}
+
+FX_BOOL CPWL_RadioButton::OnChar(FX_WORD nChar)
+{
+ SetCheck(TRUE);
+ return TRUE;
+}
+
diff --git a/fpdfsdk/src/pdfwindow/PWL_Utils.cpp b/fpdfsdk/src/pdfwindow/PWL_Utils.cpp
index aec1d4d..1de6b56 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Utils.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Utils.cpp
@@ -1,2844 +1,2844 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_Utils.h"
-#include "../../include/pdfwindow/PWL_Icon.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_Utils ------------------------------ */
-
-CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData, FX_INT32 nCount)
-{
- CFX_ByteTextBuf csAP;
-
- for (FX_INT32 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, FX_INT32 nCount)
-{
- path.SetPointCount(nCount);
-
- for (FX_INT32 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;
- }
- }
-}
-
-
-CPDF_Rect CPWL_Utils::MaxRect(const CPDF_Rect & rect1,const CPDF_Rect & rect2)
-{
- CPDF_Rect 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;
-}
-
-CPDF_Rect CPWL_Utils::OffsetRect(const CPDF_Rect & rect,FX_FLOAT x,FX_FLOAT y)
-{
- return CPDF_Rect(rect.left + x,rect.bottom + y,
- rect.right + x,rect.top + y);
-}
-
-FX_BOOL CPWL_Utils::ContainsRect(const CPDF_Rect& rcParent, const CPDF_Rect& rcChild)
-{
- return rcChild.left >= rcParent.left && rcChild.bottom >= rcParent.bottom &&
- rcChild.right <= rcParent.right && rcChild.top <= rcParent.top;
-}
-
-FX_BOOL CPWL_Utils::IntersectRect(const CPDF_Rect& rect1, const CPDF_Rect& 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;
-}
-
-CPDF_Point CPWL_Utils::OffsetPoint(const CPDF_Point& point,FX_FLOAT x,FX_FLOAT y)
-{
- return CPDF_Point(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 CPDF_Rect & crBBox)
-{
- CFX_ByteTextBuf csAP;
-
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- const FX_INT32 num = 8;
-
- CPWL_Point pts[num*3] =
- {
- //1
- CPWL_Point(0.28f, 0.52f),
- CPWL_Point(0.27f, 0.48f),
- CPWL_Point(0.29f, 0.40f),
-
- //2
- CPWL_Point(0.30f, 0.33f),
- CPWL_Point(0.31f, 0.29f),
- CPWL_Point(0.31f, 0.28f),
-
- //3
- CPWL_Point(0.39f, 0.28f),
- CPWL_Point(0.49f, 0.29f),
- CPWL_Point(0.77f, 0.67f),
-
- //4
- CPWL_Point(0.76f, 0.68f),
- CPWL_Point(0.78f, 0.69f),
- CPWL_Point(0.76f, 0.75f),
-
- //5
- CPWL_Point(0.76f, 0.75f),
- CPWL_Point(0.73f, 0.80f),
- CPWL_Point(0.68f, 0.75f),
-
- //6
- CPWL_Point(0.68f, 0.74f),
- CPWL_Point(0.68f, 0.74f),
- CPWL_Point(0.44f, 0.47f),
-
- //7
- CPWL_Point(0.43f, 0.47f),
- CPWL_Point(0.40f, 0.47f),
- CPWL_Point(0.41f, 0.58f),
-
- //8
- CPWL_Point(0.40f, 0.60f),
- CPWL_Point(0.28f, 0.66f),
- CPWL_Point(0.30f, 0.56f)
- };
-
- for (FX_INT32 j=0; j<num*3; j++)
- {
- pts[j].x *= fWidth;
- pts[j].x += crBBox.left;
-
- pts[j].y *= fHeight;
- pts[j].y += crBBox.bottom;
- }
-
- csAP << pts[0].x << " " << pts[0].y << " m\n";
-
- for (FX_INT32 i=0; i<num; i++)
- {
- FX_INT32 nCur = i*3;
- FX_INT32 n1 = i*3 + 1;
- FX_INT32 n2 = i*3 + 2;
- FX_INT32 nNext = (i < num-1 ? (i+1)*3 : 0);
-
- FX_FLOAT px1 = pts[n1].x - pts[nCur].x;
- FX_FLOAT py1 = pts[n1].y - pts[nCur].y;
- FX_FLOAT px2 = pts[n2].x - pts[nNext].x;
- FX_FLOAT py2 = pts[n2].y - pts[nNext].y;
-
- csAP << pts[nCur].x + px1 * PWL_BEZIER << " " << pts[nCur].y + py1 * PWL_BEZIER << " "
- << pts[nNext].x + px2 * PWL_BEZIER << " " << pts[nNext].y + py2 * PWL_BEZIER << " "
- << pts[nNext].x << " " << pts[nNext].y << " c\n";
- }
-
- return csAP.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetAP_Circle(const CPDF_Rect & crBBox)
-{
- CFX_ByteTextBuf csAP;
-
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPDF_Point pt1(crBBox.left,crBBox.bottom + fHeight / 2);
- CPDF_Point pt2(crBBox.left + fWidth / 2,crBBox.top);
- CPDF_Point pt3(crBBox.right,crBBox.bottom + fHeight / 2);
- CPDF_Point 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 * PWL_BEZIER << " "
- << pt2.x - px * PWL_BEZIER << " " << pt2.y << " "
- << pt2.x << " " << pt2.y << " c\n";
-
- px = pt3.x - pt2.x;
- py = pt2.y - pt3.y;
-
- csAP << pt2.x + px * PWL_BEZIER << " " << pt2.y << " "
- << pt3.x << " " << pt3.y + py * PWL_BEZIER << " "
- << pt3.x << " " << pt3.y << " c\n";
-
- px = pt3.x - pt4.x;
- py = pt3.y - pt4.y;
-
- csAP << pt3.x << " " << pt3.y - py * PWL_BEZIER << " "
- << pt4.x + px * PWL_BEZIER << " " << pt4.y << " "
- << pt4.x << " " << pt4.y << " c\n";
-
- px = pt4.x - pt1.x;
- py = pt1.y - pt4.y;
-
- csAP << pt4.x - px * PWL_BEZIER << " " << pt4.y << " "
- << pt1.x << " " << pt1.y - py * PWL_BEZIER << " "
- << pt1.x << " " << pt1.y << " c\n";
-
- return csAP.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetAP_Cross(const CPDF_Rect & 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 CPDF_Rect & crBBox)
-{
- CFX_ByteTextBuf csAP;
-
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPDF_Point pt1(crBBox.left,crBBox.bottom + fHeight / 2);
- CPDF_Point pt2(crBBox.left + fWidth / 2,crBBox.top);
- CPDF_Point pt3(crBBox.right,crBBox.bottom + fHeight / 2);
- CPDF_Point 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 CPDF_Rect & 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 CPDF_Rect & crBBox)
-{
- CFX_ByteTextBuf csAP;
-
- FX_FLOAT fRadius = (crBBox.top - crBBox.bottom)/(1+(FX_FLOAT)cos(PWL_PI/5.0f));
- CPDF_Point ptCenter = CPDF_Point((crBBox.left + crBBox.right) / 2.0f,(crBBox.top + crBBox.bottom) / 2.0f);
-
- FX_FLOAT px[5],py[5];
-
- FX_FLOAT fAngel = PWL_PI/10.0f;
-
- for (FX_INT32 i=0; i<5; i++)
- {
- px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel);
- py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel);
-
- fAngel += PWL_PI * 2 / 5.0f;
- }
-
- csAP << px[0] << " " << py[0] << " m\n";
-
- FX_INT32 nNext = 0;
- for (FX_INT32 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 CPDF_Rect & crBBox,FX_FLOAT fRotate)
-{
- CFX_ByteTextBuf csAP;
-
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
-
- CPDF_Point pt1(-fWidth/2,0);
- CPDF_Point pt2(0,fHeight/2);
- CPDF_Point 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 * PWL_BEZIER << " "
- << pt2.x - px * PWL_BEZIER << " " << pt2.y << " "
- << pt2.x << " " << pt2.y << " c\n";
-
- px = pt3.x - pt2.x;
- py = pt2.y - pt3.y;
-
- csAP << pt2.x + px * PWL_BEZIER << " " << pt2.y << " "
- << pt3.x << " " << pt3.y + py * PWL_BEZIER << " "
- << pt3.x << " " << pt3.y << " c\n";
-
- return csAP.GetByteString();
-}
-
-
-CPDF_Rect CPWL_Utils::InflateRect(const CPDF_Rect & rcRect, FX_FLOAT fSize)
-{
- if (rcRect.IsEmpty()) return rcRect;
-
- CPDF_Rect rcNew(rcRect.left - fSize,
- rcRect.bottom - fSize,
- rcRect.right + fSize,
- rcRect.top + fSize);
- rcNew.Normalize();
- return rcNew;
-}
-
-CPDF_Rect CPWL_Utils::DeflateRect(const CPDF_Rect & rcRect, FX_FLOAT fSize)
-{
- if (rcRect.IsEmpty()) return rcRect;
-
- CPDF_Rect rcNew(rcRect.left + fSize,
- rcRect.bottom + fSize,
- rcRect.right - fSize,
- rcRect.top - fSize);
- rcNew.Normalize();
- return rcNew;
-}
-
-CPDF_Rect CPWL_Utils::ScaleRect(const CPDF_Rect & rcRect,FX_FLOAT fScale)
-{
- FX_FLOAT fHalfWidth = (rcRect.right - rcRect.left) / 2.0f;
- FX_FLOAT fHalfHeight = (rcRect.top - rcRect.bottom) / 2.0f;
-
- CPDF_Point ptCenter = CPDF_Point((rcRect.left + rcRect.right) / 2,(rcRect.top + rcRect.bottom) / 2);
-
- return CPDF_Rect(ptCenter.x - fHalfWidth * fScale,
- ptCenter.y - fHalfHeight * fScale,
- ptCenter.x + fHalfWidth * fScale,
- ptCenter.y + fHalfHeight * fScale);
-}
-
-CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CPDF_Rect & 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 CPDF_Rect & 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();
-}
-
-CPDF_Rect CPWL_Utils::GetCenterSquare(const CPDF_Rect & 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 CPDF_Rect(fCenterX - fRadius,fCenterY - fRadius,fCenterX + fRadius,fCenterY + fRadius);
-}
-
-CFX_ByteString CPWL_Utils::GetEditAppStream(IFX_Edit* pEdit, const CPDF_Point & 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 CPDF_Point & 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;
- FX_INT32 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 CPDF_Point & 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 CPDF_Point & ptOffset,
- const CPVT_WordRange * pRange)
-{
- ASSERT(pEdit != NULL);
- ASSERT(pSpellCheck != NULL);
-
- 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 CPDF_Rect & rcBBox,IFX_Edit_FontMap * pFontMap,
- const CFX_WideString & sText, FX_INT32 nAlignmentH, FX_INT32 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);
-
- CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit, CPDF_Point(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 CPDF_Rect & rcBBox,
- IFX_Edit_FontMap * pFontMap,
- CPDF_Stream * pIconStream,
- CPDF_IconFit & IconFit,
- const CFX_WideString & sLabel,
- const CPWL_Color & crText,
- FX_FLOAT fFontSize,
- FX_INT32 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);
-
- CPDF_Rect rcLabelContent = pEdit->GetContentRect();
-
- CPWL_Icon Icon;
- PWL_CREATEPARAM cp;
- cp.dwFlags = PWS_VISIBLE;
- Icon.Create(cp);
- Icon.SetIconFit(&IconFit);
- Icon.SetPDFStream(pIconStream);
-
- CPDF_Rect rcLabel = CPDF_Rect(0,0,0,0);
- CPDF_Rect rcIcon = CPDF_Rect(0,0,0,0);
- FX_FLOAT fWidth = 0.0f;
- FX_FLOAT fHeight = 0.0f;
-
- switch (nLayOut)
- {
- case PPBL_LABEL:
- rcLabel = rcBBox;
- rcIcon = CPDF_Rect(0,0,0,0);
- break;
- case PPBL_ICON:
- rcIcon = rcBBox;
- rcLabel = CPDF_Rect(0,0,0,0);
- break;
- case PPBL_ICONTOPLABELBOTTOM:
-
- if (pIconStream)
- {
- if (IsFloatZero(fFontSize))
- {
- fHeight = rcBBox.top - rcBBox.bottom;
- rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcBBox.bottom + fHeight * fAutoFontScale);
- rcIcon = CPDF_Rect(rcBBox.left,rcLabel.top,rcBBox.right,rcBBox.top);
- }
- else
- {
- fHeight = rcLabelContent.Height();
-
- if (rcBBox.bottom + fHeight > rcBBox.top)
- {
- rcIcon = CPDF_Rect(0,0,0,0);
- rcLabel = rcBBox;
- }
- else
- {
- rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcBBox.bottom + fHeight);
- rcIcon = CPDF_Rect(rcBBox.left,rcLabel.top,rcBBox.right,rcBBox.top);
- }
- }
- }
- else
- {
- rcLabel = rcBBox;
- rcIcon = CPDF_Rect(0,0,0,0);
- }
-
- break;
- case PPBL_LABELTOPICONBOTTOM:
-
- if (pIconStream)
- {
- if (IsFloatZero(fFontSize))
- {
- fHeight = rcBBox.top - rcBBox.bottom;
- rcLabel = CPDF_Rect(rcBBox.left,rcBBox.top - fHeight * fAutoFontScale ,rcBBox.right,rcBBox.top);
- rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcLabel.bottom);
- }
- else
- {
- fHeight = rcLabelContent.Height();
-
- if (rcBBox.bottom + fHeight > rcBBox.top)
- {
- rcIcon = CPDF_Rect(0,0,0,0);
- rcLabel = rcBBox;
- }
- else
- {
- rcLabel = CPDF_Rect(rcBBox.left,rcBBox.top - fHeight,rcBBox.right,rcBBox.top);
- rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcLabel.bottom);
- }
- }
- }
- else
- {
- rcLabel = rcBBox;
- rcIcon = CPDF_Rect(0,0,0,0);
- }
-
- break;
- case PPBL_ICONLEFTLABELRIGHT:
-
- if (pIconStream)
- {
- if (IsFloatZero(fFontSize))
- {
- fWidth = rcBBox.right - rcBBox.left;
- rcLabel = CPDF_Rect(rcBBox.right - fWidth * fAutoFontScale,rcBBox.bottom,rcBBox.right,rcBBox.top);
- rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcLabel.left,rcBBox.top);
-
- if (rcLabelContent.Width() < fWidth * fAutoFontScale)
- {
- }
- else
- {
- if (rcLabelContent.Width() < fWidth)
- {
- rcLabel = CPDF_Rect(rcBBox.right - rcLabelContent.Width(),rcBBox.bottom,rcBBox.right,rcBBox.top);
- rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcLabel.left,rcBBox.top);
- }
- else
- {
- rcLabel = rcBBox;
- rcIcon = CPDF_Rect(0,0,0,0);
- }
- }
- }
- else
- {
- fWidth = rcLabelContent.Width();
-
- if (rcBBox.left + fWidth > rcBBox.right)
- {
- rcLabel = rcBBox;
- rcIcon = CPDF_Rect(0,0,0,0);
- }
- else
- {
- rcLabel = CPDF_Rect(rcBBox.right - fWidth,rcBBox.bottom,rcBBox.right,rcBBox.top);
- rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcLabel.left,rcBBox.top);
- }
- }
- }
- else
- {
- rcLabel = rcBBox;
- rcIcon = CPDF_Rect(0,0,0,0);
- }
-
- break;
- case PPBL_LABELLEFTICONRIGHT:
-
- if (pIconStream)
- {
- if (IsFloatZero(fFontSize))
- {
- fWidth = rcBBox.right - rcBBox.left;
- rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.left + fWidth * fAutoFontScale,rcBBox.top);
- rcIcon = CPDF_Rect(rcLabel.right,rcBBox.bottom,rcBBox.right,rcBBox.top);
-
- if (rcLabelContent.Width() < fWidth * fAutoFontScale)
- {
- }
- else
- {
- if (rcLabelContent.Width() < fWidth)
- {
- rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.left + rcLabelContent.Width(),rcBBox.top);
- rcIcon = CPDF_Rect(rcLabel.right,rcBBox.bottom,rcBBox.right,rcBBox.top);
- }
- else
- {
- rcLabel = rcBBox;
- rcIcon = CPDF_Rect(0,0,0,0);
- }
- }
- }
- else
- {
- fWidth = rcLabelContent.Width();
-
- if (rcBBox.left + fWidth > rcBBox.right)
- {
- rcLabel = rcBBox;
- rcIcon = CPDF_Rect(0,0,0,0);
- }
- else
- {
- rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.left + fWidth,rcBBox.top);
- rcIcon = CPDF_Rect(rcLabel.right,rcBBox.bottom,rcBBox.right,rcBBox.top);
- }
- }
- }
- else
- {
- rcLabel = rcBBox;
- rcIcon = CPDF_Rect(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,CPDF_Point(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 CPDF_Rect & rect, FX_FLOAT fWidth,
- const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom,
- FX_INT32 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 CPDF_Rect & rect, FX_FLOAT fWidth,
- const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom,
- FX_INT32 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),PWL_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),PWL_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),PWL_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),PWL_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 CPDF_Rect & 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 CPDF_Rect & 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 CPDF_Rect & 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 CPDF_Rect & 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 CPDF_Rect & 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 CPDF_Rect & 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 CPDF_Rect & rcBBox,
- FX_INT32 nStyle,
- const CPWL_Color & crText)
-{
- CPDF_Rect 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 CPDF_Rect & rcBBox,
- FX_INT32 nStyle,
- const CPWL_Color & crText)
-{
- CPDF_Rect 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 CPDF_Rect & 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";
-
- CPDF_Point ptCenter = CPDF_Point((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 - FX_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 - FX_MIN(1.0f, dC + dK);
- dG = 1.0f - FX_MIN(1.0f, dM + dK);
- dB = 1.0f - FX_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 = FX_MIN(dC, FX_MIN(dM, dY));
-}
-
-void CPWL_Utils::PWLColorToARGB(const CPWL_Color& color, FX_INT32& 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, FX_INT32 nTransparancy)
-{
- FX_INT32 nAlpha = nTransparancy;
- FX_FLOAT dRed = 0;
- FX_FLOAT dGreen = 0;
- FX_FLOAT dBlue = 0;
-
- PWLColorToARGB(color, nAlpha, dRed, dGreen, dBlue);
-
- return ArgbEncode(nAlpha, (FX_INT32)(dRed*255), (FX_INT32)(dGreen*255), (FX_INT32)(dBlue*255));
-}
-
-void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect,
- const FX_COLORREF & color)
-{
- CFX_PathData path;
- CPDF_Rect 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, CPDF_Matrix* pUser2Device,
- const CPDF_Point* pPts, FX_INT32 nCount, const FX_COLORREF& color)
-{
- CFX_PathData path;
- path.SetPointCount(nCount);
-
- path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_MOVETO);
- for (FX_INT32 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, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect,
- const FX_COLORREF & color, FX_FLOAT fWidth)
-{
- CFX_PathData path;
- CPDF_Rect 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, CPDF_Matrix* pUser2Device,
- const CPDF_Point & ptMoveTo, const CPDF_Point & 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, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect,
- const CPWL_Color & color, FX_INT32 nTransparancy)
-{
- CPWL_Utils::DrawFillRect(pDevice,pUser2Device,rect,PWLColorToFXColor(color,nTransparancy));
-}
-
-void CPWL_Utils::DrawShadow(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
- FX_BOOL bVertical, FX_BOOL bHorizontal, CPDF_Rect rect,
- FX_INT32 nTransparancy, FX_INT32 nStartGray, FX_INT32 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)
- {
- FX_INT32 nGray = nStartGray + (FX_INT32)(fStepGray * (fy-rect.bottom));
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, CPDF_Point(rect.left, fy),
- CPDF_Point(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)
- {
- FX_INT32 nGray = nStartGray + (FX_INT32)(fStepGray * (fx-rect.left));
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, CPDF_Point(fx, rect.bottom),
- CPDF_Point(fx, rect.top), ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f);
- }
- }
-}
-
-void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
- const CPDF_Rect & rect, FX_FLOAT fWidth,
- const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom,
- FX_INT32 nStyle, const CPWL_Dash & dash, FX_INT32 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;
- FX_INT32 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, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit,
- const CPDF_Rect& rcClip, const CPDF_Point& 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())
- {
- CPDF_Rect rcTemp = rcClip;
- pUser2Device->TransformRect(rcTemp);
- FX_RECT rcDevClip;
- rcDevClip.left = (FX_INT32)rcTemp.left;
- rcDevClip.right = (FX_INT32)rcTemp.right;
- rcDevClip.top = (FX_INT32)rcTemp.top;
- rcDevClip.bottom = (FX_INT32)rcTemp.bottom;
- pDevice->SetClip_Rect(&rcDevClip);
- }
-
- 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(FX_INT32 nType, const CPDF_Rect& 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, CPDF_Matrix* pUser2Device,
- FX_INT32 nType, const CPDF_Rect & rect, const CPWL_Color& crFill, const CPWL_Color& crStroke, const FX_INT32 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 CPDF_Rect& 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 + PWL_BEZIER*(fWidth / 7.0f - fWidth / 15.0f),
- crBBox.bottom + fHeight * 2 / 5.0f + PWL_BEZIER*(fHeight * 2 / 7.0f - fHeight * 2 / 5.0f)), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 4.5f + PWL_BEZIER*(fWidth / 5.0f - fWidth / 4.5f),
- crBBox.bottom + fHeight / 16.0f + PWL_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 + PWL_BEZIER*(fWidth / 4.4f - fWidth / 4.5f),
- crBBox.bottom + fHeight / 16.0f - PWL_BEZIER*fHeight / 16.0f), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f + PWL_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 + PWL_BEZIER*fWidth*(1/7.0f + 2/15.0f),
- crBBox.bottom + PWL_BEZIER*fHeight * 4 / 5.0f), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 14 / 15.0f + PWL_BEZIER*fWidth*(1/7.0f - 7/15.0f),
- crBBox.bottom + fHeight * 15/16.0f + PWL_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 + PWL_BEZIER*(fWidth * 7 / 15.0f - fWidth * 14 / 15.0f),
- crBBox.bottom + fHeight * 15 / 16.0f + PWL_BEZIER*(fHeight * 8 / 7.0f - fHeight * 15 / 16.0f)), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.6f + PWL_BEZIER*(fWidth / 3.4f - fWidth / 3.6f),
- crBBox.bottom + fHeight / 3.5f + PWL_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 + PWL_BEZIER*(fHeight / 4.0f - fHeight / 3.5f)), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f + PWL_BEZIER*(fWidth / 3.5f - fWidth / 15.0f),
- crBBox.bottom + fHeight * 2 / 5.0f + PWL_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 CPDF_Rect& 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 + PWL_BEZIER*(fHeight*14/15.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_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 + PWL_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 + PWL_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 - PWL_BEZIER*(fHeight/2.0f - fHeight/15.0f)), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_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 - PWL_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 - PWL_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 + PWL_BEZIER*(fHeight*4/5.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_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 + PWL_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 + PWL_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 - PWL_BEZIER*(fHeight*4/5.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_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 - PWL_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 - PWL_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 CPDF_Rect& 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 + PWL_BEZIER*(fHeight/6.0f - fHeight/10.0f)), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15.0f - PWL_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 + PWL_BEZIER*fWidth/15.0f, crBBox.top - fHeight/10.0f), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.top - fHeight/6 + PWL_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 + PWL_BEZIER*fHeight/15.0f), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth*2/15.0f + PWL_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 + PWL_BEZIER*fHeight*2/15.0f), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth*5/15.0f - PWL_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 + PWL_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 + PWL_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 - PWL_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 - PWL_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 CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
-{
- FX_FLOAT fWidth = crBBox.right - crBBox.left;
- FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
- //FX_FLOAT fcatercorner = (FX_FLOAT)sqrt(fWidth*fWidth + fHeight*fHeight);
- 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 CPDF_Rect& 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 + PWL_BEZIER*(fHeight/60.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_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 + PWL_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 + PWL_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 + PWL_BEZIER*fHeight*29/60.0f), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_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 - PWL_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 + PWL_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 + PWL_BEZIER*fHeight*0.23f), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f - PWL_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 + PWL_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 + PWL_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 + PWL_BEZIER*fHeight*0.13f), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f + PWL_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 - PWL_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 + PWL_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 + PWL_BEZIER*fHeight*0.055f), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f - PWL_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 + PWL_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 + PWL_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 - PWL_BEZIER*fHeight*0.055f), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f + PWL_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 - PWL_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 - PWL_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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
-{
- FX_FLOAT fLongRadius = (crBBox.top - crBBox.bottom)/(1+(FX_FLOAT)cos(PWL_PI/5.0f));
- fLongRadius = fLongRadius * 0.7f;
- FX_FLOAT fShortRadius = fLongRadius * 0.55f;
- CPDF_Point ptCenter = CPDF_Point((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 = PWL_PI/10.0f;
-
- for (FX_INT32 i=0; i<5; i++)
- {
- px1[i] = ptCenter.x + fLongRadius * (FX_FLOAT)cos(fAngel);
- py1[i] = ptCenter.y + fLongRadius * (FX_FLOAT)sin(fAngel);
-
- fAngel += PWL_PI * 2 / 5.0f;
- }
-
- fAngel = PWL_PI/5.0f + PWL_PI/10.0f;
-
- for (FX_INT32 j=0; j<5; j++)
- {
- px2[j] = ptCenter.x + fShortRadius * (FX_FLOAT)cos(fAngel);
- py2[j] = ptCenter.y + fShortRadius * (FX_FLOAT)sin(fAngel);
-
- fAngel += PWL_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(FX_INT32 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
-{
- FX_FLOAT fOutWidth = crBBox.right - crBBox.left;
- FX_FLOAT fOutHeight = crBBox.top - crBBox.bottom;
-
- CPDF_Rect 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 - PWL_BEZIER * fHeight * 0.4f), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.45f - PWL_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 - PWL_BEZIER * fHeight * 0.7f), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.75f - PWL_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 + PWL_BEZIER * fWidth*0.60f, crInBox.top - fHeight*0.55f), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f, crInBox.top - PWL_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 - PWL_BEZIER * fHeight * 0.85f), PWLPT_BEZIERTO),
- CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.90f - PWL_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),
-
- /*
- CPWL_PathData(CPWL_Point(crBBox.left, crBBox.top), PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.right, crBBox.top), PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right, crBBox.bottom), PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left, crBBox.bottom), PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left, crBBox.top), PWLPT_LINETO),
-
- CPWL_PathData(CPWL_Point(crBBox.left+fOutWidth*0.04f, crBBox.top-fOutHeight*0.04f), PWLPT_MOVETO),
- CPWL_PathData(CPWL_Point(crBBox.right-fOutWidth*0.04f, crBBox.top-fOutHeight*0.04f), PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.right-fOutWidth*0.04f, crBBox.bottom+fOutHeight*0.04f), PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left+fOutWidth*0.04f, crBBox.bottom+fOutHeight*0.04f), PWLPT_LINETO),
- CPWL_PathData(CPWL_Point(crBBox.left+fOutWidth*0.04f, crBBox.top-fOutHeight*0.04f), PWLPT_LINETO),
- */
- };
-
- if(type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 23);
- else
- GetPathDataFromArray(path, PathArray, 23);
-}
-
-void CPWL_Color::ConvertColorType(FX_INT32 nColorType)
-{
- switch (this->nColorType)
- {
- case COLORTYPE_TRANSPARENT:
- break;
- case COLORTYPE_GRAY:
- switch (nColorType)
- {
- case COLORTYPE_RGB:
- CPWL_Utils::ConvertGRAY2RGB(this->fColor1, this->fColor1, this->fColor2, this->fColor3);
- break;
- case COLORTYPE_CMYK:
- CPWL_Utils::ConvertGRAY2CMYK(this->fColor1, this->fColor1, this->fColor2, this->fColor3, this->fColor4);
- break;
- }
- break;
- case COLORTYPE_RGB:
- switch (nColorType)
- {
- case COLORTYPE_GRAY:
- CPWL_Utils::ConvertRGB2GRAY(this->fColor1, this->fColor2, this->fColor3, this->fColor1);
- break;
- case COLORTYPE_CMYK:
- CPWL_Utils::ConvertRGB2CMYK(this->fColor1, this->fColor2, this->fColor3, this->fColor1, this->fColor2, this->fColor3, this->fColor4);
- break;
- }
- break;
- case COLORTYPE_CMYK:
- switch (nColorType)
- {
- case COLORTYPE_GRAY:
- CPWL_Utils::ConvertCMYK2GRAY(this->fColor1, this->fColor2, this->fColor3, this->fColor4, this->fColor1);
- break;
- case COLORTYPE_RGB:
- CPWL_Utils::ConvertCMYK2RGB(this->fColor1, this->fColor2, this->fColor3, this->fColor4, this->fColor1, this->fColor2, this->fColor3);
- break;
- }
- break;
- }
- this->nColorType = nColorType;
-}
-
-
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_Utils.h"
+#include "../../include/pdfwindow/PWL_Icon.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_Utils ------------------------------ */
+
+CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData, FX_INT32 nCount)
+{
+ CFX_ByteTextBuf csAP;
+
+ for (FX_INT32 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, FX_INT32 nCount)
+{
+ path.SetPointCount(nCount);
+
+ for (FX_INT32 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;
+ }
+ }
+}
+
+
+CPDF_Rect CPWL_Utils::MaxRect(const CPDF_Rect & rect1,const CPDF_Rect & rect2)
+{
+ CPDF_Rect 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;
+}
+
+CPDF_Rect CPWL_Utils::OffsetRect(const CPDF_Rect & rect,FX_FLOAT x,FX_FLOAT y)
+{
+ return CPDF_Rect(rect.left + x,rect.bottom + y,
+ rect.right + x,rect.top + y);
+}
+
+FX_BOOL CPWL_Utils::ContainsRect(const CPDF_Rect& rcParent, const CPDF_Rect& rcChild)
+{
+ return rcChild.left >= rcParent.left && rcChild.bottom >= rcParent.bottom &&
+ rcChild.right <= rcParent.right && rcChild.top <= rcParent.top;
+}
+
+FX_BOOL CPWL_Utils::IntersectRect(const CPDF_Rect& rect1, const CPDF_Rect& 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;
+}
+
+CPDF_Point CPWL_Utils::OffsetPoint(const CPDF_Point& point,FX_FLOAT x,FX_FLOAT y)
+{
+ return CPDF_Point(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 CPDF_Rect & crBBox)
+{
+ CFX_ByteTextBuf csAP;
+
+ FX_FLOAT fWidth = crBBox.right - crBBox.left;
+ FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
+
+ const FX_INT32 num = 8;
+
+ CPWL_Point pts[num*3] =
+ {
+ //1
+ CPWL_Point(0.28f, 0.52f),
+ CPWL_Point(0.27f, 0.48f),
+ CPWL_Point(0.29f, 0.40f),
+
+ //2
+ CPWL_Point(0.30f, 0.33f),
+ CPWL_Point(0.31f, 0.29f),
+ CPWL_Point(0.31f, 0.28f),
+
+ //3
+ CPWL_Point(0.39f, 0.28f),
+ CPWL_Point(0.49f, 0.29f),
+ CPWL_Point(0.77f, 0.67f),
+
+ //4
+ CPWL_Point(0.76f, 0.68f),
+ CPWL_Point(0.78f, 0.69f),
+ CPWL_Point(0.76f, 0.75f),
+
+ //5
+ CPWL_Point(0.76f, 0.75f),
+ CPWL_Point(0.73f, 0.80f),
+ CPWL_Point(0.68f, 0.75f),
+
+ //6
+ CPWL_Point(0.68f, 0.74f),
+ CPWL_Point(0.68f, 0.74f),
+ CPWL_Point(0.44f, 0.47f),
+
+ //7
+ CPWL_Point(0.43f, 0.47f),
+ CPWL_Point(0.40f, 0.47f),
+ CPWL_Point(0.41f, 0.58f),
+
+ //8
+ CPWL_Point(0.40f, 0.60f),
+ CPWL_Point(0.28f, 0.66f),
+ CPWL_Point(0.30f, 0.56f)
+ };
+
+ for (FX_INT32 j=0; j<num*3; j++)
+ {
+ pts[j].x *= fWidth;
+ pts[j].x += crBBox.left;
+
+ pts[j].y *= fHeight;
+ pts[j].y += crBBox.bottom;
+ }
+
+ csAP << pts[0].x << " " << pts[0].y << " m\n";
+
+ for (FX_INT32 i=0; i<num; i++)
+ {
+ FX_INT32 nCur = i*3;
+ FX_INT32 n1 = i*3 + 1;
+ FX_INT32 n2 = i*3 + 2;
+ FX_INT32 nNext = (i < num-1 ? (i+1)*3 : 0);
+
+ FX_FLOAT px1 = pts[n1].x - pts[nCur].x;
+ FX_FLOAT py1 = pts[n1].y - pts[nCur].y;
+ FX_FLOAT px2 = pts[n2].x - pts[nNext].x;
+ FX_FLOAT py2 = pts[n2].y - pts[nNext].y;
+
+ csAP << pts[nCur].x + px1 * PWL_BEZIER << " " << pts[nCur].y + py1 * PWL_BEZIER << " "
+ << pts[nNext].x + px2 * PWL_BEZIER << " " << pts[nNext].y + py2 * PWL_BEZIER << " "
+ << pts[nNext].x << " " << pts[nNext].y << " c\n";
+ }
+
+ return csAP.GetByteString();
+}
+
+CFX_ByteString CPWL_Utils::GetAP_Circle(const CPDF_Rect & crBBox)
+{
+ CFX_ByteTextBuf csAP;
+
+ FX_FLOAT fWidth = crBBox.right - crBBox.left;
+ FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
+
+ CPDF_Point pt1(crBBox.left,crBBox.bottom + fHeight / 2);
+ CPDF_Point pt2(crBBox.left + fWidth / 2,crBBox.top);
+ CPDF_Point pt3(crBBox.right,crBBox.bottom + fHeight / 2);
+ CPDF_Point 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 * PWL_BEZIER << " "
+ << pt2.x - px * PWL_BEZIER << " " << pt2.y << " "
+ << pt2.x << " " << pt2.y << " c\n";
+
+ px = pt3.x - pt2.x;
+ py = pt2.y - pt3.y;
+
+ csAP << pt2.x + px * PWL_BEZIER << " " << pt2.y << " "
+ << pt3.x << " " << pt3.y + py * PWL_BEZIER << " "
+ << pt3.x << " " << pt3.y << " c\n";
+
+ px = pt3.x - pt4.x;
+ py = pt3.y - pt4.y;
+
+ csAP << pt3.x << " " << pt3.y - py * PWL_BEZIER << " "
+ << pt4.x + px * PWL_BEZIER << " " << pt4.y << " "
+ << pt4.x << " " << pt4.y << " c\n";
+
+ px = pt4.x - pt1.x;
+ py = pt1.y - pt4.y;
+
+ csAP << pt4.x - px * PWL_BEZIER << " " << pt4.y << " "
+ << pt1.x << " " << pt1.y - py * PWL_BEZIER << " "
+ << pt1.x << " " << pt1.y << " c\n";
+
+ return csAP.GetByteString();
+}
+
+CFX_ByteString CPWL_Utils::GetAP_Cross(const CPDF_Rect & 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 CPDF_Rect & crBBox)
+{
+ CFX_ByteTextBuf csAP;
+
+ FX_FLOAT fWidth = crBBox.right - crBBox.left;
+ FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
+
+ CPDF_Point pt1(crBBox.left,crBBox.bottom + fHeight / 2);
+ CPDF_Point pt2(crBBox.left + fWidth / 2,crBBox.top);
+ CPDF_Point pt3(crBBox.right,crBBox.bottom + fHeight / 2);
+ CPDF_Point 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 CPDF_Rect & 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 CPDF_Rect & crBBox)
+{
+ CFX_ByteTextBuf csAP;
+
+ FX_FLOAT fRadius = (crBBox.top - crBBox.bottom)/(1+(FX_FLOAT)cos(PWL_PI/5.0f));
+ CPDF_Point ptCenter = CPDF_Point((crBBox.left + crBBox.right) / 2.0f,(crBBox.top + crBBox.bottom) / 2.0f);
+
+ FX_FLOAT px[5],py[5];
+
+ FX_FLOAT fAngel = PWL_PI/10.0f;
+
+ for (FX_INT32 i=0; i<5; i++)
+ {
+ px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel);
+ py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel);
+
+ fAngel += PWL_PI * 2 / 5.0f;
+ }
+
+ csAP << px[0] << " " << py[0] << " m\n";
+
+ FX_INT32 nNext = 0;
+ for (FX_INT32 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 CPDF_Rect & crBBox,FX_FLOAT fRotate)
+{
+ CFX_ByteTextBuf csAP;
+
+ FX_FLOAT fWidth = crBBox.right - crBBox.left;
+ FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
+
+ CPDF_Point pt1(-fWidth/2,0);
+ CPDF_Point pt2(0,fHeight/2);
+ CPDF_Point 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 * PWL_BEZIER << " "
+ << pt2.x - px * PWL_BEZIER << " " << pt2.y << " "
+ << pt2.x << " " << pt2.y << " c\n";
+
+ px = pt3.x - pt2.x;
+ py = pt2.y - pt3.y;
+
+ csAP << pt2.x + px * PWL_BEZIER << " " << pt2.y << " "
+ << pt3.x << " " << pt3.y + py * PWL_BEZIER << " "
+ << pt3.x << " " << pt3.y << " c\n";
+
+ return csAP.GetByteString();
+}
+
+
+CPDF_Rect CPWL_Utils::InflateRect(const CPDF_Rect & rcRect, FX_FLOAT fSize)
+{
+ if (rcRect.IsEmpty()) return rcRect;
+
+ CPDF_Rect rcNew(rcRect.left - fSize,
+ rcRect.bottom - fSize,
+ rcRect.right + fSize,
+ rcRect.top + fSize);
+ rcNew.Normalize();
+ return rcNew;
+}
+
+CPDF_Rect CPWL_Utils::DeflateRect(const CPDF_Rect & rcRect, FX_FLOAT fSize)
+{
+ if (rcRect.IsEmpty()) return rcRect;
+
+ CPDF_Rect rcNew(rcRect.left + fSize,
+ rcRect.bottom + fSize,
+ rcRect.right - fSize,
+ rcRect.top - fSize);
+ rcNew.Normalize();
+ return rcNew;
+}
+
+CPDF_Rect CPWL_Utils::ScaleRect(const CPDF_Rect & rcRect,FX_FLOAT fScale)
+{
+ FX_FLOAT fHalfWidth = (rcRect.right - rcRect.left) / 2.0f;
+ FX_FLOAT fHalfHeight = (rcRect.top - rcRect.bottom) / 2.0f;
+
+ CPDF_Point ptCenter = CPDF_Point((rcRect.left + rcRect.right) / 2,(rcRect.top + rcRect.bottom) / 2);
+
+ return CPDF_Rect(ptCenter.x - fHalfWidth * fScale,
+ ptCenter.y - fHalfHeight * fScale,
+ ptCenter.x + fHalfWidth * fScale,
+ ptCenter.y + fHalfHeight * fScale);
+}
+
+CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CPDF_Rect & 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 CPDF_Rect & 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();
+}
+
+CPDF_Rect CPWL_Utils::GetCenterSquare(const CPDF_Rect & 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 CPDF_Rect(fCenterX - fRadius,fCenterY - fRadius,fCenterX + fRadius,fCenterY + fRadius);
+}
+
+CFX_ByteString CPWL_Utils::GetEditAppStream(IFX_Edit* pEdit, const CPDF_Point & 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 CPDF_Point & 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;
+ FX_INT32 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 CPDF_Point & 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 CPDF_Point & ptOffset,
+ const CPVT_WordRange * pRange)
+{
+ ASSERT(pEdit != NULL);
+ ASSERT(pSpellCheck != NULL);
+
+ 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 CPDF_Rect & rcBBox,IFX_Edit_FontMap * pFontMap,
+ const CFX_WideString & sText, FX_INT32 nAlignmentH, FX_INT32 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);
+
+ CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit, CPDF_Point(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 CPDF_Rect & rcBBox,
+ IFX_Edit_FontMap * pFontMap,
+ CPDF_Stream * pIconStream,
+ CPDF_IconFit & IconFit,
+ const CFX_WideString & sLabel,
+ const CPWL_Color & crText,
+ FX_FLOAT fFontSize,
+ FX_INT32 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);
+
+ CPDF_Rect rcLabelContent = pEdit->GetContentRect();
+
+ CPWL_Icon Icon;
+ PWL_CREATEPARAM cp;
+ cp.dwFlags = PWS_VISIBLE;
+ Icon.Create(cp);
+ Icon.SetIconFit(&IconFit);
+ Icon.SetPDFStream(pIconStream);
+
+ CPDF_Rect rcLabel = CPDF_Rect(0,0,0,0);
+ CPDF_Rect rcIcon = CPDF_Rect(0,0,0,0);
+ FX_FLOAT fWidth = 0.0f;
+ FX_FLOAT fHeight = 0.0f;
+
+ switch (nLayOut)
+ {
+ case PPBL_LABEL:
+ rcLabel = rcBBox;
+ rcIcon = CPDF_Rect(0,0,0,0);
+ break;
+ case PPBL_ICON:
+ rcIcon = rcBBox;
+ rcLabel = CPDF_Rect(0,0,0,0);
+ break;
+ case PPBL_ICONTOPLABELBOTTOM:
+
+ if (pIconStream)
+ {
+ if (IsFloatZero(fFontSize))
+ {
+ fHeight = rcBBox.top - rcBBox.bottom;
+ rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcBBox.bottom + fHeight * fAutoFontScale);
+ rcIcon = CPDF_Rect(rcBBox.left,rcLabel.top,rcBBox.right,rcBBox.top);
+ }
+ else
+ {
+ fHeight = rcLabelContent.Height();
+
+ if (rcBBox.bottom + fHeight > rcBBox.top)
+ {
+ rcIcon = CPDF_Rect(0,0,0,0);
+ rcLabel = rcBBox;
+ }
+ else
+ {
+ rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcBBox.bottom + fHeight);
+ rcIcon = CPDF_Rect(rcBBox.left,rcLabel.top,rcBBox.right,rcBBox.top);
+ }
+ }
+ }
+ else
+ {
+ rcLabel = rcBBox;
+ rcIcon = CPDF_Rect(0,0,0,0);
+ }
+
+ break;
+ case PPBL_LABELTOPICONBOTTOM:
+
+ if (pIconStream)
+ {
+ if (IsFloatZero(fFontSize))
+ {
+ fHeight = rcBBox.top - rcBBox.bottom;
+ rcLabel = CPDF_Rect(rcBBox.left,rcBBox.top - fHeight * fAutoFontScale ,rcBBox.right,rcBBox.top);
+ rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcLabel.bottom);
+ }
+ else
+ {
+ fHeight = rcLabelContent.Height();
+
+ if (rcBBox.bottom + fHeight > rcBBox.top)
+ {
+ rcIcon = CPDF_Rect(0,0,0,0);
+ rcLabel = rcBBox;
+ }
+ else
+ {
+ rcLabel = CPDF_Rect(rcBBox.left,rcBBox.top - fHeight,rcBBox.right,rcBBox.top);
+ rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcLabel.bottom);
+ }
+ }
+ }
+ else
+ {
+ rcLabel = rcBBox;
+ rcIcon = CPDF_Rect(0,0,0,0);
+ }
+
+ break;
+ case PPBL_ICONLEFTLABELRIGHT:
+
+ if (pIconStream)
+ {
+ if (IsFloatZero(fFontSize))
+ {
+ fWidth = rcBBox.right - rcBBox.left;
+ rcLabel = CPDF_Rect(rcBBox.right - fWidth * fAutoFontScale,rcBBox.bottom,rcBBox.right,rcBBox.top);
+ rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcLabel.left,rcBBox.top);
+
+ if (rcLabelContent.Width() < fWidth * fAutoFontScale)
+ {
+ }
+ else
+ {
+ if (rcLabelContent.Width() < fWidth)
+ {
+ rcLabel = CPDF_Rect(rcBBox.right - rcLabelContent.Width(),rcBBox.bottom,rcBBox.right,rcBBox.top);
+ rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcLabel.left,rcBBox.top);
+ }
+ else
+ {
+ rcLabel = rcBBox;
+ rcIcon = CPDF_Rect(0,0,0,0);
+ }
+ }
+ }
+ else
+ {
+ fWidth = rcLabelContent.Width();
+
+ if (rcBBox.left + fWidth > rcBBox.right)
+ {
+ rcLabel = rcBBox;
+ rcIcon = CPDF_Rect(0,0,0,0);
+ }
+ else
+ {
+ rcLabel = CPDF_Rect(rcBBox.right - fWidth,rcBBox.bottom,rcBBox.right,rcBBox.top);
+ rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcLabel.left,rcBBox.top);
+ }
+ }
+ }
+ else
+ {
+ rcLabel = rcBBox;
+ rcIcon = CPDF_Rect(0,0,0,0);
+ }
+
+ break;
+ case PPBL_LABELLEFTICONRIGHT:
+
+ if (pIconStream)
+ {
+ if (IsFloatZero(fFontSize))
+ {
+ fWidth = rcBBox.right - rcBBox.left;
+ rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.left + fWidth * fAutoFontScale,rcBBox.top);
+ rcIcon = CPDF_Rect(rcLabel.right,rcBBox.bottom,rcBBox.right,rcBBox.top);
+
+ if (rcLabelContent.Width() < fWidth * fAutoFontScale)
+ {
+ }
+ else
+ {
+ if (rcLabelContent.Width() < fWidth)
+ {
+ rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.left + rcLabelContent.Width(),rcBBox.top);
+ rcIcon = CPDF_Rect(rcLabel.right,rcBBox.bottom,rcBBox.right,rcBBox.top);
+ }
+ else
+ {
+ rcLabel = rcBBox;
+ rcIcon = CPDF_Rect(0,0,0,0);
+ }
+ }
+ }
+ else
+ {
+ fWidth = rcLabelContent.Width();
+
+ if (rcBBox.left + fWidth > rcBBox.right)
+ {
+ rcLabel = rcBBox;
+ rcIcon = CPDF_Rect(0,0,0,0);
+ }
+ else
+ {
+ rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.left + fWidth,rcBBox.top);
+ rcIcon = CPDF_Rect(rcLabel.right,rcBBox.bottom,rcBBox.right,rcBBox.top);
+ }
+ }
+ }
+ else
+ {
+ rcLabel = rcBBox;
+ rcIcon = CPDF_Rect(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,CPDF_Point(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 CPDF_Rect & rect, FX_FLOAT fWidth,
+ const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom,
+ FX_INT32 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 CPDF_Rect & rect, FX_FLOAT fWidth,
+ const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom,
+ FX_INT32 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),PWL_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),PWL_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),PWL_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),PWL_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 CPDF_Rect & 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 CPDF_Rect & 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 CPDF_Rect & 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 CPDF_Rect & 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 CPDF_Rect & 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 CPDF_Rect & 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 CPDF_Rect & rcBBox,
+ FX_INT32 nStyle,
+ const CPWL_Color & crText)
+{
+ CPDF_Rect 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 CPDF_Rect & rcBBox,
+ FX_INT32 nStyle,
+ const CPWL_Color & crText)
+{
+ CPDF_Rect 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 CPDF_Rect & 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";
+
+ CPDF_Point ptCenter = CPDF_Point((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 - FX_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 - FX_MIN(1.0f, dC + dK);
+ dG = 1.0f - FX_MIN(1.0f, dM + dK);
+ dB = 1.0f - FX_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 = FX_MIN(dC, FX_MIN(dM, dY));
+}
+
+void CPWL_Utils::PWLColorToARGB(const CPWL_Color& color, FX_INT32& 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, FX_INT32 nTransparancy)
+{
+ FX_INT32 nAlpha = nTransparancy;
+ FX_FLOAT dRed = 0;
+ FX_FLOAT dGreen = 0;
+ FX_FLOAT dBlue = 0;
+
+ PWLColorToARGB(color, nAlpha, dRed, dGreen, dBlue);
+
+ return ArgbEncode(nAlpha, (FX_INT32)(dRed*255), (FX_INT32)(dGreen*255), (FX_INT32)(dBlue*255));
+}
+
+void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect,
+ const FX_COLORREF & color)
+{
+ CFX_PathData path;
+ CPDF_Rect 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, CPDF_Matrix* pUser2Device,
+ const CPDF_Point* pPts, FX_INT32 nCount, const FX_COLORREF& color)
+{
+ CFX_PathData path;
+ path.SetPointCount(nCount);
+
+ path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_MOVETO);
+ for (FX_INT32 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, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect,
+ const FX_COLORREF & color, FX_FLOAT fWidth)
+{
+ CFX_PathData path;
+ CPDF_Rect 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, CPDF_Matrix* pUser2Device,
+ const CPDF_Point & ptMoveTo, const CPDF_Point & 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, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect,
+ const CPWL_Color & color, FX_INT32 nTransparancy)
+{
+ CPWL_Utils::DrawFillRect(pDevice,pUser2Device,rect,PWLColorToFXColor(color,nTransparancy));
+}
+
+void CPWL_Utils::DrawShadow(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
+ FX_BOOL bVertical, FX_BOOL bHorizontal, CPDF_Rect rect,
+ FX_INT32 nTransparancy, FX_INT32 nStartGray, FX_INT32 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)
+ {
+ FX_INT32 nGray = nStartGray + (FX_INT32)(fStepGray * (fy-rect.bottom));
+ CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, CPDF_Point(rect.left, fy),
+ CPDF_Point(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)
+ {
+ FX_INT32 nGray = nStartGray + (FX_INT32)(fStepGray * (fx-rect.left));
+ CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, CPDF_Point(fx, rect.bottom),
+ CPDF_Point(fx, rect.top), ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f);
+ }
+ }
+}
+
+void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
+ const CPDF_Rect & rect, FX_FLOAT fWidth,
+ const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom,
+ FX_INT32 nStyle, const CPWL_Dash & dash, FX_INT32 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;
+ FX_INT32 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, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit,
+ const CPDF_Rect& rcClip, const CPDF_Point& 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())
+ {
+ CPDF_Rect rcTemp = rcClip;
+ pUser2Device->TransformRect(rcTemp);
+ FX_RECT rcDevClip;
+ rcDevClip.left = (FX_INT32)rcTemp.left;
+ rcDevClip.right = (FX_INT32)rcTemp.right;
+ rcDevClip.top = (FX_INT32)rcTemp.top;
+ rcDevClip.bottom = (FX_INT32)rcTemp.bottom;
+ pDevice->SetClip_Rect(&rcDevClip);
+ }
+
+ 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(FX_INT32 nType, const CPDF_Rect& 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, CPDF_Matrix* pUser2Device,
+ FX_INT32 nType, const CPDF_Rect & rect, const CPWL_Color& crFill, const CPWL_Color& crStroke, const FX_INT32 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 CPDF_Rect& 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 + PWL_BEZIER*(fWidth / 7.0f - fWidth / 15.0f),
+ crBBox.bottom + fHeight * 2 / 5.0f + PWL_BEZIER*(fHeight * 2 / 7.0f - fHeight * 2 / 5.0f)), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 4.5f + PWL_BEZIER*(fWidth / 5.0f - fWidth / 4.5f),
+ crBBox.bottom + fHeight / 16.0f + PWL_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 + PWL_BEZIER*(fWidth / 4.4f - fWidth / 4.5f),
+ crBBox.bottom + fHeight / 16.0f - PWL_BEZIER*fHeight / 16.0f), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f + PWL_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 + PWL_BEZIER*fWidth*(1/7.0f + 2/15.0f),
+ crBBox.bottom + PWL_BEZIER*fHeight * 4 / 5.0f), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 14 / 15.0f + PWL_BEZIER*fWidth*(1/7.0f - 7/15.0f),
+ crBBox.bottom + fHeight * 15/16.0f + PWL_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 + PWL_BEZIER*(fWidth * 7 / 15.0f - fWidth * 14 / 15.0f),
+ crBBox.bottom + fHeight * 15 / 16.0f + PWL_BEZIER*(fHeight * 8 / 7.0f - fHeight * 15 / 16.0f)), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.6f + PWL_BEZIER*(fWidth / 3.4f - fWidth / 3.6f),
+ crBBox.bottom + fHeight / 3.5f + PWL_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 + PWL_BEZIER*(fHeight / 4.0f - fHeight / 3.5f)), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f + PWL_BEZIER*(fWidth / 3.5f - fWidth / 15.0f),
+ crBBox.bottom + fHeight * 2 / 5.0f + PWL_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 CPDF_Rect& 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 + PWL_BEZIER*(fHeight*14/15.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_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 + PWL_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 + PWL_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 - PWL_BEZIER*(fHeight/2.0f - fHeight/15.0f)), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_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 - PWL_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 - PWL_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 + PWL_BEZIER*(fHeight*4/5.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_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 + PWL_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 + PWL_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 - PWL_BEZIER*(fHeight*4/5.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_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 - PWL_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 - PWL_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 CPDF_Rect& 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 + PWL_BEZIER*(fHeight/6.0f - fHeight/10.0f)), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15.0f - PWL_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 + PWL_BEZIER*fWidth/15.0f, crBBox.top - fHeight/10.0f), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.top - fHeight/6 + PWL_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 + PWL_BEZIER*fHeight/15.0f), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.right - fWidth*2/15.0f + PWL_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 + PWL_BEZIER*fHeight*2/15.0f), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth*5/15.0f - PWL_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 + PWL_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 + PWL_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 - PWL_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 - PWL_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 CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
+{
+ FX_FLOAT fWidth = crBBox.right - crBBox.left;
+ FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
+ //FX_FLOAT fcatercorner = (FX_FLOAT)sqrt(fWidth*fWidth + fHeight*fHeight);
+ 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 CPDF_Rect& 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 + PWL_BEZIER*(fHeight/60.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_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 + PWL_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 + PWL_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 + PWL_BEZIER*fHeight*29/60.0f), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_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 - PWL_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 + PWL_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 + PWL_BEZIER*fHeight*0.23f), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f - PWL_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 + PWL_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 + PWL_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 + PWL_BEZIER*fHeight*0.13f), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f + PWL_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 - PWL_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 + PWL_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 + PWL_BEZIER*fHeight*0.055f), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f - PWL_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 + PWL_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 + PWL_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 - PWL_BEZIER*fHeight*0.055f), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f + PWL_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 - PWL_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 - PWL_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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
+{
+ FX_FLOAT fLongRadius = (crBBox.top - crBBox.bottom)/(1+(FX_FLOAT)cos(PWL_PI/5.0f));
+ fLongRadius = fLongRadius * 0.7f;
+ FX_FLOAT fShortRadius = fLongRadius * 0.55f;
+ CPDF_Point ptCenter = CPDF_Point((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 = PWL_PI/10.0f;
+
+ for (FX_INT32 i=0; i<5; i++)
+ {
+ px1[i] = ptCenter.x + fLongRadius * (FX_FLOAT)cos(fAngel);
+ py1[i] = ptCenter.y + fLongRadius * (FX_FLOAT)sin(fAngel);
+
+ fAngel += PWL_PI * 2 / 5.0f;
+ }
+
+ fAngel = PWL_PI/5.0f + PWL_PI/10.0f;
+
+ for (FX_INT32 j=0; j<5; j++)
+ {
+ px2[j] = ptCenter.x + fShortRadius * (FX_FLOAT)cos(fAngel);
+ py2[j] = ptCenter.y + fShortRadius * (FX_FLOAT)sin(fAngel);
+
+ fAngel += PWL_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(FX_INT32 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& 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 CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
+{
+ FX_FLOAT fOutWidth = crBBox.right - crBBox.left;
+ FX_FLOAT fOutHeight = crBBox.top - crBBox.bottom;
+
+ CPDF_Rect 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 - PWL_BEZIER * fHeight * 0.4f), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.45f - PWL_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 - PWL_BEZIER * fHeight * 0.7f), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.75f - PWL_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 + PWL_BEZIER * fWidth*0.60f, crInBox.top - fHeight*0.55f), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f, crInBox.top - PWL_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 - PWL_BEZIER * fHeight * 0.85f), PWLPT_BEZIERTO),
+ CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.90f - PWL_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),
+
+ /*
+ CPWL_PathData(CPWL_Point(crBBox.left, crBBox.top), PWLPT_MOVETO),
+ CPWL_PathData(CPWL_Point(crBBox.right, crBBox.top), PWLPT_LINETO),
+ CPWL_PathData(CPWL_Point(crBBox.right, crBBox.bottom), PWLPT_LINETO),
+ CPWL_PathData(CPWL_Point(crBBox.left, crBBox.bottom), PWLPT_LINETO),
+ CPWL_PathData(CPWL_Point(crBBox.left, crBBox.top), PWLPT_LINETO),
+
+ CPWL_PathData(CPWL_Point(crBBox.left+fOutWidth*0.04f, crBBox.top-fOutHeight*0.04f), PWLPT_MOVETO),
+ CPWL_PathData(CPWL_Point(crBBox.right-fOutWidth*0.04f, crBBox.top-fOutHeight*0.04f), PWLPT_LINETO),
+ CPWL_PathData(CPWL_Point(crBBox.right-fOutWidth*0.04f, crBBox.bottom+fOutHeight*0.04f), PWLPT_LINETO),
+ CPWL_PathData(CPWL_Point(crBBox.left+fOutWidth*0.04f, crBBox.bottom+fOutHeight*0.04f), PWLPT_LINETO),
+ CPWL_PathData(CPWL_Point(crBBox.left+fOutWidth*0.04f, crBBox.top-fOutHeight*0.04f), PWLPT_LINETO),
+ */
+ };
+
+ if(type == PWLPT_STREAM)
+ sPathData = GetAppStreamFromArray(PathArray, 23);
+ else
+ GetPathDataFromArray(path, PathArray, 23);
+}
+
+void CPWL_Color::ConvertColorType(FX_INT32 nColorType)
+{
+ switch (this->nColorType)
+ {
+ case COLORTYPE_TRANSPARENT:
+ break;
+ case COLORTYPE_GRAY:
+ switch (nColorType)
+ {
+ case COLORTYPE_RGB:
+ CPWL_Utils::ConvertGRAY2RGB(this->fColor1, this->fColor1, this->fColor2, this->fColor3);
+ break;
+ case COLORTYPE_CMYK:
+ CPWL_Utils::ConvertGRAY2CMYK(this->fColor1, this->fColor1, this->fColor2, this->fColor3, this->fColor4);
+ break;
+ }
+ break;
+ case COLORTYPE_RGB:
+ switch (nColorType)
+ {
+ case COLORTYPE_GRAY:
+ CPWL_Utils::ConvertRGB2GRAY(this->fColor1, this->fColor2, this->fColor3, this->fColor1);
+ break;
+ case COLORTYPE_CMYK:
+ CPWL_Utils::ConvertRGB2CMYK(this->fColor1, this->fColor2, this->fColor3, this->fColor1, this->fColor2, this->fColor3, this->fColor4);
+ break;
+ }
+ break;
+ case COLORTYPE_CMYK:
+ switch (nColorType)
+ {
+ case COLORTYPE_GRAY:
+ CPWL_Utils::ConvertCMYK2GRAY(this->fColor1, this->fColor2, this->fColor3, this->fColor4, this->fColor1);
+ break;
+ case COLORTYPE_RGB:
+ CPWL_Utils::ConvertCMYK2RGB(this->fColor1, this->fColor2, this->fColor3, this->fColor4, this->fColor1, this->fColor2, this->fColor3);
+ break;
+ }
+ break;
+ }
+ this->nColorType = nColorType;
+}
+
+
diff --git a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
index 035ffbb..9bb784c 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
@@ -1,1342 +1,1342 @@
-// 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 "../../include/pdfwindow/PDFWindow.h"
-#include "../../include/pdfwindow/PWL_Wnd.h"
-#include "../../include/pdfwindow/PWL_Utils.h"
-#include "../../include/pdfwindow/PWL_ScrollBar.h"
-
-/* -------------------------- CPWL_Timer -------------------------- */
-
-static CFX_MapPtrTemplate<FX_INT32, CPWL_Timer*> g_TimeMap;
-
-CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemHandler) :
- m_pAttached(pAttached),
- m_nTimerID(0),
- m_pSystemHandler(pSystemHandler)
-{
- ASSERT(m_pAttached != NULL);
- ASSERT(m_pSystemHandler != NULL);
-}
-
-CPWL_Timer::~CPWL_Timer()
-{
- KillPWLTimer();
-}
-
-FX_INT32 CPWL_Timer::SetPWLTimer(FX_INT32 nElapse)
-{
- if (m_nTimerID != 0) KillPWLTimer();
- m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc);
- g_TimeMap.SetAt(m_nTimerID, this);
- return m_nTimerID;
-}
-
-void CPWL_Timer::KillPWLTimer()
-{
- if (m_nTimerID != 0)
- {
- m_pSystemHandler->KillTimer(m_nTimerID);
- g_TimeMap.RemoveKey(m_nTimerID);
- m_nTimerID = 0;
- }
-}
-
-void CPWL_Timer::TimerProc(FX_INT32 idEvent)
-{
- CPWL_Timer* pTimer = NULL;
- if (g_TimeMap.Lookup(idEvent, pTimer))
- {
- if (pTimer)
- {
- if (pTimer->m_pAttached)
- pTimer->m_pAttached->TimerProc();
- }
- }
-}
-
-/* -------------------------- CPWL_TimerHandler -------------------------- */
-
-CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL)
-{
-}
-
-CPWL_TimerHandler::~CPWL_TimerHandler()
-{
- if (m_pTimer) delete m_pTimer;
-}
-
-void CPWL_TimerHandler::BeginTimer(FX_INT32 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()
-{
-}
-
-/* --------------------------- CPWL_MsgControl ---------------------------- */
-
-class CPWL_MsgControl
-{
- friend class CPWL_Wnd;
-
-public:
- CPWL_MsgControl(CPWL_Wnd * pWnd)
- {
-// PWL_TRACE("new CPWL_MsgControl\n");
- m_pCreatedWnd = pWnd;
- Default();
- }
-
- ~CPWL_MsgControl()
- {
-// PWL_TRACE("~CPWL_MsgControl\n");
- 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( FX_INT32 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( FX_INT32 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::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 = CPDF_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::Destroy()
-{
- KillFocus();
-
- OnDestroy();
-
- if (m_bCreated)
- {
- for (FX_INT32 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 CPDF_Rect & rcNew, FX_BOOL bReset,FX_BOOL bRefresh)
-{
- if (IsValid())
- {
- CPDF_Rect rcOld = this->GetWindowRect();
-
- m_rcWindow = rcNew;
- m_rcWindow.Normalize();
- //m_rcClip = CPWL_Utils::InflateRect(m_rcWindow,1.0f); //for special caret
-
- 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 CPDF_Rect & rcOld, const CPDF_Rect & rcNew)
-{
- CPDF_Rect rcUnion = rcOld;
- rcUnion.Union(rcNew);
-
- InvalidateRect(&rcUnion);
-
- /*
- CPDF_Rect SubArray[4];
-
- rcOld.Substract4(rcNew,SubArray);
- for (FX_INT32 i=0;i<4;i++)
- {
- if (SubArray[i].left == 0 &&
- SubArray[i].right == 0 &&
- SubArray[i].top == 0 &&
- SubArray[i].bottom == 0)continue;
-
- InvalidateRect(&CPWL_Utils::InflateRect(SubArray[i],2));
- }
-
- rcNew.Substract4(rcOld,SubArray);
- for (FX_INT32 j=0;j<4;j++)
- {
- if (SubArray[j].left == 0 &&
- SubArray[j].right == 0 &&
- SubArray[j].top == 0 &&
- SubArray[j].bottom == 0)continue;
-
- InvalidateRect(&CPWL_Utils::InflateRect(SubArray[j],2));
- }
- */
-}
-
-void CPWL_Wnd::GetAppearanceStream(CFX_ByteString & sAppStream)
-{
- if (IsValid())
- {
- CFX_ByteTextBuf sTextBuf;
- GetAppearanceStream(sTextBuf);
- sAppStream += sTextBuf.GetByteString();
- }
-}
-
-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)
-{
- CPDF_Rect rectWnd = GetWindowRect();
- if (!rectWnd.IsEmpty())
- {
- CFX_ByteTextBuf sThis;
-
- if (HasFlag(PWS_BACKGROUND))
- sThis << CPWL_Utils::GetRectFillAppStream(rectWnd,this->GetBackgroundColor());
-
- if (HasFlag(PWS_BORDER))
- sThis << CPWL_Utils::GetBorderAppStream(rectWnd,
- (FX_FLOAT)GetBorderWidth(),
- GetBorderColor(),
- this->GetBorderLeftTopColor(this->GetBorderStyle()),
- this->GetBorderRightBottomColor(this->GetBorderStyle()),
- this->GetBorderStyle(),
- this->GetBorderDash());
-
- sAppStream << sThis;
- }
-}
-
-void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf & sAppStream)
-{
- for (FX_INT32 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, CPDF_Matrix* pUser2Device)
-{
- if (IsValid() && IsVisible())
- {
- DrawThisAppearance(pDevice,pUser2Device);
- DrawChildAppearance(pDevice,pUser2Device);
- }
-}
-
-void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- CPDF_Rect rectWnd = GetWindowRect();
- if (!rectWnd.IsEmpty())
- {
- if (HasFlag(PWS_BACKGROUND))
- {
- CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rectWnd,(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
- CPWL_Utils::DrawFillRect(pDevice,pUser2Device,rcClient,this->GetBackgroundColor(),GetTransparency());
- }
-
- if (HasFlag(PWS_BORDER))
- CPWL_Utils::DrawBorder(pDevice,
- pUser2Device,
- rectWnd,
- (FX_FLOAT)GetBorderWidth(),
- GetBorderColor(),
- this->GetBorderLeftTopColor(this->GetBorderStyle()),
- this->GetBorderRightBottomColor(this->GetBorderStyle()),
- this->GetBorderStyle(),
- this->GetBorderDash(),
- GetTransparency());
- }
-}
-
-void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
- {
- CPDF_Matrix mt = pChild->GetChildMatrix();
- if (mt.IsIdentity())
- {
- pChild->DrawAppearance(pDevice,pUser2Device);
- }
- else
- {
- mt.Concat(*pUser2Device);
- pChild->DrawAppearance(pDevice,&mt);
- }
- }
- }
-}
-
-void CPWL_Wnd::InvalidateRect(CPDF_Rect* pRect)
-{
- if (IsValid())
- {
- CPDF_Rect rcRefresh = pRect ? *pRect : GetWindowRect();
-
- if (!HasFlag(PWS_NOREFRESHCLIP))
- {
- CPDF_Rect 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 (FX_INT32 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 CPDF_Point & point, FX_DWORD nFlag)\
-{\
- if (IsValid() && IsVisible() && IsEnabled())\
- {\
- if (IsWndCaptureMouse(this))\
- {\
- for (FX_INT32 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 (FX_INT32 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 (this->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(OnRButtonDblClk)
-PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonDown)
-PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonUp)
-PWL_IMPLEMENT_MOUSE_METHOD(OnMouseMove)
-
-FX_BOOL CPWL_Wnd::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag)
-{
- if (IsValid() && IsVisible() && IsEnabled())
- {
- SetCursor();
- if (IsWndCaptureKeyboard(this))
- {
- for (FX_INT32 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 (FX_INT32 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, FX_INTPTR wParam, FX_INTPTR lParam)
-{
- switch (msg)
- {
- case PNM_ADDCHILD:
- this->AddChild(pWnd);
- break;
- case PNM_REMOVECHILD:
- this->RemoveChild(pWnd);
- break;
- default:
- break;
- }
-}
-
-FX_BOOL CPWL_Wnd::IsValid() const
-{
- return m_bCreated;
-}
-
-PWL_CREATEPARAM CPWL_Wnd::GetCreationParam() const
-{
- return m_sPrivateParam;
-}
-
-CPWL_Wnd* CPWL_Wnd::GetParentWindow() const
-{
- return m_sPrivateParam.pParentWnd;
-}
-
-CPDF_Rect CPWL_Wnd::GetOriginWindowRect() const
-{
- return m_sPrivateParam.rcRectWnd;
-}
-
-CPDF_Rect CPWL_Wnd::GetWindowRect() const
-{
- return m_rcWindow;
-}
-
-CPDF_Rect CPWL_Wnd::GetClientRect() const
-{
- CPDF_Rect rcWindow = GetWindowRect();
- CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
-
- if (CPWL_ScrollBar * pVSB = this->GetVScrollBar())
- rcClient.right -= pVSB->GetScrollBarWidth();
-
- rcClient.Normalize();
-
- if (rcWindow.Contains(rcClient))
- return rcClient;
- else
- return CPDF_Rect();
-}
-
-CPDF_Point CPWL_Wnd::GetCenterPoint() const
-{
- CPDF_Rect rcClient = GetClientRect();
-
- return CPDF_Point((rcClient.left + rcClient.right) * 0.5f,
- (rcClient.top + rcClient.bottom) * 0.5f);
-}
-
-CPDF_Rect CPWL_Wnd::GetClientCenterSquare() const
-{
- return CPWL_Utils::GetCenterSquare(GetClientRect());
-}
-
-CPDF_Rect CPWL_Wnd::GetWindowCenterSquare() const
-{
- return CPWL_Utils::GetCenterSquare(CPWL_Utils::DeflateRect(GetWindowRect(),0.1f));
-}
-
-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;
-}
-
-FX_INT32 CPWL_Wnd::GetBorderStyle() const
-{
- return m_sPrivateParam.nBorderStyle;
-}
-
-void CPWL_Wnd::SetBorderStyle(FX_INT32 nBorderStyle)
-{
- if (HasFlag(PWS_BORDER))
- m_sPrivateParam.nBorderStyle = nBorderStyle;
-}
-
-FX_INT32 CPWL_Wnd::GetBorderWidth() const
-{
- if (HasFlag(PWS_BORDER))
- return m_sPrivateParam.dwBorderWidth;
-
- return 0;
-}
-
-FX_INT32 CPWL_Wnd::GetInnerBorderWidth() const
-{
- /*
- switch (GetBorderStyle())
- {
- case PBS_BEVELED:
- case PBS_INSET:
- return GetBorderWidth() / 2;
- }
- */
- return 0;
-}
-
-void CPWL_Wnd::SetBorderWidth(FX_INT32 nBorderWidth)
-{
- if (HasFlag(PWS_BORDER))
- m_sPrivateParam.dwBorderWidth = nBorderWidth;
-}
-
-CPWL_Color CPWL_Wnd::GetBorderColor() const
-{
- if (HasFlag(PWS_BORDER))
- return m_sPrivateParam.sBorderColor;
-
- return CPWL_Color();
-}
-
-void CPWL_Wnd::SetBorderColor(const CPWL_Color & color)
-{
- if (HasFlag(PWS_BORDER))
- m_sPrivateParam.sBorderColor = color;
-}
-
-CPWL_Dash CPWL_Wnd::GetBorderDash() const
-{
- return m_sPrivateParam.sDash;
-}
-
-void* CPWL_Wnd::GetAttachedData() const
-{
- return m_sPrivateParam.pAttachedData;
-}
-
-void CPWL_Wnd::SetBorderDash(const CPWL_Dash & sDash)
-{
- if (HasFlag(PWS_BORDER))
- m_sPrivateParam.sDash = sDash;
-}
-
-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;
-
- if ((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 (FX_INT32 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 CPDF_Point & point) const
-{
- return IsValid() && IsVisible() && GetWindowRect().Contains(point.x,point.y);
-}
-
-FX_BOOL CPWL_Wnd::ClientHitTest(const CPDF_Point & 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();
- else
- return this;
-}
-
-void CPWL_Wnd::SetVisible(FX_BOOL bVisible)
-{
- if (IsValid())
- {
- for (FX_INT32 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 CPDF_Rect & rect)
-{
- m_rcClip = rect;
- m_rcClip.Normalize();
-}
-
-CPDF_Rect CPWL_Wnd::GetClipRect() const
-{
- return m_rcClip;
-}
-
-FX_BOOL CPWL_Wnd::IsReadOnly() const
-{
- return HasFlag(PWS_READONLY);
-}
-
-void CPWL_Wnd::RePosChildWnd()
-{
- CPDF_Rect rcContent = CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
-
- CPWL_ScrollBar * pVSB = this->GetVScrollBar();
-
- CPDF_Rect rcVScroll = CPDF_Rect(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())
- {
- FX_INT32 nCursorType = this->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;
-}
-
-CPDF_Rect CPWL_Wnd::GetFocusRect() const
-{
- return CPWL_Utils::InflateRect(this->GetWindowRect(),1);
-}
-
-FX_FLOAT CPWL_Wnd::GetFontSize() const
-{
- return this->m_sPrivateParam.fFontSize;
-}
-
-void CPWL_Wnd::SetFontSize(FX_FLOAT fFontSize)
-{
- this->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(FX_INT32 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(FX_INT32 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;
-}
-
-/* ----------------------------------------------------------------- */
-
-FX_INT32 CPWL_Wnd::GetTransparency()
-{
- return m_sPrivateParam.nTransparency;
-}
-
-void CPWL_Wnd::SetTransparency(FX_INT32 nTransparency)
-{
- for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- pChild->SetTransparency(nTransparency);
- }
- }
-
- m_sPrivateParam.nTransparency = nTransparency;
-}
-
-CPDF_Matrix CPWL_Wnd::GetWindowMatrix() const
-{
- CPDF_Matrix mt = this->GetChildToRoot();
-
- if (IPWL_Provider* pProvider = GetProvider())
- {
- mt.Concat(pProvider->GetWindowMatrix(GetAttachedData()));
- return mt;
- }
-
-/*
- if (CReader_App* pApp = CPWL_Module::GetReaderApp())
- if (CReader_Document* pDocument = pApp->GetCurrentDocument())
- if (CReader_DocView* pDocView = pDocument->GetCurrentDocView())
- {
- CPDF_Matrix mtPageView;
- pDocView->GetCurrentMatrix(mtPageView);
- mt.Concat(mtPageView);
- return mt;
- }
-
-*/
-
- return mt;
-}
-
-void CPWL_Wnd::PWLtoWnd(const CPDF_Point& point, FX_INT32& x, FX_INT32& y) const
-{
- CPDF_Matrix mt = GetWindowMatrix();
- CPDF_Point pt = point;
- mt.Transform(pt.x,pt.y);
- x = (FX_INT32)(pt.x+0.5);
- y = (FX_INT32)(pt.y+0.5);
-}
-
-FX_RECT CPWL_Wnd::PWLtoWnd(const CPDF_Rect & rect) const
-{
- CPDF_Rect rcTemp = rect;
- CPDF_Matrix mt = GetWindowMatrix();
- mt.TransformRect(rcTemp);
- return FX_RECT((FX_INT32)(rcTemp.left+0.5), (FX_INT32)(rcTemp.bottom+0.5), (FX_INT32)(rcTemp.right+0.5), (FX_INT32)(rcTemp.top+0.5));
-}
-
-FX_HWND CPWL_Wnd::GetAttachedHWnd() const
-{
- return m_sPrivateParam.hAttachedWnd;
-}
-
-CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const
-{
- CPDF_Matrix mt = GetChildMatrix();
- if (mt.IsIdentity())
- return point;
- else
- {
- CPDF_Point pt = point;
- mt.Transform(pt.x,pt.y);
- return pt;
- }
-}
-
-CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const
-{
- CPDF_Matrix mt = GetChildMatrix();
- if (mt.IsIdentity())
- return rect;
- else
- {
- CPDF_Rect rc = rect;
- mt.TransformRect(rc);
- return rc;
- }
-}
-
-CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const
-{
- CPDF_Matrix mt = GetChildMatrix();
- if (mt.IsIdentity())
- return point;
- else
- {
- mt.SetReverse(mt);
- CPDF_Point pt = point;
- mt.Transform(pt.x,pt.y);
- return pt;
- }
-}
-
-CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const
-{
- CPDF_Matrix mt = GetChildMatrix();
- if (mt.IsIdentity())
- return rect;
- else
- {
- mt.SetReverse(mt);
- CPDF_Rect rc = rect;
- mt.TransformRect(rc);
- return rc;
- }
-}
-
-CPDF_Matrix CPWL_Wnd::GetChildToRoot() const
-{
- CPDF_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;
-}
-
-CPDF_Matrix CPWL_Wnd::GetChildMatrix() const
-{
- if (HasFlag(PWS_CHILD))
- return m_sPrivateParam.mtChild;
-
- return CPDF_Matrix(1,0,0,1,0,0);
-}
-
-void CPWL_Wnd::SetChildMatrix(const CPDF_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 (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- pChild->EnableWindow(bEnable);
- }
- }
-
- this->m_bEnabled = bEnable;
-
- if (bEnable)
- this->OnEnabled();
- else
- this->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;
-}
-
+// 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 "../../include/pdfwindow/PDFWindow.h"
+#include "../../include/pdfwindow/PWL_Wnd.h"
+#include "../../include/pdfwindow/PWL_Utils.h"
+#include "../../include/pdfwindow/PWL_ScrollBar.h"
+
+/* -------------------------- CPWL_Timer -------------------------- */
+
+static CFX_MapPtrTemplate<FX_INT32, CPWL_Timer*> g_TimeMap;
+
+CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemHandler) :
+ m_pAttached(pAttached),
+ m_nTimerID(0),
+ m_pSystemHandler(pSystemHandler)
+{
+ ASSERT(m_pAttached != NULL);
+ ASSERT(m_pSystemHandler != NULL);
+}
+
+CPWL_Timer::~CPWL_Timer()
+{
+ KillPWLTimer();
+}
+
+FX_INT32 CPWL_Timer::SetPWLTimer(FX_INT32 nElapse)
+{
+ if (m_nTimerID != 0) KillPWLTimer();
+ m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc);
+ g_TimeMap.SetAt(m_nTimerID, this);
+ return m_nTimerID;
+}
+
+void CPWL_Timer::KillPWLTimer()
+{
+ if (m_nTimerID != 0)
+ {
+ m_pSystemHandler->KillTimer(m_nTimerID);
+ g_TimeMap.RemoveKey(m_nTimerID);
+ m_nTimerID = 0;
+ }
+}
+
+void CPWL_Timer::TimerProc(FX_INT32 idEvent)
+{
+ CPWL_Timer* pTimer = NULL;
+ if (g_TimeMap.Lookup(idEvent, pTimer))
+ {
+ if (pTimer)
+ {
+ if (pTimer->m_pAttached)
+ pTimer->m_pAttached->TimerProc();
+ }
+ }
+}
+
+/* -------------------------- CPWL_TimerHandler -------------------------- */
+
+CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL)
+{
+}
+
+CPWL_TimerHandler::~CPWL_TimerHandler()
+{
+ if (m_pTimer) delete m_pTimer;
+}
+
+void CPWL_TimerHandler::BeginTimer(FX_INT32 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()
+{
+}
+
+/* --------------------------- CPWL_MsgControl ---------------------------- */
+
+class CPWL_MsgControl
+{
+ friend class CPWL_Wnd;
+
+public:
+ CPWL_MsgControl(CPWL_Wnd * pWnd)
+ {
+// PWL_TRACE("new CPWL_MsgControl\n");
+ m_pCreatedWnd = pWnd;
+ Default();
+ }
+
+ ~CPWL_MsgControl()
+ {
+// PWL_TRACE("~CPWL_MsgControl\n");
+ 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( FX_INT32 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( FX_INT32 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::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 = CPDF_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::Destroy()
+{
+ KillFocus();
+
+ OnDestroy();
+
+ if (m_bCreated)
+ {
+ for (FX_INT32 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 CPDF_Rect & rcNew, FX_BOOL bReset,FX_BOOL bRefresh)
+{
+ if (IsValid())
+ {
+ CPDF_Rect rcOld = this->GetWindowRect();
+
+ m_rcWindow = rcNew;
+ m_rcWindow.Normalize();
+ //m_rcClip = CPWL_Utils::InflateRect(m_rcWindow,1.0f); //for special caret
+
+ 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 CPDF_Rect & rcOld, const CPDF_Rect & rcNew)
+{
+ CPDF_Rect rcUnion = rcOld;
+ rcUnion.Union(rcNew);
+
+ InvalidateRect(&rcUnion);
+
+ /*
+ CPDF_Rect SubArray[4];
+
+ rcOld.Substract4(rcNew,SubArray);
+ for (FX_INT32 i=0;i<4;i++)
+ {
+ if (SubArray[i].left == 0 &&
+ SubArray[i].right == 0 &&
+ SubArray[i].top == 0 &&
+ SubArray[i].bottom == 0)continue;
+
+ InvalidateRect(&CPWL_Utils::InflateRect(SubArray[i],2));
+ }
+
+ rcNew.Substract4(rcOld,SubArray);
+ for (FX_INT32 j=0;j<4;j++)
+ {
+ if (SubArray[j].left == 0 &&
+ SubArray[j].right == 0 &&
+ SubArray[j].top == 0 &&
+ SubArray[j].bottom == 0)continue;
+
+ InvalidateRect(&CPWL_Utils::InflateRect(SubArray[j],2));
+ }
+ */
+}
+
+void CPWL_Wnd::GetAppearanceStream(CFX_ByteString & sAppStream)
+{
+ if (IsValid())
+ {
+ CFX_ByteTextBuf sTextBuf;
+ GetAppearanceStream(sTextBuf);
+ sAppStream += sTextBuf.GetByteString();
+ }
+}
+
+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)
+{
+ CPDF_Rect rectWnd = GetWindowRect();
+ if (!rectWnd.IsEmpty())
+ {
+ CFX_ByteTextBuf sThis;
+
+ if (HasFlag(PWS_BACKGROUND))
+ sThis << CPWL_Utils::GetRectFillAppStream(rectWnd,this->GetBackgroundColor());
+
+ if (HasFlag(PWS_BORDER))
+ sThis << CPWL_Utils::GetBorderAppStream(rectWnd,
+ (FX_FLOAT)GetBorderWidth(),
+ GetBorderColor(),
+ this->GetBorderLeftTopColor(this->GetBorderStyle()),
+ this->GetBorderRightBottomColor(this->GetBorderStyle()),
+ this->GetBorderStyle(),
+ this->GetBorderDash());
+
+ sAppStream << sThis;
+ }
+}
+
+void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf & sAppStream)
+{
+ for (FX_INT32 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, CPDF_Matrix* pUser2Device)
+{
+ if (IsValid() && IsVisible())
+ {
+ DrawThisAppearance(pDevice,pUser2Device);
+ DrawChildAppearance(pDevice,pUser2Device);
+ }
+}
+
+void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
+{
+ CPDF_Rect rectWnd = GetWindowRect();
+ if (!rectWnd.IsEmpty())
+ {
+ if (HasFlag(PWS_BACKGROUND))
+ {
+ CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rectWnd,(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
+ CPWL_Utils::DrawFillRect(pDevice,pUser2Device,rcClient,this->GetBackgroundColor(),GetTransparency());
+ }
+
+ if (HasFlag(PWS_BORDER))
+ CPWL_Utils::DrawBorder(pDevice,
+ pUser2Device,
+ rectWnd,
+ (FX_FLOAT)GetBorderWidth(),
+ GetBorderColor(),
+ this->GetBorderLeftTopColor(this->GetBorderStyle()),
+ this->GetBorderRightBottomColor(this->GetBorderStyle()),
+ this->GetBorderStyle(),
+ this->GetBorderDash(),
+ GetTransparency());
+ }
+}
+
+void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
+{
+ for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++)
+ {
+ if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
+ {
+ CPDF_Matrix mt = pChild->GetChildMatrix();
+ if (mt.IsIdentity())
+ {
+ pChild->DrawAppearance(pDevice,pUser2Device);
+ }
+ else
+ {
+ mt.Concat(*pUser2Device);
+ pChild->DrawAppearance(pDevice,&mt);
+ }
+ }
+ }
+}
+
+void CPWL_Wnd::InvalidateRect(CPDF_Rect* pRect)
+{
+ if (IsValid())
+ {
+ CPDF_Rect rcRefresh = pRect ? *pRect : GetWindowRect();
+
+ if (!HasFlag(PWS_NOREFRESHCLIP))
+ {
+ CPDF_Rect 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 (FX_INT32 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 CPDF_Point & point, FX_DWORD nFlag)\
+{\
+ if (IsValid() && IsVisible() && IsEnabled())\
+ {\
+ if (IsWndCaptureMouse(this))\
+ {\
+ for (FX_INT32 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 (FX_INT32 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 (this->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(OnRButtonDblClk)
+PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonDown)
+PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonUp)
+PWL_IMPLEMENT_MOUSE_METHOD(OnMouseMove)
+
+FX_BOOL CPWL_Wnd::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag)
+{
+ if (IsValid() && IsVisible() && IsEnabled())
+ {
+ SetCursor();
+ if (IsWndCaptureKeyboard(this))
+ {
+ for (FX_INT32 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 (FX_INT32 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, FX_INTPTR wParam, FX_INTPTR lParam)
+{
+ switch (msg)
+ {
+ case PNM_ADDCHILD:
+ this->AddChild(pWnd);
+ break;
+ case PNM_REMOVECHILD:
+ this->RemoveChild(pWnd);
+ break;
+ default:
+ break;
+ }
+}
+
+FX_BOOL CPWL_Wnd::IsValid() const
+{
+ return m_bCreated;
+}
+
+PWL_CREATEPARAM CPWL_Wnd::GetCreationParam() const
+{
+ return m_sPrivateParam;
+}
+
+CPWL_Wnd* CPWL_Wnd::GetParentWindow() const
+{
+ return m_sPrivateParam.pParentWnd;
+}
+
+CPDF_Rect CPWL_Wnd::GetOriginWindowRect() const
+{
+ return m_sPrivateParam.rcRectWnd;
+}
+
+CPDF_Rect CPWL_Wnd::GetWindowRect() const
+{
+ return m_rcWindow;
+}
+
+CPDF_Rect CPWL_Wnd::GetClientRect() const
+{
+ CPDF_Rect rcWindow = GetWindowRect();
+ CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
+
+ if (CPWL_ScrollBar * pVSB = this->GetVScrollBar())
+ rcClient.right -= pVSB->GetScrollBarWidth();
+
+ rcClient.Normalize();
+
+ if (rcWindow.Contains(rcClient))
+ return rcClient;
+ else
+ return CPDF_Rect();
+}
+
+CPDF_Point CPWL_Wnd::GetCenterPoint() const
+{
+ CPDF_Rect rcClient = GetClientRect();
+
+ return CPDF_Point((rcClient.left + rcClient.right) * 0.5f,
+ (rcClient.top + rcClient.bottom) * 0.5f);
+}
+
+CPDF_Rect CPWL_Wnd::GetClientCenterSquare() const
+{
+ return CPWL_Utils::GetCenterSquare(GetClientRect());
+}
+
+CPDF_Rect CPWL_Wnd::GetWindowCenterSquare() const
+{
+ return CPWL_Utils::GetCenterSquare(CPWL_Utils::DeflateRect(GetWindowRect(),0.1f));
+}
+
+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;
+}
+
+FX_INT32 CPWL_Wnd::GetBorderStyle() const
+{
+ return m_sPrivateParam.nBorderStyle;
+}
+
+void CPWL_Wnd::SetBorderStyle(FX_INT32 nBorderStyle)
+{
+ if (HasFlag(PWS_BORDER))
+ m_sPrivateParam.nBorderStyle = nBorderStyle;
+}
+
+FX_INT32 CPWL_Wnd::GetBorderWidth() const
+{
+ if (HasFlag(PWS_BORDER))
+ return m_sPrivateParam.dwBorderWidth;
+
+ return 0;
+}
+
+FX_INT32 CPWL_Wnd::GetInnerBorderWidth() const
+{
+ /*
+ switch (GetBorderStyle())
+ {
+ case PBS_BEVELED:
+ case PBS_INSET:
+ return GetBorderWidth() / 2;
+ }
+ */
+ return 0;
+}
+
+void CPWL_Wnd::SetBorderWidth(FX_INT32 nBorderWidth)
+{
+ if (HasFlag(PWS_BORDER))
+ m_sPrivateParam.dwBorderWidth = nBorderWidth;
+}
+
+CPWL_Color CPWL_Wnd::GetBorderColor() const
+{
+ if (HasFlag(PWS_BORDER))
+ return m_sPrivateParam.sBorderColor;
+
+ return CPWL_Color();
+}
+
+void CPWL_Wnd::SetBorderColor(const CPWL_Color & color)
+{
+ if (HasFlag(PWS_BORDER))
+ m_sPrivateParam.sBorderColor = color;
+}
+
+CPWL_Dash CPWL_Wnd::GetBorderDash() const
+{
+ return m_sPrivateParam.sDash;
+}
+
+void* CPWL_Wnd::GetAttachedData() const
+{
+ return m_sPrivateParam.pAttachedData;
+}
+
+void CPWL_Wnd::SetBorderDash(const CPWL_Dash & sDash)
+{
+ if (HasFlag(PWS_BORDER))
+ m_sPrivateParam.sDash = sDash;
+}
+
+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;
+
+ if ((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 (FX_INT32 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 CPDF_Point & point) const
+{
+ return IsValid() && IsVisible() && GetWindowRect().Contains(point.x,point.y);
+}
+
+FX_BOOL CPWL_Wnd::ClientHitTest(const CPDF_Point & 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();
+ else
+ return this;
+}
+
+void CPWL_Wnd::SetVisible(FX_BOOL bVisible)
+{
+ if (IsValid())
+ {
+ for (FX_INT32 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 CPDF_Rect & rect)
+{
+ m_rcClip = rect;
+ m_rcClip.Normalize();
+}
+
+CPDF_Rect CPWL_Wnd::GetClipRect() const
+{
+ return m_rcClip;
+}
+
+FX_BOOL CPWL_Wnd::IsReadOnly() const
+{
+ return HasFlag(PWS_READONLY);
+}
+
+void CPWL_Wnd::RePosChildWnd()
+{
+ CPDF_Rect rcContent = CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
+
+ CPWL_ScrollBar * pVSB = this->GetVScrollBar();
+
+ CPDF_Rect rcVScroll = CPDF_Rect(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())
+ {
+ FX_INT32 nCursorType = this->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;
+}
+
+CPDF_Rect CPWL_Wnd::GetFocusRect() const
+{
+ return CPWL_Utils::InflateRect(this->GetWindowRect(),1);
+}
+
+FX_FLOAT CPWL_Wnd::GetFontSize() const
+{
+ return this->m_sPrivateParam.fFontSize;
+}
+
+void CPWL_Wnd::SetFontSize(FX_FLOAT fFontSize)
+{
+ this->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(FX_INT32 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(FX_INT32 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;
+}
+
+/* ----------------------------------------------------------------- */
+
+FX_INT32 CPWL_Wnd::GetTransparency()
+{
+ return m_sPrivateParam.nTransparency;
+}
+
+void CPWL_Wnd::SetTransparency(FX_INT32 nTransparency)
+{
+ for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++)
+ {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
+ {
+ pChild->SetTransparency(nTransparency);
+ }
+ }
+
+ m_sPrivateParam.nTransparency = nTransparency;
+}
+
+CPDF_Matrix CPWL_Wnd::GetWindowMatrix() const
+{
+ CPDF_Matrix mt = this->GetChildToRoot();
+
+ if (IPWL_Provider* pProvider = GetProvider())
+ {
+ mt.Concat(pProvider->GetWindowMatrix(GetAttachedData()));
+ return mt;
+ }
+
+/*
+ if (CReader_App* pApp = CPWL_Module::GetReaderApp())
+ if (CReader_Document* pDocument = pApp->GetCurrentDocument())
+ if (CReader_DocView* pDocView = pDocument->GetCurrentDocView())
+ {
+ CPDF_Matrix mtPageView;
+ pDocView->GetCurrentMatrix(mtPageView);
+ mt.Concat(mtPageView);
+ return mt;
+ }
+
+*/
+
+ return mt;
+}
+
+void CPWL_Wnd::PWLtoWnd(const CPDF_Point& point, FX_INT32& x, FX_INT32& y) const
+{
+ CPDF_Matrix mt = GetWindowMatrix();
+ CPDF_Point pt = point;
+ mt.Transform(pt.x,pt.y);
+ x = (FX_INT32)(pt.x+0.5);
+ y = (FX_INT32)(pt.y+0.5);
+}
+
+FX_RECT CPWL_Wnd::PWLtoWnd(const CPDF_Rect & rect) const
+{
+ CPDF_Rect rcTemp = rect;
+ CPDF_Matrix mt = GetWindowMatrix();
+ mt.TransformRect(rcTemp);
+ return FX_RECT((FX_INT32)(rcTemp.left+0.5), (FX_INT32)(rcTemp.bottom+0.5), (FX_INT32)(rcTemp.right+0.5), (FX_INT32)(rcTemp.top+0.5));
+}
+
+FX_HWND CPWL_Wnd::GetAttachedHWnd() const
+{
+ return m_sPrivateParam.hAttachedWnd;
+}
+
+CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const
+{
+ CPDF_Matrix mt = GetChildMatrix();
+ if (mt.IsIdentity())
+ return point;
+ else
+ {
+ CPDF_Point pt = point;
+ mt.Transform(pt.x,pt.y);
+ return pt;
+ }
+}
+
+CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const
+{
+ CPDF_Matrix mt = GetChildMatrix();
+ if (mt.IsIdentity())
+ return rect;
+ else
+ {
+ CPDF_Rect rc = rect;
+ mt.TransformRect(rc);
+ return rc;
+ }
+}
+
+CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const
+{
+ CPDF_Matrix mt = GetChildMatrix();
+ if (mt.IsIdentity())
+ return point;
+ else
+ {
+ mt.SetReverse(mt);
+ CPDF_Point pt = point;
+ mt.Transform(pt.x,pt.y);
+ return pt;
+ }
+}
+
+CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const
+{
+ CPDF_Matrix mt = GetChildMatrix();
+ if (mt.IsIdentity())
+ return rect;
+ else
+ {
+ mt.SetReverse(mt);
+ CPDF_Rect rc = rect;
+ mt.TransformRect(rc);
+ return rc;
+ }
+}
+
+CPDF_Matrix CPWL_Wnd::GetChildToRoot() const
+{
+ CPDF_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;
+}
+
+CPDF_Matrix CPWL_Wnd::GetChildMatrix() const
+{
+ if (HasFlag(PWS_CHILD))
+ return m_sPrivateParam.mtChild;
+
+ return CPDF_Matrix(1,0,0,1,0,0);
+}
+
+void CPWL_Wnd::SetChildMatrix(const CPDF_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 (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++)
+ {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
+ {
+ pChild->EnableWindow(bEnable);
+ }
+ }
+
+ this->m_bEnabled = bEnable;
+
+ if (bEnable)
+ this->OnEnabled();
+ else
+ this->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;
+}
+