diff options
author | dsinclair <dsinclair@chromium.org> | 2016-11-16 13:54:01 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-16 13:54:01 -0800 |
commit | 058d2d6b7851b77a371bb4d37d5da1148794397a (patch) | |
tree | ce0d9ba4397c1314dec15334dff6ac5dac261bf4 /xfa/fwl/core | |
parent | 8a3aa459fc5284f51bcd7e98e95bf6214f47bb67 (diff) | |
download | pdfium-058d2d6b7851b77a371bb4d37d5da1148794397a.tar.xz |
Continue formatting fwl/core
Review-Url: https://codereview.chromium.org/2510793003
Diffstat (limited to 'xfa/fwl/core')
-rw-r--r-- | xfa/fwl/core/fwl_widgetdef.h | 1 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_edit.cpp | 415 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_form.cpp | 173 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_formproxy.cpp | 3 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_listbox.cpp | 466 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_monthcalendar.cpp | 254 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_monthcalendar.h | 6 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_picturebox.cpp | 34 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_picturebox.h | 4 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_pushbutton.cpp | 95 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_scrollbar.cpp | 223 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_spinbutton.cpp | 13 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_tooltip.cpp | 81 | ||||
-rw-r--r-- | xfa/fwl/core/ifwl_widget.cpp | 106 |
14 files changed, 917 insertions, 957 deletions
diff --git a/xfa/fwl/core/fwl_widgetdef.h b/xfa/fwl/core/fwl_widgetdef.h index f0ef5f5d18..c01f5404ae 100644 --- a/xfa/fwl/core/fwl_widgetdef.h +++ b/xfa/fwl/core/fwl_widgetdef.h @@ -56,6 +56,7 @@ #define FWL_VKEY_MButton 0x04 #define FWL_VKEY_Back 0x08 #define FWL_VKEY_Tab 0x09 +#define FWL_VKEY_NewLine 0x0A #define FWL_VKEY_Clear 0x0C #define FWL_VKEY_Return 0x0D #define FWL_VKEY_Shift 0x10 diff --git a/xfa/fwl/core/ifwl_edit.cpp b/xfa/fwl/core/ifwl_edit.cpp index 3e864baa28..65a54dc57a 100644 --- a/xfa/fwl/core/ifwl_edit.cpp +++ b/xfa/fwl/core/ifwl_edit.cpp @@ -45,9 +45,8 @@ void AddSquigglyPath(CFX_Path* pPathData, FX_FLOAT fStep) { pPathData->MoveTo(fStartX, fY); int i = 1; - for (FX_FLOAT fx = fStartX + fStep; fx < fEndX; fx += fStep, ++i) { + for (FX_FLOAT fx = fStartX + fStep; fx < fEndX; fx += fStep, ++i) pPathData->LineTo(fx, fY + (i & 1) * fStep); - } } } // namespace @@ -77,7 +76,6 @@ IFWL_Edit::IFWL_Edit(const IFWL_App* app, IFWL_Edit::~IFWL_Edit() { if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) ShowCaret(false); - ClearRecord(); } @@ -86,20 +84,7 @@ FWL_Type IFWL_Edit::GetClassID() const { } void IFWL_Edit::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (bAutoSize) { - rect.Set(0, 0, 0, 0); - - int32_t iTextLen = m_EdtEngine.GetTextLength(); - if (iTextLen > 0) { - CFX_WideString wsText; - m_EdtEngine.GetText(wsText, 0); - CFX_SizeF sz = CalcTextSize( - wsText, m_pProperties->m_pThemeProvider, - !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine)); - rect.Set(0, 0, sz.x, sz.y); - } - IFWL_Widget::GetWidgetRect(rect, true); - } else { + if (!bAutoSize) { rect = m_pProperties->m_rtWidget; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { if (IsShowScrollBar(true)) { @@ -115,7 +100,21 @@ void IFWL_Edit::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { rect.height += kEditMargin; } } + return; + } + + rect.Set(0, 0, 0, 0); + + int32_t iTextLen = m_EdtEngine.GetTextLength(); + if (iTextLen > 0) { + CFX_WideString wsText; + m_EdtEngine.GetText(wsText, 0); + CFX_SizeF sz = CalcTextSize( + wsText, m_pProperties->m_pThemeProvider, + !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine)); + rect.Set(0, 0, sz.x, sz.y); } + IFWL_Widget::GetWidgetRect(rect, true); } void IFWL_Edit::SetStates(uint32_t dwStates, bool bSet) { @@ -127,16 +126,15 @@ void IFWL_Edit::SetStates(uint32_t dwStates, bool bSet) { } void IFWL_Edit::Update() { - if (IsLocked()) { + if (IsLocked()) return; - } - if (!m_pProperties->m_pThemeProvider) { + if (!m_pProperties->m_pThemeProvider) m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } + Layout(); - if (m_rtClient.IsEmpty()) { + if (m_rtClient.IsEmpty()) return; - } + UpdateEditEngine(); UpdateVAlignment(); UpdateScroll(); @@ -176,9 +174,10 @@ void IFWL_Edit::AddSpellCheckObj(CFX_Path& PathData, CFX_RectFArray rectArray; CFX_RectF rectText; const FDE_TXTEDTPARAMS* txtEdtParams = m_EdtEngine.GetEditParams(); - FX_FLOAT fAsent = (FX_FLOAT)txtEdtParams->pFont->GetAscent() * + FX_FLOAT fAsent = static_cast<FX_FLOAT>(txtEdtParams->pFont->GetAscent()) * txtEdtParams->fFontSize / 1000; pPage->CalcRangeRectArray(nStart, nCount, rectArray); + for (int i = 0; i < rectArray.GetSize(); i++) { rectText = rectArray.GetAt(i); fY = rectText.top + fAsent + fOffSetY; @@ -188,45 +187,49 @@ void IFWL_Edit::AddSpellCheckObj(CFX_Path& PathData, AddSquigglyPath(&PathData, fStartX, fEndX, fY, fStep); } } + void IFWL_Edit::DrawSpellCheck(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { pGraphics->SaveGraphState(); - if (pMatrix) { + if (pMatrix) pGraphics->ConcatMatrix(const_cast<CFX_Matrix*>(pMatrix)); - } - FX_ARGB cr = 0xFFFF0000; - CFX_Color crLine(cr); + + CFX_Color crLine(0xFFFF0000); CFWL_EvtEdtCheckWord checkWordEvent; checkWordEvent.m_pSrcTarget = this; + CFX_ByteString sLatinWord; CFX_Path pathSpell; pathSpell.Create(); + int32_t nStart = 0; FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; + CFX_WideString wsSpell; GetText(wsSpell); int32_t nContentLen = wsSpell.GetLength(); for (int i = 0; i < nContentLen; i++) { if (FX_EDIT_ISLATINWORD(wsSpell[i])) { - if (sLatinWord.IsEmpty()) { + if (sLatinWord.IsEmpty()) nStart = i; - } sLatinWord += (FX_CHAR)wsSpell[i]; - } else { - checkWordEvent.bsWord = sLatinWord; - checkWordEvent.bCheckWord = true; - DispatchEvent(&checkWordEvent); - if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) { - AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX, - fOffSetY); - } - sLatinWord.clear(); + continue; + } + checkWordEvent.bsWord = sLatinWord; + checkWordEvent.bCheckWord = true; + DispatchEvent(&checkWordEvent); + if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) { + AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX, + fOffSetY); } + sLatinWord.clear(); } + checkWordEvent.bsWord = sLatinWord; checkWordEvent.bCheckWord = true; DispatchEvent(&checkWordEvent); + if (!sLatinWord.IsEmpty() && !checkWordEvent.bCheckWord) { AddSpellCheckObj(pathSpell, nStart, sLatinWord.GetLength(), fOffSetX, fOffSetY); @@ -246,44 +249,39 @@ void IFWL_Edit::DrawSpellCheck(CFX_Graphics* pGraphics, } pGraphics->RestoreGraphState(); } + void IFWL_Edit::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!pGraphics) return; if (!m_pProperties->m_pThemeProvider) return; - if (m_rtClient.IsEmpty()) { + if (m_rtClient.IsEmpty()) return; - } + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - if (!m_pWidgetMgr->IsFormDisabled()) { + if (!m_pWidgetMgr->IsFormDisabled()) DrawTextBk(pGraphics, pTheme, pMatrix); - } - DrawContent(pGraphics, pTheme, pMatrix); if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) && !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly)) { DrawSpellCheck(pGraphics, pMatrix); } - if (HasBorder()) { + if (HasBorder()) DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); - } - if (HasEdge()) { + if (HasEdge()) DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); - } } + void IFWL_Edit::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { if (!pThemeProvider) return; - if (m_pHorzScrollBar) { + if (m_pHorzScrollBar) m_pHorzScrollBar->SetThemeProvider(pThemeProvider); - } - if (m_pVertScrollBar) { + if (m_pVertScrollBar) m_pVertScrollBar->SetThemeProvider(pThemeProvider); - } - if (m_pCaret) { + if (m_pCaret) m_pCaret->SetThemeProvider(pThemeProvider); - } m_pProperties->m_pThemeProvider = pThemeProvider; } @@ -437,9 +435,8 @@ void IFWL_Edit::On_CaretChanged(CFDE_TxtEdtEngine* pEdit, } } if (bRepaintContent || bRepaintScroll) { - if (bRepaintContent) { + if (bRepaintContent) rtInvalid.Union(m_rtEngine); - } Repaint(&rtInvalid); } } @@ -482,6 +479,7 @@ void IFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit, bNeedUpdate = (bHSelfAdaption && !evt.bHSelfAdaption) || (bVSelfAdaption && !evt.bVSelfAdaption); } + FX_FLOAT fContentWidth1 = fContentWidth; FX_FLOAT fContentHeight1 = fContentHeight; if (bNeedUpdate) { @@ -499,6 +497,7 @@ void IFWL_Edit::On_TextChanged(CFDE_TxtEdtEngine* pEdit, rtTemp.height = std::max(m_pProperties->m_rtWidget.height, fContentHeight1); m_pProperties->m_rtWidget.height = fContentHeight1; } + CFWL_EvtEdtTextChanged event; event.m_pSrcTarget = this; event.nChangeType = ChangeInfo.nChangeType; @@ -522,6 +521,7 @@ bool IFWL_Edit::On_PageLoad(CFDE_TxtEdtEngine* pEdit, IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex); if (!pPage) return false; + pPage->LoadPage(nullptr, nullptr); return true; } @@ -532,6 +532,7 @@ bool IFWL_Edit::On_PageUnload(CFDE_TxtEdtEngine* pEdit, IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(nPageIndex); if (!pPage) return false; + pPage->UnloadPage(nullptr); return true; } @@ -543,9 +544,9 @@ void IFWL_Edit::On_AddDoRecord(CFDE_TxtEdtEngine* pEdit, bool IFWL_Edit::On_Validate(CFDE_TxtEdtEngine* pEdit, CFX_WideString& wsText) { IFWL_Widget* pDst = GetOuter(); - if (!pDst) { + if (!pDst) pDst = this; - } + CFWL_EvtEdtValidate event; event.pDstWidget = pDst; event.m_pSrcTarget = this; @@ -570,18 +571,19 @@ void IFWL_Edit::DrawTextBk(CFX_Graphics* pGraphics, ? CFWL_PartState_ReadOnly : CFWL_PartState_Normal; uint32_t dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled); - if (dwStates) { + if (dwStates) param.m_dwStates = CFWL_PartState_Disabled; - } param.m_pGraphics = pGraphics; param.m_matrix = *pMatrix; param.m_rtPart = m_rtClient; pTheme->DrawBackground(¶m); - if (!IsShowScrollBar(true) || !IsShowScrollBar(false)) { + + if (!IsShowScrollBar(true) || !IsShowScrollBar(false)) return; - } + CFX_RectF rtScorll; m_pHorzScrollBar->GetWidgetRect(rtScorll); + CFX_RectF rtStatic; rtStatic.Set(m_rtClient.right() - rtScorll.height, m_rtClient.bottom() - rtScorll.height, rtScorll.height, @@ -591,16 +593,18 @@ void IFWL_Edit::DrawTextBk(CFX_Graphics* pGraphics, param.m_rtPart = rtStatic; pTheme->DrawBackground(¶m); } + void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix) { IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); if (!pPage) return; + pGraphics->SaveGraphState(); - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) pGraphics->SaveGraphState(); - } + CFX_RectF rtClip = m_rtEngine; FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; @@ -610,6 +614,7 @@ void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, pMatrix->TransformRect(rtClip); mt.Concat(*pMatrix); } + bool bShowSel = (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_NoHideSel) || (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); if (bShowSel) { @@ -619,6 +624,7 @@ void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, FWL_WGTSTATE_Deactivated; } } + int32_t nSelCount = m_EdtEngine.CountSelRanges(); if (bShowSel && nSelCount > 0) { int32_t nPageCharStart = pPage->GetCharStart(); @@ -631,14 +637,15 @@ void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, for (i = 0; i < nSelCount; i++) { nCharCount = m_EdtEngine.GetSelRange(i, nCharStart); int32_t nCharEnd = nCharStart + nCharCount - 1; - if (nCharEnd < nPageCharStart || nCharStart > nPageCharEnd) { + if (nCharEnd < nPageCharStart || nCharStart > nPageCharEnd) continue; - } + int32_t nBgn = std::max(nCharStart, nPageCharStart); int32_t nEnd = std::min(nCharEnd, nPageCharEnd); pPage->CalcRangeRectArray(nBgn - nPageCharStart, nEnd - nBgn + 1, rectArr); } + int32_t nCount = rectArr.GetSize(); CFX_Path path; path.Create(); @@ -649,6 +656,7 @@ void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, rectArr[i].height); } pGraphics->SetClipRect(rtClip); + CFWL_ThemeBackground param; param.m_pGraphics = pGraphics; param.m_matrix = *pMatrix; @@ -657,6 +665,7 @@ void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, param.m_pPath = &path; pTheme->DrawBackground(¶m); } + CFX_RenderDevice* pRenderDev = pGraphics->GetRenderDevice(); if (!pRenderDev) return; @@ -667,6 +676,7 @@ void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, pRenderDevice->SetClipRect(rtClip); pRenderContext->StartRender(pRenderDevice.get(), pPage, mt); pRenderContext->DoRender(nullptr); + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { pGraphics->RestoreGraphState(); CFX_Path path; @@ -678,6 +688,7 @@ void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, fLeft += fStep; path.AddLine(fLeft, m_rtClient.top, fLeft, m_rtClient.bottom()); } + CFWL_ThemeBackground param; param.m_pGraphics = pGraphics; param.m_matrix = *pMatrix; @@ -692,45 +703,36 @@ void IFWL_Edit::DrawContent(CFX_Graphics* pGraphics, void IFWL_Edit::UpdateEditEngine() { UpdateEditParams(); UpdateEditLayout(); - if (m_nLimit > -1) { + if (m_nLimit > -1) m_EdtEngine.SetLimit(m_nLimit); - } } + void IFWL_Edit::UpdateEditParams() { FDE_TXTEDTPARAMS params; params.nHorzScale = 100; params.fPlateWidth = m_rtEngine.width; params.fPlateHeight = m_rtEngine.height; - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_RTLLayout) { + if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_RTLLayout) params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_RTL; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalLayout) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalLayout) params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_DocVertical; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalChars) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VerticalChars) params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_CharVertial; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReverseLine) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReverseLine) params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_LineReserve; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ArabicShapes) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ArabicShapes) params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_ArabicShapes; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ExpandTab) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ExpandTab) params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_ExpandTab; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_CombText; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_LastLineHeight) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_LastLineHeight) params.dwLayoutStyles |= FDE_TEXTEDITLAYOUT_LastLineHeight; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Validate) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Validate) params.dwMode |= FDE_TEXTEDITMODE_Validate; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Password) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_Password) params.dwMode |= FDE_TEXTEDITMODE_Password; - } + switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignMask) { case FWL_STYLEEXT_EDT_HNear: { params.dwAlignment |= FDE_TEXTEDITALIGN_Left; @@ -744,7 +746,8 @@ void IFWL_Edit::UpdateEditParams() { params.dwAlignment |= FDE_TEXTEDITALIGN_Right; break; } - default: {} + default: + break; } switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HAlignModeMask) { case FWL_STYLEEXT_EDT_Justified: { @@ -755,7 +758,10 @@ void IFWL_Edit::UpdateEditParams() { params.dwAlignment |= FDE_TEXTEDITALIGN_Distributed; break; } - default: { params.dwAlignment |= FDE_TEXTEDITALIGN_Normal; } + default: { + params.dwAlignment |= FDE_TEXTEDITALIGN_Normal; + break; + } } if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { params.dwMode |= FDE_TEXTEDITMODE_MultiLines; @@ -770,40 +776,43 @@ void IFWL_Edit::UpdateEditParams() { } else { params.fPlateHeight = 0x00FFFFFF; } - } else { - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoHScroll) == 0) { - params.dwMode |= FDE_TEXTEDITMODE_LimitArea_Horz; - } + } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_AutoHScroll) == + 0) { + params.dwMode |= FDE_TEXTEDITMODE_LimitArea_Horz; } if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ReadOnly) || (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled)) { params.dwMode |= FDE_TEXTEDITMODE_ReadOnly; } + FX_FLOAT* pFontSize = static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::FontSize)); if (!pFontSize) return; + m_fFontSize = *pFontSize; uint32_t* pFontColor = static_cast<uint32_t*>(GetThemeCapacity(CFWL_WidgetCapacity::TextColor)); if (!pFontColor) return; + params.dwFontColor = *pFontColor; FX_FLOAT* pLineHeight = static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::LineHeight)); if (!pLineHeight) return; + params.fLineSpace = *pLineHeight; CFGAS_GEFont* pFont = static_cast<CFGAS_GEFont*>(GetThemeCapacity(CFWL_WidgetCapacity::Font)); if (!pFont) return; + params.pFont = pFont; params.fFontSize = m_fFontSize; params.nLineCount = (int32_t)(params.fPlateHeight / params.fLineSpace); - if (params.nLineCount <= 0) { + if (params.nLineCount <= 0) params.nLineCount = 1; - } params.fTabWidth = params.fFontSize * 1; params.bTabEquidistant = true; params.wLineBreakChar = L'\n'; @@ -884,6 +893,7 @@ void IFWL_Edit::UpdateVAlignment() { IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); if (!pPage) return; + const CFX_RectF& rtFDE = pPage->GetContentsBox(); FX_FLOAT fOffsetY = 0.0f; FX_FLOAT fSpaceAbove = 0.0f; @@ -894,12 +904,11 @@ void IFWL_Edit::UpdateVAlignment() { fSpaceAbove = pSpace->x; fSpaceBelow = pSpace->y; } - if (fSpaceAbove < 0.1f) { + if (fSpaceAbove < 0.1f) fSpaceAbove = 0; - } - if (fSpaceBelow < 0.1f) { + if (fSpaceBelow < 0.1f) fSpaceBelow = 0; - } + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VCenter) { fOffsetY = (m_rtEngine.height - rtFDE.height) / 2; if (fOffsetY < (fSpaceAbove + fSpaceBelow) / 2 && @@ -913,33 +922,33 @@ void IFWL_Edit::UpdateVAlignment() { } else { fOffsetY += fSpaceAbove; } - m_fVAlignOffset = fOffsetY; - if (m_fVAlignOffset < 0) { - m_fVAlignOffset = 0; - } + m_fVAlignOffset = std::max(fOffsetY, 0.0f); } + void IFWL_Edit::UpdateCaret() { CFX_RectF rtFDE; m_EdtEngine.GetCaretRect(rtFDE); + rtFDE.Offset(m_rtEngine.left - m_fScrollOffsetX, m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset); CFX_RectF rtCaret; rtCaret.Set(rtFDE.left, rtFDE.top, rtFDE.width, rtFDE.height); + CFX_RectF temp = rtCaret; CFX_RectF rtClient; GetClientRect(rtClient); rtCaret.Intersect(rtClient); + if (rtCaret.left > rtClient.right()) { FX_FLOAT right = rtCaret.right(); rtCaret.left = rtClient.right() - 1; rtCaret.width = right - rtCaret.left; } - bool bIntersect = !rtCaret.IsEmpty(); + bool bShow = true; bool bShowWhole = false; - if (!(m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) || !bIntersect) { + if (!(m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) || rtCaret.IsEmpty()) bShow = false; - } if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption && temp.right() > m_rtEngine.right()) { bShowWhole = true; @@ -948,13 +957,14 @@ void IFWL_Edit::UpdateCaret() { temp.bottom() > m_rtEngine.bottom()) { bShowWhole = true; } else { - bShow = (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && bIntersect); + bShow = (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && + !rtCaret.IsEmpty()); } - if (bShowWhole) { + if (bShowWhole) rtCaret = temp; - } ShowCaret(bShow, &rtCaret); } + IFWL_ScrollBar* IFWL_Edit::UpdateScroll() { bool bShowHorz = m_pHorzScrollBar && @@ -962,12 +972,13 @@ IFWL_ScrollBar* IFWL_Edit::UpdateScroll() { bool bShowVert = m_pVertScrollBar && ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Invisible) == 0); - if (!bShowHorz && !bShowVert) { + if (!bShowHorz && !bShowVert) return nullptr; - } + IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); if (!pPage) return nullptr; + const CFX_RectF& rtFDE = pPage->GetContentsBox(); IFWL_ScrollBar* pRepaint = nullptr; if (bShowHorz) { @@ -977,13 +988,8 @@ IFWL_ScrollBar* IFWL_Edit::UpdateScroll() { m_pHorzScrollBar->LockUpdate(); FX_FLOAT fRange = rtFDE.width - rtScroll.width; m_pHorzScrollBar->SetRange(0.0f, fRange); - FX_FLOAT fPos = m_fScrollOffsetX; - if (fPos < 0.0f) { - fPos = 0.0f; - } - if (fPos > fRange) { - fPos = fRange; - } + + FX_FLOAT fPos = std::min(std::max(m_fScrollOffsetX, 0.0f), fRange); m_pHorzScrollBar->SetPos(fPos); m_pHorzScrollBar->SetTrackPos(fPos); m_pHorzScrollBar->SetPageSize(rtScroll.width); @@ -1001,24 +1007,17 @@ IFWL_ScrollBar* IFWL_Edit::UpdateScroll() { pRepaint = m_pHorzScrollBar.get(); } } + if (bShowVert) { CFX_RectF rtScroll; m_pVertScrollBar->GetWidgetRect(rtScroll); if (rtScroll.height < rtFDE.height) { m_pVertScrollBar->LockUpdate(); FX_FLOAT fStep = m_EdtEngine.GetEditParams()->fLineSpace; - FX_FLOAT fRange = rtFDE.height - m_rtEngine.height; - if (fRange < fStep) { - fRange = fStep; - } + FX_FLOAT fRange = std::max(rtFDE.height - m_rtEngine.height, fStep); + m_pVertScrollBar->SetRange(0.0f, fRange); - FX_FLOAT fPos = m_fScrollOffsetY; - if (fPos < 0.0f) { - fPos = 0.0f; - } - if (fPos > fRange) { - fPos = fRange; - } + FX_FLOAT fPos = std::min(std::max(m_fScrollOffsetY, 0.0f), fRange); m_pVertScrollBar->SetPos(fPos); m_pVertScrollBar->SetTrackPos(fPos); m_pVertScrollBar->SetPageSize(rtScroll.height); @@ -1038,6 +1037,7 @@ IFWL_ScrollBar* IFWL_Edit::UpdateScroll() { } return pRepaint; } + bool IFWL_Edit::IsShowScrollBar(bool bVert) { bool bShow = (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) @@ -1052,12 +1052,14 @@ bool IFWL_Edit::IsShowScrollBar(bool bVert) { return bShow && (m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) && (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine); } + bool IFWL_Edit::IsContentHeightOverflow() { IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); if (!pPage) return false; return pPage->GetContentsBox().height > m_rtEngine.height + 1.0f; } + int32_t IFWL_Edit::AddDoRecord(IFDE_TxtEdtDoRecord* pRecord) { int32_t nCount = pdfium::CollectionSize<int32_t>(m_DoRecords); if (m_iCurRecord == nCount - 1) { @@ -1074,6 +1076,7 @@ int32_t IFWL_Edit::AddDoRecord(IFDE_TxtEdtDoRecord* pRecord) { m_iCurRecord = pdfium::CollectionSize<int32_t>(m_DoRecords) - 1; return m_iCurRecord; } + void IFWL_Edit::Layout() { GetClientRect(m_rtClient); m_rtEngine = m_rtClient; @@ -1081,6 +1084,7 @@ void IFWL_Edit::Layout() { GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); if (!pfWidth) return; + FX_FLOAT fWidth = *pfWidth; if (!m_pOuter) { CFX_RectF* pUIMargin = static_cast<CFX_RectF*>( @@ -1100,10 +1104,12 @@ void IFWL_Edit::Layout() { pUIMargin->height); } } + bool bShowVertScrollbar = IsShowScrollBar(true); bool bShowHorzScrollbar = IsShowScrollBar(false); if (bShowVertScrollbar) { InitScrollBar(); + CFX_RectF rtVertScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth, @@ -1111,19 +1117,21 @@ void IFWL_Edit::Layout() { } else { rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, m_rtClient.height); - if (bShowHorzScrollbar) { + if (bShowHorzScrollbar) rtVertScr.height -= fWidth; - } m_rtEngine.width -= fWidth; } + m_pVertScrollBar->SetWidgetRect(rtVertScr); m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, false); m_pVertScrollBar->Update(); } else if (m_pVertScrollBar) { m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, true); } + if (bShowHorzScrollbar) { InitScrollBar(false); + CFX_RectF rtHoriScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin, @@ -1131,9 +1139,8 @@ void IFWL_Edit::Layout() { } else { rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, m_rtClient.width, fWidth); - if (bShowVertScrollbar) { + if (bShowVertScrollbar) rtHoriScr.width -= fWidth; - } m_rtEngine.height -= fWidth; } m_pHorzScrollBar->SetWidgetRect(rtHoriScr); @@ -1143,11 +1150,13 @@ void IFWL_Edit::Layout() { m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, true); } } + void IFWL_Edit::LayoutScrollBar() { if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_ShowScrollbarFocus) == 0) { return; } + FX_FLOAT* pfWidth = nullptr; bool bShowVertScrollbar = IsShowScrollBar(true); bool bShowHorzScrollbar = IsShowScrollBar(false); @@ -1164,9 +1173,8 @@ void IFWL_Edit::LayoutScrollBar() { } else { rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, m_rtClient.height); - if (bShowHorzScrollbar) { + if (bShowHorzScrollbar) rtVertScr.height -= fWidth; - } } m_pVertScrollBar->SetWidgetRect(rtVertScr); m_pVertScrollBar->Update(); @@ -1175,12 +1183,14 @@ void IFWL_Edit::LayoutScrollBar() { } else if (m_pVertScrollBar) { m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, true); } + if (bShowHorzScrollbar) { if (!m_pHorzScrollBar) { if (!pfWidth) { pfWidth = static_cast<FX_FLOAT*>( GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); } + FX_FLOAT fWidth = pfWidth ? *pfWidth : 0; InitScrollBar(false); CFX_RectF rtHoriScr; @@ -1190,9 +1200,8 @@ void IFWL_Edit::LayoutScrollBar() { } else { rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, m_rtClient.width, fWidth); - if (bShowVertScrollbar) { + if (bShowVertScrollbar) rtHoriScr.width -= (fWidth); - } } m_pHorzScrollBar->SetWidgetRect(rtHoriScr); m_pHorzScrollBar->Update(); @@ -1201,9 +1210,8 @@ void IFWL_Edit::LayoutScrollBar() { } else if (m_pHorzScrollBar) { m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, true); } - if (bShowVertScrollbar || bShowHorzScrollbar) { + if (bShowVertScrollbar || bShowHorzScrollbar) UpdateScroll(); - } } void IFWL_Edit::DeviceToEngine(CFX_PointF& pt) { @@ -1212,9 +1220,8 @@ void IFWL_Edit::DeviceToEngine(CFX_PointF& pt) { } void IFWL_Edit::InitScrollBar(bool bVert) { - if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { + if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) return; - } auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); prop->m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; @@ -1250,6 +1257,7 @@ bool FWL_ShowCaret(IFWL_Widget* pWidget, pDocEnvironment->DisplayCaret(pXFAWidget, bVisible, &rt); return true; } + pDocEnvironment->DisplayCaret(pXFAWidget, bVisible, pRtAnchor); return true; } @@ -1257,59 +1265,59 @@ bool FWL_ShowCaret(IFWL_Widget* pWidget, void IFWL_Edit::ShowCaret(bool bVisible, CFX_RectF* pRect) { if (m_pCaret) { m_pCaret->ShowCaret(bVisible); - if (bVisible && !pRect->IsEmpty()) { + if (bVisible && !pRect->IsEmpty()) m_pCaret->SetWidgetRect(*pRect); - } Repaint(&m_rtEngine); - } else { - IFWL_Widget* pOuter = this; + return; + } + + IFWL_Widget* pOuter = this; + if (bVisible) { + pRect->Offset(m_pProperties->m_rtWidget.left, + m_pProperties->m_rtWidget.top); + } + while (pOuter->GetOuter()) { + pOuter = pOuter->GetOuter(); if (bVisible) { - pRect->Offset(m_pProperties->m_rtWidget.left, - m_pProperties->m_rtWidget.top); + CFX_RectF rtOuter; + pOuter->GetWidgetRect(rtOuter); + pRect->Offset(rtOuter.left, rtOuter.top); } - while (pOuter->GetOuter()) { - pOuter = pOuter->GetOuter(); - if (bVisible) { - CFX_RectF rtOuter; - pOuter->GetWidgetRect(rtOuter); - pRect->Offset(rtOuter.left, rtOuter.top); - } - } - FWL_ShowCaret(pOuter, bVisible, pRect); } + FWL_ShowCaret(pOuter, bVisible, pRect); } + bool IFWL_Edit::ValidateNumberChar(FX_WCHAR cNum) { - if (!m_bSetRange) { + if (!m_bSetRange) return true; - } + CFX_WideString wsOld, wsText; m_EdtEngine.GetText(wsText, 0); if (wsText.IsEmpty()) { - if (cNum == L'0') { + if (cNum == L'0') return false; - } return true; } + int32_t caretPos = m_EdtEngine.GetCaretPos(); - int32_t iSel = CountSelRanges(); - if (iSel == 0) { - if (cNum == L'0' && caretPos == 0) { + if (CountSelRanges() == 0) { + if (cNum == L'0' && caretPos == 0) return false; - } + int32_t nLen = wsText.GetLength(); CFX_WideString l = wsText.Mid(0, caretPos); CFX_WideString r = wsText.Mid(caretPos, nLen - caretPos); CFX_WideString wsNew = l + cNum + r; - if (wsNew.GetInteger() <= m_iMax) { - return true; - } - } else { - if (wsText.GetInteger() <= m_iMax) { + if (wsNew.GetInteger() <= m_iMax) return true; - } + return false; } + + if (wsText.GetInteger() <= m_iMax) + return true; return false; } + void IFWL_Edit::InitCaret() { if (!m_pCaret) { if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) { @@ -1416,6 +1424,7 @@ void IFWL_Edit::DoButtonDown(CFWL_MsgMouse* pMsg) { IFDE_TxtEdtPage* pPage = m_EdtEngine.GetPage(0); if (!pPage) return; + CFX_PointF pt(pMsg->m_fx, pMsg->m_fy); DeviceToEngine(pt); bool bBefore = true; @@ -1449,13 +1458,15 @@ void IFWL_Edit::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { } ClearRecord(); } + LayoutScrollBar(); - if (bRepaint) { - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, - m_pProperties->m_rtWidget.height); - Repaint(&rtInvalidate); - } + if (!bRepaint) + return; + + CFX_RectF rtInvalidate; + rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height); + Repaint(&rtInvalidate); } void IFWL_Edit::OnLButtonDown(CFWL_MsgMouse* pMsg) { @@ -1467,14 +1478,12 @@ void IFWL_Edit::OnLButtonDown(CFWL_MsgMouse* pMsg) { DoButtonDown(pMsg); int32_t nIndex = m_EdtEngine.GetCaretPos(); bool bRepaint = false; - int32_t iCount = m_EdtEngine.CountSelRanges(); - if (iCount > 0) { + if (m_EdtEngine.CountSelRanges() > 0) { m_EdtEngine.ClearSelection(); bRepaint = true; } - bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift); - if (bShift && m_nSelStart != nIndex) { + if ((pMsg->m_dwFlags & FWL_KEYFLAG_Shift) && m_nSelStart != nIndex) { int32_t iStart = std::min(m_nSelStart, nIndex); int32_t iEnd = std::max(m_nSelStart, nIndex); m_EdtEngine.AddSelRange(iStart, iEnd - iStart); @@ -1523,14 +1532,16 @@ void IFWL_Edit::OnMouseMove(CFWL_MsgMouse* pMsg) { m_EdtEngine.SetCaretPos(nIndex, bBefore); nIndex = m_EdtEngine.GetCaretPos(); m_EdtEngine.ClearSelection(); - if (nIndex != m_nSelStart) { - int32_t nLen = m_EdtEngine.GetTextLength(); - if (m_nSelStart >= nLen) - m_nSelStart = nLen; - m_EdtEngine.AddSelRange(std::min(m_nSelStart, nIndex), - FXSYS_abs(nIndex - m_nSelStart)); - } + if (nIndex == m_nSelStart) + return; + + int32_t nLen = m_EdtEngine.GetTextLength(); + if (m_nSelStart >= nLen) + m_nSelStart = nLen; + + m_EdtEngine.AddSelRange(std::min(m_nSelStart, nIndex), + FXSYS_abs(nIndex - m_nSelStart)); } void IFWL_Edit::OnKeyDown(CFWL_MsgKey* pMsg) { @@ -1598,14 +1609,13 @@ void IFWL_Edit::OnChar(CFWL_MsgKey* pMsg) { } int32_t iError = 0; - FX_WCHAR c = (FX_WCHAR)pMsg->m_dwKeyCode; + FX_WCHAR c = static_cast<FX_WCHAR>(pMsg->m_dwKeyCode); int32_t nCaret = m_EdtEngine.GetCaretPos(); switch (c) { case FWL_VKEY_Back: m_EdtEngine.Delete(nCaret, true); break; - case 0x0A: - break; + case FWL_VKEY_NewLine: case FWL_VKEY_Escape: break; case FWL_VKEY_Tab: { @@ -1697,17 +1707,18 @@ bool IFWL_Edit::OnScroll(IFWL_ScrollBar* pScrollBar, case FWL_SCBCODE::EndScroll: return false; } - if (iCurPos != fPos) { - pScrollBar->SetPos(fPos); - pScrollBar->SetTrackPos(fPos); - UpdateOffset(pScrollBar, fPos - iCurPos); - UpdateCaret(); + if (iCurPos == fPos) + return true; - CFX_RectF rect; - GetWidgetRect(rect); - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); - Repaint(&rtInvalidate); - } + pScrollBar->SetPos(fPos); + pScrollBar->SetTrackPos(fPos); + UpdateOffset(pScrollBar, fPos - iCurPos); + UpdateCaret(); + + CFX_RectF rect; + GetWidgetRect(rect); + CFX_RectF rtInvalidate; + rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); + Repaint(&rtInvalidate); return true; } diff --git a/xfa/fwl/core/ifwl_form.cpp b/xfa/fwl/core/ifwl_form.cpp index 42827ab759..989da199e1 100644 --- a/xfa/fwl/core/ifwl_form.cpp +++ b/xfa/fwl/core/ifwl_form.cpp @@ -88,24 +88,27 @@ bool IFWL_Form::IsInstance(const CFX_WideStringC& wsClass) const { } void IFWL_Form::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (bAutoSize) { - rect.Reset(); - FX_FLOAT fCapHeight = GetCaptionHeight(); - FX_FLOAT fCXBorder = GetBorderSize(true); - FX_FLOAT fCYBorder = GetBorderSize(false); - FX_FLOAT fEdge = GetEdgeWidth(); - rect.height += fCapHeight + fCYBorder + fEdge + fEdge; - rect.width += fCXBorder + fCXBorder + fEdge + fEdge; - } else { + if (!bAutoSize) { rect = m_pProperties->m_rtWidget; + return; } + + rect.Reset(); + FX_FLOAT fCapHeight = GetCaptionHeight(); + FX_FLOAT fCXBorder = GetBorderSize(true); + FX_FLOAT fCYBorder = GetBorderSize(false); + FX_FLOAT fEdge = GetEdgeWidth(); + rect.height += fCapHeight + fCYBorder + fEdge + fEdge; + rect.width += fCXBorder + fCXBorder + fEdge + fEdge; } + void IFWL_Form::GetClientRect(CFX_RectF& rect) { if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) == 0) { rect = m_pProperties->m_rtWidget; rect.Offset(-rect.left, -rect.top); return; } + #ifdef FWL_UseMacSystemBorder rect = m_rtRelative; CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); @@ -134,31 +137,33 @@ void IFWL_Form::GetClientRect(CFX_RectF& rect) { rect.Deflate(x, t, x, y); #endif } + void IFWL_Form::Update() { - if (m_iLock > 0) { + if (m_iLock > 0) return; - } - if (!m_pProperties->m_pThemeProvider) { + if (!m_pProperties->m_pThemeProvider) m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } -#ifdef FWL_UseMacSystemBorder -#else + +#ifndef FWL_UseMacSystemBorder SetThemeData(); - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) { + if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) UpdateIcon(); - } #endif + UpdateCaption(); Layout(); } + FWL_WidgetHit IFWL_Form::HitTest(FX_FLOAT fx, FX_FLOAT fy) { GetAvailableTheme(); + if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) return FWL_WidgetHit::CloseBox; if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) return FWL_WidgetHit::MaxBox; if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) return FWL_WidgetHit::MinBox; + CFX_RectF rtCap; rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder, m_rtCaption.width - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder, @@ -169,32 +174,40 @@ FWL_WidgetHit IFWL_Form::HitTest(FX_FLOAT fx, FX_FLOAT fy) { (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_Resize)) { FX_FLOAT fWidth = m_rtRelative.width - 2 * (m_fCYBorder + kCornerEnlarge); FX_FLOAT fHeight = m_rtRelative.height - 2 * (m_fCXBorder + kCornerEnlarge); + CFX_RectF rt; rt.Set(0, m_fCXBorder + kCornerEnlarge, m_fCYBorder, fHeight); if (rt.Contains(fx, fy)) return FWL_WidgetHit::Left; + rt.Set(m_rtRelative.width - m_fCYBorder, m_fCXBorder + kCornerEnlarge, m_fCYBorder, fHeight); if (rt.Contains(fx, fy)) return FWL_WidgetHit::Right; + rt.Set(m_fCYBorder + kCornerEnlarge, 0, fWidth, m_fCXBorder); if (rt.Contains(fx, fy)) return FWL_WidgetHit::Top; + rt.Set(m_fCYBorder + kCornerEnlarge, m_rtRelative.height - m_fCXBorder, fWidth, m_fCXBorder); if (rt.Contains(fx, fy)) return FWL_WidgetHit::Bottom; + rt.Set(0, 0, m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); if (rt.Contains(fx, fy)) return FWL_WidgetHit::LeftTop; + rt.Set(0, m_rtRelative.height - m_fCXBorder - kCornerEnlarge, m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); if (rt.Contains(fx, fy)) return FWL_WidgetHit::LeftBottom; + rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, 0, m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); if (rt.Contains(fx, fy)) return FWL_WidgetHit::RightTop; + rt.Set(m_rtRelative.width - m_fCYBorder - kCornerEnlarge, m_rtRelative.height - m_fCXBorder - kCornerEnlarge, m_fCYBorder + kCornerEnlarge, m_fCXBorder + kCornerEnlarge); @@ -203,17 +216,19 @@ FWL_WidgetHit IFWL_Form::HitTest(FX_FLOAT fx, FX_FLOAT fy) { } return FWL_WidgetHit::Client; } + void IFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!pGraphics) return; if (!m_pProperties->m_pThemeProvider) return; + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; bool bInactive = !IsActive(); int32_t iState = bInactive ? CFWL_PartState_Inactive : CFWL_PartState_Normal; - if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) { + if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_FRM_NoDrawClient) == 0) DrawBackground(pGraphics, pTheme); - } + #ifdef FWL_UseMacSystemBorder return; #endif @@ -222,9 +237,8 @@ void IFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { param.m_dwStates = iState; param.m_pGraphics = pGraphics; param.m_rtPart = m_rtRelative; - if (pMatrix) { + if (pMatrix) param.m_matrix.Concat(*pMatrix); - } if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { param.m_iPart = CFWL_Part::Border; pTheme->DrawBackground(¶m); @@ -253,31 +267,29 @@ void IFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { } if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon) { param.m_iPart = CFWL_Part::Icon; - if (HasIcon()) { + if (HasIcon()) DrawIconImage(pGraphics, pTheme, pMatrix); - } } + #if (_FX_OS_ == _FX_MACOSX_) { if (m_pCloseBox) { param.m_iPart = CFWL_Part::CloseBox; param.m_dwStates = m_pCloseBox->GetPartState(); - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) { + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) param.m_dwStates = CFWL_PartState_Disabled; - } else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) { + else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) param.m_dwStates = CFWL_PartState_Hovered; - } param.m_rtPart = m_pCloseBox->m_rtBtn; pTheme->DrawBackground(¶m); } if (m_pMaxBox) { param.m_iPart = CFWL_Part::MaximizeBox; param.m_dwStates = m_pMaxBox->GetPartState(); - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) { + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) param.m_dwStates = CFWL_PartState_Disabled; - } else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) { + else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) param.m_dwStates = CFWL_PartState_Hovered; - } param.m_rtPart = m_pMaxBox->m_rtBtn; param.m_bMaximize = m_bMaximized; pTheme->DrawBackground(¶m); @@ -285,11 +297,10 @@ void IFWL_Form::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (m_pMinBox) { param.m_iPart = CFWL_Part::MinimizeBox; param.m_dwStates = m_pMinBox->GetPartState(); - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) { + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Deactivated) param.m_dwStates = CFWL_PartState_Disabled; - } else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) { + else if (CFWL_PartState_Normal == param.m_dwStates && m_bMouseIn) param.m_dwStates = CFWL_PartState_Hovered; - } param.m_rtPart = m_pMinBox->m_rtBtn; pTheme->DrawBackground(¶m); } @@ -336,10 +347,11 @@ IFWL_Widget* IFWL_Form::DoModal() { m_bDoModalFlag = true; SetStates(FWL_WGTSTATE_Invisible, false); pDriver->Run(); -#if (_FX_OS_ == _FX_MACOSX_) -#else + +#if _FX_OS_ != _FX_MACOSX_ pDriver->PopNoteLoop(); #endif + m_pNoteLoop.reset(); return nullptr; } @@ -347,7 +359,9 @@ IFWL_Widget* IFWL_Form::DoModal() { void IFWL_Form::EndDoModal() { if (!m_pNoteLoop) return; + m_bDoModalFlag = false; + #if (_FX_OS_ == _FX_MACOSX_) m_pNoteLoop->EndModalLoop(); const IFWL_App* pApp = GetOwnerApp(); @@ -392,35 +406,29 @@ void IFWL_Form::RemoveSysButtons() { } CFWL_SysBtn* IFWL_Form::GetSysBtnAtPoint(FX_FLOAT fx, FX_FLOAT fy) { - if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) { + if (m_pCloseBox && m_pCloseBox->m_rtBtn.Contains(fx, fy)) return m_pCloseBox; - } - if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) { + if (m_pMaxBox && m_pMaxBox->m_rtBtn.Contains(fx, fy)) return m_pMaxBox; - } - if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) { + if (m_pMinBox && m_pMinBox->m_rtBtn.Contains(fx, fy)) return m_pMinBox; - } - if (m_pCaptionBox && m_pCaptionBox->m_rtBtn.Contains(fx, fy)) { + if (m_pCaptionBox && m_pCaptionBox->m_rtBtn.Contains(fx, fy)) return m_pCaptionBox; - } return nullptr; } + CFWL_SysBtn* IFWL_Form::GetSysBtnByState(uint32_t dwState) { - if (m_pCloseBox && (m_pCloseBox->m_dwState & dwState)) { + if (m_pCloseBox && (m_pCloseBox->m_dwState & dwState)) return m_pCloseBox; - } - if (m_pMaxBox && (m_pMaxBox->m_dwState & dwState)) { + if (m_pMaxBox && (m_pMaxBox->m_dwState & dwState)) return m_pMaxBox; - } - if (m_pMinBox && (m_pMinBox->m_dwState & dwState)) { + if (m_pMinBox && (m_pMinBox->m_dwState & dwState)) return m_pMinBox; - } - if (m_pCaptionBox && (m_pCaptionBox->m_dwState & dwState)) { + if (m_pCaptionBox && (m_pCaptionBox->m_dwState & dwState)) return m_pCaptionBox; - } return nullptr; } + CFWL_SysBtn* IFWL_Form::GetSysBtnByIndex(int32_t nIndex) { if (nIndex < 0) return nullptr; @@ -428,36 +436,32 @@ CFWL_SysBtn* IFWL_Form::GetSysBtnByIndex(int32_t nIndex) { CFX_ArrayTemplate<CFWL_SysBtn*> arrBtn; if (m_pMinBox) arrBtn.Add(m_pMinBox); - if (m_pMaxBox) arrBtn.Add(m_pMaxBox); - if (m_pCloseBox) arrBtn.Add(m_pCloseBox); - return arrBtn[nIndex]; } + int32_t IFWL_Form::GetSysBtnIndex(CFWL_SysBtn* pBtn) { CFX_ArrayTemplate<CFWL_SysBtn*> arrBtn; if (m_pMinBox) arrBtn.Add(m_pMinBox); - if (m_pMaxBox) arrBtn.Add(m_pMaxBox); - if (m_pCloseBox) arrBtn.Add(m_pCloseBox); - return arrBtn.Find(pBtn); } + FX_FLOAT IFWL_Form::GetCaptionHeight() { CFWL_WidgetCapacity dwCapacity = CFWL_WidgetCapacity::None; - if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) { + if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Caption) dwCapacity = CFWL_WidgetCapacity::CYCaption; - } else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) { + else if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_NarrowCaption) dwCapacity = CFWL_WidgetCapacity::CYNarrowCaption; - } + if (dwCapacity != CFWL_WidgetCapacity::None) { FX_FLOAT* pfCapHeight = static_cast<FX_FLOAT*>(GetThemeCapacity(dwCapacity)); @@ -465,23 +469,24 @@ FX_FLOAT IFWL_Form::GetCaptionHeight() { } return 0; } + void IFWL_Form::DrawCaptionText(CFX_Graphics* pGs, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix) { CFX_WideString wsText; IFWL_DataProvider* pData = m_pProperties->m_pDataProvider; pData->GetCaption(this, wsText); - if (wsText.IsEmpty()) { + if (wsText.IsEmpty()) return; - } + CFWL_ThemeText textParam; textParam.m_pWidget = this; textParam.m_iPart = CFWL_Part::Caption; textParam.m_dwStates = CFWL_PartState_Normal; textParam.m_pGraphics = pGs; - if (pMatrix) { + if (pMatrix) textParam.m_matrix.Concat(*pMatrix); - } + CFX_RectF rtText; if (m_bCustomizeLayout) { rtText = m_rtCaptionText; @@ -499,6 +504,7 @@ void IFWL_Form::DrawCaptionText(CFX_Graphics* pGs, : FDE_TTOALIGNMENT_CenterLeft; pTheme->DrawText(&textParam); } + void IFWL_Form::DrawIconImage(CFX_Graphics* pGs, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix) { @@ -510,11 +516,11 @@ void IFWL_Form::DrawIconImage(CFX_Graphics* pGs, param.m_pGraphics = pGs; param.m_pImage = pData->GetIcon(this, false); param.m_rtPart = m_rtIcon; - if (pMatrix) { + if (pMatrix) param.m_matrix.Concat(*pMatrix); - } pTheme->DrawBackground(¶m); } + void IFWL_Form::GetEdgeRect(CFX_RectF& rtEdge) { rtEdge = m_rtRelative; if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border) { @@ -523,27 +529,32 @@ void IFWL_Form::GetEdgeRect(CFX_RectF& rtEdge) { rtEdge.Deflate(fCX, m_rtCaption.Height(), fCX, fCY); } } + void IFWL_Form::SetWorkAreaRect() { m_rtRestore = m_pProperties->m_rtWidget; CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); if (!pWidgetMgr) return; + m_bSetMaximize = true; Repaint(&m_rtRelative); } void IFWL_Form::Layout() { GetRelativeRect(m_rtRelative); + #ifndef FWL_UseMacSystemBorder ResetSysBtn(); #endif } + void IFWL_Form::ResetSysBtn() { m_fCXBorder = *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CXBorder)); m_fCYBorder = *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::CYBorder)); RemoveSysButtons(); + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; m_bCustomizeLayout = pTheme->IsCustomizedLayout(this); FX_FLOAT fCapHeight = GetCaptionHeight(); @@ -551,6 +562,7 @@ void IFWL_Form::ResetSysBtn() { m_rtCaption = m_rtRelative; m_rtCaption.height = fCapHeight; } + m_iSysBox = 0; if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_CloseBox) { m_pCloseBox = new CFWL_SysBtn; @@ -595,6 +607,7 @@ void IFWL_Form::ResetSysBtn() { } m_iSysBox++; } + IFWL_FormDP* pData = static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); if (m_pProperties->m_dwStyles & FWL_WGTSTYLE_Icon && @@ -605,6 +618,7 @@ void IFWL_Form::ResetSysBtn() { } } } + void IFWL_Form::RegisterForm() { const IFWL_App* pApp = GetOwnerApp(); if (!pApp) @@ -617,6 +631,7 @@ void IFWL_Form::RegisterForm() { pDriver->RegisterForm(this); } + void IFWL_Form::UnRegisterForm() { const IFWL_App* pApp = GetOwnerApp(); if (!pApp) @@ -636,15 +651,18 @@ void IFWL_Form::SetThemeData() { m_fBigIconSz = *static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::BigIcon)); } + bool IFWL_Form::HasIcon() { IFWL_FormDP* pData = static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); return !!pData->GetIcon(this, false); } + void IFWL_Form::UpdateIcon() { CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); if (!pWidgetMgr) return; + IFWL_FormDP* pData = static_cast<IFWL_FormDP*>(m_pProperties->m_pDataProvider); CFX_DIBitmap* pBigIcon = pData->GetIcon(this, true); @@ -654,21 +672,22 @@ void IFWL_Form::UpdateIcon() { if (pSmallIcon) m_pSmallIcon = pSmallIcon; } + void IFWL_Form::UpdateCaption() { CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); if (!pWidgetMgr) return; + IFWL_DataProvider* pData = m_pProperties->m_pDataProvider; if (!pData) return; + CFX_WideString text; pData->GetCaption(this, text); } -#ifdef FWL_UseMacSystemBorder -void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) {} -#else void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) { +#ifndef FWL_UseMacSystemBorder if (!pMessage) return; @@ -699,8 +718,8 @@ void IFWL_Form::OnProcessMessage(CFWL_Message* pMessage) { default: break; } -} #endif // FWL_UseMacSystemBorder +} void IFWL_Form::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { @@ -711,8 +730,10 @@ void IFWL_Form::OnLButtonDown(CFWL_MsgMouse* pMsg) { SetGrab(true); m_bLButtonDown = true; m_eResizeType = FORM_RESIZETYPE_None; + CFWL_SysBtn* pPressBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); m_iCaptureBtn = GetSysBtnIndex(pPressBtn); + CFX_RectF rtCap; rtCap.Set(m_rtCaption.left + m_fCYBorder, m_rtCaption.top + m_fCXBorder, m_rtCaption.width - kSystemButtonSize * m_iSysBox - 2 * m_fCYBorder, @@ -724,6 +745,7 @@ void IFWL_Form::OnLButtonDown(CFWL_MsgMouse* pMsg) { } else if (rtCap.Contains(pMsg->m_fx, pMsg->m_fy)) { m_eResizeType = FORM_RESIZETYPE_Cap; } + m_InfoStart.m_ptStart = CFX_PointF(pMsg->m_fx, pMsg->m_fy); m_InfoStart.m_szStart = CFX_SizeF(m_pProperties->m_rtWidget.width, m_pProperties->m_rtWidget.height); @@ -763,7 +785,8 @@ void IFWL_Form::OnMouseMove(CFWL_MsgMouse* pMsg) { rtInvalidate.Reset(); CFWL_SysBtn* pPointBtn = GetSysBtnAtPoint(pMsg->m_fx, pMsg->m_fy); CFWL_SysBtn* pOldHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); -#if (_FX_OS_ == _FX_MACOSX_) + +#if _FX_OS_ == _FX_MACOSX_ { if (pOldHover && pPointBtn != pOldHover) pOldHover->SetNormal(); @@ -803,16 +826,18 @@ void IFWL_Form::OnMouseMove(CFWL_MsgMouse* pMsg) { } } #endif + if (!rtInvalidate.IsEmpty()) Repaint(&rtInvalidate); } void IFWL_Form::OnMouseLeave(CFWL_MsgMouse* pMsg) { CFWL_SysBtn* pHover = GetSysBtnByState(FWL_SYSBUTTONSTATE_Hover); - if (pHover) { - pHover->SetNormal(); - Repaint(&pHover->m_rtBtn); - } + if (!pHover) + return; + + pHover->SetNormal(); + Repaint(&pHover->m_rtBtn); } void IFWL_Form::OnLButtonDblClk(CFWL_MsgMouse* pMsg) { diff --git a/xfa/fwl/core/ifwl_formproxy.cpp b/xfa/fwl/core/ifwl_formproxy.cpp index 56194d8c15..1bdc002b18 100644 --- a/xfa/fwl/core/ifwl_formproxy.cpp +++ b/xfa/fwl/core/ifwl_formproxy.cpp @@ -22,9 +22,8 @@ FWL_Type IFWL_FormProxy::GetClassID() const { } bool IFWL_FormProxy::IsInstance(const CFX_WideStringC& wsClass) const { - if (wsClass == CFX_WideStringC(FWL_CLASS_FormProxy)) { + if (wsClass == CFX_WideStringC(FWL_CLASS_FormProxy)) return true; - } return IFWL_Form::IsInstance(wsClass); } diff --git a/xfa/fwl/core/ifwl_listbox.cpp b/xfa/fwl/core/ifwl_listbox.cpp index 041e008065..6696d4ce9e 100644 --- a/xfa/fwl/core/ifwl_listbox.cpp +++ b/xfa/fwl/core/ifwl_listbox.cpp @@ -43,27 +43,26 @@ FWL_Type IFWL_ListBox::GetClassID() const { } void IFWL_ListBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (bAutoSize) { - rect.Set(0, 0, 0, 0); - if (!m_pProperties->m_pThemeProvider) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - CFX_SizeF fs = CalcSize(true); - rect.Set(0, 0, fs.x, fs.y); - IFWL_Widget::GetWidgetRect(rect, true); - } else { + if (!bAutoSize) { rect = m_pProperties->m_rtWidget; + return; } + + rect.Set(0, 0, 0, 0); + if (!m_pProperties->m_pThemeProvider) + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + + CFX_SizeF fs = CalcSize(true); + rect.Set(0, 0, fs.x, fs.y); + IFWL_Widget::GetWidgetRect(rect, true); } void IFWL_ListBox::Update() { - if (IsLocked()) { + if (IsLocked()) return; - } - if (!m_pProperties->m_pThemeProvider) { + if (!m_pProperties->m_pThemeProvider) m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - m_iTTOAligns = FDE_TTOALIGNMENT_Center; + switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) { case FWL_STYLEEXT_LTB_LeftAlign: { m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft; @@ -74,11 +73,14 @@ void IFWL_ListBox::Update() { break; } case FWL_STYLEEXT_LTB_CenterAlign: - default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; } + default: { + m_iTTOAligns = FDE_TTOALIGNMENT_Center; + break; + } } - if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { + if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) m_dwTTOStyles |= FDE_TTOSTYLE_RTL; - } + m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; m_fScorllBarWidth = GetScrollWidth(); CalcSize(); @@ -108,28 +110,26 @@ void IFWL_ListBox::DrawWidget(CFX_Graphics* pGraphics, return; if (!m_pProperties->m_pThemeProvider) return; + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; pGraphics->SaveGraphState(); - if (HasBorder()) { + if (HasBorder()) DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); - } - if (HasEdge()) { + if (HasEdge()) DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); - } + CFX_RectF rtClip(m_rtConent); - if (IsShowScrollBar(false)) { + if (IsShowScrollBar(false)) rtClip.height -= m_fScorllBarWidth; - } - if (IsShowScrollBar(true)) { + if (IsShowScrollBar(true)) rtClip.width -= m_fScorllBarWidth; - } - if (pMatrix) { + if (pMatrix) pMatrix->TransformRect(rtClip); - } + pGraphics->SetClipRect(rtClip); - if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) { + if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) DrawBkground(pGraphics, pTheme, pMatrix); - } + DrawItems(pGraphics, pTheme, pMatrix); pGraphics->RestoreGraphState(); } @@ -138,69 +138,54 @@ void IFWL_ListBox::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { if (pThemeProvider) m_pProperties->m_pThemeProvider = pThemeProvider; } + int32_t IFWL_ListBox::CountSelItems() { if (!m_pProperties->m_pDataProvider) return 0; + int32_t iRet = 0; IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { CFWL_ListItem* pItem = pData->GetItem(this, i); - if (!pItem) { + if (!pItem) continue; - } + uint32_t dwStyle = pData->GetItemStyles(this, pItem); - if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { + if (dwStyle & FWL_ITEMSTATE_LTB_Selected) iRet++; - } } return iRet; } CFWL_ListItem* IFWL_ListBox::GetSelItem(int32_t nIndexSel) { - if (!m_pProperties->m_pDataProvider) + int32_t idx = GetSelIndex(nIndexSel); + if (idx < 0) return nullptr; - int32_t index = 0; IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - int32_t iCount = pData->CountItems(this); - for (int32_t i = 0; i < iCount; i++) { - CFWL_ListItem* pItem = pData->GetItem(this, i); - if (!pItem) { - return nullptr; - } - uint32_t dwStyle = pData->GetItemStyles(this, pItem); - if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { - if (index == nIndexSel) { - return pItem; - } else { - index++; - } - } - } - return nullptr; + return pData->GetItem(this, idx); } int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) { if (!m_pProperties->m_pDataProvider) return -1; + int32_t index = 0; IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { CFWL_ListItem* pItem = pData->GetItem(this, i); - if (!pItem) { + if (!pItem) return -1; - } + uint32_t dwStyle = pData->GetItemStyles(this, pItem); if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { - if (index == nIndex) { + if (index == nIndex) return i; - } else { - index++; - } + index++; } } return -1; @@ -218,20 +203,21 @@ void IFWL_ListBox::SetSelItem(CFWL_ListItem* pItem, bool bSelect) { } return; } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) SetSelectionDirect(pItem, bSelect); - } else { + else SetSelection(pItem, pItem, bSelect); - } } void IFWL_ListBox::GetItemText(CFWL_ListItem* pItem, CFX_WideString& wsText) { if (!m_pProperties->m_pDataProvider) return; + IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); if (!pItem) return; + pData->GetItemText(this, pItem, wsText); } @@ -260,7 +246,8 @@ CFWL_ListItem* IFWL_ListBox::GetItem(CFWL_ListItem* pItem, uint32_t dwKeyCode) { hRet = pData->GetItem(this, iDstItem); break; } - default: {} + default: + break; } return hRet; } @@ -323,18 +310,18 @@ void IFWL_ListBox::ClearSelection() { } void IFWL_ListBox::SelectAll() { - bool bMulti = m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection; - if (!bMulti) { + if (!m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) return; - } + IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(this); - if (iCount > 0) { - CFWL_ListItem* pItemStart = pData->GetItem(this, 0); - CFWL_ListItem* pItemEnd = pData->GetItem(this, iCount - 1); - SetSelection(pItemStart, pItemEnd, false); - } + if (iCount <= 0) + return; + + CFWL_ListItem* pItemStart = pData->GetItem(this, 0); + CFWL_ListItem* pItemEnd = pData->GetItem(this, iCount - 1); + SetSelection(pItemStart, pItemEnd, false); } CFWL_ListItem* IFWL_ListBox::GetFocusedItem() { @@ -345,9 +332,8 @@ CFWL_ListItem* IFWL_ListBox::GetFocusedItem() { CFWL_ListItem* pItem = pData->GetItem(this, i); if (!pItem) return nullptr; - if (pData->GetItemStyles(this, pItem) & FWL_ITEMSTATE_LTB_Focused) { + if (pData->GetItemStyles(this, pItem) & FWL_ITEMSTATE_LTB_Focused) return pItem; - } } return nullptr; } @@ -356,44 +342,44 @@ void IFWL_ListBox::SetFocusItem(CFWL_ListItem* pItem) { IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); CFWL_ListItem* hFocus = GetFocusedItem(); - if (pItem != hFocus) { - if (hFocus) { - uint32_t dwStyle = pData->GetItemStyles(this, hFocus); - dwStyle &= ~FWL_ITEMSTATE_LTB_Focused; - pData->SetItemStyles(this, hFocus, dwStyle); - } - if (pItem) { - uint32_t dwStyle = pData->GetItemStyles(this, pItem); - dwStyle |= FWL_ITEMSTATE_LTB_Focused; - pData->SetItemStyles(this, pItem, dwStyle); - } + if (pItem == hFocus) + return; + + if (hFocus) { + uint32_t dwStyle = pData->GetItemStyles(this, hFocus); + dwStyle &= ~FWL_ITEMSTATE_LTB_Focused; + pData->SetItemStyles(this, hFocus, dwStyle); + } + if (pItem) { + uint32_t dwStyle = pData->GetItemStyles(this, pItem); + dwStyle |= FWL_ITEMSTATE_LTB_Focused; + pData->SetItemStyles(this, pItem, dwStyle); } } CFWL_ListItem* IFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { fx -= m_rtConent.left, fy -= m_rtConent.top; FX_FLOAT fPosX = 0.0f; - if (m_pHorzScrollBar) { + if (m_pHorzScrollBar) fPosX = m_pHorzScrollBar->GetPos(); - } + FX_FLOAT fPosY = 0.0; - if (m_pVertScrollBar) { + if (m_pVertScrollBar) fPosY = m_pVertScrollBar->GetPos(); - } + IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t nCount = pData->CountItems(this); for (int32_t i = 0; i < nCount; i++) { CFWL_ListItem* pItem = pData->GetItem(this, i); - if (!pItem) { + if (!pItem) continue; - } + CFX_RectF rtItem; pData->GetItemRect(this, pItem, rtItem); rtItem.Offset(-fPosX, -fPosY); - if (rtItem.Contains(fx, fy)) { + if (rtItem.Contains(fx, fy)) return pItem; - } } return nullptr; } @@ -401,9 +387,9 @@ CFWL_ListItem* IFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { bool IFWL_ListBox::GetItemCheckRect(CFWL_ListItem* pItem, CFX_RectF& rtCheck) { if (!m_pProperties->m_pDataProvider) return false; - if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { + if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) return false; - } + IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); pData->GetItemCheckRect(this, pItem, rtCheck); @@ -413,9 +399,9 @@ bool IFWL_ListBox::GetItemCheckRect(CFWL_ListItem* pItem, CFX_RectF& rtCheck) { bool IFWL_ListBox::GetItemChecked(CFWL_ListItem* pItem) { if (!m_pProperties->m_pDataProvider) return false; - if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { + if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) return false; - } + IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); return !!(pData->GetItemCheckState(this, pItem) & FWL_ITEMSTATE_LTB_Checked); @@ -424,9 +410,9 @@ bool IFWL_ListBox::GetItemChecked(CFWL_ListItem* pItem) { bool IFWL_ListBox::SetItemChecked(CFWL_ListItem* pItem, bool bChecked) { if (!m_pProperties->m_pDataProvider) return false; - if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { + if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) return false; - } + IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); pData->SetItemCheckState(this, pItem, @@ -437,10 +423,12 @@ bool IFWL_ListBox::SetItemChecked(CFWL_ListItem* pItem, bool bChecked) { bool IFWL_ListBox::ScrollToVisible(CFWL_ListItem* pItem) { if (!m_pVertScrollBar) return false; + CFX_RectF rtItem; IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); pData->GetItemRect(this, pItem, rtItem); + bool bScroll = false; FX_FLOAT fPosY = m_pVertScrollBar->GetPos(); rtItem.Offset(0, -fPosY + m_rtConent.top); @@ -451,9 +439,9 @@ bool IFWL_ListBox::ScrollToVisible(CFWL_ListItem* pItem) { fPosY += rtItem.bottom() - m_rtConent.bottom(); bScroll = true; } - if (!bScroll) { + if (!bScroll) return false; - } + m_pVertScrollBar->SetPos(fPosY); m_pVertScrollBar->SetTrackPos(fPosY); Repaint(&m_rtClient); @@ -467,6 +455,7 @@ void IFWL_ListBox::DrawBkground(CFX_Graphics* pGraphics, return; if (!pTheme) return; + CFWL_ThemeBackground param; param.m_pWidget = this; param.m_iPart = CFWL_Part::Background; @@ -474,12 +463,11 @@ void IFWL_ListBox::DrawBkground(CFX_Graphics* pGraphics, param.m_pGraphics = pGraphics; param.m_matrix.Concat(*pMatrix); param.m_rtPart = m_rtClient; - if (IsShowScrollBar(false) && IsShowScrollBar(true)) { + if (IsShowScrollBar(false) && IsShowScrollBar(true)) param.m_pData = &m_rtStatic; - } - if (!IsEnabled()) { + if (!IsEnabled()) param.m_dwStates = CFWL_PartState_Disabled; - } + pTheme->DrawBackground(¶m); } @@ -487,20 +475,19 @@ void IFWL_ListBox::DrawItems(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix) { FX_FLOAT fPosX = 0.0f; - if (m_pHorzScrollBar) { + if (m_pHorzScrollBar) fPosX = m_pHorzScrollBar->GetPos(); - } + FX_FLOAT fPosY = 0.0f; - if (m_pVertScrollBar) { + if (m_pVertScrollBar) fPosY = m_pVertScrollBar->GetPos(); - } + CFX_RectF rtView(m_rtConent); - if (m_pHorzScrollBar) { + if (m_pHorzScrollBar) rtView.height -= m_fScorllBarWidth; - } - if (m_pVertScrollBar) { + if (m_pVertScrollBar) rtView.width -= m_fScorllBarWidth; - } + bool bMultiCol = !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn); IFWL_ListBoxDP* pData = @@ -508,21 +495,19 @@ void IFWL_ListBox::DrawItems(CFX_Graphics* pGraphics, int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { CFWL_ListItem* pItem = pData->GetItem(this, i); - if (!pItem) { + if (!pItem) continue; - } + CFX_RectF rtItem; pData->GetItemRect(this, pItem, rtItem); rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY); - if (rtItem.bottom() < m_rtConent.top) { + if (rtItem.bottom() < m_rtConent.top) continue; - } - if (rtItem.top >= m_rtConent.bottom()) { + if (rtItem.top >= m_rtConent.bottom()) break; - } - if (bMultiCol && rtItem.left > m_rtConent.right()) { + if (bMultiCol && rtItem.left > m_rtConent.right()) break; - } + if (GetStylesEx() & FWL_STYLEEXT_LTB_OwnerDraw) { CFWL_EvtLtbDrawItem ev; ev.m_pSrcTarget = this; @@ -547,95 +532,94 @@ void IFWL_ListBox::DrawItem(CFX_Graphics* pGraphics, static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); uint32_t dwItemStyles = pData->GetItemStyles(this, pItem); uint32_t dwPartStates = CFWL_PartState_Normal; - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) dwPartStates = CFWL_PartState_Disabled; - } else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) { + else if (dwItemStyles & FWL_ITEMSTATE_LTB_Selected) dwPartStates = CFWL_PartState_Selected; - } + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused && dwItemStyles & FWL_ITEMSTATE_LTB_Focused) { dwPartStates |= CFWL_PartState_Focused; } - { - CFWL_ThemeBackground param; - param.m_pWidget = this; - param.m_iPart = CFWL_Part::ListItem; - param.m_dwStates = dwPartStates; - param.m_pGraphics = pGraphics; - param.m_matrix.Concat(*pMatrix); - param.m_rtPart = rtItem; - param.m_bMaximize = true; - CFX_RectF rtFocus(rtItem); - param.m_pData = &rtFocus; - if (m_pVertScrollBar && !m_pHorzScrollBar && - (dwPartStates & CFWL_PartState_Focused)) { - param.m_rtPart.left += 1; - param.m_rtPart.width -= (m_fScorllBarWidth + 1); - rtFocus.Deflate(0.5, 0.5, 1 + m_fScorllBarWidth, 1); - } - pTheme->DrawBackground(¶m); - } - { - bool bHasIcon = !!(GetStylesEx() & FWL_STYLEEXT_LTB_Icon); - if (bHasIcon) { - CFX_RectF rtDIB; - CFX_DIBitmap* pDib = pData->GetItemIcon(this, pItem); - rtDIB.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); - if (pDib) { - CFWL_ThemeBackground param; - param.m_pWidget = this; - param.m_iPart = CFWL_Part::Icon; - param.m_pGraphics = pGraphics; - param.m_matrix.Concat(*pMatrix); - param.m_rtPart = rtDIB; - param.m_bMaximize = true; - param.m_pImage = pDib; - pTheme->DrawBackground(¶m); - } - } - bool bHasCheck = !!(GetStylesEx() & FWL_STYLEEXT_LTB_Check); - if (bHasCheck) { - CFX_RectF rtCheck; - rtCheck.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); - rtCheck.Deflate(2, 2, 2, 2); - pData->SetItemCheckRect(this, pItem, rtCheck); + + CFWL_ThemeBackground bg_param; + bg_param.m_pWidget = this; + bg_param.m_iPart = CFWL_Part::ListItem; + bg_param.m_dwStates = dwPartStates; + bg_param.m_pGraphics = pGraphics; + bg_param.m_matrix.Concat(*pMatrix); + bg_param.m_rtPart = rtItem; + bg_param.m_bMaximize = true; + CFX_RectF rtFocus(rtItem); + bg_param.m_pData = &rtFocus; + if (m_pVertScrollBar && !m_pHorzScrollBar && + (dwPartStates & CFWL_PartState_Focused)) { + bg_param.m_rtPart.left += 1; + bg_param.m_rtPart.width -= (m_fScorllBarWidth + 1); + rtFocus.Deflate(0.5, 0.5, 1 + m_fScorllBarWidth, 1); + } + pTheme->DrawBackground(&bg_param); + + bool bHasIcon = !!(GetStylesEx() & FWL_STYLEEXT_LTB_Icon); + if (bHasIcon) { + CFX_RectF rtDIB; + CFX_DIBitmap* pDib = pData->GetItemIcon(this, pItem); + rtDIB.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); + if (pDib) { CFWL_ThemeBackground param; param.m_pWidget = this; - param.m_iPart = CFWL_Part::Check; + param.m_iPart = CFWL_Part::Icon; param.m_pGraphics = pGraphics; - if (GetItemChecked(pItem)) { - param.m_dwStates = CFWL_PartState_Checked; - } else { - param.m_dwStates = CFWL_PartState_Normal; - } param.m_matrix.Concat(*pMatrix); - param.m_rtPart = rtCheck; + param.m_rtPart = rtDIB; param.m_bMaximize = true; + param.m_pImage = pDib; pTheme->DrawBackground(¶m); } - CFX_WideString wsText; - pData->GetItemText(this, pItem, wsText); - if (wsText.GetLength() <= 0) { - return; - } - CFX_RectF rtText(rtItem); - rtText.Deflate(kItemTextMargin, kItemTextMargin); - if (bHasIcon || bHasCheck) { - rtText.Deflate(rtItem.height, 0, 0, 0); - } - CFWL_ThemeText textParam; - textParam.m_pWidget = this; - textParam.m_iPart = CFWL_Part::ListItem; - textParam.m_dwStates = dwPartStates; - textParam.m_pGraphics = pGraphics; - textParam.m_matrix.Concat(*pMatrix); - textParam.m_rtPart = rtText; - textParam.m_wsText = wsText; - textParam.m_dwTTOStyles = m_dwTTOStyles; - textParam.m_iTTOAlign = m_iTTOAligns; - textParam.m_bMaximize = true; - pTheme->DrawText(&textParam); } + + bool bHasCheck = !!(GetStylesEx() & FWL_STYLEEXT_LTB_Check); + if (bHasCheck) { + CFX_RectF rtCheck; + rtCheck.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); + rtCheck.Deflate(2, 2, 2, 2); + pData->SetItemCheckRect(this, pItem, rtCheck); + CFWL_ThemeBackground param; + param.m_pWidget = this; + param.m_iPart = CFWL_Part::Check; + param.m_pGraphics = pGraphics; + if (GetItemChecked(pItem)) + param.m_dwStates = CFWL_PartState_Checked; + else + param.m_dwStates = CFWL_PartState_Normal; + param.m_matrix.Concat(*pMatrix); + param.m_rtPart = rtCheck; + param.m_bMaximize = true; + pTheme->DrawBackground(¶m); + } + + CFX_WideString wsText; + pData->GetItemText(this, pItem, wsText); + if (wsText.GetLength() <= 0) + return; + + CFX_RectF rtText(rtItem); + rtText.Deflate(kItemTextMargin, kItemTextMargin); + if (bHasIcon || bHasCheck) + rtText.Deflate(rtItem.height, 0, 0, 0); + + CFWL_ThemeText textParam; + textParam.m_pWidget = this; + textParam.m_iPart = CFWL_Part::ListItem; + textParam.m_dwStates = dwPartStates; + textParam.m_pGraphics = pGraphics; + textParam.m_matrix.Concat(*pMatrix); + textParam.m_rtPart = rtText; + textParam.m_wsText = wsText; + textParam.m_dwTTOStyles = m_dwTTOStyles; + textParam.m_iTTOAlign = m_iTTOAligns; + textParam.m_bMaximize = true; + pTheme->DrawText(&textParam); } CFX_SizeF IFWL_ListBox::CalcSize(bool bAutoSize) { @@ -655,6 +639,7 @@ CFX_SizeF IFWL_ListBox::CalcSize(bool bAutoSize) { pUIMargin->height); } } + FX_FLOAT fWidth = 0; if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(this)) { IFWL_ListBoxDP* pData = @@ -680,10 +665,9 @@ CFX_SizeF IFWL_ListBox::CalcSize(bool bAutoSize) { if (!bAutoSize) { FX_FLOAT fActualWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width; - if (fWidth < fActualWidth) { - fWidth = fActualWidth; - } + fWidth = std::max(fWidth, fActualWidth); } + IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); m_fItemHeight = CalcItemHeight(); @@ -696,9 +680,9 @@ CFX_SizeF IFWL_ListBox::CalcSize(bool bAutoSize) { GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize); } } - if (bAutoSize) { + if (bAutoSize) return fs; - } + FX_FLOAT iWidth = m_rtClient.width - rtUIMargin.left - rtUIMargin.width; FX_FLOAT iHeight = m_rtClient.height; bool bShowVertScr = @@ -711,35 +695,30 @@ CFX_SizeF IFWL_ListBox::CalcSize(bool bAutoSize) { (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) == 0) { bShowVertScr = (fs.y > iHeight); } - if (!bShowHorzScr && m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) { + if (!bShowHorzScr && m_pProperties->m_dwStyles & FWL_WGTSTYLE_HScroll) bShowHorzScr = (fs.x > iWidth); - } + CFX_SizeF szRange; if (bShowVertScr) { - if (!m_pVertScrollBar) { + if (!m_pVertScrollBar) InitScrollBar(); - } + CFX_RectF rtScrollBar; rtScrollBar.Set(m_rtClient.right() - m_fScorllBarWidth, m_rtClient.top, m_fScorllBarWidth, m_rtClient.height - 1); - if (bShowHorzScr) { + if (bShowHorzScr) rtScrollBar.height -= m_fScorllBarWidth; - } + m_pVertScrollBar->SetWidgetRect(rtScrollBar); szRange.x = 0, szRange.y = fs.y - m_rtConent.height; - if (szRange.y < m_fItemHeight) { - szRange.y = m_fItemHeight; - } + szRange.y = std::max(szRange.y, m_fItemHeight); + m_pVertScrollBar->SetRange(szRange.x, szRange.y); m_pVertScrollBar->SetPageSize(rtScrollBar.height * 9 / 10); m_pVertScrollBar->SetStepSize(m_fItemHeight); - FX_FLOAT fPos = m_pVertScrollBar->GetPos(); - if (fPos < 0) { - fPos = 0; - } - if (fPos > szRange.y) { - fPos = szRange.y; - } + + FX_FLOAT fPos = + std::min(std::max(m_pVertScrollBar->GetPos(), 0.f), szRange.y); m_pVertScrollBar->SetPos(fPos); m_pVertScrollBar->SetTrackPos(fPos); if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == @@ -754,27 +733,23 @@ CFX_SizeF IFWL_ListBox::CalcSize(bool bAutoSize) { m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, true); } if (bShowHorzScr) { - if (!m_pHorzScrollBar) { + if (!m_pHorzScrollBar) InitScrollBar(false); - } + CFX_RectF rtScrollBar; rtScrollBar.Set(m_rtClient.left, m_rtClient.bottom() - m_fScorllBarWidth, m_rtClient.width, m_fScorllBarWidth); - if (bShowVertScr) { + if (bShowVertScr) rtScrollBar.width -= m_fScorllBarWidth; - } + m_pHorzScrollBar->SetWidgetRect(rtScrollBar); szRange.x = 0, szRange.y = fs.x - rtScrollBar.width; m_pHorzScrollBar->SetRange(szRange.x, szRange.y); m_pHorzScrollBar->SetPageSize(fWidth * 9 / 10); m_pHorzScrollBar->SetStepSize(fWidth / 10); - FX_FLOAT fPos = m_pHorzScrollBar->GetPos(); - if (fPos < 0) { - fPos = 0; - } - if (fPos > szRange.y) { - fPos = szRange.y; - } + + FX_FLOAT fPos = + std::min(std::max(m_pHorzScrollBar->GetPos(), 0.f), szRange.y); m_pHorzScrollBar->SetPos(fPos); m_pHorzScrollBar->SetTrackPos(fPos); if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == @@ -801,18 +776,18 @@ void IFWL_ListBox::GetItemSize(CFX_SizeF& size, FX_FLOAT fWidth, FX_FLOAT fItemHeight, bool bAutoSize) { - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) { - } else { - if (!bAutoSize) { - CFX_RectF rtItem; - rtItem.Set(0, size.y, fWidth, fItemHeight); - IFWL_ListBoxDP* pData = - static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - pData->SetItemRect(this, pItem, rtItem); - } - size.x = fWidth; - size.y += fItemHeight; + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiColumn) + return; + + if (!bAutoSize) { + CFX_RectF rtItem; + rtItem.Set(0, size.y, fWidth, fItemHeight); + IFWL_ListBoxDP* pData = + static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); + pData->SetItemRect(this, pItem, rtItem); } + size.x = fWidth; + size.y += fItemHeight; } FX_FLOAT IFWL_ListBox::GetMaxTextWidth() { @@ -822,15 +797,13 @@ FX_FLOAT IFWL_ListBox::GetMaxTextWidth() { int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { CFWL_ListItem* pItem = pData->GetItem(this, i); - if (!pItem) { + if (!pItem) continue; - } + CFX_WideString wsText; pData->GetItemText(this, pItem, wsText); CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider); - if (sz.x > fRet) { - fRet = sz.x; - } + fRet = std::max(fRet, sz.x); } return fRet; } @@ -852,9 +825,9 @@ FX_FLOAT IFWL_ListBox::CalcItemHeight() { } void IFWL_ListBox::InitScrollBar(bool bVert) { - if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { + if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) return; - } + auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); prop->m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; prop->m_dwStates = FWL_WGTSTATE_Invisible; @@ -870,9 +843,8 @@ void IFWL_ListBox::InitScrollBar(bool bVert) { bool IFWL_ListBox::IsShowScrollBar(bool bVert) { IFWL_ScrollBar* pScrollbar = bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); - if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { + if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) return false; - } return !(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) || (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); @@ -885,9 +857,8 @@ void IFWL_ListBox::ProcessSelChanged() { int32_t iCount = CountSelItems(); for (int32_t i = 0; i < iCount; i++) { CFWL_ListItem* item = GetSelItem(i); - if (!item) { + if (!item) continue; - } selEvent.iarraySels.Add(i); } DispatchEvent(&selEvent); @@ -1056,6 +1027,7 @@ void IFWL_ListBox::OnVK(CFWL_ListItem* pItem, bool bShift, bool bCtrl) { if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { if (bCtrl) { + // Do nothing. } else if (bShift) { if (m_hAnchor) SetSelection(m_hAnchor, pItem, true); diff --git a/xfa/fwl/core/ifwl_monthcalendar.cpp b/xfa/fwl/core/ifwl_monthcalendar.cpp index cec6c4ca69..c5c7780b57 100644 --- a/xfa/fwl/core/ifwl_monthcalendar.cpp +++ b/xfa/fwl/core/ifwl_monthcalendar.cpp @@ -160,27 +160,28 @@ FWL_Type IFWL_MonthCalendar::GetClassID() const { } void IFWL_MonthCalendar::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (bAutoSize) { - CFX_SizeF fs = CalcSize(true); - rect.Set(0, 0, fs.x, fs.y); - IFWL_Widget::GetWidgetRect(rect, true); - } else { + if (!bAutoSize) { rect = m_pProperties->m_rtWidget; + return; } + + CFX_SizeF fs = CalcSize(true); + rect.Set(0, 0, fs.x, fs.y); + IFWL_Widget::GetWidgetRect(rect, true); } void IFWL_MonthCalendar::Update() { - if (IsLocked()) { + if (IsLocked()) return; - } - if (!m_pProperties->m_pThemeProvider) { + if (!m_pProperties->m_pThemeProvider) m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } + GetCapValue(); if (!m_bInitialized) { InitDate(); m_bInitialized = true; } + ClearDateItem(); ResetDateItem(); Layout(); @@ -190,17 +191,16 @@ void IFWL_MonthCalendar::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!pGraphics) return; - if (!m_pProperties->m_pThemeProvider) { + if (!m_pProperties->m_pThemeProvider) m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - if (HasBorder()) { + if (HasBorder()) DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); - } - if (HasEdge()) { + if (HasEdge()) DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); - } - DrawBkground(pGraphics, pTheme, pMatrix); + + DrawBackground(pGraphics, pTheme, pMatrix); DrawHeadBK(pGraphics, pTheme, pMatrix); DrawLButton(pGraphics, pTheme, pMatrix); DrawRButton(pGraphics, pTheme, pMatrix); @@ -225,18 +225,17 @@ void IFWL_MonthCalendar::SetSelect(int32_t iYear, AddSelDay(iDay); } -void IFWL_MonthCalendar::DrawBkground(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { +void IFWL_MonthCalendar::DrawBackground(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix) { CFWL_ThemeBackground params; params.m_pWidget = this; params.m_iPart = CFWL_Part::Background; params.m_pGraphics = pGraphics; params.m_dwStates = CFWL_PartState_Normal; params.m_rtPart = m_rtClient; - if (pMatrix) { + if (pMatrix) params.m_matrix.Concat(*pMatrix); - } pTheme->DrawBackground(¶ms); } @@ -249,9 +248,8 @@ void IFWL_MonthCalendar::DrawHeadBK(CFX_Graphics* pGraphics, params.m_pGraphics = pGraphics; params.m_dwStates = CFWL_PartState_Normal; params.m_rtPart = m_rtHead; - if (pMatrix) { + if (pMatrix) params.m_matrix.Concat(*pMatrix); - } pTheme->DrawBackground(¶ms); } @@ -264,9 +262,8 @@ void IFWL_MonthCalendar::DrawLButton(CFX_Graphics* pGraphics, params.m_pGraphics = pGraphics; params.m_dwStates = m_iLBtnPartStates; params.m_rtPart = m_rtLBtn; - if (pMatrix) { + if (pMatrix) params.m_matrix.Concat(*pMatrix); - } pTheme->DrawBackground(¶ms); } @@ -279,9 +276,8 @@ void IFWL_MonthCalendar::DrawRButton(CFX_Graphics* pGraphics, params.m_pGraphics = pGraphics; params.m_dwStates = m_iRBtnPartStates; params.m_rtPart = m_rtRBtn; - if (pMatrix) { + if (pMatrix) params.m_matrix.Concat(*pMatrix); - } pTheme->DrawBackground(¶ms); } @@ -305,9 +301,8 @@ void IFWL_MonthCalendar::DrawCaption(CFX_Graphics* pGraphics, textParam.m_rtPart = m_rtHeadText; textParam.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; textParam.m_iTTOAlign = FDE_TTOALIGNMENT_Center; - if (pMatrix) { + if (pMatrix) textParam.m_matrix.Concat(*pMatrix); - } pTheme->DrawText(&textParam); } @@ -320,9 +315,8 @@ void IFWL_MonthCalendar::DrawSeperator(CFX_Graphics* pGraphics, params.m_pGraphics = pGraphics; params.m_dwStates = CFWL_PartState_Normal; params.m_rtPart = m_rtHSep; - if (pMatrix) { + if (pMatrix) params.m_matrix.Concat(*pMatrix); - } pTheme->DrawBackground(¶ms); } @@ -333,9 +327,9 @@ void IFWL_MonthCalendar::DrawDatesInBK(CFX_Graphics* pGraphics, params.m_pWidget = this; params.m_iPart = CFWL_Part::DateInBK; params.m_pGraphics = pGraphics; - if (pMatrix) { + if (pMatrix) params.m_matrix.Concat(*pMatrix); - } + int32_t iCount = m_arrDates.GetSize(); for (int32_t j = 0; j < iCount; j++) { DATEINFO* pDataInfo = m_arrDates.GetAt(j); @@ -346,9 +340,8 @@ void IFWL_MonthCalendar::DrawDatesInBK(CFX_Graphics* pGraphics, pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) { params.m_dwStates |= CFWL_PartState_Flagged; } - if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Focused) { + if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Focused) params.m_dwStates |= CFWL_PartState_Focused; - } } else if (j == m_iHovered - 1) { params.m_dwStates |= CFWL_PartState_Hovered; } else if (pDataInfo->dwStates & FWL_ITEMSTATE_MCD_Flag) { @@ -371,9 +364,9 @@ void IFWL_MonthCalendar::DrawWeek(CFX_Graphics* pGraphics, params.m_dwStates = CFWL_PartState_Normal; params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; CFX_RectF rtDayOfWeek; - if (pMatrix) { + if (pMatrix) params.m_matrix.Concat(*pMatrix); - } + for (int32_t i = 0; i < 7; i++) { rtDayOfWeek.Set(m_rtWeek.left + i * (m_szCell.x + MONTHCAL_HMARGIN * 2), m_rtWeek.top, m_szCell.x, m_szCell.y); @@ -396,9 +389,9 @@ void IFWL_MonthCalendar::DrawWeekNumber(CFX_Graphics* pGraphics, CFX_WideString wsWeekNum; params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; - if (pMatrix) { + if (pMatrix) params.m_matrix.Concat(*pMatrix); - } + int32_t iMonthNum = m_pDateTime->GetMonth(); int32_t iDayNum = FX_DaysInMonth(m_iCurYear, iMonthNum); int32_t iTemp = 0; @@ -424,36 +417,36 @@ void IFWL_MonthCalendar::DrawWeekNumberSep(CFX_Graphics* pGraphics, params.m_pGraphics = pGraphics; params.m_dwStates = CFWL_PartState_Normal; params.m_rtPart = m_rtWeekNumSep; - if (pMatrix) { + if (pMatrix) params.m_matrix.Concat(*pMatrix); - } pTheme->DrawBackground(¶ms); } void IFWL_MonthCalendar::DrawToday(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix) { - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoToday) return; - } + CFWL_ThemeText params; params.m_pWidget = this; params.m_iPart = CFWL_Part::Today; params.m_pGraphics = pGraphics; params.m_dwStates = CFWL_PartState_Normal; params.m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; + CFX_WideString* wsDay = static_cast<CFX_WideString*>( pTheme->GetCapacity(¶ms, CFWL_WidgetCapacity::Today)); CFX_WideString wsText; GetTodayText(m_iYear, m_iMonth, m_iDay, wsText); params.m_wsText = *wsDay + wsText; + m_szToday = CalcTextSize(params.m_wsText, m_pProperties->m_pThemeProvider); CalcTodaySize(); params.m_rtPart = m_rtToday; params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; - if (pMatrix) { + if (pMatrix) params.m_matrix.Concat(*pMatrix); - } pTheme->DrawText(¶ms); } @@ -466,18 +459,17 @@ void IFWL_MonthCalendar::DrawDatesIn(CFX_Graphics* pGraphics, params.m_pGraphics = pGraphics; params.m_dwStates = CFWL_PartState_Normal; params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; - if (pMatrix) { + if (pMatrix) params.m_matrix.Concat(*pMatrix); - } + int32_t iCount = m_arrDates.GetSize(); for (int32_t j = 0; j < iCount; j++) { DATEINFO* pDataInfo = m_arrDates.GetAt(j); params.m_wsText = pDataInfo->wsDay; params.m_rtPart = pDataInfo->rect; params.m_dwStates = pDataInfo->dwStates; - if (j + 1 == m_iHovered) { + if (j + 1 == m_iHovered) params.m_dwStates |= CFWL_PartState_Hovered; - } params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; pTheme->DrawText(¶ms); } @@ -492,43 +484,39 @@ void IFWL_MonthCalendar::DrawDatesOut(CFX_Graphics* pGraphics, params.m_pGraphics = pGraphics; params.m_dwStates = CFWL_PartState_Normal; params.m_iTTOAlign = FDE_TTOALIGNMENT_Center; - if (pMatrix) { + if (pMatrix) params.m_matrix.Concat(*pMatrix); - } pTheme->DrawText(¶ms); } void IFWL_MonthCalendar::DrawDatesInCircle(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix) { - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_NoTodayCircle) return; - } - if (m_iMonth != m_iCurMonth || m_iYear != m_iCurYear) { + if (m_iMonth != m_iCurMonth || m_iYear != m_iCurYear) return; - } - if (m_iDay < 1 || m_iDay > m_arrDates.GetSize()) { + if (m_iDay < 1 || m_iDay > m_arrDates.GetSize()) return; - } + DATEINFO* pDate = m_arrDates[m_iDay - 1]; if (!pDate) return; + CFWL_ThemeBackground params; params.m_pWidget = this; params.m_iPart = CFWL_Part::DateInCircle; params.m_pGraphics = pGraphics; params.m_rtPart = pDate->rect; params.m_dwStates = CFWL_PartState_Normal; - if (pMatrix) { + if (pMatrix) params.m_matrix.Concat(*pMatrix); - } pTheme->DrawBackground(¶ms); } CFX_SizeF IFWL_MonthCalendar::CalcSize(bool bAutoSize) { if (!m_pProperties->m_pThemeProvider) return CFX_SizeF(); - if (!bAutoSize) { GetClientRect(m_rtClient); return CFX_SizeF(m_rtClient.width, m_rtClient.height); @@ -572,13 +560,16 @@ CFX_SizeF IFWL_MonthCalendar::CalcSize(bool bAutoSize) { fMonthMaxW = (fMonthMaxW >= sz.x) ? fMonthMaxW : sz.x; fMonthMaxH = (fMonthMaxH >= sz.y) ? fMonthMaxH : sz.y; } + CFX_WideString wsYear; GetHeadText(m_iYear, m_iMonth, wsYear); + CFX_SizeF szYear = CalcTextSize(wsYear, m_pProperties->m_pThemeProvider); fMonthMaxH = std::max(fMonthMaxH, szYear.y); m_szHead = CFX_SizeF(fMonthMaxW + szYear.x, fMonthMaxH); fMonthMaxW = m_szHead.x + MONTHCAL_HEADER_BTN_HMARGIN * 2 + m_szCell.x * 2; fs.x = std::max(fs.x, fMonthMaxW); + CFX_WideString wsToday; GetTodayText(m_iYear, m_iMonth, m_iDay, wsToday); CFX_WideString* wsText = static_cast<CFX_WideString*>( @@ -614,33 +605,32 @@ void IFWL_MonthCalendar::CalcTodaySize() { void IFWL_MonthCalendar::Layout() { GetClientRect(m_rtClient); - { - m_rtHead.Set( - m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtClient.top, - m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, - m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2); - m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, - m_rtHead.bottom(), - m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, - m_szCell.y + MONTHCAL_VMARGIN * 2); - m_rtLBtn.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, - m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, - m_szCell.x); - m_rtRBtn.Set(m_rtClient.left + m_rtClient.width - - MONTHCAL_HEADER_BTN_HMARGIN - m_szCell.x, - m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, - m_szCell.x); - m_rtHSep.Set( - m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN, - m_rtWeek.bottom() - MONTHCAL_VMARGIN, - m_rtClient.width - (MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN) * 2, - MONTHCAL_HSEP_HEIGHT); - m_rtDates.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, - m_rtWeek.bottom(), - m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, - m_szCell.y * (MONTHCAL_ROWS - 3) + - MONTHCAL_VMARGIN * (MONTHCAL_ROWS - 3) * 2); - } + + m_rtHead.Set( + m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtClient.top, + m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, + m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2); + m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtHead.bottom(), + m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, + m_szCell.y + MONTHCAL_VMARGIN * 2); + m_rtLBtn.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, + m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, + m_szCell.x); + m_rtRBtn.Set(m_rtClient.left + m_rtClient.width - + MONTHCAL_HEADER_BTN_HMARGIN - m_szCell.x, + m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, + m_szCell.x); + m_rtHSep.Set( + m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN, + m_rtWeek.bottom() - MONTHCAL_VMARGIN, + m_rtClient.width - (MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN) * 2, + MONTHCAL_HSEP_HEIGHT); + m_rtDates.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, + m_rtWeek.bottom(), + m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, + m_szCell.y * (MONTHCAL_ROWS - 3) + + MONTHCAL_VMARGIN * (MONTHCAL_ROWS - 3) * 2); + CalDateItem(); } @@ -661,19 +651,17 @@ void IFWL_MonthCalendar::CalDateItem() { fTop + iWeekOfMonth * (m_szCell.y + (MONTHCAL_VMARGIN * 2)), m_szCell.x + (MONTHCAL_HMARGIN * 2), m_szCell.y + (MONTHCAL_VMARGIN * 2)); - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) pDateInfo->rect.Offset(m_fWeekNumWid, 0); - } - if (pDateInfo->iDayOfWeek >= 6) { + if (pDateInfo->iDayOfWeek >= 6) bNewWeek = true; - } } } void IFWL_MonthCalendar::GetCapValue() { - if (!m_pProperties->m_pThemeProvider) { + if (!m_pProperties->m_pThemeProvider) m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; CFWL_ThemePart part; part.m_pWidget = this; @@ -727,9 +715,9 @@ void IFWL_MonthCalendar::GetCapValue() { pTheme->GetCapacity(&part, CFWL_WidgetCapacity::TodayFlagWidth)); m_fMCWid = *static_cast<FX_FLOAT*>( pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Width)); - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_WeekNumbers) m_fMCWid += m_fWeekNumWid; - } + m_fMCHei = *static_cast<FX_FLOAT*>( pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Height)); } @@ -759,7 +747,6 @@ void IFWL_MonthCalendar::InitDate() { void IFWL_MonthCalendar::ClearDateItem() { for (int32_t i = 0; i < m_arrDates.GetSize(); i++) delete m_arrDates.GetAt(i); - m_arrDates.RemoveAll(); } @@ -768,18 +755,17 @@ void IFWL_MonthCalendar::ResetDateItem() { int32_t iDays = FX_DaysInMonth(m_iCurYear, m_iCurMonth); int32_t iDayOfWeek = m_pDateTime->GetDayOfWeek(); for (int32_t i = 0; i < iDays; i++) { - if (iDayOfWeek >= 7) { + if (iDayOfWeek >= 7) iDayOfWeek = 0; - } + CFX_WideString wsDay; wsDay.Format(L"%d", i + 1); uint32_t dwStates = 0; - if (m_iYear == m_iCurYear && m_iMonth == m_iCurMonth && m_iDay == (i + 1)) { + if (m_iYear == m_iCurYear && m_iMonth == m_iCurMonth && m_iDay == (i + 1)) dwStates |= FWL_ITEMSTATE_MCD_Flag; - } - if (m_arrSelDays.Find(i + 1) != -1) { + if (m_arrSelDays.Find(i + 1) != -1) dwStates |= FWL_ITEMSTATE_MCD_Selected; - } + CFX_RectF rtDate; rtDate.Set(0, 0, 0, 0); m_arrDates.Add(new DATEINFO(i + 1, iDayOfWeek, dwStates, rtDate, wsDay)); @@ -796,9 +782,9 @@ void IFWL_MonthCalendar::NextMonth() { iMonth++; } DATE dt(m_iCurYear, m_iCurMonth, 1); - if (!(dt < m_dtMax)) { + if (!(dt < m_dtMax)) return; - } + m_iCurYear = iYear, m_iCurMonth = iMonth; ChangeToMonth(m_iCurYear, m_iCurMonth); } @@ -811,10 +797,11 @@ void IFWL_MonthCalendar::PrevMonth() { } else { iMonth--; } + DATE dt(m_iCurYear, m_iCurMonth, 1); - if (!(dt > m_dtMin)) { + if (!(dt > m_dtMin)) return; - } + m_iCurYear = iYear, m_iCurMonth = iMonth; ChangeToMonth(m_iCurYear, m_iCurMonth); } @@ -823,6 +810,7 @@ void IFWL_MonthCalendar::ChangeToMonth(int32_t iYear, int32_t iMonth) { m_iCurYear = iYear; m_iCurMonth = iMonth; m_iHovered = -1; + ClearDateItem(); ResetDateItem(); CalDateItem(); @@ -830,9 +818,8 @@ void IFWL_MonthCalendar::ChangeToMonth(int32_t iYear, int32_t iMonth) { } void IFWL_MonthCalendar::RemoveSelDay(int32_t iDay, bool bAll) { - if (iDay == -1 && !bAll) { + if (iDay == -1 && !bAll) return; - } if (bAll) { int32_t iCount = m_arrSelDays.GetSize(); int32_t iDatesCount = m_arrDates.GetSize(); @@ -844,19 +831,20 @@ void IFWL_MonthCalendar::RemoveSelDay(int32_t iDay, bool bAll) { } } m_arrSelDays.RemoveAll(); - } else { - int32_t index = m_arrSelDays.Find(iDay); - if (index == -1) { - return; - } - int32_t iSelDay = m_arrSelDays.GetAt(iDay); - int32_t iDatesCount = m_arrDates.GetSize(); - if (iSelDay <= iDatesCount) { - DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1); - pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; - } - m_arrSelDays.RemoveAt(index); + return; + } + + int32_t index = m_arrSelDays.Find(iDay); + if (index == -1) + return; + + int32_t iSelDay = m_arrSelDays.GetAt(iDay); + int32_t iDatesCount = m_arrDates.GetSize(); + if (iSelDay <= iDatesCount) { + DATEINFO* pDateInfo = m_arrDates.GetAt(iSelDay - 1); + pDateInfo->dwStates &= ~FWL_ITEMSTATE_MCD_Selected; } + m_arrSelDays.RemoveAt(index); } void IFWL_MonthCalendar::AddSelDay(int32_t iDay) { @@ -864,14 +852,15 @@ void IFWL_MonthCalendar::AddSelDay(int32_t iDay) { if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_MCD_MultiSelect) return; - if (m_arrSelDays.Find(iDay) == -1) { - RemoveSelDay(-1, true); - if (iDay <= m_arrDates.GetSize()) { - DATEINFO* pDateInfo = m_arrDates.GetAt(iDay - 1); - pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected; - } - m_arrSelDays.Add(iDay); + if (m_arrSelDays.Find(iDay) != -1) + return; + + RemoveSelDay(-1, true); + if (iDay <= m_arrDates.GetSize()) { + DATEINFO* pDateInfo = m_arrDates.GetAt(iDay - 1); + pDateInfo->dwStates |= FWL_ITEMSTATE_MCD_Selected; } + m_arrSelDays.Add(iDay); } void IFWL_MonthCalendar::JumpToToday() { @@ -880,11 +869,11 @@ void IFWL_MonthCalendar::JumpToToday() { m_iCurMonth = m_iMonth; ChangeToMonth(m_iYear, m_iMonth); AddSelDay(m_iDay); - } else { - if (m_arrSelDays.Find(m_iDay) == -1) { - AddSelDay(m_iDay); - } + return; } + + if (m_arrSelDays.Find(m_iDay) == -1) + AddSelDay(m_iDay); } void IFWL_MonthCalendar::GetHeadText(int32_t iYear, @@ -909,9 +898,8 @@ int32_t IFWL_MonthCalendar::GetDayAtPoint(FX_FLOAT x, FX_FLOAT y) { int32_t iCount = m_arrDates.GetSize(); for (int32_t i = 0; i < iCount; i++) { DATEINFO* pDateInfo = m_arrDates.GetAt(i); - if (pDateInfo->rect.Contains(x, y)) { + if (pDateInfo->rect.Contains(x, y)) return ++i; - } } return -1; } diff --git a/xfa/fwl/core/ifwl_monthcalendar.h b/xfa/fwl/core/ifwl_monthcalendar.h index 78b2b6b3a0..096b3a04d7 100644 --- a/xfa/fwl/core/ifwl_monthcalendar.h +++ b/xfa/fwl/core/ifwl_monthcalendar.h @@ -101,9 +101,9 @@ class IFWL_MonthCalendar : public IFWL_Widget { CFX_WideString wsDay; }; - void DrawBkground(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix); + void DrawBackground(CFX_Graphics* pGraphics, + IFWL_ThemeProvider* pTheme, + const CFX_Matrix* pMatrix); void DrawHeadBK(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix); diff --git a/xfa/fwl/core/ifwl_picturebox.cpp b/xfa/fwl/core/ifwl_picturebox.cpp index 19db6f59fa..38685f73b1 100644 --- a/xfa/fwl/core/ifwl_picturebox.cpp +++ b/xfa/fwl/core/ifwl_picturebox.cpp @@ -26,23 +26,23 @@ FWL_Type IFWL_PictureBox::GetClassID() const { } void IFWL_PictureBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (bAutoSize) { - rect.Set(0, 0, 0, 0); - if (!m_pProperties->m_pDataProvider) - return; - IFWL_Widget::GetWidgetRect(rect, true); - } else { + if (!bAutoSize) { rect = m_pProperties->m_rtWidget; + return; } + + rect.Set(0, 0, 0, 0); + if (!m_pProperties->m_pDataProvider) + return; + IFWL_Widget::GetWidgetRect(rect, true); } void IFWL_PictureBox::Update() { - if (IsLocked()) { + if (IsLocked()) return; - } - if (!m_pProperties->m_pThemeProvider) { + if (!m_pProperties->m_pThemeProvider) m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } + GetClientRect(m_rtClient); } @@ -52,20 +52,12 @@ void IFWL_PictureBox::DrawWidget(CFX_Graphics* pGraphics, return; if (!m_pProperties->m_pThemeProvider) return; + IFWL_ThemeProvider* pTheme = GetAvailableTheme(); - if (HasBorder()) { + if (HasBorder()) DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); - } - if (HasEdge()) { + if (HasEdge()) DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); - } - DrawBkground(pGraphics, pTheme, pMatrix); -} - -void IFWL_PictureBox::DrawBkground(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix) { - return; } void IFWL_PictureBox::OnDrawWidget(CFX_Graphics* pGraphics, diff --git a/xfa/fwl/core/ifwl_picturebox.h b/xfa/fwl/core/ifwl_picturebox.h index 752880f40a..52ea6ff6b2 100644 --- a/xfa/fwl/core/ifwl_picturebox.h +++ b/xfa/fwl/core/ifwl_picturebox.h @@ -47,10 +47,6 @@ class IFWL_PictureBox : public IFWL_Widget { const CFX_Matrix* pMatrix) override; private: - void DrawBkground(CFX_Graphics* pGraphics, - IFWL_ThemeProvider* pTheme, - const CFX_Matrix* pMatrix = nullptr); - CFX_RectF m_rtClient; CFX_RectF m_rtImage; CFX_Matrix m_matrix; diff --git a/xfa/fwl/core/ifwl_pushbutton.cpp b/xfa/fwl/core/ifwl_pushbutton.cpp index 03bc7060d7..387a01af1f 100644 --- a/xfa/fwl/core/ifwl_pushbutton.cpp +++ b/xfa/fwl/core/ifwl_pushbutton.cpp @@ -33,29 +33,31 @@ FWL_Type IFWL_PushButton::GetClassID() const { } void IFWL_PushButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (bAutoSize) { - rect.Set(0, 0, 0, 0); - if (!m_pProperties->m_pThemeProvider) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - CFX_WideString wsCaption; - IFWL_PushButtonDP* pData = - static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); - if (pData) { - pData->GetCaption(this, wsCaption); - } - int32_t iLen = wsCaption.GetLength(); - if (iLen > 0) { - CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); - rect.Set(0, 0, sz.x, sz.y); - } - FX_FLOAT* fcaption = - static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin)); - rect.Inflate(*fcaption, *fcaption); - IFWL_Widget::GetWidgetRect(rect, true); - } else { + if (!bAutoSize) { rect = m_pProperties->m_rtWidget; + return; + } + + rect.Set(0, 0, 0, 0); + if (!m_pProperties->m_pThemeProvider) + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + + CFX_WideString wsCaption; + IFWL_PushButtonDP* pData = + static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); + if (pData) + pData->GetCaption(this, wsCaption); + + int32_t iLen = wsCaption.GetLength(); + if (iLen > 0) { + CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); + rect.Set(0, 0, sz.x, sz.y); } + + FX_FLOAT* fcaption = + static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::Margin)); + rect.Inflate(*fcaption, *fcaption); + IFWL_Widget::GetWidgetRect(rect, true); } void IFWL_PushButton::SetStates(uint32_t dwStates, bool bSet) { @@ -67,12 +69,11 @@ void IFWL_PushButton::SetStates(uint32_t dwStates, bool bSet) { } void IFWL_PushButton::Update() { - if (IsLocked()) { + if (IsLocked()) return; - } - if (!m_pProperties->m_pThemeProvider) { + if (!m_pProperties->m_pThemeProvider) m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } + UpdateTextOutStyles(); GetClientRect(m_rtClient); m_rtCaption = m_rtClient; @@ -87,6 +88,7 @@ void IFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics, return; if (!m_pProperties->m_pThemeProvider) return; + IFWL_PushButtonDP* pData = static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; @@ -103,9 +105,9 @@ void IFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics, matrix.Concat(*pMatrix); CFX_WideString wsCaption; - if (pData) { + if (pData) pData->GetCaption(this, wsCaption); - } + CFX_RectF rtText; rtText.Set(0, 0, 0, 0); if (!wsCaption.IsEmpty()) @@ -129,13 +131,11 @@ void IFWL_PushButton::DrawBkground(CFX_Graphics* pGraphics, param.m_iPart = CFWL_Part::Background; param.m_dwStates = GetPartStates(); param.m_pGraphics = pGraphics; - if (pMatrix) { + if (pMatrix) param.m_matrix.Concat(*pMatrix); - } param.m_rtPart = m_rtClient; - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) param.m_pData = &m_rtCaption; - } pTheme->DrawBackground(¶m); } @@ -144,19 +144,19 @@ void IFWL_PushButton::DrawText(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!m_pProperties->m_pDataProvider) return; + CFX_WideString wsCaption; m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); - if (wsCaption.IsEmpty()) { + if (wsCaption.IsEmpty()) return; - } + CFWL_ThemeText param; param.m_pWidget = this; param.m_iPart = CFWL_Part::Caption; param.m_dwStates = GetPartStates(); param.m_pGraphics = pGraphics; - if (pMatrix) { + if (pMatrix) param.m_matrix.Concat(*pMatrix); - } param.m_rtPart = m_rtCaption; param.m_wsText = wsCaption; param.m_dwTTOStyles = m_dwTTOStyles; @@ -166,23 +166,20 @@ void IFWL_PushButton::DrawText(CFX_Graphics* pGraphics, uint32_t IFWL_PushButton::GetPartStates() { uint32_t dwStates = CFWL_PartState_Normal; - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) dwStates |= CFWL_PartState_Focused; - } - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) dwStates = CFWL_PartState_Disabled; - } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) { + else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Pressed) dwStates |= CFWL_PartState_Pressed; - } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) { + else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Hovered) dwStates |= CFWL_PartState_Hovered; - } else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Default) { + else if (m_pProperties->m_dwStates & FWL_STATE_PSB_Default) dwStates |= CFWL_PartState_Default; - } return dwStates; } void IFWL_PushButton::UpdateTextOutStyles() { - m_iTTOAlign = FDE_TTOALIGNMENT_Center; switch (m_pProperties->m_dwStyleExes & (FWL_STYLEEXT_PSB_HLayoutMask | FWL_STYLEEXT_PSB_VLayoutMask)) { case FWL_STYLEEXT_PSB_Left | FWL_STYLEEXT_PSB_Top: { @@ -201,10 +198,6 @@ void IFWL_PushButton::UpdateTextOutStyles() { m_iTTOAlign = FDE_TTOALIGNMENT_CenterLeft; break; } - case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_VCenter: { - m_iTTOAlign = FDE_TTOALIGNMENT_Center; - break; - } case FWL_STYLEEXT_PSB_Right | FWL_STYLEEXT_PSB_VCenter: { m_iTTOAlign = FDE_TTOALIGNMENT_CenterRight; break; @@ -221,13 +214,15 @@ void IFWL_PushButton::UpdateTextOutStyles() { m_iTTOAlign = FDE_TTOALIGNMENT_BottomRight; break; } - default: + case FWL_STYLEEXT_PSB_Center | FWL_STYLEEXT_PSB_VCenter: + default: { + m_iTTOAlign = FDE_TTOALIGNMENT_Center; break; + } } m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; - if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { + if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) m_dwTTOStyles |= FDE_TTOSTYLE_RTL; - } } void IFWL_PushButton::OnProcessMessage(CFWL_Message* pMessage) { diff --git a/xfa/fwl/core/ifwl_scrollbar.cpp b/xfa/fwl/core/ifwl_scrollbar.cpp index c651abecb1..db2164be23 100644 --- a/xfa/fwl/core/ifwl_scrollbar.cpp +++ b/xfa/fwl/core/ifwl_scrollbar.cpp @@ -59,30 +59,29 @@ FWL_Type IFWL_ScrollBar::GetClassID() const { } void IFWL_ScrollBar::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (bAutoSize) { - rect.Set(0, 0, 0, 0); - FX_FLOAT* pfMinWidth = static_cast<FX_FLOAT*>( - GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); - if (!pfMinWidth) - return; - if (IsVertical()) { - rect.Set(0, 0, (*pfMinWidth), (*pfMinWidth) * 3); - } else { - rect.Set(0, 0, (*pfMinWidth) * 3, (*pfMinWidth)); - } - IFWL_Widget::GetWidgetRect(rect, true); - } else { + if (!bAutoSize) { rect = m_pProperties->m_rtWidget; + return; } + + rect.Set(0, 0, 0, 0); + FX_FLOAT* pfMinWidth = static_cast<FX_FLOAT*>( + GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); + if (!pfMinWidth) + return; + if (IsVertical()) + rect.Set(0, 0, (*pfMinWidth), (*pfMinWidth) * 3); + else + rect.Set(0, 0, (*pfMinWidth) * 3, (*pfMinWidth)); + IFWL_Widget::GetWidgetRect(rect, true); } void IFWL_ScrollBar::Update() { - if (IsLocked()) { + if (IsLocked()) return; - } - if (!m_pProperties->m_pThemeProvider) { + if (!m_pProperties->m_pThemeProvider) m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } + Layout(); } @@ -92,13 +91,12 @@ void IFWL_ScrollBar::DrawWidget(CFX_Graphics* pGraphics, return; if (!m_pProperties->m_pThemeProvider) return; + IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - if (HasBorder()) { + if (HasBorder()) DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); - } - if (HasEdge()) { + if (HasEdge()) DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); - } DrawTrack(pGraphics, pTheme, true, pMatrix); DrawTrack(pGraphics, pTheme, false, pMatrix); DrawArrowBtn(pGraphics, pTheme, true, pMatrix); @@ -148,9 +146,8 @@ void IFWL_ScrollBar::DrawArrowBtn(CFX_Graphics* pGraphics, param.m_pGraphics = pGraphics; param.m_matrix.Concat(*pMatrix); param.m_rtPart = bMinBtn ? m_rtMinBtn : m_rtMaxBtn; - if (param.m_rtPart.height > 0 && param.m_rtPart.width > 0) { + if (param.m_rtPart.height > 0 && param.m_rtPart.width > 0) pTheme->DrawBackground(¶m); - } } void IFWL_ScrollBar::DrawThumb(CFX_Graphics* pGraphics, @@ -225,54 +222,45 @@ void IFWL_ScrollBar::CalcThumbButtonRect(CFX_RectF& rect) { m_rtThumb.Empty(); return; } + FX_FLOAT fRange = m_fRangeMax - m_fRangeMin; memset(&rect, 0, sizeof(CFX_Rect)); if (fRange < 0) { - if (IsVertical()) { + if (IsVertical()) rect.Set(m_rtClient.left, m_rtMaxBtn.bottom(), m_rtClient.width, 0); - } else { + else rect.Set(m_rtMaxBtn.right(), m_rtClient.top, 0, m_rtClient.height); - } return; } + CFX_RectF rtClient = m_rtClient; FX_FLOAT fLength = IsVertical() ? rtClient.height : rtClient.width; FX_FLOAT fSize = m_fButtonLen; if (m_bCustomLayout) { if (IsVertical()) { fLength = fLength - m_rtMinBtn.height - m_rtMaxBtn.height; - if (fLength < m_rtMinBtn.height || fLength < m_rtMaxBtn.height) { + if (fLength < m_rtMinBtn.height || fLength < m_rtMaxBtn.height) fLength = 0.0f; - } } else { fLength = fLength - m_rtMinBtn.width - m_rtMaxBtn.width; - if (fLength < m_rtMinBtn.width || fLength < m_rtMaxBtn.width) { + if (fLength < m_rtMinBtn.width || fLength < m_rtMaxBtn.width) fLength = 0.0f; - } } } else { fLength -= fSize * 2.0f; - if (fLength < fSize) { + if (fLength < fSize) fLength = 0.0f; - } } + FX_FLOAT fThumbSize = fLength * fLength / (fRange + fLength); - if (fThumbSize < m_fMinThumb) { - fThumbSize = m_fMinThumb; - } - FX_FLOAT fDiff = fLength - fThumbSize; - if (fDiff < 0.0f) { - fDiff = 0.0f; - } - FX_FLOAT fTrackPos = m_fTrackPos; - if (fTrackPos > m_fRangeMax) { - fTrackPos = m_fRangeMax; - } - if (fTrackPos < m_fRangeMin) { - fTrackPos = m_fRangeMin; - } + fThumbSize = std::max(fThumbSize, m_fMinThumb); + + FX_FLOAT fDiff = std::max(fLength - fThumbSize, 0.0f); + FX_FLOAT fTrackPos = + std::max(std::min(m_fTrackPos, m_fRangeMax), m_fRangeMin); if (!fRange) return; + if (m_bCustomLayout) { FX_FLOAT iPos = fDiff * (fTrackPos - m_fRangeMin) / fRange; rect.left = rtClient.left; @@ -300,13 +288,13 @@ void IFWL_ScrollBar::CalcThumbButtonRect(CFX_RectF& rect) { } else { FX_FLOAT iPos = fSize + fDiff * (fTrackPos - m_fRangeMin) / fRange; rect.left = rtClient.left; - if (!IsVertical()) { + if (!IsVertical()) rect.left += iPos; - } + rect.top = rtClient.top; - if (IsVertical()) { + if (IsVertical()) rect.top += iPos; - } + rect.width = IsVertical() ? rtClient.width : fThumbSize; rect.height = IsVertical() ? fThumbSize : rtClient.height; } @@ -317,6 +305,7 @@ void IFWL_ScrollBar::CalcMinTrackRect(CFX_RectF& rect) { rect.Empty(); return; } + FX_FLOAT fBottom = m_rtThumb.bottom(); FX_FLOAT fRight = m_rtThumb.right(); FX_FLOAT ix = (m_rtThumb.left + fRight) / 2; @@ -326,22 +315,21 @@ void IFWL_ScrollBar::CalcMinTrackRect(CFX_RectF& rect) { bool bVertical = IsVertical(); rect.width = bVertical ? m_rtClient.width : ix; rect.height = bVertical ? iy : m_rtClient.height; - if (m_bCustomLayout) { - if (bVertical) { - if (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height) { - rect.top = m_rtClient.top; - } else if (m_rtMinBtn.top < m_rtThumb.top) { - rect.top = m_rtMinBtn.bottom(); - rect.height -= (m_rtMinBtn.bottom() - m_rtClient.top); - } - } else { - if (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width) { - rect.left = m_rtClient.left; - } else if (m_rtMinBtn.left < m_rtThumb.left) { - rect.left = m_rtMinBtn.right(); - rect.width -= (m_rtMinBtn.right() - m_rtClient.left); - } + if (!m_bCustomLayout) + return; + + if (bVertical) { + if (m_rtMinBtn.height == 0 && m_rtMaxBtn.height == 0) { + rect.top = m_rtClient.top; + } else if (m_rtMinBtn.top < m_rtThumb.top) { + rect.top = m_rtMinBtn.bottom(); + rect.height -= (m_rtMinBtn.bottom() - m_rtClient.top); } + } else if (m_rtMinBtn.width == 0 && m_rtMaxBtn.width == 0) { + rect.left = m_rtClient.left; + } else if (m_rtMinBtn.left < m_rtThumb.left) { + rect.left = m_rtMinBtn.right(); + rect.width -= (m_rtMinBtn.right() - m_rtClient.left); } } @@ -350,6 +338,7 @@ void IFWL_ScrollBar::CalcMaxTrackRect(CFX_RectF& rect) { rect.Empty(); return; } + FX_FLOAT ix = (m_rtThumb.left + m_rtThumb.right()) / 2; FX_FLOAT iy = (m_rtThumb.top + m_rtThumb.bottom()) / 2; bool bVertical = IsVertical(); @@ -357,22 +346,21 @@ void IFWL_ScrollBar::CalcMaxTrackRect(CFX_RectF& rect) { rect.top = bVertical ? iy : m_rtClient.top; rect.width = bVertical ? m_rtClient.width : m_rtClient.right() - ix; rect.height = bVertical ? m_rtClient.bottom() - iy : m_rtClient.height; - if (m_bCustomLayout) { - if (bVertical) { - if (m_rtMinBtn.top > m_rtThumb.top && m_rtMinBtn.height > 0 && - m_rtMaxBtn.height > 0) { - rect.height -= (m_rtClient.bottom() - m_rtMinBtn.top); - } else if (m_rtMinBtn.height > 0 && m_rtMaxBtn.height > 0) { - rect.height -= (m_rtClient.bottom() - m_rtMaxBtn.top); - } - } else { - if (m_rtMinBtn.left > m_rtThumb.left && m_rtMinBtn.width > 0 && - m_rtMaxBtn.width > 0) { - rect.width -= (m_rtClient.right() - m_rtMinBtn.left); - } else if (m_rtMinBtn.width > 0 && m_rtMaxBtn.width > 0) { - rect.width -= (m_rtClient.right() - m_rtMaxBtn.left); - } + if (!m_bCustomLayout) + return; + + if (bVertical) { + if (m_rtMinBtn.top > m_rtThumb.top && m_rtMinBtn.height > 0 && + m_rtMaxBtn.height > 0) { + rect.height -= (m_rtClient.bottom() - m_rtMinBtn.top); + } else if (m_rtMinBtn.height > 0 && m_rtMaxBtn.height > 0) { + rect.height -= (m_rtClient.bottom() - m_rtMaxBtn.top); } + } else if (m_rtMinBtn.left > m_rtThumb.left && m_rtMinBtn.width > 0 && + m_rtMaxBtn.width > 0) { + rect.width -= (m_rtClient.right() - m_rtMinBtn.left); + } else if (m_rtMinBtn.width > 0 && m_rtMaxBtn.width > 0) { + rect.width -= (m_rtClient.right() - m_rtMaxBtn.left); } } @@ -383,7 +371,7 @@ FX_FLOAT IFWL_ScrollBar::GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy) { FX_FLOAT fPos; if (m_bCustomLayout) { if (IsVertical()) { - if (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height) { + if (m_rtMinBtn.height == 0 && m_rtMaxBtn.height == 0) { fPos = fRange * fDiffY / (m_rtClient.height - m_rtThumb.height); } else if (m_rtMinBtn.bottom() == m_rtMaxBtn.top) { fPos = fRange * fDiffY / @@ -393,7 +381,7 @@ FX_FLOAT IFWL_ScrollBar::GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy) { (m_rtMaxBtn.top - m_rtMinBtn.bottom() - m_rtThumb.height); } } else { - if (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width) { + if (m_rtMinBtn.width == 0 && m_rtMaxBtn.width == 0) { fPos = fRange * fDiffX / (m_rtClient.width - m_rtThumb.width); } else if (m_rtMinBtn.right() == m_rtMaxBtn.left) { fPos = fRange * fDiffX / @@ -413,51 +401,47 @@ FX_FLOAT IFWL_ScrollBar::GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy) { } } fPos += m_fLastTrackPos; - if (fPos < m_fRangeMin) { - fPos = m_fRangeMin; - } - if (fPos > m_fRangeMax) { - fPos = m_fRangeMax; - } - return fPos; + return std::min(std::max(fPos, m_fRangeMin), m_fRangeMax); } void IFWL_ScrollBar::GetTrackRect(CFX_RectF& rect, bool bLower) { bool bDisabled = !!(m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled); if (bDisabled || m_bCustomLayout) { rect = bLower ? m_rtMinTrack : m_rtMaxTrack; - } else { - FX_FLOAT fW = m_rtThumb.width / 2; - FX_FLOAT fH = m_rtThumb.height / 2; - bool bVert = IsVertical(); - if (bLower) { - if (bVert) { - FX_FLOAT fMinTrackHeight = m_rtMinTrack.height - fH - m_rtMinBtn.height; - fMinTrackHeight = (fMinTrackHeight >= 0.0f) ? fMinTrackHeight : 0.0f; - rect.Set(m_rtMinTrack.left, m_rtMinTrack.top + m_rtMinBtn.height, - m_rtMinTrack.width, fMinTrackHeight); - } else { - FX_FLOAT fMinTrackWidth = - m_rtMinTrack.width - fW - m_rtMinBtn.width + 2; - fMinTrackWidth = (fMinTrackWidth >= 0.0f) ? fMinTrackWidth : 0.0f; - rect.Set(m_rtMinTrack.left + m_rtMinBtn.width - 1, m_rtMinTrack.top, - fMinTrackWidth, m_rtMinTrack.height); - } - } else { - if (bVert) { - FX_FLOAT fMaxTrackHeight = m_rtMaxTrack.height - fH - m_rtMaxBtn.height; - fMaxTrackHeight = (fMaxTrackHeight >= 0.0f) ? fMaxTrackHeight : 0.0f; - rect.Set(m_rtMaxTrack.left, m_rtMaxTrack.top + fH, m_rtMaxTrack.width, - fMaxTrackHeight); - } else { - FX_FLOAT fMaxTrackWidth = - m_rtMaxTrack.width - fW - m_rtMaxBtn.width + 2; - fMaxTrackWidth = (fMaxTrackWidth >= 0.0f) ? fMaxTrackWidth : 0.0f; - rect.Set(m_rtMaxTrack.left + fW, m_rtMaxTrack.top, fMaxTrackWidth, - m_rtMaxTrack.height); - } + return; + } + + FX_FLOAT fW = m_rtThumb.width / 2; + FX_FLOAT fH = m_rtThumb.height / 2; + bool bVert = IsVertical(); + if (bLower) { + if (bVert) { + FX_FLOAT fMinTrackHeight = m_rtMinTrack.height - fH - m_rtMinBtn.height; + fMinTrackHeight = (fMinTrackHeight >= 0.0f) ? fMinTrackHeight : 0.0f; + rect.Set(m_rtMinTrack.left, m_rtMinTrack.top + m_rtMinBtn.height, + m_rtMinTrack.width, fMinTrackHeight); + return; } + + FX_FLOAT fMinTrackWidth = m_rtMinTrack.width - fW - m_rtMinBtn.width + 2; + fMinTrackWidth = (fMinTrackWidth >= 0.0f) ? fMinTrackWidth : 0.0f; + rect.Set(m_rtMinTrack.left + m_rtMinBtn.width - 1, m_rtMinTrack.top, + fMinTrackWidth, m_rtMinTrack.height); + return; + } + + if (bVert) { + FX_FLOAT fMaxTrackHeight = m_rtMaxTrack.height - fH - m_rtMaxBtn.height; + fMaxTrackHeight = (fMaxTrackHeight >= 0.0f) ? fMaxTrackHeight : 0.0f; + rect.Set(m_rtMaxTrack.left, m_rtMaxTrack.top + fH, m_rtMaxTrack.width, + fMaxTrackHeight); + return; } + + FX_FLOAT fMaxTrackWidth = m_rtMaxTrack.width - fW - m_rtMaxBtn.width + 2; + fMaxTrackWidth = (fMaxTrackWidth >= 0.0f) ? fMaxTrackWidth : 0.0f; + rect.Set(m_rtMaxTrack.left + fW, m_rtMaxTrack.top, fMaxTrackWidth, + m_rtMaxTrack.height); } bool IFWL_ScrollBar::SendEvent() { @@ -601,6 +585,7 @@ void IFWL_ScrollBar::DoMouseDown(int32_t iItem, return; if (iState == CFWL_PartState_Pressed) return; + iState = CFWL_PartState_Pressed; Repaint(&rtItem); } diff --git a/xfa/fwl/core/ifwl_spinbutton.cpp b/xfa/fwl/core/ifwl_spinbutton.cpp index 0352ed991e..6ae2f6aa65 100644 --- a/xfa/fwl/core/ifwl_spinbutton.cpp +++ b/xfa/fwl/core/ifwl_spinbutton.cpp @@ -47,18 +47,19 @@ FWL_Type IFWL_SpinButton::GetClassID() const { } void IFWL_SpinButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (bAutoSize) { - rect.Set(0, 0, kMinWidth, kMinHeight); - IFWL_Widget::GetWidgetRect(rect, true); - } else { + if (!bAutoSize) { rect = m_pProperties->m_rtWidget; + return; } + + rect.Set(0, 0, kMinWidth, kMinHeight); + IFWL_Widget::GetWidgetRect(rect, true); } void IFWL_SpinButton::Update() { - if (IsLocked()) { + if (IsLocked()) return; - } + GetClientRect(m_rtClient); if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) { m_rtUpButton.Set(m_rtClient.top, m_rtClient.left, m_rtClient.width, diff --git a/xfa/fwl/core/ifwl_tooltip.cpp b/xfa/fwl/core/ifwl_tooltip.cpp index 8a34a857b2..5ee594cc32 100644 --- a/xfa/fwl/core/ifwl_tooltip.cpp +++ b/xfa/fwl/core/ifwl_tooltip.cpp @@ -40,37 +40,37 @@ FWL_Type IFWL_ToolTip::GetClassID() const { } void IFWL_ToolTip::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (bAutoSize) { - rect.Set(0, 0, 0, 0); - if (!m_pProperties->m_pThemeProvider) { - m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } - CFX_WideString wsCaption; - IFWL_ToolTipDP* pData = - static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); - if (pData) { - pData->GetCaption(this, wsCaption); - } - int32_t iLen = wsCaption.GetLength(); - if (iLen > 0) { - CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); - rect.Set(0, 0, sz.x, sz.y); - rect.width += 25; - rect.height += 16; - } - IFWL_Widget::GetWidgetRect(rect, true); - } else { + if (!bAutoSize) { rect = m_pProperties->m_rtWidget; + return; + } + + rect.Set(0, 0, 0, 0); + if (!m_pProperties->m_pThemeProvider) + m_pProperties->m_pThemeProvider = GetAvailableTheme(); + + CFX_WideString wsCaption; + IFWL_ToolTipDP* pData = + static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); + if (pData) + pData->GetCaption(this, wsCaption); + + int32_t iLen = wsCaption.GetLength(); + if (iLen > 0) { + CFX_SizeF sz = CalcTextSize(wsCaption, m_pProperties->m_pThemeProvider); + rect.Set(0, 0, sz.x, sz.y); + rect.width += 25; + rect.height += 16; } + IFWL_Widget::GetWidgetRect(rect, true); } void IFWL_ToolTip::Update() { - if (IsLocked()) { + if (IsLocked()) return; - } - if (!m_pProperties->m_pThemeProvider) { + if (!m_pProperties->m_pThemeProvider) m_pProperties->m_pThemeProvider = GetAvailableTheme(); - } + UpdateTextOutStyles(); GetClientRect(m_rtClient); m_rtCaption = m_rtClient; @@ -112,13 +112,11 @@ void IFWL_ToolTip::DrawBkground(CFX_Graphics* pGraphics, param.m_iPart = CFWL_Part::Background; param.m_dwStates = m_pProperties->m_dwStates; param.m_pGraphics = pGraphics; - if (pMatrix) { + if (pMatrix) param.m_matrix.Concat(*pMatrix); - } param.m_rtPart = m_rtClient; - if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { + if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) param.m_pData = &m_rtCaption; - } pTheme->DrawBackground(¶m); } @@ -127,19 +125,19 @@ void IFWL_ToolTip::DrawText(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!m_pProperties->m_pDataProvider) return; + CFX_WideString wsCaption; m_pProperties->m_pDataProvider->GetCaption(this, wsCaption); - if (wsCaption.IsEmpty()) { + if (wsCaption.IsEmpty()) return; - } + CFWL_ThemeText param; param.m_pWidget = this; param.m_iPart = CFWL_Part::Caption; param.m_dwStates = m_pProperties->m_dwStates; param.m_pGraphics = pGraphics; - if (pMatrix) { + if (pMatrix) param.m_matrix.Concat(*pMatrix); - } param.m_rtPart = m_rtCaption; param.m_wsText = wsCaption; param.m_dwTTOStyles = m_dwTTOStyles; @@ -150,12 +148,10 @@ void IFWL_ToolTip::DrawText(CFX_Graphics* pGraphics, void IFWL_ToolTip::UpdateTextOutStyles() { m_iTTOAlign = FDE_TTOALIGNMENT_Center; m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; - if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { + if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) m_dwTTOStyles |= FDE_TTOSTYLE_RTL; - } - if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_Multiline) { + if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_Multiline) m_dwTTOStyles &= ~FDE_TTOSTYLE_SingleLine; - } } void IFWL_ToolTip::SetStates(uint32_t dwStates, bool bSet) { @@ -178,18 +174,15 @@ void IFWL_ToolTip::RefreshToolTipPos() { FX_FLOAT fy = rtAnchor.Center().y + 20; rtPopup.Set(fx, fy, rtWidget.Width(), rtWidget.Height()); - if (rtPopup.bottom() > 0.0f) { + if (rtPopup.bottom() > 0.0f) rtPopup.Offset(0, 0.0f - rtPopup.bottom()); - } - if (rtPopup.right() > 0.0f) { + if (rtPopup.right() > 0.0f) rtPopup.Offset(0.0f - rtPopup.right(), 0); - } - if (rtPopup.left < 0) { + if (rtPopup.left < 0) rtPopup.Offset(0 - rtPopup.left, 0); - } - if (rtPopup.top < 0) { + if (rtPopup.top < 0) rtPopup.Offset(0, 0 - rtPopup.top); - } + SetWidgetRect(rtPopup); Update(); } diff --git a/xfa/fwl/core/ifwl_widget.cpp b/xfa/fwl/core/ifwl_widget.cpp index c9decffe24..b885210015 100644 --- a/xfa/fwl/core/ifwl_widget.cpp +++ b/xfa/fwl/core/ifwl_widget.cpp @@ -61,17 +61,18 @@ bool IFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { } void IFWL_Widget::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { - if (bAutoSize) { - if (HasEdge()) { - FX_FLOAT fEdge = GetEdgeWidth(); - rect.Inflate(fEdge, fEdge); - } - if (HasBorder()) { - FX_FLOAT fBorder = GetBorderSize(); - rect.Inflate(fBorder, fBorder); - } - } else { + if (!bAutoSize) { rect = m_pProperties->m_rtWidget; + return; + } + + if (HasEdge()) { + FX_FLOAT fEdge = GetEdgeWidth(); + rect.Inflate(fEdge, fEdge); + } + if (HasBorder()) { + FX_FLOAT fBorder = GetBorderSize(); + rect.Inflate(fBorder, fBorder); } } @@ -233,31 +234,32 @@ void IFWL_Widget::TransformTo(IFWL_Widget* pWidget, void IFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) { if (!m_pProperties) return; - if (bGlobal) { - IFWL_Widget* parent = GetParent(); - CFX_ArrayTemplate<IFWL_Widget*> parents; - while (parent) { - parents.Add(parent); - parent = parent->GetParent(); - } - matrix.SetIdentity(); - CFX_Matrix ctmOnParent; - CFX_RectF rect; - int32_t count = parents.GetSize(); - for (int32_t i = count - 2; i >= 0; i--) { - parent = parents.GetAt(i); - parent->GetMatrix(ctmOnParent, false); - parent->GetWidgetRect(rect); - matrix.Concat(ctmOnParent, true); - matrix.Translate(rect.left, rect.top, true); - } - CFX_Matrix m; - m.SetIdentity(); - matrix.Concat(m, true); - parents.RemoveAll(); - } else { + if (!bGlobal) { matrix.SetIdentity(); + return; + } + + IFWL_Widget* parent = GetParent(); + CFX_ArrayTemplate<IFWL_Widget*> parents; + while (parent) { + parents.Add(parent); + parent = parent->GetParent(); + } + matrix.SetIdentity(); + CFX_Matrix ctmOnParent; + CFX_RectF rect; + int32_t count = parents.GetSize(); + for (int32_t i = count - 2; i >= 0; i--) { + parent = parents.GetAt(i); + parent->GetMatrix(ctmOnParent, false); + parent->GetWidgetRect(rect); + matrix.Concat(ctmOnParent, true); + matrix.Translate(rect.left, rect.top, true); } + CFX_Matrix m; + m.SetIdentity(); + matrix.Concat(m, true); + parents.RemoveAll(); } void IFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, @@ -317,15 +319,16 @@ void* IFWL_Widget::GetThemeCapacity(CFWL_WidgetCapacity dwCapacity) { IFWL_ThemeProvider* pTheme = GetAvailableTheme(); if (!pTheme) return nullptr; + CFWL_ThemePart part; part.m_pWidget = this; return pTheme->GetCapacity(&part, dwCapacity); } IFWL_ThemeProvider* IFWL_Widget::GetAvailableTheme() { - if (m_pProperties->m_pThemeProvider) { + if (m_pProperties->m_pThemeProvider) return m_pProperties->m_pThemeProvider; - } + IFWL_Widget* pUp = this; do { pUp = (pUp->GetStyles() & FWL_WGTSTYLE_Popup) @@ -344,9 +347,9 @@ IFWL_Widget* IFWL_Widget::GetRootOuter() { IFWL_Widget* pRet = m_pOuter; if (!pRet) return nullptr; - while (IFWL_Widget* pOuter = pRet->GetOuter()) { + + while (IFWL_Widget* pOuter = pRet->GetOuter()) pRet = pOuter; - } return pRet; } @@ -400,17 +403,17 @@ void IFWL_Widget::SetFocus(bool bFocus) { return; IFWL_Widget* curFocus = pDriver->GetFocus(); - if (bFocus && curFocus != this) { + if (bFocus && curFocus != this) pDriver->SetFocus(this); - } else if (!bFocus && curFocus == this) { + else if (!bFocus && curFocus == this) pDriver->SetFocus(nullptr); - } } void IFWL_Widget::SetGrab(bool bSet) { const IFWL_App* pApp = GetOwnerApp(); if (!pApp) return; + CFWL_NoteDriver* pDriver = static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); pDriver->SetGrab(this, bSet); @@ -479,19 +482,19 @@ bool IFWL_Widget::GetPopupPosComboBox(FX_FLOAT fMinHeight, FX_FLOAT fy = 0; FX_FLOAT fPopHeight = rtPopup.height; - if (rtPopup.height > fMaxHeight) { + if (rtPopup.height > fMaxHeight) fPopHeight = fMaxHeight; - } else if (rtPopup.height < fMinHeight) { + else if (rtPopup.height < fMinHeight) fPopHeight = fMinHeight; - } + FX_FLOAT fWidth = std::max(rtAnchor.width, rtPopup.width); FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight; TransformTo(nullptr, fx, fy); - if (fBottom + fy > 0.0f) { + if (fBottom + fy > 0.0f) rtPopup.Set(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight); - } else { + else rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight); - } + rtPopup.Offset(fx, fy); return true; } @@ -543,6 +546,7 @@ void IFWL_Widget::UnregisterEventTarget() { void IFWL_Widget::DispatchKeyEvent(CFWL_MsgKey* pNote) { if (!pNote) return; + CFWL_EvtKey* pEvent = new CFWL_EvtKey; pEvent->m_pSrcTarget = this; pEvent->m_dwCmd = pNote->m_dwCmd; @@ -560,6 +564,7 @@ void IFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { const IFWL_App* pApp = GetOwnerApp(); if (!pApp) return; + CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); if (!pNoteDriver) return; @@ -587,9 +592,8 @@ void IFWL_Widget::DrawBackground(CFX_Graphics* pGraphics, param.m_pWidget = this; param.m_iPart = iPartBk; param.m_pGraphics = pGraphics; - if (pMatrix) { + if (pMatrix) param.m_matrix.Concat(*pMatrix, true); - } param.m_rtPart = rtRelative; pTheme->DrawBackground(¶m); } @@ -604,9 +608,8 @@ void IFWL_Widget::DrawBorder(CFX_Graphics* pGraphics, param.m_pWidget = this; param.m_iPart = iPartBorder; param.m_pGraphics = pGraphics; - if (pMatrix) { + if (pMatrix) param.m_matrix.Concat(*pMatrix, true); - } param.m_rtPart = rtRelative; pTheme->DrawBackground(¶m); } @@ -621,9 +624,8 @@ void IFWL_Widget::DrawEdge(CFX_Graphics* pGraphics, param.m_pWidget = this; param.m_iPart = iPartEdge; param.m_pGraphics = pGraphics; - if (pMatrix) { + if (pMatrix) param.m_matrix.Concat(*pMatrix, true); - } param.m_rtPart = rtEdge; pTheme->DrawBackground(¶m); } |