Пример #1
0
bool FormMgr::CookEvent(Event *pevt)
{
	pevt->idf = 0;
	switch (pevt->eType) {
	case penHoverEvent:
    case penUpEvent:
	case penDownEvent:
	case penMoveEvent:
    case penUpEvent2:
    case penDownEvent2:
    case penMoveEvent2:
	case penHoldEvent:
		{
			// If no capture, process as usual

			if (m_idfCapture == 0) {
				return CookPenEvent(pevt);
            }

			// Mouse is captured. If captureed but there is a new form on top,
			// gracefully release the capture (can happen if form shows while
			// mouse is captured)

			if (!CookPenEvent(pevt))
				return false;
			for (int n = m_cfrm - 1; n >= 0; n--) {
				Form *pfrm = m_apfrm[n];
				if ((pfrm->GetFlags() & (kfFrmDoModal | kfFrmVisible)) == (kfFrmDoModal | kfFrmVisible)) {
					if (pfrm->m_idf != pevt->idf) {
						pevt->dw = 1;
						pevt->eType = penUpEvent;
						m_idfCapture = 0;
                        m_cCaptureDowns = 0;
					}
				}
				break;
			}
			return true;
		}
		break;

	case keyDownEvent:
		return CookKeyEvent(pevt);
	}
	return false;
}
Пример #2
0
bool FormMgr::CookPenEvent(Event *pevt)
{
	// Send the input to the capturing form. Auto-release if pen up,
	// auto-capture if pen down.

	if (m_idfCapture != 0) {
		pevt->idf = m_idfCapture;
        if (pevt->eType == penDownEvent || pevt->eType == penDownEvent2) {
            m_cCaptureDowns++;
        }
        if (pevt->eType == penUpEvent || pevt->eType == penUpEvent2) {
            m_cCaptureDowns--;
        }
        if (m_cCaptureDowns <= 0) {
            m_cCaptureDowns = 0;
			m_idfCapture = 0;
        }
		return true;
	} else {
		// Ask the topmost form first if it wants this pen input.
		// All coords are global.

		word idf = 0;
		for (int n = m_cfrm - 1; n >= 0; n--) {
			Form *pfrm = m_apfrm[n];
			if (pfrm->OnHitTest(pevt)) {
				idf = pfrm->GetId();
				break;
			}

			// If the top-most form is modal, don't pass the event on
			// to any lower forms.

			if (pfrm->GetFlags() & kfFrmDoModal) {
				pevt->idf = 0;
				return true;
			}
		}
		pevt->idf = idf;
		if (pevt->eType == penDownEvent || pevt->eType == penDownEvent2) {
            m_cCaptureDowns = 1;
			m_idfCapture = idf;
        }
		return pevt->idf != 0;
	}
}
Пример #3
0
void FormMgr::CalcOpaqueRect(Form *pfrmStop, Rect *prcOpaqueStart, Rect *prcResult)
{
	// Start from the top and expand the opaque rect when a portion lies safely inside
	// the new rectangle.

	if (prcOpaqueStart == NULL) {
		prcResult->SetEmpty();
	} else {
		*prcResult = *prcOpaqueStart;
	}
	for (int n = m_cfrm - 1; n >= 0; n--) {
		Form *pfrm = m_apfrm[n];
		if (pfrm == pfrmStop)
			break;
		word wf = pfrm->GetFlags();
		if (wf & kfFrmTranslucent)
			continue;
		if (!(wf & kfFrmVisible))
			continue;
		prcResult->Add(prcResult, &pfrm->m_rc);
	}
}