summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/pdfwindow
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src/pdfwindow')
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Button.cpp46
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Caret.cpp292
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp979
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Edit.cpp2170
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp985
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_FontMap.cpp835
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Icon.cpp370
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_IconList.cpp893
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Label.cpp231
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_ListBox.cpp922
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp305
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Note.cpp2869
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp2158
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Signature.cpp274
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp99
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Utils.cpp6294
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Wnd.cpp1674
17 files changed, 10611 insertions, 10785 deletions
diff --git a/fpdfsdk/src/pdfwindow/PWL_Button.cpp b/fpdfsdk/src/pdfwindow/PWL_Button.cpp
index 84962285c4..9eca10c90d 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Button.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Button.cpp
@@ -9,45 +9,37 @@
#include "../../include/pdfwindow/PWL_Button.h"
#include "../../include/pdfwindow/PWL_Utils.h"
-/* ------------------------------- CPWL_Button ---------------------------------- */
+/* ------------------------------- CPWL_Button
+ * ---------------------------------- */
-CPWL_Button::CPWL_Button() :
- m_bMouseDown(FALSE)
-{
-}
+CPWL_Button::CPWL_Button() : m_bMouseDown(FALSE) {}
-CPWL_Button::~CPWL_Button()
-{
-// PWL_TRACE("~CPWL_Button\n");
+CPWL_Button::~CPWL_Button() {
+ // PWL_TRACE("~CPWL_Button\n");
}
-CFX_ByteString CPWL_Button::GetClassName() const
-{
- return "CPWL_Button";
+CFX_ByteString CPWL_Button::GetClassName() const {
+ return "CPWL_Button";
}
-void CPWL_Button::OnCreate(PWL_CREATEPARAM & cp)
-{
- cp.eCursorType = FXCT_HAND;
+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);
+FX_BOOL CPWL_Button::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) {
+ CPWL_Wnd::OnLButtonDown(point, nFlag);
- m_bMouseDown = TRUE;
- SetCapture();
+ m_bMouseDown = TRUE;
+ SetCapture();
- return TRUE;
+ return TRUE;
}
-FX_BOOL CPWL_Button::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonUp(point, nFlag);
+FX_BOOL CPWL_Button::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) {
+ CPWL_Wnd::OnLButtonUp(point, nFlag);
- ReleaseCapture();
- m_bMouseDown = FALSE;
+ ReleaseCapture();
+ m_bMouseDown = FALSE;
- return TRUE;
+ return TRUE;
}
-
diff --git a/fpdfsdk/src/pdfwindow/PWL_Caret.cpp b/fpdfsdk/src/pdfwindow/PWL_Caret.cpp
index 84a8b3d186..f35385e7f7 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Caret.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Caret.cpp
@@ -9,189 +9,157 @@
#include "../../include/pdfwindow/PWL_Caret.h"
#include "../../include/pdfwindow/PWL_Utils.h"
-#define PWL_CARET_FLASHINTERVAL 500
+#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()
+ : m_bFlash(FALSE),
+ m_ptHead(0, 0),
+ m_ptFoot(0, 0),
+ m_fWidth(0.4f),
+ m_nDelay(0) {}
-CPWL_Caret::~CPWL_Caret()
-{
-}
+CPWL_Caret::~CPWL_Caret() {}
-CFX_ByteString CPWL_Caret::GetClassName() const
-{
- return "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::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::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;
- }
+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();
+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();
- }
+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 + m_fWidth,
- m_ptHead.y);
+CPDF_Rect CPWL_Caret::GetCaretRect() const {
+ return CPDF_Rect(m_ptFoot.x, m_ptFoot.y, m_ptHead.x + 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)
- {
- m_ptHead = ptHead;
- m_ptFoot = ptFoot;
-
- m_bFlash = TRUE;
- //Move(GetCaretRect(),FALSE,TRUE);
- Move(m_rcInvalid, FALSE, TRUE);
- }
- }
- else
- {
- m_ptHead = ptHead;
- m_ptFoot = ptFoot;
-
- EndTimer();
- BeginTimer(PWL_CARET_FLASHINTERVAL);
-
- CPWL_Wnd::SetVisible(TRUE);
- m_bFlash = TRUE;
-
- //Move(GetCaretRect(),FALSE,TRUE);
- Move(m_rcInvalid, FALSE, TRUE);
- }
- }
- else
- {
- m_ptHead = CPDF_Point(0, 0);
- m_ptFoot = CPDF_Point(0, 0);
-
- m_bFlash = FALSE;
- if (IsVisible())
- {
- EndTimer();
- CPWL_Wnd::SetVisible(FALSE);
- }
- }
+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) {
+ m_ptHead = ptHead;
+ m_ptFoot = ptFoot;
+
+ m_bFlash = TRUE;
+ // Move(GetCaretRect(),FALSE,TRUE);
+ Move(m_rcInvalid, FALSE, TRUE);
+ }
+ } else {
+ m_ptHead = ptHead;
+ m_ptFoot = ptFoot;
+
+ EndTimer();
+ BeginTimer(PWL_CARET_FLASHINTERVAL);
+
+ CPWL_Wnd::SetVisible(TRUE);
+ m_bFlash = TRUE;
+
+ // Move(GetCaretRect(),FALSE,TRUE);
+ Move(m_rcInvalid, FALSE, TRUE);
+ }
+ } else {
+ m_ptHead = CPDF_Point(0, 0);
+ 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);
-}
+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 80115ab7cf..932f8c56d6 100644
--- a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp
@@ -12,682 +12,643 @@
#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))
+#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 (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;
- }
+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 (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;
+ return TRUE;
}
-FX_BOOL CPWL_CBListBox::OnKeyDownWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWORD nFlag)
-{
- if (!m_pList) return FALSE;
+FX_BOOL CPWL_CBListBox::OnKeyDownWithExit(FX_WORD nChar,
+ FX_BOOL& bExit,
+ FX_DWORD nFlag) {
+ if (!m_pList)
+ return FALSE;
- switch (nChar)
- {
+ switch (nChar) {
default:
- return FALSE;
+ 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;
- }
+ break;
+ }
- switch (nChar)
- {
+ switch (nChar) {
case FWL_VKEY_Up:
- m_pList->OnVK_UP(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- break;
+ m_pList->OnVK_UP(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
+ break;
case FWL_VKEY_Down:
- m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- break;
+ m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
+ break;
case FWL_VKEY_Home:
- m_pList->OnVK_HOME(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- break;
+ m_pList->OnVK_HOME(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
+ break;
case FWL_VKEY_Left:
- m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- break;
+ m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
+ break;
case FWL_VKEY_End:
- m_pList->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- break;
+ m_pList->OnVK_END(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
+ break;
case FWL_VKEY_Right:
- m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- break;
+ m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
+ break;
case FWL_VKEY_Delete:
- break;
- }
+ break;
+ }
- OnNotifySelChanged(TRUE,bExit, nFlag);
+ OnNotifySelChanged(TRUE, bExit, nFlag);
- return TRUE;
+ return TRUE;
}
-FX_BOOL CPWL_CBListBox::OnCharWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWORD nFlag)
-{
- if (!m_pList) return FALSE;
+FX_BOOL CPWL_CBListBox::OnCharWithExit(FX_WORD nChar,
+ FX_BOOL& bExit,
+ FX_DWORD nFlag) {
+ if (!m_pList)
+ return FALSE;
- if (!m_pList->OnChar(nChar,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag))) return FALSE;
+ if (!m_pList->OnChar(nChar, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)))
+ return FALSE;
- if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow())
- {
- pComboBox->SetSelectText();
- }
+ if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow()) {
+ pComboBox->SetSelectText();
+ }
- OnNotifySelChanged(TRUE,bExit,nFlag);
+ OnNotifySelChanged(TRUE, bExit, nFlag);
- return TRUE;
+ return TRUE;
}
/* ---------------------------- CPWL_CBButton ---------------------------- */
-void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
-{
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
+void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
+ CPWL_Wnd::GetThisAppearanceStream(sAppStream);
- CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();
+ CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();
- if (IsVisible() && !rectWnd.IsEmpty())
- {
- CFX_ByteTextBuf sButton;
+ if (IsVisible() && !rectWnd.IsEmpty()) {
+ CFX_ByteTextBuf sButton;
- CPDF_Point ptCenter = GetCenterPoint();
+ CPDF_Point ptCenter = 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);
+ 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";
+ 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";
- }
+ sAppStream << "q\n" << sButton << "Q\n";
}
+ }
}
-void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
+void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device) {
+ CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
- CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();
+ CPDF_Rect rectWnd = CPWL_Wnd::GetWindowRect();
- if (IsVisible() && !rectWnd.IsEmpty())
- {
- CPDF_Point ptCenter = GetCenterPoint();
+ if (IsVisible() && !rectWnd.IsEmpty()) {
+ CPDF_Point ptCenter = 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);
+ 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;
+ 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);
+ 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);
- }
+ 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);
+FX_BOOL CPWL_CBButton::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) {
+ CPWL_Wnd::OnLButtonDown(point, nFlag);
- SetCapture();
+ SetCapture();
- if (CPWL_Wnd * pParent = GetParentWindow())
- {
- pParent->OnNotify(this,PNM_LBUTTONDOWN,0,PWL_MAKEDWORD(point.x,point.y));
- }
+ if (CPWL_Wnd* pParent = GetParentWindow()) {
+ pParent->OnNotify(this, PNM_LBUTTONDOWN, 0,
+ PWL_MAKEDWORD(point.x, point.y));
+ }
- return TRUE;
+ return TRUE;
}
-FX_BOOL CPWL_CBButton::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonUp(point, nFlag);
+FX_BOOL CPWL_CBButton::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) {
+ CPWL_Wnd::OnLButtonUp(point, nFlag);
- ReleaseCapture();
+ ReleaseCapture();
- return TRUE;
+ 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)
-{
-}
+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";
+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::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::SetFocus() {
+ if (m_pEdit)
+ m_pEdit->SetFocus();
}
-void CPWL_ComboBox::KillFocus()
-{
- SetPopup(FALSE);
- CPWL_Wnd::KillFocus();
+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();
+CFX_WideString CPWL_ComboBox::GetText() const {
+ if (m_pEdit) {
+ return m_pEdit->GetText();
+ }
+ return CFX_WideString();
}
-void CPWL_ComboBox::SetText(const FX_WCHAR* text)
-{
- if (m_pEdit)
- m_pEdit->SetText(text);
+void CPWL_ComboBox::SetText(const FX_WCHAR* text) {
+ if (m_pEdit)
+ m_pEdit->SetText(text);
}
-void CPWL_ComboBox::AddString(const FX_WCHAR* string)
-{
- if (m_pList)
- m_pList->AddString(string);
+void CPWL_ComboBox::AddString(const FX_WCHAR* string) {
+ if (m_pList)
+ m_pList->AddString(string);
}
-int32_t CPWL_ComboBox::GetSelect() const
-{
- return m_nSelectItem;
+int32_t CPWL_ComboBox::GetSelect() const {
+ return m_nSelectItem;
}
-void CPWL_ComboBox::SetSelect(int32_t nItemIndex)
-{
- if (m_pList)
- m_pList->Select(nItemIndex);
+void CPWL_ComboBox::SetSelect(int32_t nItemIndex) {
+ if (m_pList)
+ m_pList->Select(nItemIndex);
- m_pEdit->SetText(m_pList->GetText().c_str());
+ m_pEdit->SetText(m_pList->GetText().c_str());
- m_nSelectItem = nItemIndex;
+ m_nSelectItem = nItemIndex;
}
-void CPWL_ComboBox::SetEditSel(int32_t nStartChar,int32_t nEndChar)
-{
- if (m_pEdit)
- {
- m_pEdit->SetSel(nStartChar,nEndChar);
- }
+void CPWL_ComboBox::SetEditSel(int32_t nStartChar, int32_t nEndChar) {
+ if (m_pEdit) {
+ m_pEdit->SetSel(nStartChar, nEndChar);
+ }
}
-void CPWL_ComboBox::GetEditSel(int32_t & nStartChar, int32_t & nEndChar) const
-{
- nStartChar = -1;
- nEndChar = -1;
+void CPWL_ComboBox::GetEditSel(int32_t& nStartChar, int32_t& nEndChar) const {
+ nStartChar = -1;
+ nEndChar = -1;
- if (m_pEdit)
- {
- m_pEdit->GetSel(nStartChar,nEndChar);
- }
+ if (m_pEdit) {
+ m_pEdit->GetSel(nStartChar, nEndChar);
+ }
}
-void CPWL_ComboBox::Clear()
-{
- if (m_pEdit)
- {
- m_pEdit->Clear();
- }
+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::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);
+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;
+ 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(PWS_AUTOFONTSIZE))
+ ecp.dwFlags |= PWS_AUTOFONTSIZE;
- if (!HasFlag(PCBS_ALLOWCUSTOMTEXT))
- ecp.dwFlags |= PWS_READONLY;
+ if (!HasFlag(PCBS_ALLOWCUSTOMTEXT))
+ ecp.dwFlags |= PWS_READONLY;
- ecp.rcRectWnd = CPDF_Rect(0,0,0,0);
- ecp.dwBorderWidth = 0;
- ecp.nBorderStyle = PBS_SOLID;
+ ecp.rcRectWnd = CPDF_Rect(0, 0, 0, 0);
+ ecp.dwBorderWidth = 0;
+ ecp.nBorderStyle = PBS_SOLID;
- m_pEdit->Create(ecp);
- }
+ m_pEdit->Create(ecp);
+ }
}
-void CPWL_ComboBox::CreateButton(const PWL_CREATEPARAM & cp)
-{
- if (!m_pButton)
- {
- m_pButton = new CPWL_CBButton;
+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;
+ 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);
- }
+ 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::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();
+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();
+ 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;
+ 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;
+ switch (m_nPopupWhere) {
+ case 0:
+ rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
- if (rcButton.left < rclient.left)
- rcButton.left = rclient.left;
+ if (rcButton.left < rclient.left)
+ rcButton.left = rclient.left;
- rcButton.bottom = rcButton.top - fOldClientHeight;
+ rcButton.bottom = rcButton.top - fOldClientHeight;
- rcEdit.right = rcButton.left - 1.0f;
+ rcEdit.right = rcButton.left - 1.0f;
- if (rcEdit.left < rclient.left)
- rcEdit.left = rclient.left;
+ if (rcEdit.left < rclient.left)
+ rcEdit.left = rclient.left;
- if (rcEdit.right < rcEdit.left)
- rcEdit.right = rcEdit.left;
+ if (rcEdit.right < rcEdit.left)
+ rcEdit.right = rcEdit.left;
- rcEdit.bottom = rcEdit.top - fOldClientHeight;
+ rcEdit.bottom = rcEdit.top - fOldClientHeight;
- rcList.top -= fOldWindowHeight;
+ rcList.top -= fOldWindowHeight;
- break;
- case 1:
- rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
+ break;
+ case 1:
+ rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
- if (rcButton.left < rclient.left)
- rcButton.left = rclient.left;
+ if (rcButton.left < rclient.left)
+ rcButton.left = rclient.left;
- rcButton.top = rcButton.bottom + fOldClientHeight;
+ rcButton.top = rcButton.bottom + fOldClientHeight;
- rcEdit.right = rcButton.left - 1.0f;
+ rcEdit.right = rcButton.left - 1.0f;
- if (rcEdit.left < rclient.left)
- rcEdit.left = rclient.left;
+ if (rcEdit.left < rclient.left)
+ rcEdit.left = rclient.left;
- if (rcEdit.right < rcEdit.left)
- rcEdit.right = rcEdit.left;
+ if (rcEdit.right < rcEdit.left)
+ rcEdit.right = rcEdit.left;
- rcEdit.top = rcEdit.bottom + fOldClientHeight;
+ rcEdit.top = rcEdit.bottom + fOldClientHeight;
- rcList.bottom += fOldWindowHeight;
+ rcList.bottom += fOldWindowHeight;
- break;
- }
+ break;
+ }
- if (m_pButton)
- m_pButton->Move(rcButton,TRUE,FALSE);
+ if (m_pButton)
+ m_pButton->Move(rcButton, TRUE, FALSE);
- if (m_pEdit)
- m_pEdit->Move(rcEdit,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);
- }
+ if (m_pList) {
+ m_pList->SetVisible(TRUE);
+ m_pList->Move(rcList, TRUE, FALSE);
+ m_pList->ScrollToListItem(m_nSelectItem);
}
- else
- {
- CPDF_Rect rcButton = rcClient;
+ } else {
+ CPDF_Rect rcButton = rcClient;
- rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
+ rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH;
- if (rcButton.left < rcClient.left)
- rcButton.left = rcClient.left;
+ if (rcButton.left < rcClient.left)
+ rcButton.left = rcClient.left;
- if (m_pButton)
- m_pButton->Move(rcButton,TRUE,FALSE);
+ if (m_pButton)
+ m_pButton->Move(rcButton, TRUE, FALSE);
- CPDF_Rect rcEdit = rcClient;
- rcEdit.right = rcButton.left - 1.0f;
+ CPDF_Rect rcEdit = rcClient;
+ rcEdit.right = rcButton.left - 1.0f;
- if (rcEdit.left < rcClient.left)
- rcEdit.left = rcClient.left;
+ if (rcEdit.left < rcClient.left)
+ rcEdit.left = rcClient.left;
- if (rcEdit.right < rcEdit.left)
- rcEdit.right = rcEdit.left;
+ if (rcEdit.right < rcEdit.left)
+ rcEdit.right = rcEdit.left;
- if (m_pEdit)
- m_pEdit->Move(rcEdit,TRUE,FALSE);
+ if (m_pEdit)
+ m_pEdit->Move(rcEdit, TRUE, FALSE);
- if (m_pList)
- m_pList->SetVisible(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_BOOL bExit = FALSE;
- m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, 0);
- if (bExit) return;
-
- int32_t nWhere = 0;
- FX_FLOAT fPopupRet = 0.0f;
- FX_FLOAT fPopupMin = 0.0f;
- if (m_pList->GetCount() > 3)
- fPopupMin = m_pList->GetFirstHeight() * 3 + m_pList->GetBorderWidth() * 2;
- FX_FLOAT fPopupMax = fListHeight + m_pList->GetBorderWidth() * 2;
- m_pFillerNotify->QueryWherePopup(GetAttachedData(), fPopupMin,fPopupMax,nWhere,fPopupRet);
-
- if (IsFloatBigger(fPopupRet,0.0f))
- {
- m_bPopup = bPopup;
-
- 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);
-
- bExit = FALSE;
- m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, 0);
- if (bExit) return;
- }
- }
- }
- 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_pFillerNotify)
- {
- m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
- if (bExit) return FALSE;
- bExit = FALSE;
- m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
- if (bExit) return FALSE;
- }
- if (m_pList->OnKeyDownWithExit(nChar,bExit,nFlag))
- {
- if (bExit) return FALSE;
- SetSelectText();
- }
- }
- return TRUE;
- case FWL_VKEY_Down:
- if (m_pList->GetCurSel() < m_pList->GetCount() - 1)
- {
- FX_BOOL bExit = FALSE;
-
- if (m_pFillerNotify)
- {
- m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
- if (bExit) return FALSE;
- bExit = FALSE;
- m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
- if (bExit) return FALSE;
- }
- if (m_pList->OnKeyDownWithExit(nChar,bExit,nFlag))
- {
- if (bExit) return FALSE;
- SetSelectText();
- }
- }
- return TRUE;
- }
-
- if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
- return m_pEdit->OnKeyDown(nChar,nFlag);
+void CPWL_ComboBox::SelectAll() {
+ if (m_pEdit && HasFlag(PCBS_ALLOWCUSTOMTEXT))
+ m_pEdit->SelectAll();
+}
- return FALSE;
+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_BOOL bExit = FALSE;
+ m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, 0);
+ if (bExit)
+ return;
+
+ int32_t nWhere = 0;
+ FX_FLOAT fPopupRet = 0.0f;
+ FX_FLOAT fPopupMin = 0.0f;
+ if (m_pList->GetCount() > 3)
+ fPopupMin =
+ m_pList->GetFirstHeight() * 3 + m_pList->GetBorderWidth() * 2;
+ FX_FLOAT fPopupMax = fListHeight + m_pList->GetBorderWidth() * 2;
+ m_pFillerNotify->QueryWherePopup(GetAttachedData(), fPopupMin, fPopupMax,
+ nWhere, fPopupRet);
+
+ if (IsFloatBigger(fPopupRet, 0.0f)) {
+ m_bPopup = bPopup;
+
+ 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);
+
+ bExit = FALSE;
+ m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, 0);
+ if (bExit)
+ return;
+ }
+ }
+ } else {
+ m_bPopup = bPopup;
+ Move(m_rcOldWindow, TRUE, TRUE);
+ }
}
-FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag)
-{
- if (!m_pList)
- return FALSE;
+FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) {
+ if (!m_pList)
+ return FALSE;
+ if (!m_pEdit)
+ return FALSE;
- if (!m_pEdit)
- return FALSE;
+ m_nSelectItem = -1;
- m_nSelectItem = -1;
- if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
- return m_pEdit->OnChar(nChar,nFlag);
+ switch (nChar) {
+ case FWL_VKEY_Up:
+ if (m_pList->GetCurSel() > 0) {
+ FX_BOOL bExit = FALSE;
- FX_BOOL bExit = FALSE;
- if (m_pFillerNotify)
- {
- m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
- if (bExit)
+ if (m_pFillerNotify) {
+ m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
+ if (bExit)
return FALSE;
+ bExit = FALSE;
+ m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
+ if (bExit)
+ return FALSE;
+ }
+ if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) {
+ if (bExit)
+ return FALSE;
+ SetSelectText();
+ }
+ }
+ return TRUE;
+ case FWL_VKEY_Down:
+ if (m_pList->GetCurSel() < m_pList->GetCount() - 1) {
+ FX_BOOL bExit = FALSE;
- m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
- if (bExit)
+ if (m_pFillerNotify) {
+ m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
+ if (bExit)
return FALSE;
- }
- if (m_pList->OnCharWithExit(nChar,bExit,nFlag))
- return bExit;
+ bExit = FALSE;
+ m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
+ if (bExit)
+ return FALSE;
+ }
+ if (m_pList->OnKeyDownWithExit(nChar, bExit, nFlag)) {
+ if (bExit)
+ return FALSE;
+ SetSelectText();
+ }
+ }
+ return TRUE;
+ }
+
+ if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
+ return m_pEdit->OnKeyDown(nChar, nFlag);
+ return FALSE;
+}
+
+FX_BOOL CPWL_ComboBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
+ if (!m_pList)
+ return FALSE;
+
+ if (!m_pEdit)
return FALSE;
+
+ m_nSelectItem = -1;
+ if (HasFlag(PCBS_ALLOWCUSTOMTEXT))
+ return m_pEdit->OnChar(nChar, nFlag);
+
+ FX_BOOL bExit = FALSE;
+ if (m_pFillerNotify) {
+ m_pFillerNotify->OnPopupPreOpen(GetAttachedData(), bExit, nFlag);
+ if (bExit)
+ return FALSE;
+
+ m_pFillerNotify->OnPopupPostOpen(GetAttachedData(), bExit, nFlag);
+ if (bExit)
+ return FALSE;
+ }
+ if (m_pList->OnCharWithExit(nChar, bExit, nFlag))
+ return bExit;
+
+ return FALSE;
}
-void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam)
-{
- switch (msg)
- {
+void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd,
+ FX_DWORD msg,
+ intptr_t wParam,
+ intptr_t lParam) {
+ switch (msg) {
case PNM_LBUTTONDOWN:
- if (pWnd == m_pButton)
- {
- SetPopup(!m_bPopup);
- return;
- }
- break;
+ 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;
- }
+ if (m_pEdit && m_pList) {
+ if (pWnd == m_pList) {
+ SetSelectText();
+ SelectAll();
+ m_pEdit->SetFocus();
+ SetPopup(FALSE);
+ return;
}
- }
+ }
+ }
- CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam);
+ CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
}
-FX_BOOL CPWL_ComboBox::IsPopup() const
-{
- return m_bPopup;
+FX_BOOL CPWL_ComboBox::IsPopup() const {
+ return m_bPopup;
}
-void CPWL_ComboBox::SetSelectText()
-{
- CFX_WideString swText = m_pList->GetText();
- m_pEdit->SelectAll();
- m_pEdit->ReplaceSel(m_pList->GetText().c_str());
- m_pEdit->SelectAll();
+void CPWL_ComboBox::SetSelectText() {
+ CFX_WideString swText = m_pList->GetText();
+ m_pEdit->SelectAll();
+ m_pEdit->ReplaceSel(m_pList->GetText().c_str());
+ m_pEdit->SelectAll();
- m_nSelectItem = m_pList->GetCurSel();
+ m_nSelectItem = m_pList->GetCurSel();
}
-FX_BOOL CPWL_ComboBox::IsModified() const
-{
- return m_pEdit->IsModified();
+FX_BOOL CPWL_ComboBox::IsModified() const {
+ return m_pEdit->IsModified();
}
-void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify)
-{
- m_pFillerNotify = pNotify;
+void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) {
+ m_pFillerNotify = pNotify;
- if (m_pEdit)
- m_pEdit->SetFillerNotify(pNotify);
+ if (m_pEdit)
+ m_pEdit->SetFillerNotify(pNotify);
- if (m_pList)
- m_pList->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 58d8a79da1..edefd7ecd2 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
@@ -17,1301 +17,1209 @@
/* ---------------------------- CPWL_Edit ------------------------------ */
-CPWL_Edit::CPWL_Edit() : m_pFillerNotify(NULL),
- m_pSpellCheck(NULL),
- m_bFocus(FALSE)
-{
- m_pFormFiller = NULL;
+CPWL_Edit::CPWL_Edit()
+ : m_pFillerNotify(NULL), m_pSpellCheck(NULL), m_bFocus(FALSE) {
+ m_pFormFiller = NULL;
}
-CPWL_Edit::~CPWL_Edit()
-{
- ASSERT(m_bFocus == FALSE);
+CPWL_Edit::~CPWL_Edit() {
+ ASSERT(m_bFocus == FALSE);
}
-CFX_ByteString CPWL_Edit::GetClassName() const
-{
- return PWL_CLASSNAME_EDIT;
+CFX_ByteString CPWL_Edit::GetClassName() const {
+ return PWL_CLASSNAME_EDIT;
}
-void CPWL_Edit::OnDestroy()
-{
-}
+void CPWL_Edit::OnDestroy() {}
+
+void CPWL_Edit::SetText(const FX_WCHAR* csText) {
+ CFX_WideString swText = csText;
+
+ if (HasFlag(PES_RICH)) {
+ CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText);
+
+ if (CXML_Element* pXML =
+ CXML_Element::Parse(sValue.c_str(), sValue.GetLength())) {
+ int32_t nCount = pXML->CountChildren();
+ FX_BOOL bFirst = TRUE;
+
+ swText.Empty();
+
+ for (int32_t i = 0; i < nCount; i++) {
+ if (CXML_Element* pSubElement = pXML->GetElement(i)) {
+ CFX_ByteString tag = pSubElement->GetTagName();
+ if (tag.EqualNoCase("p")) {
+ int nChild = pSubElement->CountChildren();
+ CFX_WideString swSection;
+ for (int32_t j = 0; j < nChild; j++) {
+ swSection += pSubElement->GetContent(j);
+ }
+
+ if (bFirst)
+ bFirst = FALSE;
+ else
+ swText += FWL_VKEY_Return;
+ swText += swSection;
+ }
+ }
+ }
+
+ delete pXML;
+ }
+ }
-void CPWL_Edit::SetText(const FX_WCHAR* csText)
-{
- CFX_WideString swText = csText;
-
- if (HasFlag(PES_RICH))
- {
- CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText);
-
- if (CXML_Element * pXML = CXML_Element::Parse(sValue.c_str(), sValue.GetLength()))
- {
- int32_t nCount = pXML->CountChildren();
- FX_BOOL bFirst = TRUE;
-
- swText.Empty();
-
- for (int32_t i=0; i<nCount; i++)
- {
- if (CXML_Element * pSubElement = pXML->GetElement(i))
- {
- CFX_ByteString tag=pSubElement->GetTagName();
- if (tag.EqualNoCase("p"))
- {
- int nChild = pSubElement->CountChildren();
- CFX_WideString swSection;
- for(int32_t j=0; j<nChild; j++)
- {
- swSection += pSubElement->GetContent(j);
- }
-
- if (bFirst)bFirst = FALSE;
- else
- swText += FWL_VKEY_Return;
- swText += swSection;
- }
- }
- }
-
- delete pXML;
- }
- }
-
- m_pEdit->SetText(swText.c_str());
+ m_pEdit->SetText(swText.c_str());
}
-void CPWL_Edit::RePosChildWnd()
-{
- if (CPWL_ScrollBar * pVSB = GetVScrollBar()) {
- 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);
- }
+void CPWL_Edit::RePosChildWnd() {
+ if (CPWL_ScrollBar* pVSB = GetVScrollBar()) {
+ 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
+ if (m_pEditCaret && !HasFlag(PES_TEXTOVERFLOW))
+ m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect(
+ GetClientRect(), 1.0f)); //+1 for caret beside border
- CPWL_EditCtrl::RePosChildWnd();
+ CPWL_EditCtrl::RePosChildWnd();
}
-CPDF_Rect CPWL_Edit::GetClientRect() const
-{
- CPDF_Rect rcClient = CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
+CPDF_Rect CPWL_Edit::GetClientRect() const {
+ CPDF_Rect rcClient = CPWL_Utils::DeflateRect(
+ GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
- if (CPWL_ScrollBar * pVSB = GetVScrollBar())
- {
- if (pVSB->IsVisible())
- {
- rcClient.right -= PWL_SCROLLBAR_WIDTH;
- }
- }
+ if (CPWL_ScrollBar* pVSB = GetVScrollBar()) {
+ if (pVSB->IsVisible()) {
+ rcClient.right -= PWL_SCROLLBAR_WIDTH;
+ }
+ }
- return rcClient;
+ return rcClient;
}
-void CPWL_Edit::SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pEdit->SetAlignmentH((int32_t)nFormat, bPaint);
+void CPWL_Edit::SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_pEdit->SetAlignmentH((int32_t)nFormat, bPaint);
}
-void CPWL_Edit::SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pEdit->SetAlignmentV((int32_t)nFormat, bPaint);
+void CPWL_Edit::SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_pEdit->SetAlignmentV((int32_t)nFormat, bPaint);
}
-FX_BOOL CPWL_Edit::CanSelectAll() const
-{
- return GetSelectWordRange() != m_pEdit->GetWholeWordRange();
+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::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::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::CanCut() const {
+ return CanCopy() && !IsReadOnly();
}
-FX_BOOL CPWL_Edit::CanPaste() const
-{
- if (IsReadOnly()) return FALSE;
+FX_BOOL CPWL_Edit::CanPaste() const {
+ if (IsReadOnly())
+ return FALSE;
- CFX_WideString swClipboard;
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- swClipboard = pSH->GetClipboardText(GetAttachedHWnd());
+ CFX_WideString swClipboard;
+ if (IFX_SystemHandler* pSH = GetSystemHandler())
+ swClipboard = pSH->GetClipboardText(GetAttachedHWnd());
- return !swClipboard.IsEmpty();
+ return !swClipboard.IsEmpty();
}
-void CPWL_Edit::CopyText()
-{
- if (!CanCopy()) return;
+void CPWL_Edit::CopyText() {
+ if (!CanCopy())
+ return;
- CFX_WideString str = m_pEdit->GetSelText();
+ CFX_WideString str = m_pEdit->GetSelText();
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- pSH->SetClipboardText(GetAttachedHWnd(), str);
+ 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.c_str());
- }
-
- if (m_pFillerNotify)
- {
- FX_BOOL bExit = FALSE;
- m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit,0);
- if (bExit) return;
- }
+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.c_str());
+ }
+
+ if (m_pFillerNotify) {
+ FX_BOOL bExit = FALSE;
+ m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit, 0);
+ if (bExit)
+ return;
+ }
}
-void CPWL_Edit::CutText()
-{
- if (!CanCut()) return;
+void CPWL_Edit::CutText() {
+ if (!CanCut())
+ return;
- CFX_WideString str = m_pEdit->GetSelText();
+ CFX_WideString str = m_pEdit->GetSelText();
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- pSH->SetClipboardText(GetAttachedHWnd(), str);
+ if (IFX_SystemHandler* pSH = GetSystemHandler())
+ pSH->SetClipboardText(GetAttachedHWnd(), str);
- m_pEdit->Clear();
+ m_pEdit->Clear();
}
-void CPWL_Edit::OnCreated()
-{
- CPWL_EditCtrl::OnCreated();
+void CPWL_Edit::OnCreated() {
+ CPWL_EditCtrl::OnCreated();
- if (CPWL_ScrollBar * pScroll = GetVScrollBar())
- {
- pScroll->RemoveFlag(PWS_AUTOTRANSPARENT);
- pScroll->SetTransparency(255);
- }
+ if (CPWL_ScrollBar* pScroll = GetVScrollBar()) {
+ pScroll->RemoveFlag(PWS_AUTOTRANSPARENT);
+ pScroll->SetTransparency(255);
+ }
- SetParamByFlag();
+ SetParamByFlag();
- m_rcOldWindow = GetWindowRect();
+ m_rcOldWindow = GetWindowRect();
- m_pEdit->SetOprNotify(this);
- m_pEdit->EnableOprNotify(TRUE);
+ 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::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;
-
- int32_t nCharArray = m_pEdit->GetCharArray();
-
- if (nCharArray > 0)
- {
- switch (GetBorderStyle())
- {
- case PBS_SOLID:
- {
- sLine << "q\n" << GetBorderWidth() << " w\n"
- << CPWL_Utils::GetColorAppStream(GetBorderColor(),FALSE) << " 2 J 0 j\n";
-
- for (int32_t i=1;i<nCharArray;i++)
- {
- sLine << rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*i << " "
- << rcClient.bottom << " m\n"
- << rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*i << " "
- << rcClient.top << " l S\n";
- }
-
- sLine << "Q\n";
- }
- break;
- case PBS_DASH:
- {
- sLine << "q\n" << GetBorderWidth() << " w\n"
- << CPWL_Utils::GetColorAppStream(GetBorderColor(),FALSE) << " 2 J 0 j\n"
- << "[" << GetBorderDash().nDash << " "
- << GetBorderDash().nGap << "] "
- << GetBorderDash().nPhase << " d\n";
-
- for (int32_t i=1;i<nCharArray;i++)
- {
- sLine << rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*i << " "
- << rcClient.bottom << " m\n"
- << rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*i << " "
- << rcClient.top << " l S\n";
- }
-
- sLine << "Q\n";
- }
- break;
- }
- }
-
- sAppStream << sLine;
-
- CFX_ByteTextBuf sText;
-
- 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 = 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::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
+ CPWL_Wnd::GetThisAppearanceStream(sAppStream);
+
+ CPDF_Rect rcClient = GetClientRect();
+ CFX_ByteTextBuf sLine;
+
+ int32_t nCharArray = m_pEdit->GetCharArray();
+
+ if (nCharArray > 0) {
+ switch (GetBorderStyle()) {
+ case PBS_SOLID: {
+ sLine << "q\n" << GetBorderWidth() << " w\n"
+ << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE)
+ << " 2 J 0 j\n";
+
+ for (int32_t i = 1; i < nCharArray; i++) {
+ sLine << rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) * i
+ << " " << rcClient.bottom << " m\n"
+ << rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) * i
+ << " " << rcClient.top << " l S\n";
+ }
+
+ sLine << "Q\n";
+ } break;
+ case PBS_DASH: {
+ sLine << "q\n" << GetBorderWidth() << " w\n"
+ << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE)
+ << " 2 J 0 j\n"
+ << "[" << GetBorderDash().nDash << " " << GetBorderDash().nGap
+ << "] " << GetBorderDash().nPhase << " d\n";
+
+ for (int32_t i = 1; i < nCharArray; i++) {
+ sLine << rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) * i
+ << " " << rcClient.bottom << " m\n"
+ << rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) * i
+ << " " << rcClient.top << " l S\n";
+ }
+
+ sLine << "Q\n";
+ } break;
+ }
+ }
+
+ sAppStream << sLine;
+
+ CFX_ByteTextBuf sText;
+
+ 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 = 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;
-
- int32_t nCharArray = m_pEdit->GetCharArray();
- FX_SAFE_INT32 nCharArraySafe = nCharArray;
- nCharArraySafe -= 1;
- nCharArraySafe *= 2;
-
- if (nCharArray > 0 && nCharArraySafe.IsValid())
- {
- switch (GetBorderStyle())
- {
- case PBS_SOLID:
- {
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
-
- CFX_PathData path;
- path.SetPointCount(nCharArraySafe.ValueOrDie());
-
- for (int32_t i=0; i<nCharArray-1; i++)
- {
- path.SetPoint(i*2, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
- rcClient.bottom, FXPT_MOVETO);
- path.SetPoint(i*2+1, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
- rcClient.top, FXPT_LINETO);
- }
- if (path.GetPointCount() > 0)
- pDevice->DrawPath(&path, pUser2Device, &gsd,0,
- CPWL_Utils::PWLColorToFXColor(GetBorderColor(),255), FXFILL_ALTERNATE);
- }
- break;
- case PBS_DASH:
- {
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
-
- gsd.SetDashCount(2);
- gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().nDash;
- gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().nGap;
- gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase;
-
- CFX_PathData path;
- path.SetPointCount(nCharArraySafe.ValueOrDie());
-
- for (int32_t i=0; i<nCharArray-1; i++)
- {
- path.SetPoint(i*2, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
- rcClient.bottom, FXPT_MOVETO);
- path.SetPoint(i*2+1, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
- rcClient.top, FXPT_LINETO);
- }
- if (path.GetPointCount() > 0)
- pDevice->DrawPath(&path, pUser2Device, &gsd,0,
- CPWL_Utils::PWLColorToFXColor(GetBorderColor(),255), FXFILL_ALTERNATE);
- }
- break;
- }
- }
-
- 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(), GetTransparency()),
- CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), 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, GetCreationParam().pSpellCheck);
- }
+void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device) {
+ CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
+
+ CPDF_Rect rcClient = GetClientRect();
+ CFX_ByteTextBuf sLine;
+
+ int32_t nCharArray = m_pEdit->GetCharArray();
+ FX_SAFE_INT32 nCharArraySafe = nCharArray;
+ nCharArraySafe -= 1;
+ nCharArraySafe *= 2;
+
+ if (nCharArray > 0 && nCharArraySafe.IsValid()) {
+ switch (GetBorderStyle()) {
+ case PBS_SOLID: {
+ CFX_GraphStateData gsd;
+ gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
+
+ CFX_PathData path;
+ path.SetPointCount(nCharArraySafe.ValueOrDie());
+
+ for (int32_t i = 0; i < nCharArray - 1; i++) {
+ path.SetPoint(
+ i * 2,
+ rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
+ rcClient.bottom, FXPT_MOVETO);
+ path.SetPoint(
+ i * 2 + 1,
+ rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
+ rcClient.top, FXPT_LINETO);
+ }
+ if (path.GetPointCount() > 0)
+ pDevice->DrawPath(
+ &path, pUser2Device, &gsd, 0,
+ CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255),
+ FXFILL_ALTERNATE);
+ } break;
+ case PBS_DASH: {
+ CFX_GraphStateData gsd;
+ gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
+
+ gsd.SetDashCount(2);
+ gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().nDash;
+ gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().nGap;
+ gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase;
+
+ CFX_PathData path;
+ path.SetPointCount(nCharArraySafe.ValueOrDie());
+
+ for (int32_t i = 0; i < nCharArray - 1; i++) {
+ path.SetPoint(
+ i * 2,
+ rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
+ rcClient.bottom, FXPT_MOVETO);
+ path.SetPoint(
+ i * 2 + 1,
+ rcClient.left +
+ ((rcClient.right - rcClient.left) / nCharArray) * (i + 1),
+ rcClient.top, FXPT_LINETO);
+ }
+ if (path.GetPointCount() > 0)
+ pDevice->DrawPath(
+ &path, pUser2Device, &gsd, 0,
+ CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255),
+ FXFILL_ALTERNATE);
+ } break;
+ }
+ }
+
+ 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(), GetTransparency()),
+ CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), 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,
+ GetCreationParam().pSpellCheck);
+ }
}
-FX_BOOL CPWL_Edit::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonDown(point,nFlag);
+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)
- InvalidateRect();
+ if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) {
+ if (m_bMouseDown)
+ InvalidateRect();
- m_bMouseDown = TRUE;
- SetCapture();
+ m_bMouseDown = TRUE;
+ SetCapture();
- m_pEdit->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- }
+ m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
+ }
- return TRUE;
+ return TRUE;
}
-FX_BOOL CPWL_Edit::OnLButtonDblClk(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonDblClk(point, nFlag);
+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();
- }
+ if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) {
+ m_pEdit->SelectAll();
+ }
- return TRUE;
+ 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;
-
- 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);
-
- int32_t nSuggest = sSuggestWords.GetSize();
-
- for (int32_t nWord=0; nWord<nSuggest; nWord++)
- {
- pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SUGGEST+nWord, sSuggestWords[nWord].UTF8Decode());
- }
-
- if (nSuggest > 0)
- pSH->AppendMenuItem(hPopup, 0, L"");
-
- ptPopup = GetWordRightBottomPoint(wrLatin.EndPos);
- }
- }
- }
- }
-
- IPWL_Provider* pProvider = GetProvider();
-
- if (HasFlag(PES_UNDO))
- {
- pSH->AppendMenuItem(hPopup, WM_PWLEDIT_UNDO,
- pProvider ? pProvider->LoadPopupMenuString(0) : L"&Undo");
- pSH->AppendMenuItem(hPopup, WM_PWLEDIT_REDO,
- pProvider ? pProvider->LoadPopupMenuString(1) : L"&Redo");
- pSH->AppendMenuItem(hPopup, 0, L"");
-
- if (!m_pEdit->CanUndo())
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_UNDO, FALSE);
- if (!m_pEdit->CanRedo())
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_REDO, FALSE);
- }
-
- pSH->AppendMenuItem(hPopup, WM_PWLEDIT_CUT,
- pProvider ? pProvider->LoadPopupMenuString(2) : L"Cu&t");
- pSH->AppendMenuItem(hPopup, WM_PWLEDIT_COPY,
- pProvider ? pProvider->LoadPopupMenuString(3) : L"&Copy");
- pSH->AppendMenuItem(hPopup, WM_PWLEDIT_PASTE,
- pProvider ? pProvider->LoadPopupMenuString(4) : L"&Paste");
- pSH->AppendMenuItem(hPopup, WM_PWLEDIT_DELETE,
- pProvider ? pProvider->LoadPopupMenuString(5) : L"&Delete");
-
- CFX_WideString swText = pSH->GetClipboardText(GetAttachedHWnd());
- if (swText.IsEmpty())
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
-
- if (!m_pEdit->IsSelected())
- {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
- }
-
- if (IsReadOnly())
- {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
- }
-
- if (HasFlag(PES_PASSWORD))
- {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
- }
-
- if (HasFlag(PES_NOREAD))
- {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
- }
-
- pSH->AppendMenuItem(hPopup, 0, L"");
- pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SELECTALL,
- pProvider ? pProvider->LoadPopupMenuString(6) : L"&Select All");
-
- if (m_pEdit->GetTotalWords() == 0)
- {
- pSH->EnableMenuItem(hPopup, WM_PWLEDIT_SELECTALL, FALSE);
- }
-
- int32_t x, y;
- PWLtoWnd(ptPopup, x, y);
- pSH->ClientToScreen(GetAttachedHWnd(), x, y);
- pSH->SetCursor(FXCT_ARROW);
- int32_t nCmd = pSH->TrackPopupMenu(hPopup,
- x,
- y,
- GetAttachedHWnd());
-
-
- switch (nCmd)
- {
- case WM_PWLEDIT_UNDO:
- Undo();
- break;
- case WM_PWLEDIT_REDO:
- Redo();
- break;
- case WM_PWLEDIT_CUT:
- CutText();
- break;
- case WM_PWLEDIT_COPY:
- CopyText();
- break;
- case WM_PWLEDIT_PASTE:
- PasteText();
- break;
- case WM_PWLEDIT_DELETE:
- Clear();
- break;
- case WM_PWLEDIT_SELECTALL:
- SelectAll();
- break;
- case WM_PWLEDIT_SUGGEST + 0:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[0].UTF8Decode().c_str());
- break;
- case WM_PWLEDIT_SUGGEST + 1:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[1].UTF8Decode().c_str());
- break;
- case WM_PWLEDIT_SUGGEST + 2:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[2].UTF8Decode().c_str());
- break;
- case WM_PWLEDIT_SUGGEST + 3:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[3].UTF8Decode().c_str());
- break;
- case WM_PWLEDIT_SUGGEST + 4:
- SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
- ReplaceSel(sSuggestWords[4].UTF8Decode().c_str());
- break;
- default:
- break;
- }
-
- pSH->DestroyMenu(hPopup);
-
- return TRUE;
+#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;
+
+ 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);
+
+ int32_t nSuggest = sSuggestWords.GetSize();
+
+ for (int32_t nWord = 0; nWord < nSuggest; nWord++) {
+ pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SUGGEST + nWord,
+ sSuggestWords[nWord].UTF8Decode());
+ }
+
+ if (nSuggest > 0)
+ pSH->AppendMenuItem(hPopup, 0, L"");
+
+ ptPopup = GetWordRightBottomPoint(wrLatin.EndPos);
+ }
+ }
+ }
+ }
+
+ IPWL_Provider* pProvider = GetProvider();
+
+ if (HasFlag(PES_UNDO)) {
+ pSH->AppendMenuItem(
+ hPopup, WM_PWLEDIT_UNDO,
+ pProvider ? pProvider->LoadPopupMenuString(0) : L"&Undo");
+ pSH->AppendMenuItem(
+ hPopup, WM_PWLEDIT_REDO,
+ pProvider ? pProvider->LoadPopupMenuString(1) : L"&Redo");
+ pSH->AppendMenuItem(hPopup, 0, L"");
+
+ if (!m_pEdit->CanUndo())
+ pSH->EnableMenuItem(hPopup, WM_PWLEDIT_UNDO, FALSE);
+ if (!m_pEdit->CanRedo())
+ pSH->EnableMenuItem(hPopup, WM_PWLEDIT_REDO, FALSE);
+ }
+
+ pSH->AppendMenuItem(hPopup, WM_PWLEDIT_CUT,
+ pProvider ? pProvider->LoadPopupMenuString(2) : L"Cu&t");
+ pSH->AppendMenuItem(hPopup, WM_PWLEDIT_COPY,
+ pProvider ? pProvider->LoadPopupMenuString(3) : L"&Copy");
+ pSH->AppendMenuItem(
+ hPopup, WM_PWLEDIT_PASTE,
+ pProvider ? pProvider->LoadPopupMenuString(4) : L"&Paste");
+ pSH->AppendMenuItem(
+ hPopup, WM_PWLEDIT_DELETE,
+ pProvider ? pProvider->LoadPopupMenuString(5) : L"&Delete");
+
+ CFX_WideString swText = pSH->GetClipboardText(GetAttachedHWnd());
+ if (swText.IsEmpty())
+ pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
+
+ if (!m_pEdit->IsSelected()) {
+ pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
+ pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
+ pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
+ }
+
+ if (IsReadOnly()) {
+ pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
+ pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
+ pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
+ }
+
+ if (HasFlag(PES_PASSWORD)) {
+ pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
+ pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
+ }
+
+ if (HasFlag(PES_NOREAD)) {
+ pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
+ pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
+ }
+
+ pSH->AppendMenuItem(hPopup, 0, L"");
+ pSH->AppendMenuItem(
+ hPopup, WM_PWLEDIT_SELECTALL,
+ pProvider ? pProvider->LoadPopupMenuString(6) : L"&Select All");
+
+ if (m_pEdit->GetTotalWords() == 0) {
+ pSH->EnableMenuItem(hPopup, WM_PWLEDIT_SELECTALL, FALSE);
+ }
+
+ int32_t x, y;
+ PWLtoWnd(ptPopup, x, y);
+ pSH->ClientToScreen(GetAttachedHWnd(), x, y);
+ pSH->SetCursor(FXCT_ARROW);
+ int32_t nCmd = pSH->TrackPopupMenu(hPopup, x, y, GetAttachedHWnd());
+
+ switch (nCmd) {
+ case WM_PWLEDIT_UNDO:
+ Undo();
+ break;
+ case WM_PWLEDIT_REDO:
+ Redo();
+ break;
+ case WM_PWLEDIT_CUT:
+ CutText();
+ break;
+ case WM_PWLEDIT_COPY:
+ CopyText();
+ break;
+ case WM_PWLEDIT_PASTE:
+ PasteText();
+ break;
+ case WM_PWLEDIT_DELETE:
+ Clear();
+ break;
+ case WM_PWLEDIT_SELECTALL:
+ SelectAll();
+ break;
+ case WM_PWLEDIT_SUGGEST + 0:
+ SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
+ m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
+ ReplaceSel(sSuggestWords[0].UTF8Decode().c_str());
+ break;
+ case WM_PWLEDIT_SUGGEST + 1:
+ SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
+ m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
+ ReplaceSel(sSuggestWords[1].UTF8Decode().c_str());
+ break;
+ case WM_PWLEDIT_SUGGEST + 2:
+ SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
+ m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
+ ReplaceSel(sSuggestWords[2].UTF8Decode().c_str());
+ break;
+ case WM_PWLEDIT_SUGGEST + 3:
+ SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
+ m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
+ ReplaceSel(sSuggestWords[3].UTF8Decode().c_str());
+ break;
+ case WM_PWLEDIT_SUGGEST + 4:
+ SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),
+ m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
+ ReplaceSel(sSuggestWords[4].UTF8Decode().c_str());
+ break;
+ default:
+ break;
+ }
+
+ pSH->DestroyMenu(hPopup);
+
+ return TRUE;
}
-void CPWL_Edit::OnSetFocus()
-{
- SetEditCaret(TRUE);
+void CPWL_Edit::OnSetFocus() {
+ SetEditCaret(TRUE);
- if (!IsReadOnly())
- {
- if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler())
- pFocusHandler->OnSetFocus(this);
- }
+ if (!IsReadOnly()) {
+ if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler())
+ pFocusHandler->OnSetFocus(this);
+ }
- m_bFocus = TRUE;
+ m_bFocus = TRUE;
}
-void CPWL_Edit::OnKillFocus()
-{
- ShowVScrollBar(FALSE);
+void CPWL_Edit::OnKillFocus() {
+ ShowVScrollBar(FALSE);
- m_pEdit->SelectNone();
- SetCaret(FALSE, CPDF_Point(0.0f,0.0f), CPDF_Point(0.0f,0.0f));
+ m_pEdit->SelectNone();
+ SetCaret(FALSE, CPDF_Point(0.0f, 0.0f), CPDF_Point(0.0f, 0.0f));
- SetCharSet(0);
+ SetCharSet(0);
- if (!IsReadOnly())
- {
- if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler())
- pFocusHandler->OnKillFocus(this);
- }
+ if (!IsReadOnly()) {
+ if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler())
+ pFocusHandler->OnKillFocus(this);
+ }
- m_bFocus = FALSE;
+ m_bFocus = FALSE;
}
-void CPWL_Edit::SetHorzScale(int32_t nHorzScale, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pEdit->SetHorzScale(nHorzScale, bPaint);
+void CPWL_Edit::SetHorzScale(int32_t nHorzScale, FX_BOOL bPaint /* = TRUE*/) {
+ m_pEdit->SetHorzScale(nHorzScale, bPaint);
}
-void CPWL_Edit::SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pEdit->SetCharSpace(fCharSpace, bPaint);
+void CPWL_Edit::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);
+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);
+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())
- {
- int32_t nStart = -1;
- int32_t nEnd = -1;
+CPVT_WordRange CPWL_Edit::GetSelectWordRange() const {
+ if (m_pEdit->IsSelected()) {
+ int32_t nStart = -1;
+ int32_t nEnd = -1;
- m_pEdit->GetSel(nStart, nEnd);
+ m_pEdit->GetSel(nStart, nEnd);
- CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStart);
- CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEnd);
+ CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStart);
+ CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEnd);
- return CPVT_WordRange(wpStart,wpEnd);
- }
+ return CPVT_WordRange(wpStart, wpEnd);
+ }
- return CPVT_WordRange();
+ 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);
+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";
- }
+ if (sEdit.GetLength() > 0) {
+ sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit
+ << "ET\n";
+ }
- return sRet.GetByteString();
+ return sRet.GetByteString();
}
-CFX_ByteString CPWL_Edit::GetCaretAppearanceStream(const CPDF_Point & ptOffset) const
-{
- if (m_pEditCaret)
- return m_pEditCaret->GetCaretAppearanceStream(ptOffset);
+CFX_ByteString CPWL_Edit::GetCaretAppearanceStream(
+ const CPDF_Point& ptOffset) const {
+ if (m_pEditCaret)
+ return m_pEditCaret->GetCaretAppearanceStream(ptOffset);
- return CFX_ByteString();
+ return CFX_ByteString();
}
-CPDF_Point CPWL_Edit::GetWordRightBottomPoint(const CPVT_WordPlace& wpWord)
-{
- CPDF_Point pt(0.0f, 0.0f);
+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);
- }
+ 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);
- }
+ pIterator->SetAt(wpOld);
+ }
- return pt;
+ return pt;
}
-FX_BOOL CPWL_Edit::IsTextFull() const
-{
- return m_pEdit->IsTextFull();
+FX_BOOL CPWL_Edit::IsTextFull() const {
+ return m_pEdit->IsTextFull();
}
-FX_FLOAT CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont, const CPDF_Rect& rcPlate, int32_t nCharArray)
-{
- if (pFont && !pFont->IsStandardFont())
- {
- FX_RECT rcBBox;
- pFont->GetFontBBox(rcBBox);
+FX_FLOAT CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont,
+ const CPDF_Rect& rcPlate,
+ int32_t 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();
+ 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 xdiv < ydiv ? xdiv : ydiv;
+ }
- return 0.0f;
+ return 0.0f;
}
-void CPWL_Edit::SetCharArray(int32_t nCharArray)
-{
- if (HasFlag(PES_CHARARRAY) && nCharArray > 0)
- {
- m_pEdit->SetCharArray(nCharArray);
- m_pEdit->SetTextOverflow(TRUE);
-
- if (HasFlag(PWS_AUTOFONTSIZE))
- {
- if (IFX_Edit_FontMap* pFontMap = GetFontMap())
- {
- FX_FLOAT fFontSize = GetCharArrayAutoFontSize(pFontMap->GetPDFFont(0), GetClientRect(), nCharArray);
- if (fFontSize > 0.0f)
- {
- m_pEdit->SetAutoFontSize(FALSE);
- m_pEdit->SetFontSize(fFontSize);
- }
- }
- }
- }
+void CPWL_Edit::SetCharArray(int32_t nCharArray) {
+ if (HasFlag(PES_CHARARRAY) && nCharArray > 0) {
+ m_pEdit->SetCharArray(nCharArray);
+ m_pEdit->SetTextOverflow(TRUE);
+
+ if (HasFlag(PWS_AUTOFONTSIZE)) {
+ if (IFX_Edit_FontMap* pFontMap = GetFontMap()) {
+ FX_FLOAT fFontSize = GetCharArrayAutoFontSize(
+ pFontMap->GetPDFFont(0), GetClientRect(), nCharArray);
+ if (fFontSize > 0.0f) {
+ m_pEdit->SetAutoFontSize(FALSE);
+ m_pEdit->SetFontSize(fFontSize);
+ }
+ }
+ }
+ }
}
-void CPWL_Edit::SetLimitChar(int32_t nLimitChar)
-{
- m_pEdit->SetLimitChar(nLimitChar);
+void CPWL_Edit::SetLimitChar(int32_t nLimitChar) {
+ m_pEdit->SetLimitChar(nLimitChar);
}
-void CPWL_Edit::ReplaceSel(const FX_WCHAR* csText)
-{
- m_pEdit->Clear();
- m_pEdit->InsertText(csText);
+void CPWL_Edit::ReplaceSel(const FX_WCHAR* csText) {
+ m_pEdit->Clear();
+ m_pEdit->InsertText(csText);
}
-CPDF_Rect CPWL_Edit::GetFocusRect() const
-{
- return CPDF_Rect();
+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);
- }
- }
- }
+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();
- }
+FX_BOOL CPWL_Edit::IsVScrollBarVisible() const {
+ if (CPWL_ScrollBar* pScroll = GetVScrollBar()) {
+ return pScroll->IsVisible();
+ }
- return FALSE;
+ return FALSE;
}
-void CPWL_Edit::EnableSpellCheck(FX_BOOL bEnabled)
-{
- if (bEnabled)
- AddFlag(PES_SPELLCHECK);
- else
- RemoveFlag(PES_SPELLCHECK);
+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;
+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.
+*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::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;
- int32_t 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())
- {
- int32_t nOldCharSet = GetCharSet();
- int32_t 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::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;
+ int32_t 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()) {
+ int32_t nOldCharSet = GetCharSet();
+ int32_t 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;
+ }
+ }
-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 += GetFontSize();
- }
- else
- {
- ptScroll.y -= GetFontSize();
- }
- SetScrollPos(ptScroll);
-
- return TRUE;
- }
-
- return FALSE;
+ return bRet;
}
-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);
- }
-}
+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 += GetFontSize();
+ } else {
+ ptScroll.y -= GetFontSize();
+ }
+ SetScrollPos(ptScroll);
+
+ return TRUE;
+ }
-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);
- }
+ return FALSE;
}
-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::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::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::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::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::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::OnSetText(const CPVT_WordPlace& place, const CPVT_WordPlace& 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::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::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::OnAddUndo(IFX_Edit_UndoItem* pUndoItem)
-{
- if (m_pEditNotify)
- {
- m_pEditNotify->OnAddUndo(this);
- }
+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);
+ }
}
-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;
+void CPWL_Edit::OnAddUndo(IFX_Edit_UndoItem* pUndoItem) {
+ if (m_pEditNotify) {
+ m_pEditNotify->OnAddUndo(this);
+ }
}
-CPVT_WordRange CPWL_Edit::GetLatinWordsRange(const CPDF_Point& point) const
-{
- return GetSameWordsRange(m_pEdit->SearchWordPlace(point), TRUE, FALSE);
+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 CPVT_WordPlace & place) const
-{
- return GetSameWordsRange(place, TRUE, FALSE);
+CPVT_WordRange CPWL_Edit::GetLatinWordsRange(const CPDF_Point& point) const {
+ return GetSameWordsRange(m_pEdit->SearchWordPlace(point), TRUE, FALSE);
}
-CPVT_WordRange CPWL_Edit::GetArabicWordsRange(const CPVT_WordPlace & place) const
-{
- return GetSameWordsRange(place, FALSE, TRUE);
+CPVT_WordRange CPWL_Edit::GetLatinWordsRange(
+ const CPVT_WordPlace& place) const {
+ return GetSameWordsRange(place, TRUE, FALSE);
}
-#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;
+CPVT_WordRange CPWL_Edit::GetArabicWordsRange(
+ const CPVT_WordPlace& place) const {
+ return GetSameWordsRange(place, FALSE, TRUE);
}
-void CPWL_Edit::AjustArabicWords(const CPVT_WordRange& wr)
-{
+#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::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::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);
+ 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 0d14587f66..eb6324ee7e 100644
--- a/fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp
@@ -12,172 +12,146 @@
#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))
+#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()
+ : 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);
+CPWL_EditCtrl::~CPWL_EditCtrl() {
+ IFX_Edit::DelEdit(m_pEdit);
}
-void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp)
-{
- cp.eCursorType = FXCT_VBEAM;
+void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp) {
+ cp.eCursorType = FXCT_VBEAM;
}
-void CPWL_EditCtrl::OnCreated()
-{
- SetFontSize(GetCreationParam().fFontSize);
+void CPWL_EditCtrl::OnCreated() {
+ SetFontSize(GetCreationParam().fFontSize);
- m_pEdit->SetFontMap(GetFontMap());
- m_pEdit->SetNotify(this);
- m_pEdit->Initialize();
+ m_pEdit->SetFontMap(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);
+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);
+ mt.Transform(point1.x, point1.y);
+ mt.Transform(point2.x, point2.y);
- return point2.y == point1.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::SetCursor() {
+ if (IsValid()) {
+ if (IFX_SystemHandler* pSH = GetSystemHandler()) {
+ if (IsWndHorV())
+ pSH->SetCursor(FXCT_VBEAM);
+ else
+ pSH->SetCursor(FXCT_HBEAM);
}
-}
-
-void CPWL_EditCtrl::RePosChildWnd()
-{
- m_pEdit->SetPlateRect(GetClientRect());
-}
-
-void CPWL_EditCtrl::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam)
-{
- CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam);
-
- switch (msg)
- {
- case PNM_SETSCROLLINFO:
- switch (wParam)
- {
- case SBT_VSCROLL:
- if (CPWL_Wnd * pChild = GetVScrollBar())
- {
- pChild->OnNotify(pWnd,PNM_SETSCROLLINFO,wParam,lParam);
- }
- break;
- }
- break;
- case PNM_SETSCROLLPOS:
- switch (wParam)
- {
- case SBT_VSCROLL:
- if (CPWL_Wnd * pChild = GetVScrollBar())
- {
- pChild->OnNotify(pWnd,PNM_SETSCROLLPOS,wParam,lParam);
- }
- break;
- }
- break;
- case PNM_SCROLLWINDOW:
- {
- FX_FLOAT fPos = *(FX_FLOAT*)lParam;
- switch (wParam)
- {
- case SBT_VSCROLL:
- m_pEdit->SetScrollPos(CPDF_Point(m_pEdit->GetScrollPos().x,fPos));
- break;
- }
- }
- break;
- case PNM_SETCARETINFO:
- {
- if (PWL_CARET_INFO * pCaretInfo = (PWL_CARET_INFO *)wParam)
- {
- SetCaret(pCaretInfo->bVisible,
- pCaretInfo->ptHead,
- pCaretInfo->ptFoot);
- }
- }
- break;
- }
-}
-
-void CPWL_EditCtrl::CreateChildWnd(const PWL_CREATEPARAM & cp)
-{
- if (!IsReadOnly())
- CreateEditCaret(cp);
-}
-
-void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM & cp)
-{
- if (!m_pEditCaret)
- {
- m_pEditCaret = new CPWL_Caret;
- m_pEditCaret->SetInvalidRect(GetClientRect());
-
- PWL_CREATEPARAM ecp = cp;
- ecp.pParentWnd = this;
- ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP;
- ecp.dwBorderWidth = 0;
- ecp.nBorderStyle = PBS_SOLID;
- ecp.rcRectWnd = 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;
+ }
+}
+
+void CPWL_EditCtrl::RePosChildWnd() {
+ m_pEdit->SetPlateRect(GetClientRect());
+}
+
+void CPWL_EditCtrl::OnNotify(CPWL_Wnd* pWnd,
+ FX_DWORD msg,
+ intptr_t wParam,
+ intptr_t lParam) {
+ CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
+
+ switch (msg) {
+ case PNM_SETSCROLLINFO:
+ switch (wParam) {
+ case SBT_VSCROLL:
+ if (CPWL_Wnd* pChild = GetVScrollBar()) {
+ pChild->OnNotify(pWnd, PNM_SETSCROLLINFO, wParam, lParam);
+ }
+ break;
+ }
+ break;
+ case PNM_SETSCROLLPOS:
+ switch (wParam) {
+ case SBT_VSCROLL:
+ if (CPWL_Wnd* pChild = GetVScrollBar()) {
+ pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam);
+ }
+ break;
+ }
+ break;
+ case PNM_SCROLLWINDOW: {
+ FX_FLOAT fPos = *(FX_FLOAT*)lParam;
+ switch (wParam) {
+ case SBT_VSCROLL:
+ m_pEdit->SetScrollPos(CPDF_Point(m_pEdit->GetScrollPos().x, fPos));
+ break;
+ }
+ } break;
+ case PNM_SETCARETINFO: {
+ if (PWL_CARET_INFO* pCaretInfo = (PWL_CARET_INFO*)wParam) {
+ SetCaret(pCaretInfo->bVisible, pCaretInfo->ptHead, pCaretInfo->ptFoot);
+ }
+ } break;
+ }
+}
+
+void CPWL_EditCtrl::CreateChildWnd(const PWL_CREATEPARAM& cp) {
+ if (!IsReadOnly())
+ CreateEditCaret(cp);
+}
+
+void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM& cp) {
+ if (!m_pEditCaret) {
+ m_pEditCaret = new CPWL_Caret;
+ m_pEditCaret->SetInvalidRect(GetClientRect());
+
+ PWL_CREATEPARAM ecp = cp;
+ ecp.pParentWnd = this;
+ ecp.dwFlags = PWS_CHILD | PWS_NOREFRESHCLIP;
+ ecp.dwBorderWidth = 0;
+ ecp.nBorderStyle = PBS_SOLID;
+ ecp.rcRectWnd = 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);
+ FX_BOOL bRet = CPWL_Wnd::OnKeyDown(nChar, nFlag);
- //FILTER
- switch (nChar)
- {
+ // FILTER
+ switch (nChar) {
default:
- return FALSE;
+ return FALSE;
case FWL_VKEY_Delete:
case FWL_VKEY_Up:
case FWL_VKEY_Down:
@@ -196,527 +170,460 @@ FX_BOOL CPWL_EditCtrl::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag)
case 'x':
case 'a':
case 'z':
- break;
- }
+ break;
+ }
- if (nChar == FWL_VKEY_Delete)
- {
- if (m_pEdit->IsSelected())
- nChar = FWL_VKEY_Unknown;
- }
+ 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;
- }
+ 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;
+ return bRet;
}
-FX_BOOL CPWL_EditCtrl::OnChar(FX_WORD nChar, FX_DWORD nFlag)
-{
- if (m_bMouseDown) return TRUE;
-
- CPWL_Wnd::OnChar(nChar,nFlag);
+FX_BOOL CPWL_EditCtrl::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
+ if (m_bMouseDown)
+ return TRUE;
- //FILTER
- switch (nChar)
- {
- case 0x0A:
- case 0x1B:
- return FALSE;
- default:
- break;
- }
+ CPWL_Wnd::OnChar(nChar, nFlag);
- FX_BOOL bCtrl = IsCTRLpressed(nFlag);
- FX_BOOL bAlt = IsALTpressed(nFlag);
- FX_BOOL bShift = IsSHIFTpressed(nFlag);
-
- FX_WORD word = nChar;
-
- if (bCtrl && !bAlt)
- {
- switch (nChar)
- {
- case 'C' - 'A' + 1:
- CopyText();
- return TRUE;
- case 'V' - 'A' + 1:
- PasteText();
- return TRUE;
- case 'X' - 'A' + 1:
- CutText();
- return TRUE;
- case 'A' - 'A' + 1:
- SelectAll();
- return TRUE;
- case 'Z' - 'A' + 1:
- if (bShift)
- Redo();
- else
- Undo();
- return TRUE;
- default:
- if (nChar < 32)
- return FALSE;
- }
+ // FILTER
+ switch (nChar) {
+ case 0x0A:
+ case 0x1B:
+ return FALSE;
+ default:
+ break;
+ }
+
+ FX_BOOL bCtrl = IsCTRLpressed(nFlag);
+ FX_BOOL bAlt = IsALTpressed(nFlag);
+ FX_BOOL bShift = IsSHIFTpressed(nFlag);
+
+ FX_WORD word = nChar;
+
+ if (bCtrl && !bAlt) {
+ switch (nChar) {
+ case 'C' - 'A' + 1:
+ CopyText();
+ return TRUE;
+ case 'V' - 'A' + 1:
+ PasteText();
+ return TRUE;
+ case 'X' - 'A' + 1:
+ CutText();
+ return TRUE;
+ case 'A' - 'A' + 1:
+ SelectAll();
+ return TRUE;
+ case 'Z' - 'A' + 1:
+ if (bShift)
+ Redo();
+ else
+ Undo();
+ return TRUE;
+ default:
+ if (nChar < 32)
+ return FALSE;
}
+ }
- if (IsReadOnly()) return TRUE;
+ if (IsReadOnly())
+ return TRUE;
- if (m_pEdit->IsSelected() && word == FWL_VKEY_Back)
- word = FWL_VKEY_Unknown;
+ if (m_pEdit->IsSelected() && word == FWL_VKEY_Back)
+ word = FWL_VKEY_Unknown;
- Clear();
+ Clear();
- switch (word)
- {
+ switch (word) {
case FWL_VKEY_Back:
- Backspace();
- break;
+ Backspace();
+ break;
case FWL_VKEY_Return:
- InsertReturn();
- break;
+ InsertReturn();
+ break;
case FWL_VKEY_Unknown:
- break;
+ break;
default:
- if (IsINSERTpressed(nFlag))
- Delete();
- InsertWord(word, GetCharSet());
- break;
- }
+ if (IsINSERTpressed(nFlag))
+ Delete();
+ InsertWord(word, GetCharSet());
+ break;
+ }
- return TRUE;
+ return TRUE;
}
-FX_BOOL CPWL_EditCtrl::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonDown(point,nFlag);
+FX_BOOL CPWL_EditCtrl::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) {
+ CPWL_Wnd::OnLButtonDown(point, nFlag);
- if (ClientHitTest(point))
- {
- if (m_bMouseDown)
- InvalidateRect();
+ if (ClientHitTest(point)) {
+ if (m_bMouseDown)
+ InvalidateRect();
- m_bMouseDown = TRUE;
- SetCapture();
+ m_bMouseDown = TRUE;
+ SetCapture();
- m_pEdit->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
- }
+ m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
+ }
- return TRUE;
+ return TRUE;
}
-FX_BOOL CPWL_EditCtrl::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonUp(point,nFlag);
+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) && !IsFocused())
- SetFocus();
+ if (m_bMouseDown) {
+ // can receive keybord message
+ if (ClientHitTest(point) && !IsFocused())
+ SetFocus();
- ReleaseCapture();
- m_bMouseDown = FALSE;
- }
+ ReleaseCapture();
+ m_bMouseDown = FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-FX_BOOL CPWL_EditCtrl::OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnMouseMove(point,nFlag);
+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);
+ if (m_bMouseDown)
+ m_pEdit->OnMouseMove(point, FALSE, FALSE);
- return TRUE;
+ return TRUE;
}
-CPDF_Rect CPWL_EditCtrl::GetContentRect() const
-{
- return m_pEdit->GetContentRect();
+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);
+void CPWL_EditCtrl::SetEditCaret(FX_BOOL bVisible) {
+ CPDF_Point ptHead(0, 0), ptFoot(0, 0);
- if (bVisible)
- {
- GetCaretInfo(ptHead,ptFoot);
- }
+ if (bVisible) {
+ GetCaretInfo(ptHead, ptFoot);
+ }
- CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace();
- 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;
- }
+ CPVT_WordPlace wpTemp = m_pEdit->GetCaretWordPlace();
+ 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(int32_t& x, int32_t& y) const
-{
- CPDF_Point ptHead(0,0), ptFoot(0,0);
+void CPWL_EditCtrl::GetCaretPos(int32_t& x, int32_t& y) const {
+ CPDF_Point ptHead(0, 0), ptFoot(0, 0);
- GetCaretInfo(ptHead,ptFoot);
+ GetCaretInfo(ptHead, ptFoot);
- PWLtoWnd(ptHead, x, y);
+ 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;
+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);
- }
+ m_pEditCaret->SetCaret(bVisible, ptHead, ptFoot);
+ }
}
-FX_BOOL CPWL_EditCtrl::IsModified() const
-{
- return m_pEdit->IsModified();
+FX_BOOL CPWL_EditCtrl::IsModified() const {
+ return m_pEdit->IsModified();
}
-CFX_WideString CPWL_EditCtrl::GetText() const
-{
- return m_pEdit->GetText();
+CFX_WideString CPWL_EditCtrl::GetText() const {
+ return m_pEdit->GetText();
}
-void CPWL_EditCtrl::SetSel(int32_t nStartChar,int32_t nEndChar)
-{
- m_pEdit->SetSel(nStartChar, nEndChar);
+void CPWL_EditCtrl::SetSel(int32_t nStartChar, int32_t nEndChar) {
+ m_pEdit->SetSel(nStartChar, nEndChar);
}
-void CPWL_EditCtrl::GetSel(int32_t & nStartChar, int32_t & nEndChar ) const
-{
- m_pEdit->GetSel(nStartChar, nEndChar);
+void CPWL_EditCtrl::GetSel(int32_t& nStartChar, int32_t& nEndChar) const {
+ m_pEdit->GetSel(nStartChar, nEndChar);
}
-void CPWL_EditCtrl::Clear()
-{
- if (!IsReadOnly())
- m_pEdit->Clear();
+void CPWL_EditCtrl::Clear() {
+ if (!IsReadOnly())
+ m_pEdit->Clear();
}
-void CPWL_EditCtrl::SelectAll()
-{
- m_pEdit->SelectAll();
+void CPWL_EditCtrl::SelectAll() {
+ m_pEdit->SelectAll();
}
-void CPWL_EditCtrl::Paint()
-{
- if (m_pEdit)
- m_pEdit->Paint();
+void CPWL_EditCtrl::Paint() {
+ if (m_pEdit)
+ m_pEdit->Paint();
}
-void CPWL_EditCtrl::EnableRefresh(FX_BOOL bRefresh)
-{
- if (m_pEdit)
- m_pEdit->EnableRefresh(bRefresh);
+void CPWL_EditCtrl::EnableRefresh(FX_BOOL bRefresh) {
+ if (m_pEdit)
+ m_pEdit->EnableRefresh(bRefresh);
}
-int32_t CPWL_EditCtrl::GetCaret() const
-{
- if (m_pEdit)
- return m_pEdit->GetCaret();
+int32_t CPWL_EditCtrl::GetCaret() const {
+ if (m_pEdit)
+ return m_pEdit->GetCaret();
- return -1;
+ return -1;
}
-void CPWL_EditCtrl::SetCaret(int32_t nPos)
-{
- if (m_pEdit)
- m_pEdit->SetCaret(nPos);
+void CPWL_EditCtrl::SetCaret(int32_t nPos) {
+ if (m_pEdit)
+ m_pEdit->SetCaret(nPos);
}
-int32_t CPWL_EditCtrl::GetTotalWords() const
-{
- if (m_pEdit)
- return m_pEdit->GetTotalWords();
+int32_t CPWL_EditCtrl::GetTotalWords() const {
+ if (m_pEdit)
+ return m_pEdit->GetTotalWords();
- return 0;
+ return 0;
}
-void CPWL_EditCtrl::SetScrollPos(const CPDF_Point& point)
-{
- if (m_pEdit)
- m_pEdit->SetScrollPos(point);
+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();
+CPDF_Point CPWL_EditCtrl::GetScrollPos() const {
+ if (m_pEdit)
+ return m_pEdit->GetScrollPos();
- return CPDF_Point(0.0f, 0.0f);
+ return CPDF_Point(0.0f, 0.0f);
}
-CPDF_Font * CPWL_EditCtrl::GetCaretFont() const
-{
- int32_t nFontIndex = 0;
+CPDF_Font* CPWL_EditCtrl::GetCaretFont() const {
+ int32_t nFontIndex = 0;
- if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator())
- {
- pIterator->SetAt(m_pEdit->GetCaret());
- CPVT_Word word;
- CPVT_Section section;
- if (pIterator->GetWord(word))
- {
- nFontIndex = word.nFontIndex;
- }
- else if (HasFlag(PES_RICH))
- {
- if (pIterator->GetSection(section))
- {
- nFontIndex = section.WordProps.nFontIndex;
- }
- }
+ if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) {
+ pIterator->SetAt(m_pEdit->GetCaret());
+ CPVT_Word word;
+ CPVT_Section section;
+ if (pIterator->GetWord(word)) {
+ nFontIndex = word.nFontIndex;
+ } else if (HasFlag(PES_RICH)) {
+ if (pIterator->GetSection(section)) {
+ nFontIndex = section.WordProps.nFontIndex;
+ }
}
+ }
- if (IFX_Edit_FontMap* pFontMap = GetFontMap())
- return pFontMap->GetPDFFont(nFontIndex);
-
- return NULL;
-}
-
-FX_FLOAT CPWL_EditCtrl::GetCaretFontSize() const
-{
- FX_FLOAT fFontSize = GetFontSize();
-
- if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator())
- {
- pIterator->SetAt(m_pEdit->GetCaret());
- CPVT_Word word;
- CPVT_Section section;
- if (pIterator->GetWord(word))
- {
- fFontSize = word.fFontSize;
- }
- else if (HasFlag(PES_RICH))
- {
- if (pIterator->GetSection(section))
- {
- fFontSize = section.WordProps.fFontSize;
- }
- }
- }
+ if (IFX_Edit_FontMap* pFontMap = GetFontMap())
+ return pFontMap->GetPDFFont(nFontIndex);
- return fFontSize;
+ return NULL;
}
-void CPWL_EditCtrl::SetText(const FX_WCHAR* csText)
-{
- m_pEdit->SetText(csText);
-}
+FX_FLOAT CPWL_EditCtrl::GetCaretFontSize() const {
+ FX_FLOAT fFontSize = GetFontSize();
-void CPWL_EditCtrl::CopyText()
-{
-}
+ 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;
+ }
+ }
+ }
-void CPWL_EditCtrl::PasteText()
-{
+ return fFontSize;
}
-void CPWL_EditCtrl::CutText()
-{
+void CPWL_EditCtrl::SetText(const FX_WCHAR* csText) {
+ m_pEdit->SetText(csText);
}
-void CPWL_EditCtrl::ShowVScrollBar(FX_BOOL bShow)
-{
-}
+void CPWL_EditCtrl::CopyText() {}
+
+void CPWL_EditCtrl::PasteText() {}
-void CPWL_EditCtrl::InsertText(const FX_WCHAR* csText)
-{
- if (!IsReadOnly())
- m_pEdit->InsertText(csText);
+void CPWL_EditCtrl::CutText() {}
+
+void CPWL_EditCtrl::ShowVScrollBar(FX_BOOL bShow) {}
+
+void CPWL_EditCtrl::InsertText(const FX_WCHAR* csText) {
+ if (!IsReadOnly())
+ m_pEdit->InsertText(csText);
}
-void CPWL_EditCtrl::InsertWord(FX_WORD word, int32_t nCharset)
-{
- if (!IsReadOnly())
- m_pEdit->InsertWord(word, nCharset);
+void CPWL_EditCtrl::InsertWord(FX_WORD word, int32_t nCharset) {
+ if (!IsReadOnly())
+ m_pEdit->InsertWord(word, nCharset);
}
-void CPWL_EditCtrl::InsertReturn()
-{
- if (!IsReadOnly())
- m_pEdit->InsertReturn();
+void CPWL_EditCtrl::InsertReturn() {
+ if (!IsReadOnly())
+ m_pEdit->InsertReturn();
}
-void CPWL_EditCtrl::Delete()
-{
- if (!IsReadOnly())
- m_pEdit->Delete();
+void CPWL_EditCtrl::Delete() {
+ if (!IsReadOnly())
+ m_pEdit->Delete();
}
-void CPWL_EditCtrl::Backspace()
-{
- if (!IsReadOnly())
- m_pEdit->Backspace();
+void CPWL_EditCtrl::Backspace() {
+ if (!IsReadOnly())
+ m_pEdit->Backspace();
}
-FX_BOOL CPWL_EditCtrl::CanUndo() const
-{
- return !IsReadOnly() && m_pEdit->CanUndo();
+FX_BOOL CPWL_EditCtrl::CanUndo() const {
+ return !IsReadOnly() && m_pEdit->CanUndo();
}
-FX_BOOL CPWL_EditCtrl::CanRedo() const
-{
- return !IsReadOnly() && m_pEdit->CanRedo();
+FX_BOOL CPWL_EditCtrl::CanRedo() const {
+ return !IsReadOnly() && m_pEdit->CanRedo();
}
-void CPWL_EditCtrl::Redo()
-{
- if (CanRedo())
- m_pEdit->Redo();
+void CPWL_EditCtrl::Redo() {
+ if (CanRedo())
+ m_pEdit->Redo();
}
-void CPWL_EditCtrl::Undo()
-{
- if (CanUndo())
- m_pEdit->Undo();
+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;
+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;
+ Info.fPlateWidth = fPlateMax - fPlateMin;
+ Info.fContentMin = fContentMin;
+ Info.fContentMax = fContentMax;
+ Info.fSmallStep = fSmallStep;
+ Info.fBigStep = fBigStep;
- OnNotify(this,PNM_SETSCROLLINFO,SBT_VSCROLL,(intptr_t)&Info);
+ OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&Info);
- if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fContentMin)
- || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.fContentMin))
- {
- ShowVScrollBar(FALSE);
- }
- else
- {
- ShowVScrollBar(TRUE);
- }
+ if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) ||
+ IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) {
+ ShowVScrollBar(FALSE);
+ } else {
+ ShowVScrollBar(TRUE);
+ }
}
-void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy)
-{
- OnNotify(this, PNM_SETSCROLLPOS,SBT_VSCROLL, (intptr_t)&fy);
+void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT fy) {
+ OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&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;
+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;
- OnNotify(this, PNM_SETCARETINFO, (intptr_t)&cInfo, (intptr_t)NULL);
+ OnNotify(this, PNM_SETCARETINFO, (intptr_t)&cInfo, (intptr_t)NULL);
}
-void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps & secProps, const CPVT_WordProps & wordProps)
-{
-}
+void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps& secProps,
+ const CPVT_WordProps& wordProps) {}
-void CPWL_EditCtrl::IOnContentChange(const CPDF_Rect& rcContent)
-{
- if (IsValid())
- {
- if (m_pEditNotify)
- {
- m_pEditNotify->OnContentChange(rcContent);
- }
+void CPWL_EditCtrl::IOnContentChange(const CPDF_Rect& rcContent) {
+ if (IsValid()) {
+ if (m_pEditNotify) {
+ m_pEditNotify->OnContentChange(rcContent);
}
+ }
}
-void CPWL_EditCtrl::IOnInvalidateRect(CPDF_Rect * pRect)
-{
- InvalidateRect(pRect);
+void CPWL_EditCtrl::IOnInvalidateRect(CPDF_Rect* pRect) {
+ InvalidateRect(pRect);
}
-int32_t CPWL_EditCtrl::GetCharSet() const
-{
- return m_nCharSet < 0 ? DEFAULT_CHARSET : m_nCharSet;
+int32_t CPWL_EditCtrl::GetCharSet() const {
+ return m_nCharSet < 0 ? DEFAULT_CHARSET : m_nCharSet;
}
-void CPWL_EditCtrl::GetTextRange(const CPDF_Rect& rect, int32_t & nStartChar, int32_t & 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)));
+void CPWL_EditCtrl::GetTextRange(const CPDF_Rect& rect,
+ int32_t& nStartChar,
+ int32_t& 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(int32_t & nStartChar, int32_t & nEndChar) const
-{
- CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar);
- CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar);
- return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd));
+CFX_WideString CPWL_EditCtrl::GetText(int32_t& nStartChar,
+ int32_t& nEndChar) const {
+ CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStartChar);
+ CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEndChar);
+ return m_pEdit->GetRangeText(CPVT_WordRange(wpStart, wpEnd));
}
-void CPWL_EditCtrl::SetReadyToInput()
-{
- if (m_bMouseDown)
- {
- ReleaseCapture();
- m_bMouseDown = FALSE;
- }
+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 5fb9c99c3a..65fc9a6bd1 100644
--- a/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
@@ -8,191 +8,158 @@
#include "../../include/pdfwindow/PWL_Wnd.h"
#include "../../include/pdfwindow/PWL_FontMap.h"
-#define DEFAULT_FONT_NAME "Helvetica"
+#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(IFX_SystemHandler* pSystemHandler)
+ : m_pPDFDoc(NULL), m_pSystemHandler(pSystemHandler) {
+ ASSERT(m_pSystemHandler != NULL);
}
-CPWL_FontMap::~CPWL_FontMap()
-{
- delete m_pPDFDoc;
- m_pPDFDoc = NULL;
+CPWL_FontMap::~CPWL_FontMap() {
+ delete m_pPDFDoc;
+ m_pPDFDoc = NULL;
- Empty();
+ Empty();
}
-void CPWL_FontMap::SetSystemHandler(IFX_SystemHandler* pSystemHandler)
-{
- m_pSystemHandler = pSystemHandler;
+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(int32_t nFontIndex)
-{
- if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
- {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
- {
- return pData->pFont;
- }
+CPDF_Document* CPWL_FontMap::GetDocument() {
+ if (!m_pPDFDoc) {
+ if (CPDF_ModuleMgr::Get()) {
+ m_pPDFDoc = FX_NEW CPDF_Document;
+ m_pPDFDoc->CreateNewDoc();
}
+ }
- return NULL;
+ return m_pPDFDoc;
}
-CFX_ByteString CPWL_FontMap::GetPDFFontAlias(int32_t nFontIndex)
-{
- if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
- {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
- {
- return pData->sFontName;
- }
+CPDF_Font* CPWL_FontMap::GetPDFFont(int32_t nFontIndex) {
+ if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) {
+ if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) {
+ return pData->pFont;
}
+ }
- return "";
+ return NULL;
}
-FX_BOOL CPWL_FontMap::KnowWord(int32_t nFontIndex, FX_WORD word)
-{
- if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
- {
- if (m_aData.GetAt(nFontIndex))
- {
- return CharCodeFromUnicode(nFontIndex, word) >= 0;
- }
+CFX_ByteString CPWL_FontMap::GetPDFFontAlias(int32_t nFontIndex) {
+ if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) {
+ if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) {
+ return pData->sFontName;
}
+ }
- return FALSE;
+ return "";
}
-int32_t CPWL_FontMap::GetWordFontIndex(FX_WORD word, int32_t nCharset, int32_t nFontIndex)
-{
- if (nFontIndex > 0)
- {
- if (KnowWord(nFontIndex, word))
- return nFontIndex;
+FX_BOOL CPWL_FontMap::KnowWord(int32_t nFontIndex, FX_WORD word) {
+ if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) {
+ if (m_aData.GetAt(nFontIndex)) {
+ return CharCodeFromUnicode(nFontIndex, word) >= 0;
}
- else
- {
- if (const CPWL_FontMap_Data* pData = GetFontMapData(0))
- {
- if (nCharset == DEFAULT_CHARSET ||
- pData->nCharset == SYMBOL_CHARSET ||
- nCharset == pData->nCharset)
- {
- if (KnowWord(0, word))
- return 0;
- }
- }
- }
-
- int32_t nNewFontIndex = GetFontIndex(GetNativeFontName(nCharset), nCharset, TRUE);
- if (nNewFontIndex >= 0)
- {
- if (KnowWord(nNewFontIndex, word))
- return nNewFontIndex;
+ }
+
+ return FALSE;
+}
+
+int32_t CPWL_FontMap::GetWordFontIndex(FX_WORD word,
+ int32_t nCharset,
+ int32_t nFontIndex) {
+ if (nFontIndex > 0) {
+ if (KnowWord(nFontIndex, word))
+ return nFontIndex;
+ } else {
+ if (const CPWL_FontMap_Data* pData = GetFontMapData(0)) {
+ if (nCharset == DEFAULT_CHARSET || pData->nCharset == SYMBOL_CHARSET ||
+ nCharset == pData->nCharset) {
+ if (KnowWord(0, word))
+ return 0;
+ }
}
- nNewFontIndex = GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE);
- if (nNewFontIndex >= 0)
- {
- if (KnowWord(nNewFontIndex, word))
- return nNewFontIndex;
- }
- return -1;
-}
-
-int32_t CPWL_FontMap::CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word)
-{
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
- {
- if (pData->pFont)
- {
- if (pData->pFont->IsUnicodeCompatible())
- {
- int nCharCode = pData->pFont->CharCodeFromUnicode(word);
- pData->pFont->GlyphFromCharCode(nCharCode);
- return nCharCode;
- }
- if (word < 0xFF)
- return word;
- }
+ }
+
+ int32_t nNewFontIndex =
+ GetFontIndex(GetNativeFontName(nCharset), nCharset, TRUE);
+ if (nNewFontIndex >= 0) {
+ if (KnowWord(nNewFontIndex, word))
+ return nNewFontIndex;
+ }
+ nNewFontIndex = GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE);
+ if (nNewFontIndex >= 0) {
+ if (KnowWord(nNewFontIndex, word))
+ return nNewFontIndex;
+ }
+ return -1;
+}
+
+int32_t CPWL_FontMap::CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word) {
+ if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) {
+ if (pData->pFont) {
+ if (pData->pFont->IsUnicodeCompatible()) {
+ int nCharCode = pData->pFont->CharCodeFromUnicode(word);
+ pData->pFont->GlyphFromCharCode(nCharCode);
+ return nCharCode;
+ }
+ if (word < 0xFF)
+ return word;
}
- return -1;
+ }
+ return -1;
}
-CFX_ByteString CPWL_FontMap::GetNativeFontName(int32_t nCharset)
-{
- //searching native font is slow, so we must save time
- for (int32_t i=0,sz=m_aNativeFont.GetSize(); i<sz; i++)
- {
- if (CPWL_FontMap_Native* pData = m_aNativeFont.GetAt(i))
- {
- if (pData->nCharset == nCharset)
- return pData->sFontName;
- }
+CFX_ByteString CPWL_FontMap::GetNativeFontName(int32_t nCharset) {
+ // searching native font is slow, so we must save time
+ for (int32_t i = 0, sz = m_aNativeFont.GetSize(); i < sz; i++) {
+ if (CPWL_FontMap_Native* pData = m_aNativeFont.GetAt(i)) {
+ if (pData->nCharset == nCharset)
+ return pData->sFontName;
}
+ }
- CFX_ByteString sNew = GetNativeFont(nCharset);
+ CFX_ByteString sNew = GetNativeFont(nCharset);
- if (!sNew.IsEmpty())
- {
- CPWL_FontMap_Native* pNewData = new CPWL_FontMap_Native;
- pNewData->nCharset = nCharset;
- pNewData->sFontName = sNew;
+ if (!sNew.IsEmpty()) {
+ CPWL_FontMap_Native* pNewData = new CPWL_FontMap_Native;
+ pNewData->nCharset = nCharset;
+ pNewData->sFontName = sNew;
- m_aNativeFont.Add(pNewData);
- }
+ m_aNativeFont.Add(pNewData);
+ }
- return sNew;
+ return sNew;
}
-void CPWL_FontMap::Empty()
-{
- {
- for (int32_t i=0, sz=m_aData.GetSize(); i<sz; i++)
- delete m_aData.GetAt(i);
+void CPWL_FontMap::Empty() {
+ {
+ for (int32_t i = 0, sz = m_aData.GetSize(); i < sz; i++)
+ delete m_aData.GetAt(i);
- m_aData.RemoveAll();
- }
- {
- for (int32_t i=0, sz=m_aNativeFont.GetSize(); i<sz; i++)
- delete m_aNativeFont.GetAt(i);
+ m_aData.RemoveAll();
+ }
+ {
+ for (int32_t i = 0, sz = m_aNativeFont.GetSize(); i < sz; i++)
+ delete m_aNativeFont.GetAt(i);
- m_aNativeFont.RemoveAll();
- }
+ m_aNativeFont.RemoveAll();
+ }
}
-void CPWL_FontMap::Initial(const FX_CHAR* fontname)
-{
- CFX_ByteString sFontName = fontname;
+void CPWL_FontMap::Initial(const FX_CHAR* fontname) {
+ CFX_ByteString sFontName = fontname;
- if (sFontName.IsEmpty())
- sFontName = DEFAULT_FONT_NAME;
+ if (sFontName.IsEmpty())
+ sFontName = DEFAULT_FONT_NAME;
- GetFontIndex(sFontName, ANSI_CHARSET, FALSE);
+ GetFontIndex(sFontName, ANSI_CHARSET, FALSE);
}
-
/*
List of currently supported standard fonts:
Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique
@@ -201,368 +168,350 @@ 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 (int32_t i=0; i<14; i++)
- {
- if (sFontName == g_sDEStandardFontName[i])
- return TRUE;
+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 (int32_t i = 0; i < 14; i++) {
+ if (sFontName == g_sDEStandardFontName[i])
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName,
+ int32_t nCharset) {
+ for (int32_t i = 0, sz = m_aData.GetSize(); i < sz; i++) {
+ if (CPWL_FontMap_Data* pData = m_aData.GetAt(i)) {
+ if (nCharset == DEFAULT_CHARSET || nCharset == pData->nCharset) {
+ if (sFontName.IsEmpty() || pData->sFontName == sFontName)
+ return i;
+ }
}
+ }
- return FALSE;
+ return -1;
}
-int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, int32_t nCharset)
-{
- for (int32_t i=0,sz=m_aData.GetSize(); i<sz; i++)
- {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(i))
- {
- if (nCharset == DEFAULT_CHARSET || nCharset == pData->nCharset)
- {
- if (sFontName.IsEmpty() || pData->sFontName == sFontName)
- return i;
- }
- }
- }
+int32_t CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName,
+ int32_t nCharset,
+ FX_BOOL bFind) {
+ int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCharset);
+ if (nFontIndex >= 0)
+ return nFontIndex;
- return -1;
-}
+ CFX_ByteString sAlias;
+ CPDF_Font* pFont = NULL;
+ if (bFind)
+ pFont = FindFontSameCharset(sAlias, nCharset);
-int32_t CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName, int32_t nCharset, FX_BOOL bFind)
-{
- int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCharset);
- if (nFontIndex >= 0)
- return nFontIndex;
-
- CFX_ByteString sAlias;
- CPDF_Font* pFont = NULL;
- if (bFind)
- pFont = FindFontSameCharset(sAlias, nCharset);
-
- if (!pFont)
- {
- CFX_ByteString sTemp = sFontName;
- pFont = AddFontToDocument(GetDocument(), sTemp, nCharset);
- sAlias = EncodeFontAlias(sTemp, nCharset);
- }
- AddedFont(pFont, sAlias);
- return AddFontData(pFont, sAlias, nCharset);
+ if (!pFont) {
+ CFX_ByteString sTemp = sFontName;
+ pFont = AddFontToDocument(GetDocument(), sTemp, nCharset);
+ sAlias = EncodeFontAlias(sTemp, nCharset);
+ }
+ AddedFont(pFont, sAlias);
+ return AddFontData(pFont, sAlias, nCharset);
}
-int32_t CPWL_FontMap::GetPWLFontIndex(FX_WORD word, int32_t nCharset)
-{
- int32_t nFind = -1;
-
- for (int32_t i=0,sz=m_aData.GetSize(); i<sz; i++)
- {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(i))
- {
- if (pData->nCharset == nCharset)
- {
- nFind = i;
- break;
- }
- }
+int32_t CPWL_FontMap::GetPWLFontIndex(FX_WORD word, int32_t nCharset) {
+ int32_t nFind = -1;
+
+ for (int32_t i = 0, sz = m_aData.GetSize(); i < sz; i++) {
+ if (CPWL_FontMap_Data* pData = m_aData.GetAt(i)) {
+ if (pData->nCharset == nCharset) {
+ nFind = i;
+ break;
+ }
}
+ }
- CPDF_Font* pNewFont = GetPDFFont(nFind);
+ CPDF_Font* pNewFont = GetPDFFont(nFind);
- if (!pNewFont) return -1;
+ if (!pNewFont)
+ return -1;
- /*
- if (CPDF_Font* pFont = GetPDFFont(nFind))
- {
- PWLFont.AddWordToFontDict(pFontDict, word);
- }
- */
+ /*
+ if (CPDF_Font* pFont = GetPDFFont(nFind))
+ {
+ PWLFont.AddWordToFontDict(pFontDict, word);
+ }
+ */
- CFX_ByteString sAlias = EncodeFontAlias("Arial_Chrome", nCharset);
- AddedFont(pNewFont, sAlias);
+ CFX_ByteString sAlias = EncodeFontAlias("Arial_Chrome", nCharset);
+ AddedFont(pNewFont, sAlias);
- return AddFontData(pNewFont, sAlias, nCharset);
+ return AddFontData(pNewFont, sAlias, nCharset);
}
-CPDF_Font* CPWL_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, int32_t nCharset)
-{
- return NULL;
+CPDF_Font* CPWL_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias,
+ int32_t nCharset) {
+ return NULL;
}
-int32_t CPWL_FontMap::AddFontData(CPDF_Font* pFont, const CFX_ByteString& sFontAlias, int32_t nCharset)
-{
- CPWL_FontMap_Data* pNewData = new CPWL_FontMap_Data;
- pNewData->pFont = pFont;
- pNewData->sFontName = sFontAlias;
- pNewData->nCharset = nCharset;
+int32_t CPWL_FontMap::AddFontData(CPDF_Font* pFont,
+ const CFX_ByteString& sFontAlias,
+ int32_t nCharset) {
+ CPWL_FontMap_Data* pNewData = new CPWL_FontMap_Data;
+ pNewData->pFont = pFont;
+ pNewData->sFontName = sFontAlias;
+ pNewData->nCharset = nCharset;
- m_aData.Add(pNewData);
+ m_aData.Add(pNewData);
- return m_aData.GetSize() -1;
+ return m_aData.GetSize() - 1;
}
-void CPWL_FontMap::AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias)
-{
-}
+void CPWL_FontMap::AddedFont(CPDF_Font* pFont,
+ const CFX_ByteString& sFontAlias) {}
-CFX_ByteString CPWL_FontMap::GetFontName(int32_t nFontIndex)
-{
- if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
- {
- if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
- {
- return pData->sFontName;
- }
+CFX_ByteString CPWL_FontMap::GetFontName(int32_t nFontIndex) {
+ if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) {
+ if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) {
+ return pData->sFontName;
}
+ }
- return "";
+ return "";
}
-CFX_ByteString CPWL_FontMap::GetNativeFont(int32_t nCharset)
-{
-
- if (nCharset == DEFAULT_CHARSET)
- nCharset = GetNativeCharset();
+CFX_ByteString CPWL_FontMap::GetNativeFont(int32_t nCharset) {
+ if (nCharset == DEFAULT_CHARSET)
+ nCharset = GetNativeCharset();
- CFX_ByteString sFontName = GetDefaultFontByCharset(nCharset);
- if (m_pSystemHandler)
- {
- if (m_pSystemHandler->FindNativeTrueTypeFont(nCharset, sFontName))
- return sFontName;
+ CFX_ByteString sFontName = GetDefaultFontByCharset(nCharset);
+ if (m_pSystemHandler) {
+ if (m_pSystemHandler->FindNativeTrueTypeFont(nCharset, sFontName))
+ return sFontName;
- sFontName = m_pSystemHandler->GetNativeTrueTypeFont(nCharset);
- }
- return sFontName;
-}
-
-CPDF_Font* CPWL_FontMap::AddFontToDocument(CPDF_Document* pDoc, CFX_ByteString& sFontName, uint8_t nCharset)
-{
- if (IsStandardFont(sFontName))
- return AddStandardFont(pDoc, sFontName);
-
- return AddSystemFont(pDoc, sFontName, nCharset);
+ sFontName = m_pSystemHandler->GetNativeTrueTypeFont(nCharset);
+ }
+ return sFontName;
}
-CPDF_Font* CPWL_FontMap::AddStandardFont(CPDF_Document* pDoc, CFX_ByteString& sFontName)
-{
- if (!pDoc) return NULL;
+CPDF_Font* CPWL_FontMap::AddFontToDocument(CPDF_Document* pDoc,
+ CFX_ByteString& sFontName,
+ uint8_t nCharset) {
+ if (IsStandardFont(sFontName))
+ return AddStandardFont(pDoc, sFontName);
- 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;
+ return AddSystemFont(pDoc, sFontName, nCharset);
}
-CPDF_Font* CPWL_FontMap::AddSystemFont(CPDF_Document* pDoc, CFX_ByteString& sFontName, uint8_t nCharset)
-{
- if (!pDoc) return NULL;
-
- if (sFontName.IsEmpty()) sFontName = GetNativeFont(nCharset);
- if (nCharset == DEFAULT_CHARSET) nCharset = GetNativeCharset();
-
- if (m_pSystemHandler)
- return m_pSystemHandler->AddNativeTrueTypeFontToPDF(pDoc, sFontName, nCharset);
-
+CPDF_Font* CPWL_FontMap::AddStandardFont(CPDF_Document* pDoc,
+ CFX_ByteString& sFontName) {
+ if (!pDoc)
return NULL;
-}
-CFX_ByteString CPWL_FontMap::EncodeFontAlias(const CFX_ByteString& sFontName, int32_t nCharset)
-{
- CFX_ByteString sPostfix;
- sPostfix.Format("_%02X", nCharset);
- return EncodeFontAlias(sFontName) + sPostfix;
-}
+ CPDF_Font* pFont = NULL;
-CFX_ByteString CPWL_FontMap::EncodeFontAlias(const CFX_ByteString& sFontName)
-{
- CFX_ByteString sRet = sFontName;
- sRet.Remove(' ');
- return sRet;
-}
+ if (sFontName == "ZapfDingbats")
+ pFont = pDoc->AddStandardFont(sFontName, NULL);
+ else {
+ CPDF_FontEncoding fe(PDFFONT_ENCODING_WINANSI);
+ pFont = pDoc->AddStandardFont(sFontName, &fe);
+ }
-int32_t CPWL_FontMap::GetFontMapCount() const
-{
- return m_aData.GetSize();
+ return pFont;
}
-const CPWL_FontMap_Data* CPWL_FontMap::GetFontMapData(int32_t nIndex) const
-{
- if (nIndex >=0 && nIndex < m_aData.GetSize())
- {
- return m_aData.GetAt(nIndex);
- }
-
+CPDF_Font* CPWL_FontMap::AddSystemFont(CPDF_Document* pDoc,
+ CFX_ByteString& sFontName,
+ uint8_t nCharset) {
+ if (!pDoc)
return NULL;
-}
-int32_t CPWL_FontMap::GetNativeCharset()
-{
- uint8_t nCharset = ANSI_CHARSET;
- int32_t iCodePage = FXSYS_GetACP();
- switch (iCodePage)
- {
- case 932://Japan
- nCharset = SHIFTJIS_CHARSET;
- break;
- case 936://Chinese (PRC, Singapore)
- nCharset = GB2312_CHARSET;
- break;
- case 950://Chinese (Taiwan; Hong Kong SAR, PRC)
- nCharset = GB2312_CHARSET;
- break;
- case 1252://Windows 3.1 Latin 1 (US, Western Europe)
- nCharset = ANSI_CHARSET;
- break;
- case 874://Thai
- nCharset = THAI_CHARSET;
- break;
- case 949://Korean
- nCharset = HANGUL_CHARSET;
- break;
- case 1200://Unicode (BMP of ISO 10646)
- nCharset = ANSI_CHARSET;
- break;
- case 1250://Windows 3.1 Eastern European
- nCharset = EASTEUROPE_CHARSET;
- break;
- case 1251://Windows 3.1 Cyrillic
- nCharset = RUSSIAN_CHARSET;
- break;
- case 1253://Windows 3.1 Greek
- nCharset = GREEK_CHARSET;
- break;
- case 1254://Windows 3.1 Turkish
- nCharset = TURKISH_CHARSET;
- break;
- case 1255://Hebrew
- nCharset = HEBREW_CHARSET;
- break;
- case 1256://Arabic
- nCharset = ARABIC_CHARSET;
- break;
- case 1257://Baltic
- nCharset = BALTIC_CHARSET;
- break;
- case 1258://Vietnamese
- nCharset = VIETNAMESE_CHARSET;
- break;
- case 1361://Korean(Johab)
- nCharset = JOHAB_CHARSET;
- break;
- }
- return nCharset;
+ if (sFontName.IsEmpty())
+ sFontName = GetNativeFont(nCharset);
+ if (nCharset == DEFAULT_CHARSET)
+ nCharset = GetNativeCharset();
+
+ if (m_pSystemHandler)
+ return m_pSystemHandler->AddNativeTrueTypeFontToPDF(pDoc, sFontName,
+ nCharset);
+
+ return NULL;
+}
+
+CFX_ByteString CPWL_FontMap::EncodeFontAlias(const CFX_ByteString& sFontName,
+ int32_t nCharset) {
+ CFX_ByteString sPostfix;
+ sPostfix.Format("_%02X", nCharset);
+ return EncodeFontAlias(sFontName) + sPostfix;
+}
+
+CFX_ByteString CPWL_FontMap::EncodeFontAlias(const CFX_ByteString& sFontName) {
+ CFX_ByteString sRet = sFontName;
+ sRet.Remove(' ');
+ return sRet;
+}
+
+int32_t CPWL_FontMap::GetFontMapCount() const {
+ return m_aData.GetSize();
+}
+
+const CPWL_FontMap_Data* CPWL_FontMap::GetFontMapData(int32_t nIndex) const {
+ if (nIndex >= 0 && nIndex < m_aData.GetSize()) {
+ return m_aData.GetAt(nIndex);
+ }
+
+ return NULL;
+}
+
+int32_t CPWL_FontMap::GetNativeCharset() {
+ uint8_t nCharset = ANSI_CHARSET;
+ int32_t iCodePage = FXSYS_GetACP();
+ switch (iCodePage) {
+ case 932: // Japan
+ nCharset = SHIFTJIS_CHARSET;
+ break;
+ case 936: // Chinese (PRC, Singapore)
+ nCharset = GB2312_CHARSET;
+ break;
+ case 950: // Chinese (Taiwan; Hong Kong SAR, PRC)
+ nCharset = GB2312_CHARSET;
+ break;
+ case 1252: // Windows 3.1 Latin 1 (US, Western Europe)
+ nCharset = ANSI_CHARSET;
+ break;
+ case 874: // Thai
+ nCharset = THAI_CHARSET;
+ break;
+ case 949: // Korean
+ nCharset = HANGUL_CHARSET;
+ break;
+ case 1200: // Unicode (BMP of ISO 10646)
+ nCharset = ANSI_CHARSET;
+ break;
+ case 1250: // Windows 3.1 Eastern European
+ nCharset = EASTEUROPE_CHARSET;
+ break;
+ case 1251: // Windows 3.1 Cyrillic
+ nCharset = RUSSIAN_CHARSET;
+ break;
+ case 1253: // Windows 3.1 Greek
+ nCharset = GREEK_CHARSET;
+ break;
+ case 1254: // Windows 3.1 Turkish
+ nCharset = TURKISH_CHARSET;
+ break;
+ case 1255: // Hebrew
+ nCharset = HEBREW_CHARSET;
+ break;
+ case 1256: // Arabic
+ nCharset = ARABIC_CHARSET;
+ break;
+ case 1257: // Baltic
+ nCharset = BALTIC_CHARSET;
+ break;
+ case 1258: // Vietnamese
+ nCharset = VIETNAMESE_CHARSET;
+ break;
+ case 1361: // Korean(Johab)
+ nCharset = JOHAB_CHARSET;
+ break;
+ }
+ return nCharset;
}
const CPWL_FontMap::CharsetFontMap CPWL_FontMap::defaultTTFMap[] = {
- { ANSI_CHARSET, "Helvetica" },
- { GB2312_CHARSET, "SimSun" },
- { CHINESEBIG5_CHARSET, "MingLiU" },
- { SHIFTJIS_CHARSET, "MS Gothic" },
- { HANGUL_CHARSET, "Batang" },
- { RUSSIAN_CHARSET, "Arial" },
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
- { EASTEUROPE_CHARSET, "Arial" },
+ {ANSI_CHARSET, "Helvetica"}, {GB2312_CHARSET, "SimSun"},
+ {CHINESEBIG5_CHARSET, "MingLiU"}, {SHIFTJIS_CHARSET, "MS Gothic"},
+ {HANGUL_CHARSET, "Batang"}, {RUSSIAN_CHARSET, "Arial"},
+#if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \
+ _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
+ {EASTEUROPE_CHARSET, "Arial"},
#else
- { EASTEUROPE_CHARSET, "Tahoma" },
+ {EASTEUROPE_CHARSET, "Tahoma"},
#endif
- { ARABIC_CHARSET, "Arial" },
- { -1, NULL }
-};
-
-CFX_ByteString CPWL_FontMap::GetDefaultFontByCharset(int32_t nCharset)
-{
- int i = 0;
- while (defaultTTFMap[i].charset != -1) {
- if (nCharset == defaultTTFMap[i].charset)
- return defaultTTFMap[i].fontname;
- ++i;
- }
- return "";
-}
+ {ARABIC_CHARSET, "Arial"}, {-1, NULL}};
+
+CFX_ByteString CPWL_FontMap::GetDefaultFontByCharset(int32_t nCharset) {
+ int i = 0;
+ while (defaultTTFMap[i].charset != -1) {
+ if (nCharset == defaultTTFMap[i].charset)
+ return defaultTTFMap[i].fontname;
+ ++i;
+ }
+ return "";
+}
+
+int32_t CPWL_FontMap::CharSetFromUnicode(FX_WORD word, int32_t nOldCharset) {
+ if (m_pSystemHandler && (-1 != m_pSystemHandler->GetCharSet()))
+ return m_pSystemHandler->GetCharSet();
+ // to avoid CJK Font to show ASCII
+ if (word < 0x7F)
+ return ANSI_CHARSET;
+ // follow the old charset
+ if (nOldCharset != DEFAULT_CHARSET)
+ return nOldCharset;
-int32_t CPWL_FontMap::CharSetFromUnicode(FX_WORD word, int32_t nOldCharset)
-{
- if(m_pSystemHandler && (-1 != m_pSystemHandler->GetCharSet()))
- return m_pSystemHandler->GetCharSet();
- //to avoid CJK Font to show ASCII
- if (word < 0x7F) return ANSI_CHARSET;
- //follow the old charset
- if (nOldCharset != DEFAULT_CHARSET) return nOldCharset;
-
- //find new charset
- if ((word >= 0x4E00 && word <= 0x9FA5) ||
- (word >= 0xE7C7 && word <= 0xE7F3) ||
- (word >= 0x3000 && word <= 0x303F) ||
- (word >= 0x2000 && word <= 0x206F))
- {
- return GB2312_CHARSET;
- }
+ // 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 >= 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 >= 0xAC00) && (word <= 0xD7AF)) ||
+ ((word >= 0x1100) && (word <= 0x11FF)) ||
+ ((word >= 0x3130) && (word <= 0x318F))) {
+ return HANGUL_CHARSET;
+ }
- if (word >= 0x0E00 && word <= 0x0E7F)
- return THAI_CHARSET;
+ if (word >= 0x0E00 && word <= 0x0E7F)
+ return THAI_CHARSET;
- if ((word >= 0x0370 && word <= 0x03FF) ||
- (word >= 0x1F00 && word <= 0x1FFF))
- return GREEK_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 >= 0x0600 && word <= 0x06FF) || (word >= 0xFB50 && word <= 0xFEFC))
+ return ARABIC_CHARSET;
- if (word >= 0x0590 && word <= 0x05FF)
- return HEBREW_CHARSET;
+ if (word >= 0x0590 && word <= 0x05FF)
+ return HEBREW_CHARSET;
- if (word >= 0x0400 && word <= 0x04FF)
- return RUSSIAN_CHARSET;
+ if (word >= 0x0400 && word <= 0x04FF)
+ return RUSSIAN_CHARSET;
- if (word >= 0x0100 && word <= 0x024F)
- return EASTEUROPE_CHARSET;
+ if (word >= 0x0100 && word <= 0x024F)
+ return EASTEUROPE_CHARSET;
- if (word >= 0x1E00 && word <= 0x1EFF)
- return VIETNAMESE_CHARSET;
+ if (word >= 0x1E00 && word <= 0x1EFF)
+ return VIETNAMESE_CHARSET;
- return ANSI_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(IFX_SystemHandler* pSystemHandler,
+ CPDF_Document* pAttachedDoc)
+ : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {}
-CPWL_DocFontMap::~CPWL_DocFontMap()
-{
-}
+CPWL_DocFontMap::~CPWL_DocFontMap() {}
-CPDF_Document* CPWL_DocFontMap::GetDocument()
-{
- return m_pAttachedDoc;
+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 71174dfb0a..29e0aa86f5 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
@@ -9,254 +9,222 @@
#include "../../include/pdfwindow/PWL_Icon.h"
#include "../../include/pdfwindow/PWL_Utils.h"
-/* ------------------------------- CPWL_Image ---------------------------------- */
+/* ------------------------------- CPWL_Image ----------------------------------
+ */
-CPWL_Image::CPWL_Image() : m_pPDFStream(NULL)
-{
-}
+CPWL_Image::CPWL_Image() : m_pPDFStream(NULL) {}
-CPWL_Image::~CPWL_Image()
-{
-}
+CPWL_Image::~CPWL_Image() {}
-CFX_ByteString CPWL_Image::GetImageAppStream()
-{
- CFX_ByteTextBuf sAppStream;
+CFX_ByteString CPWL_Image::GetImageAppStream() {
+ CFX_ByteTextBuf sAppStream;
- CFX_ByteString sAlias = GetImageAlias();
- CPDF_Rect rcPlate = GetClientRect();
- CPDF_Matrix mt;
- mt.SetReverse(GetImageMatrix());
+ CFX_ByteString sAlias = 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 fHScale = 1.0f;
+ FX_FLOAT fVScale = 1.0f;
+ GetScale(fHScale, fVScale);
- FX_FLOAT fx = 0.0f;
- FX_FLOAT fy = 0.0f;
- GetImageOffset(fx,fy);
+ 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";
+ 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 << 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";
- }
+ sAppStream << "0 g 0 G 1 w /" << sAlias << " Do\n"
+ << "Q\n";
+ }
- return sAppStream.GetByteString();
+ return sAppStream.GetByteString();
}
-void CPWL_Image::SetPDFStream(CPDF_Stream * pStream)
-{
- m_pPDFStream = pStream;
+void CPWL_Image::SetPDFStream(CPDF_Stream* pStream) {
+ m_pPDFStream = pStream;
}
-CPDF_Stream * CPWL_Image::GetPDFStream()
-{
- return m_pPDFStream;
+CPDF_Stream* CPWL_Image::GetPDFStream() {
+ return m_pPDFStream;
}
-void CPWL_Image::GetImageSize(FX_FLOAT & fWidth,FX_FLOAT & fHeight)
-{
- fWidth = 0.0f;
- fHeight = 0.0f;
-
- if (m_pPDFStream)
- {
- if (CPDF_Dictionary * pDict = m_pPDFStream->GetDict())
- {
- CPDF_Rect rect = pDict->GetRect("BBox");
-
- fWidth = rect.right - rect.left;
- fHeight = rect.top - rect.bottom;
- }
- }
-}
+void CPWL_Image::GetImageSize(FX_FLOAT& fWidth, FX_FLOAT& fHeight) {
+ fWidth = 0.0f;
+ fHeight = 0.0f;
-CPDF_Matrix CPWL_Image::GetImageMatrix()
-{
- if (m_pPDFStream)
- {
- if (CPDF_Dictionary * pDict = m_pPDFStream->GetDict())
- {
- return pDict->GetMatrix("Matrix");
- }
- }
-
- return CPDF_Matrix();
-}
+ if (m_pPDFStream) {
+ if (CPDF_Dictionary* pDict = m_pPDFStream->GetDict()) {
+ CPDF_Rect rect = pDict->GetRect("BBox");
-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();
+ fWidth = rect.right - rect.left;
+ fHeight = rect.top - rect.bottom;
+ }
+ }
}
-void CPWL_Image::SetImageAlias(const FX_CHAR* sImageAlias)
-{
- m_sImageAlias = sImageAlias;
-}
+CPDF_Matrix CPWL_Image::GetImageMatrix() {
+ if (m_pPDFStream) {
+ if (CPDF_Dictionary* pDict = m_pPDFStream->GetDict()) {
+ return pDict->GetMatrix("Matrix");
+ }
+ }
-void CPWL_Image::GetScale(FX_FLOAT & fHScale,FX_FLOAT & fVScale)
-{
- fHScale = 1.0f;
- fVScale = 1.0f;
+ 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;
-void CPWL_Image::GetImageOffset(FX_FLOAT & x,FX_FLOAT & y)
-{
- x = 0.0f;
- y = 0.0f;
+ return CFX_ByteString();
}
-/* ------------------------------- CPWL_Icon ---------------------------------- */
+void CPWL_Image::SetImageAlias(const FX_CHAR* sImageAlias) {
+ m_sImageAlias = sImageAlias;
+}
-CPWL_Icon::CPWL_Icon() : m_pIconFit(NULL)
-{
+void CPWL_Image::GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale) {
+ fHScale = 1.0f;
+ fVScale = 1.0f;
}
-CPWL_Icon::~CPWL_Icon()
-{
+void CPWL_Image::GetImageOffset(FX_FLOAT& x, FX_FLOAT& y) {
+ x = 0.0f;
+ y = 0.0f;
}
-int32_t CPWL_Icon::GetScaleMethod()
-{
- if (m_pIconFit)
- return m_pIconFit->GetScaleMethod();
+/* ------------------------------- CPWL_Icon ----------------------------------
+ */
- return 0;
-}
+CPWL_Icon::CPWL_Icon() : m_pIconFit(NULL) {}
-FX_BOOL CPWL_Icon::IsProportionalScale()
-{
- if (m_pIconFit)
- return m_pIconFit->IsProportionalScale();
+CPWL_Icon::~CPWL_Icon() {}
- return FALSE;
-}
+int32_t CPWL_Icon::GetScaleMethod() {
+ if (m_pIconFit)
+ return m_pIconFit->GetScaleMethod();
-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 ? m_pIconFit->m_pDict->GetArray("A") : NULL;
- 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;
- }
+ return 0;
}
-FX_BOOL CPWL_Icon::GetFittingBounds()
-{
- if (m_pIconFit)
- return m_pIconFit->GetFittingBounds();
+FX_BOOL CPWL_Icon::IsProportionalScale() {
+ if (m_pIconFit)
+ return m_pIconFit->IsProportionalScale();
- return FALSE;
+ 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 = GetClientRect();
- fPlateWidth = rcPlate.right - rcPlate.left;
- fPlateHeight = rcPlate.top - rcPlate.bottom;
-
- GetImageSize(fImageWidth,fImageHeight);
-
- int32_t nScaleMethod = GetScaleMethod();
-
- switch (nScaleMethod)
- {
- default:
- case 0:
- fHScale = fPlateWidth / PWL_MAX(fImageWidth,1.0f);
- fVScale = fPlateHeight / PWL_MAX(fImageHeight,1.0f);
- break;
- case 1:
- if (fPlateWidth < fImageWidth)
- fHScale = fPlateWidth / PWL_MAX(fImageWidth,1.0f);
- if (fPlateHeight < fImageHeight)
- fVScale = fPlateHeight / PWL_MAX(fImageHeight,1.0f);
- break;
- case 2:
- if (fPlateWidth > fImageWidth)
- fHScale = fPlateWidth / PWL_MAX(fImageWidth,1.0f);
- if (fPlateHeight > fImageHeight)
- fVScale = fPlateHeight / PWL_MAX(fImageHeight,1.0f);
- break;
- case 3:
- break;
- }
-
- FX_FLOAT fMinScale;
- if (IsProportionalScale())
- {
- fMinScale = PWL_MIN(fHScale,fVScale);
- fHScale = fMinScale;
- fVScale = fMinScale;
- }
- }
+void CPWL_Icon::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 ? m_pIconFit->m_pDict->GetArray("A") : NULL;
+ 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;
+ }
}
-void CPWL_Icon::GetImageOffset(FX_FLOAT & x,FX_FLOAT & y)
-{
- FX_FLOAT fLeft,fBottom;
+FX_BOOL CPWL_Icon::GetFittingBounds() {
+ if (m_pIconFit)
+ return m_pIconFit->GetFittingBounds();
- GetIconPosition(fLeft, fBottom);
- x = 0.0f;
- y = 0.0f;
+ return FALSE;
+}
+
+void CPWL_Icon::GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale) {
+ fHScale = 1.0f;
+ fVScale = 1.0f;
- FX_FLOAT fImageWidth,fImageHeight;
- GetImageSize(fImageWidth,fImageHeight);
+ if (m_pPDFStream) {
+ FX_FLOAT fImageWidth, fImageHeight;
+ FX_FLOAT fPlateWidth, fPlateHeight;
- FX_FLOAT fHScale,fVScale;
- GetScale(fHScale,fVScale);
+ CPDF_Rect rcPlate = GetClientRect();
+ fPlateWidth = rcPlate.right - rcPlate.left;
+ fPlateHeight = rcPlate.top - rcPlate.bottom;
- FX_FLOAT fImageFactWidth = fImageWidth * fHScale;
- FX_FLOAT fImageFactHeight = fImageHeight * fVScale;
+ GetImageSize(fImageWidth, fImageHeight);
- FX_FLOAT fPlateWidth,fPlateHeight;
- CPDF_Rect rcPlate = GetClientRect();
- fPlateWidth = rcPlate.right - rcPlate.left;
- fPlateHeight = rcPlate.top - rcPlate.bottom;
+ int32_t nScaleMethod = GetScaleMethod();
- x = (fPlateWidth - fImageFactWidth) * fLeft;
- y = (fPlateHeight - fImageFactHeight) * fBottom;
+ switch (nScaleMethod) {
+ default:
+ case 0:
+ fHScale = fPlateWidth / PWL_MAX(fImageWidth, 1.0f);
+ fVScale = fPlateHeight / PWL_MAX(fImageHeight, 1.0f);
+ break;
+ case 1:
+ if (fPlateWidth < fImageWidth)
+ fHScale = fPlateWidth / PWL_MAX(fImageWidth, 1.0f);
+ if (fPlateHeight < fImageHeight)
+ fVScale = fPlateHeight / PWL_MAX(fImageHeight, 1.0f);
+ break;
+ case 2:
+ if (fPlateWidth > fImageWidth)
+ fHScale = fPlateWidth / PWL_MAX(fImageWidth, 1.0f);
+ if (fPlateHeight > fImageHeight)
+ fVScale = fPlateHeight / PWL_MAX(fImageHeight, 1.0f);
+ break;
+ case 3:
+ break;
+ }
+
+ FX_FLOAT fMinScale;
+ if (IsProportionalScale()) {
+ fMinScale = PWL_MIN(fHScale, fVScale);
+ fHScale = fMinScale;
+ fVScale = fMinScale;
+ }
+ }
}
+void CPWL_Icon::GetImageOffset(FX_FLOAT& x, FX_FLOAT& y) {
+ FX_FLOAT fLeft, fBottom;
+
+ GetIconPosition(fLeft, fBottom);
+ x = 0.0f;
+ y = 0.0f;
+
+ FX_FLOAT fImageWidth, fImageHeight;
+ GetImageSize(fImageWidth, fImageHeight);
+
+ FX_FLOAT fHScale, fVScale;
+ GetScale(fHScale, fVScale);
+
+ FX_FLOAT fImageFactWidth = fImageWidth * fHScale;
+ FX_FLOAT fImageFactHeight = fImageHeight * fVScale;
+
+ FX_FLOAT fPlateWidth, fPlateHeight;
+ CPDF_Rect rcPlate = GetClientRect();
+ fPlateWidth = rcPlate.right - rcPlate.left;
+ fPlateHeight = rcPlate.top - rcPlate.bottom;
+
+ x = (fPlateWidth - fImageFactWidth) * fLeft;
+ y = (fPlateHeight - fImageFactHeight) * fBottom;
+}
diff --git a/fpdfsdk/src/pdfwindow/PWL_IconList.cpp b/fpdfsdk/src/pdfwindow/PWL_IconList.cpp
index 157eba633d..24d2dad5fa 100644
--- a/fpdfsdk/src/pdfwindow/PWL_IconList.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_IconList.cpp
@@ -12,581 +12,494 @@
#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
+#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()
+ : m_nIconIndex(-1), m_pData(NULL), m_bSelected(FALSE), m_pText(NULL) {}
+
+CPWL_IconList_Item::~CPWL_IconList_Item() {}
-CPWL_IconList_Item::~CPWL_IconList_Item()
-{
+CFX_ByteString CPWL_IconList_Item::GetClassName() const {
+ return "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;
}
-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 (IsEnabled()) {
+ CPWL_Utils::DrawFillRect(
+ pDevice, pUser2Device, rcClient,
+ CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_SELBACKCOLOR,
+ GetTransparency()));
+ } else {
+ CPWL_Utils::DrawFillRect(
+ pDevice, pUser2Device, rcClient,
+ CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_LIGHTGRAYCOLOR,
+ GetTransparency()));
+ }
+ }
+
+ 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(),
+ GetTransparency());
}
-void CPWL_IconList_Item::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- CPDF_Rect rcClient = GetClientRect();
+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);
+}
- if (m_bSelected)
- {
- if (IsEnabled())
- {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient,
- CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_SELBACKCOLOR, GetTransparency()));
- }
- else
- {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient,
- CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_LIGHTGRAYCOLOR, GetTransparency()));
- }
- }
+FX_BOOL CPWL_IconList_Item::IsSelected() const {
+ return m_bSelected;
+}
- CPDF_Rect rcIcon = rcClient;
- rcIcon.left += PWL_IconList_ITEM_ICON_LEFTMARGIN;
- rcIcon.right = rcIcon.left + PWL_IconList_ITEM_WIDTH;
+void CPWL_IconList_Item::CreateChildWnd(const PWL_CREATEPARAM& cp) {
+ m_pText = new CPWL_Label;
- CPWL_Utils::DrawIconAppStream(pDevice, pUser2Device, m_nIconIndex, rcIcon,
- m_crIcon, m_pText->GetTextColor(), GetTransparency());
+ 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::SetSelect(FX_BOOL bSelected)
-{
- m_bSelected = bSelected;
+void CPWL_IconList_Item::SetData(void* pData) {
+ m_pData = pData;
+}
- if (bSelected)
- m_pText->SetTextColor(PWL_DEFAULT_WHITECOLOR);
- else
- m_pText->SetTextColor(PWL_DEFAULT_BLACKCOLOR);
+void CPWL_IconList_Item::SetIcon(int32_t nIconIndex) {
+ m_nIconIndex = nIconIndex;
+}
+void CPWL_IconList_Item::SetText(const CFX_WideString& str) {
+ m_pText->SetText(str.c_str());
}
-FX_BOOL CPWL_IconList_Item::IsSelected() const
-{
- return m_bSelected;
+CFX_WideString CPWL_IconList_Item::GetText() const {
+ return m_pText->GetText();
}
-void CPWL_IconList_Item::CreateChildWnd(const PWL_CREATEPARAM & cp)
-{
- m_pText = new CPWL_Label;
+void CPWL_IconList_Item::RePosChildWnd() {
+ CPDF_Rect rcClient = GetClientRect();
- 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);
+ 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::SetData(void* pData)
-{
- m_pData = pData;
+void CPWL_IconList_Item::SetIconFillColor(const CPWL_Color& color) {
+ m_crIcon = color;
}
-void CPWL_IconList_Item::SetIcon(int32_t nIconIndex)
-{
- m_nIconIndex = nIconIndex;
+void CPWL_IconList_Item::OnEnabled() {
+ if (m_bSelected)
+ m_pText->SetTextColor(PWL_DEFAULT_WHITECOLOR);
+ else
+ m_pText->SetTextColor(PWL_DEFAULT_BLACKCOLOR);
+
+ InvalidateRect();
}
-void CPWL_IconList_Item::SetText(const CFX_WideString& str)
-{
- m_pText->SetText(str.c_str());
+void CPWL_IconList_Item::OnDisabled() {
+ m_pText->SetTextColor(PWL_DEFAULT_HEAVYGRAYCOLOR);
+
+ InvalidateRect();
}
-CFX_WideString CPWL_IconList_Item::GetText() const
-{
- return m_pText->GetText();
+/* ----------------- CPWL_IconList_Content ----------------- */
+
+CPWL_IconList_Content::CPWL_IconList_Content(int32_t nListCount)
+ : m_nSelectIndex(-1),
+ m_pNotify(NULL),
+ m_bEnableNotify(TRUE),
+ m_bMouseDown(FALSE),
+ m_nListCount(nListCount) {}
+
+CPWL_IconList_Content::~CPWL_IconList_Content() {}
+
+void CPWL_IconList_Content::CreateChildWnd(const PWL_CREATEPARAM& cp) {
+ for (int32_t i = 0; i < m_nListCount; i++) {
+ CPWL_IconList_Item* pNewItem = new CPWL_IconList_Item();
+
+ PWL_CREATEPARAM icp = cp;
+ icp.pParentWnd = this;
+ icp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_NOREFRESHCLIP;
+ pNewItem->Create(icp);
+ }
+
+ SetItemSpace(PWL_IconList_ITEM_SPACE);
+ ResetContent(0);
+
+ if (CPWL_Wnd* pParent = GetParentWindow()) {
+ CPDF_Rect rcScroll = GetScrollArea();
+ GetScrollPos();
+
+ PWL_SCROLL_INFO sInfo;
+ sInfo.fContentMin = rcScroll.bottom;
+ sInfo.fContentMax = rcScroll.top;
+ sInfo.fPlateWidth = GetClientRect().Height();
+ sInfo.fSmallStep = 13.0f;
+ sInfo.fBigStep = sInfo.fPlateWidth;
+
+ pParent->OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&sInfo);
+ }
}
-void CPWL_IconList_Item::RePosChildWnd()
-{
- CPDF_Rect rcClient = GetClientRect();
+FX_BOOL CPWL_IconList_Content::OnLButtonDown(const CPDF_Point& point,
+ FX_DWORD nFlag) {
+ SetFocus();
+
+ SetCapture();
+ m_bMouseDown = TRUE;
+
+ int32_t nItemIndex = FindItemIndex(point);
+ SetSelect(nItemIndex);
+ ScrollToItem(nItemIndex);
- rcClient.left += (PWL_IconList_ITEM_ICON_LEFTMARGIN + PWL_IconList_ITEM_WIDTH + PWL_IconList_ITEM_ICON_LEFTMARGIN);
+ return TRUE;
+}
+
+FX_BOOL CPWL_IconList_Content::OnLButtonUp(const CPDF_Point& point,
+ FX_DWORD nFlag) {
+ m_bMouseDown = FALSE;
+ ReleaseCapture();
- m_pText->Move(rcClient, TRUE, FALSE);
+ return TRUE;
}
-void CPWL_IconList_Item::SetIconFillColor(const CPWL_Color& color)
-{
- m_crIcon = color;
+FX_BOOL CPWL_IconList_Content::OnMouseMove(const CPDF_Point& point,
+ FX_DWORD nFlag) {
+ if (m_bMouseDown) {
+ int32_t nItemIndex = FindItemIndex(point);
+ SetSelect(nItemIndex);
+ ScrollToItem(nItemIndex);
+ }
+
+ return TRUE;
}
-void CPWL_IconList_Item::OnEnabled()
-{
- if (m_bSelected)
- m_pText->SetTextColor(PWL_DEFAULT_WHITECOLOR);
- else
- m_pText->SetTextColor(PWL_DEFAULT_BLACKCOLOR);
+FX_BOOL CPWL_IconList_Content::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) {
+ switch (nChar) {
+ case FWL_VKEY_Up:
+ if (m_nSelectIndex > 0) {
+ int32_t nItemIndex = m_nSelectIndex - 1;
+ SetSelect(nItemIndex);
+ ScrollToItem(nItemIndex);
+ }
+ return TRUE;
+ case FWL_VKEY_Down:
+ if (m_nSelectIndex < m_nListCount - 1) {
+ int32_t nItemIndex = m_nSelectIndex + 1;
+ SetSelect(nItemIndex);
+ ScrollToItem(nItemIndex);
+ }
+ return TRUE;
+ }
- InvalidateRect();
+ return FALSE;
}
-void CPWL_IconList_Item::OnDisabled()
-{
- m_pText->SetTextColor(PWL_DEFAULT_HEAVYGRAYCOLOR);
+int32_t CPWL_IconList_Content::FindItemIndex(const CPDF_Point& point) {
+ int32_t nIndex = 0;
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
+ CPDF_Rect rcWnd = pChild->ChildToParent(pChild->GetWindowRect());
+
+ if (point.y < rcWnd.top) {
+ nIndex = i;
+ }
+ }
+ }
- InvalidateRect();
+ return nIndex;
}
-/* ----------------- CPWL_IconList_Content ----------------- */
+void CPWL_IconList_Content::ScrollToItem(int32_t 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();
+ }
-CPWL_IconList_Content::CPWL_IconList_Content(int32_t nListCount) :
- m_nSelectIndex(-1),
- m_pNotify(NULL),
- m_bEnableNotify(TRUE),
- m_bMouseDown(FALSE),
- m_nListCount(nListCount)
-{
-}
-
-CPWL_IconList_Content::~CPWL_IconList_Content()
-{
-}
-
-void CPWL_IconList_Content::CreateChildWnd(const PWL_CREATEPARAM & cp)
-{
- for (int32_t i=0; i<m_nListCount; i++)
- {
- CPWL_IconList_Item* pNewItem = new CPWL_IconList_Item();
-
- PWL_CREATEPARAM icp = cp;
- icp.pParentWnd = this;
- icp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_NOREFRESHCLIP;
- pNewItem->Create(icp);
- }
-
- SetItemSpace(PWL_IconList_ITEM_SPACE);
- ResetContent(0);
-
- if (CPWL_Wnd * pParent = GetParentWindow())
- {
- CPDF_Rect rcScroll = GetScrollArea();
- GetScrollPos();
-
- PWL_SCROLL_INFO sInfo;
- sInfo.fContentMin = rcScroll.bottom;
- sInfo.fContentMax = rcScroll.top;
- sInfo.fPlateWidth = GetClientRect().Height();
- sInfo.fSmallStep = 13.0f;
- sInfo.fBigStep = sInfo.fPlateWidth;
-
- pParent->OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&sInfo);
- }
-}
-
-FX_BOOL CPWL_IconList_Content::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
-{
- SetFocus();
-
- SetCapture();
- m_bMouseDown = TRUE;
-
- int32_t nItemIndex = FindItemIndex(point);
- SetSelect(nItemIndex);
- ScrollToItem(nItemIndex);
-
- return TRUE;
-}
-
-FX_BOOL CPWL_IconList_Content::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
-{
- m_bMouseDown = FALSE;
- ReleaseCapture();
-
- return TRUE;
-}
-
-FX_BOOL CPWL_IconList_Content::OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag)
-{
- if (m_bMouseDown)
- {
- int32_t nItemIndex = FindItemIndex(point);
- SetSelect(nItemIndex);
- ScrollToItem(nItemIndex);
- }
-
- return TRUE;
-}
-
-FX_BOOL CPWL_IconList_Content::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag)
-{
- switch (nChar)
- {
- case FWL_VKEY_Up:
- if (m_nSelectIndex > 0)
- {
- int32_t nItemIndex = m_nSelectIndex - 1;
- SetSelect(nItemIndex);
- ScrollToItem(nItemIndex);
- }
- return TRUE;
- case FWL_VKEY_Down:
- if (m_nSelectIndex < m_nListCount-1)
- {
- int32_t nItemIndex = m_nSelectIndex + 1;
- SetSelect(nItemIndex);
- ScrollToItem(nItemIndex);
- }
- return TRUE;
- }
-
- return FALSE;
-}
-
-int32_t CPWL_IconList_Content::FindItemIndex(const CPDF_Point& point)
-{
- int32_t nIndex = 0;
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
- {
- CPDF_Rect rcWnd = pChild->ChildToParent(pChild->GetWindowRect());
-
- if (point.y < rcWnd.top)
- {
- nIndex = i;
- }
- }
- }
-
- return nIndex;
-}
-
-void CPWL_IconList_Content::ScrollToItem(int32_t 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();
- }
+ SetScrollPos(ptScroll);
+ ResetFace();
+ InvalidateRect();
+ if (CPWL_Wnd* pParent = GetParentWindow()) {
+ pParent->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
+ (intptr_t)&ptScroll.y);
+ }
+ }
+ }
+}
+
+void CPWL_IconList_Content::SetSelect(int32_t nIndex) {
+ if (m_nSelectIndex != nIndex) {
+ SelectItem(m_nSelectIndex, FALSE);
+ SelectItem(nIndex, TRUE);
+ m_nSelectIndex = nIndex;
- SetScrollPos(ptScroll);
- ResetFace();
- InvalidateRect();
- if (CPWL_Wnd* pParent = GetParentWindow())
- {
- pParent->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&ptScroll.y);
- }
- }
- }
-}
-
-void CPWL_IconList_Content::SetSelect(int32_t nIndex)
-{
- if (m_nSelectIndex != nIndex)
- {
- SelectItem(m_nSelectIndex, FALSE);
- SelectItem(nIndex, TRUE);
- m_nSelectIndex = nIndex;
-
- if (IPWL_IconList_Notify* pNotify = GetNotify())
- pNotify->OnNoteListSelChanged(nIndex);
- }
-}
-
-int32_t CPWL_IconList_Content::GetSelect() const
-{
- return m_nSelectIndex;
-}
-
-IPWL_IconList_Notify* CPWL_IconList_Content::GetNotify() const
-{
- if (m_bEnableNotify)
- return m_pNotify;
- return NULL;
-}
-
-void CPWL_IconList_Content::SetNotify(IPWL_IconList_Notify* pNotify)
-{
- m_pNotify = pNotify;
-}
-
-void CPWL_IconList_Content::EnableNotify(FX_BOOL bNotify)
-{
- m_bEnableNotify = bNotify;
-}
-
-void CPWL_IconList_Content::SelectItem(int32_t nItemIndex, FX_BOOL bSelect)
-{
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- {
- pItem->SetSelect(bSelect);
- pItem->InvalidateRect();
- }
+ if (IPWL_IconList_Notify* pNotify = GetNotify())
+ pNotify->OnNoteListSelChanged(nIndex);
+ }
}
-CPWL_IconList_Item* CPWL_IconList_Content::GetListItem(int32_t nItemIndex) const
-{
- if (nItemIndex >= 0 && nItemIndex<m_aChildren.GetSize())
- {
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(nItemIndex))
- {
- if (pChild->GetClassName() == "CPWL_IconList_Item")
- {
- return (CPWL_IconList_Item*)pChild;
- }
- }
- }
+int32_t CPWL_IconList_Content::GetSelect() const {
+ return m_nSelectIndex;
+}
- return NULL;
+IPWL_IconList_Notify* CPWL_IconList_Content::GetNotify() const {
+ if (m_bEnableNotify)
+ return m_pNotify;
+ return NULL;
}
-void CPWL_IconList_Content::SetListData(int32_t nItemIndex, void* pData)
-{
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- pItem->SetData(pData);
+void CPWL_IconList_Content::SetNotify(IPWL_IconList_Notify* pNotify) {
+ m_pNotify = pNotify;
}
-void CPWL_IconList_Content::SetListIcon(int32_t nItemIndex, int32_t nIconIndex)
-{
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- pItem->SetIcon(nIconIndex);
+void CPWL_IconList_Content::EnableNotify(FX_BOOL bNotify) {
+ m_bEnableNotify = bNotify;
}
-void CPWL_IconList_Content::SetListString(int32_t nItemIndex, const CFX_WideString& str)
-{
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- pItem->SetText(str);
+void CPWL_IconList_Content::SelectItem(int32_t nItemIndex, FX_BOOL bSelect) {
+ if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex)) {
+ pItem->SetSelect(bSelect);
+ pItem->InvalidateRect();
+ }
}
-CFX_WideString CPWL_IconList_Content::GetListString(int32_t nItemIndex) const
-{
- if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
- return pItem->GetText();
+CPWL_IconList_Item* CPWL_IconList_Content::GetListItem(
+ int32_t nItemIndex) const {
+ if (nItemIndex >= 0 && nItemIndex < m_aChildren.GetSize()) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(nItemIndex)) {
+ if (pChild->GetClassName() == "CPWL_IconList_Item") {
+ return (CPWL_IconList_Item*)pChild;
+ }
+ }
+ }
+
+ return NULL;
+}
- return L"";
+void CPWL_IconList_Content::SetListData(int32_t nItemIndex, void* pData) {
+ if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
+ pItem->SetData(pData);
}
-void CPWL_IconList_Content::SetIconFillColor(const CPWL_Color& color)
-{
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
- {
- if (pChild->GetClassName() == "CPWL_IconList_Item")
- {
- CPWL_IconList_Item* pItem = (CPWL_IconList_Item*)pChild;
- pItem->SetIconFillColor(color);
- pItem->InvalidateRect();
- }
- }
- }
+void CPWL_IconList_Content::SetListIcon(int32_t nItemIndex,
+ int32_t nIconIndex) {
+ if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
+ pItem->SetIcon(nIconIndex);
+}
+void CPWL_IconList_Content::SetListString(int32_t nItemIndex,
+ const CFX_WideString& str) {
+ if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
+ pItem->SetText(str);
}
-/* -------------------- CPWL_IconList --------------------- */
+CFX_WideString CPWL_IconList_Content::GetListString(int32_t nItemIndex) const {
+ if (CPWL_IconList_Item* pItem = GetListItem(nItemIndex))
+ return pItem->GetText();
+
+ return L"";
+}
-CPWL_IconList::CPWL_IconList(int32_t nListCount) :
- m_pListContent(NULL),
- m_nListCount(nListCount)
-{
-}
-
-CPWL_IconList::~CPWL_IconList()
-{
-}
-
-void CPWL_IconList::RePosChildWnd()
-{
- CPWL_Wnd::RePosChildWnd();
-
- if (m_pListContent)
- m_pListContent->Move(GetClientRect(), TRUE, FALSE);
-}
-
-void CPWL_IconList::CreateChildWnd(const PWL_CREATEPARAM & cp)
-{
- m_pListContent = new CPWL_IconList_Content(m_nListCount);
-
- PWL_CREATEPARAM ccp = cp;
- ccp.pParentWnd = this;
- ccp.dwFlags = PWS_CHILD | PWS_VISIBLE;
- m_pListContent->Create(ccp);
-}
-
-void CPWL_IconList::OnCreated()
-{
- if (CPWL_ScrollBar* pScrollBar = GetVScrollBar())
- {
- pScrollBar->RemoveFlag(PWS_AUTOTRANSPARENT);
- pScrollBar->SetTransparency(255);
- pScrollBar->SetNotifyForever(TRUE);
- }
+void CPWL_IconList_Content::SetIconFillColor(const CPWL_Color& color) {
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
+ if (pChild->GetClassName() == "CPWL_IconList_Item") {
+ CPWL_IconList_Item* pItem = (CPWL_IconList_Item*)pChild;
+ pItem->SetIconFillColor(color);
+ pItem->InvalidateRect();
+ }
+ }
+ }
}
-void CPWL_IconList::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam)
-{
- CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
+/* -------------------- CPWL_IconList --------------------- */
+
+CPWL_IconList::CPWL_IconList(int32_t nListCount)
+ : m_pListContent(NULL), m_nListCount(nListCount) {}
+
+CPWL_IconList::~CPWL_IconList() {}
- if (wParam == SBT_VSCROLL)
- {
- switch (msg)
- {
- case PNM_SETSCROLLINFO:
- if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam)
- {
- if (CPWL_ScrollBar* pScrollBar = GetVScrollBar())
- {
- if (pInfo->fContentMax - pInfo->fContentMin > pInfo->fPlateWidth)
- {
- if (!pScrollBar->IsVisible())
- {
- pScrollBar->SetVisible(TRUE);
- RePosChildWnd();
- }
- else
- {
- }
- }
- else
- {
- if (pScrollBar->IsVisible())
- {
- pScrollBar->SetVisible(FALSE);
- RePosChildWnd();
- }
+void CPWL_IconList::RePosChildWnd() {
+ CPWL_Wnd::RePosChildWnd();
- if (m_pListContent)
- m_pListContent->SetScrollPos(CPDF_Point(0.0f,0.0f));
- }
+ 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);
- 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 = GetVScrollBar())
- pScrollBar->OnNotify(pWnd,PNM_SETSCROLLPOS,wParam,lParam);
- return;
- }
- }
+ PWL_CREATEPARAM ccp = cp;
+ ccp.pParentWnd = this;
+ ccp.dwFlags = PWS_CHILD | PWS_VISIBLE;
+ m_pListContent->Create(ccp);
}
-void CPWL_IconList::SetSelect(int32_t nIndex)
-{
- m_pListContent->SetSelect(nIndex);
+void CPWL_IconList::OnCreated() {
+ if (CPWL_ScrollBar* pScrollBar = GetVScrollBar()) {
+ pScrollBar->RemoveFlag(PWS_AUTOTRANSPARENT);
+ pScrollBar->SetTransparency(255);
+ pScrollBar->SetNotifyForever(TRUE);
+ }
}
-void CPWL_IconList::SetTopItem(int32_t nIndex)
-{
- m_pListContent->ScrollToItem(nIndex);
+void CPWL_IconList::OnNotify(CPWL_Wnd* pWnd,
+ FX_DWORD msg,
+ intptr_t wParam,
+ intptr_t lParam) {
+ CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
+
+ if (wParam == SBT_VSCROLL) {
+ switch (msg) {
+ case PNM_SETSCROLLINFO:
+ if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) {
+ if (CPWL_ScrollBar* pScrollBar = GetVScrollBar()) {
+ if (pInfo->fContentMax - pInfo->fContentMin > pInfo->fPlateWidth) {
+ if (!pScrollBar->IsVisible()) {
+ pScrollBar->SetVisible(TRUE);
+ RePosChildWnd();
+ } else {
+ }
+ } else {
+ if (pScrollBar->IsVisible()) {
+ pScrollBar->SetVisible(FALSE);
+ RePosChildWnd();
+ }
+
+ if (m_pListContent)
+ m_pListContent->SetScrollPos(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 = GetVScrollBar())
+ pScrollBar->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam);
+ return;
+ }
+ }
}
-int32_t CPWL_IconList::GetSelect() const
-{
- return m_pListContent->GetSelect();
+void CPWL_IconList::SetSelect(int32_t nIndex) {
+ m_pListContent->SetSelect(nIndex);
}
-void CPWL_IconList::SetNotify(IPWL_IconList_Notify* pNotify)
-{
- m_pListContent->SetNotify(pNotify);
+void CPWL_IconList::SetTopItem(int32_t nIndex) {
+ m_pListContent->ScrollToItem(nIndex);
}
-void CPWL_IconList::EnableNotify(FX_BOOL bNotify)
-{
- m_pListContent->EnableNotify(bNotify);
-}
-
-void CPWL_IconList::SetListData(int32_t nItemIndex, void* pData)
-{
- m_pListContent->SetListData(nItemIndex, pData);
-}
-
-void CPWL_IconList::SetListIcon(int32_t nItemIndex, int32_t nIconIndex)
-{
- m_pListContent->SetListIcon(nItemIndex, nIconIndex);
-}
-
-void CPWL_IconList::SetListString(int32_t nItemIndex, const CFX_WideString& str)
-{
- m_pListContent->SetListString(nItemIndex, str);
-}
-
-CFX_WideString CPWL_IconList::GetListString(int32_t nItemIndex) const
-{
- return m_pListContent->GetListString(nItemIndex);
-}
-
-void CPWL_IconList::SetIconFillColor(const CPWL_Color& color)
-{
- m_pListContent->SetIconFillColor(color);
-}
-
-FX_BOOL CPWL_IconList::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPDF_Point ptScroll = m_pListContent->GetScrollPos();
- CPDF_Rect rcScroll = m_pListContent->GetScrollArea();
- CPDF_Rect rcContents = m_pListContent->GetClientRect();
+int32_t CPWL_IconList::GetSelect() const {
+ return m_pListContent->GetSelect();
+}
- if (rcScroll.top - rcScroll.bottom > rcContents.Height())
- {
- CPDF_Point ptNew = ptScroll;
+void CPWL_IconList::SetNotify(IPWL_IconList_Notify* pNotify) {
+ m_pListContent->SetNotify(pNotify);
+}
- if (zDelta > 0)
- ptNew.y += 30;
- else
- ptNew.y -= 30;
+void CPWL_IconList::EnableNotify(FX_BOOL bNotify) {
+ m_pListContent->EnableNotify(bNotify);
+}
- 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;
+void CPWL_IconList::SetListData(int32_t nItemIndex, void* pData) {
+ m_pListContent->SetListData(nItemIndex, pData);
+}
- if (ptNew.y != ptScroll.y)
- {
- m_pListContent->SetScrollPos(ptNew);
- m_pListContent->ResetFace();
- m_pListContent->InvalidateRect(NULL);
+void CPWL_IconList::SetListIcon(int32_t nItemIndex, int32_t nIconIndex) {
+ m_pListContent->SetListIcon(nItemIndex, nIconIndex);
+}
- if (CPWL_ScrollBar* pScrollBar = GetVScrollBar())
- pScrollBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&ptNew.y);
+void CPWL_IconList::SetListString(int32_t nItemIndex,
+ const CFX_WideString& str) {
+ m_pListContent->SetListString(nItemIndex, str);
+}
- return TRUE;
- }
- }
+CFX_WideString CPWL_IconList::GetListString(int32_t nItemIndex) const {
+ return m_pListContent->GetListString(nItemIndex);
+}
- return FALSE;
+void CPWL_IconList::SetIconFillColor(const CPWL_Color& color) {
+ m_pListContent->SetIconFillColor(color);
}
+FX_BOOL CPWL_IconList::OnMouseWheel(short zDelta,
+ const CPDF_Point& point,
+ FX_DWORD nFlag) {
+ 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 = GetVScrollBar())
+ pScrollBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
+ (intptr_t)&ptNew.y);
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
diff --git a/fpdfsdk/src/pdfwindow/PWL_Label.cpp b/fpdfsdk/src/pdfwindow/PWL_Label.cpp
index e1780c69a8..797270ebba 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Label.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Label.cpp
@@ -11,177 +11,144 @@
/* ---------------------------- CPWL_Label ------------------------------ */
-CPWL_Label::CPWL_Label() : m_pEdit(NULL)
-{
- m_pEdit = IFX_Edit::NewEdit();
-
- ASSERT(m_pEdit != NULL);
+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);
+CPWL_Label::~CPWL_Label() {
+ IFX_Edit::DelEdit(m_pEdit);
}
-
-CFX_ByteString CPWL_Label::GetClassName() const
-{
- return "CPWL_Label";
-}
-
-void CPWL_Label::OnCreated()
-{
- SetParamByFlag();
- SetFontSize(GetCreationParam().fFontSize);
-
- m_pEdit->SetFontMap(GetFontMap());
- m_pEdit->Initialize();
-
- if (HasFlag(PES_TEXTOVERFLOW))
- {
- SetClipRect(CPDF_Rect(0.0f,0.0f,0.0f,0.0f));
- m_pEdit->SetTextOverflow(TRUE);
- }
+
+CFX_ByteString CPWL_Label::GetClassName() const {
+ return "CPWL_Label";
}
-void CPWL_Label::SetText(const FX_WCHAR* csText)
-{
- m_pEdit->SetText(csText);
+void CPWL_Label::OnCreated() {
+ SetParamByFlag();
+ SetFontSize(GetCreationParam().fFontSize);
+
+ m_pEdit->SetFontMap(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::RePosChildWnd()
-{
- m_pEdit->SetPlateRect(GetClientRect());
+void CPWL_Label::SetText(const FX_WCHAR* csText) {
+ m_pEdit->SetText(csText);
}
-void CPWL_Label::SetFontSize(FX_FLOAT fFontSize)
-{
- m_pEdit->SetFontSize(fFontSize);
+void CPWL_Label::RePosChildWnd() {
+ m_pEdit->SetPlateRect(GetClientRect());
}
-FX_FLOAT CPWL_Label::GetFontSize() const
-{
- return m_pEdit->GetFontSize();
+void CPWL_Label::SetFontSize(FX_FLOAT fFontSize) {
+ m_pEdit->SetFontSize(fFontSize);
}
-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);
- }
+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_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('*');
- }
+ 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));
+ 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);
+void CPWL_Label::DrawThisAppearance(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device) {
+ CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
- GetClientRect();
+ GetClientRect();
- CPDF_Rect rcClip;
- CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange();
- CPVT_WordRange* pRange = NULL;
+ 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(), GetTransparency()),
- CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()),
- rcClip, CPDF_Point(0.0f,0.0f), pRange,pSysHandler, NULL);
+ if (!HasFlag(PES_TEXTOVERFLOW)) {
+ rcClip = GetClientRect();
+ pRange = &wrRange;
+ }
+ IFX_SystemHandler* pSysHandler = GetSystemHandler();
+ IFX_Edit::DrawEdit(
+ pDevice, pUser2Device, m_pEdit,
+ CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
+ CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()),
+ rcClip, CPDF_Point(0.0f, 0.0f), pRange, pSysHandler, NULL);
}
-void CPWL_Label::SetHorzScale(int32_t nHorzScale)
-{
- m_pEdit->SetHorzScale(nHorzScale);
+void CPWL_Label::SetHorzScale(int32_t nHorzScale) {
+ m_pEdit->SetHorzScale(nHorzScale);
}
-void CPWL_Label::SetCharSpace(FX_FLOAT fCharSpace)
-{
- m_pEdit->SetCharSpace(fCharSpace);
+void CPWL_Label::SetCharSpace(FX_FLOAT fCharSpace) {
+ m_pEdit->SetCharSpace(fCharSpace);
}
-CPDF_Rect CPWL_Label::GetContentRect() const
-{
- return m_pEdit->GetContentRect();
+CPDF_Rect CPWL_Label::GetContentRect() const {
+ return m_pEdit->GetContentRect();
}
-void CPWL_Label::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
-{
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
+void CPWL_Label::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
+ CPWL_Wnd::GetThisAppearanceStream(sAppStream);
- sAppStream << GetTextAppearanceStream(CPDF_Point(0.0f, 0.0f));
+ 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);
+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";
- }
+ if (sEdit.GetLength() > 0) {
+ sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit
+ << "ET\n";
+ }
- return sRet.GetByteString();
+ return sRet.GetByteString();
}
-CFX_WideString CPWL_Label::GetText() const
-{
- return m_pEdit->GetText();
+CFX_WideString CPWL_Label::GetText() const {
+ return m_pEdit->GetText();
}
-void CPWL_Label::SetLimitChar(int32_t nLimitChar)
-{
- m_pEdit->SetLimitChar(nLimitChar);
+void CPWL_Label::SetLimitChar(int32_t nLimitChar) {
+ m_pEdit->SetLimitChar(nLimitChar);
}
-int32_t CPWL_Label::GetTotalWords()
-{
- if (m_pEdit)
- return m_pEdit->GetTotalWords();
+int32_t CPWL_Label::GetTotalWords() {
+ if (m_pEdit)
+ return m_pEdit->GetTotalWords();
- return 0;
+ return 0;
}
-
diff --git a/fpdfsdk/src/pdfwindow/PWL_ListBox.cpp b/fpdfsdk/src/pdfwindow/PWL_ListBox.cpp
index 48fb409b7b..ba75e55fdf 100644
--- a/fpdfsdk/src/pdfwindow/PWL_ListBox.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_ListBox.cpp
@@ -12,587 +12,531 @@
#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))
+#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(CPWL_ListBox* pList) : m_pList(pList) {
+ ASSERT(m_pList != NULL);
}
-CPWL_List_Notify::~CPWL_List_Notify()
-{
-}
+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;
+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;
+ Info.fPlateWidth = fPlateMax - fPlateMin;
+ Info.fContentMin = fContentMin;
+ Info.fContentMax = fContentMax;
+ Info.fSmallStep = fSmallStep;
+ Info.fBigStep = fBigStep;
- m_pList->OnNotify(m_pList,PNM_SETSCROLLINFO,SBT_VSCROLL,(intptr_t)&Info);
+ m_pList->OnNotify(m_pList, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&Info);
- if (CPWL_ScrollBar * pScroll = m_pList->GetVScrollBar())
- {
- if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fContentMin)
- || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.fContentMin))
- {
- if (pScroll->IsVisible())
- {
- pScroll->SetVisible(FALSE);
- m_pList->RePosChildWnd();
- }
- }
- else
- {
- if (!pScroll->IsVisible())
- {
- pScroll->SetVisible(TRUE);
- m_pList->RePosChildWnd();
- }
- }
- }
+ if (CPWL_ScrollBar* pScroll = m_pList->GetVScrollBar()) {
+ if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) ||
+ IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) {
+ if (pScroll->IsVisible()) {
+ pScroll->SetVisible(FALSE);
+ m_pList->RePosChildWnd();
+ }
+ } else {
+ if (!pScroll->IsVisible()) {
+ pScroll->SetVisible(TRUE);
+ m_pList->RePosChildWnd();
+ }
+ }
+ }
}
-void CPWL_List_Notify::IOnSetScrollPosY(FX_FLOAT fy)
-{
- m_pList->OnNotify(m_pList,PNM_SETSCROLLPOS,SBT_VSCROLL,(intptr_t)&fy);
+void CPWL_List_Notify::IOnSetScrollPosY(FX_FLOAT fy) {
+ m_pList->OnNotify(m_pList, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy);
}
-void CPWL_List_Notify::IOnInvalidateRect(CPDF_Rect * pRect)
-{
- m_pList->InvalidateRect(pRect);
+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();
+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);
+ ASSERT(m_pList != NULL);
}
-CPWL_ListBox::~CPWL_ListBox()
-{
- IFX_List::DelList(m_pList);
- delete m_pListNotify;
- m_pListNotify = NULL;
+CPWL_ListBox::~CPWL_ListBox() {
+ IFX_List::DelList(m_pList);
+ delete m_pListNotify;
+ m_pListNotify = NULL;
}
-CFX_ByteString CPWL_ListBox::GetClassName() const
-{
- return "CPWL_ListBox";
+CFX_ByteString CPWL_ListBox::GetClassName() const {
+ return "CPWL_ListBox";
}
-void CPWL_ListBox::OnCreated()
-{
- if (m_pList)
- {
- delete m_pListNotify;
+void CPWL_ListBox::OnCreated() {
+ if (m_pList) {
+ delete m_pListNotify;
- m_pList->SetFontMap(GetFontMap());
- m_pList->SetNotify(m_pListNotify = new CPWL_List_Notify(this));
+ m_pList->SetFontMap(GetFontMap());
+ m_pList->SetNotify(m_pListNotify = new CPWL_List_Notify(this));
+
+ SetHoverSel(HasFlag(PLBS_HOVERSEL));
+ m_pList->SetMultipleSel(HasFlag(PLBS_MULTIPLESEL));
+ m_pList->SetFontSize(GetCreationParam().fFontSize);
+
+ m_bHoverSel = HasFlag(PLBS_HOVERSEL);
+ }
+}
+
+void CPWL_ListBox::OnDestroy() {
+ delete m_pListNotify;
+ m_pListNotify = NULL;
+}
+
+void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
+ CPWL_Wnd::GetThisAppearanceStream(sAppStream);
+
+ CFX_ByteTextBuf sListItems;
+
+ if (m_pList) {
+ CPDF_Rect rcPlate = m_pList->GetPlateRect();
+ for (int32_t 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 = 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 (int32_t 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));
+ }
- SetHoverSel(HasFlag(PLBS_HOVERSEL));
- m_pList->SetMultipleSel(HasFlag(PLBS_MULTIPLESEL));
- m_pList->SetFontSize(GetCreationParam().fFontSize);
+ if (m_bMouseDown) {
+ if (m_pList)
+ m_pList->OnMouseMove(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag));
+ }
- m_bHoverSel = HasFlag(PLBS_HOVERSEL);
- }
+ return TRUE;
}
-void CPWL_ListBox::OnDestroy()
-{
- delete m_pListNotify;
- m_pListNotify = NULL;
-}
-
-void CPWL_ListBox::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
-{
- CPWL_Wnd::GetThisAppearanceStream(sAppStream);
-
- CFX_ByteTextBuf sListItems;
-
- if (m_pList)
- {
- CPDF_Rect rcPlate = m_pList->GetPlateRect();
- for (int32_t 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 = 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 (int32_t 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, intptr_t wParam, intptr_t lParam)
-{
- CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam);
-
- FX_FLOAT fPos;
-
- switch (msg)
- {
- case PNM_SETSCROLLINFO:
- switch (wParam)
- {
- case SBT_VSCROLL:
- if (CPWL_Wnd * pChild = GetVScrollBar())
- {
- pChild->OnNotify(pWnd,PNM_SETSCROLLINFO,wParam,lParam);
- }
- break;
- }
- break;
- case PNM_SETSCROLLPOS:
- switch (wParam)
- {
- case SBT_VSCROLL:
- if (CPWL_Wnd * pChild = GetVScrollBar())
- {
- pChild->OnNotify(pWnd,PNM_SETSCROLLPOS,wParam,lParam);
- }
- break;
- }
- break;
- case PNM_SCROLLWINDOW:
- fPos = *(FX_FLOAT*)lParam;
- switch (wParam)
- {
- case SBT_VSCROLL:
- if (m_pList)
- m_pList->SetScrollPos(CPDF_Point(0,fPos));
- break;
- }
- break;
- }
+void CPWL_ListBox::OnNotify(CPWL_Wnd* pWnd,
+ FX_DWORD msg,
+ intptr_t wParam,
+ intptr_t lParam) {
+ CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
+
+ FX_FLOAT fPos;
+
+ switch (msg) {
+ case PNM_SETSCROLLINFO:
+ switch (wParam) {
+ case SBT_VSCROLL:
+ if (CPWL_Wnd* pChild = GetVScrollBar()) {
+ pChild->OnNotify(pWnd, PNM_SETSCROLLINFO, wParam, lParam);
+ }
+ break;
+ }
+ break;
+ case PNM_SETSCROLLPOS:
+ switch (wParam) {
+ case SBT_VSCROLL:
+ if (CPWL_Wnd* pChild = GetVScrollBar()) {
+ pChild->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam);
+ }
+ break;
+ }
+ break;
+ case PNM_SCROLLWINDOW:
+ fPos = *(FX_FLOAT*)lParam;
+ switch (wParam) {
+ case SBT_VSCROLL:
+ if (m_pList)
+ m_pList->SetScrollPos(CPDF_Point(0, fPos));
+ break;
+ }
+ break;
+ }
}
-void CPWL_ListBox::KillFocus()
-{
- CPWL_Wnd::KillFocus();
+void CPWL_ListBox::KillFocus() {
+ CPWL_Wnd::KillFocus();
}
-void CPWL_ListBox::RePosChildWnd()
-{
- CPWL_Wnd::RePosChildWnd();
+void CPWL_ListBox::RePosChildWnd() {
+ CPWL_Wnd::RePosChildWnd();
- if (m_pList)
- m_pList->SetPlateRect(GetListRect());
+ 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;
+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);
- }
+ 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;
- }
+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();
+ return CPWL_Wnd::GetFocusRect();
}
-void CPWL_ListBox::AddString(const FX_WCHAR* string)
-{
- if (m_pList)
- {
- m_pList->AddString(string);
- }
+void CPWL_ListBox::AddString(const FX_WCHAR* string) {
+ if (m_pList) {
+ m_pList->AddString(string);
+ }
}
-CFX_WideString CPWL_ListBox::GetText() const
-{
- if (m_pList)
- return m_pList->GetText();
+CFX_WideString CPWL_ListBox::GetText() const {
+ if (m_pList)
+ return m_pList->GetText();
- return L"";
+ return L"";
}
-void CPWL_ListBox::SetFontSize(FX_FLOAT fFontSize)
-{
- if (m_pList)
- m_pList->SetFontSize(fFontSize);
+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;
+FX_FLOAT CPWL_ListBox::GetFontSize() const {
+ if (m_pList)
+ return m_pList->GetFontSize();
+ return 0.0f;
}
-void CPWL_ListBox::Select(int32_t nItemIndex)
-{
- if (m_pList)
- m_pList->Select(nItemIndex);
+void CPWL_ListBox::Select(int32_t nItemIndex) {
+ if (m_pList)
+ m_pList->Select(nItemIndex);
}
-void CPWL_ListBox::SetCaret(int32_t nItemIndex)
-{
- if (m_pList)
- m_pList->SetCaret(nItemIndex);
+void CPWL_ListBox::SetCaret(int32_t nItemIndex) {
+ if (m_pList)
+ m_pList->SetCaret(nItemIndex);
}
-void CPWL_ListBox::SetTopVisibleIndex(int32_t nItemIndex)
-{
- if (m_pList)
- m_pList->SetTopItem(nItemIndex);
+void CPWL_ListBox::SetTopVisibleIndex(int32_t nItemIndex) {
+ if (m_pList)
+ m_pList->SetTopItem(nItemIndex);
}
-void CPWL_ListBox::ScrollToListItem(int32_t nItemIndex)
-{
- if (m_pList)
- m_pList->ScrollToListItem(nItemIndex);
+void CPWL_ListBox::ScrollToListItem(int32_t nItemIndex) {
+ if (m_pList)
+ m_pList->ScrollToListItem(nItemIndex);
}
-void CPWL_ListBox::ResetContent()
-{
- if (m_pList)
- m_pList->Empty();
+void CPWL_ListBox::ResetContent() {
+ if (m_pList)
+ m_pList->Empty();
}
-void CPWL_ListBox::Reset()
-{
- if (m_pList)
- m_pList->Cancel();
+void CPWL_ListBox::Reset() {
+ if (m_pList)
+ m_pList->Cancel();
}
-FX_BOOL CPWL_ListBox::IsMultipleSel() const
-{
- if (m_pList)
- return m_pList->IsMultipleSel();
+FX_BOOL CPWL_ListBox::IsMultipleSel() const {
+ if (m_pList)
+ return m_pList->IsMultipleSel();
- return FALSE;
+ return FALSE;
}
-int32_t CPWL_ListBox::GetCaretIndex() const
-{
- if (m_pList)
- return m_pList->GetCaret();
+int32_t CPWL_ListBox::GetCaretIndex() const {
+ if (m_pList)
+ return m_pList->GetCaret();
- return -1;
+ return -1;
}
-int32_t CPWL_ListBox::GetCurSel() const
-{
- if (m_pList)
- return m_pList->GetSelect();
+int32_t CPWL_ListBox::GetCurSel() const {
+ if (m_pList)
+ return m_pList->GetSelect();
- return -1;
+ return -1;
}
-FX_BOOL CPWL_ListBox::IsItemSelected(int32_t nItemIndex) const
-{
- if (m_pList)
- return m_pList->IsItemSelected(nItemIndex);
+FX_BOOL CPWL_ListBox::IsItemSelected(int32_t nItemIndex) const {
+ if (m_pList)
+ return m_pList->IsItemSelected(nItemIndex);
- return FALSE;
+ return FALSE;
}
-int32_t CPWL_ListBox::GetTopVisibleIndex() const
-{
- if (m_pList)
- {
- m_pList->ScrollToListItem(m_pList->GetFirstSelected());
- return m_pList->GetTopItem();
- }
+int32_t CPWL_ListBox::GetTopVisibleIndex() const {
+ if (m_pList) {
+ m_pList->ScrollToListItem(m_pList->GetFirstSelected());
+ return m_pList->GetTopItem();
+ }
- return -1;
+ return -1;
}
-int32_t CPWL_ListBox::GetCount() const
-{
- if (m_pList)
- return m_pList->GetCount();
+int32_t CPWL_ListBox::GetCount() const {
+ if (m_pList)
+ return m_pList->GetCount();
- return 0;
+ return 0;
}
-int32_t CPWL_ListBox::FindNext(int32_t nIndex,FX_WCHAR nChar) const
-{
- if (m_pList)
- return m_pList->FindNext(nIndex,nChar);
+int32_t CPWL_ListBox::FindNext(int32_t nIndex, FX_WCHAR nChar) const {
+ if (m_pList)
+ return m_pList->FindNext(nIndex, nChar);
- return nIndex;
+ return nIndex;
}
-CPDF_Rect CPWL_ListBox::GetContentRect() const
-{
- if (m_pList)
- return m_pList->GetContentRect();
+CPDF_Rect CPWL_ListBox::GetContentRect() const {
+ if (m_pList)
+ return m_pList->GetContentRect();
- return CPDF_Rect();
+ return CPDF_Rect();
}
-FX_FLOAT CPWL_ListBox::GetFirstHeight() const
-{
- if (m_pList)
- return m_pList->GetFirstHeight();
+FX_FLOAT CPWL_ListBox::GetFirstHeight() const {
+ if (m_pList)
+ return m_pList->GetFirstHeight();
- return 0.0f;
+ return 0.0f;
}
-CPDF_Rect CPWL_ListBox::GetListRect() const
-{
- return CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
+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;
+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));
- }
+ 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;
+ 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 3077e6293f..e01ce5c203 100644
--- a/fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_ListCtrl.cpp
@@ -10,236 +10,199 @@
/* ---------------------------- 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()
+ : 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()
-{
-}
+CPWL_ListCtrl::~CPWL_ListCtrl() {}
-void CPWL_ListCtrl::SetScrollPos(const CPDF_Point& point)
-{
- m_ptScroll = point;
+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.left)
+ m_ptScroll.x = m_rcContent.left;
- if (m_ptScroll.x > m_rcContent.right)
- m_ptScroll.x = m_rcContent.right;
+ 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.top)
+ m_ptScroll.y = m_rcContent.top;
- if (m_ptScroll.y < m_rcContent.bottom)
- m_ptScroll.y = m_rcContent.bottom;
+ if (m_ptScroll.y < m_rcContent.bottom)
+ m_ptScroll.y = m_rcContent.bottom;
}
-CPDF_Point CPWL_ListCtrl::GetScrollPos() const
-{
- return m_ptScroll;
+CPDF_Point CPWL_ListCtrl::GetScrollPos() const {
+ return m_ptScroll;
}
-CPDF_Rect CPWL_ListCtrl::GetScrollArea() const
-{
- return m_rcContent;
+CPDF_Rect CPWL_ListCtrl::GetScrollArea() const {
+ return m_rcContent;
}
-void CPWL_ListCtrl::ResetFace()
-{
- ResetAll(FALSE, 0);
+void CPWL_ListCtrl::ResetFace() {
+ ResetAll(FALSE, 0);
}
-void CPWL_ListCtrl::ResetContent(int32_t nStart)
-{
- if (nStart < 0)
- nStart = 0;
- if (nStart >= 0 && nStart < m_aChildren.GetSize())
- ResetAll(TRUE, nStart);
+void CPWL_ListCtrl::ResetContent(int32_t nStart) {
+ if (nStart < 0)
+ nStart = 0;
+ if (nStart >= 0 && nStart < m_aChildren.GetSize())
+ ResetAll(TRUE, nStart);
}
-FX_FLOAT CPWL_ListCtrl::GetContentsHeight(FX_FLOAT fLimitWidth)
-{
- FX_FLOAT fRet = m_fTopSpace;
+FX_FLOAT CPWL_ListCtrl::GetContentsHeight(FX_FLOAT fLimitWidth) {
+ FX_FLOAT fRet = m_fTopSpace;
- FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
+ FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- if (fLimitWidth > fBorderWidth* 2)
- {
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- FX_FLOAT fLeft = pChild->GetItemLeftMargin();
- FX_FLOAT fRight = pChild->GetItemRightMargin();
+ if (fLimitWidth > fBorderWidth * 2) {
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
+ FX_FLOAT fLeft = pChild->GetItemLeftMargin();
+ FX_FLOAT fRight = pChild->GetItemRightMargin();
- fRet += pChild->GetItemHeight(fLimitWidth - fBorderWidth* 2 - fLeft - fRight);
- fRet += m_fItemSpace;
- }
- }
+ fRet += pChild->GetItemHeight(fLimitWidth - fBorderWidth * 2 - fLeft -
+ fRight);
+ fRet += m_fItemSpace;
+ }
+ }
- fRet -= m_fItemSpace;
- }
+ fRet -= m_fItemSpace;
+ }
- fRet += m_fBottomSpace;
+ fRet += m_fBottomSpace;
- return fRet;
+ return fRet;
}
-void CPWL_ListCtrl::ResetAll(FX_BOOL bMove, int32_t nStart)
-{
- CPDF_Rect rcClient = GetClientRect();
+void CPWL_ListCtrl::ResetAll(FX_BOOL bMove, int32_t nStart) {
+ CPDF_Rect rcClient = GetClientRect();
- FX_FLOAT fWidth = rcClient.Width();
+ FX_FLOAT fWidth = rcClient.Width();
- FX_FLOAT fy = 0.0f - m_fTopSpace;
+ 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;
+ if (nStart - 1 >= 0 && nStart - 1 < m_aChildren.GetSize())
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(nStart - 1))
+ fy = pChild->GetWindowRect().bottom - m_fItemSpace;
- for (int32_t i=nStart,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- FX_FLOAT fLeft = pChild->GetItemLeftMargin();
- FX_FLOAT fRight = pChild->GetItemRightMargin();
+ for (int32_t i = nStart, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
+ FX_FLOAT fLeft = pChild->GetItemLeftMargin();
+ FX_FLOAT fRight = pChild->GetItemRightMargin();
- pChild->SetChildMatrix(
- CPDF_Matrix(1,0,0,1,
- rcClient.left - m_ptScroll.x,
- rcClient.top - m_ptScroll.y)
- );
+ 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;
- }
- }
- }
+ 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_fItemSpace;
- fy -= m_fBottomSpace;
+ fy -= m_fBottomSpace;
- if (bMove)
- {
- m_rcContent.left = 0;
- m_rcContent.top = 0;
- m_rcContent.right = fWidth;
- m_rcContent.bottom = fy;
- }
+ 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::SetItemSpace(FX_FLOAT fSpace) {
+ m_fItemSpace = fSpace;
}
-void CPWL_ListCtrl::SetTopSpace(FX_FLOAT fSpace)
-{
- m_fTopSpace = fSpace;
+void CPWL_ListCtrl::SetTopSpace(FX_FLOAT fSpace) {
+ m_fTopSpace = fSpace;
}
-void CPWL_ListCtrl::SetBottomSpace(FX_FLOAT fSpace)
-{
- m_fBottomSpace = fSpace;
+void CPWL_ListCtrl::SetBottomSpace(FX_FLOAT fSpace) {
+ m_fBottomSpace = fSpace;
}
-void CPWL_ListCtrl::RePosChildWnd()
-{
- ResetFace();
+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((int32_t)rcTemp.left,
- (int32_t)rcTemp.bottom,
- (int32_t)rcTemp.right,
- (int32_t)rcTemp.top);
+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((int32_t)rcTemp.left, (int32_t)rcTemp.bottom,
+ (int32_t)rcTemp.right, (int32_t)rcTemp.top);
- pDevice->SetClip_Rect(&rcClip);
+ pDevice->SetClip_Rect(&rcClip);
- for (int32_t 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);
- }
- }
- }
- }
+ for (int32_t 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();
+ pDevice->RestoreState();
}
-int32_t CPWL_ListCtrl::GetItemIndex(CPWL_Wnd* pItem)
-{
- for (int32_t i=0, sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (pItem == m_aChildren.GetAt(i))
- return i;
- }
+int32_t CPWL_ListCtrl::GetItemIndex(CPWL_Wnd* pItem) {
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (pItem == m_aChildren.GetAt(i))
+ return i;
+ }
- return -1;
+ return -1;
}
-CPDF_Point CPWL_ListCtrl::InToOut(const CPDF_Point& point) const
-{
- CPDF_Rect rcClient = GetClientRect();
+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);
+ 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();
+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);
+ 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();
+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);
+ 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();
+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);
+ 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 7ed1115a82..6b05dde3b8 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Note.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Note.cpp
@@ -18,1753 +18,1598 @@
#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 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))
+#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::CPWL_Note_Options() : m_pText(NULL) {}
-CPWL_Note_Options::CPWL_Note_Options() : m_pText(NULL)
-{
-}
-
-CPWL_Note_Options::~CPWL_Note_Options()
-{
-}
+CPWL_Note_Options::~CPWL_Note_Options() {}
-void CPWL_Note_Options::SetTextColor(const CPWL_Color & color)
-{
- CPWL_Wnd::SetTextColor(color);
+void CPWL_Note_Options::SetTextColor(const CPWL_Color& color) {
+ CPWL_Wnd::SetTextColor(color);
- if (m_pText)
- m_pText->SetTextColor(color);
+ if (m_pText)
+ m_pText->SetTextColor(color);
}
-void CPWL_Note_Options::RePosChildWnd()
-{
- if (IsValid())
- {
- ASSERT(m_pText != NULL);
+void CPWL_Note_Options::RePosChildWnd() {
+ if (IsValid()) {
+ ASSERT(m_pText != NULL);
- CPDF_Rect rcClient = GetClientRect();
+ 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);
- }
- }
+ 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::CreateChildWnd(const PWL_CREATEPARAM& cp) {
+ m_pText = new CPWL_Label;
+ PWL_CREATEPARAM tcp = cp;
+ tcp.pParentWnd = this;
+ tcp.dwFlags = PWS_CHILD | PWS_VISIBLE;
+ m_pText->Create(tcp);
}
-void CPWL_Note_Options::SetText(const CFX_WideString& sText)
-{
- m_pText->SetText(sText.c_str());
+void CPWL_Note_Options::SetText(const CFX_WideString& sText) {
+ m_pText->SetText(sText.c_str());
}
-void CPWL_Note_Options::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
+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_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 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);
+ 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;
+ 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);
+ 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);
+ 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 CPWL_Note_Options::GetContentRect() const {
+ ASSERT(m_pText != NULL);
- CPDF_Rect rcText = m_pText->GetContentRect();
- rcText.right += 15.0f;
- return rcText;
+ CPDF_Rect rcText = m_pText->GetContentRect();
+ rcText.right += 15.0f;
+ return rcText;
}
-/* ------------------------------- CPWL_Note_Edit ------------------------------ */
+/* ------------------------------- 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()
+ : m_bEnableNotify(TRUE),
+ m_fOldItemHeight(0.0f),
+ m_bSizeChanged(FALSE),
+ m_fOldMin(0.0f),
+ m_fOldMax(0.0f) {}
-CPWL_Note_Edit::~CPWL_Note_Edit()
-{
+CPWL_Note_Edit::~CPWL_Note_Edit() {}
+
+void CPWL_Note_Edit::RePosChildWnd() {
+ m_bEnableNotify = FALSE;
+ CPWL_Edit::RePosChildWnd();
+ m_bEnableNotify = TRUE;
+
+ m_fOldItemHeight = GetContentRect().Height();
}
-void CPWL_Note_Edit::RePosChildWnd()
-{
- m_bEnableNotify = FALSE;
- CPWL_Edit::RePosChildWnd();
- m_bEnableNotify = TRUE;
+void CPWL_Note_Edit::SetText(const FX_WCHAR* csText) {
+ m_bEnableNotify = FALSE;
+ CPWL_Edit::SetText(csText);
+ m_bEnableNotify = TRUE;
+ m_fOldItemHeight = GetContentRect().Height();
+}
- m_fOldItemHeight = GetContentRect().Height();
-}
-
-void CPWL_Note_Edit::SetText(const FX_WCHAR* csText)
-{
- m_bEnableNotify = FALSE;
- CPWL_Edit::SetText(csText);
- m_bEnableNotify = TRUE;
- m_fOldItemHeight = GetContentRect().Height();
-}
-
-void CPWL_Note_Edit::OnSetFocus()
-{
- m_bEnableNotify = FALSE;
- CPWL_Edit::OnSetFocus();
- m_bEnableNotify = TRUE;
+void CPWL_Note_Edit::OnSetFocus() {
+ m_bEnableNotify = FALSE;
+ CPWL_Edit::OnSetFocus();
+ m_bEnableNotify = TRUE;
- EnableSpellCheck(TRUE);
+ EnableSpellCheck(TRUE);
}
-void CPWL_Note_Edit::OnKillFocus()
-{
- EnableSpellCheck(FALSE);
+void CPWL_Note_Edit::OnKillFocus() {
+ EnableSpellCheck(FALSE);
- if (CPWL_Wnd* pParent = GetParentWindow())
- {
- if (CPWL_Wnd* pGrand = pParent->GetParentWindow())
- {
- ASSERT(pGrand->GetClassName() == "CPWL_NoteItem");
+ if (CPWL_Wnd* pParent = GetParentWindow()) {
+ if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) {
+ ASSERT(pGrand->GetClassName() == "CPWL_NoteItem");
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pGrand;
+ CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pGrand;
- pNoteItem->OnContentsValidate();
- }
- }
+ pNoteItem->OnContentsValidate();
+ }
+ }
- CPWL_Edit::OnKillFocus();
+ CPWL_Edit::OnKillFocus();
}
-void CPWL_Note_Edit::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam)
-{
- if (m_bEnableNotify)
- {
- if (wParam == SBT_VSCROLL)
- {
- switch (msg)
- {
- case PNM_SETSCROLLINFO:
- if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam)
- {
- if (!IsFloatEqual(pInfo->fContentMax, m_fOldMax) ||
- !IsFloatEqual(pInfo->fContentMin, m_fOldMin))
- {
- m_bSizeChanged = TRUE;
- if (CPWL_Wnd * pParent = GetParentWindow())
- {
- pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- }
+void CPWL_Note_Edit::OnNotify(CPWL_Wnd* pWnd,
+ FX_DWORD msg,
+ intptr_t wParam,
+ intptr_t lParam) {
+ if (m_bEnableNotify) {
+ if (wParam == SBT_VSCROLL) {
+ switch (msg) {
+ case PNM_SETSCROLLINFO:
+ if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) {
+ if (!IsFloatEqual(pInfo->fContentMax, m_fOldMax) ||
+ !IsFloatEqual(pInfo->fContentMin, m_fOldMin)) {
+ m_bSizeChanged = TRUE;
+ if (CPWL_Wnd* pParent = GetParentWindow()) {
+ pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
+ }
- m_fOldMax = pInfo->fContentMax;
- m_fOldMin = pInfo->fContentMin;
- return;
- }
- }
- }
- }
- }
+ m_fOldMax = pInfo->fContentMax;
+ m_fOldMin = pInfo->fContentMin;
+ return;
+ }
+ }
+ }
+ }
+ }
- CPWL_Edit::OnNotify(pWnd, msg, wParam, lParam);
+ CPWL_Edit::OnNotify(pWnd, msg, wParam, lParam);
- if (m_bEnableNotify)
- {
- switch (msg)
- {
- case PNM_SETCARETINFO:
- if (PWL_CARET_INFO * pInfo = (PWL_CARET_INFO*)wParam)
- {
- PWL_CARET_INFO newInfo = *pInfo;
- newInfo.bVisible = TRUE;
- newInfo.ptHead = ChildToParent(pInfo->ptHead);
- newInfo.ptFoot = ChildToParent(pInfo->ptFoot);
+ if (m_bEnableNotify) {
+ switch (msg) {
+ case PNM_SETCARETINFO:
+ if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) {
+ PWL_CARET_INFO newInfo = *pInfo;
+ newInfo.bVisible = TRUE;
+ newInfo.ptHead = ChildToParent(pInfo->ptHead);
+ newInfo.ptFoot = ChildToParent(pInfo->ptFoot);
- if (CPWL_Wnd * pParent = GetParentWindow())
- {
- pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0);
- }
- }
- break;
- }
- }
+ if (CPWL_Wnd* pParent = GetParentWindow()) {
+ pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0);
+ }
+ }
+ break;
+ }
+ }
}
-FX_FLOAT CPWL_Note_Edit::GetItemHeight(FX_FLOAT fLimitWidth)
-{
- if (fLimitWidth > 0)
- {
- if (!m_bSizeChanged)
- return m_fOldItemHeight;
+FX_FLOAT CPWL_Note_Edit::GetItemHeight(FX_FLOAT fLimitWidth) {
+ if (fLimitWidth > 0) {
+ if (!m_bSizeChanged)
+ return m_fOldItemHeight;
- m_bSizeChanged = FALSE;
+ m_bSizeChanged = FALSE;
- EnableNotify(FALSE);
- EnableRefresh(FALSE);
- m_pEdit->EnableNotify(FALSE);
+ EnableNotify(FALSE);
+ EnableRefresh(FALSE);
+ m_pEdit->EnableNotify(FALSE);
- Move(CPDF_Rect(0,0,fLimitWidth,0), TRUE, FALSE);
- FX_FLOAT fRet = GetContentRect().Height();
+ Move(CPDF_Rect(0, 0, fLimitWidth, 0), TRUE, FALSE);
+ FX_FLOAT fRet = GetContentRect().Height();
- m_pEdit->EnableNotify(TRUE);
- EnableNotify(TRUE);
- EnableRefresh(TRUE);
+ m_pEdit->EnableNotify(TRUE);
+ EnableNotify(TRUE);
+ EnableRefresh(TRUE);
- return fRet;
- }
+ return fRet;
+ }
- return 0;
+ return 0;
}
-FX_FLOAT CPWL_Note_Edit::GetItemLeftMargin()
-{
- return POPUP_ITEM_TEXT_INDENT;
+FX_FLOAT CPWL_Note_Edit::GetItemLeftMargin() {
+ return POPUP_ITEM_TEXT_INDENT;
}
-FX_FLOAT CPWL_Note_Edit::GetItemRightMargin()
-{
- 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::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 = GetClientRect();
+void CPWL_Note_LBBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device) {
+ CPDF_Rect rcClient = GetClientRect();
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = 1.0f;
+ CFX_GraphStateData gsd;
+ gsd.m_LineWidth = 1.0f;
- CFX_PathData pathCross;
+ 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);
+ pathCross.SetPointCount(4);
+ pathCross.SetPoint(0, rcClient.left, rcClient.top, FXPT_MOVETO);
+ pathCross.SetPoint(1, rcClient.right, rcClient.bottom, FXPT_LINETO);
+ pathCross.SetPoint(2, rcClient.left,
+ rcClient.bottom + rcClient.Height() * 0.5f, FXPT_MOVETO);
+ pathCross.SetPoint(3, rcClient.left + rcClient.Width() * 0.5f,
+ rcClient.bottom, FXPT_LINETO);
- pDevice->DrawPath(&pathCross, pUser2Device, &gsd,
- 0, CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), FXFILL_ALTERNATE);
+ pDevice->DrawPath(
+ &pathCross, pUser2Device, &gsd, 0,
+ CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
+ FXFILL_ALTERNATE);
}
-/* -------------------------------- CPWL_Note_RBBox --------------------------------*/
+/* -------------------------------- CPWL_Note_RBBox
+ * --------------------------------*/
-CPWL_Note_RBBox::CPWL_Note_RBBox()
-{
-}
+CPWL_Note_RBBox::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 = GetClientRect();
+void CPWL_Note_RBBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device) {
+ CPDF_Rect rcClient = GetClientRect();
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = 1.0f;
+ CFX_GraphStateData gsd;
+ gsd.m_LineWidth = 1.0f;
- CFX_PathData pathCross;
+ 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);
+ pathCross.SetPointCount(4);
+ pathCross.SetPoint(0, rcClient.right, rcClient.top, FXPT_MOVETO);
+ pathCross.SetPoint(1, rcClient.left, rcClient.bottom, FXPT_LINETO);
+ pathCross.SetPoint(2, rcClient.right,
+ rcClient.bottom + rcClient.Height() * 0.5f, FXPT_MOVETO);
+ pathCross.SetPoint(3, rcClient.left + rcClient.Width() * 0.5f,
+ rcClient.bottom, FXPT_LINETO);
- pDevice->DrawPath(&pathCross, pUser2Device, &gsd,
- 0, CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), FXFILL_ALTERNATE);
+ pDevice->DrawPath(
+ &pathCross, pUser2Device, &gsd, 0,
+ CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
+ FXFILL_ALTERNATE);
}
-/* --------------------------------- CPWL_Note_Icon ---------------------------------- */
+/* --------------------------------- CPWL_Note_Icon
+ * ---------------------------------- */
-CPWL_Note_Icon::CPWL_Note_Icon() : m_nType(0)
-{
-}
+CPWL_Note_Icon::CPWL_Note_Icon() : m_nType(0) {}
-CPWL_Note_Icon::~CPWL_Note_Icon()
-{
-}
+CPWL_Note_Icon::~CPWL_Note_Icon() {}
-void CPWL_Note_Icon::SetIconType(int32_t nType)
-{
- m_nType = nType;
+void CPWL_Note_Icon::SetIconType(int32_t nType) {
+ m_nType = nType;
}
-void CPWL_Note_Icon::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- CPWL_Utils::DrawIconAppStream(pDevice, pUser2Device, m_nType, GetClientRect(),
- GetBackgroundColor(), PWL_DEFAULT_BLACKCOLOR, GetTransparency());
+void CPWL_Note_Icon::DrawThisAppearance(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device) {
+ CPWL_Utils::DrawIconAppStream(pDevice, pUser2Device, m_nType, GetClientRect(),
+ GetBackgroundColor(), PWL_DEFAULT_BLACKCOLOR,
+ GetTransparency());
}
-/* --------------------------------- CPWL_Note_CloseBox ---------------------------------- */
+/* --------------------------------- CPWL_Note_CloseBox
+ * ---------------------------------- */
-CPWL_Note_CloseBox::CPWL_Note_CloseBox() : m_bMouseDown(FALSE)
-{
-}
+CPWL_Note_CloseBox::CPWL_Note_CloseBox() : m_bMouseDown(FALSE) {}
-CPWL_Note_CloseBox::~CPWL_Note_CloseBox()
-{
-}
+CPWL_Note_CloseBox::~CPWL_Note_CloseBox() {}
-void CPWL_Note_CloseBox::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- CPWL_Button::DrawThisAppearance(pDevice, pUser2Device);
+void CPWL_Note_CloseBox::DrawThisAppearance(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device) {
+ CPWL_Button::DrawThisAppearance(pDevice, pUser2Device);
- CPDF_Rect rcClient = GetClientRect();
- rcClient = CPWL_Utils::DeflateRect(rcClient, 2.0f);
+ CPDF_Rect rcClient = GetClientRect();
+ rcClient = CPWL_Utils::DeflateRect(rcClient, 2.0f);
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = 1.0f;
+ CFX_GraphStateData gsd;
+ gsd.m_LineWidth = 1.0f;
- CFX_PathData pathCross;
+ CFX_PathData pathCross;
- if (m_bMouseDown)
- {
- rcClient.left += 0.5f;
- rcClient.right += 0.5f;
- rcClient.top -= 0.5f;
- rcClient.bottom -= 0.5f;
- }
+ 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);
+ pathCross.SetPointCount(4);
+ pathCross.SetPoint(0, rcClient.left, rcClient.bottom, FXPT_MOVETO);
+ pathCross.SetPoint(1, rcClient.right, rcClient.top, FXPT_LINETO);
+ pathCross.SetPoint(2, rcClient.left, rcClient.top, FXPT_MOVETO);
+ pathCross.SetPoint(3, rcClient.right, rcClient.bottom, FXPT_LINETO);
- pDevice->DrawPath(&pathCross, pUser2Device, &gsd,
- 0, CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), FXFILL_ALTERNATE);
+ pDevice->DrawPath(
+ &pathCross, pUser2Device, &gsd, 0,
+ CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()),
+ FXFILL_ALTERNATE);
}
-FX_BOOL CPWL_Note_CloseBox::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
-{
- SetBorderStyle(PBS_INSET);
- InvalidateRect(NULL);
+FX_BOOL CPWL_Note_CloseBox::OnLButtonDown(const CPDF_Point& point,
+ FX_DWORD nFlag) {
+ SetBorderStyle(PBS_INSET);
+ InvalidateRect(NULL);
- m_bMouseDown = TRUE;
+ m_bMouseDown = TRUE;
- return CPWL_Button::OnLButtonDown(point,nFlag);
+ return CPWL_Button::OnLButtonDown(point, nFlag);
}
-FX_BOOL CPWL_Note_CloseBox::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
-{
- m_bMouseDown = FALSE;
+FX_BOOL CPWL_Note_CloseBox::OnLButtonUp(const CPDF_Point& point,
+ FX_DWORD nFlag) {
+ m_bMouseDown = FALSE;
- SetBorderStyle(PBS_BEVELED);
- InvalidateRect(NULL);
+ SetBorderStyle(PBS_BEVELED);
+ InvalidateRect(NULL);
- return CPWL_Button::OnLButtonUp(point,nFlag);
+ return CPWL_Button::OnLButtonUp(point, nFlag);
}
-/* ------------------------------ CPWL_Note_Contents ------------------------------- */
+/* ------------------------------ CPWL_Note_Contents
+ * ------------------------------- */
+
+CPWL_Note_Contents::CPWL_Note_Contents() : m_pEdit(NULL) {}
+
+CPWL_Note_Contents::~CPWL_Note_Contents() {}
-CPWL_Note_Contents::CPWL_Note_Contents() : m_pEdit(NULL)
-{
+CFX_ByteString CPWL_Note_Contents::GetClassName() const {
+ return "CPWL_Note_Contents";
}
-CPWL_Note_Contents::~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);
}
-CFX_ByteString CPWL_Note_Contents::GetClassName() const
-{
- return "CPWL_Note_Contents";
+void CPWL_Note_Contents::SetText(const CFX_WideString& sText) {
+ if (m_pEdit) {
+ m_pEdit->EnableNotify(FALSE);
+ m_pEdit->SetText(sText.c_str());
+ m_pEdit->EnableNotify(TRUE);
+ OnNotify(m_pEdit, PNM_NOTEEDITCHANGED, 0, 0);
+ }
}
-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;
+CFX_WideString CPWL_Note_Contents::GetText() const {
+ if (m_pEdit)
+ return m_pEdit->GetText();
+
+ return L"";
+}
+
+CPWL_NoteItem* CPWL_Note_Contents::CreateSubItem() {
+ CPWL_NoteItem* pNoteItem = new CPWL_NoteItem;
+ PWL_CREATEPARAM icp = GetCreationParam();
+ icp.pParentWnd = this;
+ icp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_BACKGROUND;
+ pNoteItem->Create(icp);
+
+ pNoteItem->OnCreateNoteItem();
+
+ pNoteItem->ResetSubjectName(m_aChildren.GetSize() - 1);
+
+ FX_SYSTEMTIME st;
+ if (IFX_SystemHandler* pSH = GetSystemHandler())
+ st = pSH->GetLocalTime();
+ pNoteItem->SetDateTime(st);
+
+ pNoteItem->SetContents(L"");
+
+ OnNotify(pNoteItem, PNM_NOTEEDITCHANGED, 0, 0);
- m_pEdit->EnableNotify(FALSE);
- m_pEdit->Create(ecp);
- m_pEdit->EnableNotify(TRUE);
+ return pNoteItem;
}
-void CPWL_Note_Contents::SetText(const CFX_WideString& sText)
-{
- if (m_pEdit)
- {
- m_pEdit->EnableNotify(FALSE);
- m_pEdit->SetText(sText.c_str());
- m_pEdit->EnableNotify(TRUE);
- OnNotify(m_pEdit, PNM_NOTEEDITCHANGED, 0, 0);
- }
+int32_t CPWL_Note_Contents::CountSubItems() const {
+ return m_aChildren.GetSize() - 1;
}
-CFX_WideString CPWL_Note_Contents::GetText() const
-{
- if (m_pEdit)
- return m_pEdit->GetText();
+IPWL_NoteItem* CPWL_Note_Contents::GetSubItems(int32_t index) const {
+ int32_t nIndex = index + 1;
- return L"";
+ 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;
}
-CPWL_NoteItem* CPWL_Note_Contents::CreateSubItem()
-{
- CPWL_NoteItem* pNoteItem = new CPWL_NoteItem;
- PWL_CREATEPARAM icp = GetCreationParam();
- icp.pParentWnd = this;
- icp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_BACKGROUND;
- pNoteItem->Create(icp);
+void CPWL_Note_Contents::DeleteSubItem(IPWL_NoteItem* pNoteItem) {
+ int32_t nIndex = GetItemIndex((CPWL_NoteItem*)pNoteItem);
- pNoteItem->OnCreateNoteItem();
+ if (nIndex > 0) {
+ if (CPWL_NoteItem* pPWLNoteItem = (CPWL_NoteItem*)pNoteItem) {
+ pPWLNoteItem->KillFocus();
+ pPWLNoteItem->Destroy();
+ delete pPWLNoteItem;
+ }
- pNoteItem->ResetSubjectName(m_aChildren.GetSize() - 1);
+ for (int32_t i = nIndex, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
+ ASSERT(pChild->GetClassName() == "CPWL_NoteItem");
+ CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild;
+ pItem->ResetSubjectName(i);
+ }
+ }
- FX_SYSTEMTIME st;
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- st = pSH->GetLocalTime();
- pNoteItem->SetDateTime(st);
+ OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
+ }
+}
+
+IPWL_NoteItem* CPWL_Note_Contents::GetHitNoteItem(const CPDF_Point& point) {
+ CPDF_Point pt = ParentToChild(point);
- pNoteItem->SetContents(L"");
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
+ if (pChild->GetClassName() == "CPWL_NoteItem") {
+ CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild;
+ if (IPWL_NoteItem* pRet = pNoteItem->GetHitNoteItem(pt))
+ return pRet;
+ }
+ }
+ }
+ return NULL;
+}
+
+void CPWL_Note_Contents::OnNotify(CPWL_Wnd* pWnd,
+ FX_DWORD msg,
+ intptr_t wParam,
+ intptr_t lParam) {
+ switch (msg) {
+ case PNM_NOTEEDITCHANGED: {
+ int32_t nIndex = GetItemIndex(pWnd);
+ if (nIndex < 0)
+ nIndex = 0;
+
+ m_pEdit->EnableNotify(FALSE);
+ ResetContent(nIndex);
+ m_pEdit->EnableNotify(TRUE);
+
+ for (int32_t i = nIndex + 1, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
+ pChild->OnNotify(this, PNM_NOTERESET, 0, 0);
+ }
+
+ if (CPWL_Wnd* pParent = GetParentWindow()) {
+ pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
+ }
+ }
+ return;
+ case PNM_SCROLLWINDOW:
+ SetScrollPos(CPDF_Point(0.0f, *(FX_FLOAT*)lParam));
+ ResetFace();
+ InvalidateRect(NULL);
+ return;
+ case PNM_SETCARETINFO:
+ if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) {
+ PWL_CARET_INFO newInfo = *pInfo;
+ newInfo.bVisible = TRUE;
+ newInfo.ptHead = ChildToParent(pInfo->ptHead);
+ newInfo.ptFoot = ChildToParent(pInfo->ptFoot);
+
+ if (CPWL_Wnd* pParent = GetParentWindow()) {
+ pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0);
+ }
+ }
+ return;
+ case PNM_NOTERESET: {
+ m_pEdit->EnableNotify(FALSE);
+ ResetContent(0);
+ m_pEdit->EnableNotify(TRUE);
+
+ for (int32_t i = 1, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
+ pChild->OnNotify(this, PNM_NOTERESET, 0, 0);
+ }
+
+ m_pEdit->EnableNotify(FALSE);
+ ResetContent(0);
+ m_pEdit->EnableNotify(TRUE);
+ }
+ return;
+ }
+
+ CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
+}
+
+FX_BOOL CPWL_Note_Contents::OnLButtonDown(const 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 (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
+ if (pChild->GetClassName() == "CPWL_NoteItem") {
+ CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild;
+ pNoteItem->EnableModify(bEnabled);
+ }
+ }
+ }
+}
+
+void CPWL_Note_Contents::EnableRead(FX_BOOL bEnabled) {
+ if (!bEnabled)
+ m_pEdit->AddFlag(PES_NOREAD);
+ else
+ m_pEdit->RemoveFlag(PES_NOREAD);
+
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
+ if (pChild->GetClassName() == "CPWL_NoteItem") {
+ CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild;
+ pNoteItem->EnableRead(bEnabled);
+ }
+ }
+ }
+}
+
+/* ---------------------------------- CPWL_NoteItem
+ * ---------------------------------- */
+
+CPWL_NoteItem::CPWL_NoteItem()
+ : m_pSubject(NULL),
+ m_pDateTime(NULL),
+ m_pContents(NULL),
+ m_pPrivateData(NULL),
+ m_sAuthor(L""),
+ m_fOldItemHeight(0.0f),
+ m_bSizeChanged(FALSE),
+ m_bAllowModify(TRUE) {}
+
+CPWL_NoteItem::~CPWL_NoteItem() {}
+
+CFX_ByteString CPWL_NoteItem::GetClassName() const {
+ return "CPWL_NoteItem";
+}
+
+void CPWL_NoteItem::CreateChildWnd(const PWL_CREATEPARAM& cp) {
+ CPWL_Color sTextColor;
+
+ if (CPWL_Utils::IsBlackOrWhite(GetBackgroundColor()))
+ sTextColor = PWL_DEFAULT_WHITECOLOR;
+ else
+ sTextColor = PWL_DEFAULT_BLACKCOLOR;
+
+ m_pSubject = new CPWL_Label;
+ PWL_CREATEPARAM scp = cp;
+ scp.pParentWnd = this;
+ scp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_LEFT | PES_TOP;
+ scp.sTextColor = sTextColor;
+ m_pSubject->Create(scp);
+
+ m_pDateTime = new CPWL_Label;
+ PWL_CREATEPARAM dcp = cp;
+ dcp.pParentWnd = this;
+ dcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_RIGHT | PES_TOP;
+ dcp.sTextColor = sTextColor;
+ m_pDateTime->Create(dcp);
+
+ m_pContents = new CPWL_Note_Contents;
+ PWL_CREATEPARAM ccp = cp;
+ ccp.pParentWnd = this;
+ // ccp.sBackgroundColor = 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 (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;
+ SetBackgroundColor(sBK);
+
+ CPWL_Color sTextColor;
+
+ if (CPWL_Utils::IsBlackOrWhite(sBK))
+ sTextColor = PWL_DEFAULT_WHITECOLOR;
+ else
+ sTextColor = PWL_DEFAULT_BLACKCOLOR;
- OnNotify(pNoteItem, PNM_NOTEEDITCHANGED, 0, 0);
+ SetTextColor(sTextColor);
+ if (m_pSubject)
+ m_pSubject->SetTextColor(sTextColor);
+ if (m_pDateTime)
+ m_pDateTime->SetTextColor(sTextColor);
- return pNoteItem;
+ InvalidateRect(nullptr);
+
+ if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
+ pNotify->OnSetBkColor(this);
+ }
}
-int32_t CPWL_Note_Contents::CountSubItems() const
-{
- return m_aChildren.GetSize() - 1;
+void CPWL_NoteItem::SetSubjectName(const CFX_WideString& sName) {
+ if (m_pSubject) {
+ m_pSubject->SetText(sName.c_str());
+ }
+
+ if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
+ pNotify->OnSetSubjectName(this);
+ }
}
-IPWL_NoteItem* CPWL_Note_Contents::GetSubItems(int32_t index) const
-{
- int32_t nIndex = index + 1;
+void CPWL_NoteItem::SetAuthorName(const CFX_WideString& sName) {
+ m_sAuthor = sName;
+ ResetSubjectName(-1);
- if (nIndex > 0 && nIndex < m_aChildren.GetSize())
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(nIndex))
- {
- ASSERT(pChild->GetClassName() == "CPWL_NoteItem");
- CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild;
- return pItem;
- }
- return NULL;
-}
-
-void CPWL_Note_Contents::DeleteSubItem(IPWL_NoteItem* pNoteItem)
-{
- int32_t nIndex = GetItemIndex((CPWL_NoteItem*)pNoteItem);
-
- if (nIndex > 0)
- {
- if (CPWL_NoteItem* pPWLNoteItem = (CPWL_NoteItem*)pNoteItem)
- {
- pPWLNoteItem->KillFocus();
- pPWLNoteItem->Destroy();
- delete pPWLNoteItem;
- }
-
- for (int32_t i=nIndex,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- ASSERT(pChild->GetClassName() == "CPWL_NoteItem");
- CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild;
- pItem->ResetSubjectName(i);
- }
- }
-
- OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- }
-}
-
-IPWL_NoteItem* CPWL_Note_Contents::GetHitNoteItem(const CPDF_Point& point)
-{
- CPDF_Point pt = ParentToChild(point);
-
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- if (pChild->GetClassName() == "CPWL_NoteItem")
- {
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild;
- if (IPWL_NoteItem* pRet = pNoteItem->GetHitNoteItem(pt))
- return pRet;
- }
- }
- }
- return NULL;
-}
-
-void CPWL_Note_Contents::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam)
-{
- switch (msg)
- {
- case PNM_NOTEEDITCHANGED:
- {
- int32_t nIndex = GetItemIndex(pWnd);
- if (nIndex < 0) nIndex = 0;
-
- m_pEdit->EnableNotify(FALSE);
- ResetContent(nIndex);
- m_pEdit->EnableNotify(TRUE);
-
- for (int32_t i=nIndex+1, sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- pChild->OnNotify(this, PNM_NOTERESET, 0, 0);
- }
-
- if (CPWL_Wnd * pParent = GetParentWindow())
- {
- pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- }
- }
- return;
- case PNM_SCROLLWINDOW:
- SetScrollPos(CPDF_Point(0.0f, *(FX_FLOAT*)lParam));
- ResetFace();
- InvalidateRect(NULL);
- return;
- case PNM_SETCARETINFO:
- if (PWL_CARET_INFO * pInfo = (PWL_CARET_INFO*)wParam)
- {
- PWL_CARET_INFO newInfo = *pInfo;
- newInfo.bVisible = TRUE;
- newInfo.ptHead = ChildToParent(pInfo->ptHead);
- newInfo.ptFoot = ChildToParent(pInfo->ptFoot);
-
- if (CPWL_Wnd * pParent = GetParentWindow())
- {
- pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0);
- }
- }
- return;
- case PNM_NOTERESET:
- {
- m_pEdit->EnableNotify(FALSE);
- ResetContent(0);
- m_pEdit->EnableNotify(TRUE);
-
- for (int32_t i=1, sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- pChild->OnNotify(this, PNM_NOTERESET, 0, 0);
- }
-
- m_pEdit->EnableNotify(FALSE);
- ResetContent(0);
- m_pEdit->EnableNotify(TRUE);
- }
- return;
- }
-
- CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
-}
-
-FX_BOOL CPWL_Note_Contents::OnLButtonDown(const 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 (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- if (pChild->GetClassName() == "CPWL_NoteItem")
- {
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild;
- pNoteItem->EnableModify(bEnabled);
- }
- }
- }
-}
-
-void CPWL_Note_Contents::EnableRead(FX_BOOL bEnabled)
-{
- if (!bEnabled)
- m_pEdit->AddFlag(PES_NOREAD);
- else
- m_pEdit->RemoveFlag(PES_NOREAD);
-
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- if (pChild->GetClassName() == "CPWL_NoteItem")
- {
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild;
- pNoteItem->EnableRead(bEnabled);
- }
- }
- }
-}
-
-/* ---------------------------------- CPWL_NoteItem ---------------------------------- */
-
-CPWL_NoteItem::CPWL_NoteItem() :
- m_pSubject(NULL),
- m_pDateTime(NULL),
- m_pContents(NULL),
- m_pPrivateData(NULL),
- m_sAuthor(L""),
- m_fOldItemHeight(0.0f),
- m_bSizeChanged(FALSE),
- m_bAllowModify(TRUE)
-{
-}
-
-CPWL_NoteItem::~CPWL_NoteItem()
-{
-}
-
-CFX_ByteString CPWL_NoteItem::GetClassName() const
-{
- return "CPWL_NoteItem";
-}
-
-void CPWL_NoteItem::CreateChildWnd(const PWL_CREATEPARAM & cp)
-{
- CPWL_Color sTextColor;
-
- if (CPWL_Utils::IsBlackOrWhite(GetBackgroundColor()))
- sTextColor = PWL_DEFAULT_WHITECOLOR;
- else
- sTextColor = PWL_DEFAULT_BLACKCOLOR;
-
- m_pSubject = new CPWL_Label;
- PWL_CREATEPARAM scp = cp;
- scp.pParentWnd = this;
- scp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_LEFT | PES_TOP;
- scp.sTextColor = sTextColor;
- m_pSubject->Create(scp);
-
- m_pDateTime = new CPWL_Label;
- PWL_CREATEPARAM dcp = cp;
- dcp.pParentWnd = this;
- dcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_RIGHT | PES_TOP;
- dcp.sTextColor = sTextColor;
- m_pDateTime->Create(dcp);
-
- m_pContents = new CPWL_Note_Contents;
- PWL_CREATEPARAM ccp = cp;
- ccp.pParentWnd = this;
- //ccp.sBackgroundColor = 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 (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;
- SetBackgroundColor(sBK);
-
- CPWL_Color sTextColor;
-
- if (CPWL_Utils::IsBlackOrWhite(sBK))
- sTextColor = PWL_DEFAULT_WHITECOLOR;
- else
- sTextColor = PWL_DEFAULT_BLACKCOLOR;
-
- SetTextColor(sTextColor);
- if (m_pSubject)
- m_pSubject->SetTextColor(sTextColor);
- if (m_pDateTime)
- m_pDateTime->SetTextColor(sTextColor);
-
- InvalidateRect(nullptr);
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify())
- {
- pNotify->OnSetBkColor(this);
- }
-}
-
-void CPWL_NoteItem::SetSubjectName(const CFX_WideString& sName)
-{
- if (m_pSubject)
- {
- m_pSubject->SetText(sName.c_str());
- }
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify())
- {
- pNotify->OnSetSubjectName(this);
- }
-}
-
-void CPWL_NoteItem::SetAuthorName(const CFX_WideString& sName)
-{
- m_sAuthor = sName;
- ResetSubjectName(-1);
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify())
- {
- pNotify->OnSetAuthorName(this);
- }
-}
+ if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
+ pNotify->OnSetAuthorName(this);
+ }
+}
-void CPWL_NoteItem::ResetSubjectName(int32_t nItemIndex)
-{
- if (nItemIndex < 0)
- {
- if (CPWL_Wnd* pParent = GetParentWindow())
- {
- ASSERT(pParent->GetClassName() == "CPWL_Note_Contents");
+void CPWL_NoteItem::ResetSubjectName(int32_t nItemIndex) {
+ if (nItemIndex < 0) {
+ if (CPWL_Wnd* pParent = GetParentWindow()) {
+ ASSERT(pParent->GetClassName() == "CPWL_Note_Contents");
- CPWL_Note_Contents* pContents = (CPWL_Note_Contents*)pParent;
- nItemIndex = pContents->GetItemIndex(this);
- }
- }
+ CPWL_Note_Contents* pContents = (CPWL_Note_Contents*)pParent;
+ nItemIndex = pContents->GetItemIndex(this);
+ }
+ }
- const CPWL_Note* pNote = GetNote();
- ASSERT(pNote != NULL);
+ const CPWL_Note* pNote = GetNote();
+ ASSERT(pNote != NULL);
- CFX_WideString sSubject;
- sSubject.Format(pNote->GetReplyString().c_str(), nItemIndex);
+ CFX_WideString sSubject;
+ sSubject.Format(pNote->GetReplyString().c_str(), nItemIndex);
- if (!m_sAuthor.IsEmpty())
- {
- sSubject += L" - ";
- sSubject += m_sAuthor;
- }
- SetSubjectName(sSubject);
- RePosChildWnd();
+ if (!m_sAuthor.IsEmpty()) {
+ sSubject += L" - ";
+ sSubject += m_sAuthor;
+ }
+ SetSubjectName(sSubject);
+ RePosChildWnd();
}
-void CPWL_NoteItem::SetDateTime(FX_SYSTEMTIME time)
-{
- m_dtNote = time;
+void CPWL_NoteItem::SetDateTime(FX_SYSTEMTIME time) {
+ m_dtNote = time;
- CFX_WideString swTime;
- swTime.Format(L"%04d-%02d-%02d %02d:%02d:%02d", time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond);
- if (m_pDateTime)
- {
- m_pDateTime->SetText(swTime.c_str());
- }
+ CFX_WideString swTime;
+ swTime.Format(L"%04d-%02d-%02d %02d:%02d:%02d", time.wYear, time.wMonth,
+ time.wDay, time.wHour, time.wMinute, time.wSecond);
+ if (m_pDateTime) {
+ m_pDateTime->SetText(swTime.c_str());
+ }
- RePosChildWnd();
+ RePosChildWnd();
- if (IPWL_NoteNotify* pNotify = GetNoteNotify())
- {
- pNotify->OnSetDateTime(this);
- }
+ if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
+ pNotify->OnSetDateTime(this);
+ }
}
-void CPWL_NoteItem::SetContents(const CFX_WideString& sContents)
-{
- if (m_pContents)
- {
- m_pContents->SetText(sContents);
- }
+void CPWL_NoteItem::SetContents(const CFX_WideString& sContents) {
+ if (m_pContents) {
+ m_pContents->SetText(sContents);
+ }
- if (IPWL_NoteNotify* pNotify = GetNoteNotify())
- {
- pNotify->OnSetContents(this);
- }
+ if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
+ pNotify->OnSetContents(this);
+ }
}
-CPWL_NoteItem* CPWL_NoteItem::GetParentNoteItem() const
-{
- if (CPWL_Wnd* pParent = GetParentWindow())
- {
- if (CPWL_Wnd* pGrand = pParent->GetParentWindow())
- {
- ASSERT(pGrand->GetClassName() == "CPWL_NoteItem");
- return (CPWL_NoteItem*)pGrand;
- }
- }
+CPWL_NoteItem* CPWL_NoteItem::GetParentNoteItem() const {
+ if (CPWL_Wnd* pParent = GetParentWindow()) {
+ if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) {
+ ASSERT(pGrand->GetClassName() == "CPWL_NoteItem");
+ return (CPWL_NoteItem*)pGrand;
+ }
+ }
- return NULL;
+ return NULL;
}
-IPWL_NoteItem* CPWL_NoteItem::GetParentItem() const
-{
- return GetParentNoteItem();
+IPWL_NoteItem* CPWL_NoteItem::GetParentItem() const {
+ return GetParentNoteItem();
}
-CPWL_Edit* CPWL_NoteItem::GetEdit() const
-{
- if (m_pContents)
- return m_pContents->GetEdit();
- return NULL;
+CPWL_Edit* CPWL_NoteItem::GetEdit() const {
+ if (m_pContents)
+ return m_pContents->GetEdit();
+ return NULL;
}
-void* CPWL_NoteItem::GetPrivateData() const
-{
- return m_pPrivateData;
+void* CPWL_NoteItem::GetPrivateData() const {
+ return m_pPrivateData;
}
-CFX_WideString CPWL_NoteItem::GetAuthorName() const
-{
- return m_sAuthor;
+CFX_WideString CPWL_NoteItem::GetAuthorName() const {
+ return m_sAuthor;
}
-CPWL_Color CPWL_NoteItem::GetBkColor() const
-{
- return GetBackgroundColor();
+CPWL_Color CPWL_NoteItem::GetBkColor() const {
+ return GetBackgroundColor();
}
-CFX_WideString CPWL_NoteItem::GetContents() const
-{
- if (m_pContents)
- return m_pContents->GetText();
+CFX_WideString CPWL_NoteItem::GetContents() const {
+ if (m_pContents)
+ return m_pContents->GetText();
- return L"";
+ return L"";
}
-FX_SYSTEMTIME CPWL_NoteItem::GetDateTime() const
-{
- return m_dtNote;
+FX_SYSTEMTIME CPWL_NoteItem::GetDateTime() const {
+ return m_dtNote;
}
-CFX_WideString CPWL_NoteItem::GetSubjectName() const
-{
- if (m_pSubject)
- return m_pSubject->GetText();
+CFX_WideString CPWL_NoteItem::GetSubjectName() const {
+ if (m_pSubject)
+ return m_pSubject->GetText();
- return L"";
+ return L"";
}
-CPWL_NoteItem* CPWL_NoteItem::CreateNoteItem()
-{
- if (m_pContents)
- return m_pContents->CreateSubItem();
+CPWL_NoteItem* CPWL_NoteItem::CreateNoteItem() {
+ if (m_pContents)
+ return m_pContents->CreateSubItem();
- return NULL;
+ return NULL;
}
-IPWL_NoteItem* CPWL_NoteItem::CreateSubItem()
-{
- return CreateNoteItem();
+IPWL_NoteItem* CPWL_NoteItem::CreateSubItem() {
+ return CreateNoteItem();
}
-int32_t CPWL_NoteItem::CountSubItems() const
-{
- if (m_pContents)
- return m_pContents->CountSubItems();
+int32_t CPWL_NoteItem::CountSubItems() const {
+ if (m_pContents)
+ return m_pContents->CountSubItems();
- return 0;
+ return 0;
}
-IPWL_NoteItem* CPWL_NoteItem::GetSubItems(int32_t index) const
-{
- if (m_pContents)
- return m_pContents->GetSubItems(index);
+IPWL_NoteItem* CPWL_NoteItem::GetSubItems(int32_t index) const {
+ if (m_pContents)
+ return m_pContents->GetSubItems(index);
- return NULL;
+ return NULL;
}
-void CPWL_NoteItem::DeleteSubItem(IPWL_NoteItem* pNoteItem)
-{
- KillFocus();
+void CPWL_NoteItem::DeleteSubItem(IPWL_NoteItem* pNoteItem) {
+ KillFocus();
- if (IPWL_NoteNotify* pNotify = GetNoteNotify())
- {
- pNotify->OnItemDelete(pNoteItem);
- }
+ if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
+ pNotify->OnItemDelete(pNoteItem);
+ }
- if (m_pContents)
- m_pContents->DeleteSubItem(pNoteItem);
+ if (m_pContents)
+ m_pContents->DeleteSubItem(pNoteItem);
}
-IPWL_NoteItem* CPWL_NoteItem::GetHitNoteItem(const CPDF_Point& point)
-{
- CPDF_Point pt = ParentToChild(point);
+IPWL_NoteItem* CPWL_NoteItem::GetHitNoteItem(const CPDF_Point& point) {
+ CPDF_Point pt = ParentToChild(point);
- if (WndHitTest(pt))
- {
- if (m_pContents)
- {
- if (IPWL_NoteItem* pNoteItem = m_pContents->GetHitNoteItem(pt))
- return pNoteItem;
- }
+ if (WndHitTest(pt)) {
+ if (m_pContents) {
+ if (IPWL_NoteItem* pNoteItem = m_pContents->GetHitNoteItem(pt))
+ return pNoteItem;
+ }
- return this;
- }
+ return this;
+ }
- return NULL;
+ return NULL;
}
-IPWL_NoteItem* CPWL_NoteItem::GetFocusedNoteItem() const
-{
- if (const CPWL_Wnd* pWnd = GetFocused())
- {
- if (pWnd->GetClassName() == "CPWL_Edit")
- {
- if (CPWL_Wnd* pParent = pWnd->GetParentWindow())
- {
- ASSERT(pParent->GetClassName() == "CPWL_Note_Contents");
+IPWL_NoteItem* CPWL_NoteItem::GetFocusedNoteItem() const {
+ if (const CPWL_Wnd* pWnd = GetFocused()) {
+ if (pWnd->GetClassName() == "CPWL_Edit") {
+ if (CPWL_Wnd* pParent = pWnd->GetParentWindow()) {
+ ASSERT(pParent->GetClassName() == "CPWL_Note_Contents");
- if (CPWL_Wnd* pGrand = pParent->GetParentWindow())
- {
- ASSERT(pGrand->GetClassName() == "CPWL_NoteItem");
- return (CPWL_NoteItem*)pGrand;
- }
- }
- }
- }
+ if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) {
+ ASSERT(pGrand->GetClassName() == "CPWL_NoteItem");
+ return (CPWL_NoteItem*)pGrand;
+ }
+ }
+ }
+ }
- return NULL;
+ return NULL;
}
-FX_FLOAT CPWL_NoteItem::GetItemHeight(FX_FLOAT fLimitWidth)
-{
- if (fLimitWidth > 0)
- {
- if (!m_bSizeChanged)
- return m_fOldItemHeight;
+FX_FLOAT CPWL_NoteItem::GetItemHeight(FX_FLOAT fLimitWidth) {
+ if (fLimitWidth > 0) {
+ if (!m_bSizeChanged)
+ return m_fOldItemHeight;
+
+ m_bSizeChanged = FALSE;
- m_bSizeChanged = FALSE;
+ ASSERT(m_pSubject != NULL);
+ ASSERT(m_pDateTime != NULL);
+ ASSERT(m_pContents != NULL);
- ASSERT(m_pSubject != NULL);
- ASSERT(m_pDateTime != NULL);
- ASSERT(m_pContents != NULL);
+ FX_FLOAT fRet = m_pDateTime->GetContentRect().Height();
+ FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
+ if (fLimitWidth > fBorderWidth * 2)
+ fRet += m_pContents->GetContentsHeight(fLimitWidth - fBorderWidth * 2);
+ fRet += POPUP_ITEM_HEAD_BOTTOM + POPUP_ITEM_BOTTOMWIDTH + fBorderWidth * 2;
- FX_FLOAT fRet = m_pDateTime->GetContentRect().Height();
- FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth();
- if (fLimitWidth > fBorderWidth * 2)
- fRet += m_pContents->GetContentsHeight(fLimitWidth - fBorderWidth * 2);
- fRet += POPUP_ITEM_HEAD_BOTTOM + POPUP_ITEM_BOTTOMWIDTH + fBorderWidth * 2;
+ return m_fOldItemHeight = fRet;
+ }
- return m_fOldItemHeight = fRet;
- }
+ return 0;
+}
- return 0;
+FX_FLOAT CPWL_NoteItem::GetItemLeftMargin() {
+ return POPUP_ITEM_SIDEMARGIN;
}
-FX_FLOAT CPWL_NoteItem::GetItemLeftMargin()
-{
- return POPUP_ITEM_SIDEMARGIN;
+FX_FLOAT CPWL_NoteItem::GetItemRightMargin() {
+ 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);
}
-FX_BOOL CPWL_NoteItem::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag)
-{
- if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point)))
- {
- SetNoteFocus(FALSE);
- }
+void CPWL_NoteItem::OnNotify(CPWL_Wnd* pWnd,
+ FX_DWORD msg,
+ intptr_t wParam,
+ intptr_t lParam) {
+ switch (msg) {
+ case PNM_NOTEEDITCHANGED:
+ m_bSizeChanged = TRUE;
- CPWL_Wnd::OnLButtonDown(point,nFlag);
+ if (CPWL_Wnd* pParent = GetParentWindow()) {
+ pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
+ }
+ return;
+ case PNM_SETCARETINFO:
+ if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) {
+ PWL_CARET_INFO newInfo = *pInfo;
+ newInfo.bVisible = TRUE;
+ newInfo.ptHead = ChildToParent(pInfo->ptHead);
+ newInfo.ptFoot = ChildToParent(pInfo->ptFoot);
- return TRUE;
+ if (CPWL_Wnd* pParent = GetParentWindow()) {
+ pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0);
+ }
+ }
+ return;
+ case PNM_NOTERESET:
+ m_bSizeChanged = TRUE;
+ m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
+
+ return;
+ }
+
+ CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
}
-FX_BOOL CPWL_NoteItem::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
-{
- if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point)))
- {
- SetNoteFocus(FALSE);
- PopupNoteItemMenu(point);
+void CPWL_NoteItem::PopupNoteItemMenu(const CPDF_Point& point) {
+ if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
+ int32_t x, y;
+ PWLtoWnd(point, x, y);
+ if (IFX_SystemHandler* pSH = GetSystemHandler())
+ pSH->ClientToScreen(GetAttachedHWnd(), x, y);
+ pNotify->OnPopupMenu(this, x, y);
+ }
+}
- return TRUE;
- }
+const CPWL_Note* CPWL_NoteItem::GetNote() const {
+ if (const CPWL_Wnd* pRoot = GetRootWnd()) {
+ ASSERT(pRoot->GetClassName() == "CPWL_NoteItem");
+ CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pRoot;
+ if (pNoteItem->IsTopItem()) {
+ return (CPWL_Note*)pNoteItem;
+ }
+ }
- return CPWL_Wnd::OnRButtonUp(point,nFlag);
+ return NULL;
}
-void CPWL_NoteItem::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam)
-{
- switch (msg)
- {
- case PNM_NOTEEDITCHANGED:
- m_bSizeChanged = TRUE;
+IPWL_NoteNotify* CPWL_NoteItem::GetNoteNotify() const {
+ if (const CPWL_Note* pNote = GetNote())
+ return pNote->GetNoteNotify();
- if (CPWL_Wnd* pParent = GetParentWindow())
- {
- pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- }
- return;
- case PNM_SETCARETINFO:
- if (PWL_CARET_INFO * pInfo = (PWL_CARET_INFO*)wParam)
- {
- PWL_CARET_INFO newInfo = *pInfo;
- newInfo.bVisible = TRUE;
- newInfo.ptHead = ChildToParent(pInfo->ptHead);
- newInfo.ptFoot = ChildToParent(pInfo->ptFoot);
-
- if (CPWL_Wnd * pParent = GetParentWindow())
- {
- pParent->OnNotify(this, PNM_SETCARETINFO, (intptr_t)&newInfo, 0);
- }
- }
- return;
- case PNM_NOTERESET:
- m_bSizeChanged = TRUE;
- m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
+ return NULL;
+}
- return;
- }
+void CPWL_NoteItem::OnCreateNoteItem() {
+ if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
+ pNotify->OnItemCreate(this);
+ }
+}
- CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
+void CPWL_NoteItem::OnContentsValidate() {
+ if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
+ pNotify->OnSetContents(this);
+ }
}
-void CPWL_NoteItem::PopupNoteItemMenu(const CPDF_Point& point)
-{
- if (IPWL_NoteNotify* pNotify = GetNoteNotify())
- {
- int32_t x,y;
- PWLtoWnd(point, x, y);
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- pSH->ClientToScreen(GetAttachedHWnd(), x, y);
- pNotify->OnPopupMenu(this, x, y);
- }
+void CPWL_NoteItem::SetNoteFocus(FX_BOOL bLast) {
+ m_pContents->SetEditFocus(bLast);
}
-const CPWL_Note* CPWL_NoteItem::GetNote() const
-{
- if (const CPWL_Wnd* pRoot = GetRootWnd())
- {
- ASSERT(pRoot->GetClassName() == "CPWL_NoteItem");
- CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pRoot;
- if (pNoteItem->IsTopItem())
- {
- return (CPWL_Note*)pNoteItem;
- }
- }
+void CPWL_NoteItem::EnableModify(FX_BOOL bEnabled) {
+ m_pContents->EnableModify(bEnabled);
+ m_bAllowModify = bEnabled;
+}
- return NULL;
+void CPWL_NoteItem::EnableRead(FX_BOOL bEnabled) {
+ m_pContents->EnableRead(bEnabled);
}
-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_pLBBox(NULL),
- m_pRBBox(NULL),
- m_pContentsBar(NULL),
- m_pOptions(NULL),
- m_pNoteNotify(pNoteNotify),
- m_bResizing(FALSE),
- m_rcCaption(0,0,0,0),
- m_bEnalbleNotify(TRUE),
- m_pPopupNote(pPopupNote)
-{
-}
-
-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);
- OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
- if (const CPWL_Wnd* pWnd = GetFocused())
- {
- if (pWnd->GetClassName() == "CPWL_Edit")
- {
- CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
- pEdit->SetCaret(pEdit->GetCaret());
- }
- }
-}
-
-FX_BOOL CPWL_Note::ResetScrollBar()
-{
- FX_BOOL bScrollChanged = FALSE;
-
- if (ScrollBarShouldVisible())
- {
- if (!m_pContentsBar->IsVisible())
- {
- m_pContentsBar->SetVisible(TRUE);
- if (m_pContentsBar->IsVisible())
- {
- m_pContentsBar->InvalidateRect(NULL);
- bScrollChanged = TRUE;
- }
- }
- }
- else
- {
- if (m_pContentsBar->IsVisible())
- {
- m_pContentsBar->SetVisible(FALSE);
- m_pContentsBar->InvalidateRect(NULL);
-
- bScrollChanged = TRUE;
- }
- }
-
- if (bScrollChanged)
- {
- CPDF_Rect rcNote = 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 (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
-int32_t 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(GetBackgroundColor()))
- sTextColor = PWL_DEFAULT_WHITECOLOR;
- else
- sTextColor = PWL_DEFAULT_BLACKCOLOR;
-
- m_pAuthor = new CPWL_Label;
- PWL_CREATEPARAM acp = cp;
- acp.pParentWnd = this;
- acp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_LEFT | PES_TOP;
- acp.sTextColor = sTextColor;
- m_pAuthor->Create(acp);
-
- m_pCloseBox = new CPWL_Note_CloseBox;
- PWL_CREATEPARAM ccp = cp;
- ccp.pParentWnd = this;
- ccp.dwBorderWidth = 2;
- ccp.nBorderStyle = PBS_BEVELED;
- ccp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER;
- ccp.sTextColor = sTextColor;
- m_pCloseBox->Create(ccp);
-
- m_pIcon = new CPWL_Note_Icon;
- PWL_CREATEPARAM icp = cp;
- icp.pParentWnd = this;
- icp.dwFlags = PWS_VISIBLE | PWS_CHILD;
- m_pIcon->Create(icp);
-
- m_pOptions = new CPWL_Note_Options;
- PWL_CREATEPARAM ocp = cp;
- ocp.pParentWnd = this;
- ocp.dwFlags = PWS_CHILD | PWS_VISIBLE;
- ocp.sTextColor = sTextColor;
- m_pOptions->Create(ocp);
-
- m_pLBBox = new CPWL_Note_LBBox;
- PWL_CREATEPARAM lcp = cp;
- lcp.pParentWnd = this;
- lcp.dwFlags = PWS_VISIBLE | PWS_CHILD;
- lcp.eCursorType = FXCT_NESW;
- lcp.sTextColor = sTextColor;
- m_pLBBox->Create(lcp);
-
- m_pRBBox = new CPWL_Note_RBBox;
- PWL_CREATEPARAM rcp = cp;
- rcp.pParentWnd = this;
- rcp.dwFlags = PWS_VISIBLE | PWS_CHILD;
- rcp.eCursorType = FXCT_NWSE;
- rcp.sTextColor = sTextColor;
- m_pRBBox->Create(rcp);
-
- m_pContentsBar = new CPWL_ScrollBar(SBT_VSCROLL);
- PWL_CREATEPARAM scp = cp;
- scp.pParentWnd = this;
- scp.sBackgroundColor = CPWL_Color(COLORTYPE_RGB, 240/255.0f, 240/255.0f, 240/255.0f);
- scp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_BACKGROUND;
- m_pContentsBar->Create(scp);
- m_pContentsBar->SetNotifyForever(TRUE);
-}
-
-void CPWL_Note::SetSubjectName(const CFX_WideString& sName)
-{
- CPWL_NoteItem::SetSubjectName(sName);
- RePosChildWnd();
-}
-
-void CPWL_Note::SetAuthorName(const CFX_WideString& sName)
-{
- if (m_pAuthor)
- {
- m_pAuthor->SetText(sName.c_str());
- RePosChildWnd();
- }
-
- if (IPWL_NoteNotify* pNotify = GetNoteNotify())
- {
- pNotify->OnSetAuthorName(this);
- }
-}
-
-CFX_WideString CPWL_Note::GetAuthorName() const
-{
- if (m_pAuthor)
- return m_pAuthor->GetText();
-
- return L"";
-}
-
-FX_BOOL CPWL_Note::OnMouseWheel(short zDelta, const 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, (intptr_t)&ptNew.y);
- m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&ptNew.y);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-void CPWL_Note::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam)
-{
- switch (msg)
- {
- case PNM_NOTEEDITCHANGED:
- {
- 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);
- OnNotify(this, PNM_NOTEEDITCHANGED, 0, lParam);
- }
- }
-
- if (!bScrollChanged)
- {
- if (m_pContentsBar->IsVisible())
- {
- m_pContentsBar->OnNotify(pWnd, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&sInfo);
- m_OldScrollInfo = sInfo;
-
- 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, (intptr_t)&ptScroll.y);
- m_pContentsBar->InvalidateRect(NULL);
- m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL, (intptr_t)&ptScroll.y);
- }
- }
- }
- }
- }
-
- m_pContents->InvalidateRect(NULL);
-
- return;
- case PNM_SCROLLWINDOW:
- if (m_pContents)
- m_pContents->OnNotify(pWnd, msg, wParam, lParam);
- return;
- case PNM_SETSCROLLPOS:
- if (m_pContentsBar)
- m_pContentsBar->OnNotify(pWnd,PNM_SETSCROLLPOS,wParam,lParam);
- return;
- }
-
- if (msg == PNM_SETCARETINFO && IsValid())
- {
- if (PWL_CARET_INFO * pInfo = (PWL_CARET_INFO*)wParam)
- {
- if (m_pContents)
- {
- 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, (intptr_t)&pt.y);
-
- CPDF_Point ptScroll = m_pContents->GetScrollPos();
- m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&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, (intptr_t)&pt.y);
-
- CPDF_Point ptScroll = m_pContents->GetScrollPos();
- m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&ptScroll.y);
-
- return;
- }
- }
- }
- }
-
- CPWL_NoteItem::OnNotify(pWnd, msg, wParam, lParam);
-}
-
-void CPWL_Note::SetBkColor(const CPWL_Color& color)
-{
- CPWL_NoteItem::SetBkColor(color);
-
- CPWL_Color sBK = color;
- CPWL_Color sTextColor;
- if (CPWL_Utils::IsBlackOrWhite(sBK))
- sTextColor = PWL_DEFAULT_WHITECOLOR;
- else
- sTextColor = PWL_DEFAULT_BLACKCOLOR;
-
- if (m_pCloseBox)
- m_pCloseBox->SetTextColor(sTextColor);
- if (m_pAuthor)
- m_pAuthor->SetTextColor(sTextColor);
- if (m_pOptions)
- m_pOptions->SetTextColor(sTextColor);
- if (m_pLBBox)
- m_pLBBox->SetTextColor(sTextColor);
- if (m_pRBBox)
- m_pRBBox->SetTextColor(sTextColor);
-}
-
-FX_BOOL CPWL_Note::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag)
-{
- if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point)))
- {
- if (IPWL_NoteNotify* pNotify = GetNoteNotify())
- {
- int32_t x, y;
- PWLtoWnd(point, x, y);
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- pSH->ClientToScreen(GetAttachedHWnd(), x, y);
- KillFocus();
- pNotify->OnPopupMenu(x, y);
-
- return TRUE;
- }
- }
+/* ---------------------------------- 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_pLBBox(NULL),
+ m_pRBBox(NULL),
+ m_pContentsBar(NULL),
+ m_pOptions(NULL),
+ m_pNoteNotify(pNoteNotify),
+ m_bResizing(FALSE),
+ m_rcCaption(0, 0, 0, 0),
+ m_bEnalbleNotify(TRUE),
+ m_pPopupNote(pPopupNote) {}
- return CPWL_Wnd::OnLButtonDown(point,nFlag);
+CPWL_Note::~CPWL_Note() {}
+
+IPWL_NoteItem* CPWL_Note::Reply() {
+ return CreateNoteItem();
+}
+
+void CPWL_Note::EnableNotify(FX_BOOL bEnabled) {
+ m_bEnalbleNotify = bEnabled;
}
-FX_BOOL CPWL_Note::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
-{
- return CPWL_Wnd::OnRButtonUp(point,nFlag);
+void CPWL_Note::RePosChildWnd() {
+ RePosNoteChildren();
+ m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
+ ResetScrollBar();
+ m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0);
+ OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0);
+ if (const CPWL_Wnd* pWnd = GetFocused()) {
+ if (pWnd->GetClassName() == "CPWL_Edit") {
+ CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
+ pEdit->SetCaret(pEdit->GetCaret());
+ }
+ }
+}
+
+FX_BOOL CPWL_Note::ResetScrollBar() {
+ FX_BOOL bScrollChanged = FALSE;
+
+ if (ScrollBarShouldVisible()) {
+ if (!m_pContentsBar->IsVisible()) {
+ m_pContentsBar->SetVisible(TRUE);
+ if (m_pContentsBar->IsVisible()) {
+ m_pContentsBar->InvalidateRect(NULL);
+ bScrollChanged = TRUE;
+ }
+ }
+ } else {
+ if (m_pContentsBar->IsVisible()) {
+ m_pContentsBar->SetVisible(FALSE);
+ m_pContentsBar->InvalidateRect(NULL);
+
+ bScrollChanged = TRUE;
+ }
+ }
+
+ if (bScrollChanged) {
+ CPDF_Rect rcNote = 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 (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
+int32_t 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(GetBackgroundColor()))
+ sTextColor = PWL_DEFAULT_WHITECOLOR;
+ else
+ sTextColor = PWL_DEFAULT_BLACKCOLOR;
+
+ m_pAuthor = new CPWL_Label;
+ PWL_CREATEPARAM acp = cp;
+ acp.pParentWnd = this;
+ acp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_LEFT | PES_TOP;
+ acp.sTextColor = sTextColor;
+ m_pAuthor->Create(acp);
+
+ m_pCloseBox = new CPWL_Note_CloseBox;
+ PWL_CREATEPARAM ccp = cp;
+ ccp.pParentWnd = this;
+ ccp.dwBorderWidth = 2;
+ ccp.nBorderStyle = PBS_BEVELED;
+ ccp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER;
+ ccp.sTextColor = sTextColor;
+ m_pCloseBox->Create(ccp);
+
+ m_pIcon = new CPWL_Note_Icon;
+ PWL_CREATEPARAM icp = cp;
+ icp.pParentWnd = this;
+ icp.dwFlags = PWS_VISIBLE | PWS_CHILD;
+ m_pIcon->Create(icp);
+
+ m_pOptions = new CPWL_Note_Options;
+ PWL_CREATEPARAM ocp = cp;
+ ocp.pParentWnd = this;
+ ocp.dwFlags = PWS_CHILD | PWS_VISIBLE;
+ ocp.sTextColor = sTextColor;
+ m_pOptions->Create(ocp);
+
+ m_pLBBox = new CPWL_Note_LBBox;
+ PWL_CREATEPARAM lcp = cp;
+ lcp.pParentWnd = this;
+ lcp.dwFlags = PWS_VISIBLE | PWS_CHILD;
+ lcp.eCursorType = FXCT_NESW;
+ lcp.sTextColor = sTextColor;
+ m_pLBBox->Create(lcp);
+
+ m_pRBBox = new CPWL_Note_RBBox;
+ PWL_CREATEPARAM rcp = cp;
+ rcp.pParentWnd = this;
+ rcp.dwFlags = PWS_VISIBLE | PWS_CHILD;
+ rcp.eCursorType = FXCT_NWSE;
+ rcp.sTextColor = sTextColor;
+ m_pRBBox->Create(rcp);
+
+ m_pContentsBar = new CPWL_ScrollBar(SBT_VSCROLL);
+ PWL_CREATEPARAM scp = cp;
+ scp.pParentWnd = this;
+ scp.sBackgroundColor =
+ CPWL_Color(COLORTYPE_RGB, 240 / 255.0f, 240 / 255.0f, 240 / 255.0f);
+ scp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_BACKGROUND;
+ m_pContentsBar->Create(scp);
+ m_pContentsBar->SetNotifyForever(TRUE);
+}
+
+void CPWL_Note::SetSubjectName(const CFX_WideString& sName) {
+ CPWL_NoteItem::SetSubjectName(sName);
+ RePosChildWnd();
+}
+
+void CPWL_Note::SetAuthorName(const CFX_WideString& sName) {
+ if (m_pAuthor) {
+ m_pAuthor->SetText(sName.c_str());
+ RePosChildWnd();
+ }
+
+ if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
+ pNotify->OnSetAuthorName(this);
+ }
+}
+
+CFX_WideString CPWL_Note::GetAuthorName() const {
+ if (m_pAuthor)
+ return m_pAuthor->GetText();
+
+ return L"";
+}
+
+FX_BOOL CPWL_Note::OnMouseWheel(short zDelta,
+ const 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,
+ (intptr_t)&ptNew.y);
+ m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
+ (intptr_t)&ptNew.y);
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+void CPWL_Note::OnNotify(CPWL_Wnd* pWnd,
+ FX_DWORD msg,
+ intptr_t wParam,
+ intptr_t lParam) {
+ switch (msg) {
+ case PNM_NOTEEDITCHANGED: {
+ 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);
+ OnNotify(this, PNM_NOTEEDITCHANGED, 0, lParam);
+ }
+ }
+
+ if (!bScrollChanged) {
+ if (m_pContentsBar->IsVisible()) {
+ m_pContentsBar->OnNotify(pWnd, PNM_SETSCROLLINFO, SBT_VSCROLL,
+ (intptr_t)&sInfo);
+ m_OldScrollInfo = sInfo;
+
+ 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,
+ (intptr_t)&ptScroll.y);
+ m_pContentsBar->InvalidateRect(NULL);
+ m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL,
+ (intptr_t)&ptScroll.y);
+ }
+ }
+ }
+ }
+ }
+
+ m_pContents->InvalidateRect(NULL);
+
+ return;
+ case PNM_SCROLLWINDOW:
+ if (m_pContents)
+ m_pContents->OnNotify(pWnd, msg, wParam, lParam);
+ return;
+ case PNM_SETSCROLLPOS:
+ if (m_pContentsBar)
+ m_pContentsBar->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam);
+ return;
+ }
+
+ if (msg == PNM_SETCARETINFO && IsValid()) {
+ if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) {
+ if (m_pContents) {
+ 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,
+ (intptr_t)&pt.y);
+
+ CPDF_Point ptScroll = m_pContents->GetScrollPos();
+ m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
+ (intptr_t)&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,
+ (intptr_t)&pt.y);
+
+ CPDF_Point ptScroll = m_pContents->GetScrollPos();
+ m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL,
+ (intptr_t)&ptScroll.y);
+
+ return;
+ }
+ }
+ }
+ }
+
+ CPWL_NoteItem::OnNotify(pWnd, msg, wParam, lParam);
+}
+
+void CPWL_Note::SetBkColor(const CPWL_Color& color) {
+ CPWL_NoteItem::SetBkColor(color);
+
+ CPWL_Color sBK = color;
+ CPWL_Color sTextColor;
+ if (CPWL_Utils::IsBlackOrWhite(sBK))
+ sTextColor = PWL_DEFAULT_WHITECOLOR;
+ else
+ sTextColor = PWL_DEFAULT_BLACKCOLOR;
+
+ if (m_pCloseBox)
+ m_pCloseBox->SetTextColor(sTextColor);
+ if (m_pAuthor)
+ m_pAuthor->SetTextColor(sTextColor);
+ if (m_pOptions)
+ m_pOptions->SetTextColor(sTextColor);
+ if (m_pLBBox)
+ m_pLBBox->SetTextColor(sTextColor);
+ if (m_pRBBox)
+ m_pRBBox->SetTextColor(sTextColor);
}
-const CPWL_Note* CPWL_Note::GetNote() const
-{
- return this;
+FX_BOOL CPWL_Note::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) {
+ if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point))) {
+ if (IPWL_NoteNotify* pNotify = GetNoteNotify()) {
+ int32_t x, y;
+ PWLtoWnd(point, x, y);
+ if (IFX_SystemHandler* pSH = GetSystemHandler())
+ pSH->ClientToScreen(GetAttachedHWnd(), x, y);
+ KillFocus();
+ pNotify->OnPopupMenu(x, y);
+
+ return TRUE;
+ }
+ }
+
+ return CPWL_Wnd::OnLButtonDown(point, nFlag);
}
-IPWL_NoteNotify* CPWL_Note::GetNoteNotify() const
-{
- if (m_bEnalbleNotify)
- return m_pNoteNotify;
+FX_BOOL CPWL_Note::OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag) {
+ return CPWL_Wnd::OnRButtonUp(point, nFlag);
+}
- return NULL;
+const CPWL_Note* CPWL_Note::GetNote() const {
+ return this;
}
-void CPWL_Note::SetIconType(int32_t nType)
-{
- if (m_pIcon)
- m_pIcon->SetIconType(nType);
+IPWL_NoteNotify* CPWL_Note::GetNoteNotify() const {
+ if (m_bEnalbleNotify)
+ return m_pNoteNotify;
+
+ return NULL;
}
-void CPWL_Note::EnableModify(FX_BOOL bEnabled)
-{
- m_pContents->EnableModify(bEnabled);
+void CPWL_Note::SetIconType(int32_t nType) {
+ if (m_pIcon)
+ m_pIcon->SetIconType(nType);
}
-void CPWL_Note::EnableRead(FX_BOOL bEnabled)
-{
- m_pContents->EnableRead(bEnabled);
+void CPWL_Note::EnableModify(FX_BOOL bEnabled) {
+ m_pContents->EnableModify(bEnabled);
}
-CFX_WideString CPWL_Note::GetReplyString() const
-{
- return m_sReplyString;
+void CPWL_Note::EnableRead(FX_BOOL bEnabled) {
+ m_pContents->EnableRead(bEnabled);
}
-void CPWL_Note::SetReplyString(const CFX_WideString& string)
-{
- m_sReplyString = string;
+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 6d61705222..c762b4cd92 100644
--- a/fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp
@@ -9,1295 +9,1201 @@
#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))
+#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::PWL_FLOATRANGE()
-{
- Default();
+PWL_FLOATRANGE::PWL_FLOATRANGE() {
+ Default();
}
-PWL_FLOATRANGE::PWL_FLOATRANGE(FX_FLOAT min,FX_FLOAT max)
-{
- Set(min,max);
+PWL_FLOATRANGE::PWL_FLOATRANGE(FX_FLOAT min, FX_FLOAT max) {
+ Set(min, max);
}
-void PWL_FLOATRANGE::Default()
-{
- fMin = 0;
- fMax = 0;
+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;
- }
+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_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;
+FX_FLOAT PWL_FLOATRANGE::GetWidth() const {
+ return fMax - fMin;
}
-/* ------------------------------- PWL_SCROLL_PRIVATEDATA ------------------------------- */
+/* ------------------------------- PWL_SCROLL_PRIVATEDATA
+ * ------------------------------- */
-PWL_SCROLL_PRIVATEDATA::PWL_SCROLL_PRIVATEDATA()
-{
- Default();
+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::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);
+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;
+ 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::SetClientWidth(FX_FLOAT width) {
+ fClientWidth = width;
}
-void PWL_SCROLL_PRIVATEDATA::SetSmallStep(FX_FLOAT step)
-{
- fSmallStep = step;
+void PWL_SCROLL_PRIVATEDATA::SetSmallStep(FX_FLOAT step) {
+ fSmallStep = step;
}
-void PWL_SCROLL_PRIVATEDATA::SetBigStep(FX_FLOAT step)
-{
- fBigStep = 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;
+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::AddSmall() {
+ if (!SetPos(fScrollPos + fSmallStep))
+ SetPos(ScrollRange.fMax);
}
-void PWL_SCROLL_PRIVATEDATA::SubSmall()
-{
- if (!SetPos(fScrollPos - fSmallStep))
- SetPos(ScrollRange.fMin);
+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::AddBig() {
+ if (!SetPos(fScrollPos + fBigStep))
+ SetPos(ScrollRange.fMax);
}
-void PWL_SCROLL_PRIVATEDATA::SubBig()
-{
- if (!SetPos(fScrollPos - fBigStep))
- SetPos(ScrollRange.fMin);
+void PWL_SCROLL_PRIVATEDATA::SubBig() {
+ if (!SetPos(fScrollPos - fBigStep))
+ SetPos(ScrollRange.fMin);
}
-/* ------------------------------- CPWL_SBButton ------------------------------- */
+/* ------------------------------- CPWL_SBButton -------------------------------
+ */
-CPWL_SBButton::CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType,PWL_SBBUTTON_TYPE eButtonType)
-{
- m_eScrollBarType = eScrollBarType;
- m_eSBButtonType = eButtonType;
+CPWL_SBButton::CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType,
+ PWL_SBBUTTON_TYPE eButtonType) {
+ m_eScrollBarType = eScrollBarType;
+ m_eSBButtonType = eButtonType;
- m_bMouseDown = FALSE;
+ m_bMouseDown = FALSE;
}
-CPWL_SBButton::~CPWL_SBButton()
-{
-
-}
+CPWL_SBButton::~CPWL_SBButton() {}
-CFX_ByteString CPWL_SBButton::GetClassName() const
-{
- return "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::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 = GetCenterPoint();
-
- switch (m_eScrollBarType)
- {
- case SBT_HSCROLL:
- switch (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 (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::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 = GetCenterPoint();
+
+ switch (m_eScrollBarType) {
+ case SBT_HSCROLL:
+ switch (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 (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 = GetCenterPoint();
- int32_t nTransparancy = GetTransparency();
-
- switch (m_eScrollBarType)
- {
- case SBT_HSCROLL:
- CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
- switch (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 (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 (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 (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 (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 (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 (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
+void CPWL_SBButton::DrawThisAppearance(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device) {
+ if (!IsVisible())
+ return;
+
+ CPDF_Rect rectWnd = GetWindowRect();
+ if (rectWnd.IsEmpty())
+ return;
+
+ CPDF_Point ptCenter = GetCenterPoint();
+ int32_t nTransparancy = GetTransparency();
+
+ switch (m_eScrollBarType) {
+ case SBT_HSCROLL:
+ CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
+ switch (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 (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 (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 (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 (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 (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 (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 (!IsEnabled())
+ crStroke = CPWL_Utils::PWLColorToFXColor(
+ PWL_DEFAULT_HEAVYGRAYCOLOR, 255);
+
+ FX_FLOAT nFrictionWidth = 5.0f;
+ FX_FLOAT nFrictionHeight = 5.5f;
- if (rectWnd.Height() > 8.0f)
- {
- FX_COLORREF crStroke = ArgbEncode(nTransparancy,120,120,120);
- if (!IsEnabled())
- crStroke = CPWL_Utils::PWLColorToFXColor(PWL_DEFAULT_HEAVYGRAYCOLOR,255);
+ 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);
- FX_FLOAT nFrictionWidth = 5.0f;
- FX_FLOAT nFrictionHeight = 5.5f;
+ CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight,
+ crStroke, 1.0f);
- 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);
+ ptLeft.y += 2.0f;
+ ptRight.y += 2.0f;
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight,
- crStroke,1.0f);
+ CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight,
+ crStroke, 1.0f);
- ptLeft.y += 2.0f;
- ptRight.y += 2.0f;
+ ptLeft.y += 2.0f;
+ ptRight.y += 2.0f;
+
+ CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight,
+ crStroke, 1.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;
+ }
+}
- ptLeft.y += 2.0f;
- ptRight.y += 2.0f;
+FX_BOOL CPWL_SBButton::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) {
+ CPWL_Wnd::OnLButtonDown(point, nFlag);
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight,
- crStroke,1.0f);
+ if (CPWL_Wnd* pParent = GetParentWindow())
+ pParent->OnNotify(this, PNM_LBUTTONDOWN, 0, (intptr_t)&point);
- /*
- ptLeft.y += 1.5f;
- ptRight.y += 1.5f;
+ m_bMouseDown = TRUE;
+ SetCapture();
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight,
- ArgbEncode(nTransparancy,150,150,150),1.0f);
- */
- }
- }
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
+ return TRUE;
}
-FX_BOOL CPWL_SBButton::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonDown(point,nFlag);
+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_LBUTTONDOWN,0,(intptr_t)&point);
+ if (CPWL_Wnd* pParent = GetParentWindow())
+ pParent->OnNotify(this, PNM_LBUTTONUP, 0, (intptr_t)&point);
- m_bMouseDown = TRUE;
- SetCapture();
+ m_bMouseDown = FALSE;
+ ReleaseCapture();
- return TRUE;
+ return TRUE;
}
-FX_BOOL CPWL_SBButton::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonUp(point,nFlag);
+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_LBUTTONUP,0,(intptr_t)&point);
+ if (CPWL_Wnd* pParent = GetParentWindow()) {
+ pParent->OnNotify(this, PNM_MOUSEMOVE, 0, (intptr_t)&point);
- m_bMouseDown = FALSE;
- ReleaseCapture();
+ /*
+ if (m_bMouseDown && (m_eSBButtonType == PSBT_MIN || m_eSBButtonType ==
+ PSBT_MAX))
+ {
+ if
+ (!pParent->OnNotify(this,PNM_LBUTTONDOWN,nFlags,(intptr_t)&point))
+ return FALSE;
+ }
+ */
+ }
- return TRUE;
+ return TRUE;
}
-FX_BOOL CPWL_SBButton::OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnMouseMove(point,nFlag);
+/* ------------------------------- CPWL_ScrollBar
+ * ---------------------------------- */
- if (CPWL_Wnd * pParent = GetParentWindow())
- {
- pParent->OnNotify(this,PNM_MOUSEMOVE,0,(intptr_t)&point);
+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) {}
- /*
- if (m_bMouseDown && (m_eSBButtonType == PSBT_MIN || m_eSBButtonType == PSBT_MAX))
- {
- if (!pParent->OnNotify(this,PNM_LBUTTONDOWN,nFlags,(intptr_t)&point))
- return FALSE;
- }
- */
- }
+CPWL_ScrollBar::~CPWL_ScrollBar() {}
- return TRUE;
+CFX_ByteString CPWL_ScrollBar::GetClassName() const {
+ return "CPWL_ScrollBar";
}
-/* ------------------------------- 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)
-{
+void CPWL_ScrollBar::OnCreate(PWL_CREATEPARAM& cp) {
+ cp.eCursorType = FXCT_ARROW;
}
-CPWL_ScrollBar::~CPWL_ScrollBar()
-{
+void CPWL_ScrollBar::RePosChildWnd() {
+ CPDF_Rect rcClient = GetClientRect();
+ 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 (m_pMinButton)
+ m_pMinButton->Move(rcMinButton, TRUE, FALSE);
+ if (m_pMaxButton)
+ m_pMaxButton->Move(rcMaxButton, TRUE, FALSE);
+ MovePosButton(FALSE);
}
-CFX_ByteString CPWL_ScrollBar::GetClassName() const
-{
- return "CPWL_ScrollBar";
-}
+void CPWL_ScrollBar::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
+ CPDF_Rect rectWnd = GetWindowRect();
-void CPWL_ScrollBar::OnCreate(PWL_CREATEPARAM & cp)
-{
- cp.eCursorType = FXCT_ARROW;
-}
-
-void CPWL_ScrollBar::RePosChildWnd()
-{
- CPDF_Rect rcClient = GetClientRect();
- 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 (m_pMinButton)
- m_pMinButton->Move(rcMinButton, TRUE, FALSE);
- if (m_pMaxButton)
- m_pMaxButton->Move(rcMaxButton, TRUE, FALSE);
- MovePosButton(FALSE);
-}
+ if (IsVisible() && !rectWnd.IsEmpty()) {
+ CFX_ByteTextBuf sButton;
-void CPWL_ScrollBar::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
-{
- CPDF_Rect rectWnd = GetWindowRect();
+ 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";
- if (IsVisible() && !rectWnd.IsEmpty())
- {
- CFX_ByteTextBuf sButton;
+ sAppStream << 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";
+void CPWL_ScrollBar::DrawThisAppearance(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device) {
+ CPDF_Rect rectWnd = GetWindowRect();
+
+ if (IsVisible() && !rectWnd.IsEmpty()) {
+ CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rectWnd,
+ 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(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(GetTransparency(), 100, 100, 100), 1.0f);
+ }
+}
- sAppStream << sButton;
- }
+FX_BOOL CPWL_ScrollBar::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) {
+ CPWL_Wnd::OnLButtonDown(point, nFlag);
+
+ if (HasFlag(PWS_AUTOTRANSPARENT)) {
+ if (GetTransparency() != 255) {
+ SetTransparency(255);
+ InvalidateRect();
+ }
+ }
+
+ CPDF_Rect rcMinArea, rcMaxArea;
+
+ if (m_pPosButton && m_pPosButton->IsVisible()) {
+ CPDF_Rect rcClient = 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;
}
-void CPWL_ScrollBar::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- CPDF_Rect rectWnd = GetWindowRect();
+FX_BOOL CPWL_ScrollBar::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) {
+ CPWL_Wnd::OnLButtonUp(point, nFlag);
- if (IsVisible() && !rectWnd.IsEmpty())
- {
- CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rectWnd, GetBackgroundColor(), GetTransparency());
+ if (HasFlag(PWS_AUTOTRANSPARENT)) {
+ if (GetTransparency() != PWL_SCROLLBAR_TRANSPARANCY) {
+ SetTransparency(PWL_SCROLLBAR_TRANSPARANCY);
+ InvalidateRect();
+ }
+ }
- 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(GetTransparency(), 100, 100, 100), 1.0f);
+ EndTimer();
+ m_bMouseDown = FALSE;
- 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(GetTransparency(), 100, 100, 100),1.0f);
- }
+ return TRUE;
}
-FX_BOOL CPWL_ScrollBar::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
-{
- CPWL_Wnd::OnLButtonDown(point,nFlag);
-
- if (HasFlag(PWS_AUTOTRANSPARENT))
- {
- if (GetTransparency() != 255)
- {
- SetTransparency(255);
- InvalidateRect();
- }
- }
-
- CPDF_Rect rcMinArea,rcMaxArea;
-
- if (m_pPosButton && m_pPosButton->IsVisible())
- {
- CPDF_Rect rcClient = 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;
+void CPWL_ScrollBar::OnNotify(CPWL_Wnd* pWnd,
+ FX_DWORD msg,
+ intptr_t wParam,
+ intptr_t lParam) {
+ CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
+
+ switch (msg) {
+ case PNM_LBUTTONDOWN:
+ if (pWnd == m_pMinButton) {
+ OnMinButtonLBDown(*(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;
+ SetScrollRange(0, fMax, pInfo->fPlateWidth);
+ SetScrollStep(pInfo->fBigStep, pInfo->fSmallStep);
+ }
+ }
+ } break;
+ case PNM_SETSCROLLPOS: {
+ FX_FLOAT fPos = *(FX_FLOAT*)lParam;
+ switch (m_sbType) {
+ case SBT_HSCROLL:
+ fPos = fPos - m_OriginInfo.fContentMin;
+ break;
+ case SBT_VSCROLL:
+ fPos = m_OriginInfo.fContentMax - fPos;
+ break;
+ }
+ SetScrollPos(fPos);
+ } break;
+ }
}
-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();
- }
- }
+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);
+ }
+}
- EndTimer();
- m_bMouseDown = FALSE;
+FX_FLOAT CPWL_ScrollBar::GetScrollBarWidth() const {
+ if (!IsVisible())
+ return 0;
- return TRUE;
+ return PWL_SCROLLBAR_WIDTH;
}
-void CPWL_ScrollBar::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam)
-{
- CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam);
-
- switch (msg)
- {
- case PNM_LBUTTONDOWN:
- if (pWnd == m_pMinButton)
- {
- OnMinButtonLBDown(*(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;
- SetScrollRange(0, fMax, pInfo->fPlateWidth);
- SetScrollStep(pInfo->fBigStep, pInfo->fSmallStep);
- }
- }
- }
- break;
- case PNM_SETSCROLLPOS:
- {
- FX_FLOAT fPos = *(FX_FLOAT*)lParam;
- switch (m_sbType)
- {
- case SBT_HSCROLL:
- fPos = fPos - m_OriginInfo.fContentMin;
- break;
- case SBT_VSCROLL:
- fPos = m_OriginInfo.fContentMax - fPos;
- break;
- }
- SetScrollPos(fPos);
- }
- break;
- }
+void CPWL_ScrollBar::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::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);
- }
-}
+void CPWL_ScrollBar::SetScrollPos(FX_FLOAT fPos) {
+ FX_FLOAT fOldPos = m_sData.fScrollPos;
-FX_FLOAT CPWL_ScrollBar::GetScrollBarWidth() const
-{
- if (!IsVisible()) return 0;
+ m_sData.SetPos(fPos);
- return PWL_SCROLLBAR_WIDTH;
+ if (!IsFloatEqual(m_sData.fScrollPos, fOldPos))
+ MovePosButton(TRUE);
}
-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::SetScrollStep(FX_FLOAT fBigStep, FX_FLOAT fSmallStep) {
+ m_sData.SetBigStep(fBigStep);
+ m_sData.SetSmallStep(fSmallStep);
}
-void CPWL_ScrollBar::SetScrollPos(FX_FLOAT fPos)
-{
- FX_FLOAT fOldPos = m_sData.fScrollPos;
+void CPWL_ScrollBar::MovePosButton(FX_BOOL bRefresh) {
+ ASSERT(m_pPosButton != NULL);
+ ASSERT(m_pMinButton != NULL);
+ ASSERT(m_pMaxButton != NULL);
- m_sData.SetPos(fPos);
+ if (m_pPosButton->IsVisible()) {
+ CPDF_Rect rcClient;
+ CPDF_Rect rcPosArea, rcPosButton;
- if (!IsFloatEqual(m_sData.fScrollPos, fOldPos))
- MovePosButton(TRUE);
-}
+ rcClient = GetClientRect();
+ rcPosArea = GetScrollArea();
-void CPWL_ScrollBar::SetScrollStep(FX_FLOAT fBigStep,FX_FLOAT fSmallStep)
-{
- m_sData.SetBigStep(fBigStep);
- m_sData.SetSmallStep(fSmallStep);
-}
+ FX_FLOAT fLeft, fRight, fTop, fBottom;
-void CPWL_ScrollBar::MovePosButton(FX_BOOL bRefresh)
-{
- ASSERT (m_pPosButton != NULL);
- ASSERT (m_pMinButton != NULL);
- ASSERT (m_pMaxButton != NULL);
+ switch (m_sbType) {
+ case SBT_HSCROLL:
+ fLeft = TrueToFace(m_sData.fScrollPos);
+ fRight = TrueToFace(m_sData.fScrollPos + m_sData.fClientWidth);
- if (m_pPosButton->IsVisible())
- {
+ 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);
- CPDF_Rect rcClient;
- CPDF_Rect rcPosArea,rcPosButton;
+ if (IsFloatSmaller(fTop - fBottom, PWL_SCROLLBAR_POSBUTTON_MINWIDTH))
+ fBottom = fTop - PWL_SCROLLBAR_POSBUTTON_MINWIDTH;
- rcClient = GetClientRect();
- rcPosArea = GetScrollArea();
+ if (IsFloatSmaller(fBottom, rcPosArea.bottom)) {
+ fBottom = rcPosArea.bottom;
+ fTop = fBottom + PWL_SCROLLBAR_POSBUTTON_MINWIDTH;
+ }
- FX_FLOAT fLeft,fRight,fTop,fBottom;
+ rcPosButton = CPDF_Rect(rcPosArea.left, fBottom, rcPosArea.right, fTop);
- switch (m_sbType)
- {
- case SBT_HSCROLL:
- fLeft = TrueToFace(m_sData.fScrollPos);
- fRight = TrueToFace(m_sData.fScrollPos + m_sData.fClientWidth);
+ break;
+ }
- if (fRight - fLeft < PWL_SCROLLBAR_POSBUTTON_MINWIDTH)
- fRight = fLeft + PWL_SCROLLBAR_POSBUTTON_MINWIDTH;
+ m_pPosButton->Move(rcPosButton, TRUE, bRefresh);
+ }
+}
- if (fRight > rcPosArea.right)
- {
- fRight = rcPosArea.right;
- fLeft = fRight - PWL_SCROLLBAR_POSBUTTON_MINWIDTH;
- }
+void CPWL_ScrollBar::OnMinButtonLBDown(const CPDF_Point& point) {
+ m_sData.SubSmall();
+ MovePosButton(TRUE);
+ NotifyScrollWindow();
- rcPosButton = CPDF_Rect(fLeft ,
- rcPosArea.bottom,
- fRight ,
- rcPosArea.top);
+ m_bMinOrMax = TRUE;
- break;
- case SBT_VSCROLL:
- fBottom = TrueToFace(m_sData.fScrollPos + m_sData.fClientWidth);
- fTop = TrueToFace(m_sData.fScrollPos);
+ EndTimer();
+ BeginTimer(100);
+}
- if (IsFloatSmaller(fTop - fBottom, PWL_SCROLLBAR_POSBUTTON_MINWIDTH))
- fBottom = fTop - PWL_SCROLLBAR_POSBUTTON_MINWIDTH;
+void CPWL_ScrollBar::OnMinButtonLBUp(const CPDF_Point& point) {}
- if (IsFloatSmaller(fBottom, rcPosArea.bottom))
- {
- fBottom = rcPosArea.bottom;
- fTop = fBottom + PWL_SCROLLBAR_POSBUTTON_MINWIDTH;
- }
+void CPWL_ScrollBar::OnMinButtonMouseMove(const CPDF_Point& point) {}
- rcPosButton = CPDF_Rect(rcPosArea.left,
- fBottom,
- rcPosArea.right,
- fTop);
+void CPWL_ScrollBar::OnMaxButtonLBDown(const CPDF_Point& point) {
+ m_sData.AddSmall();
+ MovePosButton(TRUE);
+ NotifyScrollWindow();
- break;
- }
+ m_bMinOrMax = FALSE;
- m_pPosButton->Move(rcPosButton,TRUE,bRefresh);
- }
+ EndTimer();
+ BeginTimer(100);
}
-void CPWL_ScrollBar::OnMinButtonLBDown(const CPDF_Point & point)
-{
- m_sData.SubSmall();
- MovePosButton(TRUE);
- NotifyScrollWindow();
+void CPWL_ScrollBar::OnMaxButtonLBUp(const CPDF_Point& point) {}
- m_bMinOrMax = TRUE;
+void CPWL_ScrollBar::OnMaxButtonMouseMove(const CPDF_Point& point) {}
- EndTimer();
- BeginTimer(100);
-}
+void CPWL_ScrollBar::OnPosButtonLBDown(const CPDF_Point& point) {
+ m_bMouseDown = TRUE;
+
+ if (m_pPosButton) {
+ CPDF_Rect rcPosButton = m_pPosButton->GetWindowRect();
-void CPWL_ScrollBar::OnMinButtonLBUp(const CPDF_Point & point)
-{
+ 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::OnMinButtonMouseMove(const CPDF_Point & point)
-{
+void CPWL_ScrollBar::OnPosButtonLBUp(const CPDF_Point& point) {
+ if (m_bMouseDown) {
+ if (!m_bNotifyForever)
+ NotifyScrollWindow();
+ }
+ m_bMouseDown = FALSE;
}
-void CPWL_ScrollBar::OnMaxButtonLBDown(const CPDF_Point & point)
-{
- m_sData.AddSmall();
- MovePosButton(TRUE);
- NotifyScrollWindow();
+void CPWL_ScrollBar::OnPosButtonMouseMove(const CPDF_Point& point) {
+ FX_FLOAT fOldScrollPos = m_sData.fScrollPos;
- m_bMinOrMax = FALSE;
+ FX_FLOAT fNewPos = 0;
- EndTimer();
- BeginTimer(100);
-}
+ 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;
+ }
-void CPWL_ScrollBar::OnMaxButtonLBUp(const CPDF_Point & point)
-{
-}
+ if (m_bMouseDown) {
+ switch (m_sbType) {
+ case SBT_HSCROLL:
-void CPWL_ScrollBar::OnMaxButtonMouseMove(const CPDF_Point & point)
-{
-}
+ if (IsFloatSmaller(fNewPos, m_sData.ScrollRange.fMin)) {
+ fNewPos = m_sData.ScrollRange.fMin;
+ }
-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;
- }
- }
-}
+ if (IsFloatBigger(fNewPos, m_sData.ScrollRange.fMax)) {
+ fNewPos = m_sData.ScrollRange.fMax;
+ }
-void CPWL_ScrollBar::OnPosButtonLBUp(const CPDF_Point & point)
-{
- if (m_bMouseDown)
- {
- if (!m_bNotifyForever)
- NotifyScrollWindow();
- }
- m_bMouseDown = FALSE;
-}
+ 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);
-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();
- }
- }
+ if (m_bNotifyForever)
+ NotifyScrollWindow();
+ }
+ }
}
-void CPWL_ScrollBar::NotifyScrollWindow()
-{
- if (CPWL_Wnd * pParent = GetParentWindow())
- {
- FX_FLOAT fPos;
- switch (m_sbType)
- {
- case SBT_HSCROLL:
- fPos = m_OriginInfo.fContentMin + m_sData.fScrollPos;
- break;
- case SBT_VSCROLL:
- fPos = m_OriginInfo.fContentMax - m_sData.fScrollPos;
- break;
- }
- pParent->OnNotify(this,PNM_SCROLLWINDOW,(intptr_t)m_sbType,(intptr_t)&fPos);
- }
+void CPWL_ScrollBar::NotifyScrollWindow() {
+ if (CPWL_Wnd* pParent = GetParentWindow()) {
+ FX_FLOAT fPos;
+ switch (m_sbType) {
+ case SBT_HSCROLL:
+ fPos = m_OriginInfo.fContentMin + m_sData.fScrollPos;
+ break;
+ case SBT_VSCROLL:
+ fPos = m_OriginInfo.fContentMax - m_sData.fScrollPos;
+ break;
+ }
+ pParent->OnNotify(this, PNM_SCROLLWINDOW, (intptr_t)m_sbType,
+ (intptr_t)&fPos);
+ }
}
-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;
+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 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 fFactWidth = m_sData.ScrollRange.GetWidth() + m_sData.fClientWidth;
+ fFactWidth = fFactWidth == 0 ? 1 : fFactWidth;
- FX_FLOAT fFace = 0;
+ 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;
- }
+ 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;
+ return fFace;
}
-FX_FLOAT CPWL_ScrollBar::FaceToTrue(FX_FLOAT fFace)
-{
- CPDF_Rect rcPosArea;
- rcPosArea = GetScrollArea();
+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 fFactWidth = m_sData.ScrollRange.GetWidth() + m_sData.fClientWidth;
+ fFactWidth = fFactWidth == 0 ? 1 : fFactWidth;
- FX_FLOAT fTrue = 0;
+ 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;
- }
+ 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;
+ return fTrue;
}
-void CPWL_ScrollBar::CreateChildWnd(const PWL_CREATEPARAM & cp)
-{
- CreateButtons(cp);
+void CPWL_ScrollBar::CreateChildWnd(const PWL_CREATEPARAM& cp) {
+ CreateButtons(cp);
}
-void CPWL_ScrollBar::TimerProc()
-{
- PWL_SCROLL_PRIVATEDATA sTemp = m_sData;
+void CPWL_ScrollBar::TimerProc() {
+ PWL_SCROLL_PRIVATEDATA sTemp = m_sData;
- if (m_bMinOrMax)m_sData.SubSmall();
- else m_sData.AddSmall();
+ if (m_bMinOrMax)
+ m_sData.SubSmall();
+ else
+ m_sData.AddSmall();
- if (FXSYS_memcmp(&m_sData, &sTemp, sizeof(PWL_SCROLL_PRIVATEDATA)) != 0)
- {
- MovePosButton(TRUE);
- NotifyScrollWindow();
- }
+ if (FXSYS_memcmp(&m_sData, &sTemp, sizeof(PWL_SCROLL_PRIVATEDATA)) != 0) {
+ MovePosButton(TRUE);
+ NotifyScrollWindow();
+ }
}
diff --git a/fpdfsdk/src/pdfwindow/PWL_Signature.cpp b/fpdfsdk/src/pdfwindow/PWL_Signature.cpp
index 76b2bd333a..bfe32ae8ad 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Signature.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Signature.cpp
@@ -11,210 +11,194 @@
#include "../../include/pdfwindow/PWL_Label.h"
#include "../../include/pdfwindow/PWL_Utils.h"
-/* --------------------------------- CPWL_Signature_Image --------------------------------- */
+/* --------------------------------- CPWL_Signature_Image
+ * --------------------------------- */
-CPWL_Signature_Image::CPWL_Signature_Image() : m_pImage(NULL)
-{
-}
+CPWL_Signature_Image::CPWL_Signature_Image() : m_pImage(NULL) {}
-CPWL_Signature_Image::~CPWL_Signature_Image()
-{
-}
+CPWL_Signature_Image::~CPWL_Signature_Image() {}
-void CPWL_Signature_Image::SetImage(CFX_DIBSource* pImage)
-{
- m_pImage = pImage;
+void CPWL_Signature_Image::SetImage(CFX_DIBSource* pImage) {
+ m_pImage = pImage;
}
-CFX_DIBSource* CPWL_Signature_Image::GetImage()
-{
- return m_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);
+void CPWL_Signature_Image::DrawThisAppearance(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device) {
+ CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device);
- if (m_pImage)
- {
- CPDF_Rect rcClient = GetClientRect();
+ if (m_pImage) {
+ CPDF_Rect rcClient = GetClientRect();
- FX_FLOAT x, y;
- pUser2Device->Transform(rcClient.left, rcClient.top, x, y);
+ FX_FLOAT x, y;
+ pUser2Device->Transform(rcClient.left, rcClient.top, x, y);
- pDevice->StretchDIBits(m_pImage, (int32_t)x, (int32_t)y,
- (int32_t)rcClient.Width(), (int32_t)rcClient.Height());
- }
+ pDevice->StretchDIBits(m_pImage, (int32_t)x, (int32_t)y,
+ (int32_t)rcClient.Width(),
+ (int32_t)rcClient.Height());
+ }
}
-void CPWL_Signature_Image::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
-{
- sAppStream << CPWL_Image::GetImageAppStream();
+void CPWL_Signature_Image::GetThisAppearanceStream(
+ CFX_ByteTextBuf& sAppStream) {
+ sAppStream << CPWL_Image::GetImageAppStream();
}
-void CPWL_Signature_Image::GetScale(FX_FLOAT & fHScale,FX_FLOAT & fVScale)
-{
- FX_FLOAT fImageW, fImageH;
+void CPWL_Signature_Image::GetScale(FX_FLOAT& fHScale, FX_FLOAT& fVScale) {
+ FX_FLOAT fImageW, fImageH;
- GetImageSize(fImageW, fImageH);
+ GetImageSize(fImageW, fImageH);
- CPDF_Rect rcClient = GetClientRect();
+ CPDF_Rect rcClient = GetClientRect();
- fHScale = rcClient.Width() / fImageW;
- fVScale = rcClient.Height() / fImageH;
+ fHScale = rcClient.Width() / fImageW;
+ fVScale = rcClient.Height() / fImageH;
}
-/* --------------------------------- CPWL_Signature --------------------------------- */
+/* --------------------------------- 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()
+ : m_pText(NULL),
+ m_pDescription(NULL),
+ m_pImage(NULL),
+ m_bTextExist(TRUE),
+ m_bImageExist(FALSE),
+ m_bFlagExist(TRUE) {}
-CPWL_Signature::~CPWL_Signature()
-{
-}
+CPWL_Signature::~CPWL_Signature() {}
-void CPWL_Signature::SetTextFlag(FX_BOOL bTextExist)
-{
- m_bTextExist = bTextExist;
+void CPWL_Signature::SetTextFlag(FX_BOOL bTextExist) {
+ m_bTextExist = bTextExist;
- RePosChildWnd();
+ RePosChildWnd();
}
-void CPWL_Signature::SetImageFlag(FX_BOOL bImageExist)
-{
- m_bImageExist = bImageExist;
+void CPWL_Signature::SetImageFlag(FX_BOOL bImageExist) {
+ m_bImageExist = bImageExist;
- RePosChildWnd();
+ RePosChildWnd();
}
-void CPWL_Signature::SetFoxitFlag(FX_BOOL bFlagExist)
-{
- m_bFlagExist = bFlagExist;
+void CPWL_Signature::SetFoxitFlag(FX_BOOL bFlagExist) {
+ m_bFlagExist = bFlagExist;
}
-void CPWL_Signature::SetText(const FX_WCHAR* sText)
-{
- m_pText->SetText(sText);
+void CPWL_Signature::SetText(const FX_WCHAR* sText) {
+ m_pText->SetText(sText);
- RePosChildWnd();
+ RePosChildWnd();
}
-void CPWL_Signature::SetDescription(const FX_WCHAR* string)
-{
- m_pDescription->SetText(string);
+void CPWL_Signature::SetDescription(const FX_WCHAR* string) {
+ m_pDescription->SetText(string);
- RePosChildWnd();
+ RePosChildWnd();
}
-void CPWL_Signature::SetImage(CFX_DIBSource* pImage)
-{
- m_pImage->SetImage(pImage);
+void CPWL_Signature::SetImage(CFX_DIBSource* pImage) {
+ m_pImage->SetImage(pImage);
- RePosChildWnd();
+ RePosChildWnd();
}
-void CPWL_Signature::SetImageStream(CPDF_Stream * pStream, const FX_CHAR* sImageAlias)
-{
- m_pImage->SetPDFStream(pStream);
- m_pImage->SetImageAlias(sImageAlias);
+void CPWL_Signature::SetImageStream(CPDF_Stream* pStream,
+ const FX_CHAR* sImageAlias) {
+ m_pImage->SetPDFStream(pStream);
+ m_pImage->SetImageAlias(sImageAlias);
- RePosChildWnd();
+ RePosChildWnd();
}
-void CPWL_Signature::RePosChildWnd()
-{
- CPDF_Rect rcClient = GetClientRect();
+void CPWL_Signature::RePosChildWnd() {
+ CPDF_Rect rcClient = GetClientRect();
- CPDF_Rect rcText = rcClient;
- CPDF_Rect rcDescription = rcClient;
+ CPDF_Rect rcText = rcClient;
+ CPDF_Rect rcDescription = rcClient;
- FX_BOOL bTextVisible = m_bTextExist && m_pText->GetText().GetLength() > 0;
+ 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;
- }
- }
+ 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->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);
+ 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);
+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_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);
+ 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);
+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);
+ 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();
+ /*
+ CPDF_Rect rcClient = GetClientRect();
- CFX_PathData path;
+ 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);
+ 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;
+ 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);
- */
+ 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);
+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 90fa8f880d..7f125ad1d7 100644
--- a/fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_SpecialButton.cpp
@@ -12,99 +12,76 @@
/* --------------------------- CPWL_PushButton ---------------------------- */
-CPWL_PushButton::CPWL_PushButton()
-{
-}
+CPWL_PushButton::CPWL_PushButton() {}
-CPWL_PushButton::~CPWL_PushButton()
-{
-}
+CPWL_PushButton::~CPWL_PushButton() {}
-CFX_ByteString CPWL_PushButton::GetClassName() const
-{
- return "CPWL_PushButton";
+CFX_ByteString CPWL_PushButton::GetClassName() const {
+ return "CPWL_PushButton";
}
-CPDF_Rect CPWL_PushButton::GetFocusRect() const
-{
- return CPWL_Utils::DeflateRect(GetWindowRect(), (FX_FLOAT)GetBorderWidth());
+CPDF_Rect CPWL_PushButton::GetFocusRect() const {
+ return CPWL_Utils::DeflateRect(GetWindowRect(), (FX_FLOAT)GetBorderWidth());
}
/* --------------------------- CPWL_CheckBox ---------------------------- */
-CPWL_CheckBox::CPWL_CheckBox() : m_bChecked(FALSE)
-{
-}
+CPWL_CheckBox::CPWL_CheckBox() : m_bChecked(FALSE) {}
-CPWL_CheckBox::~CPWL_CheckBox()
-{
-}
+CPWL_CheckBox::~CPWL_CheckBox() {}
-CFX_ByteString CPWL_CheckBox::GetClassName() const
-{
- return "CPWL_CheckBox";
+CFX_ByteString CPWL_CheckBox::GetClassName() const {
+ return "CPWL_CheckBox";
}
-void CPWL_CheckBox::SetCheck(FX_BOOL bCheck)
-{
- m_bChecked = bCheck;
+void CPWL_CheckBox::SetCheck(FX_BOOL bCheck) {
+ m_bChecked = bCheck;
}
-FX_BOOL CPWL_CheckBox::IsChecked() const
-{
- return m_bChecked;
+FX_BOOL CPWL_CheckBox::IsChecked() const {
+ return m_bChecked;
}
-FX_BOOL CPWL_CheckBox::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
-{
- if (IsReadOnly()) return FALSE;
+FX_BOOL CPWL_CheckBox::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) {
+ if (IsReadOnly())
+ return FALSE;
- SetCheck(!IsChecked());
- return TRUE;
+ SetCheck(!IsChecked());
+ return TRUE;
}
-FX_BOOL CPWL_CheckBox::OnChar(FX_WORD nChar, FX_DWORD nFlag)
-{
- SetCheck(!IsChecked());
- return TRUE;
+FX_BOOL CPWL_CheckBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
+ SetCheck(!IsChecked());
+ return TRUE;
}
/* --------------------------- CPWL_RadioButton ---------------------------- */
-CPWL_RadioButton::CPWL_RadioButton() : m_bChecked(FALSE)
-{
-}
+CPWL_RadioButton::CPWL_RadioButton() : m_bChecked(FALSE) {}
-CPWL_RadioButton::~CPWL_RadioButton()
-{
-}
+CPWL_RadioButton::~CPWL_RadioButton() {}
-CFX_ByteString CPWL_RadioButton::GetClassName() const
-{
- return "CPWL_RadioButton";
+CFX_ByteString CPWL_RadioButton::GetClassName() const {
+ return "CPWL_RadioButton";
}
-FX_BOOL CPWL_RadioButton::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
-{
- if (IsReadOnly()) return FALSE;
+FX_BOOL CPWL_RadioButton::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) {
+ if (IsReadOnly())
+ return FALSE;
- SetCheck(TRUE);
- return TRUE;
+ SetCheck(TRUE);
+ return TRUE;
}
-void CPWL_RadioButton::SetCheck(FX_BOOL bCheck)
-{
- m_bChecked = bCheck;
+void CPWL_RadioButton::SetCheck(FX_BOOL bCheck) {
+ m_bChecked = bCheck;
}
-FX_BOOL CPWL_RadioButton::IsChecked() const
-{
- return m_bChecked;
+FX_BOOL CPWL_RadioButton::IsChecked() const {
+ return m_bChecked;
}
-FX_BOOL CPWL_RadioButton::OnChar(FX_WORD nChar, FX_DWORD nFlag)
-{
- SetCheck(TRUE);
- return TRUE;
+FX_BOOL CPWL_RadioButton::OnChar(FX_WORD nChar, FX_DWORD nFlag) {
+ SetCheck(TRUE);
+ return TRUE;
}
-
diff --git a/fpdfsdk/src/pdfwindow/PWL_Utils.cpp b/fpdfsdk/src/pdfwindow/PWL_Utils.cpp
index b9ba7661af..52b22b548a 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Utils.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Utils.cpp
@@ -9,2819 +9,3705 @@
#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))
+#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, int32_t nCount)
-{
- CFX_ByteTextBuf csAP;
-
- for (int32_t i=0; i<nCount; i++)
- {
- switch (pPathData[i].type)
- {
- case PWLPT_MOVETO:
- csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " m\n";
- break;
- case PWLPT_LINETO:
- csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " l\n";
- break;
- case PWLPT_BEZIERTO:
- csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " "
- << pPathData[i+1].point.x << " " << pPathData[i+1].point.y << " "
- << pPathData[i+2].point.x << " " << pPathData[i+2].point.y << " c\n";
-
- i += 2;
- break;
- default:
- break;
- }
- }
-
- return csAP.GetByteString();
-}
+CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData,
+ int32_t nCount) {
+ CFX_ByteTextBuf csAP;
+
+ for (int32_t i = 0; i < nCount; i++) {
+ switch (pPathData[i].type) {
+ case PWLPT_MOVETO:
+ csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " m\n";
+ break;
+ case PWLPT_LINETO:
+ csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " l\n";
+ break;
+ case PWLPT_BEZIERTO:
+ csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " "
+ << pPathData[i + 1].point.x << " " << pPathData[i + 1].point.y
+ << " " << pPathData[i + 2].point.x << " "
+ << pPathData[i + 2].point.y << " c\n";
+
+ i += 2;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return csAP.GetByteString();
+}
+
+void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path,
+ const CPWL_PathData* pPathData,
+ int32_t nCount) {
+ path.SetPointCount(nCount);
+
+ for (int32_t i = 0; i < nCount; i++) {
+ switch (pPathData[i].type) {
+ case PWLPT_MOVETO:
+ path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y,
+ FXPT_MOVETO);
+ break;
+ case PWLPT_LINETO:
+ path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y,
+ FXPT_LINETO);
+ break;
+ case PWLPT_BEZIERTO:
+ path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y,
+ FXPT_BEZIERTO);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+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;
-void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path, const CPWL_PathData* pPathData, int32_t nCount)
-{
- path.SetPointCount(nCount);
-
- for (int32_t i=0; i<nCount; i++)
- {
- switch (pPathData[i].type)
- {
- case PWLPT_MOVETO:
- path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, FXPT_MOVETO);
- break;
- case PWLPT_LINETO:
- path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, FXPT_LINETO);
- break;
- case PWLPT_BEZIERTO:
- path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, FXPT_BEZIERTO);
- break;
- default:
- break;
- }
- }
-}
-
-
-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;
- }
+ if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) {
+ wrRet.BeginPos = wr2.BeginPos;
+ } else {
+ wrRet.BeginPos = wr1.BeginPos;
+ }
- return wrRet;
+ 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;
+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;
+ FX_FLOAT fWidth = crBBox.right - crBBox.left;
+ FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
- const int32_t num = 8;
+ const int32_t 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),
+ 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),
+ // 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),
+ // 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),
+ // 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),
+ // 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),
+ // 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),
+ // 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)
- };
+ // 8
+ CPWL_Point(0.40f, 0.60f), CPWL_Point(0.28f, 0.66f),
+ CPWL_Point(0.30f, 0.56f)};
- for (int32_t j=0; j<num*3; j++)
- {
- pts[j].x *= fWidth;
- pts[j].x += crBBox.left;
+ for (int32_t j = 0; j < num * 3; j++) {
+ pts[j].x *= fWidth;
+ pts[j].x += crBBox.left;
- pts[j].y *= fHeight;
- pts[j].y += crBBox.bottom;
- }
+ pts[j].y *= fHeight;
+ pts[j].y += crBBox.bottom;
+ }
- csAP << pts[0].x << " " << pts[0].y << " m\n";
+ csAP << pts[0].x << " " << pts[0].y << " m\n";
- for (int32_t i=0; i<num; i++)
- {
- int32_t nCur = i*3;
- int32_t n1 = i*3 + 1;
- int32_t n2 = i*3 + 2;
- int32_t nNext = (i < num-1 ? (i+1)*3 : 0);
+ for (int32_t i = 0; i < num; i++) {
+ int32_t nCur = i * 3;
+ int32_t n1 = i * 3 + 1;
+ int32_t n2 = i * 3 + 2;
+ int32_t 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;
+ 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";
- }
+ 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();
+ return csAP.GetByteString();
}
-CFX_ByteString CPWL_Utils::GetAP_Circle(const CPDF_Rect & crBBox)
-{
- CFX_ByteTextBuf csAP;
+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;
+ 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);
+ 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 << pt1.x << " " << pt1.y << " m\n";
- FX_FLOAT px = pt2.x - pt1.x;
- FX_FLOAT py = pt2.y - pt1.y;
+ 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";
+ 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;
+ 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";
+ 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;
+ 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";
+ 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;
+ 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";
+ csAP << pt4.x - px * PWL_BEZIER << " " << pt4.y << " " << pt1.x << " "
+ << pt1.y - py * PWL_BEZIER << " " << pt1.x << " " << pt1.y << " c\n";
- return csAP.GetByteString();
+ return csAP.GetByteString();
}
-CFX_ByteString CPWL_Utils::GetAP_Cross(const CPDF_Rect & crBBox)
-{
- CFX_ByteTextBuf csAP;
+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";
+ 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();
+ return csAP.GetByteString();
}
-CFX_ByteString CPWL_Utils::GetAP_Diamond(const CPDF_Rect & crBBox)
-{
- CFX_ByteTextBuf csAP;
+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;
+ 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);
+ 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";
+ 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();
+ return csAP.GetByteString();
}
-CFX_ByteString CPWL_Utils::GetAP_Square(const CPDF_Rect & crBBox)
-{
- CFX_ByteTextBuf csAP;
+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";
+ 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();
+ return csAP.GetByteString();
}
-CFX_ByteString CPWL_Utils::GetAP_Star(const CPDF_Rect & crBBox)
-{
- CFX_ByteTextBuf csAP;
+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 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 px[5], py[5];
- FX_FLOAT fAngel = PWL_PI/10.0f;
+ FX_FLOAT fAngel = PWL_PI / 10.0f;
- for (int32_t i=0; i<5; i++)
- {
- px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel);
- py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel);
+ for (int32_t i = 0; i < 5; i++) {
+ px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel);
+ py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel);
- fAngel += PWL_PI * 2 / 5.0f;
- }
+ fAngel += PWL_PI * 2 / 5.0f;
+ }
- csAP << px[0] << " " << py[0] << " m\n";
+ csAP << px[0] << " " << py[0] << " m\n";
- int32_t nNext = 0;
- for (int32_t j=0; j<5; j++)
- {
- nNext += 2;
- if (nNext >= 5) nNext -= 5;
- csAP << px[nNext] << " " << py[nNext] << " l\n";
- }
+ int32_t nNext = 0;
+ for (int32_t j = 0; j < 5; j++) {
+ nNext += 2;
+ if (nNext >= 5)
+ nNext -= 5;
+ csAP << px[nNext] << " " << py[nNext] << " l\n";
+ }
- return csAP.GetByteString();
+ 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;
+CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CPDF_Rect& crBBox,
+ FX_FLOAT fRotate) {
+ CFX_ByteTextBuf csAP;
- CPDF_Point pt1(-fWidth/2,0);
- CPDF_Point pt2(0,fHeight/2);
- CPDF_Point pt3(fWidth/2,0);
+ FX_FLOAT fWidth = crBBox.right - crBBox.left;
+ FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
- FX_FLOAT px,py;
+ CPDF_Point pt1(-fWidth / 2, 0);
+ CPDF_Point pt2(0, fHeight / 2);
+ CPDF_Point pt3(fWidth / 2, 0);
- csAP << cos(fRotate) << " " << sin(fRotate) << " " << -sin(fRotate) << " " << cos(fRotate) << " "
- << crBBox.left + fWidth / 2 << " " << crBBox.bottom + fHeight / 2 << " cm\n";
+ 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";
+ csAP << pt1.x << " " << pt1.y << " m\n";
- px = pt2.x - pt1.x;
- py = pt2.y - pt1.y;
+ 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";
+ 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;
+ 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";
+ csAP << pt2.x + px * PWL_BEZIER << " " << pt2.y << " " << pt3.x << " "
+ << pt3.y + py * PWL_BEZIER << " " << pt3.x << " " << pt3.y << " c\n";
- return csAP.GetByteString();
+ return csAP.GetByteString();
}
+CPDF_Rect CPWL_Utils::InflateRect(const CPDF_Rect& rcRect, FX_FLOAT fSize) {
+ if (rcRect.IsEmpty())
+ return rcRect;
-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 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 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 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_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);
+ 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);
+ 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 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";
- }
+ 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();
+ return sAppStream.GetByteString();
}
-CFX_ByteString CPWL_Utils::GetCircleFillAppStream(const CPDF_Rect & rect,const CPWL_Color & color)
-{
- CFX_ByteTextBuf sAppStream;
+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";
- }
+ 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();
+ 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;
+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 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;
+ FX_FLOAT fRadius = (fWidth > fHeight) ? fHeight / 2 : fWidth / 2;
- return CPDF_Rect(fCenterX - fRadius,fCenterY - fRadius,fCenterX + fRadius,fCenterY + fRadius);
+ 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::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);
+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;
+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";
+ sRet << "0 w\n" << fStartX << " " << fY << " m\n";
- FX_FLOAT fx;
- int32_t i;
+ FX_FLOAT fx;
+ int32_t i;
- for (i=1,fx=fStartX+fStep; fx<fEndX; fx+=fStep,i++)
- {
- sRet << fx << " " << fY + (i&1)*fStep << " l\n";
- }
+ for (i = 1, fx = fStartX + fStep; fx < fEndX; fx += fStep, i++) {
+ sRet << fx << " " << fY + (i & 1) * fStep << " l\n";
+ }
- sRet << "S\n";
+ sRet << "S\n";
- return sRet.GetByteString();
+ 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, int32_t nAlignmentH, int32_t nAlignmentV,
- FX_FLOAT fFontSize, FX_BOOL bMultiLine, FX_BOOL bAutoReturn, const CPWL_Color & crText)
-{
- CFX_ByteTextBuf sRet;
-
- if (IFX_Edit * pEdit = IFX_Edit::NewEdit())
- {
- pEdit->SetFontMap(pFontMap);
- pEdit->SetPlateRect(rcBBox);
- pEdit->SetAlignmentH(nAlignmentH);
- pEdit->SetAlignmentV(nAlignmentV);
- pEdit->SetMultiLine(bMultiLine);
- pEdit->SetAutoReturn(bAutoReturn);
- if (IsFloatZero(fFontSize))
- pEdit->SetAutoFontSize(TRUE);
- else
- pEdit->SetFontSize(fFontSize);
-
- pEdit->Initialize();
- pEdit->SetText(sText.c_str());
-
- CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit, 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,
- int32_t nLayOut)
-{
- const FX_FLOAT fAutoFontScale = 1.0f / 3.0f;
-
- if (IFX_Edit * pEdit = IFX_Edit::NewEdit())
- {
- pEdit->SetFontMap(pFontMap);
- pEdit->SetAlignmentH(1);
- pEdit->SetAlignmentV(1);
- pEdit->SetMultiLine(FALSE);
- pEdit->SetAutoReturn(FALSE);
- if (IsFloatZero(fFontSize))
- pEdit->SetAutoFontSize(TRUE);
- else
- pEdit->SetFontSize(fFontSize);
-
- pEdit->Initialize();
- pEdit->SetText(sLabel.c_str());
-
- 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,
- int32_t nStyle, const CPWL_Dash & dash)
-{
- CFX_ByteTextBuf sAppStream;
- CFX_ByteString sColor;
-
- FX_FLOAT fLeft = rect.left;
- FX_FLOAT fRight = rect.right;
- FX_FLOAT fTop = rect.top;
- FX_FLOAT fBottom = rect.bottom;
-
- if (fWidth > 0.0f)
- {
- FX_FLOAT fHalfWidth = fWidth / 2.0f;
-
- sAppStream << "q\n";
-
- switch (nStyle)
- {
- default:
- case PBS_SOLID:
- sColor = CPWL_Utils::GetColorAppStream(color,TRUE);
- if (sColor.GetLength() > 0)
- {
- sAppStream << sColor;
- sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " << fTop - fBottom << " re\n";
- sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " "
- << fRight - fLeft - fWidth * 2 << " " << fTop - fBottom - fWidth * 2 << " re\n";
- sAppStream << "f*\n";
- }
- break;
- case PBS_DASH:
- sColor = CPWL_Utils::GetColorAppStream(color,FALSE);
- if (sColor.GetLength() > 0)
- {
- sAppStream << sColor;
- sAppStream << fWidth << " w" << " [" << dash.nDash << " " << dash.nGap << "] " << dash.nPhase << " d\n";
- sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 << " m\n";
- sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2 << " l\n";
- sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2 << " l\n";
- sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2 << " l\n";
- sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 << " l S\n";
- }
- break;
- case PBS_BEVELED:
- case PBS_INSET:
- sColor = CPWL_Utils::GetColorAppStream(crLeftTop,TRUE);
- if (sColor.GetLength() > 0)
- {
- sAppStream << sColor;
- sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " m\n";
- sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth << " l\n";
- sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth << " l\n";
- sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 << " l\n";
- sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 << " l\n";
- sAppStream << fLeft + fHalfWidth * 2 << " " << fBottom + fHalfWidth * 2 << " l f\n";
- }
-
- sColor = CPWL_Utils::GetColorAppStream(crRightBottom,TRUE);
- if (sColor.GetLength() > 0)
- {
- sAppStream << sColor;
- sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth << " m\n";
- sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfWidth << " l\n";
- sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " l\n";
- sAppStream << fLeft + fHalfWidth * 2 << " " << fBottom + fHalfWidth * 2 << " l\n";
- sAppStream << fRight - fHalfWidth * 2 << " " << fBottom + fHalfWidth * 2 << " l\n";
- sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 << " l f\n";
- }
-
- sColor = CPWL_Utils::GetColorAppStream(color,TRUE);
- if (sColor.GetLength() > 0)
- {
- sAppStream << sColor;
- sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " << fTop - fBottom << " re\n";
- sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " "
- << fRight - fLeft - fHalfWidth * 2 << " " << fTop - fBottom - fHalfWidth * 2 << " re f*\n";
- }
- break;
- case PBS_UNDERLINED:
- sColor = CPWL_Utils::GetColorAppStream(color,FALSE);
- if (sColor.GetLength() > 0)
- {
- sAppStream << sColor;
- sAppStream << fWidth << " w\n";
- sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n";
- sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n";
- }
- break;
- }
-
- sAppStream << "Q\n";
- }
-
- return sAppStream.GetByteString();
-}
-
-CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(const CPDF_Rect & rect, FX_FLOAT fWidth,
- const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom,
- int32_t nStyle, const CPWL_Dash & dash)
-{
- CFX_ByteTextBuf sAppStream;
- CFX_ByteString sColor;
-
-
-
-
-
-
- if (fWidth > 0.0f)
- {
- sAppStream << "q\n";
-
- switch (nStyle)
- {
- default:
- case PBS_SOLID:
- case PBS_UNDERLINED:
- {
- sColor = CPWL_Utils::GetColorAppStream(color,FALSE);
- if (sColor.GetLength() > 0)
- {
- sAppStream << "q\n" << fWidth << " w\n" << sColor
- << CPWL_Utils::GetAP_Circle(CPWL_Utils::DeflateRect(rect,fWidth / 2.0f))
- << " S\nQ\n";
- }
- }
- break;
- case PBS_DASH:
- {
- sColor = CPWL_Utils::GetColorAppStream(color,FALSE);
- if (sColor.GetLength() > 0)
- {
- sAppStream << "q\n" << fWidth << " w\n"
- << "[" << dash.nDash << " " << dash.nGap << "] " << dash.nPhase << " d\n"
- << sColor << CPWL_Utils::GetAP_Circle(CPWL_Utils::DeflateRect(rect,fWidth / 2.0f))
- << " S\nQ\n";
- }
- }
- break;
- case PBS_BEVELED:
- {
- FX_FLOAT fHalfWidth = fWidth / 2.0f;
-
- sColor = CPWL_Utils::GetColorAppStream(color,FALSE);
- if (sColor.GetLength() > 0)
- {
- sAppStream << "q\n" << fHalfWidth << " w\n"
- << sColor << CPWL_Utils::GetAP_Circle(rect)
- << " S\nQ\n";
- }
-
- sColor = CPWL_Utils::GetColorAppStream(crLeftTop,FALSE);
- if (sColor.GetLength() > 0)
- {
- sAppStream << "q\n" << fHalfWidth << " w\n"
- << sColor << CPWL_Utils::GetAP_HalfCircle(CPWL_Utils::DeflateRect(rect,fHalfWidth * 0.75f),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,
- int32_t 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,
- int32_t 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, int32_t& alpha, FX_FLOAT& red, FX_FLOAT& green, FX_FLOAT& blue)
-{
- switch (color.nColorType)
- {
- case COLORTYPE_TRANSPARENT:
- {
- alpha = 0;
- }
- break;
- case COLORTYPE_GRAY:
- {
- ConvertGRAY2RGB(color.fColor1, red, green, blue);
- }
- break;
- case COLORTYPE_RGB:
- {
- red = color.fColor1;
- green = color.fColor2;
- blue = color.fColor3;
- }
- break;
- case COLORTYPE_CMYK:
- {
- ConvertCMYK2RGB(color.fColor1, color.fColor2, color.fColor3, color.fColor4,
- red, green, blue);
- }
- break;
- }
-}
-
-FX_COLORREF CPWL_Utils::PWLColorToFXColor(const CPWL_Color& color, int32_t nTransparancy)
-{
- int32_t nAlpha = nTransparancy;
- FX_FLOAT dRed = 0;
- FX_FLOAT dGreen = 0;
- FX_FLOAT dBlue = 0;
-
- PWLColorToARGB(color, nAlpha, dRed, dGreen, dBlue);
-
- return ArgbEncode(nAlpha, (int32_t)(dRed*255), (int32_t)(dGreen*255), (int32_t)(dBlue*255));
-}
-
-void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice, 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, int32_t nCount, const FX_COLORREF& color)
-{
- CFX_PathData path;
- path.SetPointCount(nCount);
-
- path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_MOVETO);
- for (int32_t i=1; i<nCount; i++)
- path.SetPoint(i, pPts[i].x, pPts[i].y, FXPT_LINETO);
-
- pDevice->DrawPath(&path, pUser2Device, NULL, color, 0, FXFILL_ALTERNATE);
-}
-
-void CPWL_Utils::DrawStrokeRect(CFX_RenderDevice* pDevice, 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, int32_t 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,
- int32_t nTransparancy, int32_t nStartGray, int32_t nEndGray)
-{
- FX_FLOAT fStepGray = 1.0f;
-
- if (bVertical)
- {
- fStepGray = (nEndGray - nStartGray) / rect.Height();
-
- for (FX_FLOAT fy=rect.bottom+0.5f; fy<=rect.top-0.5f; fy+=1.0f)
- {
- int32_t nGray = nStartGray + (int32_t)(fStepGray * (fy-rect.bottom));
- CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, 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)
- {
- int32_t nGray = nStartGray + (int32_t)(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,
- int32_t nStyle, const CPWL_Dash & dash, int32_t nTransparancy)
-{
- FX_FLOAT fLeft = rect.left;
- FX_FLOAT fRight = rect.right;
- FX_FLOAT fTop = rect.top;
- FX_FLOAT fBottom = rect.bottom;
-
- if (fWidth > 0.0f)
- {
- FX_FLOAT fHalfWidth = fWidth / 2.0f;
-
- switch (nStyle)
- {
- default:
- case PBS_SOLID:
- {
- CFX_PathData path;
- path.AppendRect(fLeft, fBottom, fRight, fTop);
- path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth, fTop - fWidth);
- pDevice->DrawPath(&path, pUser2Device, NULL, PWLColorToFXColor(color,nTransparancy), 0, FXFILL_ALTERNATE);
- }
- break;
- case PBS_DASH:
- {
- CFX_PathData path;
-
- path.SetPointCount(5);
- path.SetPoint(0, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, FXPT_MOVETO);
- path.SetPoint(1, fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f, FXPT_LINETO);
- path.SetPoint(2, fRight - fWidth / 2.0f, fTop - fWidth / 2.0f, FXPT_LINETO);
- path.SetPoint(3, fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f, FXPT_LINETO);
- path.SetPoint(4, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, FXPT_LINETO);
-
- CFX_GraphStateData gsd;
- gsd.SetDashCount(2);
- gsd.m_DashArray[0] = 3.0f;
- gsd.m_DashArray[1] = 3.0f;
- gsd.m_DashPhase = 0;
-
- gsd.m_LineWidth = fWidth;
- pDevice->DrawPath(&path, pUser2Device, &gsd, 0, PWLColorToFXColor(color,nTransparancy), FXFILL_WINDING);
- }
- break;
- case PBS_BEVELED:
- case PBS_INSET:
- {
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = fHalfWidth;
-
- CFX_PathData pathLT;
-
- pathLT.SetPointCount(7);
- pathLT.SetPoint(0, fLeft + fHalfWidth, fBottom + fHalfWidth, FXPT_MOVETO);
- pathLT.SetPoint(1, fLeft + fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
- pathLT.SetPoint(2, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
- pathLT.SetPoint(3, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, FXPT_LINETO);
- pathLT.SetPoint(4, fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2, FXPT_LINETO);
- pathLT.SetPoint(5, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, FXPT_LINETO);
- pathLT.SetPoint(6, fLeft + fHalfWidth, fBottom + fHalfWidth, FXPT_LINETO);
-
- pDevice->DrawPath(&pathLT, pUser2Device, &gsd, PWLColorToFXColor(crLeftTop,nTransparancy), 0, FXFILL_ALTERNATE);
-
- CFX_PathData pathRB;
-
- pathRB.SetPointCount(7);
- pathRB.SetPoint(0, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_MOVETO);
- pathRB.SetPoint(1, fRight - fHalfWidth, fBottom + fHalfWidth, FXPT_LINETO);
- pathRB.SetPoint(2, fLeft + fHalfWidth, fBottom + fHalfWidth, FXPT_LINETO);
- pathRB.SetPoint(3, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, FXPT_LINETO);
- pathRB.SetPoint(4, fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2, FXPT_LINETO);
- pathRB.SetPoint(5, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, FXPT_LINETO);
- pathRB.SetPoint(6, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
-
- pDevice->DrawPath(&pathRB, pUser2Device, &gsd, PWLColorToFXColor(crRightBottom,nTransparancy), 0, FXFILL_ALTERNATE);
-
- CFX_PathData path;
-
- path.AppendRect(fLeft, fBottom, fRight, fTop);
- path.AppendRect(fLeft + fHalfWidth, fBottom + fHalfWidth, fRight - fHalfWidth, fTop - fHalfWidth);
-
- pDevice->DrawPath(&path, pUser2Device, &gsd, PWLColorToFXColor(color,nTransparancy), 0, FXFILL_ALTERNATE);
- }
- break;
- case PBS_UNDERLINED:
- {
- CFX_PathData path;
-
- path.SetPointCount(2);
- path.SetPoint(0, fLeft, fBottom + fWidth / 2, FXPT_MOVETO);
- path.SetPoint(1, fRight, fBottom + fWidth / 2, FXPT_LINETO);
-
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = fWidth;
-
- pDevice->DrawPath(&path, pUser2Device, &gsd,0, PWLColorToFXColor(color,nTransparancy), FXFILL_ALTERNATE);
- }
- break;
- case PBS_SHADOW:
- {
- CFX_PathData path;
- path.AppendRect(fLeft, fBottom, fRight, fTop);
- path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth, fTop - fWidth);
- pDevice->DrawPath(&path, pUser2Device, NULL, PWLColorToFXColor(color,nTransparancy/2), 0, FXFILL_ALTERNATE);
- }
- break;
- }
- }
-}
-
-static void AddSquigglyPath(CFX_PathData & PathData, FX_FLOAT fStartX, FX_FLOAT fEndX, FX_FLOAT fY, FX_FLOAT fStep)
-{
- PathData.AddPointCount(1);
- PathData.SetPoint(PathData.GetPointCount() - 1, fStartX, fY, FXPT_MOVETO);
-
- FX_FLOAT fx;
- int32_t i;
-
- for (i=1,fx=fStartX+fStep; fx<fEndX; fx+=fStep,i++)
- {
- PathData.AddPointCount(1);
- PathData.SetPoint(PathData.GetPointCount() - 1, fx, fY + (i&1)*fStep, FXPT_LINETO);
- }
-}
-
-static void AddSpellCheckObj(CFX_PathData & PathData, IFX_Edit* pEdit, const CPVT_WordRange& wrWord)
-{
- FX_FLOAT fStartX = 0.0f;
- FX_FLOAT fEndX = 0.0f;
- FX_FLOAT fY = 0.0f;
- FX_FLOAT fStep = 0.0f;
-
- FX_BOOL bBreak = FALSE;
-
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator())
- {
- pIterator->SetAt(wrWord.BeginPos);
-
- do
- {
- CPVT_WordPlace place = pIterator->GetAt();
-
- CPVT_Line line;
- if (pIterator->GetLine(line))
- {
- fY = line.ptLine.y;
- fStep = (line.fLineAscent - line.fLineDescent) / 16.0f;
- }
-
- if (place.LineCmp(wrWord.BeginPos) == 0)
- {
- pIterator->SetAt(wrWord.BeginPos);
- CPVT_Word word;
- if (pIterator->GetWord(word))
- {
- fStartX = word.ptWord.x;
- }
- }
- else
- {
- fStartX = line.ptLine.x;
- }
-
- if (place.LineCmp(wrWord.EndPos) == 0)
- {
- pIterator->SetAt(wrWord.EndPos);
- CPVT_Word word;
- if (pIterator->GetWord(word))
- {
- fEndX = word.ptWord.x + word.fWidth;
- }
-
- bBreak = TRUE;
- }
- else
- {
- fEndX = line.ptLine.x + line.fLineWidth;
- }
-
- AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep);
-
- if (bBreak) break;
- }
- while (pIterator->NextLine());
- }
-}
-
-void CPWL_Utils::DrawEditSpellCheck(CFX_RenderDevice* pDevice, 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 = (int32_t)rcTemp.left;
- rcDevClip.right = (int32_t)rcTemp.right;
- rcDevClip.top = (int32_t)rcTemp.top;
- rcDevClip.bottom = (int32_t)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(int32_t 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,
- int32_t nType, const CPDF_Rect & rect, const CPWL_Color& crFill, const CPWL_Color& crStroke, const int32_t nTransparancy)
-{
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = 1.0f;
-
- CFX_ByteString sPath;
- CFX_PathData path;
-
- switch (nType)
- {
- case PWL_ICONTYPE_CHECKMARK:
- GetGraphics_Checkmark(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_CIRCLE:
- GetGraphics_Circle(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_COMMENT:
- GetGraphics_Comment(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_CROSS:
- GetGraphics_Cross(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_HELP:
- GetGraphics_Help(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_INSERTTEXT:
- GetGraphics_InsertText(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_KEY:
- GetGraphics_Key(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_NEWPARAGRAPH:
- GetGraphics_NewParagraph(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_TEXTNOTE:
- GetGraphics_TextNote(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_PARAGRAPH:
- GetGraphics_Paragraph(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_RIGHTARROW:
- GetGraphics_RightArrow(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_RIGHTPOINTER:
- GetGraphics_RightPointer(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_STAR:
- GetGraphics_Star(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_UPARROW:
- GetGraphics_UpArrow(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_UPLEFTARROW:
- GetGraphics_UpLeftArrow(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_GRAPH:
- GetGraphics_Graph(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_PAPERCLIP:
- GetGraphics_Paperclip(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_ATTACHMENT:
- GetGraphics_Attachment(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_TAG:
- GetGraphics_Tag(sPath, path, rect, PWLPT_PATHDATA);
- break;
- case PWL_ICONTYPE_FOXIT:
- GetGraphics_Foxit(sPath, path, rect, PWLPT_PATHDATA);
- break;
- default:
- return;
- }
-
- pDevice->DrawPath(&path, pUser2Device, &gsd,
- PWLColorToFXColor(crFill,nTransparancy), PWLColorToFXColor(crStroke,nTransparancy), FXFILL_ALTERNATE);
-}
-
-void CPWL_Utils::GetGraphics_Checkmark(CFX_ByteString& sPathData, CFX_PathData& path, const 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 (int32_t i=0; i<5; i++)
- {
- px1[i] = ptCenter.x + fLongRadius * (FX_FLOAT)cos(fAngel);
- py1[i] = ptCenter.y + fLongRadius * (FX_FLOAT)sin(fAngel);
-
- fAngel += PWL_PI * 2 / 5.0f;
- }
-
- fAngel = PWL_PI/5.0f + PWL_PI/10.0f;
-
- for (int32_t j=0; j<5; j++)
- {
- px2[j] = ptCenter.x + fShortRadius * (FX_FLOAT)cos(fAngel);
- py2[j] = ptCenter.y + fShortRadius * (FX_FLOAT)sin(fAngel);
-
- fAngel += 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(int32_t k = 0; k < 4; k++)
- {
- PathArray[(k+1)*2] = CPWL_PathData(CPWL_Point(px1[k+1], py1[k+1]), PWLPT_LINETO);
- PathArray[(k+1)*2 + 1] = CPWL_PathData(CPWL_Point(px2[k+1], py2[k+1]), PWLPT_LINETO);
- }
-
- PathArray[10] = CPWL_PathData(CPWL_Point(px1[0], py1[0]), PWLPT_LINETO);
-
- if(type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 11);
- else
- GetPathDataFromArray(path, PathArray, 11);
-}
-
-void CPWL_Utils::GetGraphics_UpArrow(CFX_ByteString& sPathData, CFX_PathData& path, const 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),
- };
-
- if(type == PWLPT_STREAM)
- sPathData = GetAppStreamFromArray(PathArray, 23);
- else
- GetPathDataFromArray(path, PathArray, 23);
-}
-
-void CPWL_Color::ConvertColorType(int32_t other_nColorType)
-{
- switch (other_nColorType)
- {
- case COLORTYPE_TRANSPARENT:
- break;
- case COLORTYPE_GRAY:
- switch (other_nColorType)
- {
- case COLORTYPE_RGB:
- CPWL_Utils::ConvertGRAY2RGB(fColor1, fColor1, fColor2, fColor3);
- break;
- case COLORTYPE_CMYK:
- CPWL_Utils::ConvertGRAY2CMYK(fColor1, fColor1, fColor2, fColor3, fColor4);
- break;
- }
- break;
- case COLORTYPE_RGB:
- switch (other_nColorType)
- {
- case COLORTYPE_GRAY:
- CPWL_Utils::ConvertRGB2GRAY(fColor1, fColor2, fColor3, fColor1);
- break;
- case COLORTYPE_CMYK:
- CPWL_Utils::ConvertRGB2CMYK(fColor1, fColor2, fColor3, fColor1, fColor2, fColor3, fColor4);
- break;
- }
- break;
- case COLORTYPE_CMYK:
- switch (other_nColorType)
- {
- case COLORTYPE_GRAY:
- CPWL_Utils::ConvertCMYK2GRAY(fColor1, fColor2, fColor3, fColor4, fColor1);
- break;
- case COLORTYPE_RGB:
- CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4, fColor1, fColor2, fColor3);
- break;
- }
- break;
- }
- nColorType = other_nColorType;
-}
+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,
+ int32_t nAlignmentH,
+ int32_t nAlignmentV,
+ FX_FLOAT fFontSize,
+ FX_BOOL bMultiLine,
+ FX_BOOL bAutoReturn,
+ const CPWL_Color& crText) {
+ CFX_ByteTextBuf sRet;
+
+ if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) {
+ pEdit->SetFontMap(pFontMap);
+ pEdit->SetPlateRect(rcBBox);
+ pEdit->SetAlignmentH(nAlignmentH);
+ pEdit->SetAlignmentV(nAlignmentV);
+ pEdit->SetMultiLine(bMultiLine);
+ pEdit->SetAutoReturn(bAutoReturn);
+ if (IsFloatZero(fFontSize))
+ pEdit->SetAutoFontSize(TRUE);
+ else
+ pEdit->SetFontSize(fFontSize);
+
+ pEdit->Initialize();
+ pEdit->SetText(sText.c_str());
+
+ CFX_ByteString sEdit =
+ CPWL_Utils::GetEditAppStream(pEdit, 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,
+ int32_t nLayOut) {
+ const FX_FLOAT fAutoFontScale = 1.0f / 3.0f;
+
+ if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) {
+ pEdit->SetFontMap(pFontMap);
+ pEdit->SetAlignmentH(1);
+ pEdit->SetAlignmentV(1);
+ pEdit->SetMultiLine(FALSE);
+ pEdit->SetAutoReturn(FALSE);
+ if (IsFloatZero(fFontSize))
+ pEdit->SetAutoFontSize(TRUE);
+ else
+ pEdit->SetFontSize(fFontSize);
+
+ pEdit->Initialize();
+ pEdit->SetText(sLabel.c_str());
+
+ 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,
+ int32_t nStyle,
+ const CPWL_Dash& dash) {
+ CFX_ByteTextBuf sAppStream;
+ CFX_ByteString sColor;
+
+ FX_FLOAT fLeft = rect.left;
+ FX_FLOAT fRight = rect.right;
+ FX_FLOAT fTop = rect.top;
+ FX_FLOAT fBottom = rect.bottom;
+
+ if (fWidth > 0.0f) {
+ FX_FLOAT fHalfWidth = fWidth / 2.0f;
+
+ sAppStream << "q\n";
+
+ switch (nStyle) {
+ default:
+ case PBS_SOLID:
+ sColor = CPWL_Utils::GetColorAppStream(color, TRUE);
+ if (sColor.GetLength() > 0) {
+ sAppStream << sColor;
+ sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " "
+ << fTop - fBottom << " re\n";
+ sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " "
+ << fRight - fLeft - fWidth * 2 << " "
+ << fTop - fBottom - fWidth * 2 << " re\n";
+ sAppStream << "f*\n";
+ }
+ break;
+ case PBS_DASH:
+ sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
+ if (sColor.GetLength() > 0) {
+ sAppStream << sColor;
+ sAppStream << fWidth << " w"
+ << " [" << dash.nDash << " " << dash.nGap << "] "
+ << dash.nPhase << " d\n";
+ sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2
+ << " m\n";
+ sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2
+ << " l\n";
+ sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2
+ << " l\n";
+ sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2
+ << " l\n";
+ sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2
+ << " l S\n";
+ }
+ break;
+ case PBS_BEVELED:
+ case PBS_INSET:
+ sColor = CPWL_Utils::GetColorAppStream(crLeftTop, TRUE);
+ if (sColor.GetLength() > 0) {
+ sAppStream << sColor;
+ sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth
+ << " m\n";
+ sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth
+ << " l\n";
+ sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth
+ << " l\n";
+ sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
+ << " l\n";
+ sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
+ << " l\n";
+ sAppStream << fLeft + fHalfWidth * 2 << " "
+ << fBottom + fHalfWidth * 2 << " l f\n";
+ }
+
+ sColor = CPWL_Utils::GetColorAppStream(crRightBottom, TRUE);
+ if (sColor.GetLength() > 0) {
+ sAppStream << sColor;
+ sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth
+ << " m\n";
+ sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfWidth
+ << " l\n";
+ sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth
+ << " l\n";
+ sAppStream << fLeft + fHalfWidth * 2 << " "
+ << fBottom + fHalfWidth * 2 << " l\n";
+ sAppStream << fRight - fHalfWidth * 2 << " "
+ << fBottom + fHalfWidth * 2 << " l\n";
+ sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
+ << " l f\n";
+ }
+
+ sColor = CPWL_Utils::GetColorAppStream(color, TRUE);
+ if (sColor.GetLength() > 0) {
+ sAppStream << sColor;
+ sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " "
+ << fTop - fBottom << " re\n";
+ sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " "
+ << fRight - fLeft - fHalfWidth * 2 << " "
+ << fTop - fBottom - fHalfWidth * 2 << " re f*\n";
+ }
+ break;
+ case PBS_UNDERLINED:
+ sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
+ if (sColor.GetLength() > 0) {
+ sAppStream << sColor;
+ sAppStream << fWidth << " w\n";
+ sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n";
+ sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n";
+ }
+ break;
+ }
+
+ sAppStream << "Q\n";
+ }
+
+ return sAppStream.GetByteString();
+}
+
+CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
+ const CPDF_Rect& rect,
+ FX_FLOAT fWidth,
+ const CPWL_Color& color,
+ const CPWL_Color& crLeftTop,
+ const CPWL_Color& crRightBottom,
+ int32_t nStyle,
+ const CPWL_Dash& dash) {
+ CFX_ByteTextBuf sAppStream;
+ CFX_ByteString sColor;
+
+ if (fWidth > 0.0f) {
+ sAppStream << "q\n";
+
+ switch (nStyle) {
+ default:
+ case PBS_SOLID:
+ case PBS_UNDERLINED: {
+ sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
+ if (sColor.GetLength() > 0) {
+ sAppStream << "q\n" << fWidth << " w\n" << sColor
+ << CPWL_Utils::GetAP_Circle(
+ CPWL_Utils::DeflateRect(rect, fWidth / 2.0f))
+ << " S\nQ\n";
+ }
+ } break;
+ case PBS_DASH: {
+ sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
+ if (sColor.GetLength() > 0) {
+ sAppStream << "q\n" << fWidth << " w\n"
+ << "[" << dash.nDash << " " << dash.nGap << "] "
+ << dash.nPhase << " d\n" << sColor
+ << CPWL_Utils::GetAP_Circle(
+ CPWL_Utils::DeflateRect(rect, fWidth / 2.0f))
+ << " S\nQ\n";
+ }
+ } break;
+ case PBS_BEVELED: {
+ FX_FLOAT fHalfWidth = fWidth / 2.0f;
+
+ sColor = CPWL_Utils::GetColorAppStream(color, FALSE);
+ if (sColor.GetLength() > 0) {
+ sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
+ << CPWL_Utils::GetAP_Circle(rect) << " S\nQ\n";
+ }
+
+ sColor = CPWL_Utils::GetColorAppStream(crLeftTop, FALSE);
+ if (sColor.GetLength() > 0) {
+ sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
+ << CPWL_Utils::GetAP_HalfCircle(
+ CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f),
+ 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,
+ int32_t 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,
+ int32_t 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,
+ int32_t& alpha,
+ FX_FLOAT& red,
+ FX_FLOAT& green,
+ FX_FLOAT& blue) {
+ switch (color.nColorType) {
+ case COLORTYPE_TRANSPARENT: {
+ alpha = 0;
+ } break;
+ case COLORTYPE_GRAY: {
+ ConvertGRAY2RGB(color.fColor1, red, green, blue);
+ } break;
+ case COLORTYPE_RGB: {
+ red = color.fColor1;
+ green = color.fColor2;
+ blue = color.fColor3;
+ } break;
+ case COLORTYPE_CMYK: {
+ ConvertCMYK2RGB(color.fColor1, color.fColor2, color.fColor3,
+ color.fColor4, red, green, blue);
+ } break;
+ }
+}
+
+FX_COLORREF CPWL_Utils::PWLColorToFXColor(const CPWL_Color& color,
+ int32_t nTransparancy) {
+ int32_t nAlpha = nTransparancy;
+ FX_FLOAT dRed = 0;
+ FX_FLOAT dGreen = 0;
+ FX_FLOAT dBlue = 0;
+
+ PWLColorToARGB(color, nAlpha, dRed, dGreen, dBlue);
+
+ return ArgbEncode(nAlpha, (int32_t)(dRed * 255), (int32_t)(dGreen * 255),
+ (int32_t)(dBlue * 255));
+}
+
+void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice,
+ 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,
+ int32_t nCount,
+ const FX_COLORREF& color) {
+ CFX_PathData path;
+ path.SetPointCount(nCount);
+
+ path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_MOVETO);
+ for (int32_t i = 1; i < nCount; i++)
+ path.SetPoint(i, pPts[i].x, pPts[i].y, FXPT_LINETO);
+
+ pDevice->DrawPath(&path, pUser2Device, NULL, color, 0, FXFILL_ALTERNATE);
+}
+
+void CPWL_Utils::DrawStrokeRect(CFX_RenderDevice* pDevice,
+ 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,
+ int32_t 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,
+ int32_t nTransparancy,
+ int32_t nStartGray,
+ int32_t nEndGray) {
+ FX_FLOAT fStepGray = 1.0f;
+
+ if (bVertical) {
+ fStepGray = (nEndGray - nStartGray) / rect.Height();
+
+ for (FX_FLOAT fy = rect.bottom + 0.5f; fy <= rect.top - 0.5f; fy += 1.0f) {
+ int32_t nGray = nStartGray + (int32_t)(fStepGray * (fy - rect.bottom));
+ CPWL_Utils::DrawStrokeLine(
+ pDevice, pUser2Device, 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) {
+ int32_t nGray = nStartGray + (int32_t)(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,
+ int32_t nStyle,
+ const CPWL_Dash& dash,
+ int32_t nTransparancy) {
+ FX_FLOAT fLeft = rect.left;
+ FX_FLOAT fRight = rect.right;
+ FX_FLOAT fTop = rect.top;
+ FX_FLOAT fBottom = rect.bottom;
+
+ if (fWidth > 0.0f) {
+ FX_FLOAT fHalfWidth = fWidth / 2.0f;
+
+ switch (nStyle) {
+ default:
+ case PBS_SOLID: {
+ CFX_PathData path;
+ path.AppendRect(fLeft, fBottom, fRight, fTop);
+ path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth,
+ fTop - fWidth);
+ pDevice->DrawPath(&path, pUser2Device, NULL,
+ PWLColorToFXColor(color, nTransparancy), 0,
+ FXFILL_ALTERNATE);
+ } break;
+ case PBS_DASH: {
+ CFX_PathData path;
+
+ path.SetPointCount(5);
+ path.SetPoint(0, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f,
+ FXPT_MOVETO);
+ path.SetPoint(1, fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f,
+ FXPT_LINETO);
+ path.SetPoint(2, fRight - fWidth / 2.0f, fTop - fWidth / 2.0f,
+ FXPT_LINETO);
+ path.SetPoint(3, fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f,
+ FXPT_LINETO);
+ path.SetPoint(4, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f,
+ FXPT_LINETO);
+
+ CFX_GraphStateData gsd;
+ gsd.SetDashCount(2);
+ gsd.m_DashArray[0] = 3.0f;
+ gsd.m_DashArray[1] = 3.0f;
+ gsd.m_DashPhase = 0;
+
+ gsd.m_LineWidth = fWidth;
+ pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
+ PWLColorToFXColor(color, nTransparancy),
+ FXFILL_WINDING);
+ } break;
+ case PBS_BEVELED:
+ case PBS_INSET: {
+ CFX_GraphStateData gsd;
+ gsd.m_LineWidth = fHalfWidth;
+
+ CFX_PathData pathLT;
+
+ pathLT.SetPointCount(7);
+ pathLT.SetPoint(0, fLeft + fHalfWidth, fBottom + fHalfWidth,
+ FXPT_MOVETO);
+ pathLT.SetPoint(1, fLeft + fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
+ pathLT.SetPoint(2, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
+ pathLT.SetPoint(3, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2,
+ FXPT_LINETO);
+ pathLT.SetPoint(4, fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2,
+ FXPT_LINETO);
+ pathLT.SetPoint(5, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2,
+ FXPT_LINETO);
+ pathLT.SetPoint(6, fLeft + fHalfWidth, fBottom + fHalfWidth,
+ FXPT_LINETO);
+
+ pDevice->DrawPath(&pathLT, pUser2Device, &gsd,
+ PWLColorToFXColor(crLeftTop, nTransparancy), 0,
+ FXFILL_ALTERNATE);
+
+ CFX_PathData pathRB;
+
+ pathRB.SetPointCount(7);
+ pathRB.SetPoint(0, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_MOVETO);
+ pathRB.SetPoint(1, fRight - fHalfWidth, fBottom + fHalfWidth,
+ FXPT_LINETO);
+ pathRB.SetPoint(2, fLeft + fHalfWidth, fBottom + fHalfWidth,
+ FXPT_LINETO);
+ pathRB.SetPoint(3, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2,
+ FXPT_LINETO);
+ pathRB.SetPoint(4, fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2,
+ FXPT_LINETO);
+ pathRB.SetPoint(5, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2,
+ FXPT_LINETO);
+ pathRB.SetPoint(6, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
+
+ pDevice->DrawPath(&pathRB, pUser2Device, &gsd,
+ PWLColorToFXColor(crRightBottom, nTransparancy), 0,
+ FXFILL_ALTERNATE);
+
+ CFX_PathData path;
+
+ path.AppendRect(fLeft, fBottom, fRight, fTop);
+ path.AppendRect(fLeft + fHalfWidth, fBottom + fHalfWidth,
+ fRight - fHalfWidth, fTop - fHalfWidth);
+
+ pDevice->DrawPath(&path, pUser2Device, &gsd,
+ PWLColorToFXColor(color, nTransparancy), 0,
+ FXFILL_ALTERNATE);
+ } break;
+ case PBS_UNDERLINED: {
+ CFX_PathData path;
+
+ path.SetPointCount(2);
+ path.SetPoint(0, fLeft, fBottom + fWidth / 2, FXPT_MOVETO);
+ path.SetPoint(1, fRight, fBottom + fWidth / 2, FXPT_LINETO);
+
+ CFX_GraphStateData gsd;
+ gsd.m_LineWidth = fWidth;
+
+ pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
+ PWLColorToFXColor(color, nTransparancy),
+ FXFILL_ALTERNATE);
+ } break;
+ case PBS_SHADOW: {
+ CFX_PathData path;
+ path.AppendRect(fLeft, fBottom, fRight, fTop);
+ path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth,
+ fTop - fWidth);
+ pDevice->DrawPath(&path, pUser2Device, NULL,
+ PWLColorToFXColor(color, nTransparancy / 2), 0,
+ FXFILL_ALTERNATE);
+ } break;
+ }
+ }
+}
+
+static void AddSquigglyPath(CFX_PathData& PathData,
+ FX_FLOAT fStartX,
+ FX_FLOAT fEndX,
+ FX_FLOAT fY,
+ FX_FLOAT fStep) {
+ PathData.AddPointCount(1);
+ PathData.SetPoint(PathData.GetPointCount() - 1, fStartX, fY, FXPT_MOVETO);
+
+ FX_FLOAT fx;
+ int32_t i;
+
+ for (i = 1, fx = fStartX + fStep; fx < fEndX; fx += fStep, i++) {
+ PathData.AddPointCount(1);
+ PathData.SetPoint(PathData.GetPointCount() - 1, fx, fY + (i & 1) * fStep,
+ FXPT_LINETO);
+ }
+}
+
+static void AddSpellCheckObj(CFX_PathData& PathData,
+ IFX_Edit* pEdit,
+ const CPVT_WordRange& wrWord) {
+ FX_FLOAT fStartX = 0.0f;
+ FX_FLOAT fEndX = 0.0f;
+ FX_FLOAT fY = 0.0f;
+ FX_FLOAT fStep = 0.0f;
+
+ FX_BOOL bBreak = FALSE;
+
+ if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
+ pIterator->SetAt(wrWord.BeginPos);
+
+ do {
+ CPVT_WordPlace place = pIterator->GetAt();
+
+ CPVT_Line line;
+ if (pIterator->GetLine(line)) {
+ fY = line.ptLine.y;
+ fStep = (line.fLineAscent - line.fLineDescent) / 16.0f;
+ }
+
+ if (place.LineCmp(wrWord.BeginPos) == 0) {
+ pIterator->SetAt(wrWord.BeginPos);
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ fStartX = word.ptWord.x;
+ }
+ } else {
+ fStartX = line.ptLine.x;
+ }
+
+ if (place.LineCmp(wrWord.EndPos) == 0) {
+ pIterator->SetAt(wrWord.EndPos);
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ fEndX = word.ptWord.x + word.fWidth;
+ }
+
+ bBreak = TRUE;
+ } else {
+ fEndX = line.ptLine.x + line.fLineWidth;
+ }
+
+ AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep);
+
+ if (bBreak)
+ break;
+ } while (pIterator->NextLine());
+ }
+}
+
+void CPWL_Utils::DrawEditSpellCheck(CFX_RenderDevice* pDevice,
+ 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 = (int32_t)rcTemp.left;
+ rcDevClip.right = (int32_t)rcTemp.right;
+ rcDevClip.top = (int32_t)rcTemp.top;
+ rcDevClip.bottom = (int32_t)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(int32_t 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,
+ int32_t nType,
+ const CPDF_Rect& rect,
+ const CPWL_Color& crFill,
+ const CPWL_Color& crStroke,
+ const int32_t nTransparancy) {
+ CFX_GraphStateData gsd;
+ gsd.m_LineWidth = 1.0f;
+
+ CFX_ByteString sPath;
+ CFX_PathData path;
+
+ switch (nType) {
+ case PWL_ICONTYPE_CHECKMARK:
+ GetGraphics_Checkmark(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_CIRCLE:
+ GetGraphics_Circle(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_COMMENT:
+ GetGraphics_Comment(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_CROSS:
+ GetGraphics_Cross(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_HELP:
+ GetGraphics_Help(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_INSERTTEXT:
+ GetGraphics_InsertText(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_KEY:
+ GetGraphics_Key(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_NEWPARAGRAPH:
+ GetGraphics_NewParagraph(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_TEXTNOTE:
+ GetGraphics_TextNote(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_PARAGRAPH:
+ GetGraphics_Paragraph(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_RIGHTARROW:
+ GetGraphics_RightArrow(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_RIGHTPOINTER:
+ GetGraphics_RightPointer(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_STAR:
+ GetGraphics_Star(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_UPARROW:
+ GetGraphics_UpArrow(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_UPLEFTARROW:
+ GetGraphics_UpLeftArrow(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_GRAPH:
+ GetGraphics_Graph(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_PAPERCLIP:
+ GetGraphics_Paperclip(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_ATTACHMENT:
+ GetGraphics_Attachment(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_TAG:
+ GetGraphics_Tag(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ case PWL_ICONTYPE_FOXIT:
+ GetGraphics_Foxit(sPath, path, rect, PWLPT_PATHDATA);
+ break;
+ default:
+ return;
+ }
+
+ pDevice->DrawPath(
+ &path, pUser2Device, &gsd, PWLColorToFXColor(crFill, nTransparancy),
+ PWLColorToFXColor(crStroke, nTransparancy), FXFILL_ALTERNATE);
+}
+
+void CPWL_Utils::GetGraphics_Checkmark(CFX_ByteString& sPathData,
+ CFX_PathData& path,
+ const 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 (int32_t i = 0; i < 5; i++) {
+ px1[i] = ptCenter.x + fLongRadius * (FX_FLOAT)cos(fAngel);
+ py1[i] = ptCenter.y + fLongRadius * (FX_FLOAT)sin(fAngel);
+
+ fAngel += PWL_PI * 2 / 5.0f;
+ }
+
+ fAngel = PWL_PI / 5.0f + PWL_PI / 10.0f;
+
+ for (int32_t j = 0; j < 5; j++) {
+ px2[j] = ptCenter.x + fShortRadius * (FX_FLOAT)cos(fAngel);
+ py2[j] = ptCenter.y + fShortRadius * (FX_FLOAT)sin(fAngel);
+
+ fAngel += 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 (int32_t k = 0; k < 4; k++) {
+ PathArray[(k + 1) * 2] =
+ CPWL_PathData(CPWL_Point(px1[k + 1], py1[k + 1]), PWLPT_LINETO);
+ PathArray[(k + 1) * 2 + 1] =
+ CPWL_PathData(CPWL_Point(px2[k + 1], py2[k + 1]), PWLPT_LINETO);
+ }
+
+ PathArray[10] = CPWL_PathData(CPWL_Point(px1[0], py1[0]), PWLPT_LINETO);
+
+ if (type == PWLPT_STREAM)
+ sPathData = GetAppStreamFromArray(PathArray, 11);
+ else
+ GetPathDataFromArray(path, PathArray, 11);
+}
+
+void CPWL_Utils::GetGraphics_UpArrow(CFX_ByteString& sPathData,
+ CFX_PathData& path,
+ const 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),
+ };
+
+ if (type == PWLPT_STREAM)
+ sPathData = GetAppStreamFromArray(PathArray, 23);
+ else
+ GetPathDataFromArray(path, PathArray, 23);
+}
+
+void CPWL_Color::ConvertColorType(int32_t other_nColorType) {
+ switch (other_nColorType) {
+ case COLORTYPE_TRANSPARENT:
+ break;
+ case COLORTYPE_GRAY:
+ switch (other_nColorType) {
+ case COLORTYPE_RGB:
+ CPWL_Utils::ConvertGRAY2RGB(fColor1, fColor1, fColor2, fColor3);
+ break;
+ case COLORTYPE_CMYK:
+ CPWL_Utils::ConvertGRAY2CMYK(fColor1, fColor1, fColor2, fColor3,
+ fColor4);
+ break;
+ }
+ break;
+ case COLORTYPE_RGB:
+ switch (other_nColorType) {
+ case COLORTYPE_GRAY:
+ CPWL_Utils::ConvertRGB2GRAY(fColor1, fColor2, fColor3, fColor1);
+ break;
+ case COLORTYPE_CMYK:
+ CPWL_Utils::ConvertRGB2CMYK(fColor1, fColor2, fColor3, fColor1,
+ fColor2, fColor3, fColor4);
+ break;
+ }
+ break;
+ case COLORTYPE_CMYK:
+ switch (other_nColorType) {
+ case COLORTYPE_GRAY:
+ CPWL_Utils::ConvertCMYK2GRAY(fColor1, fColor2, fColor3, fColor4,
+ fColor1);
+ break;
+ case COLORTYPE_RGB:
+ CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4,
+ fColor1, fColor2, fColor3);
+ break;
+ }
+ break;
+ }
+ nColorType = other_nColorType;
+}
diff --git a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
index 1bb2ffd107..ce8bc57ae2 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp
@@ -13,545 +13,449 @@
/* -------------------------- CPWL_Timer -------------------------- */
-static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap()
-{
+static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap() {
// Leak the object at shutdown.
static auto timeMap = new std::map<int32_t, CPWL_Timer*>;
return *timeMap;
}
-CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemHandler) :
- m_nTimerID(0),
- m_pAttached(pAttached),
- m_pSystemHandler(pSystemHandler)
-{
- ASSERT(m_pAttached != NULL);
- ASSERT(m_pSystemHandler != NULL);
+CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached,
+ IFX_SystemHandler* pSystemHandler)
+ : m_nTimerID(0), m_pAttached(pAttached), m_pSystemHandler(pSystemHandler) {
+ ASSERT(m_pAttached != NULL);
+ ASSERT(m_pSystemHandler != NULL);
}
-CPWL_Timer::~CPWL_Timer()
-{
- KillPWLTimer();
+CPWL_Timer::~CPWL_Timer() {
+ KillPWLTimer();
}
-int32_t CPWL_Timer::SetPWLTimer(int32_t nElapse)
-{
- if (m_nTimerID != 0)
- KillPWLTimer();
- m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc);
+int32_t CPWL_Timer::SetPWLTimer(int32_t nElapse) {
+ if (m_nTimerID != 0)
+ KillPWLTimer();
+ m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc);
- GetPWLTimeMap()[m_nTimerID] = this;
- return m_nTimerID;
+ GetPWLTimeMap()[m_nTimerID] = this;
+ return m_nTimerID;
}
-void CPWL_Timer::KillPWLTimer()
-{
- if (m_nTimerID == 0)
- return;
+void CPWL_Timer::KillPWLTimer() {
+ if (m_nTimerID == 0)
+ return;
- m_pSystemHandler->KillTimer(m_nTimerID);
- GetPWLTimeMap().erase(m_nTimerID);
- m_nTimerID = 0;
+ m_pSystemHandler->KillTimer(m_nTimerID);
+ GetPWLTimeMap().erase(m_nTimerID);
+ m_nTimerID = 0;
}
-void CPWL_Timer::TimerProc(int32_t idEvent)
-{
- auto it = GetPWLTimeMap().find(idEvent);
- if (it == GetPWLTimeMap().end())
- return;
+void CPWL_Timer::TimerProc(int32_t idEvent) {
+ auto it = GetPWLTimeMap().find(idEvent);
+ if (it == GetPWLTimeMap().end())
+ return;
- CPWL_Timer* pTimer = it->second;
- if (pTimer->m_pAttached)
- pTimer->m_pAttached->TimerProc();
+ CPWL_Timer* pTimer = it->second;
+ if (pTimer->m_pAttached)
+ pTimer->m_pAttached->TimerProc();
}
/* -------------------------- CPWL_TimerHandler -------------------------- */
-CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL)
-{
-}
+CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL) {}
-CPWL_TimerHandler::~CPWL_TimerHandler()
-{
- delete m_pTimer;
+CPWL_TimerHandler::~CPWL_TimerHandler() {
+ delete m_pTimer;
}
-void CPWL_TimerHandler::BeginTimer(int32_t nElapse)
-{
- if (!m_pTimer)
- m_pTimer = new CPWL_Timer(this, GetSystemHandler());
+void CPWL_TimerHandler::BeginTimer(int32_t nElapse) {
+ if (!m_pTimer)
+ m_pTimer = new CPWL_Timer(this, GetSystemHandler());
- if (m_pTimer)
- m_pTimer->SetPWLTimer(nElapse);
+ if (m_pTimer)
+ m_pTimer->SetPWLTimer(nElapse);
}
-void CPWL_TimerHandler::EndTimer()
-{
- if (m_pTimer)
- m_pTimer->KillPWLTimer();
+void CPWL_TimerHandler::EndTimer() {
+ if (m_pTimer)
+ m_pTimer->KillPWLTimer();
}
-void CPWL_TimerHandler::TimerProc()
-{
-}
+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( int32_t i=0,sz=m_aMousePath.GetSize(); i<sz; i++)
- if (m_aMousePath.GetAt(i) == pWnd)
- return TRUE;
-
- return FALSE;
- }
+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 (int32_t i = 0, sz = m_aMousePath.GetSize(); i < sz; i++)
+ if (m_aMousePath.GetAt(i) == pWnd)
+ return TRUE;
- FX_BOOL IsMainCaptureKeyboard(const CPWL_Wnd * pWnd) const
- {
- return pWnd == m_pMainKeyboardWnd;
- }
+ return FALSE;
+ }
+ FX_BOOL IsMainCaptureKeyboard(const CPWL_Wnd* pWnd) const {
+ return pWnd == m_pMainKeyboardWnd;
+ }
- FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd * pWnd) const
- {
- if (pWnd)
- for( int32_t i=0,sz=m_aKeyboardPath.GetSize(); i<sz; i++)
- if (m_aKeyboardPath.GetAt(i) == pWnd)
- return TRUE;
+ FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const {
+ if (pWnd)
+ for (int32_t i = 0, sz = m_aKeyboardPath.GetSize(); i < sz; i++)
+ if (m_aKeyboardPath.GetAt(i) == pWnd)
+ return TRUE;
- return FALSE;
- }
+ return FALSE;
+ }
- void SetFocus(CPWL_Wnd * pWnd)
- {
- m_aKeyboardPath.RemoveAll();
+ void SetFocus(CPWL_Wnd* pWnd) {
+ m_aKeyboardPath.RemoveAll();
- if (pWnd)
- {
- m_pMainKeyboardWnd = pWnd;
+ if (pWnd) {
+ m_pMainKeyboardWnd = pWnd;
- CPWL_Wnd * pParent = pWnd;
- while (pParent)
- {
- m_aKeyboardPath.Add(pParent);
- pParent = pParent->GetParentWindow();
- }
+ CPWL_Wnd* pParent = pWnd;
+ while (pParent) {
+ m_aKeyboardPath.Add(pParent);
+ pParent = pParent->GetParentWindow();
+ }
- pWnd->OnSetFocus();
- }
+ 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 KillFocus() {
+ if (m_aKeyboardPath.GetSize() > 0)
+ if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0))
+ pWnd->OnKillFocus();
- void SetCapture(CPWL_Wnd * pWnd)
- {
- m_aMousePath.RemoveAll();
+ m_pMainKeyboardWnd = NULL;
+ m_aKeyboardPath.RemoveAll();
+ }
- if (pWnd)
- {
- m_pMainMouseWnd = pWnd;
+ void SetCapture(CPWL_Wnd* pWnd) {
+ m_aMousePath.RemoveAll();
- CPWL_Wnd * pParent = pWnd;
- while (pParent)
- {
- m_aMousePath.Add(pParent);
- pParent = pParent->GetParentWindow();
- }
- }
- }
+ if (pWnd) {
+ m_pMainMouseWnd = pWnd;
- void ReleaseCapture()
- {
- m_pMainMouseWnd = NULL;
- m_aMousePath.RemoveAll();
+ CPWL_Wnd* pParent = pWnd;
+ while (pParent) {
+ m_aMousePath.Add(pParent);
+ pParent = pParent->GetParentWindow();
+ }
}
-
-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;
+ }
+
+ 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()
+ : 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);
+CPWL_Wnd::~CPWL_Wnd() {
+ ASSERT(m_bCreated == FALSE);
}
-CFX_ByteString CPWL_Wnd::GetClassName() const
-{
- return "CPWL_Wnd";
+CFX_ByteString CPWL_Wnd::GetClassName() const {
+ return "CPWL_Wnd";
}
-void CPWL_Wnd::Create(const PWL_CREATEPARAM & cp)
-{
- if (!IsValid())
- {
- m_sPrivateParam = cp;
+void CPWL_Wnd::Create(const PWL_CREATEPARAM& cp) {
+ if (!IsValid()) {
+ m_sPrivateParam = cp;
- OnCreate(m_sPrivateParam);
+ OnCreate(m_sPrivateParam);
- m_sPrivateParam.rcRectWnd.Normalize();
- m_rcWindow = m_sPrivateParam.rcRectWnd;
- m_rcClip = CPWL_Utils::InflateRect(m_rcWindow,1.0f);
+ m_sPrivateParam.rcRectWnd.Normalize();
+ m_rcWindow = m_sPrivateParam.rcRectWnd;
+ m_rcClip = CPWL_Utils::InflateRect(m_rcWindow, 1.0f);
- CreateMsgControl();
+ CreateMsgControl();
- if (m_sPrivateParam.pParentWnd)
- m_sPrivateParam.pParentWnd->OnNotify(this, PNM_ADDCHILD);
+ if (m_sPrivateParam.pParentWnd)
+ m_sPrivateParam.pParentWnd->OnNotify(this, PNM_ADDCHILD);
- PWL_CREATEPARAM ccp = m_sPrivateParam;
+ PWL_CREATEPARAM ccp = m_sPrivateParam;
- ccp.dwFlags &= 0xFFFF0000L; //remove sub styles
- ccp.mtChild = CPDF_Matrix(1,0,0,1,0,0);
+ ccp.dwFlags &= 0xFFFF0000L; // remove sub styles
+ ccp.mtChild = CPDF_Matrix(1, 0, 0, 1, 0, 0);
- CreateScrollBar(ccp);
- CreateChildWnd(ccp);
+ CreateScrollBar(ccp);
+ CreateChildWnd(ccp);
- m_bVisible = HasFlag(PWS_VISIBLE);
+ m_bVisible = HasFlag(PWS_VISIBLE);
- OnCreated();
+ OnCreated();
- RePosChildWnd();
- m_bCreated = TRUE;
- }
+ RePosChildWnd();
+ m_bCreated = TRUE;
+ }
}
-void CPWL_Wnd::OnCreate(PWL_CREATEPARAM & cp)
-{
-}
+void CPWL_Wnd::OnCreate(PWL_CREATEPARAM& cp) {}
-void CPWL_Wnd::OnCreated()
-{
-}
-
-void CPWL_Wnd::OnDestroy()
-{
-}
+void CPWL_Wnd::OnCreated() {}
-void CPWL_Wnd::Destroy()
-{
- KillFocus();
+void CPWL_Wnd::OnDestroy() {}
- OnDestroy();
+void CPWL_Wnd::Destroy() {
+ KillFocus();
- if (m_bCreated)
- {
- for (int32_t i = m_aChildren.GetSize()-1; i >= 0; i --)
- {
- if (CPWL_Wnd * pChild = m_aChildren[i])
- {
- pChild->Destroy();
- delete pChild;
- pChild = NULL;
- }
- }
+ OnDestroy();
- if (m_sPrivateParam.pParentWnd)
- m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD);
- m_bCreated = FALSE;
+ if (m_bCreated) {
+ for (int32_t i = m_aChildren.GetSize() - 1; i >= 0; i--) {
+ if (CPWL_Wnd* pChild = m_aChildren[i]) {
+ pChild->Destroy();
+ delete pChild;
+ pChild = NULL;
+ }
}
- DestroyMsgControl();
-
- FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM));
- m_aChildren.RemoveAll();
- m_pVScrollBar = NULL;
-}
+ if (m_sPrivateParam.pParentWnd)
+ m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD);
+ m_bCreated = FALSE;
+ }
-void CPWL_Wnd::Move(const CPDF_Rect & rcNew, FX_BOOL bReset,FX_BOOL bRefresh)
-{
- if (IsValid())
- {
- CPDF_Rect rcOld = GetWindowRect();
+ DestroyMsgControl();
- m_rcWindow = rcNew;
- m_rcWindow.Normalize();
+ FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM));
+ m_aChildren.RemoveAll();
+ m_pVScrollBar = NULL;
+}
- if (rcOld.left != rcNew.left || rcOld.right != rcNew.right ||
- rcOld.top != rcNew.top || rcOld.bottom != rcNew.bottom)
- {
- if (bReset)
- {
- RePosChildWnd();
- }
+void CPWL_Wnd::Move(const CPDF_Rect& rcNew, FX_BOOL bReset, FX_BOOL bRefresh) {
+ if (IsValid()) {
+ CPDF_Rect rcOld = GetWindowRect();
- }
- if (bRefresh)
- {
- InvalidateRectMove(rcOld,rcNew);
- }
+ m_rcWindow = rcNew;
+ m_rcWindow.Normalize();
- m_sPrivateParam.rcRectWnd = m_rcWindow;
+ 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);
+void CPWL_Wnd::InvalidateRectMove(const CPDF_Rect& rcOld,
+ const CPDF_Rect& rcNew) {
+ CPDF_Rect rcUnion = rcOld;
+ rcUnion.Union(rcNew);
- InvalidateRect(&rcUnion);
+ InvalidateRect(&rcUnion);
}
-void CPWL_Wnd::GetAppearanceStream(CFX_ByteString & sAppStream)
-{
- if (IsValid())
- {
- CFX_ByteTextBuf sTextBuf;
- GetAppearanceStream(sTextBuf);
- sAppStream += sTextBuf.GetByteString();
- }
+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);
- }
+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, GetBackgroundColor());
-
- if (HasFlag(PWS_BORDER)) {
- sThis << CPWL_Utils::GetBorderAppStream(
- rectWnd,
- (FX_FLOAT)GetBorderWidth(),
- GetBorderColor(),
- GetBorderLeftTopColor(GetBorderStyle()),
- GetBorderRightBottomColor(GetBorderStyle()),
- GetBorderStyle(),
- GetBorderDash());
- }
+// 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;
- sAppStream << sThis;
- }
-}
+ if (HasFlag(PWS_BACKGROUND))
+ sThis << CPWL_Utils::GetRectFillAppStream(rectWnd, GetBackgroundColor());
-void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf & sAppStream)
-{
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
- {
- pChild->GetAppearanceStream(sAppStream);
- }
+ if (HasFlag(PWS_BORDER)) {
+ sThis << CPWL_Utils::GetBorderAppStream(
+ rectWnd, (FX_FLOAT)GetBorderWidth(), GetBorderColor(),
+ GetBorderLeftTopColor(GetBorderStyle()),
+ GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(),
+ GetBorderDash());
}
-}
-void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- if (IsValid() && IsVisible())
- {
- DrawThisAppearance(pDevice,pUser2Device);
- DrawChildAppearance(pDevice,pUser2Device);
- }
+ sAppStream << sThis;
+ }
}
-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, GetBackgroundColor(), GetTransparency());
- }
-
- if (HasFlag(PWS_BORDER))
- CPWL_Utils::DrawBorder(pDevice,
- pUser2Device,
- rectWnd,
- (FX_FLOAT)GetBorderWidth(),
- GetBorderColor(),
- GetBorderLeftTopColor(GetBorderStyle()),
- GetBorderRightBottomColor(GetBorderStyle()),
- GetBorderStyle(),
- GetBorderDash(),
- GetTransparency());
+void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf& sAppStream) {
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
+ pChild->GetAppearanceStream(sAppStream);
+ }
+ }
+}
+
+void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice,
+ 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,
+ GetBackgroundColor(), GetTransparency());
}
-}
-void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
-{
- for (int32_t 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);
- }
- }
+ if (HasFlag(PWS_BORDER))
+ CPWL_Utils::DrawBorder(
+ pDevice, pUser2Device, rectWnd, (FX_FLOAT)GetBorderWidth(),
+ GetBorderColor(), GetBorderLeftTopColor(GetBorderStyle()),
+ GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(),
+ GetBorderDash(), GetTransparency());
+ }
+}
+
+void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device) {
+ for (int32_t 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();
+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);
- }
- }
+ if (!HasFlag(PWS_NOREFRESHCLIP)) {
+ CPDF_Rect rcClip = GetClipRect();
+ if (!rcClip.IsEmpty()) {
+ rcRefresh.Intersect(rcClip);
+ }
}
-}
-#define PWL_IMPLEMENT_KEY_METHOD(key_method_name)\
-FX_BOOL CPWL_Wnd::key_method_name(FX_WORD nChar, FX_DWORD nFlag)\
-{\
- if (IsValid() && IsVisible() && IsEnabled())\
- {\
- if (IsWndCaptureKeyboard(this))\
- {\
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
- {\
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
- {\
- if (IsWndCaptureKeyboard(pChild))\
- {\
- return pChild->key_method_name(nChar,nFlag);\
- }\
- }\
- }\
- }\
- }\
- return FALSE;\
-}
-
-#define PWL_IMPLEMENT_MOUSE_METHOD(mouse_method_name)\
-FX_BOOL CPWL_Wnd::mouse_method_name(const CPDF_Point & point, FX_DWORD nFlag)\
-{\
- if (IsValid() && IsVisible() && IsEnabled())\
- {\
- if (IsWndCaptureMouse(this))\
- {\
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
- {\
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
- {\
- if (IsWndCaptureMouse(pChild))\
- {\
- return pChild->mouse_method_name(pChild->ParentToChild(point),nFlag);\
- }\
- }\
- }\
- SetCursor();\
- }\
- else\
- {\
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
- {\
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
- {\
- if (pChild->WndHitTest(pChild->ParentToChild(point)))\
- {\
- return pChild->mouse_method_name(pChild->ParentToChild(point),nFlag);\
- }\
- }\
- }\
- if (WndHitTest(point))\
- SetCursor();\
- }\
- }\
- return FALSE;\
-}
+ FX_RECT rcWin = PWLtoWnd(rcRefresh);
+ rcWin.left -= PWL_INVALIDATE_INFLATE;
+ rcWin.top -= PWL_INVALIDATE_INFLATE;
+ rcWin.right += PWL_INVALIDATE_INFLATE;
+ rcWin.bottom += PWL_INVALIDATE_INFLATE;
+
+ if (IFX_SystemHandler* pSH = GetSystemHandler()) {
+ if (FX_HWND hWnd = GetAttachedHWnd()) {
+ pSH->InvalidateRect(hWnd, rcWin);
+ }
+ }
+ }
+}
+
+#define PWL_IMPLEMENT_KEY_METHOD(key_method_name) \
+ FX_BOOL CPWL_Wnd::key_method_name(FX_WORD nChar, FX_DWORD nFlag) { \
+ if (IsValid() && IsVisible() && IsEnabled()) { \
+ if (IsWndCaptureKeyboard(this)) { \
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \
+ if (IsWndCaptureKeyboard(pChild)) { \
+ return pChild->key_method_name(nChar, nFlag); \
+ } \
+ } \
+ } \
+ } \
+ } \
+ return FALSE; \
+ }
+
+#define PWL_IMPLEMENT_MOUSE_METHOD(mouse_method_name) \
+ FX_BOOL CPWL_Wnd::mouse_method_name(const CPDF_Point& point, \
+ FX_DWORD nFlag) { \
+ if (IsValid() && IsVisible() && IsEnabled()) { \
+ if (IsWndCaptureMouse(this)) { \
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \
+ if (IsWndCaptureMouse(pChild)) { \
+ return pChild->mouse_method_name(pChild->ParentToChild(point), \
+ nFlag); \
+ } \
+ } \
+ } \
+ SetCursor(); \
+ } else { \
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \
+ if (pChild->WndHitTest(pChild->ParentToChild(point))) { \
+ return pChild->mouse_method_name(pChild->ParentToChild(point), \
+ nFlag); \
+ } \
+ } \
+ } \
+ if (WndHitTest(point)) \
+ SetCursor(); \
+ } \
+ } \
+ return FALSE; \
+ }
PWL_IMPLEMENT_KEY_METHOD(OnKeyDown)
PWL_IMPLEMENT_KEY_METHOD(OnKeyUp)
@@ -568,726 +472,610 @@ 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 (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
- {
- if (IsWndCaptureKeyboard(pChild))
- {
- return pChild->OnMouseWheel(zDelta,pChild->ParentToChild(point), nFlag);
- }
- }
- }
+FX_BOOL CPWL_Wnd::OnMouseWheel(short zDelta,
+ const CPDF_Point& point,
+ FX_DWORD nFlag) {
+ if (IsValid() && IsVisible() && IsEnabled()) {
+ SetCursor();
+ if (IsWndCaptureKeyboard(this)) {
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
+ if (IsWndCaptureKeyboard(pChild)) {
+ return pChild->OnMouseWheel(zDelta, pChild->ParentToChild(point),
+ nFlag);
+ }
}
+ }
}
- return FALSE;
+ }
+ return FALSE;
}
-void CPWL_Wnd::AddChild(CPWL_Wnd * pWnd)
-{
- m_aChildren.Add(pWnd);
+void CPWL_Wnd::AddChild(CPWL_Wnd* pWnd) {
+ m_aChildren.Add(pWnd);
}
-void CPWL_Wnd::RemoveChild(CPWL_Wnd * pWnd)
-{
- for (int32_t i = m_aChildren.GetSize()-1; i >= 0; i --)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- if (pChild == pWnd)
- {
- m_aChildren.RemoveAt(i);
- break;
- }
- }
+void CPWL_Wnd::RemoveChild(CPWL_Wnd* pWnd) {
+ for (int32_t i = m_aChildren.GetSize() - 1; i >= 0; i--) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
+ if (pChild == pWnd) {
+ m_aChildren.RemoveAt(i);
+ break;
+ }
}
+ }
}
-void CPWL_Wnd::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam)
-{
- switch (msg)
- {
+void CPWL_Wnd::OnNotify(CPWL_Wnd* pWnd,
+ FX_DWORD msg,
+ intptr_t wParam,
+ intptr_t lParam) {
+ switch (msg) {
case PNM_ADDCHILD:
- AddChild(pWnd);
- break;
+ AddChild(pWnd);
+ break;
case PNM_REMOVECHILD:
- RemoveChild(pWnd);
- break;
+ RemoveChild(pWnd);
+ break;
default:
- break;
- }
+ break;
+ }
}
-FX_BOOL CPWL_Wnd::IsValid() const
-{
- return m_bCreated;
+FX_BOOL CPWL_Wnd::IsValid() const {
+ return m_bCreated;
}
-PWL_CREATEPARAM CPWL_Wnd::GetCreationParam() const
-{
- return m_sPrivateParam;
+PWL_CREATEPARAM CPWL_Wnd::GetCreationParam() const {
+ return m_sPrivateParam;
}
-CPWL_Wnd* CPWL_Wnd::GetParentWindow() const
-{
- return m_sPrivateParam.pParentWnd;
+CPWL_Wnd* CPWL_Wnd::GetParentWindow() const {
+ return m_sPrivateParam.pParentWnd;
}
-CPDF_Rect CPWL_Wnd::GetOriginWindowRect() const
-{
- return m_sPrivateParam.rcRectWnd;
+CPDF_Rect CPWL_Wnd::GetOriginWindowRect() const {
+ return m_sPrivateParam.rcRectWnd;
}
-CPDF_Rect CPWL_Wnd::GetWindowRect() const
-{
- return m_rcWindow;
+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 = GetVScrollBar())
- rcClient.right -= pVSB->GetScrollBarWidth();
+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 = GetVScrollBar())
+ rcClient.right -= pVSB->GetScrollBarWidth();
- rcClient.Normalize();
- return rcWindow.Contains(rcClient) ? rcClient : CPDF_Rect();
+ rcClient.Normalize();
+ return rcWindow.Contains(rcClient) ? rcClient : 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_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::GetClientCenterSquare() const {
+ return CPWL_Utils::GetCenterSquare(GetClientRect());
}
-CPDF_Rect CPWL_Wnd::GetWindowCenterSquare() const
-{
- return CPWL_Utils::GetCenterSquare(CPWL_Utils::DeflateRect(GetWindowRect(),0.1f));
+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;
+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::RemoveFlag(FX_DWORD dwFlags) {
+ m_sPrivateParam.dwFlags &= ~dwFlags;
}
-void CPWL_Wnd::AddFlag(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;
+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::SetBackgroundColor(const CPWL_Color& color) {
+ m_sPrivateParam.sBackgroundColor = color;
}
-void CPWL_Wnd::SetTextColor(const CPWL_Color & color)
-{
- m_sPrivateParam.sTextColor = 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;
+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::GetTextColor() const {
+ return m_sPrivateParam.sTextColor;
}
-CPWL_Color CPWL_Wnd::GetTextStrokeColor() const
-{
- return m_sPrivateParam.sTextStrokeColor;
+CPWL_Color CPWL_Wnd::GetTextStrokeColor() const {
+ return m_sPrivateParam.sTextStrokeColor;
}
-int32_t CPWL_Wnd::GetBorderStyle() const
-{
- return m_sPrivateParam.nBorderStyle;
+int32_t CPWL_Wnd::GetBorderStyle() const {
+ return m_sPrivateParam.nBorderStyle;
}
-void CPWL_Wnd::SetBorderStyle(int32_t nBorderStyle)
-{
- if (HasFlag(PWS_BORDER))
- m_sPrivateParam.nBorderStyle = nBorderStyle;
+void CPWL_Wnd::SetBorderStyle(int32_t nBorderStyle) {
+ if (HasFlag(PWS_BORDER))
+ m_sPrivateParam.nBorderStyle = nBorderStyle;
}
-int32_t CPWL_Wnd::GetBorderWidth() const
-{
- if (HasFlag(PWS_BORDER))
- return m_sPrivateParam.dwBorderWidth;
+int32_t CPWL_Wnd::GetBorderWidth() const {
+ if (HasFlag(PWS_BORDER))
+ return m_sPrivateParam.dwBorderWidth;
- return 0;
+ return 0;
}
-int32_t CPWL_Wnd::GetInnerBorderWidth() const
-{
- /*
- switch (GetBorderStyle())
- {
- case PBS_BEVELED:
- case PBS_INSET:
- return GetBorderWidth() / 2;
- }
- */
- return 0;
+int32_t CPWL_Wnd::GetInnerBorderWidth() const {
+ /*
+ switch (GetBorderStyle())
+ {
+ case PBS_BEVELED:
+ case PBS_INSET:
+ return GetBorderWidth() / 2;
+ }
+ */
+ return 0;
}
-void CPWL_Wnd::SetBorderWidth(int32_t nBorderWidth)
-{
- if (HasFlag(PWS_BORDER))
- m_sPrivateParam.dwBorderWidth = nBorderWidth;
+void CPWL_Wnd::SetBorderWidth(int32_t nBorderWidth) {
+ if (HasFlag(PWS_BORDER))
+ m_sPrivateParam.dwBorderWidth = nBorderWidth;
}
-CPWL_Color CPWL_Wnd::GetBorderColor() const
-{
- if (HasFlag(PWS_BORDER))
- return m_sPrivateParam.sBorderColor;
+CPWL_Color CPWL_Wnd::GetBorderColor() const {
+ if (HasFlag(PWS_BORDER))
+ return m_sPrivateParam.sBorderColor;
- return CPWL_Color();
+ return CPWL_Color();
}
-void CPWL_Wnd::SetBorderColor(const CPWL_Color & color)
-{
- if (HasFlag(PWS_BORDER))
- m_sPrivateParam.sBorderColor = 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;
+CPWL_Dash CPWL_Wnd::GetBorderDash() const {
+ return m_sPrivateParam.sDash;
}
-void* CPWL_Wnd::GetAttachedData() const
-{
- return m_sPrivateParam.pAttachedData;
+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;
+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;
+CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const {
+ if (HasFlag(PWS_VSCROLL))
+ return m_pVScrollBar;
- return NULL;
+ return NULL;
}
-void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM & cp)
-{
- CreateVScrollBar(cp);
+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;
+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;
+ // 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;
+ 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);
- }
+ 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::SetCapture() {
+ if (CPWL_MsgControl* pMsgCtrl = GetMsgControl())
+ pMsgCtrl->SetCapture(this);
}
-void CPWL_Wnd::ReleaseCapture()
-{
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- pChild->ReleaseCapture();
+void CPWL_Wnd::ReleaseCapture() {
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++)
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
+ pChild->ReleaseCapture();
- if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
- pMsgCtrl->ReleaseCapture();
+ 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::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::KillFocus() {
+ if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) {
+ if (pMsgCtrl->IsWndCaptureKeyboard(this))
+ pMsgCtrl->KillFocus();
+ }
}
-void CPWL_Wnd::OnSetFocus()
-{
-}
+void CPWL_Wnd::OnSetFocus() {}
-void CPWL_Wnd::OnKillFocus()
-{
-}
+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::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);
+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();
+const CPWL_Wnd* CPWL_Wnd::GetRootWnd() const {
+ if (m_sPrivateParam.pParentWnd)
+ return m_sPrivateParam.pParentWnd->GetRootWnd();
- return this;
+ return this;
}
-void CPWL_Wnd::SetVisible(FX_BOOL bVisible)
-{
- if (IsValid())
- {
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- pChild->SetVisible(bVisible);
- }
- }
+void CPWL_Wnd::SetVisible(FX_BOOL bVisible) {
+ if (IsValid()) {
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
+ pChild->SetVisible(bVisible);
+ }
+ }
- if (bVisible != m_bVisible)
- {
- m_bVisible = bVisible;
- RePosChildWnd();
- InvalidateRect();
- }
+ if (bVisible != m_bVisible) {
+ m_bVisible = bVisible;
+ RePosChildWnd();
+ InvalidateRect();
}
+ }
}
-void CPWL_Wnd::SetClipRect(const CPDF_Rect & rect)
-{
- m_rcClip = rect;
- m_rcClip.Normalize();
+void CPWL_Wnd::SetClipRect(const CPDF_Rect& rect) {
+ m_rcClip = rect;
+ m_rcClip.Normalize();
}
-CPDF_Rect CPWL_Wnd::GetClipRect() const
-{
- return m_rcClip;
+CPDF_Rect CPWL_Wnd::GetClipRect() const {
+ return m_rcClip;
}
-FX_BOOL CPWL_Wnd::IsReadOnly() const
-{
- return HasFlag(PWS_READONLY);
+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()));
+void CPWL_Wnd::RePosChildWnd() {
+ CPDF_Rect rcContent = CPWL_Utils::DeflateRect(
+ GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
- CPWL_ScrollBar * pVSB = GetVScrollBar();
+ CPWL_ScrollBar* pVSB = GetVScrollBar();
- CPDF_Rect rcVScroll = CPDF_Rect(rcContent.right - PWL_SCROLLBAR_WIDTH,
- rcContent.bottom,
- rcContent.right-1.0f,
- rcContent.top);
+ 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);
+ if (pVSB)
+ pVSB->Move(rcVScroll, TRUE, FALSE);
}
-void CPWL_Wnd::CreateChildWnd(const PWL_CREATEPARAM & cp)
-{
-}
+void CPWL_Wnd::CreateChildWnd(const PWL_CREATEPARAM& cp) {}
-void CPWL_Wnd::SetCursor()
-{
- if (IsValid())
- {
- if (IFX_SystemHandler* pSH = GetSystemHandler())
- {
- int32_t nCursorType = GetCreationParam().eCursorType;
- pSH->SetCursor(nCursorType);
- }
+void CPWL_Wnd::SetCursor() {
+ if (IsValid()) {
+ if (IFX_SystemHandler* pSH = GetSystemHandler()) {
+ int32_t nCursorType = GetCreationParam().eCursorType;
+ pSH->SetCursor(nCursorType);
}
+ }
}
-void CPWL_Wnd::CreateMsgControl()
-{
- if (!m_sPrivateParam.pMsgControl)
- m_sPrivateParam.pMsgControl = new CPWL_MsgControl(this);
+void CPWL_Wnd::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;
+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;
+CPWL_MsgControl* CPWL_Wnd::GetMsgControl() const {
+ return m_sPrivateParam.pMsgControl;
}
-FX_BOOL CPWL_Wnd::IsCaptureMouse() const
-{
- return IsWndCaptureMouse(this);
+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);
+FX_BOOL CPWL_Wnd::IsWndCaptureMouse(const CPWL_Wnd* pWnd) const {
+ if (CPWL_MsgControl* pCtrl = GetMsgControl())
+ return pCtrl->IsWndCaptureMouse(pWnd);
- return FALSE;
+ return FALSE;
}
-FX_BOOL CPWL_Wnd::IsWndCaptureKeyboard(const CPWL_Wnd * pWnd) const
-{
- if (CPWL_MsgControl * pCtrl = GetMsgControl())
- return pCtrl->IsWndCaptureKeyboard(pWnd);
+FX_BOOL CPWL_Wnd::IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const {
+ if (CPWL_MsgControl* pCtrl = GetMsgControl())
+ return pCtrl->IsWndCaptureKeyboard(pWnd);
- return FALSE;
+ return FALSE;
}
-FX_BOOL CPWL_Wnd::IsFocused() const
-{
- if (CPWL_MsgControl * pCtrl = GetMsgControl())
- return pCtrl->IsMainCaptureKeyboard(this);
+FX_BOOL CPWL_Wnd::IsFocused() const {
+ if (CPWL_MsgControl* pCtrl = GetMsgControl())
+ return pCtrl->IsMainCaptureKeyboard(this);
- return FALSE;
+ return FALSE;
}
-CPDF_Rect CPWL_Wnd::GetFocusRect() const
-{
- return CPWL_Utils::InflateRect(GetWindowRect(),1);
+CPDF_Rect CPWL_Wnd::GetFocusRect() const {
+ return CPWL_Utils::InflateRect(GetWindowRect(), 1);
}
-FX_FLOAT CPWL_Wnd::GetFontSize() const
-{
- return m_sPrivateParam.fFontSize;
+FX_FLOAT CPWL_Wnd::GetFontSize() const {
+ return m_sPrivateParam.fFontSize;
}
-void CPWL_Wnd::SetFontSize(FX_FLOAT fFontSize)
-{
- m_sPrivateParam.fFontSize = fFontSize;
+void CPWL_Wnd::SetFontSize(FX_FLOAT fFontSize) {
+ m_sPrivateParam.fFontSize = fFontSize;
}
-IFX_SystemHandler* CPWL_Wnd::GetSystemHandler() const
-{
- return m_sPrivateParam.pSystemHandler;
+IFX_SystemHandler* CPWL_Wnd::GetSystemHandler() const {
+ return m_sPrivateParam.pSystemHandler;
}
-IPWL_FocusHandler* CPWL_Wnd::GetFocusHandler() const
-{
- return m_sPrivateParam.pFocusHandler;
+IPWL_FocusHandler* CPWL_Wnd::GetFocusHandler() const {
+ return m_sPrivateParam.pFocusHandler;
}
-IPWL_Provider* CPWL_Wnd::GetProvider() const
-{
- return m_sPrivateParam.pProvider;
+IPWL_Provider* CPWL_Wnd::GetProvider() const {
+ return m_sPrivateParam.pProvider;
}
-IFX_Edit_FontMap* CPWL_Wnd::GetFontMap() const
-{
- return m_sPrivateParam.pFontMap;
+IFX_Edit_FontMap* CPWL_Wnd::GetFontMap() const {
+ return m_sPrivateParam.pFontMap;
}
-CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(int32_t nBorderStyle) const
-{
- CPWL_Color color;
+CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(int32_t nBorderStyle) const {
+ CPWL_Color color;
- switch (nBorderStyle)
- {
- case PBS_SOLID:
- break;
- case PBS_DASH:
- break;
- case PBS_BEVELED:
- color = CPWL_Color(COLORTYPE_GRAY,1);
- break;
- case PBS_INSET:
- color = CPWL_Color(COLORTYPE_GRAY,0.5f);
- break;
- case PBS_UNDERLINED:
- break;
- }
+ switch (nBorderStyle) {
+ case PBS_SOLID:
+ break;
+ case PBS_DASH:
+ break;
+ case PBS_BEVELED:
+ color = CPWL_Color(COLORTYPE_GRAY, 1);
+ break;
+ case PBS_INSET:
+ color = CPWL_Color(COLORTYPE_GRAY, 0.5f);
+ break;
+ case PBS_UNDERLINED:
+ break;
+ }
- return color;
-}
-
-CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(int32_t nBorderStyle) const
-{
- CPWL_Color color;
-
- switch (nBorderStyle)
- {
- case PBS_SOLID:
- break;
- case PBS_DASH:
- break;
- case PBS_BEVELED:
- color = CPWL_Utils::DevideColor(GetBackgroundColor(),2);
- break;
- case PBS_INSET:
- color = CPWL_Color(COLORTYPE_GRAY,0.75f);
- break;
- case PBS_UNDERLINED:
- break;
- }
+ return color;
+}
+
+CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(int32_t nBorderStyle) const {
+ CPWL_Color color;
- return color;
+ switch (nBorderStyle) {
+ case PBS_SOLID:
+ break;
+ case PBS_DASH:
+ break;
+ case PBS_BEVELED:
+ color = CPWL_Utils::DevideColor(GetBackgroundColor(), 2);
+ break;
+ case PBS_INSET:
+ color = CPWL_Color(COLORTYPE_GRAY, 0.75f);
+ break;
+ case PBS_UNDERLINED:
+ break;
+ }
+
+ return color;
}
/* ----------------------------------------------------------------- */
-int32_t CPWL_Wnd::GetTransparency()
-{
- return m_sPrivateParam.nTransparency;
+int32_t CPWL_Wnd::GetTransparency() {
+ return m_sPrivateParam.nTransparency;
}
-void CPWL_Wnd::SetTransparency(int32_t nTransparency)
-{
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- pChild->SetTransparency(nTransparency);
- }
+void CPWL_Wnd::SetTransparency(int32_t nTransparency) {
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
+ pChild->SetTransparency(nTransparency);
}
+ }
- m_sPrivateParam.nTransparency = nTransparency;
+ m_sPrivateParam.nTransparency = nTransparency;
}
-CPDF_Matrix CPWL_Wnd::GetWindowMatrix() const
-{
- CPDF_Matrix mt = GetChildToRoot();
-
- if (IPWL_Provider* pProvider = GetProvider())
- {
- mt.Concat(pProvider->GetWindowMatrix(GetAttachedData()));
- return mt;
- }
+CPDF_Matrix CPWL_Wnd::GetWindowMatrix() const {
+ CPDF_Matrix mt = GetChildToRoot();
+ if (IPWL_Provider* pProvider = GetProvider()) {
+ mt.Concat(pProvider->GetWindowMatrix(GetAttachedData()));
return mt;
+ }
+
+ return mt;
}
-void CPWL_Wnd::PWLtoWnd(const CPDF_Point& point, int32_t& x, int32_t& y) const
-{
- CPDF_Matrix mt = GetWindowMatrix();
- CPDF_Point pt = point;
- mt.Transform(pt.x,pt.y);
- x = (int32_t)(pt.x+0.5);
- y = (int32_t)(pt.y+0.5);
+void CPWL_Wnd::PWLtoWnd(const CPDF_Point& point, int32_t& x, int32_t& y) const {
+ CPDF_Matrix mt = GetWindowMatrix();
+ CPDF_Point pt = point;
+ mt.Transform(pt.x, pt.y);
+ x = (int32_t)(pt.x + 0.5);
+ y = (int32_t)(pt.y + 0.5);
}
-FX_RECT CPWL_Wnd::PWLtoWnd(const CPDF_Rect & rect) const
-{
- CPDF_Rect rcTemp = rect;
- CPDF_Matrix mt = GetWindowMatrix();
- mt.TransformRect(rcTemp);
- return FX_RECT((int32_t)(rcTemp.left+0.5), (int32_t)(rcTemp.bottom+0.5), (int32_t)(rcTemp.right+0.5), (int32_t)(rcTemp.top+0.5));
+FX_RECT CPWL_Wnd::PWLtoWnd(const CPDF_Rect& rect) const {
+ CPDF_Rect rcTemp = rect;
+ CPDF_Matrix mt = GetWindowMatrix();
+ mt.TransformRect(rcTemp);
+ return FX_RECT((int32_t)(rcTemp.left + 0.5), (int32_t)(rcTemp.bottom + 0.5),
+ (int32_t)(rcTemp.right + 0.5), (int32_t)(rcTemp.top + 0.5));
}
-FX_HWND CPWL_Wnd::GetAttachedHWnd() const
-{
- return m_sPrivateParam.hAttachedWnd;
+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;
+CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const {
+ CPDF_Matrix mt = GetChildMatrix();
+ if (mt.IsIdentity())
+ return point;
- CPDF_Point pt = point;
- mt.Transform(pt.x,pt.y);
- return pt;
+ 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;
+CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const {
+ CPDF_Matrix mt = GetChildMatrix();
+ if (mt.IsIdentity())
+ return rect;
- CPDF_Rect rc = rect;
- mt.TransformRect(rc);
- return rc;
+ 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;
+CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const {
+ CPDF_Matrix mt = GetChildMatrix();
+ if (mt.IsIdentity())
+ return point;
- mt.SetReverse(mt);
- CPDF_Point pt = point;
- mt.Transform(pt.x,pt.y);
- return pt;
+ 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;
+CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const {
+ CPDF_Matrix mt = GetChildMatrix();
+ if (mt.IsIdentity())
+ return rect;
- mt.SetReverse(mt);
- CPDF_Rect rc = rect;
- mt.TransformRect(rc);
- return rc;
+ 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();
- }
+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;
+ }
+ return mt;
}
-CPDF_Matrix CPWL_Wnd::GetChildMatrix() const
-{
- if (HasFlag(PWS_CHILD))
- return m_sPrivateParam.mtChild;
+CPDF_Matrix CPWL_Wnd::GetChildMatrix() const {
+ if (HasFlag(PWS_CHILD))
+ return m_sPrivateParam.mtChild;
- return CPDF_Matrix(1,0,0,1,0,0);
+ return CPDF_Matrix(1, 0, 0, 1, 0, 0);
}
-void CPWL_Wnd::SetChildMatrix(const CPDF_Matrix& mt)
-{
- m_sPrivateParam.mtChild = mt;
+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;
- }
+const CPWL_Wnd* CPWL_Wnd::GetFocused() const {
+ if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) {
+ return pMsgCtrl->m_pMainKeyboardWnd;
+ }
- return NULL;
+ return NULL;
}
-void CPWL_Wnd::EnableWindow(FX_BOOL bEnable)
-{
- if (m_bEnabled != bEnable)
- {
- for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
- {
- if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
- {
- pChild->EnableWindow(bEnable);
- }
- }
+void CPWL_Wnd::EnableWindow(FX_BOOL bEnable) {
+ if (m_bEnabled != bEnable) {
+ for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
+ if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
+ pChild->EnableWindow(bEnable);
+ }
+ }
- m_bEnabled = bEnable;
+ m_bEnabled = bEnable;
- if (bEnable)
- OnEnabled();
- else
- OnDisabled();
- }
+ if (bEnable)
+ OnEnabled();
+ else
+ OnDisabled();
+ }
}
-FX_BOOL CPWL_Wnd::IsEnabled()
-{
- return m_bEnabled;
+FX_BOOL CPWL_Wnd::IsEnabled() {
+ return m_bEnabled;
}
-void CPWL_Wnd::OnEnabled()
-{
-}
+void CPWL_Wnd::OnEnabled() {}
-void CPWL_Wnd::OnDisabled()
-{
-}
+void CPWL_Wnd::OnDisabled() {}
-FX_BOOL CPWL_Wnd::IsCTRLpressed(FX_DWORD nFlag) const
-{
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
- {
- return pSystemHandler->IsCTRLKeyDown(nFlag);
- }
+FX_BOOL CPWL_Wnd::IsCTRLpressed(FX_DWORD nFlag) const {
+ if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
+ return pSystemHandler->IsCTRLKeyDown(nFlag);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CPWL_Wnd::IsSHIFTpressed(FX_DWORD nFlag) const
-{
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
- {
- return pSystemHandler->IsSHIFTKeyDown(nFlag);
- }
+FX_BOOL CPWL_Wnd::IsSHIFTpressed(FX_DWORD nFlag) const {
+ if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
+ return pSystemHandler->IsSHIFTKeyDown(nFlag);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CPWL_Wnd::IsALTpressed(FX_DWORD nFlag) const
-{
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
- {
- return pSystemHandler->IsALTKeyDown(nFlag);
- }
+FX_BOOL CPWL_Wnd::IsALTpressed(FX_DWORD nFlag) const {
+ if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
+ return pSystemHandler->IsALTKeyDown(nFlag);
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const
-{
- if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
- {
- return pSystemHandler->IsINSERTKeyDown(nFlag);
- }
+FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const {
+ if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
+ return pSystemHandler->IsINSERTKeyDown(nFlag);
+ }
- return FALSE;
+ return FALSE;
}