本文整理汇总了C++中rect函数的典型用法代码示例。如果您正苦于以下问题:C++ rect函数的具体用法?C++ rect怎么用?C++ rect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deriveDragLabelFont
PassOwnPtr<DragImage> DragImage::create(const KURL& url, const String& inLabel, const FontDescription& systemFont, float deviceScaleFactor)
{
const Font labelFont = deriveDragLabelFont(kDragLinkLabelFontSize, FontWeightBold, systemFont);
const Font urlFont = deriveDragLabelFont(kDragLinkUrlFontSize, FontWeightNormal, systemFont);
FontCachePurgePreventer fontCachePurgePreventer;
bool drawURLString = true;
bool clipURLString = false;
bool clipLabelString = false;
String urlString = url.string();
String label = inLabel.stripWhiteSpace();
if (label.isEmpty()) {
drawURLString = false;
label = urlString;
}
// First step is drawing the link drag image width.
TextRun labelRun(label.impl());
TextRun urlRun(urlString.impl());
IntSize labelSize(labelFont.width(labelRun), labelFont.fontMetrics().ascent() + labelFont.fontMetrics().descent());
if (labelSize.width() > kMaxDragLabelStringWidth) {
labelSize.setWidth(kMaxDragLabelStringWidth);
clipLabelString = true;
}
IntSize urlStringSize;
IntSize imageSize(labelSize.width() + kDragLabelBorderX * 2, labelSize.height() + kDragLabelBorderY * 2);
if (drawURLString) {
urlStringSize.setWidth(urlFont.width(urlRun));
urlStringSize.setHeight(urlFont.fontMetrics().ascent() + urlFont.fontMetrics().descent());
imageSize.setHeight(imageSize.height() + urlStringSize.height());
if (urlStringSize.width() > kMaxDragLabelStringWidth) {
imageSize.setWidth(kMaxDragLabelWidth);
clipURLString = true;
} else
imageSize.setWidth(std::max(labelSize.width(), urlStringSize.width()) + kDragLabelBorderX * 2);
}
// We now know how big the image needs to be, so we create and
// fill the background
IntSize scaledImageSize = imageSize;
scaledImageSize.scale(deviceScaleFactor);
OwnPtr<ImageBuffer> buffer(ImageBuffer::create(scaledImageSize));
if (!buffer)
return nullptr;
buffer->canvas()->scale(deviceScaleFactor, deviceScaleFactor);
const float DragLabelRadius = 5;
IntRect rect(IntPoint(), imageSize);
SkPaint backgroundPaint;
backgroundPaint.setColor(SkColorSetRGB(140, 140, 140));
SkRRect rrect;
rrect.setRectXY(SkRect::MakeWH(imageSize.width(), imageSize.height()), DragLabelRadius, DragLabelRadius);
buffer->canvas()->drawRRect(rrect, backgroundPaint);
// Draw the text
SkPaint textPaint;
if (drawURLString) {
if (clipURLString)
urlString = StringTruncator::centerTruncate(urlString, imageSize.width() - (kDragLabelBorderX * 2.0f), urlFont);
IntPoint textPos(kDragLabelBorderX, imageSize.height() - (kLabelBorderYOffset + urlFont.fontMetrics().descent()));
TextRun textRun(urlString);
urlFont.drawText(buffer->canvas(), TextRunPaintInfo(textRun), textPos, deviceScaleFactor, textPaint);
}
if (clipLabelString)
label = StringTruncator::rightTruncate(label, imageSize.width() - (kDragLabelBorderX * 2.0f), labelFont);
bool hasStrongDirectionality;
TextRun textRun = textRunWithDirectionality(label, &hasStrongDirectionality);
IntPoint textPos(kDragLabelBorderX, kDragLabelBorderY + labelFont.fontDescription().computedPixelSize());
if (hasStrongDirectionality && textRun.direction() == RTL) {
float textWidth = labelFont.width(textRun);
int availableWidth = imageSize.width() - kDragLabelBorderX * 2;
textPos.setX(availableWidth - ceilf(textWidth));
}
labelFont.drawBidiText(buffer->canvas(), TextRunPaintInfo(textRun), FloatPoint(textPos), Font::DoNotPaintIfFontNotReady, deviceScaleFactor, textPaint);
RefPtr<Image> image = buffer->newImageSnapshot();
return DragImage::create(image.get(), DoNotRespectImageOrientation, deviceScaleFactor);
}
示例2: BeginPaint
LRESULT CALLBACK NotificationWnd::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)\
{
NotificationWnd *wnd = (NotificationWnd *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (WM_ERASEBKGND == message) {
// do nothing, helps to avoid flicker
return TRUE;
}
if (WM_TIMER == message && TIMEOUT_TIMER_ID == wParam) {
if (wnd->notificationCb)
wnd->notificationCb->RemoveNotification(wnd);
else
delete wnd;
return 0;
}
if (WM_PAINT == message && wnd) {
PAINTSTRUCT ps;
HDC hdcWnd = BeginPaint(hwnd, &ps);
ClientRect rect(hwnd);
DoubleBuffer buffer(hwnd, rect);
HDC hdc = buffer.GetDC();
HFONT oldfnt = SelectFont(hdc, wnd->font);
RECT rTmp = rect.ToRECT();
DrawFrameControl(hdc, &rTmp, DFC_BUTTON, DFCS_BUTTONPUSH);
if (wnd->highlight) {
SetBkMode(hdc, OPAQUE);
SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
}
else {
SetBkMode(hdc, TRANSPARENT);
SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
}
rect.Inflate(-PADDING, -PADDING);
RectI rectMsg = rect;
if (wnd->hasProgress)
rectMsg.dy -= PROGRESS_HEIGHT + PADDING / 2;
if (wnd->hasCancel)
rectMsg.dx -= 20;
ScopedMem<WCHAR> text(win::GetText(hwnd));
rTmp = rectMsg.ToRECT();
DrawText(hdc, text, -1, &rTmp, DT_SINGLELINE | DT_NOPREFIX);
if (wnd->hasCancel) {
rTmp = GetCancelRect(hwnd).ToRECT();
DrawFrameControl(hdc, &rTmp, DFC_CAPTION, DFCS_CAPTIONCLOSE | DFCS_FLAT);
}
if (wnd->hasProgress) {
rect.dx = wnd->progressWidth;
rect.y += rectMsg.dy + PADDING / 2;
rect.dy = PROGRESS_HEIGHT;
PaintRect(hdc, rect);
rect.x += 2;
rect.dx = (wnd->progressWidth - 3) * wnd->progress / 100;
rect.y += 2;
rect.dy -= 3;
HBRUSH brush = GetStockBrush(BLACK_BRUSH);
rTmp = rect.ToRECT();
FillRect(hdc, &rTmp, brush);
DeleteObject(brush);
}
SelectFont(hdc, oldfnt);
buffer.Flush(hdcWnd);
EndPaint(hwnd, &ps);
return 0;
}
if (WM_SETCURSOR == message && wnd->hasCancel) {
PointI pt;
if (GetCursorPosInHwnd(hwnd, pt) &&
GetCancelRect(hwnd).Contains(pt)) {
SetCursor(LoadCursor(NULL, IDC_HAND));
return TRUE;
}
}
if (WM_LBUTTONUP == message && wnd->hasCancel) {
if (GetCancelRect(hwnd).Contains(PointI(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)))) {
if (wnd->notificationCb)
wnd->notificationCb->RemoveNotification(wnd);
else
delete wnd;
return 0;
}
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
示例3: Display
void CDrawRectOutline::MoveField(int w, CDPoint r)
{
Display();
CDRect rect( m_point_a.x, m_point_a.y, m_point_b.x, m_point_b.y );
rect.NormalizeRect();
switch (w)
{
case CRectTracker::hitTopLeft:
rect.left += r.x;
rect.top += r.y;
break;
case CRectTracker::hitTopRight:
rect.right += r.x;
rect.top += r.y;
break;
case CRectTracker::hitBottomRight:
rect.right += r.x;
rect.bottom += r.y;
break;
case CRectTracker::hitBottomLeft:
rect.left += r.x;
rect.bottom += r.y;
break;
case CRectTracker::hitTop:
rect.top += r.y;
break;
case CRectTracker::hitRight:
rect.right += r.x;
break;
case CRectTracker::hitBottom:
rect.bottom += r.y;
break;
case CRectTracker::hitLeft:
rect.left += r.x;
break;
case 11:
case CRectTracker::hitMiddle:
rect += r;
break;
}
if (m_point_a.x < m_point_b.x)
{
m_point_a.x = rect.left;
m_point_b.x = rect.right;
}
else
{
m_point_b.x = rect.left;
m_point_a.x = rect.right;
}
if (m_point_a.y < m_point_b.y)
{
m_point_a.y = rect.top;
m_point_b.y = rect.bottom;
}
else
{
m_point_b.y = rect.top;
m_point_a.y = rect.bottom;
}
Display();
}
示例4: placingFootprint
int StructureManager::placeStructureFromDeed(CreatureObject* creature, StructureDeed* deed, float x, float y, int angle) {
ManagedReference<Zone*> zone = creature->getZone();
//Already placing a structure?
if (zone == NULL || creature->containsActiveSession(SessionFacadeType::PLACESTRUCTURE))
return 1;
ManagedReference<PlanetManager*> planetManager = zone->getPlanetManager();
String serverTemplatePath = deed->getGeneratedObjectTemplate();
if (deed->getFaction() != 0 && creature->getFaction() != deed->getFaction()) {
creature->sendSystemMessage("You are not the correct faction");
return 1;
}
Reference<SharedStructureObjectTemplate*> serverTemplate =
dynamic_cast<SharedStructureObjectTemplate*>(templateManager->getTemplate(serverTemplatePath.hashCode()));
//Check to see if this zone allows this structure.
if (serverTemplate == NULL || !serverTemplate->isAllowedZone(zone->getZoneName())) {
creature->sendSystemMessage("@player_structure:wrong_planet"); //That deed cannot be used on this planet.
return 1;
}
if (!planetManager->isBuildingPermittedAt(x, y, creature)) {
creature->sendSystemMessage("@player_structure:not_permitted"); //Building is not permitted here.
return 1;
}
SortedVector<ManagedReference<ActiveArea*> > objects;
zone->getInRangeActiveAreas(x, y, &objects, true);
ManagedReference<CityRegion*> city;
for (int i = 0; i < objects.size(); ++i) {
ActiveArea* area = objects.get(i).get();
if (!area->isRegion())
continue;
city = dynamic_cast<Region*>(area)->getCityRegion();
if (city != NULL)
break;
}
SortedVector<ManagedReference<QuadTreeEntry*> > inRangeObjects;
zone->getInRangeObjects(x, y, 128, &inRangeObjects, true);
float placingFootprintLength0, placingFootprintWidth0, placingFootprintLength1, placingFootprintWidth1;
if (!getStructureFootprint(serverTemplate, angle, placingFootprintLength0, placingFootprintWidth0, placingFootprintLength1, placingFootprintWidth1)) {
float x0 = x + placingFootprintWidth0;
float y0 = y + placingFootprintLength0;
float x1 = x + placingFootprintWidth1;
float y1 = y + placingFootprintLength1;
BoundaryRectangle placingFootprint(x0, y0, x1, y1);
//info("placing center x:" + String::valueOf(x) + " y:" + String::valueOf(y), true);
//info("placingFootprint x0:" + String::valueOf(x0) + " y0:" + String::valueOf(y0) + " x1:" + String::valueOf(x1) + " y1:" + String::valueOf(y1), true);
for (int i = 0; i < inRangeObjects.size(); ++i) {
SceneObject* scene = inRangeObjects.get(i).castTo<SceneObject*>();
if (scene == NULL)
continue;
float l0 = -5; //Along the x axis.
float w0 = -5; //Along the y axis.
float l1 = 5;
float w1 = 5;
if (getStructureFootprint(scene->getObjectTemplate(), scene->getDirectionAngle(), l0, w0, l1, w1))
continue;
float xx0 = scene->getPositionX() + (w0 + 0.1);
float yy0 = scene->getPositionY() + (l0 + 0.1);
float xx1 = scene->getPositionX() + (w1 - 0.1);
float yy1 = scene->getPositionY() + (l1 - 0.1);
BoundaryRectangle rect(xx0, yy0, xx1, yy1);
//info("existing footprint xx0:" + String::valueOf(xx0) + " yy0:" + String::valueOf(yy0) + " xx1:" + String::valueOf(xx1) + " yy1:" + String::valueOf(yy1), true);
// check 4 points of the current rect
if (rect.containsPoint(x0, y0)
|| rect.containsPoint(x0, y1)
|| rect.containsPoint(x1, y0)
|| rect.containsPoint(x1, y1) ) {
//info("existing footprint contains placing point", true);
creature->sendSystemMessage("@player_structure:no_room"); //there is no room to place the structure here..
return 1;
}
if (placingFootprint.containsPoint(xx0, yy0)
//.........这里部分代码省略.........
示例5: resizeEvent
void CloudView::resizeEvent(QResizeEvent *event)
{
resizer_->move(rect().bottomRight() - resizer_->rect().bottomRight());
resizer_->raise();
}
示例6: return
QSEqualsResult QSRectClass::isEqual(const QSObject &a, const QSObject &b) const
{
if (!b.isA(this))
return EqualsNotEqual;
return (QSEqualsResult)(*rect(&a) == *rect(&b));
}
示例7: graphics
void CDuiEdit::DrawControl(CDC &dc, CRect rcUpdate)
{
Graphics graphics(dc);
DrawImageFrame(graphics, m_pImage, m_rc, m_EditState * m_sizeImage.cx, 0, m_sizeImage.cx, m_sizeImage.cy, 4);
if(m_pLeftImage)
{
CRect rc;
rc.left = m_rc.left + 2;
rc.top = m_rc.top + (m_rc.Height() - m_sizeLeftImage.cy) / 2;
rc.right = rc.left + m_sizeLeftImage.cx;
rc.bottom = rc.top + m_sizeLeftImage.cy;
if(m_nLeftImageCount > m_buttonState)
{
graphics.DrawImage(m_pLeftImage, RectF((Gdiplus::REAL)rc.left , (Gdiplus::REAL)rc.top, (Gdiplus::REAL)rc.Width(), (Gdiplus::REAL)rc.Height()),
(Gdiplus::REAL)(m_buttonState * m_sizeLeftImage.cx), 0, (Gdiplus::REAL)m_sizeLeftImage.cx, (Gdiplus::REAL)m_sizeLeftImage.cy, UnitPixel);
}else
{
graphics.DrawImage(m_pLeftImage, RectF((Gdiplus::REAL)rc.left , (Gdiplus::REAL)rc.top, (Gdiplus::REAL)rc.Width(), (Gdiplus::REAL)rc.Height()),
0, 0, (Gdiplus::REAL)m_sizeLeftImage.cx, (Gdiplus::REAL)m_sizeLeftImage.cy, UnitPixel);
}
}
if(m_pSmallImage)
{
CRect rc;
rc.left = m_rc.right - m_sizeSmallImage.cx - 2;
rc.top = m_rc.top + (m_rc.Height() - m_sizeSmallImage.cy) / 2;
rc.right = rc.left + m_sizeSmallImage.cx;
rc.bottom = rc.top + m_sizeSmallImage.cy;
if(m_nSmallImageCount > m_buttonState)
{
graphics.DrawImage(m_pSmallImage, RectF((Gdiplus::REAL)rc.left , (Gdiplus::REAL)rc.top, (Gdiplus::REAL)rc.Width(), (Gdiplus::REAL)rc.Height()),
(Gdiplus::REAL)(m_buttonState * m_sizeSmallImage.cx), 0, (Gdiplus::REAL)m_sizeSmallImage.cx, (Gdiplus::REAL)m_sizeSmallImage.cy, UnitPixel);
}else
{
graphics.DrawImage(m_pSmallImage, RectF((Gdiplus::REAL)rc.left , (Gdiplus::REAL)rc.top, (Gdiplus::REAL)rc.Width(), (Gdiplus::REAL)rc.Height()),
0, 0, (Gdiplus::REAL)m_sizeSmallImage.cx, (Gdiplus::REAL)m_sizeSmallImage.cy, UnitPixel);
}
}
BSTR bsFont = m_strFont.AllocSysString();
FontFamily fontFamily(bsFont);
Font font(&fontFamily, (REAL)m_nFontWidth, m_fontStyle, UnitPixel);
SolidBrush solidBrush(m_clrText);
SolidBrush solidBrushTip(m_clrTooltip);
graphics.SetTextRenderingHint( TextRenderingHintClearTypeGridFit );
::SysFreeString(bsFont);
StringFormat strFormat;
strFormat.SetAlignment(StringAlignmentNear); // 水平方向左对齐
if(!m_bMultiLine)
{
// 单行文字
strFormat.SetLineAlignment(StringAlignmentCenter); // 垂直方向中间对齐
strFormat.SetFormatFlags( StringFormatFlagsNoWrap | StringFormatFlagsMeasureTrailingSpaces);
}else
{
strFormat.SetLineAlignment(StringAlignmentNear); // 垂直方向上对齐
}
RectF rect((Gdiplus::REAL)m_rcText.left, (Gdiplus::REAL)(m_rcText.top+2), (Gdiplus::REAL)m_rcText.Width(), (Gdiplus::REAL)(m_rcText.Height()-2));
if(!m_strTitle.IsEmpty())
{
// 文字非空
CString strTitle = m_strTitle;
if(m_bPassWord)
{
int nlen = strTitle.GetLength();
strTitle = "";
for(int i = 0; i < nlen; i++)
{
strTitle += '*';
}
}
BSTR bsTitle = strTitle.AllocSysString();
graphics.DrawString(bsTitle, (INT)wcslen(bsTitle), &font, rect, &strFormat, &solidBrush);
::SysFreeString(bsTitle);
}else
if(!m_strTooltip.IsEmpty())
{
// 如果没有文字,但设置了tooltip,则显示tooltip
BSTR bsTooltip = m_strTooltip.AllocSysString();
graphics.DrawString(bsTooltip, (INT)wcslen(bsTooltip), &font, rect, &strFormat, &solidBrushTip);
::SysFreeString(bsTooltip);
}
}
示例8: rect_empty
void rect_empty()
{
rect(buffer,cursor_x,cursor_y,cursor_x+20,cursor_y+20,makecol(0,0,255));
draw_sprite(screen,buffer,0,0);
}
示例9: rect
void AreaDialog::mouseMoveEvent(QMouseEvent* e)
{
mMouseMagnifier = false;
if (mMouseDown) {
mMousePos = e->pos();
if (mNewSelection) {
QRect r = rect();
mSelection = QRect(mDragStartPoint, limitPointToRect(mMousePos, r)).normalized();
}
else if (mMouseOverHandle == 0) { // moving the whole selection
QRect r = rect().normalized(), s = mSelectionBeforeDrag.normalized();
QPoint p = s.topLeft() + e->pos() - mDragStartPoint;
r.setBottomRight(r.bottomRight() - QPoint(s.width(), s.height()));
if (!r.isNull() && r.isValid())
mSelection.moveTo(limitPointToRect(p, r));
}
else {// dragging a handle
QRect r = mSelectionBeforeDrag;
QPoint offset = e->pos() - mDragStartPoint;
if (mMouseOverHandle == &mTLHandle || mMouseOverHandle == &mTHandle
|| mMouseOverHandle == &mTRHandle) // dragging one of the top handles
{
r.setTop(r.top() + offset.y());
}
if (mMouseOverHandle == &mTLHandle || mMouseOverHandle == &mLHandle
|| mMouseOverHandle == &mBLHandle) // dragging one of the left handles
{
r.setLeft(r.left() + offset.x());
}
if (mMouseOverHandle == &mBLHandle || mMouseOverHandle == &mBHandle
|| mMouseOverHandle == &mBRHandle) // dragging one of the bottom handles
{
r.setBottom(r.bottom() + offset.y());
}
if (mMouseOverHandle == &mTRHandle || mMouseOverHandle == &mRHandle
|| mMouseOverHandle == &mBRHandle) // dragging one of the right handles
{
r.setRight(r.right() + offset.x());
}
r = r.normalized();
r.setTopLeft(limitPointToRect(r.topLeft(), rect()));
r.setBottomRight(limitPointToRect(r.bottomRight(), rect()));
mSelection = r;
}
if (qApp->keyboardModifiers() & Qt::ControlModifier)
{
// The lazy 1:1 aspect ratio approach!
mSelection.setHeight(mSelection.width());
}
if (mAcceptWidget) {
QPoint acceptPos = e->pos();
QRect acceptRect = QRect(acceptPos, QSize(120, 70));
// Prevent the widget from overlapping the handles
if (acceptRect.intersects(mTLHandle)) {
acceptPos = mTLHandle.bottomRight() + QPoint(2, 2); // Corner case
}
if (acceptRect.intersects(mBRHandle)) {
acceptPos = mBRHandle.bottomRight();
}
if (acceptRect.intersects(mBHandle)) {
acceptPos = mBHandle.bottomRight();
}
if (acceptRect.intersects(mRHandle)) {
acceptPos = mRHandle.topRight();
}
if (acceptRect.intersects(mTHandle)) {
acceptPos = mTHandle.bottomRight();
}
if ((acceptPos.x()+120) > mScreenshot->pixmap().rect().width())
acceptPos.setX(acceptPos.x()-120);
if ((acceptPos.y()+70) > mScreenshot->pixmap().rect().height())
acceptPos.setY(acceptPos.y()-70);
mAcceptWidget->move(acceptPos);
}
update();
}
else
{
if (mSelection.isNull()) {
//.........这里部分代码省略.........
示例10: invalidate_surfaces
void surface_manager::invalidate_surfaces()
{
for (auto& s : iSurfaces)
s->invalidate_surface(rect(point{}, s->surface_size()), false);
}
示例11: parseArgs
/**
* Parse command line arguments
*
* @param argc Number of arguments in array argv
* @param argv Arguments array
*
* @return true to continue with application launch; otherwise false
*/
bool parseArgs()
{
QStringListIterator it(QCoreApplication::arguments());
while (it.hasNext() == true)
{
QString arg(it.next());
if ((arg == "-c" || arg == "--closebutton") && it.hasNext() == true)
{
QString str(it.next());
QStringList parts = str.split(",");
if (parts.size() == 4)
{
QRect rect(parts[0].toInt(), parts[1].toInt(),
parts[2].toInt(), parts[3].toInt());
if (rect.isValid() == true)
QLCArgs::closeButtonRect = rect;
}
}
else if (arg == "-d" || arg == "--debug")
{
if (it.hasNext() == true)
QLCArgs::debugLevel = QtMsgType(it.peekNext().toInt());
else
QLCArgs::debugLevel = QtMsgType(0);
}
else if (arg == "-f" || arg == "--fullscreen")
{
QLCArgs::fullScreen = true;
if (it.hasNext() == true && it.peekNext() == "resize")
QLCArgs::fullScreenResize = true;
}
else if (arg == "-h" || arg == "--help")
{
printUsage();
return false;
}
else if (arg == "-k" || arg == "--kiosk")
{
QLCArgs::kioskMode = true;
}
else if (arg == "-l" || arg == "--locale")
{
if (it.hasNext() == true)
QLCi18n::setDefaultLocale(it.next());
}
else if (arg == "-o" || arg == "--open")
{
if (it.hasNext() == true)
QLCArgs::workspace = it.next();
}
else if (arg == "-p" || arg == "--operate")
{
QLCArgs::operate = true;
}
else if (arg == "-v" || arg == "--version")
{
/* Don't print anything, since version is always
printed before anything else. Just make the app
exit by returning false. */
return false;
}
}
return true;
}
示例12: NS_ASSERTION
//.........这里部分代码省略.........
BigImageIterator* bigImgIter = source->AsBigImageIterator();
BigImageIterator* iterOnWhite = nullptr;
if (bigImgIter) {
bigImgIter->BeginBigImageIteration();
}
if (sourceOnWhite) {
iterOnWhite = sourceOnWhite->AsBigImageIterator();
MOZ_ASSERT(!bigImgIter || bigImgIter->GetTileCount() == iterOnWhite->GetTileCount(),
"Tile count mismatch on component alpha texture");
if (iterOnWhite) {
iterOnWhite->BeginBigImageIteration();
}
}
bool usingTiles = (bigImgIter && bigImgIter->GetTileCount() > 1);
do {
if (iterOnWhite) {
MOZ_ASSERT(iterOnWhite->GetTileRect() == bigImgIter->GetTileRect(),
"component alpha textures should be the same size.");
}
nsIntRect texRect = bigImgIter ? bigImgIter->GetTileRect()
: nsIntRect(0, 0,
texSize.width,
texSize.height);
// Draw texture. If we're using tiles, we do repeating manually, as texture
// repeat would cause each individual tile to repeat instead of the
// compound texture as a whole. This involves drawing at most 4 sections,
// 2 for each axis that has texture repeat.
for (int y = 0; y < (usingTiles ? 2 : 1); y++) {
for (int x = 0; x < (usingTiles ? 2 : 1); x++) {
nsIntRect currentTileRect(texRect);
currentTileRect.MoveBy(x * texSize.width, y * texSize.height);
nsIntRegionRectIterator screenIter(screenRects);
nsIntRegionRectIterator regionIter(regionRects);
const nsIntRect* screenRect;
const nsIntRect* regionRect;
while ((screenRect = screenIter.Next()) &&
(regionRect = regionIter.Next())) {
nsIntRect tileScreenRect(*screenRect);
nsIntRect tileRegionRect(*regionRect);
// When we're using tiles, find the intersection between the tile
// rect and this region rect. Tiling is then handled by the
// outer for-loops and modifying the tile rect.
if (usingTiles) {
tileScreenRect.MoveBy(-origin);
tileScreenRect = tileScreenRect.Intersect(currentTileRect);
tileScreenRect.MoveBy(origin);
if (tileScreenRect.IsEmpty())
continue;
tileRegionRect = regionRect->Intersect(currentTileRect);
tileRegionRect.MoveBy(-currentTileRect.TopLeft());
}
gfx::Rect rect(tileScreenRect.x, tileScreenRect.y,
tileScreenRect.width, tileScreenRect.height);
effect->mTextureCoords = Rect(Float(tileRegionRect.x) / texRect.width,
Float(tileRegionRect.y) / texRect.height,
Float(tileRegionRect.width) / texRect.width,
Float(tileRegionRect.height) / texRect.height);
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain, aOpacity, aTransform);
if (usingTiles) {
DiagnosticFlags diagnostics = DiagnosticFlags::CONTENT | DiagnosticFlags::BIGIMAGE;
if (iterOnWhite) {
diagnostics |= DiagnosticFlags::COMPONENT_ALPHA;
}
GetCompositor()->DrawDiagnostics(diagnostics, rect, aClipRect,
aTransform, mFlashCounter);
}
}
}
}
if (iterOnWhite) {
iterOnWhite->NextTile();
}
} while (usingTiles && bigImgIter->NextTile());
if (bigImgIter) {
bigImgIter->EndBigImageIteration();
}
if (iterOnWhite) {
iterOnWhite->EndBigImageIteration();
}
DiagnosticFlags diagnostics = DiagnosticFlags::CONTENT;
if (iterOnWhite) {
diagnostics |= DiagnosticFlags::COMPONENT_ALPHA;
}
GetCompositor()->DrawDiagnostics(diagnostics, *aVisibleRegion, aClipRect,
aTransform, mFlashCounter);
}
示例13: UpdateMemDC
void CSelectBox::DrawControl(CDC &dc, CRect rcUpdate)
{
int nWidth = m_rc.Width();
int nHeight = m_rc.Height();
int nItemWidth = nWidth / m_nXCount;
int nItemHeight = nHeight / m_nYCount;
int nXPos = (nWidth - nItemWidth * m_nXCount) / 2;
int nYPos = (nHeight - nItemHeight * m_nYCount) / 2;
if(!m_bUpdate)
{
UpdateMemDC(dc, nWidth, nHeight * 3);
m_memDC.BitBlt(0, 0, nWidth, nHeight, &dc, m_rc.left ,m_rc.top, SRCCOPY);
int nXPosTemp = nXPos;
int nYPosTemp = nYPos;
Graphics graphics(m_memDC);
Pen pen(m_clrFrame, 1);
for(int i = 0; i <= m_nYCount; i++)
{
graphics.DrawLine(&pen, nXPos, nYPosTemp, nXPos + nItemWidth * m_nXCount, nYPosTemp);
nYPosTemp += nItemHeight;
}
for(int i = 0; i <= m_nXCount; i++)
{
graphics.DrawLine(&pen, nXPosTemp, nYPos, nXPosTemp, nYPos + nItemHeight * m_nYCount);
nXPosTemp += nItemWidth;
}
if(m_bImage)
{
for(size_t i = 0; i < m_vecpImage.size(); i++)
{
if(m_vecpImage[i] != NULL)
{
graphics.DrawImage(m_vecpImage[i], Rect(nXPos + nItemWidth * (i % m_nXCount) + 1, nYPos + nItemHeight * (i / m_nXCount) + 1, nItemWidth - 1, nItemHeight - 1),
0, 0, m_vecsizeImage[i].cx, m_vecsizeImage[i].cy, UnitPixel);
}
}
}
else
{
for(size_t i = 0; i < m_vecclr.size(); i++)
{
SolidBrush brush(m_vecclr[i]);
graphics.FillRectangle(&brush, nXPos + nItemWidth * (i % m_nXCount) + 1, nYPos + nItemHeight * (i / m_nXCount) + 1, nItemWidth - 1, nItemHeight - 1);
}
}
m_memDC.BitBlt(0, nHeight, nWidth, nHeight, &m_memDC, 0, 0, SRCCOPY);
m_memDC.BitBlt(0, nHeight * 2, nWidth, nHeight, &m_memDC, 0, 0, SRCCOPY);
//选择
SolidBrush brush(m_clrHover);
nYPosTemp = nYPos + nHeight;
if(m_bImage)
{
for(size_t i = 0; i < m_vecpImage.size(); i++)
{
graphics.FillRectangle(&brush, nXPos + nItemWidth * (i % m_nXCount) + 1, nYPosTemp + nItemHeight * (i / m_nXCount) + 1, nItemWidth - 1, nItemHeight - 1);
}
}
else
{
for(size_t i = 0; i < m_vecclr.size(); i++)
{
graphics.FillRectangle(&brush, nXPos + nItemWidth * (i % m_nXCount) + 1, nYPosTemp + nItemHeight * (i / m_nXCount) + 1, nItemWidth - 1, nItemHeight - 1);
}
}
int nLineWidth = m_bImage ? 2 : 1;
//选中
pen.SetColor(m_clrSelect);
pen.SetWidth((Gdiplus::REAL)nLineWidth);
nYPosTemp = nYPos + nHeight * 2;
for(int i = 0; i < m_nYCount; i++)
{
nXPosTemp = nXPos;
for(int j = 0; j < m_nXCount; j++)
{
Rect rect(nXPosTemp + nLineWidth, nYPosTemp + nLineWidth, nItemWidth - 1 - nLineWidth, nItemHeight - 1 - nLineWidth);
//绘制矩形
graphics.DrawRectangles(&pen, &rect, 1);
nXPosTemp += nItemWidth;
}
nYPosTemp += nItemHeight;
}
}
dc.BitBlt(m_rc.left,m_rc.top, m_rc.Width()+1, m_rc.Height()+1, &m_memDC, 0, 0, SRCCOPY);
if(m_nXSelect != -1 && m_nYSelect != -1)
{
//.........这里部分代码省略.........
示例14: while
IntRect Font::findGlyphRect(Page& page, unsigned int width, unsigned int height) const
{
// Find the line that fits well the glyph
Row* row = NULL;
float bestRatio = 0;
for (std::vector<Row>::iterator it = page.rows.begin(); it != page.rows.end() && !row; ++it)
{
float ratio = static_cast<float>(height) / it->height;
// Ignore rows that are either too small or too high
if ((ratio < 0.7f) || (ratio > 1.f))
continue;
// Check if there's enough horizontal space left in the row
if (width > page.texture.getSize().x - it->width)
continue;
// Make sure that this new row is the best found so far
if (ratio < bestRatio)
continue;
// The current row passed all the tests: we can select it
row = &*it;
bestRatio = ratio;
}
// If we didn't find a matching row, create a new one (10% taller than the glyph)
if (!row)
{
int rowHeight = height + height / 10;
while ((page.nextRow + rowHeight >= page.texture.getSize().y) || (width >= page.texture.getSize().x))
{
// Not enough space: resize the texture if possible
unsigned int textureWidth = page.texture.getSize().x;
unsigned int textureHeight = page.texture.getSize().y;
if ((textureWidth * 2 <= Texture::getMaximumSize()) && (textureHeight * 2 <= Texture::getMaximumSize()))
{
// Make the texture 2 times bigger
Image newImage;
newImage.create(textureWidth * 2, textureHeight * 2, Color(255, 255, 255, 0));
newImage.copy(page.texture.copyToImage(), 0, 0);
page.texture.loadFromImage(newImage);
}
else
{
// Oops, we've reached the maximum texture size...
err() << "Failed to add a new character to the font: the maximum texture size has been reached" << std::endl;
return IntRect(0, 0, 2, 2);
}
}
// We can now create the new row
page.rows.push_back(Row(page.nextRow, rowHeight));
page.nextRow += rowHeight;
row = &page.rows.back();
}
// Find the glyph's rectangle on the selected row
IntRect rect(row->width, row->top, width, height);
// Update the row informations
row->width += width;
return rect;
}
示例15: toVariant
QVariant QSRectClass::toVariant(const QSObject *obj, QVariant::Type) const
{
return *rect(obj);
}