• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ WebRect类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中WebRect的典型用法代码示例。如果您正苦于以下问题:C++ WebRect类的具体用法?C++ WebRect怎么用?C++ WebRect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了WebRect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GetBounds

void DisplayElement::GetBounds (WebRect *rect)
{
	if (mFlags & DISPLAY_FLAG_BOUNDS_VALID)
	{
		*rect = mBounds;
		return;
	}

	*rect = mRect;

	WebRect childRect;
	DisplayElement *pChild = mpFirstChild;

	while (pChild)
	{
		if (!(pChild->mFlags & DISPLAY_FLAG_FIXED_POS))
		{
			pChild->GetBounds(&childRect);
			childRect.Shift(mRect.left, mRect.top);
			rect->Or(&childRect);
		}

		pChild = pChild->mpNext;
	}

	SetFlag(DISPLAY_FLAG_BOUNDS_VALID);
	mBounds = *rect;
}
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:28,代码来源:delement.cpp


示例2: FormatIfNecessary

/*---------------------------------------------------------------------------*/
void HTMLBodyDisplay::Draw (DISPLAY_INT x, DISPLAY_INT y, WebRect *pViewport, WebGraphics *pGC)
{
	FormatIfNecessary();

  #if (WEBC_SUPPORT_FRAMES)
	if (mpFrameSet)
	{
		mpFrameSet->Draw(x, y, pViewport, pGC);
	}
	else
  #endif //	WEBC_SUPPORT_FRAMES
	{
		if (!(mpHtmlElement->mFlags & HBODY_FLAG_NOBACKGROUND))
		{
			WebRect screenRect;
			screenRect.Set(x, y, pViewport->right, pViewport->bottom);
			DrawBackground(&screenRect, pViewport, pGC);
		}

		// Draw all children
		DisplayElement *pChild = mpFirstChild;
		while (pChild)
		{
			if (pChild->mFlags & DISPLAY_FLAG_FIXED_POS)
			{
				pChild->Draw(pViewport->left + pChild->mRect.left, pViewport->top + pChild->mRect.top, pViewport, pGC);
			}
			else
			{
				pChild->Draw(x + pChild->mRect.left, y + pChild->mRect.top, pViewport, pGC);
			}
			pChild = pChild->mpNext;
		}
	}
}
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:36,代码来源:dhbody.cpp


示例3: GetDocumentDisplayRect

int HTMLString::GetDocumentDisplayRect (WebRect *rect, int n)
{
WebRect displayRect;
HTMLStringDisplay *display = mpFirstDisplay;

	while (display && n > 0)
	{
		if (display->GetStringIndex() + display->GetStringLength() >= miLength)
		{
			display = 0;
			break;
		}
		n--;
		display = display->GetNextSubString();
	}

	if (display)
	{
		displayRect.Set(&display->mRect);

		if (display->mpParent)
		{
			DISPLAY_INT x, y;

			display->mpParent->GetDisplayPosition(display, &x, &y);
			displayRect.MoveTo(x,y);
		}

		rect->Set(&displayRect);

		return (0);
	}

	return (-1);
}
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:35,代码来源:hstring.cpp


示例4: rect

void DisplayManager::CorrectViewportPosition (void)
{
	if (mRoot.Get())
	{
		WebRect bounds;
		PresetWebRect rect(&mViewRect);

		GetRootBounds(&bounds);
		rect.MoveTo(0,0);
		bounds.Or(&rect);

		if (mViewRect.left < bounds.left)
		{
			mViewRect.Shift(bounds.left - mViewRect.left, 0);
		}

		if (mViewRect.right > bounds.right)
		{
			mViewRect.Shift(bounds.right - mViewRect.right, 0);
		}

		if (mViewRect.top < bounds.top)
		{
			mViewRect.Shift(0, bounds.top - mViewRect.top);
		}

		if (mViewRect.bottom > bounds.bottom)
		{
			mViewRect.Shift(0, bounds.bottom - mViewRect.bottom);
		}

		if (mpVScroll)
		{
			// Range and Window must be set BEFORE Position,
			//  so position is not unjustly clipped!
			mpVScroll->SetRange(bounds.Height());
			mpVScroll->SetWindow(mViewRect.Height());
			mpVScroll->SetPosition(mViewRect.top);
		}

		if (mpHScroll)
		{
			// Range and Window must be set BEFORE Position,
			//  so position is not unjustly clipped!
			mpHScroll->SetRange(bounds.Width());
			mpHScroll->SetWindow(mViewRect.Width());
			mpHScroll->SetPosition(mViewRect.left);
		}
	}
}
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:50,代码来源:dmanager.cpp


示例5: GetBorder

void WebListBox::ResizeScrollBars(void)
{
	if (mpHScroll)
	{
		WebRect r;
		r.Set(GetMargin() + GetBorder(),
		      Height() - GetMargin() - GetBorder() - miSliderWidth - 1,
		      Width() - (mpVScroll ? miSliderWidth : 0) - GetMargin() - GetBorder() - 1,
		      Height() - GetMargin() - GetBorder() - 1);
		mpHScroll->Move(&r);
		WebRect vr;
		GetOptionsRect(&vr);
		mpHScroll->SetWindow(vr.Width());
		mpHScroll->Invalidate();
	}
	if (mpVScroll)
	{
		WebRect r;
		r.Set(Width() - 1 - GetMargin() - GetBorder() - miSliderWidth,
		      GetMargin() + GetBorder(),
		      Width() - 1 - GetMargin() - GetBorder(),
		      Height() - 1 - (mpHScroll ? miSliderWidth : 0) - GetMargin() - GetBorder());
		mpVScroll->Move(&r);
		WebRect vr;
		GetOptionsRect(&vr);
		mpVScroll->SetWindow(vr.Height());
		mpVScroll->Invalidate();

	}
}
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:30,代码来源:wtlist.cpp


示例6: paintContents

void WebPopupMenuImpl::paintContents(WebCanvas* canvas, const WebRect& rect, bool, WebFloatRect&)
{
    if (!m_widget)
        return;

    if (!rect.isEmpty()) {
        GraphicsContext context(canvas);
        m_widget->paint(&context, rect);
    }
}
开发者ID:jeremyroman,项目名称:blink,代码行数:10,代码来源:WebPopupMenuImpl.cpp


示例7: UpdateViewport

void DisplayManager::UpdateViewport (void)
{
	WebRect view;
	WebRect padding;
	WebRect vscrollRect;
	WebRect hscrollRect;

	GetPaddingWidth(&padding);

	view.Set (mRect.left + padding.left,
	          mRect.top + padding.top,
	          mRect.right - padding.right,
	          mRect.bottom - padding.bottom);

	if (mpVScroll)
	{
		vscrollRect.Set (mRect.Width() - padding.right - webc_GetDefaultDisplayInt(WEBC_DEFAULT_SLIDER_WIDTH), padding.top,
		                 mRect.Width() - 1 - padding.right, mRect.Height() - 1 - padding.bottom);

		view.right -= webc_GetDefaultDisplayInt(WEBC_DEFAULT_SLIDER_WIDTH);

		if (mpHScroll)
		{
			hscrollRect.Set (padding.left, mRect.Height() - padding.bottom - webc_GetDefaultDisplayInt(WEBC_DEFAULT_SLIDER_WIDTH),
			                 mRect.Width() - padding.right - webc_GetDefaultDisplayInt(WEBC_DEFAULT_SLIDER_WIDTH),
			                 mRect.Height() - 1 - padding.bottom);

			vscrollRect.bottom -= webc_GetDefaultDisplayInt(WEBC_DEFAULT_SLIDER_WIDTH) - 1;
			view.bottom -= webc_GetDefaultDisplayInt(WEBC_DEFAULT_SLIDER_WIDTH);

			mpHScroll->Move(&hscrollRect);
		}

		mpVScroll->Move(&vscrollRect);
	}
	else
	{
		if (mpHScroll)
		{
			hscrollRect.Set (padding.left, mRect.Height() - padding.bottom - webc_GetDefaultDisplayInt(WEBC_DEFAULT_SLIDER_WIDTH),
			                 mRect.Width() - 1 - padding.right,
			                 mRect.Height() - 1 - padding.bottom);

			view.bottom -= webc_GetDefaultDisplayInt(WEBC_DEFAULT_SLIDER_WIDTH);

			mpHScroll->Move(&hscrollRect);
		}
	}

	view.MoveTo(mViewRect.left, mViewRect.top);
	SetViewport(&view);
}
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:52,代码来源:dmanager.cpp


示例8: SizeTo

FormatResult HTMLBodyDisplay::FormatForViewport (
		WebRect* viewportRect,
		WEBC_BOOL hscrollPresent,
		WEBC_BOOL vscrollPresent
	)
{
	if (Width() != viewportRect->Width())
	{
		SizeTo(viewportRect->Width(), viewportRect->Height());
		SetParentStyleModified();
	}
	else if (Height() != viewportRect->Height())
	{
		SizeTo(viewportRect->Width(), viewportRect->Height());
		SetPosChildStyleModified();
	}

	FormatIfNecessary();
	CSSPropertyValue overflowValue;
	if (mpHtmlElement->GetStyleFromCSS(CSS_PROPERTY_OVERFLOW, &overflowValue) == CSS_VALUE_SPECIFIED)
	{
		if (CSS_OVERFLOW_HIDDEN == overflowValue.overflow)
		{
			return (DISPLAY_FORMAT_SUCCESS);
		}
	}
#if (WEBC_SUPPORT_SCROLLBARS)
	WebRect bounds;
	GetBounds(&bounds);

	if (bounds.Height() > viewportRect->Height() && !vscrollPresent)
	{
		return (DISPLAY_FORMAT_NEEDS_VSCROLL);
	}

	if (bounds.Width() > viewportRect->Width() && !hscrollPresent)
	{
		return (DISPLAY_FORMAT_NEEDS_HSCROLL);
	}
#endif
	return (DISPLAY_FORMAT_SUCCESS);
}
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:42,代码来源:dhbody.cpp


示例9: paint

void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOptions)
{
    if (!m_widget)
        return;

    if (!rect.isEmpty()) {
        GraphicsContext context(canvas);
        context.applyDeviceScaleFactor(m_client->deviceScaleFactor());
        m_widget->paint(&context, rect);
    }
}
开发者ID:jeremyroman,项目名称:blink,代码行数:11,代码来源:WebPopupMenuImpl.cpp


示例10: paintContents

void WebPopupMenuImpl::paintContents(WebCanvas* canvas, const WebRect& rect, bool, WebContentLayerClient::GraphicsContextStatus contextStatus)
{
    if (!m_widget)
        return;

    if (!rect.isEmpty()) {
        GraphicsContext context(canvas,
                                contextStatus == WebContentLayerClient::GraphicsContextEnabled ? GraphicsContext::NothingDisabled : GraphicsContext::FullyDisabled);
        m_widget->paint(&context, rect);
    }
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:11,代码来源:WebPopupMenuImpl.cpp


示例11: paint

void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect)
{
    if (!m_widget)
        return;

    if (!rect.isEmpty()) {
        OwnPtr<GraphicsContext> context = GraphicsContext::deprecatedCreateWithCanvas(canvas);
        float scaleFactor = m_client->deviceScaleFactor();
        context->scale(scaleFactor, scaleFactor);
        m_widget->paint(context.get(), rect);
    }
}
开发者ID:joone,项目名称:blink-crosswalk,代码行数:12,代码来源:WebPopupMenuImpl.cpp


示例12: FitSelection

void WebListBox::FitSelection(void)
{
	if (UseVScroll())
	{
		DISPLAY_INT offsetX, offsetY;
		WebRect r;

		GetScrollOffset(&offsetX, &offsetY);
		GetOptionsRect(&r);

		int pos = miSelected * (miTextHeight + GetSpacing());
		if (pos < offsetY)
		{
			mpVScroll->SetPosition(pos);
		}
		else if (pos > offsetY + r.Height() - miTextHeight - GetSpacing())
		{
			mpVScroll->SetPosition(pos - r.Height() + miTextHeight + GetSpacing());
		}
	}
}
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:21,代码来源:wtlist.cpp


示例13: paint

void PageWidgetDelegate::paint(Page& page, PageOverlayList* overlays, WebCanvas* canvas, const WebRect& rect, CanvasBackground background, LocalFrame& root)
{
    if (rect.isEmpty())
        return;
    GraphicsContext gc(canvas, nullptr);
    gc.setCertainlyOpaque(background == Opaque);
    float scaleFactor = page.deviceScaleFactor();
    gc.scale(scaleFactor, scaleFactor);
    gc.setDeviceScaleFactor(scaleFactor);
    IntRect dirtyRect(rect);
    gc.save(); // Needed to save the canvas, not the GraphicsContext.
    FrameView* view = root.view();
    if (view) {
        gc.clip(dirtyRect);
        view->paint(&gc, dirtyRect);
        if (overlays)
            overlays->paintWebFrame(gc);
    } else {
        gc.fillRect(dirtyRect, Color::white);
    }
    gc.restore();
}
开发者ID:kjthegod,项目名称:WebKit,代码行数:22,代码来源:PageWidgetDelegate.cpp


示例14: InvalidateChild

void DisplayElement::InvalidateChild (DisplayElement *pChild, WebRect *pDirty)
{
	WebRect dirty;
	dirty.Set(pDirty);
	dirty.Shift(mRect.left, mRect.top);

	if (GetOverflow() == DISPLAY_OVERFLOW_HIDDEN)
	{
		WebRect clipRect;
		GetClipRect(&clipRect);

		// If completely outside clipping rect, stop here
		if (!dirty.Overlaps(&clipRect))
		{
			return;
		}

		// clip pDirty to our rect
		dirty.And(&clipRect);
	}

	if ((mFlags & DISPLAY_FLAG_FIXED_POS) || !mpParent)
	{
		DisplayManager *pManager = GetManager();
		if (pManager)
		{
			if (mFlags & DISPLAY_FLAG_FIXED_POS)
			{
				dirty.Shift(pManager->mViewRect.left, pManager->mViewRect.top);
			}

			pManager->InvalidateViewportRegion(&dirty);
		}
	}
	else
	{
		mpParent->InvalidateChild(this, &dirty);
	}
 }
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:39,代码来源:delement.cpp


示例15: SetupScrollBars

void WebListBox::SetupScrollBars(WebGraphics * gc)
{
	WebRect window;
	GetContentRect(&window);
	DISPLAY_INT w = window.Width();
	DISPLAY_INT h = window.Height();

	WEBC_BOOL needH, needV;
	needH = needV = WEBC_FALSE;

	for (int t = 0; t < 2; t++)
	{
		if (w < GetTotalTextWidth())
		{
			needH = WEBC_TRUE;
			h -= miSliderWidth;
		}
		if (h < GetTotalTextHeight())
		{
			needV = WEBC_TRUE;
			w -= miSliderWidth;
		}
	}

	if (needH && !mpHScroll)
	{
		WEBC_NEW_VERBOSE(mpHScroll, WebHScroll,"wtlist:WebVscroll");
		if (mpHScroll)
		{
			mpHScroll->SetListener(this);
			mpHScroll->SetRange(GetTotalTextWidth());
			mpHScroll->SetStep(miTextHeight);
			mpHScroll->SetPosition(0);
			if (mFlags & DISPLAY_FLAG_DISABLED)
			{
				mpHScroll->Disable();
			}
			InsertLast(mpHScroll);
			ResizeScrollBars();
		}
	}
	else if (!needH && mpHScroll)
	{
		Remove(mpHScroll);
		WEBC_DELETE(mpHScroll);
		mpHScroll = WEBC_NULL;
	}

	if (needV && !mpVScroll)
	{
		WEBC_NEW_VERBOSE(mpVScroll, WebVScroll,"Wtlist:WebVscroll");
		if (mpVScroll)
		{
			mpVScroll->SetListener(this);
			mpVScroll->SetRange(GetTotalTextHeight());
			mpVScroll->SetStep(miTextHeight + GetSpacing());
			mpVScroll->SetPosition(0);
			if (mFlags & DISPLAY_FLAG_DISABLED)
			{
				mpVScroll->Disable();
			}
			InsertLast(mpVScroll);
			ResizeScrollBars();
		}
	}
	else if (!needV && mpVScroll)
	{
		Remove(mpVScroll);
		WEBC_DELETE(mpVScroll);
		mpVScroll = WEBC_NULL;
	}

}
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:73,代码来源:wtlist.cpp


示例16: GetPosition

/*---------------------------------------------------------------------------*/
template<class T> IPositionedFormatContext* HTMLElementDisplay<T>::FormatSelfPositioned (
		DisplayElement* displayParent,
		IPositionedFormatContext* rootContext,
		IPositionedFormatContext* parentContext,
		FormatContextFactory* childContextFactory,
		WEBC_BOOL generateChildContext
	)
{
	WebRect rect;
	WEBC_UINT16 position = GetPosition();
	IPositionedFormatContext* childContext = 0;

	if (position == TU_POSITION_RELATIVE)
	{
		if (generateChildContext)
		{
			const WebRect * tmpRect = 	&(((DisplayElement *)(this))->mRect);
			rect.Set(tmpRect);
			rect.MoveTo(0,0);

			CSSLength height;
			GetCSSLength(&height, CSS_PROPERTY_HEIGHT);

			childContext = childContextFactory->newPositioned (
					&rect,
					(height.type == CSS_LENGTH_UNIT_AUTO) ||
					(height.type == CSS_LENGTH_UNIT_PERCENT && parentContext->parentHeightIsAuto()), // parent height is auto
					TU_DIR_LTR,
					0, // border-left-width
					0, // border-top-width
					0, // border-right-width
					0, // border-bottom-width
					0, // autoIndentLeft
					0, // autoIndentTop
					0  // autoIndentRight
				);
		}
	}
	else
	{
		WebRect containingBlock;
		IPositionedFormatContext* containingContext;
		DISPLAY_INT borderLeftValue;
		DISPLAY_INT borderTopValue;
		DISPLAY_INT borderRightValue;
		DISPLAY_INT borderBottomValue;

		if (displayParent)
		{
			if (displayParent != T::mpParent)
			{
				mHtmlElementDisplayFlags &= ~HELEM_DISPLAY_FLAG_STYLE_SET;
			}
			displayParent->InsertOrdered(this);
		}

		if (position == TU_POSITION_FIXED)
		{
			T::SetFixedPosition(WEBC_TRUE);
			containingContext = rootContext;
		}
		else
		{
			T::SetFixedPosition(WEBC_FALSE);
			containingContext = parentContext;
		}

		containingContext->getContainingBlock(&containingBlock);

		WEBC_BOOL   parentHeightIsAuto = containingContext->parentHeightIsAuto();
		int         textDirection      = containingContext->getTextDirection();
		DISPLAY_INT parentBorderLeft   = containingContext->getParentBorderLeft();
		DISPLAY_INT parentBorderTop    = containingContext->getParentBorderTop();
		DISPLAY_INT parentBorderRight  = containingContext->getParentBorderRight();
		DISPLAY_INT parentBorderBottom = containingContext->getParentBorderBottom();

		DISPLAY_INT autoIndentLeft     = parentContext->getAutoIndentLeft();
		DISPLAY_INT autoIndentTop      = parentContext->getAutoIndentTop();
		DISPLAY_INT autoIndentRight    = parentContext->getAutoIndentRight();

		if (position == TU_POSITION_FIXED)
		{
			WebRect parentRect;

			parentContext->getContainingBlock(&parentRect);

			autoIndentLeft  += parentRect.left;
			autoIndentTop   += parentRect.top;
			autoIndentRight += (containingBlock.right - parentRect.right);
		}

		DISPLAY_INT parentWidth = containingBlock.Width() - (parentBorderLeft + parentBorderRight);
		DISPLAY_INT parentHeight = containingBlock.Height() - (parentBorderTop + parentBorderBottom);

		WebFont font = mpHtmlElement->GetWebFont();
		DISPLAY_INT emHeight = font? WEB_FONT_HEIGHT(font) : WEBC_CFG_DEFAULT_TEXT_HEIGHT;
		DISPLAY_INT exHeight = emHeight >> 1;

		// First find the left edge and width
//.........这里部分代码省略.........
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:101,代码来源:dhelem.cpp


示例17: GetGraphics

void WebEditBox::Format (void)
{
	WebGraphics *gc = GetGraphics();
	WebFont font = mFont.GetFont();

	if (!gc || !mpText || !font)
	{
		return;
	}

	int i = 0;
	do
	{
		long iIndex = 0;
		long iNextWord;
		DISPLAY_INT iWidthUsed = 0;
		WebRect box;
		DISPLAY_INT iWordWidth;

		GetTextRect(&box);
		DISPLAY_INT iWidthAvailable = box.Width();
//printf("Box w == %d\n",iWidthAvailable);
		miMaxLineWidth = 0;
		miNumLines = 1;
		while (mpText[iIndex])
		{
			switch (mpText[iIndex])
			{
				case (WebChar) '\r':
				case (WebChar) '\n':
					// break the line at CR/LF
					AddLine(++iIndex);
					iWidthUsed = 0;
					break;

				default:
					if (!(mEditFlags & EDIT_FLAG_WRAP))
					{
						iWordWidth = gc->TextWidthLen(&mpText[iIndex], font, 1);
						iWidthUsed += iWordWidth;
						miMaxLineWidth = EBSMAX(miMaxLineWidth, iWidthUsed);
						iIndex++;
					}
					else
					{

#if (TEXT_BOX_SCROLL_DISABLED)
					WebChar mpText1='m';
					DISPLAY_INT charWidth = gc->TextWidthLen(&mpText[iIndex], font, 1);
					if (iWidthUsed + charWidth > (iWidthAvailable) && iWidthUsed > 0)
					{
						AddLine(iIndex);
						iWidthUsed = charWidth;
						miMaxLineWidth = EBSMAX(miMaxLineWidth, charWidth);
						iIndex++;
					}
					else
					{
						iIndex++;
						iWidthUsed += charWidth;
					}
				}//switch statement
#else
						if (IS_WHITESPACE(mpText[iIndex]))
						{

							iWidthUsed += gc->TextWidthLen(&mpText[iIndex++], font, 1);
						}
						else
						{

							iNextWord = iIndex;
							while (!IS_WHITESPACE(mpText[iNextWord]) && mpText[iNextWord])
							{
								iNextWord++;
							}
							iWordWidth = gc->TextWidthLen(&mpText[iIndex], font, iNextWord-iIndex);
							// only do a line break if there is something already on the line
							if (iWidthUsed + iWordWidth > iWidthAvailable && iWidthUsed > 0)
							{
								// the next word_ will not fit; break the line.
								AddLine(iIndex);
								iWidthUsed = iWordWidth;
								miMaxLineWidth = EBSMAX(miMaxLineWidth, iWordWidth);
								iIndex = iNextWord;
							}
							else
							{
								// the next word_ will fit on this line
								iWidthUsed += iWordWidth;
								miMaxLineWidth = EBSMAX(miMaxLineWidth, iWordWidth);
								iIndex = iNextWord;
							}
						}
					}
#endif
					break;
			}
		}

//.........这里部分代码省略.........
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:101,代码来源:wtedbox.cpp


示例18: GetFrameRect

void WebEditBox::DrawThisOnly (DISPLAY_INT x, DISPLAY_INT y, WebGraphics *gc)
{
	WebChar c;
	long line;

	WebRect box;
	GetFrameRect(&box);
	box.Shift(x,y);

//	gc->StartBuffer();                      // begin buffering graphics commands
	gc->Rectangle(&box, GetBgColor(gc), GetBgColor(gc), 1);	// draw background
	DrawFrame(&box, gc);

	// save the current graphics context clip rectangle and set clipping to the
	//  text display region of the widget
	GetTextRect(&box);
	box.Shift(x,y);
	WebRect clipSave;
	gc->GetClip(&clipSave);
	if (clipSave.Overlaps(&box))
	{
		WebRect clip(box);
		clip.And(&clipSave);
		gc->SetClip(&clip);

		miXOffset = (mpHScroll)? mpHScroll->GetPosition() : 0;
		miYOffset = (mpVScroll)? mpVScroll->GetPosition() : 0;

		// render our text
		WebFont font = mFont.GetFont();
		if (mpText && font)
		{
			// this loop draws up to the last line
			for (line=0; line<(miNumLines-1); line++)
			{
				c = mpText[GetLineOffset(line+1)];
				mpText[GetLineOffset(line+1)] = 0;
				DrawText(gc, box.left - miXOffset, box.top - miYOffset + (line * WEB_FONT_HEIGHT(font)),
				         mpText + GetLineOffset(line), GetTextColor(gc), 0, 0, font);
				mpText[GetLineOffset(line+1)] = c;
			}

			// now draw the last line of text.
			DrawText(gc, box.left - miXOffset, box.top - miYOffset + (line*WEB_FONT_HEIGHT(font)),
			         mpText + GetLineOffset(line), GetTextColor(gc), 0, 0, font);

			// if we have the focus, draw the cursor
			if ((mFlags & DISPLAY_FLAG_FOCUS) && !(mFlags & DISPLAY_FLAG_DISABLED))
			{
				// now render the selected portion in reverse video (if we have one)
				if (mEditFlags & EDIT_FLAG_HAS_SELECTION)
				{
					long begin = EBSMIN(miCursorPos, miSelectBegin);
					long end = EBSMAX(miCursorPos, miSelectBegin);
					long beginLine = FindLine(begin), endLine = FindLine(end);
					DISPLAY_INT textLeft;
					long currentBegin, currentEnd;

					for (line=beginLine; line<=endLine; line++)
					{
						currentBegin = EBSMAX(begin, GetLineOffset(line));
						if (line == endLine)
						{
							currentEnd = end;
						}
						else
						{
							currentEnd = EBSMIN(end, GetLineOffset(line+1));
						}
						textLeft = gc->TextWidthLen(mpText + GetLineOffset(line), font, EBSMAX(0, begin - GetLineOffset(line)));

						c = mpText[currentEnd];
						mpText[currentEnd] = 0;
						DrawText(gc, box.left - miXOffset + textLeft,
						             box.top - miYOffset + (line*WEB_FONT_HEIGHT(font)),
						             mpText + currentBegin, GetBgColor(gc), GetSelectColor(gc), 1, font);
						mpText[currentEnd] = c;
					}
				}

				DISPLAY_INT cursorX = box.left - miXOffset +
					gc->TextWidthLen(mpText + GetLineOffset(miCurrentLine), font, miCursorPos - GetLineOffset(miCurrentLine)) ;
				box.Set(cursorX, box.top - miYOffset + WEB_FONT_HEIGHT(font)*miCurrentLine,
				        cursorX, box.top - miYOffset + WEB_FONT_HEIGHT(font)*(miCurrentLine+1));
				gc->Rectangle(&box, GetSelectColor(gc), GetSelectColor(gc), 1);
			}

		}

		gc->SetClip(&clipSave);	 // restore the clip rectangle
	} // if clip overlaps

/*	if (mpVScroll && mpHScroll)
	{
		GetCornerRect(&box);
		box.Shift(x,y);
		gc->Rectangle(&box, LIGHTGRAY, LIGHTGRAY, 1);
	}*/

//	gc->EndBuffer();	     // send all buffered commands to the display
//.........这里部分代码省略.........
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:101,代码来源:wtedbox.cpp


示例19:

// x,y are in same coordinate space as this->mRect; viewX, viewY is the upper left corner of the viewport in
//  the coordinate space of this->mRect
DisplayElement *DisplayElement::TrapEventPoint (DISPLAY_INT x, DISPLAY_INT y, DISPLAY_INT viewX, DISPLAY_INT viewY)
{
	// if we clip our children to our rect, and the point is outside our rect,
	//  then fail right away
	if (GetOverflow() == DISPLAY_OVERFLOW_HIDDEN)
	{
		WebRect clipRect;
		GetClipRect(&clipRect);
		if (!clipRect.Contains(x,y))
		{
			return (0);
		}
	}

	DisplayElement *pChild = mpLastChild, *pFound;

	// now search positive-z children in reverse order
	while (pChild && (pChild->GetZIndex() >= 0))
	{
		if (pChild->mFlags & DISPLAY_FLAG_FIXED_POS)
		{
			pFound = pChild->TrapEventPoint(x - (mRect.left + viewX), y - (mRect.top + viewY), -mRect.left, -mRect.top);
		}
		else
		{
			pFound = pChild->TrapEventPoint(x - mRect.left, y - mRect.top, viewX - mRect.left, viewY - mRect.top);
		}

		if (pFound)
		{
			return (pFound);
		}
		pChild = pChild->mpPrev;
	}

	// if we contain the point, trap it
	if (TrapEventInThis(x,y))
	{
		return (this);
	}

	// now search negative-z children in reverse order
	while (pChild)
	{
		if (pChild->mFlags & DISPLAY_FLAG_FIXED_POS)
		{
			pFound = pChild->TrapEventPoint(x - (mRect.left + viewX), y - (mRect.top + viewY), -mRect.left, -mRect.top);
		}
		else
		{
			pFound = pChild->TrapEventPoint(x - mRect.left, y - mRect.top, viewX - mRect.left, viewY - mRect.top);
		}

		if (pFound)
		{
			return (pFound);
		}
		pChild = pChild->mpPrev;
	}

	return (0);
}
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:64,代码来源:delement.cpp


示例20: GetClipRect

void DisplayElement::Draw (DISPLAY_INT iScreenX, DISPLAY_INT iScreenY, WebRect *pViewport, WebGraphics *pGC)
{
	DisplayElement *pChild = mpFirstChild;
	WebRect clip, saveClip, screenClip;
	WEBC_BOOL clipRestore = WEBC_FALSE;

	pGC->GetClip(&saveClip);
	clip.Set(&saveClip);
	if (GetOverflow() != DISPLAY_OVERFLOW_VISIBLE)
	//if (GetOverflow() == DISPLAY_OVERFLOW_HIDDEN)
	{
		GetClipRect(&screenClip);
		screenClip.Shift(iScreenX - mRect.left, iScreenY - mRect.top);
		if (!clip.Overlaps(&screenClip))
		{
			// we're not visible, so neither are our children
			return;
		}
		clip.And(&screenClip);
		pGC->SetClip(&clip);
		clipRestore = WEBC_TRUE;
	}

	WebRect screenRect(mRect);
	screenRect.MoveTo(iScreenX, iScreenY);
	mScreenRect = screenRect; // April2013 - save the screenrect of last known draw and subtract boundaries of the display manager screenrect
	DisplayManager*pManager= this->GetManager();
	if (pManager && pManager->mBrowser)
		pManager=pManager->mBrowser->GetDisplayManager();
	if (pManager)
	{
	WebRect r;
//	printf("Not working all the way \n");
		r=pManager->mScreenRect;
		mScreenRect.top -= r.top;
		mScreenRect.bottom -= r.top;
		mScreenRect.left -= r.left;
		mScreenRect.right -= r.left;
	}  // April2013 - end save the screenrect of last known draw and subtract boundaries of the display manager screenrect
	// Start drawing
//	pGC->StartBuffer();

	// Draw negative-z children
	while (pChild && (pChild->GetZIndex() < 0))
	{
		if (pChild->mFlags & DISPLAY_FLAG_FIXED_POS)
		{
			pChild->Draw(pViewport->left + pChild->mRect.left, pViewport->top + pChild->mRect.top, pViewport, pGC);
		}
		else
		{
			pChild->Draw(iScreenX + pChild->mRect.left, iScreenY + pChild->mRect.top, pViewport, pGC);
		}
		pChild = pChild->mpNext;
	}

	// if I am visible
	if (screenRect.Overlaps(&clip))
	{
		// Draw myself
		DrawThisOnly(iScreenX, iScreenY, pGC);
	}
#if (INCLUDE_EXPERIMENTAL_DIV_SCROLLBARS)
	int xContentOffset=0;
	int yContentOffset=0;

	if (clipRestore && vScrollWidth() || hScrollWidth())
	{
		WebRect contentClip;
		contentClip.Set(&clip);
		contentClip.SetHeight(contentClip.Height()-hScrollWidth());
		contentClip.SetWidth(contentClip.Width()-vScrollWidth());
		pGC->SetClip(&contentClip);

		if (GetHScroll())
		{
			WebHScroll *pScroll = (WebHScroll *)GetHScroll();
			xContentOffset=pScroll->GetPosition();
		}
		if (GetVScroll())
		{
			WebVScroll *pScroll = (WebVScroll *)GetVScroll();
			yContentOffset=pScroll->GetPosition();
			if (yContentOffset)
			{ // If we have a y offset step i nto the content holder element
			  // so we don't exclude the whole thing becuase it is out of our
			  // range.
		//		if (GetInlineContentHolder())
		//			pChild = GetInlineContentHolder()->mpFirstChild;
				;
			}
		}
	}
#endif

	// Draw positive-z children
	while (pChild)
	{
#if (INCLUDE_EXPERIMENTAL_DIV_SCROLLBARS)
		if (pChild->IncludeInFlow() && pChild->mRect.bottom >= yContentOffset && pChild->mRect.right >= xContentOffset)
//.........这里部分代码省略.........
开发者ID:peteratebs,项目名称:webcwebbrowser,代码行数:101,代码来源:delement.cpp



注:本文中的WebRect类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WebRequest类代码示例发布时间:2022-05-31
下一篇:
C++ WebPreferences类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap