From 7cc97521db1e52d5927f5605de5f9a7102f8af40 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 22 Jul 2015 14:59:55 -0700 Subject: Fix else-after-returns throughout pdfium. Driven by CS search for pcre:yes file:third_party/pdfium/ -file:pdfium/third_party/ \breturn\b[^;]*;\s*\n*\s*\}*\s*\n*\r*else Note: Care is required to ensure the preceding block is not an else-if. As usual, removed any tabs I saw. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1243883003 . --- fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp | 864 ++++++++++---------- fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp | 876 ++++++++++---------- fpdfsdk/src/pdfwindow/PWL_FontMap.cpp | 730 ++++++++--------- fpdfsdk/src/pdfwindow/PWL_Wnd.cpp | 1385 ++++++++++++++++---------------- 4 files changed, 1901 insertions(+), 1954 deletions(-) (limited to 'fpdfsdk/src/pdfwindow') diff --git a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp index bb2ef7510b..f5c8a815d4 100644 --- a/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_ComboBox.cpp @@ -14,649 +14,641 @@ #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 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) +FX_BOOL CPWL_CBListBox::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag) { - CPWL_Wnd::OnLButtonUp(point,nFlag); + CPWL_Wnd::OnLButtonUp(point,nFlag); - if (m_bMouseDown) - { - ReleaseCapture(); - m_bMouseDown = FALSE; + 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)); - } + 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 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; - - switch (nChar) - { - default: - return FALSE; - case FWL_VKEY_Up: - case FWL_VKEY_Down: - case FWL_VKEY_Home: - case FWL_VKEY_Left: - case FWL_VKEY_End: - case FWL_VKEY_Right: - break; - } - - switch (nChar) - { - case FWL_VKEY_Up: - m_pList->OnVK_UP(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); - break; - case FWL_VKEY_Down: - m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); - break; - case FWL_VKEY_Home: - m_pList->OnVK_HOME(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); - break; - case FWL_VKEY_Left: - m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); - break; - case FWL_VKEY_End: - m_pList->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); - break; - case FWL_VKEY_Right: - m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); - break; - case FWL_VKEY_Delete: - break; - } - - OnNotifySelChanged(TRUE,bExit, nFlag); - - return TRUE; -} - -FX_BOOL CPWL_CBListBox::OnCharWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWORD nFlag) -{ - if (!m_pList) return FALSE; - - if (!m_pList->OnChar(nChar,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag))) return FALSE; - - if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow()) - { - pComboBox->SetSelectText(); - } - - OnNotifySelChanged(TRUE,bExit,nFlag); - - return TRUE; + if (!m_pList) return FALSE; + + switch (nChar) + { + default: + return FALSE; + case FWL_VKEY_Up: + case FWL_VKEY_Down: + case FWL_VKEY_Home: + case FWL_VKEY_Left: + case FWL_VKEY_End: + case FWL_VKEY_Right: + break; + } + + switch (nChar) + { + case FWL_VKEY_Up: + m_pList->OnVK_UP(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); + break; + case FWL_VKEY_Down: + m_pList->OnVK_DOWN(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); + break; + case FWL_VKEY_Home: + m_pList->OnVK_HOME(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); + break; + case FWL_VKEY_Left: + m_pList->OnVK_LEFT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); + break; + case FWL_VKEY_End: + m_pList->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); + break; + case FWL_VKEY_Right: + m_pList->OnVK_RIGHT(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); + break; + case FWL_VKEY_Delete: + break; + } + + OnNotifySelChanged(TRUE,bExit, nFlag); + + return TRUE; +} + +FX_BOOL CPWL_CBListBox::OnCharWithExit(FX_WORD nChar, FX_BOOL & bExit, FX_DWORD nFlag) +{ + if (!m_pList) return FALSE; + + if (!m_pList->OnChar(nChar,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag))) return FALSE; + + if (CPWL_ComboBox* pComboBox = (CPWL_ComboBox*)GetParentWindow()) + { + pComboBox->SetSelectText(); + } + + OnNotifySelChanged(TRUE,bExit,nFlag); + + return TRUE; } /* ---------------------------- CPWL_CBButton ---------------------------- */ void CPWL_CBButton::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream) { - CPWL_Wnd::GetThisAppearanceStream(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); + 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) +FX_BOOL CPWL_CBButton::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag) { - CPWL_Wnd::OnLButtonDown(point,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) +FX_BOOL CPWL_CBButton::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag) { - CPWL_Wnd::OnLButtonUp(point, 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) + 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"; + return "CPWL_ComboBox"; } void CPWL_ComboBox::OnCreate(PWL_CREATEPARAM & cp) { - cp.dwFlags &= ~PWS_HSCROLL; - cp.dwFlags &= ~PWS_VSCROLL; + cp.dwFlags &= ~PWS_HSCROLL; + cp.dwFlags &= ~PWS_VSCROLL; } void CPWL_ComboBox::SetFocus() { - if (m_pEdit) - m_pEdit->SetFocus(); + if (m_pEdit) + m_pEdit->SetFocus(); } void CPWL_ComboBox::KillFocus() { - SetPopup(FALSE); - CPWL_Wnd::KillFocus(); + SetPopup(FALSE); + CPWL_Wnd::KillFocus(); } CFX_WideString CPWL_ComboBox::GetText() const { - if (m_pEdit) - { - return m_pEdit->GetText(); - } - return CFX_WideString(); + 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); + if (m_pEdit) + m_pEdit->SetText(text); } void CPWL_ComboBox::AddString(const FX_WCHAR* string) { - if (m_pList) - m_pList->AddString(string); + if (m_pList) + m_pList->AddString(string); } int32_t CPWL_ComboBox::GetSelect() const { - return m_nSelectItem; + return m_nSelectItem; } void CPWL_ComboBox::SetSelect(int32_t nItemIndex) { - if (m_pList) - m_pList->Select(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); - } + if (m_pEdit) + { + m_pEdit->SetSel(nStartChar,nEndChar); + } } void CPWL_ComboBox::GetEditSel(int32_t & nStartChar, int32_t & nEndChar) const { - nStartChar = -1; - nEndChar = -1; + 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(); - } + if (m_pEdit) + { + m_pEdit->Clear(); + } } void CPWL_ComboBox::CreateChildWnd(const PWL_CREATEPARAM & cp) { - CreateEdit(cp); - CreateButton(cp); - CreateListBox(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); + 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; + 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 (!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.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.sBorderColor.nColorType == COLORTYPE_TRANSPARENT) + lcp.sBorderColor = PWL_DEFAULT_BLACKCOLOR; - if (cp.sBackgroundColor.nColorType == COLORTYPE_TRANSPARENT) - lcp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR; + if (cp.sBackgroundColor.nColorType == COLORTYPE_TRANSPARENT) + lcp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR; - m_pList->Create(lcp); - } + m_pList->Create(lcp); + } } void CPWL_ComboBox::RePosChildWnd() { - CPDF_Rect rcClient = GetClientRect(); + 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); - } - } - else - { - CPDF_Rect rcButton = rcClient; + if (m_pList) + { + m_pList->SetVisible(TRUE); + m_pList->Move(rcList,TRUE,FALSE); + m_pList->ScrollToListItem(m_nSelectItem); + } + } + else + { + CPDF_Rect rcButton = rcClient; - rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH; + 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(); + if (m_pEdit && HasFlag(PCBS_ALLOWCUSTOMTEXT)) + m_pEdit->SelectAll(); } CPDF_Rect CPWL_ComboBox::GetFocusRect() const { - return CPDF_Rect(); + 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) - { - 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); - } - } - } - else - { - m_bPopup = bPopup; - Move(m_rcOldWindow, TRUE, TRUE); - } + 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) + { + 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); + } + } + } + else + { + m_bPopup = bPopup; + Move(m_rcOldWindow, TRUE, TRUE); + } } FX_BOOL CPWL_ComboBox::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) { - if (!m_pList) return FALSE; - if (!m_pEdit) return FALSE; - - m_nSelectItem = -1; - - switch (nChar) - { - case FWL_VKEY_Up: - if (m_pList->GetCurSel() > 0) - { - FX_BOOL bExit = FALSE; - if (m_pList->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_pList->OnKeyDownWithExit(nChar,bExit,nFlag)) - { - if (bExit) return FALSE; - SetSelectText(); - } - } - return TRUE; - } - - if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) - return m_pEdit->OnKeyDown(nChar,nFlag); - else - return FALSE; + if (!m_pList) return FALSE; + if (!m_pEdit) return FALSE; + + m_nSelectItem = -1; + + switch (nChar) + { + case FWL_VKEY_Up: + if (m_pList->GetCurSel() > 0) + { + FX_BOOL bExit = FALSE; + if (m_pList->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_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; + if (!m_pList) + return FALSE; - m_nSelectItem = -1; - FX_BOOL bExit = FALSE; + if (!m_pEdit) + return FALSE; - if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) - { - return m_pEdit->OnChar(nChar,nFlag); - } - else - { - if (m_pList->OnCharWithExit(nChar,bExit,nFlag)) - { - return bExit; - } - else - return FALSE; - } + m_nSelectItem = -1; + if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) + return m_pEdit->OnChar(nChar,nFlag); + + FX_BOOL bExit = FALSE; + return m_pList->OnCharWithExit(nChar,bExit,nFlag) ? bExit : FALSE; } void CPWL_ComboBox::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam) { - switch (msg) - { - case PNM_LBUTTONDOWN: - if (pWnd == m_pButton) - { - SetPopup(!m_bPopup); - return; - } - break; - case PNM_LBUTTONUP: - if (m_pEdit && m_pList) - { - if (pWnd == m_pList) - { - SetSelectText(); - SelectAll(); - m_pEdit->SetFocus(); - SetPopup(FALSE); - return; - } - } - } - - CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam); + switch (msg) + { + case PNM_LBUTTONDOWN: + if (pWnd == m_pButton) + { + SetPopup(!m_bPopup); + return; + } + break; + case PNM_LBUTTONUP: + if (m_pEdit && m_pList) + { + if (pWnd == m_pList) + { + SetSelectText(); + SelectAll(); + m_pEdit->SetFocus(); + SetPopup(FALSE); + return; + } + } + } + + CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam); } FX_BOOL CPWL_ComboBox::IsPopup() const { - return m_bPopup; + 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(); + 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(); + return m_pEdit->IsModified(); } void CPWL_ComboBox::SetFillerNotify(IPWL_Filler_Notify* pNotify) { - m_pFillerNotify = 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_EditCtrl.cpp b/fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp index f562076f1d..0d14587f66 100644 --- a/fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp @@ -12,558 +12,558 @@ #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(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); + m_pEdit = IFX_Edit::NewEdit(); + ASSERT(m_pEdit != NULL); } CPWL_EditCtrl::~CPWL_EditCtrl() { - IFX_Edit::DelEdit(m_pEdit); + IFX_Edit::DelEdit(m_pEdit); } -void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM & cp) +void CPWL_EditCtrl::OnCreate(PWL_CREATEPARAM& cp) { - cp.eCursorType = FXCT_VBEAM; + cp.eCursorType = FXCT_VBEAM; } void CPWL_EditCtrl::OnCreated() { - SetFontSize(GetCreationParam().fFontSize); + 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); + 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); - } - } + 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()); + 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; - } + 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); + if (!IsReadOnly()) + CreateEditCaret(cp); } void CPWL_EditCtrl::CreateEditCaret(const PWL_CREATEPARAM & cp) { - if (!m_pEditCaret) - { - m_pEditCaret = new CPWL_Caret; - m_pEditCaret->SetInvalidRect(GetClientRect()); + 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); + 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); - } + m_pEditCaret->Create(ecp); + } } void CPWL_EditCtrl::SetFontSize(FX_FLOAT fFontSize) { - m_pEdit->SetFontSize(fFontSize); + m_pEdit->SetFontSize(fFontSize); } FX_FLOAT CPWL_EditCtrl::GetFontSize() const { - return m_pEdit->GetFontSize(); + return m_pEdit->GetFontSize(); } FX_BOOL CPWL_EditCtrl::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag) { - if (m_bMouseDown) return TRUE; - - FX_BOOL bRet = CPWL_Wnd::OnKeyDown(nChar,nFlag); - - //FILTER - switch (nChar) - { - default: - return FALSE; - case FWL_VKEY_Delete: - case FWL_VKEY_Up: - case FWL_VKEY_Down: - case FWL_VKEY_Left: - case FWL_VKEY_Right: - case FWL_VKEY_Home: - case FWL_VKEY_End: - case FWL_VKEY_Insert: - case 'C': - case 'V': - case 'X': - case 'A': - case 'Z': - case 'c': - case 'v': - case 'x': - case 'a': - case 'z': - break; - } - - if (nChar == FWL_VKEY_Delete) - { - if (m_pEdit->IsSelected()) - nChar = FWL_VKEY_Unknown; - } - - switch (nChar) - { - case FWL_VKEY_Delete: - Delete(); - return TRUE; - case FWL_VKEY_Insert: - if (IsSHIFTpressed(nFlag)) - PasteText(); - return TRUE; - case FWL_VKEY_Up: - m_pEdit->OnVK_UP(IsSHIFTpressed(nFlag),FALSE); - return TRUE; - case FWL_VKEY_Down: - m_pEdit->OnVK_DOWN(IsSHIFTpressed(nFlag),FALSE); - return TRUE; - case FWL_VKEY_Left: - m_pEdit->OnVK_LEFT(IsSHIFTpressed(nFlag),FALSE); - return TRUE; - case FWL_VKEY_Right: - m_pEdit->OnVK_RIGHT(IsSHIFTpressed(nFlag),FALSE); - return TRUE; - case FWL_VKEY_Home: - m_pEdit->OnVK_HOME(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); - return TRUE; - case FWL_VKEY_End: - m_pEdit->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); - return TRUE; - case FWL_VKEY_Unknown: - if (!IsSHIFTpressed(nFlag)) - Clear(); - else - CutText(); - return TRUE; - default: - break; - } - - return bRet; + if (m_bMouseDown) return TRUE; + + FX_BOOL bRet = CPWL_Wnd::OnKeyDown(nChar,nFlag); + + //FILTER + switch (nChar) + { + default: + return FALSE; + case FWL_VKEY_Delete: + case FWL_VKEY_Up: + case FWL_VKEY_Down: + case FWL_VKEY_Left: + case FWL_VKEY_Right: + case FWL_VKEY_Home: + case FWL_VKEY_End: + case FWL_VKEY_Insert: + case 'C': + case 'V': + case 'X': + case 'A': + case 'Z': + case 'c': + case 'v': + case 'x': + case 'a': + case 'z': + break; + } + + if (nChar == FWL_VKEY_Delete) + { + if (m_pEdit->IsSelected()) + nChar = FWL_VKEY_Unknown; + } + + switch (nChar) + { + case FWL_VKEY_Delete: + Delete(); + return TRUE; + case FWL_VKEY_Insert: + if (IsSHIFTpressed(nFlag)) + PasteText(); + return TRUE; + case FWL_VKEY_Up: + m_pEdit->OnVK_UP(IsSHIFTpressed(nFlag),FALSE); + return TRUE; + case FWL_VKEY_Down: + m_pEdit->OnVK_DOWN(IsSHIFTpressed(nFlag),FALSE); + return TRUE; + case FWL_VKEY_Left: + m_pEdit->OnVK_LEFT(IsSHIFTpressed(nFlag),FALSE); + return TRUE; + case FWL_VKEY_Right: + m_pEdit->OnVK_RIGHT(IsSHIFTpressed(nFlag),FALSE); + return TRUE; + case FWL_VKEY_Home: + m_pEdit->OnVK_HOME(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); + return TRUE; + case FWL_VKEY_End: + m_pEdit->OnVK_END(IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag)); + return TRUE; + case FWL_VKEY_Unknown: + if (!IsSHIFTpressed(nFlag)) + Clear(); + else + CutText(); + return TRUE; + default: + break; + } + + return bRet; } FX_BOOL CPWL_EditCtrl::OnChar(FX_WORD nChar, FX_DWORD nFlag) { - if (m_bMouseDown) return TRUE; - - CPWL_Wnd::OnChar(nChar,nFlag); - - //FILTER - switch (nChar) - { - case 0x0A: - case 0x1B: - return FALSE; - default: - break; - } - - FX_BOOL bCtrl = IsCTRLpressed(nFlag); - FX_BOOL bAlt = IsALTpressed(nFlag); - FX_BOOL bShift = IsSHIFTpressed(nFlag); - - FX_WORD word = nChar; - - if (bCtrl && !bAlt) - { - switch (nChar) - { - case 'C' - 'A' + 1: - CopyText(); - return TRUE; - case 'V' - 'A' + 1: - PasteText(); - return TRUE; - case 'X' - 'A' + 1: - CutText(); - return TRUE; - case 'A' - 'A' + 1: - SelectAll(); - return TRUE; - case 'Z' - 'A' + 1: - if (bShift) - Redo(); - else - Undo(); - return TRUE; - default: - if (nChar < 32) - return FALSE; - } - } - - if (IsReadOnly()) return TRUE; - - if (m_pEdit->IsSelected() && word == FWL_VKEY_Back) - word = FWL_VKEY_Unknown; - - Clear(); - - switch (word) - { - case FWL_VKEY_Back: - Backspace(); - break; - case FWL_VKEY_Return: - InsertReturn(); - break; - case FWL_VKEY_Unknown: - break; - default: - if (IsINSERTpressed(nFlag)) - Delete(); - InsertWord(word, GetCharSet()); - break; - } - - return TRUE; + if (m_bMouseDown) return TRUE; + + CPWL_Wnd::OnChar(nChar,nFlag); + + //FILTER + switch (nChar) + { + case 0x0A: + case 0x1B: + return FALSE; + default: + break; + } + + FX_BOOL bCtrl = IsCTRLpressed(nFlag); + FX_BOOL bAlt = IsALTpressed(nFlag); + FX_BOOL bShift = IsSHIFTpressed(nFlag); + + FX_WORD word = nChar; + + if (bCtrl && !bAlt) + { + switch (nChar) + { + case 'C' - 'A' + 1: + CopyText(); + return TRUE; + case 'V' - 'A' + 1: + PasteText(); + return TRUE; + case 'X' - 'A' + 1: + CutText(); + return TRUE; + case 'A' - 'A' + 1: + SelectAll(); + return TRUE; + case 'Z' - 'A' + 1: + if (bShift) + Redo(); + else + Undo(); + return TRUE; + default: + if (nChar < 32) + return FALSE; + } + } + + if (IsReadOnly()) return TRUE; + + if (m_pEdit->IsSelected() && word == FWL_VKEY_Back) + word = FWL_VKEY_Unknown; + + Clear(); + + switch (word) + { + case FWL_VKEY_Back: + Backspace(); + break; + case FWL_VKEY_Return: + InsertReturn(); + break; + case FWL_VKEY_Unknown: + break; + default: + if (IsINSERTpressed(nFlag)) + Delete(); + InsertWord(word, GetCharSet()); + break; + } + + return TRUE; } FX_BOOL CPWL_EditCtrl::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag) { - CPWL_Wnd::OnLButtonDown(point,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); + 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); + 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(); + return m_pEdit->GetContentRect(); } void CPWL_EditCtrl::SetEditCaret(FX_BOOL bVisible) { - CPDF_Point ptHead(0,0),ptFoot(0,0); + 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); + 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; - } - } + 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); + 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; + 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 +FX_BOOL CPWL_EditCtrl::IsModified() const { - return m_pEdit->IsModified(); + return m_pEdit->IsModified(); } CFX_WideString CPWL_EditCtrl::GetText() const { - return m_pEdit->GetText(); + return m_pEdit->GetText(); } void CPWL_EditCtrl::SetSel(int32_t nStartChar,int32_t nEndChar) { - m_pEdit->SetSel(nStartChar, nEndChar); + m_pEdit->SetSel(nStartChar, nEndChar); } void CPWL_EditCtrl::GetSel(int32_t & nStartChar, int32_t & nEndChar ) const { - m_pEdit->GetSel(nStartChar, nEndChar); + m_pEdit->GetSel(nStartChar, nEndChar); } void CPWL_EditCtrl::Clear() { - if (!IsReadOnly()) - m_pEdit->Clear(); + if (!IsReadOnly()) + m_pEdit->Clear(); } void CPWL_EditCtrl::SelectAll() { - m_pEdit->SelectAll(); + m_pEdit->SelectAll(); } void CPWL_EditCtrl::Paint() { - if (m_pEdit) - m_pEdit->Paint(); + if (m_pEdit) + m_pEdit->Paint(); } void CPWL_EditCtrl::EnableRefresh(FX_BOOL bRefresh) { - if (m_pEdit) - m_pEdit->EnableRefresh(bRefresh); + if (m_pEdit) + m_pEdit->EnableRefresh(bRefresh); } int32_t CPWL_EditCtrl::GetCaret() const { - if (m_pEdit) - return m_pEdit->GetCaret(); + 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); + if (m_pEdit) + m_pEdit->SetCaret(nPos); } int32_t CPWL_EditCtrl::GetTotalWords() const { - if (m_pEdit) - return m_pEdit->GetTotalWords(); + 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); + if (m_pEdit) + m_pEdit->SetScrollPos(point); } CPDF_Point CPWL_EditCtrl::GetScrollPos() const { - if (m_pEdit) - return m_pEdit->GetScrollPos(); + 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; - - if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator()) - { - pIterator->SetAt(m_pEdit->GetCaret()); - CPVT_Word word; - CPVT_Section section; - if (pIterator->GetWord(word)) - { - nFontIndex = word.nFontIndex; - } - else if (HasFlag(PES_RICH)) - { - if (pIterator->GetSection(section)) - { - nFontIndex = section.WordProps.nFontIndex; - } - } - } - - if (IFX_Edit_FontMap * pFontMap = GetFontMap()) - return pFontMap->GetPDFFont(nFontIndex); - else - return NULL; + int32_t nFontIndex = 0; + + if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator()) + { + pIterator->SetAt(m_pEdit->GetCaret()); + CPVT_Word word; + CPVT_Section section; + if (pIterator->GetWord(word)) + { + nFontIndex = word.nFontIndex; + } + else if (HasFlag(PES_RICH)) + { + if (pIterator->GetSection(section)) + { + nFontIndex = section.WordProps.nFontIndex; + } + } + } + + if (IFX_Edit_FontMap* pFontMap = GetFontMap()) + return pFontMap->GetPDFFont(nFontIndex); + + return NULL; } FX_FLOAT CPWL_EditCtrl::GetCaretFontSize() const { - FX_FLOAT fFontSize = GetFontSize(); - - if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator()) - { - pIterator->SetAt(m_pEdit->GetCaret()); - CPVT_Word word; - CPVT_Section section; - if (pIterator->GetWord(word)) - { - fFontSize = word.fFontSize; - } - else if (HasFlag(PES_RICH)) - { - if (pIterator->GetSection(section)) - { - fFontSize = section.WordProps.fFontSize; - } - } - } - - return fFontSize; + FX_FLOAT fFontSize = GetFontSize(); + + if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator()) + { + pIterator->SetAt(m_pEdit->GetCaret()); + CPVT_Word word; + CPVT_Section section; + if (pIterator->GetWord(word)) + { + fFontSize = word.fFontSize; + } + else if (HasFlag(PES_RICH)) + { + if (pIterator->GetSection(section)) + { + fFontSize = section.WordProps.fFontSize; + } + } + } + + return fFontSize; } void CPWL_EditCtrl::SetText(const FX_WCHAR* csText) { - m_pEdit->SetText(csText); + m_pEdit->SetText(csText); } void CPWL_EditCtrl::CopyText() @@ -584,79 +584,79 @@ void CPWL_EditCtrl::ShowVScrollBar(FX_BOOL bShow) void CPWL_EditCtrl::InsertText(const FX_WCHAR* csText) { - if (!IsReadOnly()) - m_pEdit->InsertText(csText); + if (!IsReadOnly()) + m_pEdit->InsertText(csText); } void CPWL_EditCtrl::InsertWord(FX_WORD word, int32_t nCharset) { - if (!IsReadOnly()) - m_pEdit->InsertWord(word, nCharset); + if (!IsReadOnly()) + m_pEdit->InsertWord(word, nCharset); } void CPWL_EditCtrl::InsertReturn() { - if (!IsReadOnly()) - m_pEdit->InsertReturn(); + if (!IsReadOnly()) + m_pEdit->InsertReturn(); } void CPWL_EditCtrl::Delete() { - if (!IsReadOnly()) - m_pEdit->Delete(); + if (!IsReadOnly()) + m_pEdit->Delete(); } void CPWL_EditCtrl::Backspace() { - if (!IsReadOnly()) - m_pEdit->Backspace(); + if (!IsReadOnly()) + m_pEdit->Backspace(); } -FX_BOOL CPWL_EditCtrl::CanUndo() const +FX_BOOL CPWL_EditCtrl::CanUndo() const { - return !IsReadOnly() && m_pEdit->CanUndo(); + return !IsReadOnly() && m_pEdit->CanUndo(); } -FX_BOOL CPWL_EditCtrl::CanRedo() const +FX_BOOL CPWL_EditCtrl::CanRedo() const { - return !IsReadOnly() && m_pEdit->CanRedo(); + return !IsReadOnly() && m_pEdit->CanRedo(); } void CPWL_EditCtrl::Redo() { - if (CanRedo()) - m_pEdit->Redo(); + if (CanRedo()) + m_pEdit->Redo(); } void CPWL_EditCtrl::Undo() { - if (CanUndo()) - m_pEdit->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) + FX_FLOAT fContentMin, FX_FLOAT fContentMax, + FX_FLOAT fSmallStep, FX_FLOAT fBigStep) { - PWL_SCROLL_INFO Info; + 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) @@ -666,12 +666,12 @@ void CPWL_EditCtrl::IOnSetScrollPosY(FX_FLOAT 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; + 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) @@ -680,13 +680,13 @@ void CPWL_EditCtrl::IOnCaretChange(const CPVT_SecProps & secProps, const CPVT_Wo void CPWL_EditCtrl::IOnContentChange(const CPDF_Rect& rcContent) { - if (IsValid()) - { - if (m_pEditNotify) - { - m_pEditNotify->OnContentChange(rcContent); - } - } + if (IsValid()) + { + if (m_pEditNotify) + { + m_pEditNotify->OnContentChange(rcContent); + } + } } void CPWL_EditCtrl::IOnInvalidateRect(CPDF_Rect * pRect) @@ -701,22 +701,22 @@ int32_t CPWL_EditCtrl::GetCharSet() const 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))); + 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)); + 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() +void CPWL_EditCtrl::SetReadyToInput() { - if (m_bMouseDown) - { - ReleaseCapture(); - m_bMouseDown = FALSE; - } + if (m_bMouseDown) + { + ReleaseCapture(); + m_bMouseDown = FALSE; + } } diff --git a/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp b/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp index 84b8c94363..50b321dfac 100644 --- a/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp @@ -8,15 +8,15 @@ #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) + m_pPDFDoc(NULL), + m_pSystemHandler(pSystemHandler) { - ASSERT(m_pSystemHandler != NULL); + ASSERT(m_pSystemHandler != NULL); } CPWL_FontMap::~CPWL_FontMap() @@ -29,177 +29,167 @@ CPWL_FontMap::~CPWL_FontMap() void CPWL_FontMap::SetSystemHandler(IFX_SystemHandler* pSystemHandler) { - m_pSystemHandler = pSystemHandler; + m_pSystemHandler = pSystemHandler; } CPDF_Document* CPWL_FontMap::GetDocument() { - if (!m_pPDFDoc) - { - if (CPDF_ModuleMgr::Get()) - { - m_pPDFDoc = new CPDF_Document; - m_pPDFDoc->CreateNewDoc(); - } - } + if (!m_pPDFDoc) + { + if (CPDF_ModuleMgr::Get()) + { + m_pPDFDoc = new CPDF_Document; + m_pPDFDoc->CreateNewDoc(); + } + } - return m_pPDFDoc; + 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; - } - } + if (nFontIndex >=0 && nFontIndex < m_aData.GetSize()) + { + if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) + { + return pData->pFont; + } + } - return NULL; + return NULL; } CFX_ByteString CPWL_FontMap::GetPDFFontAlias(int32_t nFontIndex) { - if (nFontIndex >=0 && nFontIndex < m_aData.GetSize()) - { - if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) - { - return pData->sFontName; - } - } + if (nFontIndex >=0 && nFontIndex < m_aData.GetSize()) + { + if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) + { + return pData->sFontName; + } + } - return ""; + return ""; } FX_BOOL CPWL_FontMap::KnowWord(int32_t nFontIndex, FX_WORD word) { - if (nFontIndex >=0 && nFontIndex < m_aData.GetSize()) - { - if (m_aData.GetAt(nFontIndex)) - { - return CharCodeFromUnicode(nFontIndex, word) >= 0; - } - } + if (nFontIndex >=0 && nFontIndex < m_aData.GetSize()) + { + if (m_aData.GetAt(nFontIndex)) + { + return CharCodeFromUnicode(nFontIndex, word) >= 0; + } + } - return FALSE; + return FALSE; } int32_t CPWL_FontMap::GetWordFontIndex(FX_WORD word, int32_t nCharset, int32_t nFontIndex) { - if (nFontIndex > 0) - { - if (KnowWord(nFontIndex, word)) - return nFontIndex; - } - else - { - if (const CPWL_FontMap_Data* pData = GetFontMapData(0)) - { - if (nCharset == DEFAULT_CHARSET || - pData->nCharset == SYMBOL_CHARSET || - nCharset == pData->nCharset) - { - if (KnowWord(0, word)) - { - return 0; - } - } - } - } - - int32_t nNewFontIndex = -1; - - 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; + if (nFontIndex > 0) + { + if (KnowWord(nFontIndex, word)) + return nFontIndex; + } + else + { + if (const CPWL_FontMap_Data* pData = GetFontMapData(0)) + { + if (nCharset == DEFAULT_CHARSET || + pData->nCharset == SYMBOL_CHARSET || + nCharset == pData->nCharset) + { + if (KnowWord(0, word)) + return 0; + } + } + } + + int32_t nNewFontIndex = GetFontIndex(GetNativeFontName(nCharset), nCharset, TRUE); + if (nNewFontIndex >= 0) + { + if (KnowWord(nNewFontIndex, word)) + return nNewFontIndex; + } + nNewFontIndex = GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE); + if (nNewFontIndex >= 0) + { + if (KnowWord(nNewFontIndex, word)) + return nNewFontIndex; + } + return -1; } int32_t CPWL_FontMap::CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word) { - if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) - { - if (pData->pFont) - { - if (pData->pFont->IsUnicodeCompatible()) - { - int nCharCode = pData->pFont->CharCodeFromUnicode(word); - pData->pFont->GlyphFromCharCode(nCharCode); - return nCharCode; - } - else - { - if (word < 0xFF) - return word; - } - } - } - - return -1; + if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) + { + if (pData->pFont) + { + if (pData->pFont->IsUnicodeCompatible()) + { + int nCharCode = pData->pFont->CharCodeFromUnicode(word); + pData->pFont->GlyphFromCharCode(nCharCode); + return nCharCode; + } + if (word < 0xFF) + return word; + } + } + return -1; } CFX_ByteString CPWL_FontMap::GetNativeFontName(int32_t nCharset) { - //searching native font is slow, so we must save time - for (int32_t i=0,sz=m_aNativeFont.GetSize(); inCharset == nCharset) - return pData->sFontName; - } - } + //searching native font is slow, so we must save time + for (int32_t i=0,sz=m_aNativeFont.GetSize(); inCharset == 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(); inCharset) - { - if (sFontName.IsEmpty() || pData->sFontName == sFontName) - return i; - } - } - } + for (int32_t i=0,sz=m_aData.GetSize(); inCharset) + { + if (sFontName.IsEmpty() || pData->sFontName == sFontName) + return i; + } + } + } - return -1; + return -1; } int32_t CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName, int32_t nCharset, FX_BOOL bFind) { - int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCharset); - if (nFontIndex >= 0) return nFontIndex; + int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCharset); + if (nFontIndex >= 0) + return nFontIndex; -// nFontIndex = FindFont("", nCharset); -// if (nFontIndex >= 0) return nFontIndex; + CFX_ByteString sAlias; + CPDF_Font* pFont = NULL; + if (bFind) + pFont = FindFontSameCharset(sAlias, nCharset); - CFX_ByteString sAlias; - CPDF_Font* pFont = NULL; - - if (bFind) - pFont = FindFontSameCharset(sAlias, nCharset); - - if (!pFont) - { - CFX_ByteString sTemp = sFontName; - pFont = AddFontToDocument(GetDocument(), sTemp, nCharset); - - /* - if (FindFont(sAlias)) - { - sAlias = EncodeFontAlias(sTemp, nCharset); - } - else - */ - { - sAlias = EncodeFontAlias(sTemp, nCharset); - } - } - - AddedFont(pFont, sAlias); - - return AddFontData(pFont, sAlias, nCharset); + 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; + int32_t nFind = -1; - for (int32_t i=0,sz=m_aData.GetSize(); inCharset == nCharset) - { - nFind = i; - break; - } - } - } + for (int32_t i=0,sz=m_aData.GetSize(); inCharset == 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; + 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; + 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) @@ -336,253 +311,250 @@ 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; - } - } + 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) { - CFX_ByteString sFontName; - - if (nCharset == DEFAULT_CHARSET) - nCharset = GetNativeCharset(); - sFontName = GetDefaultFontByCharset(nCharset); + if (nCharset == DEFAULT_CHARSET) + nCharset = GetNativeCharset(); - 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; + 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); - else - return AddSystemFont(pDoc, sFontName, nCharset); + if (IsStandardFont(sFontName)) + return AddStandardFont(pDoc, sFontName); + + return AddSystemFont(pDoc, sFontName, nCharset); } CPDF_Font* CPWL_FontMap::AddStandardFont(CPDF_Document* pDoc, CFX_ByteString& sFontName) { - if (!pDoc) return NULL; + if (!pDoc) return NULL; - CPDF_Font* pFont = NULL; + CPDF_Font* pFont = NULL; - if (sFontName == "ZapfDingbats") - pFont = pDoc->AddStandardFont(sFontName, NULL); - else - { - CPDF_FontEncoding fe(PDFFONT_ENCODING_WINANSI); - pFont = pDoc->AddStandardFont(sFontName, &fe); - } + if (sFontName == "ZapfDingbats") + pFont = pDoc->AddStandardFont(sFontName, NULL); + else + { + CPDF_FontEncoding fe(PDFFONT_ENCODING_WINANSI); + pFont = pDoc->AddStandardFont(sFontName, &fe); + } - return pFont; + return pFont; } CPDF_Font* CPWL_FontMap::AddSystemFont(CPDF_Document* pDoc, CFX_ByteString& sFontName, uint8_t nCharset) { - if (!pDoc) return NULL; + if (!pDoc) return NULL; - if (sFontName.IsEmpty()) sFontName = GetNativeFont(nCharset); - if (nCharset == DEFAULT_CHARSET) nCharset = GetNativeCharset(); + if (sFontName.IsEmpty()) sFontName = GetNativeFont(nCharset); + if (nCharset == DEFAULT_CHARSET) nCharset = GetNativeCharset(); - if (m_pSystemHandler) - return m_pSystemHandler->AddNativeTrueTypeFontToPDF(pDoc, sFontName, nCharset); + if (m_pSystemHandler) + return m_pSystemHandler->AddNativeTrueTypeFontToPDF(pDoc, sFontName, nCharset); - return NULL; + 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 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; + CFX_ByteString sRet = sFontName; + sRet.Remove(' '); + return sRet; } int32_t CPWL_FontMap::GetFontMapCount() const { - return m_aData.GetSize(); + 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); - } + if (nIndex >=0 && nIndex < m_aData.GetSize()) + { + return m_aData.GetAt(nIndex); + } - return NULL; + 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; + 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" }, + { 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" }, + { EASTEUROPE_CHARSET, "Arial" }, #else - { EASTEUROPE_CHARSET, "Tahoma" }, + { EASTEUROPE_CHARSET, "Tahoma" }, #endif - { ARABIC_CHARSET, "Arial" }, - { -1, NULL } + { 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; + int i = 0; + while (defaultTTFMap[i].charset != -1) { + if (nCharset == defaultTTFMap[i].charset) + return defaultTTFMap[i].fontname; ++i; - } - return ""; + } + 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; + 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_FontMap(pSystemHandler), + m_pAttachedDoc(pAttachedDoc) { } @@ -592,5 +564,5 @@ CPWL_DocFontMap::~CPWL_DocFontMap() CPDF_Document* CPWL_DocFontMap::GetDocument() { - return m_pAttachedDoc; + return m_pAttachedDoc; } diff --git a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp index cf6e6a1709..433b3c6846 100644 --- a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp @@ -21,17 +21,17 @@ static std::map& GetPWLTimeMap() } CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemHandler) : - m_nTimerID(0), - m_pAttached(pAttached), - m_pSystemHandler(pSystemHandler) + m_nTimerID(0), + m_pAttached(pAttached), + m_pSystemHandler(pSystemHandler) { - ASSERT(m_pAttached != NULL); - ASSERT(m_pSystemHandler != NULL); + ASSERT(m_pAttached != NULL); + ASSERT(m_pSystemHandler != NULL); } CPWL_Timer::~CPWL_Timer() { - KillPWLTimer(); + KillPWLTimer(); } int32_t CPWL_Timer::SetPWLTimer(int32_t nElapse) @@ -78,17 +78,17 @@ CPWL_TimerHandler::~CPWL_TimerHandler() void CPWL_TimerHandler::BeginTimer(int32_t nElapse) { - if (!m_pTimer) - m_pTimer = new CPWL_Timer(this, GetSystemHandler()); + 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(); + if (m_pTimer) + m_pTimer->KillPWLTimer(); } void CPWL_TimerHandler::TimerProc() @@ -99,181 +99,181 @@ void CPWL_TimerHandler::TimerProc() class CPWL_MsgControl { - friend class CPWL_Wnd; + 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(); iGetParentWindow(); - } - - pWnd->OnSetFocus(); - } - } - - void KillFocus() - { - if (m_aKeyboardPath.GetSize() > 0) - if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0)) - pWnd->OnKillFocus(); - - m_pMainKeyboardWnd = NULL; - m_aKeyboardPath.RemoveAll(); - } - - void SetCapture(CPWL_Wnd * pWnd) - { - m_aMousePath.RemoveAll(); - - if (pWnd) - { - m_pMainMouseWnd = pWnd; - - CPWL_Wnd * pParent = pWnd; - while (pParent) - { - m_aMousePath.Add(pParent); - pParent = pParent->GetParentWindow(); - } - } - } - - void ReleaseCapture() - { - m_pMainMouseWnd = NULL; - m_aMousePath.RemoveAll(); - } + 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(); iGetParentWindow(); + } + + pWnd->OnSetFocus(); + } + } + + void KillFocus() + { + if (m_aKeyboardPath.GetSize() > 0) + if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0)) + pWnd->OnKillFocus(); + + m_pMainKeyboardWnd = NULL; + m_aKeyboardPath.RemoveAll(); + } + + void SetCapture(CPWL_Wnd * pWnd) + { + m_aMousePath.RemoveAll(); + + if (pWnd) + { + m_pMainMouseWnd = pWnd; + + CPWL_Wnd * pParent = pWnd; + while (pParent) + { + m_aMousePath.Add(pParent); + pParent = pParent->GetParentWindow(); + } + } + } + + void ReleaseCapture() + { + m_pMainMouseWnd = NULL; + m_aMousePath.RemoveAll(); + } private: - CFX_ArrayTemplate m_aMousePath; - CFX_ArrayTemplate m_aKeyboardPath; - CPWL_Wnd* m_pCreatedWnd; - CPWL_Wnd* m_pMainMouseWnd; - CPWL_Wnd* m_pMainKeyboardWnd; + CFX_ArrayTemplate m_aMousePath; + CFX_ArrayTemplate 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) + 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); + ASSERT(m_bCreated == FALSE); } CFX_ByteString CPWL_Wnd::GetClassName() const { - return "CPWL_Wnd"; + return "CPWL_Wnd"; } void CPWL_Wnd::Create(const PWL_CREATEPARAM & cp) { - if (!IsValid()) - { - m_sPrivateParam = 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) @@ -290,86 +290,86 @@ void CPWL_Wnd::OnDestroy() void CPWL_Wnd::Destroy() { - KillFocus(); + KillFocus(); - OnDestroy(); + OnDestroy(); - if (m_bCreated) - { - for (int32_t i = m_aChildren.GetSize()-1; i >= 0; i --) - { - if (CPWL_Wnd * pChild = m_aChildren[i]) - { - pChild->Destroy(); - delete pChild; - pChild = NULL; - } - } + if (m_bCreated) + { + for (int32_t i = m_aChildren.GetSize()-1; i >= 0; i --) + { + if (CPWL_Wnd * pChild = m_aChildren[i]) + { + pChild->Destroy(); + delete pChild; + pChild = NULL; + } + } - if (m_sPrivateParam.pParentWnd) - m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD); - m_bCreated = FALSE; - } + if (m_sPrivateParam.pParentWnd) + m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD); + m_bCreated = FALSE; + } - DestroyMsgControl(); + DestroyMsgControl(); - FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM)); - m_aChildren.RemoveAll(); - m_pVScrollBar = NULL; + FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM)); + m_aChildren.RemoveAll(); + m_pVScrollBar = NULL; } void CPWL_Wnd::Move(const CPDF_Rect & rcNew, FX_BOOL bReset,FX_BOOL bRefresh) { - if (IsValid()) - { - CPDF_Rect rcOld = GetWindowRect(); + if (IsValid()) + { + CPDF_Rect rcOld = GetWindowRect(); - m_rcWindow = rcNew; - m_rcWindow.Normalize(); + m_rcWindow = rcNew; + m_rcWindow.Normalize(); - if (rcOld.left != rcNew.left || rcOld.right != rcNew.right || - rcOld.top != rcNew.top || rcOld.bottom != rcNew.bottom) - { - if (bReset) - { - RePosChildWnd(); - } + if (rcOld.left != rcNew.left || rcOld.right != rcNew.right || + rcOld.top != rcNew.top || rcOld.bottom != rcNew.bottom) + { + if (bReset) + { + RePosChildWnd(); + } - } - if (bRefresh) - { - InvalidateRectMove(rcOld,rcNew); - } + } + if (bRefresh) + { + InvalidateRectMove(rcOld,rcNew); + } - m_sPrivateParam.rcRectWnd = m_rcWindow; - } + m_sPrivateParam.rcRectWnd = m_rcWindow; + } } void CPWL_Wnd::InvalidateRectMove(const CPDF_Rect & rcOld, const CPDF_Rect & rcNew) { - CPDF_Rect rcUnion = rcOld; - rcUnion.Union(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(); - } + if (IsValid()) + { + CFX_ByteTextBuf sTextBuf; + GetAppearanceStream(sTextBuf); + sAppStream += sTextBuf.GetByteString(); + } } void CPWL_Wnd::GetAppearanceStream(CFX_ByteTextBuf & sAppStream) { - if (IsValid() && IsVisible()) - { - GetThisAppearanceStream(sAppStream); - GetChildAppearanceStream(sAppStream); - } + if (IsValid() && IsVisible()) + { + GetThisAppearanceStream(sAppStream); + GetChildAppearanceStream(sAppStream); + } } //if don't set,Get default apperance stream @@ -399,158 +399,158 @@ void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream) void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf & sAppStream) { - for (int32_t i=0,sz=m_aChildren.GetSize(); iGetAppearanceStream(sAppStream); - } - } + for (int32_t i=0,sz=m_aChildren.GetSize(); iGetAppearanceStream(sAppStream); + } + } } void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device) { - if (IsValid() && IsVisible()) - { - DrawThisAppearance(pDevice,pUser2Device); - DrawChildAppearance(pDevice,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()); - } - - if (HasFlag(PWS_BORDER)) - CPWL_Utils::DrawBorder(pDevice, - pUser2Device, - rectWnd, - (FX_FLOAT)GetBorderWidth(), - GetBorderColor(), - GetBorderLeftTopColor(GetBorderStyle()), - GetBorderRightBottomColor(GetBorderStyle()), - GetBorderStyle(), - GetBorderDash(), - GetTransparency()); - } + 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::DrawChildAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device) { - for (int32_t i=0,sz=m_aChildren.GetSize(); iGetChildMatrix(); - if (mt.IsIdentity()) - { - pChild->DrawAppearance(pDevice,pUser2Device); - } - else - { - mt.Concat(*pUser2Device); - pChild->DrawAppearance(pDevice,&mt); - } - } - } + for (int32_t i=0,sz=m_aChildren.GetSize(); iGetChildMatrix(); + if (mt.IsIdentity()) + { + pChild->DrawAppearance(pDevice,pUser2Device); + } + else + { + mt.Concat(*pUser2Device); + pChild->DrawAppearance(pDevice,&mt); + } + } + } } void CPWL_Wnd::InvalidateRect(CPDF_Rect* pRect) { - if (IsValid()) - { - CPDF_Rect rcRefresh = pRect ? *pRect : GetWindowRect(); - - if (!HasFlag(PWS_NOREFRESHCLIP)) - { - CPDF_Rect rcClip = GetClipRect(); - if (!rcClip.IsEmpty()) - { - rcRefresh.Intersect(rcClip); - } - } - - FX_RECT rcWin = PWLtoWnd(rcRefresh); - rcWin.left -= PWL_INVALIDATE_INFLATE; - rcWin.top -= PWL_INVALIDATE_INFLATE; - rcWin.right += PWL_INVALIDATE_INFLATE; - rcWin.bottom += PWL_INVALIDATE_INFLATE; - - if (IFX_SystemHandler* pSH = GetSystemHandler()) - { - if (FX_HWND hWnd = GetAttachedHWnd()) - { - pSH->InvalidateRect(hWnd, rcWin); - } - } - } + if (IsValid()) + { + CPDF_Rect rcRefresh = pRect ? *pRect : GetWindowRect(); + + if (!HasFlag(PWS_NOREFRESHCLIP)) + { + CPDF_Rect rcClip = GetClipRect(); + if (!rcClip.IsEmpty()) + { + rcRefresh.Intersect(rcClip); + } + } + + FX_RECT rcWin = PWLtoWnd(rcRefresh); + rcWin.left -= PWL_INVALIDATE_INFLATE; + rcWin.top -= PWL_INVALIDATE_INFLATE; + rcWin.right += PWL_INVALIDATE_INFLATE; + rcWin.bottom += PWL_INVALIDATE_INFLATE; + + if (IFX_SystemHandler* pSH = GetSystemHandler()) + { + if (FX_HWND hWnd = GetAttachedHWnd()) + { + pSH->InvalidateRect(hWnd, rcWin); + } + } + } } #define PWL_IMPLEMENT_KEY_METHOD(key_method_name)\ FX_BOOL CPWL_Wnd::key_method_name(FX_WORD nChar, FX_DWORD nFlag)\ {\ - if (IsValid() && IsVisible() && IsEnabled())\ - {\ - if (IsWndCaptureKeyboard(this))\ - {\ - for (int32_t i=0,sz=m_aChildren.GetSize(); ikey_method_name(nChar,nFlag);\ - }\ - }\ - }\ - }\ - }\ - return FALSE;\ + if (IsValid() && IsVisible() && IsEnabled())\ + {\ + if (IsWndCaptureKeyboard(this))\ + {\ + for (int32_t i=0,sz=m_aChildren.GetSize(); ikey_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(); imouse_method_name(pChild->ParentToChild(point),nFlag);\ - }\ - }\ - }\ - SetCursor();\ - }\ - else\ - {\ - for (int32_t i=0,sz=m_aChildren.GetSize(); iWndHitTest(pChild->ParentToChild(point)))\ - {\ - return pChild->mouse_method_name(pChild->ParentToChild(point),nFlag);\ - }\ - }\ - }\ - if (WndHitTest(point))\ - SetCursor();\ - }\ - }\ - return FALSE;\ + if (IsValid() && IsVisible() && IsEnabled())\ + {\ + if (IsWndCaptureMouse(this))\ + {\ + for (int32_t i=0,sz=m_aChildren.GetSize(); imouse_method_name(pChild->ParentToChild(point),nFlag);\ + }\ + }\ + }\ + SetCursor();\ + }\ + else\ + {\ + for (int32_t i=0,sz=m_aChildren.GetSize(); iWndHitTest(pChild->ParentToChild(point)))\ + {\ + return pChild->mouse_method_name(pChild->ParentToChild(point),nFlag);\ + }\ + }\ + }\ + if (WndHitTest(point))\ + SetCursor();\ + }\ + }\ + return FALSE;\ } PWL_IMPLEMENT_KEY_METHOD(OnKeyDown) @@ -567,300 +567,294 @@ 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(); iOnMouseWheel(zDelta,pChild->ParentToChild(point), nFlag); - } - } - } - } - } - return FALSE; +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(); iOnMouseWheel(zDelta,pChild->ParentToChild(point), nFlag); + } + } + } + } + } + return FALSE; } void CPWL_Wnd::AddChild(CPWL_Wnd * pWnd) { - m_aChildren.Add(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; - } - } - } + for (int32_t i = m_aChildren.GetSize()-1; i >= 0; i --) + { + if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) + { + if (pChild == pWnd) + { + m_aChildren.RemoveAt(i); + break; + } + } + } } void CPWL_Wnd::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam) { - switch (msg) - { - case PNM_ADDCHILD: - AddChild(pWnd); - break; - case PNM_REMOVECHILD: - RemoveChild(pWnd); - break; - default: - break; - } + switch (msg) + { + case PNM_ADDCHILD: + AddChild(pWnd); + break; + case PNM_REMOVECHILD: + RemoveChild(pWnd); + break; + default: + break; + } } FX_BOOL CPWL_Wnd::IsValid() const { - return m_bCreated; + return m_bCreated; } PWL_CREATEPARAM CPWL_Wnd::GetCreationParam() const { - return m_sPrivateParam; + return m_sPrivateParam; } CPWL_Wnd* CPWL_Wnd::GetParentWindow() const { - return m_sPrivateParam.pParentWnd; + return m_sPrivateParam.pParentWnd; } CPDF_Rect CPWL_Wnd::GetOriginWindowRect() const { - return m_sPrivateParam.rcRectWnd; + return m_sPrivateParam.rcRectWnd; } CPDF_Rect CPWL_Wnd::GetWindowRect() const { - return m_rcWindow; + 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 rcWindow = GetWindowRect(); + CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth())); + if (CPWL_ScrollBar* pVSB = GetVScrollBar()) + rcClient.right -= pVSB->GetScrollBarWidth(); - rcClient.Normalize(); - - if (rcWindow.Contains(rcClient)) - return rcClient; - else - return 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_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()); + return CPWL_Utils::GetCenterSquare(GetClientRect()); } CPDF_Rect CPWL_Wnd::GetWindowCenterSquare() const { - return CPWL_Utils::GetCenterSquare(CPWL_Utils::DeflateRect(GetWindowRect(),0.1f)); + 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; + return (m_sPrivateParam.dwFlags & dwFlags) != 0; } void CPWL_Wnd::RemoveFlag(FX_DWORD dwFlags) { - m_sPrivateParam.dwFlags &= ~dwFlags; + m_sPrivateParam.dwFlags &= ~dwFlags; } void CPWL_Wnd::AddFlag(FX_DWORD dwFlags) { - m_sPrivateParam.dwFlags |= dwFlags; + m_sPrivateParam.dwFlags |= dwFlags; } CPWL_Color CPWL_Wnd::GetBackgroundColor() const { - return m_sPrivateParam.sBackgroundColor; + return m_sPrivateParam.sBackgroundColor; } void CPWL_Wnd::SetBackgroundColor(const CPWL_Color & color) { - m_sPrivateParam.sBackgroundColor = color; + m_sPrivateParam.sBackgroundColor = color; } void CPWL_Wnd::SetTextColor(const CPWL_Color & color) { - m_sPrivateParam.sTextColor = color; + m_sPrivateParam.sTextColor = color; } void CPWL_Wnd::SetTextStrokeColor(const CPWL_Color & color) { - m_sPrivateParam.sTextStrokeColor = color; + m_sPrivateParam.sTextStrokeColor = color; } CPWL_Color CPWL_Wnd::GetTextColor() const { - return m_sPrivateParam.sTextColor; + return m_sPrivateParam.sTextColor; } CPWL_Color CPWL_Wnd::GetTextStrokeColor() const { - return m_sPrivateParam.sTextStrokeColor; + return m_sPrivateParam.sTextStrokeColor; } int32_t CPWL_Wnd::GetBorderStyle() const { - return m_sPrivateParam.nBorderStyle; + return m_sPrivateParam.nBorderStyle; } void CPWL_Wnd::SetBorderStyle(int32_t nBorderStyle) { - if (HasFlag(PWS_BORDER)) - m_sPrivateParam.nBorderStyle = nBorderStyle; + if (HasFlag(PWS_BORDER)) + m_sPrivateParam.nBorderStyle = nBorderStyle; } int32_t CPWL_Wnd::GetBorderWidth() const { - if (HasFlag(PWS_BORDER)) - return m_sPrivateParam.dwBorderWidth; + 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; + /* + 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; + if (HasFlag(PWS_BORDER)) + m_sPrivateParam.dwBorderWidth = nBorderWidth; } CPWL_Color CPWL_Wnd::GetBorderColor() const { - if (HasFlag(PWS_BORDER)) - return m_sPrivateParam.sBorderColor; + 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; + if (HasFlag(PWS_BORDER)) + m_sPrivateParam.sBorderColor = color; } CPWL_Dash CPWL_Wnd::GetBorderDash() const { - return m_sPrivateParam.sDash; + return m_sPrivateParam.sDash; } void* CPWL_Wnd::GetAttachedData() const { - return m_sPrivateParam.pAttachedData; + return m_sPrivateParam.pAttachedData; } void CPWL_Wnd::SetBorderDash(const CPWL_Dash & sDash) { - if (HasFlag(PWS_BORDER)) - m_sPrivateParam.sDash = sDash; + if (HasFlag(PWS_BORDER)) + m_sPrivateParam.sDash = sDash; } CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const { - if (HasFlag(PWS_VSCROLL)) - return m_pVScrollBar; + if (HasFlag(PWS_VSCROLL)) + return m_pVScrollBar; - return NULL; + return NULL; } void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM & cp) { - CreateVScrollBar(cp); + CreateVScrollBar(cp); } void CPWL_Wnd::CreateVScrollBar(const PWL_CREATEPARAM & cp) { - if (!m_pVScrollBar && HasFlag(PWS_VSCROLL)) - { - PWL_CREATEPARAM scp = 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); + if (CPWL_MsgControl * pMsgCtrl = GetMsgControl()) + pMsgCtrl->SetCapture(this); } void CPWL_Wnd::ReleaseCapture() { - for (int32_t i=0,sz=m_aChildren.GetSize(); iReleaseCapture(); + for (int32_t i=0,sz=m_aChildren.GetSize(); iReleaseCapture(); - 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); - } + 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(); - } + if (CPWL_MsgControl * pMsgCtrl = GetMsgControl()) + { + if (pMsgCtrl->IsWndCaptureKeyboard(this)) + pMsgCtrl->KillFocus(); + } } void CPWL_Wnd::OnSetFocus() @@ -871,73 +865,73 @@ void CPWL_Wnd::OnKillFocus() { } -FX_BOOL CPWL_Wnd::WndHitTest(const CPDF_Point & point) const +FX_BOOL CPWL_Wnd::WndHitTest(const CPDF_Point & point) const { - return IsValid() && IsVisible() && GetWindowRect().Contains(point.x,point.y); + 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); + return IsValid() && IsVisible() && GetClientRect().Contains(point.x,point.y); } -const CPWL_Wnd * CPWL_Wnd::GetRootWnd() const +const CPWL_Wnd* CPWL_Wnd::GetRootWnd() const { - if (m_sPrivateParam.pParentWnd) - return m_sPrivateParam.pParentWnd->GetRootWnd(); - else - return this; + if (m_sPrivateParam.pParentWnd) + return m_sPrivateParam.pParentWnd->GetRootWnd(); + + return this; } void CPWL_Wnd::SetVisible(FX_BOOL bVisible) { - if (IsValid()) - { - for (int32_t i=0,sz=m_aChildren.GetSize(); iSetVisible(bVisible); - } - } - - if (bVisible != m_bVisible) - { - m_bVisible = bVisible; - RePosChildWnd(); - InvalidateRect(); - } - } + if (IsValid()) + { + for (int32_t i=0,sz=m_aChildren.GetSize(); iSetVisible(bVisible); + } + } + + if (bVisible != m_bVisible) + { + m_bVisible = bVisible; + RePosChildWnd(); + InvalidateRect(); + } + } } void CPWL_Wnd::SetClipRect(const CPDF_Rect & rect) { - m_rcClip = rect; - m_rcClip.Normalize(); + m_rcClip = rect; + m_rcClip.Normalize(); } CPDF_Rect CPWL_Wnd::GetClipRect() const { - return m_rcClip; + return m_rcClip; } -FX_BOOL CPWL_Wnd::IsReadOnly() const +FX_BOOL CPWL_Wnd::IsReadOnly() const { - return HasFlag(PWS_READONLY); + return HasFlag(PWS_READONLY); } void CPWL_Wnd::RePosChildWnd() { - CPDF_Rect rcContent = CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth())); + 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) @@ -946,317 +940,307 @@ 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); - } - } + 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); + 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; + if (CPWL_MsgControl* pMsgControl = GetMsgControl()) + if (pMsgControl->IsWndCreated(this)) + delete pMsgControl; } CPWL_MsgControl* CPWL_Wnd::GetMsgControl() const { - return m_sPrivateParam.pMsgControl; + return m_sPrivateParam.pMsgControl; } FX_BOOL CPWL_Wnd::IsCaptureMouse() const { - return IsWndCaptureMouse(this); + return IsWndCaptureMouse(this); } FX_BOOL CPWL_Wnd::IsWndCaptureMouse(const CPWL_Wnd * pWnd) const { - if (CPWL_MsgControl * pCtrl = GetMsgControl()) - return pCtrl->IsWndCaptureMouse(pWnd); + 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); + 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); + 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); + return CPWL_Utils::InflateRect(GetWindowRect(),1); } FX_FLOAT CPWL_Wnd::GetFontSize() const { - return m_sPrivateParam.fFontSize; + return m_sPrivateParam.fFontSize; } void CPWL_Wnd::SetFontSize(FX_FLOAT fFontSize) { - m_sPrivateParam.fFontSize = fFontSize; + m_sPrivateParam.fFontSize = fFontSize; } IFX_SystemHandler* CPWL_Wnd::GetSystemHandler() const { - return m_sPrivateParam.pSystemHandler; + return m_sPrivateParam.pSystemHandler; } IPWL_FocusHandler* CPWL_Wnd::GetFocusHandler() const { - return m_sPrivateParam.pFocusHandler; + return m_sPrivateParam.pFocusHandler; } IPWL_Provider* CPWL_Wnd::GetProvider() const { - return m_sPrivateParam.pProvider; + return m_sPrivateParam.pProvider; } IFX_Edit_FontMap* CPWL_Wnd::GetFontMap() const { - return m_sPrivateParam.pFontMap; + return m_sPrivateParam.pFontMap; } CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(int32_t nBorderStyle) const { - CPWL_Color color; - - switch (nBorderStyle) - { - case PBS_SOLID: - break; - case PBS_DASH: - break; - case PBS_BEVELED: - color = CPWL_Color(COLORTYPE_GRAY,1); - break; - case PBS_INSET: - color = CPWL_Color(COLORTYPE_GRAY,0.5f); - break; - case PBS_UNDERLINED: - break; - } + CPWL_Color color; + + switch (nBorderStyle) + { + case PBS_SOLID: + break; + case PBS_DASH: + break; + case PBS_BEVELED: + color = CPWL_Color(COLORTYPE_GRAY,1); + break; + case PBS_INSET: + color = CPWL_Color(COLORTYPE_GRAY,0.5f); + break; + case PBS_UNDERLINED: + break; + } - return color; + 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; - } + 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; + return color; } /* ----------------------------------------------------------------- */ int32_t CPWL_Wnd::GetTransparency() { - return m_sPrivateParam.nTransparency; + return m_sPrivateParam.nTransparency; } void CPWL_Wnd::SetTransparency(int32_t nTransparency) { - for (int32_t i=0,sz=m_aChildren.GetSize(); iSetTransparency(nTransparency); - } - } + for (int32_t i=0,sz=m_aChildren.GetSize(); iSetTransparency(nTransparency); + } + } - m_sPrivateParam.nTransparency = nTransparency; + m_sPrivateParam.nTransparency = nTransparency; } -CPDF_Matrix CPWL_Wnd::GetWindowMatrix() const +CPDF_Matrix CPWL_Wnd::GetWindowMatrix() const { - CPDF_Matrix mt = GetChildToRoot(); + CPDF_Matrix mt = GetChildToRoot(); - if (IPWL_Provider* pProvider = GetProvider()) - { - mt.Concat(pProvider->GetWindowMatrix(GetAttachedData())); - return mt; - } + if (IPWL_Provider* pProvider = GetProvider()) + { + mt.Concat(pProvider->GetWindowMatrix(GetAttachedData())); + return mt; + } - 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); + 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)); + 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; + return m_sPrivateParam.hAttachedWnd; } CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const { - CPDF_Matrix mt = GetChildMatrix(); - if (mt.IsIdentity()) - return point; - else - { - CPDF_Point pt = point; - mt.Transform(pt.x,pt.y); - return pt; - } + CPDF_Matrix mt = GetChildMatrix(); + if (mt.IsIdentity()) + return point; + + CPDF_Point pt = point; + mt.Transform(pt.x,pt.y); + return pt; } CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const { - CPDF_Matrix mt = GetChildMatrix(); - if (mt.IsIdentity()) - return rect; - else - { - CPDF_Rect rc = rect; - mt.TransformRect(rc); - return rc; - } + CPDF_Matrix mt = GetChildMatrix(); + if (mt.IsIdentity()) + return rect; + + CPDF_Rect rc = rect; + mt.TransformRect(rc); + return rc; } CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const { - CPDF_Matrix mt = GetChildMatrix(); - if (mt.IsIdentity()) - return point; - else - { - mt.SetReverse(mt); - CPDF_Point pt = point; - mt.Transform(pt.x,pt.y); - return pt; - } + CPDF_Matrix mt = GetChildMatrix(); + if (mt.IsIdentity()) + return point; + + mt.SetReverse(mt); + CPDF_Point pt = point; + mt.Transform(pt.x,pt.y); + return pt; } CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const { - CPDF_Matrix mt = GetChildMatrix(); - if (mt.IsIdentity()) - return rect; - else - { - mt.SetReverse(mt); - CPDF_Rect rc = rect; - mt.TransformRect(rc); - return rc; - } + CPDF_Matrix mt = GetChildMatrix(); + if (mt.IsIdentity()) + return rect; + + mt.SetReverse(mt); + CPDF_Rect rc = rect; + mt.TransformRect(rc); + return rc; } CPDF_Matrix CPWL_Wnd::GetChildToRoot() const { - CPDF_Matrix mt(1,0,0,1,0,0); - - if (HasFlag(PWS_CHILD)) - { - const CPWL_Wnd* pParent = this; - while (pParent) - { - mt.Concat(pParent->GetChildMatrix()); - pParent = pParent->GetParentWindow(); - } - } - - return mt; + CPDF_Matrix mt(1, 0, 0, 1, 0, 0); + if (HasFlag(PWS_CHILD)) + { + const CPWL_Wnd* pParent = this; + while (pParent) + { + mt.Concat(pParent->GetChildMatrix()); + pParent = pParent->GetParentWindow(); + } + } + return mt; } CPDF_Matrix CPWL_Wnd::GetChildMatrix() const { - if (HasFlag(PWS_CHILD)) - return m_sPrivateParam.mtChild; + 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; + m_sPrivateParam.mtChild = mt; } -const CPWL_Wnd* CPWL_Wnd::GetFocused() const +const CPWL_Wnd* CPWL_Wnd::GetFocused() const { - if (CPWL_MsgControl * pMsgCtrl = GetMsgControl()) - { - return pMsgCtrl->m_pMainKeyboardWnd; - } + 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(); iEnableWindow(bEnable); - } - } + if (m_bEnabled != bEnable) + { + for (int32_t i=0,sz=m_aChildren.GetSize(); iEnableWindow(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; + return m_bEnabled; } void CPWL_Wnd::OnEnabled() @@ -1269,41 +1253,40 @@ void CPWL_Wnd::OnDisabled() FX_BOOL CPWL_Wnd::IsCTRLpressed(FX_DWORD nFlag) const { - if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) - { - return pSystemHandler->IsCTRLKeyDown(nFlag); - } + if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) + { + return pSystemHandler->IsCTRLKeyDown(nFlag); + } - return FALSE; + return FALSE; } -FX_BOOL CPWL_Wnd::IsSHIFTpressed(FX_DWORD nFlag) const +FX_BOOL CPWL_Wnd::IsSHIFTpressed(FX_DWORD nFlag) const { - if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) - { - return pSystemHandler->IsSHIFTKeyDown(nFlag); - } + if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) + { + return pSystemHandler->IsSHIFTKeyDown(nFlag); + } - return FALSE; + return FALSE; } -FX_BOOL CPWL_Wnd::IsALTpressed(FX_DWORD nFlag) const +FX_BOOL CPWL_Wnd::IsALTpressed(FX_DWORD nFlag) const { - if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) - { - return pSystemHandler->IsALTKeyDown(nFlag); - } + if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) + { + return pSystemHandler->IsALTKeyDown(nFlag); + } - return FALSE; + return FALSE; } -FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const +FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const { - if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) - { - return pSystemHandler->IsINSERTKeyDown(nFlag); - } + if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) + { + return pSystemHandler->IsINSERTKeyDown(nFlag); + } - return FALSE; + return FALSE; } - -- cgit v1.2.3