示例#1
0
//-----------------------------------------------------------------------------
CMessageResult CScrollView::notify (CBaseObject* sender, IdStringPtr message)
{
	if (message == kMsgNewFocusView && getStyle () & kFollowFocusView)
	{
		CView* focusView = (CView*)sender;
		if (sc->isChild (focusView, true))
		{
			CRect r = focusView->getViewSize ();
			CPoint p;
			focusView->localToFrame (p);
			frameToLocal (p);
			r.offset (p.x, p.y);
			makeRectVisible (r);
		}
	}
	return CViewContainer::notify (sender, message);
}
示例#2
0
//----------------------------------------------------------------------------------------------------
void UIEditView::drawRect (CDrawContext *pContext, const CRect& updateRect)
{
	// disable focus drawing
	bool focusDrawing = getFrame ()->focusDrawingEnabled ();
	if (!editing && focusDrawing)
		getFrame ()->setFocusDrawingEnabled (false);

	CViewContainer::drawRect (pContext, updateRect);

	if (!editing && focusDrawing)
		getFrame ()->setFocusDrawingEnabled (focusDrawing);

	CRect oldClip = pContext->getClipRect (oldClip);
	CRect newClip (updateRect);
	newClip.offset (-getViewSize ().left, -getViewSize ().top);
	pContext->setClipRect (updateRect);

	CCoord save[4];
	modifyDrawContext (save, pContext);

	const CCoord dashLength[] = {5, 5};
	const CLineStyle lineDash (CLineStyle::kLineCapButt, CLineStyle::kLineJoinMiter, 0, 2, dashLength);
	pContext->setLineStyle (lineDash);
	pContext->setLineWidth (1);
	pContext->setDrawMode (kAliasing);
	pContext->setFrameColor (kBlueCColor);
	pContext->drawRect (CRect (0, 0, getWidth(), getHeight()), kDrawStroked);

	if (editing)
	{
		if (lines)
			lines->draw (pContext);
		pContext->setDrawMode (kAntiAliasing);
		if (highlightView)
		{
			CRect r = UISelection::getGlobalViewCoordinates (highlightView);
			CPoint p;
			frameToLocal (p);
			r.offset (p.x, p.y);
			r.inset (2, 2);
			pContext->setFrameColor (viewHighlightColor);
			pContext->setLineStyle (kLineSolid);
			pContext->setLineWidth (3);
			pContext->drawRect (r);
		}
		if (getSelection ()->total () > 0)
		{
			pContext->setDrawMode (kAliasing);
			pContext->setFrameColor (viewSelectionColor);
			pContext->setLineStyle (kLineSolid);
			pContext->setLineWidth (1);

			FOREACH_IN_SELECTION(getSelection (), view)
				CRect vs = getSelection ()->getGlobalViewCoordinates (view);
				CPoint p;
				frameToLocal (p);
				vs.offset (p.x, p.y);
				pContext->drawRect (vs);
			FOREACH_IN_SELECTION_END

		}
	}