void EmfPaintEngine::drawImage(const QRectF & r, const QImage & image, const QRectF &, Qt::ImageConversionFlags flags) { QMatrix m = painter()->worldMatrix(); QPointF p = m.map(r.topLeft()); int x = qRound(p.x()); int y = qRound(p.y()); int width = qRound(r.width()); int height = qRound(r.height()); #ifdef Q_WS_WIN setClipping(); QPixmap pix = QPixmap::fromImage (image.scaled(width, height), flags); HBITMAP hbtmp = pix.toWinHBITMAP(); HDC hDC = CreateCompatibleDC(metaDC); SelectObject(hDC, hbtmp); BitBlt(metaDC, x, y, width, height, hDC, 0, 0, SRCCOPY); DeleteObject(hbtmp); DeleteDC(hDC); resetClipping(); #else QImage imag = image.scaled(width, height); for (int i = 0; i < width; i++){ for (int j = 0; j < height; j++){ QRgb rgb = imag.pixel(i, j); if (qAlpha(rgb) == 255) SetPixel(metaDC, x + i, y + j, RGB(qRed(rgb), qGreen(rgb), qBlue(rgb))); } } #endif }
void EmfPaintEngine::drawLines ( const QLineF * lines, int lineCount ) { setClipping(); HPEN wpen = convertPen(painter()->pen()); SelectObject(metaDC, wpen); QMatrix m = painter()->worldMatrix(); for (int i = 0; i < lineCount; i++) { POINT *pts = new POINT[2]; QPointF p1 = m.map(lines[i].p1()); QPointF p2 = m.map(lines[i].p2()); pts[0].x = qRound(p1.x()); pts[0].y = qRound(p1.y()); pts[1].x = qRound(p2.x()); pts[1].y = qRound(p2.y()); Polyline(metaDC, pts, 2); delete [] pts; } resetClipping(); DeleteObject(wpen); }
void EmfPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap & pix, const QPointF &) { setClipping(); #ifdef Q_WS_WIN HBITMAP hBmp = pix.toWinHBITMAP(); HBRUSH wbrush = CreatePatternBrush(hBmp); QMatrix m = painter()->worldMatrix(); QRectF dr = m.mapRect(r); RECT rect; rect.left = qRound(dr.left()); rect.top = qRound(dr.top()); rect.right = qRound(dr.right()); rect.bottom = qRound(dr.bottom()); FillRect(metaDC, &rect, wbrush); DeleteObject(hBmp); DeleteObject(wbrush); #else int width = qRound(r.width()); int height = qRound(r.height()); QPixmap pixmap(width, height); QPainter p(&pixmap); p.drawTiledPixmap(0, 0, width, height, pix); p.end(); drawPixmap(r, pixmap, QRectF()); #endif resetClipping(); }
void EmfPaintEngine::drawPolygon ( const QPointF * points, int pointCount, PolygonDrawMode mode ) { setClipping(); HPEN wpen = convertPen(painter()->pen()); SelectObject(metaDC, wpen); HBRUSH wbrush = convertBrush(painter()->brush()); SelectObject(metaDC, wbrush); POINT *pts = new POINT[pointCount]; QMatrix m = painter()->worldMatrix(); for (int i = 0; i < pointCount; i++){ QPointF p = m.map (points[i]); pts[i].x = qRound(p.x()); pts[i].y = qRound(p.y()); } if (mode == QPaintEngine::PolylineMode) Polyline(metaDC, pts, pointCount); else if (mode == QPaintEngine::OddEvenMode) Polygon(metaDC, pts, pointCount); else qWarning("EmfEngine: drawPolygon with unsupported mode.\n"); resetClipping(); delete [] pts; DeleteObject(wpen); DeleteObject(wbrush); }
void EmfPaintEngine::drawTextItem ( const QPointF & p, const QTextItem & textItem ) { setClipping(); SetBkMode( metaDC, TRANSPARENT ); QFont f = textItem.font(); QFontMetrics fm(f); HFONT wfont = CreateFontA(fm.height() - 1, fm.averageCharWidth(), 0, 0, 10*f.weight(), f.italic(), f.underline (), f.strikeOut(), DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, f.family().toAscii().data()); SelectObject( metaDC, wfont); QColor colour = painter()->pen().color(); SetTextColor( metaDC, RGB(colour.red(), colour.green(), colour.blue())); QString text = textItem.text(); int size = text.size(); QMatrix m = painter()->worldMatrix(); XFORM xf; xf.eM11 = m.m11(); xf.eM12 = m.m12(); xf.eM21 = m.m21(); xf.eM22 = m.m22(); xf.eDx = m.dx(); xf.eDy = m.dy(); SetWorldTransform(metaDC, &xf); #ifdef Q_WS_WIN wchar_t *wtext = (wchar_t *)malloc(size*sizeof(wchar_t)); if (!wtext){ qWarning("EmfEngine: Not enough memory in drawTextItem()."); return; } size = text.toWCharArray(wtext); TextOutW(metaDC, qRound(p.x()), qRound(p.y() - 0.85*fm.height()), wtext, size); free(wtext); #else TextOutA(metaDC, qRound(p.x()), qRound(p.y() - 0.85*fm.height()), text.toLocal8Bit().data(), size); #endif xf.eM11 = 1.0; xf.eM12 = 0.0; xf.eM21 = 0.0; xf.eM22 = 1.0; xf.eDx = 0.0; xf.eDy = 0.0; SetWorldTransform(metaDC, &xf); resetClipping(); DeleteObject(wfont); }
ChatMessageDelegate::ChatMessageDelegate(QObject *parent) : QItemDelegate(parent) { m_parent = (ChatMessageView* )parent; connect(&m_timerCheck, SIGNAL(timeout()), this, SLOT(timerCheck())); m_timerCheck.start(1000); setClipping(false); m_createInRealTime = false; //m_createInRealTime = true; }
void Painter::renderTileDebug(const RenderTile& tile) { MBGL_DEBUG_GROUP(std::string { "debug " } + util::toString(tile.id)); if (frame.debugOptions != MapDebugOptions::NoDebug) { setClipping(tile.clip); if (frame.debugOptions & (MapDebugOptions::Timestamps | MapDebugOptions::ParseStatus)) { renderDebugText(tile.tile, tile.matrix); } if (frame.debugOptions & MapDebugOptions::TileBorders) { renderDebugFrame(tile.matrix); } } }
void EmfPaintEngine::drawEllipse ( const QRectF & rect ) { setClipping(); HPEN wpen = convertPen(painter()->pen()); SelectObject(metaDC, wpen); HBRUSH wbrush = convertBrush(painter()->brush()); SelectObject(metaDC, wbrush); QRectF r = painter()->worldMatrix().mapRect(rect); Ellipse(metaDC, qRound(r.left()), qRound(r.top()), qRound(r.right()), qRound(r.bottom())); resetClipping(); DeleteObject(wpen); DeleteObject(wbrush); }
void EmfPaintEngine::drawRects ( const QRectF * rects, int rectCount ) { setClipping(); HPEN wpen = convertPen(painter()->pen()); SelectObject(metaDC, wpen); HBRUSH wbrush = convertBrush(painter()->brush()); SelectObject(metaDC, wbrush); QMatrix m = painter()->worldMatrix(); for (int i = 0; i < rectCount; i++){ QRectF r = m.mapRect(rects[i]); Rectangle(metaDC, qRound(r.left()), qRound(r.top()), qRound(r.right()), qRound(r.bottom())); } resetClipping(); DeleteObject(wpen); DeleteObject(wbrush); }
void EmfPaintEngine::drawPoints ( const QPointF * points, int pointCount ) { setClipping(); QColor color = painter()->pen().color(); HBRUSH wbrush = CreateSolidBrush(RGB(color.red(), color.green(), color.blue())); SelectObject(metaDC, wbrush); int lw = painter()->pen().width(); QMatrix m = painter()->worldMatrix(); for (int i = 0; i < pointCount; i++){ QPointF p = m.map(points[i]); int x = qRound(p.x()); int y = qRound(p.y()); Rectangle(metaDC, x, y, x + lw, y + lw); } resetClipping(); DeleteObject(wbrush); }
void EmfPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &) { setClipping(); QMatrix m = painter()->worldMatrix(); QPointF p = m.map(r.topLeft()); int x = qRound(p.x()); int y = qRound(p.y()); int width = qRound(r.width()); int height = qRound(r.height()); #ifdef Q_WS_WIN HBITMAP hbtmp = NULL; DWORD op = SRCCOPY; if (pm.hasAlpha()){ QImage image = pm.scaled(width, height).toImage(); image.invertPixels(); hbtmp = QPixmap::fromImage (image).toWinHBITMAP(); op = SRCINVERT; } else hbtmp = pm.scaled(width, height).toWinHBITMAP(); HDC hDC = CreateCompatibleDC(metaDC); SelectObject(hDC, hbtmp); BitBlt(metaDC, x, y, width, height, hDC, 0, 0, op); DeleteObject(hbtmp); DeleteDC(hDC); #else QImage image = pm.scaled(width, height).toImage(); for (int i = 0; i < width; i++){ for (int j = 0; j < height; j++){ QRgb rgb = image.pixel(i, j); if (qAlpha(rgb) == 255) SetPixel(metaDC, x + i, y + j, RGB(qRed(rgb), qGreen(rgb), qBlue(rgb))); } } #endif resetClipping(); }
int QItemDelegate::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractItemDelegate::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = hasClipping(); break; } _id -= 1; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setClipping(*reinterpret_cast< bool*>(_v)); break; } _id -= 1; } else if (_c == QMetaObject::ResetProperty) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 1; } #endif // QT_NO_PROPERTIES return _id; }
SubItemDelegate::SubItemDelegate( QObject * parent ) : QItemDelegate( parent ) { setClipping(false); }
void WPainter::drawText(const WRectF& rectangle, WFlags<AlignmentFlag> alignmentFlags, TextFlag textFlag, const WString& text) { if (textFlag == TextSingleLine) drawText(rectangle, alignmentFlags, text); else { if (!(alignmentFlags & AlignVerticalMask)) alignmentFlags |= AlignTop; if (!(alignmentFlags & AlignHorizontalMask)) alignmentFlags |= AlignLeft; if (device_->features() & WPaintDevice::CanWordWrap) device_->drawText(rectangle.normalized(), alignmentFlags, textFlag, text); else if (device_->features() & WPaintDevice::HasFontMetrics) { #ifndef WT_TARGET_JAVA MultiLineTextRenderer renderer(*this, rectangle); AlignmentFlag horizontalAlign = alignmentFlags & AlignHorizontalMask; AlignmentFlag verticalAlign = alignmentFlags & AlignVerticalMask; /* * Oh irony: after all these years of hating CSS, we now * implemented an XHTML renderer for which we need to use the * same silly workarounds to render the text with all possible * alignment options */ WStringStream s; s << "<table style=\"width:" << (int)rectangle.width() << "px;\"" "cellspacing=\"0\"><tr>" "<td style=\"padding:0px;height:" << (int)rectangle.height() << "px;color:" << pen().color().cssText() << ";text-align:"; switch (horizontalAlign) { case AlignLeft: s << "left"; break; case AlignRight: s << "right"; break; case AlignCenter: s << "center"; break; default: break; } s << ";vertical-align:"; switch (verticalAlign) { case AlignTop: s << "top"; break; case AlignBottom: s << "bottom"; break; case AlignMiddle: s << "middle"; break; default: break; } s << ";" << font().cssText(false); s << "\">" << WWebWidget::escapeText(text, true).toUTF8() << "</td></tr></table>"; save(); /* * FIXME: what if there was already a clip path? We need to combine * them ... */ WPainterPath p; p.addRect(rectangle.x() + 1, rectangle.y() + 1, rectangle.width() - 2, rectangle.height() - 2); setClipPath(p); setClipping(true); renderer.render(WString::fromUTF8(s.str())); restore(); #endif // WT_TARGET_JAVA } else throw WException("WPainter::drawText(): device does not support " "TextWordWrap or FontMetrics"); } }
/*! Load the xml configuration file. From the configuration file initialize the parameters corresponding to the objects: KLT, camera. \warning To clean up memory allocated by the xml library, the user has to call vpXmlParser::cleanup() before the exit(). \throw vpException::ioError if the file has not been properly parsed (file not found or wrong format for the data). \param configFile : full name of the xml file. The XML configuration file has the following form: \code <?xml version="1.0"?> <conf> <camera> <width>640</width> <height>480</height> <u0>320</u0> <v0>240</v0> <px>686.24</px> <py>686.24</py> </camera> <face> <angle_appear>65</angle_appear> <angle_disappear>85</angle_disappear> <near_clipping>0.01</near_clipping> <far_clipping>0.90</far_clipping> <fov_clipping>1</fov_clipping> </face> <klt> <mask_border>10</mask_border> <max_features>10000</max_features> <window_size>5</window_size> <quality>0.02</quality> <min_distance>10</min_distance> <harris>0.02</harris> <size_block>3</size_block> <pyramid_lvl>3</pyramid_lvl> </klt> </conf> \endcode \sa loadConfigFile(const std::string&), vpXmlParser::cleanup() */ void vpMbKltTracker::loadConfigFile(const char* configFile) { #ifdef VISP_HAVE_XML2 vpMbtKltXmlParser xmlp; xmlp.setMaxFeatures(10000); xmlp.setWindowSize(5); xmlp.setQuality(0.01); xmlp.setMinDistance(5); xmlp.setHarrisParam(0.01); xmlp.setBlockSize(3); xmlp.setPyramidLevels(3); xmlp.setMaskBorder(maskBorder); xmlp.setAngleAppear(vpMath::deg(angleAppears)); xmlp.setAngleDisappear(vpMath::deg(angleDisappears)); try{ std::cout << " *********** Parsing XML for MBT KLT Tracker ************ " << std::endl; xmlp.parse(configFile); } catch(...){ vpERROR_TRACE("Can't open XML file \"%s\"\n ", configFile); throw vpException(vpException::ioError, "problem to parse configuration file."); } vpCameraParameters camera; xmlp.getCameraParameters(camera); setCameraParameters(camera); tracker.setMaxFeatures((int)xmlp.getMaxFeatures()); tracker.setWindowSize((int)xmlp.getWindowSize()); tracker.setQuality(xmlp.getQuality()); tracker.setMinDistance(xmlp.getMinDistance()); tracker.setHarrisFreeParameter(xmlp.getHarrisParam()); tracker.setBlockSize((int)xmlp.getBlockSize()); tracker.setPyramidLevels((int)xmlp.getPyramidLevels()); maskBorder = xmlp.getMaskBorder(); angleAppears = vpMath::rad(xmlp.getAngleAppear()); angleDisappears = vpMath::rad(xmlp.getAngleDisappear()); //if(useScanLine) faces.getMbScanLineRenderer().setMaskBorder(maskBorder); if(xmlp.hasNearClippingDistance()) setNearClippingDistance(xmlp.getNearClippingDistance()); if(xmlp.hasFarClippingDistance()) setFarClippingDistance(xmlp.getFarClippingDistance()); if(xmlp.getFovClipping()) setClipping(clippingFlag = clippingFlag | vpPolygon3D::FOV_CLIPPING); useLodGeneral = xmlp.getLodState(); minLineLengthThresholdGeneral = xmlp.getMinLineLengthThreshold(); minPolygonAreaThresholdGeneral = xmlp.getMinPolygonAreaThreshold(); applyLodSettingInConfig = false; if(this->getNbPolygon() > 0) { applyLodSettingInConfig = true; setLod(useLodGeneral); setMinLineLengthThresh(minLineLengthThresholdGeneral); setMinPolygonAreaThresh(minPolygonAreaThresholdGeneral); } #else vpTRACE("You need the libXML2 to read the config file %s", configFile); #endif }
void RS_PainterQt::resetClipping() { setClipping(false); }
void RS_PainterQt::setClipRect(int x, int y, int w, int h) { QPainter::setClipRect(x, y, w, h); setClipping(true); }
inline void setClipping(const vec2& _pos, const vec2& _posEnd) { setClipping(vec3(_pos.x(),_pos.y(),0), vec3(_posEnd.x(),_posEnd.y(),0)); };
/** * @brief Request a clipping area for the text (next draw only) * @param[in] _pos Start position of the clipping * @param[in] _width Width size of the clipping */ void setClippingWidth(const vec3& _pos, vec3 _width) { setClipping(_pos, _pos+_width); };
void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode) { // load styles used by all widgets for(const OTMLNodePtr& node : styleNode->children()) { if(node->tag() == "color") setColor(node->value<Color>()); else if(node->tag() == "x") setX(node->value<int>()); else if(node->tag() == "y") setY(node->value<int>()); else if(node->tag() == "pos") setPosition(node->value<Point>()); else if(node->tag() == "width") setWidth(node->value<int>()); else if(node->tag() == "height") setHeight(node->value<int>()); else if(node->tag() == "rect") setRect(node->value<Rect>()); else if(node->tag() == "background") setBackgroundColor(node->value<Color>()); else if(node->tag() == "background-color") setBackgroundColor(node->value<Color>()); else if(node->tag() == "background-offset-x") setBackgroundOffsetX(node->value<int>()); else if(node->tag() == "background-offset-y") setBackgroundOffsetY(node->value<int>()); else if(node->tag() == "background-offset") setBackgroundOffset(node->value<Point>()); else if(node->tag() == "background-width") setBackgroundWidth(node->value<int>()); else if(node->tag() == "background-height") setBackgroundHeight(node->value<int>()); else if(node->tag() == "background-size") setBackgroundSize(node->value<Size>()); else if(node->tag() == "background-rect") setBackgroundRect(node->value<Rect>()); else if(node->tag() == "icon") setIcon(stdext::resolve_path(node->value(), node->source())); else if(node->tag() == "icon-source") setIcon(stdext::resolve_path(node->value(), node->source())); else if(node->tag() == "icon-color") setIconColor(node->value<Color>()); else if(node->tag() == "icon-offset-x") setIconOffsetX(node->value<int>()); else if(node->tag() == "icon-offset-y") setIconOffsetY(node->value<int>()); else if(node->tag() == "icon-offset") setIconOffset(node->value<Point>()); else if(node->tag() == "icon-width") setIconWidth(node->value<int>()); else if(node->tag() == "icon-height") setIconHeight(node->value<int>()); else if(node->tag() == "icon-size") setIconSize(node->value<Size>()); else if(node->tag() == "icon-rect") setIconRect(node->value<Rect>()); else if(node->tag() == "opacity") setOpacity(node->value<float>()); else if(node->tag() == "enabled") setEnabled(node->value<bool>()); else if(node->tag() == "visible") setVisible(node->value<bool>()); else if(node->tag() == "checked") setChecked(node->value<bool>()); else if(node->tag() == "dragable") setChecked(node->value<bool>()); else if(node->tag() == "on") setOn(node->value<bool>()); else if(node->tag() == "focusable") setFocusable(node->value<bool>()); else if(node->tag() == "phantom") setPhantom(node->value<bool>()); else if(node->tag() == "size") setSize(node->value<Size>()); else if(node->tag() == "fixed-size") setFixedSize(node->value<bool>()); else if(node->tag() == "clipping") setClipping(node->value<bool>()); else if(node->tag() == "border") { auto split = stdext::split(node->value(), " "); if(split.size() == 2) { setBorderWidth(stdext::safe_cast<int>(split[0])); setBorderColor(stdext::safe_cast<Color>(split[1])); } else throw OTMLException(node, "border param must have its width followed by its color"); } else if(node->tag() == "border-width") setBorderWidth(node->value<int>()); else if(node->tag() == "border-width-top") setBorderWidthTop(node->value<int>()); else if(node->tag() == "border-width-right") setBorderWidthRight(node->value<int>()); else if(node->tag() == "border-width-bottom") setBorderWidthBottom(node->value<int>()); else if(node->tag() == "border-width-left") setBorderWidthLeft(node->value<int>()); else if(node->tag() == "border-color") setBorderColor(node->value<Color>()); else if(node->tag() == "border-color-top") setBorderColorTop(node->value<Color>()); else if(node->tag() == "border-color-right") setBorderColorRight(node->value<Color>()); else if(node->tag() == "border-color-bottom") setBorderColorBottom(node->value<Color>()); else if(node->tag() == "border-color-left") setBorderColorLeft(node->value<Color>()); else if(node->tag() == "margin-top") setMarginTop(node->value<int>()); else if(node->tag() == "margin-right") setMarginRight(node->value<int>()); else if(node->tag() == "margin-bottom") setMarginBottom(node->value<int>()); else if(node->tag() == "margin-left") setMarginLeft(node->value<int>()); else if(node->tag() == "margin") { std::string marginDesc = node->value(); std::vector<std::string> split; boost::split(split, marginDesc, boost::is_any_of(std::string(" "))); if(split.size() == 4) { setMarginTop(stdext::safe_cast<int>(split[0])); setMarginRight(stdext::safe_cast<int>(split[1])); setMarginBottom(stdext::safe_cast<int>(split[2])); setMarginLeft(stdext::safe_cast<int>(split[3])); } else if(split.size() == 3) { int marginTop = stdext::safe_cast<int>(split[0]); int marginHorizontal = stdext::safe_cast<int>(split[1]); int marginBottom = stdext::safe_cast<int>(split[2]); setMarginTop(marginTop); setMarginRight(marginHorizontal); setMarginBottom(marginBottom); setMarginLeft(marginHorizontal); } else if(split.size() == 2) { int marginVertical = stdext::safe_cast<int>(split[0]); int marginHorizontal = stdext::safe_cast<int>(split[1]); setMarginTop(marginVertical); setMarginRight(marginHorizontal); setMarginBottom(marginVertical); setMarginLeft(marginHorizontal); } else if(split.size() == 1) { int margin = stdext::safe_cast<int>(split[0]); setMarginTop(margin); setMarginRight(margin); setMarginBottom(margin); setMarginLeft(margin); } } else if(node->tag() == "padding-top") setPaddingTop(node->value<int>()); else if(node->tag() == "padding-right") setPaddingRight(node->value<int>()); else if(node->tag() == "padding-bottom") setPaddingBottom(node->value<int>()); else if(node->tag() == "padding-left") setPaddingLeft(node->value<int>()); else if(node->tag() == "padding") { std::string paddingDesc = node->value(); std::vector<std::string> split; boost::split(split, paddingDesc, boost::is_any_of(std::string(" "))); if(split.size() == 4) { setPaddingTop(stdext::safe_cast<int>(split[0])); setPaddingRight(stdext::safe_cast<int>(split[1])); setPaddingBottom(stdext::safe_cast<int>(split[2])); setPaddingLeft(stdext::safe_cast<int>(split[3])); } else if(split.size() == 3) { int paddingTop = stdext::safe_cast<int>(split[0]); int paddingHorizontal = stdext::safe_cast<int>(split[1]); int paddingBottom = stdext::safe_cast<int>(split[2]); setPaddingTop(paddingTop); setPaddingRight(paddingHorizontal); setPaddingBottom(paddingBottom); setPaddingLeft(paddingHorizontal); } else if(split.size() == 2) { int paddingVertical = stdext::safe_cast<int>(split[0]); int paddingHorizontal = stdext::safe_cast<int>(split[1]); setPaddingTop(paddingVertical); setPaddingRight(paddingHorizontal); setPaddingBottom(paddingVertical); setPaddingLeft(paddingHorizontal); } else if(split.size() == 1) { int padding = stdext::safe_cast<int>(split[0]); setPaddingTop(padding); setPaddingRight(padding); setPaddingBottom(padding); setPaddingLeft(padding); } } // layouts else if(node->tag() == "layout") { std::string layoutType; if(node->hasValue()) layoutType = node->value(); else layoutType = node->valueAt<std::string>("type", ""); if(!layoutType.empty()) { UILayoutPtr layout; if(layoutType == "horizontalBox") layout = UIHorizontalLayoutPtr(new UIHorizontalLayout(asUIWidget())); else if(layoutType == "verticalBox") layout = UIVerticalLayoutPtr(new UIVerticalLayout(asUIWidget())); else if(layoutType == "grid") layout = UIGridLayoutPtr(new UIGridLayout(asUIWidget())); else if(layoutType == "anchor") layout = UIAnchorLayoutPtr(new UIAnchorLayout(asUIWidget())); else throw OTMLException(node, "cannot determine layout type"); setLayout(layout); } if(node->hasChildren()) m_layout->applyStyle(node); } // anchors else if(boost::starts_with(node->tag(), "anchors.")) { UIWidgetPtr parent = getParent(); if(!parent) { if(m_firstOnStyle) throw OTMLException(node, "cannot create anchor, there is no parent widget!"); else continue; } UIAnchorLayoutPtr anchorLayout = parent->getLayout()->asUIAnchorLayout(); if(!anchorLayout) throw OTMLException(node, "cannot create anchor, the parent widget doesn't use anchor layout!"); std::string what = node->tag().substr(8); if(what == "fill") { fill(node->value()); } else if(what == "centerIn") { centerIn(node->value()); } else { Fw::AnchorEdge anchoredEdge = Fw::translateAnchorEdge(what); if(node->value() == "none") { removeAnchor(anchoredEdge); } else { std::vector<std::string> split = stdext::split(node->value(), "."); if(split.size() != 2) throw OTMLException(node, "invalid anchor description"); std::string hookedWidgetId = split[0]; Fw::AnchorEdge hookedEdge = Fw::translateAnchorEdge(split[1]); if(anchoredEdge == Fw::AnchorNone) throw OTMLException(node, "invalid anchor edge"); if(hookedEdge == Fw::AnchorNone) throw OTMLException(node, "invalid anchor target edge"); addAnchor(anchoredEdge, hookedWidgetId, hookedEdge); } } // lua functions } else if(boost::starts_with(node->tag(), "@")) { // load once if(m_firstOnStyle) { std::string funcName = node->tag().substr(1); std::string funcOrigin = "@" + node->source() + "[" + node->tag() + "]"; g_lua.loadFunction(node->value(), funcOrigin); luaSetField(funcName); } // lua fields value } else if(boost::starts_with(node->tag(), "&")) { std::string fieldName = node->tag().substr(1); std::string fieldOrigin = "@" + node->source() + "[" + node->tag() + "]"; g_lua.evaluateExpression(node->value(), fieldOrigin); luaSetField(fieldName); } } }
void EmfPaintEngine::drawPath ( const QPainterPath & path ) { setClipping(); int points = path.elementCount(); POINT *pts = new POINT[points]; BYTE *types = new BYTE[points]; POINT *bzs = new POINT[3]; int bez = 0; BeginPath(metaDC); QMatrix m = painter()->worldMatrix(); for (int i = 0; i < points; i++){ QPainterPath::Element el = path.elementAt(i); QPointF p = m.map(QPointF(el.x, el.y)); int x = qRound(p.x()); int y = qRound(p.y()); pts[i].x = x; pts[i].y = y; switch(el.type){ case QPainterPath::MoveToElement: types[i] = PT_MOVETO; #ifndef Q_WS_WIN MoveToEx (metaDC, x, y, 0); #endif break; case QPainterPath::LineToElement: types[i] = PT_LINETO; #ifndef Q_WS_WIN LineTo(metaDC, x, y); #endif break; case QPainterPath::CurveToElement: types[i] = PT_BEZIERTO; #ifndef Q_WS_WIN bzs[bez] = pts[i]; bez++; #endif break; case QPainterPath::CurveToDataElement: types[i] = PT_BEZIERTO; #ifndef Q_WS_WIN bzs[bez] = pts[i]; if (bez == 2){ PolyBezierTo(metaDC, bzs, 3); bez = 0; } else bez++; #endif break; } } HPEN wpen = convertPen(painter()->pen()); SelectObject(metaDC, wpen); #ifdef Q_WS_WIN PolyDraw(metaDC, pts, types, points); #else StrokePath(metaDC); #endif HBRUSH wbrush = convertBrush(painter()->brush()); SelectObject(metaDC, wbrush); EndPath(metaDC); if(QPoint(pts[0].x, pts[0].y) == QPoint(pts[points - 1].x, pts[points - 1].y)) StrokeAndFillPath(metaDC); else { FillPath(metaDC); #ifdef Q_WS_WIN PolyDraw(metaDC, pts, types, points); #else StrokePath(metaDC); #endif } resetClipping(); DeleteObject(wbrush); DeleteObject(wpen); delete [] pts; delete [] types; }