IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, FX_FLOAT x, FX_FLOAT y) { if (!parent) return nullptr; FX_FLOAT x1; FX_FLOAT y1; IFWL_Widget* child = GetLastChildWidget(parent); while (child) { if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) { x1 = x; y1 = y; CFX_Matrix matrixOnParent; child->GetMatrix(matrixOnParent); CFX_Matrix m; m.SetIdentity(); m.SetReverse(matrixOnParent); m.TransformPoint(x1, y1); CFX_RectF bounds; child->GetWidgetRect(bounds); if (bounds.Contains(x1, y1)) { x1 -= bounds.left; y1 -= bounds.top; return GetWidgetAtPoint(child, x1, y1); } } child = GetPriorSiblingWidget(child); } return parent; }
void IFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) { if (!m_pProperties) return; 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 CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, const CFX_RectF& rtClip, CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!parent) return; FX_BOOL bFormDisable = m_pWidgetMgr->IsFormDisabled(); IFWL_Widget* pNextChild = m_pWidgetMgr->GetFirstChildWidget(parent); while (pNextChild) { IFWL_Widget* child = pNextChild; pNextChild = m_pWidgetMgr->GetNextSiblingWidget(child); if (child->GetStates() & FWL_WGTSTATE_Invisible) continue; CFX_RectF rtWidget; child->GetWidgetRect(rtWidget); if (rtWidget.IsEmpty()) continue; CFX_Matrix widgetMatrix; CFX_RectF clipBounds(rtWidget); if (!bFormDisable) child->GetMatrix(widgetMatrix, TRUE); if (pMatrix) widgetMatrix.Concat(*pMatrix); if (!bFormDisable) { widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top); clipBounds.Intersect(rtClip); if (clipBounds.IsEmpty()) continue; pGraphics->SaveGraphState(); pGraphics->SetClipRect(clipBounds); } widgetMatrix.Translate(rtWidget.left, rtWidget.top, TRUE); IFWL_WidgetDelegate* pDelegate = child->SetDelegate(nullptr); if (pDelegate) { if (m_pWidgetMgr->IsFormDisabled() || IsNeedRepaint(child, &widgetMatrix, rtClip)) { pDelegate->OnDrawWidget(pGraphics, &widgetMatrix); } } if (!bFormDisable) pGraphics->RestoreGraphState(); DrawChild(child, clipBounds, pGraphics, bFormDisable ? &widgetMatrix : pMatrix); child = m_pWidgetMgr->GetNextSiblingWidget(child); } }