void SkPictureRecord::drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkPaint& paint) { size_t points = paint.countText(text, byteLength); if (0 == points) return; bool fast = paint.canComputeFastBounds(); addDraw(fast ? DRAW_POS_TEXT_H_TOP_BOTTOM : DRAW_POS_TEXT_H); addPaint(paint); addText(text, byteLength); addInt(points); #ifdef SK_DEBUG_SIZE size_t start = fWriter.size(); #endif if (fast) { addFontMetricsTopBottom(paint, constY); } addScalar(constY); fWriter.writeMul4(xpos, points * sizeof(SkScalar)); #ifdef SK_DEBUG_SIZE fPointBytes += fWriter.size() - start; fPointWrites += points; #endif validate(); }
image* textImg(char* in, font* f) { image* text; image* nextLetter; int i, j; char c; text = newImg(1,40); for(i = 0; i < strlen(in); i++) { for(j = 0; j <= f->charCount; j++) { if(j == f->charCount) { printf("Cannot use char: %c\n", in[i]); text = 0; return text; } if(in[i] == f->list[j]->value) { nextLetter = crop(f->fileLocation, f->list[j]->x, f->list[j]->y, f->list[j]->w, f->list[j]->h); ; /* add to text image */ text = addText(text, nextLetter); break; } } } return text; }
void ChatOutput::addLink(const QString &href, const QString &linktext) { QTextCharFormat format = linkFormat; format.setAnchorHref(href); addText(linktext, format); }
void VcardForm::onWmUserUpdate() { //std::string xml=*(vcard->toXML()); //const std::string &xml2=XMLStringPrep(xml); //const std::wstring xml3=utf8::utf8_wchar(xml2); //SendMessage(hwndHTML, WM_SETTEXT, 0, (LPARAM)""); //img.reset(); imgFile=appRootPath;// + L"userdata\\avatars\\" + L"$$$_tmp.jpg"; if (savePhoto(imgFile.c_str())){ //img=ImageRef(new Image(imgFile.c_str())); //Contact::ref contact = Contact::ref(new Contact(this->jid,"","","","")); //contact->img_avatar=img; } startHtml(); addImg(L"\\vcard"); beginForm("vcard-photo", "photo"); if (img) if (img->getHBmp()) { button("save",std::string("Save")); if (editForm) button("clear",std::string("Clear")); } if (editForm) button("load",std::string("Load")); addText("<BR>"); endForm(); //contact->img_avatar=img; beginForm("vcard-fields", "publish"); addHtmlField("FN", NULL, "Full Name", TXT); addHtmlField("NICKNAME", NULL, "Nickname", TXT); addHtmlField("BDAY", NULL, "Birthday", TXT); addHtmlField("ADR", "STREET", "Street", TXT); addHtmlField("ADR", "EXTADR", "Street2", TXT); addHtmlField("ADR", "LOCALITY", "City", TXT); addHtmlField("ADR", "REGION", "State", TXT); addHtmlField("ADR", "PCODE", "Post code", TXT); addHtmlField("ADR", "CTRY", "Country", TXT); addHtmlField("TEL", "HOME", "Home Phone Number", TXT); addHtmlField("TEL", "NUMBER", "Phone Number", TXT); addHtmlField("EMAIL", "USERID", "E-Mail", URL); addHtmlField("TITLE", NULL, "Position", TXT); addHtmlField("ROLE", NULL, "Role", TXT); addHtmlField("ORG", "ORGNAME", "Organization", TXT); addHtmlField("ORG", "ORGUNIT", "Dept", TXT); addHtmlField("URL", NULL, "Url", URL); addHtmlField("DESC", NULL, "About", MULTILINE); if (editForm) button(std::string("Publish")); //button("reload",std::string("Reload")); endForm(); endHtml(); }
void Instructions::addBox(bool top, int x, int y, int width, int height, u32 color, const std::string& text, u32 textColor) { boxes.emplace_back(top, x, y, width, height, color); if (!text.empty()) { addText(top, x + width/2, y + height/2, width, TextPosX::CENTER, TextPosY::CENTER, textColor, text); } }
void LogWindow::statusMessage( const QString &message, const QByteArray &data ) { QDataStream stream( data ); if ( message == "message(QString)" ) { QString msg; stream >> msg; addText( msg ); }
void HTMLViewSourceDocument::processDoctypeToken(const String& source, HTMLToken&) { if (!m_current) createContainingTable(); m_current = addSpanWithClassName("webkit-html-doctype"); addText(source, "webkit-html-doctype"); m_current = m_td; }
void ChangeDisplay::addAnnotatedBB( const BBDisplay &bb, std::string label, int r, int g, int b ) { vector<LineSegment> lines = bb.getLines(); for(vector<LineSegment>::iterator l = lines.begin(); l < lines.end(); l++) { addLine(l->from, l->to, r, g, b); } addText(label, bb.getAnnotationPos(TEXT_VERT_DIST), r, g, b); }
void HomeScreen::init() { float width = camera.w/3; float height = width/4; float x = camera.w/2-width/2; float y = camera.h/2-height/2; SDL_Color textColor = {0x00, 0x00, 0xF0}; addText(x, y, width, height, textColor, FontType::HEADER, "HOME PAGE"); };
WWidget *EventsDemo::wDropEvent() { WContainerWidget *result = new WContainerWidget(); topic("WDropEvent", result); addText(tr("events-WDropEvent"), result); new DragExample(result); return result; }
void KWDWriter::createInline(QDomElement paragraph, QDomElement toInline) { if (toInline.tagName() == "FRAMESET") { formatAttribute(paragraph,"ANCHOR","type","frameset"); // fixme: support other kinds of inlines. } if (!toInline.attribute("grpMgr").isEmpty()) { formatAttribute(paragraph,"ANCHOR","instance",toInline.attribute("grpMgr")); } addText(paragraph,"#",6); // the anchor. }
void MainWindow::fillView() { for (int i = 0; i < 10; i++) { addRectangle(); addEllipse(); addLine(); addText(); } canvas->update(); }
void SkPictureRecord::drawTextOnPath(const void* text, size_t byteLength, const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) { addDraw(DRAW_TEXT_ON_PATH); addPaint(paint); addText(text, byteLength); addPath(path); addMatrixPtr(matrix); validate(); }
std::unique_ptr<AbstractWindow> createMessageWindow(std::string const& text) final override { auto theWindow = createWindow(); theWindow->addText(text); auto theButton = createFancyButton(); //unique_ptr<FancyButton> theButton->doFancyStuff(); theButton->setText("OK"); theWindow->add(std::move(theButton)); return theWindow; }
void avrOutputDialog::doAddTextStdOut() { QByteArray data = process->readAllStandardOutput(); QString text = QString(data); QString temp; int nlPos, pos, size; addText(text); currStdLine.append(text); if (currStdLine.contains("size = ")) { pos = currStdLine.lastIndexOf("size = "); temp = currStdLine.mid(pos+7); pos = temp.lastIndexOf("\n"); size = temp.left(pos).toInt(); ui->progressBar->setMaximum(size/2048); } if (currStdLine.contains("\n")) { nlPos = currStdLine.lastIndexOf("\n"); currStdLine = currStdLine.mid(nlPos+1); } if (!currStdLine.isEmpty()) { if (currStdLine.at(0) == QChar('.')) { pos = currStdLine.lastIndexOf("."); ui->progressBar->setValue(pos); } else if (currStdLine.startsWith("Starting upload: [")) { pos = (currStdLine.lastIndexOf("#")-19)/(MAX_FSIZE/204800.0); ui->progressBar->setValue(pos); } } if (text.contains("Complete ")) { #if !__GNUC__ delete kill_timer; kill_timer = NULL; #endif int start = text.indexOf("Complete "); int end = text.indexOf("%"); if (start > 0) { start += 9; int value = text.mid(start, end-start).toInt(); ui->progressBar->setValue(value); } } if (text.contains(":010000")) { //contains fuse info QStringList stl = text.split(":01000000"); foreach (QString t, stl) { bool ok = false; if (!lfuse) lfuse = t.left(2).toInt(&ok,16); if (!hfuse && !ok) hfuse = t.left(2).toInt(&ok,16); if (!efuse && !ok) efuse = t.left(2).toInt(&ok,16); }
void MsScWriter::header(const QString title, const QString type, const QString composer, const QString footer, const unsigned int temp) { qDebug() << "MsScWriter::header()" << "title:" << title << "type:" << type << "composer:" << composer << "footer:" << footer << "temp:" << temp ; // save tempo for later use tempo = temp; if (!title.isEmpty()) score->setMetaTag("workTitle", title); // TODO re-enable following statement // currently disabled because it breaks the bww iotest // if (!type.isEmpty()) score->setMetaTag("workNumber", type); QString strType = "composer"; QString strComposer = composer; // TODO: const parameters ctor MusicXmlCreator score->addCreator(new MusicXmlCreator(strType, strComposer)); if (!footer.isEmpty()) score->setMetaTag("copyright", footer); // score->setWorkTitle(title); VBox* vbox = 0; addText(vbox, score, title, TEXT_STYLE_TITLE); addText(vbox, score, type, TEXT_STYLE_SUBTITLE); addText(vbox, score, composer, TEXT_STYLE_COMPOSER); // addText(vbox, score, strPoet, TEXT_STYLE_POET); // addText(vbox, score, strTranslator, TEXT_STYLE_TRANSLATOR); if (vbox) { vbox->setTick(0); score->measures()->add(vbox); } if (!footer.isEmpty()) score->style()->set(ST_oddFooterC, footer); Part* part = score->part(0); part->setLongName(instrumentName()); part->setMidiProgram(midiProgram() - 1); }
void HtmlView::checkBox( const char *name, const std::string &label, bool checked ) { addText("<input type=\"checkbox\" name=\""); addText(name); addText("\" "); if (checked) addText("checked"); addText(">"); addText(label); addText("</input><BR>"); }
void HtmlView::option( const char *name, const std::string &label, bool checked ) { addText("<option value=\""); addText(name); addText("\" "); if (checked) addText("selected=\"selected\""); addText(">"); addText(label); addText("</option><BR>"); }
/** * add content with autolink */ void ChatOutput::addContent(const QString &content, const QTextCharFormat &format) { QString text; QString url; int offset = 0; int index = autolinkRegexp.indexIn(content, offset); // avoid QString::mid call, content does not have links most cases. if (index == -1) { Q_ASSERT(offset == 0); addText(content, format); return; } do { Q_ASSERT(index == -1 || index >= 0); // add normal text. // when index was -1, no more links, that add the rest of content. text = content.mid(offset, (index == -1) ? -1 : (index-offset)); if (!text.isEmpty()) { addText(text, format); } if (index == -1) { break; } url = autolinkRegexp.cap(0); if (!url.isEmpty()) { addLink(url, url); } // set variables for next iteration. offset = index + autolinkRegexp.matchedLength(); index = autolinkRegexp.indexIn(content, offset); // NOTE: overflow check ((int + int) >= 0) Q_ASSERT(offset >= 0); } while (offset >= 0); }
TEST(DemoHTMLTransformer, AnnotationProcessing) { // Construct Manager TerminalLogger logger{std::cerr, true}; Manager mgr{1}; Rooted<SystemTypesystem> sys{new SystemTypesystem(mgr)}; // Get the ontologies. Rooted<Ontology> bookDom = constructBookOntology(mgr, sys, logger); Rooted<Ontology> emDom = constructEmphasisOntology(mgr, sys, logger); // Construct a document only containing overlapping annotations. // it has the form: <em>bla<strong>blub</em>bla</strong> Rooted<Document> doc{new Document(mgr, "annotations.oxd")}; doc->referenceOntologys({bookDom, emDom}); Rooted<StructuredEntity> book = buildRootStructuredEntity(doc, logger, {"book"}); ASSERT_TRUE(book != nullptr); Rooted<StructuredEntity> p = buildStructuredEntity(doc, logger, book, {"paragraph"}); ASSERT_TRUE(p != nullptr); Rooted<Anchor> em_start{new Anchor(mgr, p)}; ASSERT_TRUE(addText(logger, doc, p, "bla")); Rooted<Anchor> strong_start{new Anchor(mgr, p)}; ASSERT_TRUE(addText(logger, doc, p, "blub")); Rooted<Anchor> em_end{new Anchor(mgr, p)}; ASSERT_TRUE(addText(logger, doc, p, "bla")); Rooted<Anchor> strong_end{new Anchor(mgr, p)}; buildAnnotationEntity(doc, logger, {"emph"}, em_start, em_end); buildAnnotationEntity(doc, logger, {"strong"}, strong_start, strong_end); // Check serialization. ResourceManager dummy; XmlTransformer transformer; std::stringstream out; transformer.writeXml(doc, out, logger, dummy, false); const std::string res = out.str(); // In HTML the overlapping structure must be serialized as follows: ASSERT_TRUE( res.find( "<a:start:emph/><book:text>bla</book:text><a:start:strong/>" "<book:text>blub</book:text><a:end:emph/>" "<book:text>bla</book:text><a:end:strong/>") != std::string::npos); }
void MsScWriter::header(const QString title, const QString type, const QString composer, const QString footer, const unsigned int temp) { qDebug() << "MsScWriter::header()" << "title:" << title << "type:" << type << "composer:" << composer << "footer:" << footer << "temp:" << temp ; // save tempo for later use tempo = temp; if (!title.isEmpty()) score->setMetaTag("workTitle", title); // TODO re-enable following statement // currently disabled because it breaks the bww iotest // if (!type.isEmpty()) score->setMetaTag("workNumber", type); if (!composer.isEmpty()) score->setMetaTag("composer", composer); if (!footer.isEmpty()) score->setMetaTag("copyright", footer); // score->setWorkTitle(title); Ms::VBox* vbox = 0; addText(vbox, score, title, Ms::TextStyleType::TITLE); addText(vbox, score, type, Ms::TextStyleType::SUBTITLE); addText(vbox, score, composer, Ms::TextStyleType::COMPOSER); // addText(vbox, score, strPoet, Ms::TextStyleType::POET); // addText(vbox, score, strTranslator, Ms::TextStyleType::TRANSLATOR); if (vbox) { vbox->setTick(0); score->measures()->add(vbox); } if (!footer.isEmpty()) score->style()->set(Ms::StyleIdx::oddFooterC, footer); Ms::Part* part = score->staff(0)->part(); part->setPlainLongName(instrumentName()); part->setPartName(instrumentName()); part->instrument()->setTrackName(instrumentName()); part->setMidiProgram(midiProgram() - 1); }
void HtmlView::selectList(const char *name, const std::string &label, bool multiple){ addText(label); addText(":<BR>"); addText("<select name=\""); addText(name); addText("\" "); if (multiple) addText("size=\"5\" multiple=\"multiple\""); addText(">"); }
/*===========================================================================*/ void ModalityLabel::screenUpdated( void ) { if ( m_parameter->enable_show_information ) show(); else hide(); const kvs::Dicom* dicom = m_parameter->dicom_list[ m_parameter->index ]; const std::string manufacturer = dicom->manufacturer(); const std::string modality = dicom->modality(); setText("Manufacturer: %s", manufacturer.c_str() ); addText("Modality: %s", modality.c_str() ); }
void HistogramView::addGridLine( const double value, tAxis ax, const QSize &sz ) { QPainterPath p; if (ax == H) { p.moveTo( m_Border/2, PosY(value,sz) ); p.lineTo( sz.width() - m_Border, PosY(value,sz) ); addText( value, QPointF( sz.width() - 3 * m_Border, PosY(value,sz) - 20 )); } else { p.moveTo( PosX(value), m_Border ); p.lineTo( PosX(value), sz.height() - m_Border ); addText( value, QPointF( PosX(value), sz.height() - m_Border - 20 ) ); } QGraphicsPathItem *pathItem = new QGraphicsPathItem(p); pathItem->setPen(m_gridPen); m_histogramItems->addToGroup(pathItem); }
void Svg::addCost(const std::vector<Vector2d> &points, const std::vector<Vector2d> &edges, const std::vector<float> &costs, const ColorRGB &color) { for (int i = 0; i < edges.size(); i++) { Vector2d p1 = points[(int)edges[i].x]; Vector2d p2 = points[(int)edges[i].y]; float x = (p2.x + p1.x) * 0.5f; float y = (p2.y + p1.y) * 0.5f; addText(std::to_string((int)costs[i]), x, y, color); } }
void ClipboardDialog::onListWidgetFormatsCurrentItemChanged( QListWidgetItem *current, QListWidgetItem *) { ui->actionRemove_Format->setEnabled(current != nullptr); const QString mime = current ? current->text() : QString(); const bool hasImage = mime.startsWith(QString("image")) ; const QByteArray animationFormat = QString(mime).remove(QRegExp("^image/")).toUtf8(); const bool hasAnimation = QMovie::supportedFormats().contains(animationFormat); ui->textEdit->clear(); ui->textEdit->setVisible(!hasImage); ui->scrollAreaImage->setVisible(hasImage); if (hasImage) ui->labelContent->setBuddy(ui->scrollAreaImage); else ui->labelContent->setBuddy(ui->textEdit); const QByteArray bytes = m_data.value(mime).toByteArray(); m_timerTextLoad.stop(); if (hasAnimation) { if (m_animation) m_animation->deleteLater(); if (m_animationBuffer) m_animationBuffer->deleteLater(); m_animationBuffer = new QBuffer(this); m_animationBuffer->open(QIODevice::ReadWrite); m_animationBuffer->write(bytes); m_animationBuffer->seek(0); m_animation = new QMovie(this); m_animation->setDevice(m_animationBuffer); m_animation->setFormat(animationFormat); ui->labelImage->setMovie(m_animation); m_animation->start(); } else if (hasImage) { QPixmap pix; pix.loadFromData( bytes, mime.toLatin1() ); ui->labelImage->setPixmap(pix); } else { m_textToShow = dataToText(bytes, mime); addText(); } ui->labelProperties->setText( tr("<strong>Size:</strong> %1 bytes", "Size of data in bytes").arg(bytes.size()) ); }
void WMediaPlayer::createDefaultGui() { gui_ = 0; static const char *media[] = { "audio", "video" }; WTemplate *ui = new WTemplate (tr(std::string("Wt.WMediaPlayer.defaultgui-") + media[mediaType_])); addAnchor(ui, Play, "play-btn", "jp-play"); addAnchor(ui, Pause, "pause-btn", "jp-pause"); addAnchor(ui, Stop, "stop-btn", "jp-stop"); addAnchor(ui, VolumeMute, "mute-btn", "jp-mute"); addAnchor(ui, VolumeUnmute, "unmute-btn", "jp-unmute"); addAnchor(ui, VolumeMax, "volume-max-btn", "jp-volume-max"); addAnchor(ui, RepeatOn, "repeat-btn", "jp-repeat"); addAnchor(ui, RepeatOff, "repeat-off-btn", "jp-repeat-off"); if (mediaType_ == Video) { addAnchor(ui, VideoPlay, "video-play-btn", "jp-video-play-icon", "play"); addAnchor(ui, FullScreen, "full-screen-btn", "jp-full-screen"); addAnchor(ui, RestoreScreen, "restore-screen-btn", "jp-restore-screen"); } addText(ui, CurrentTime, "current-time", "jp-current-time"); addText(ui, Duration, "duration", "jp-duration"); addText(ui, Title, "title", std::string()); addProgressBar(ui, Time, "progress-bar", "jp-seek-bar", "jp-play-bar"); addProgressBar(ui, Volume, "volume-bar", "jp-volume-bar", "jp-volume-bar-value"); ui->bindString("title-display", title_.empty() ? "none" : ""); addStyleClass(mediaType_ == Video ? "jp-video" : "jp-audio"); setControlsWidget(ui); }
static int handleChap(isess_t *sess, pdu_t *pp) { pdu_t spp; login_req_t *lp; isc_opt_t *op = sess->op; char *ap, *ip, *cp, *digest; // MD5 is 128bits, SHA1 160bits debug_called(3); bzero(&spp, sizeof(pdu_t)); lp = (login_req_t *)&spp.ipdu.bhs; lp->cmd = ISCSI_LOGIN_CMD | 0x40; // login request + Inmediate memcpy(lp->isid, sess->isid, 6); lp->tsih = sess->tsih; // MUST be zero the first time! lp->CID = htons(1); lp->CSG = SN_PHASE; // Security Negotiation lp->NSG = LON_PHASE; lp->T = 1; if(((ap = getkeyval("CHAP_A=", pp)) == NULL) || ((ip = getkeyval("CHAP_I=", pp)) == NULL) || ((cp = getkeyval("CHAP_C=", pp)) == NULL)) return -1; if((digest = chapDigest(ap, (char)strtol(ip, (char **)NULL, 0), cp, op->chapSecret)) == NULL) return -1; addText(&spp, "CHAP_N=%s", op->chapIName? op->chapIName: op->initiatorName); addText(&spp, "CHAP_R=%s", digest); free(digest); if(op->tgtChapSecret != NULL) { op->tgtChapID = (random() >> 24) % 255; // should be random enough ... addText(&spp, "CHAP_I=%d", op->tgtChapID); cp = genChapChallenge(cp, op->tgtChallengeLen? op->tgtChallengeLen: 8); addText(&spp, "CHAP_C=%s", cp); op->tgtChapDigest = chapDigest(ap, op->tgtChapID, cp, op->tgtChapSecret); }
void WinWindow::onCreate() { addText(LABEL_ADDRESS, "Address:", 10, 45, 60); addEdit(EDIT_ADDRESS, "", 70, 40, 150); addText(LABEL_USERNAME, "Username:"******"", 70, 66, 150); addText(LABEL_PASSWORD, "Password:"******"", 70, 92, 150, 24, ES_PASSWORD); addButton(BTN_SAVE, "Save", 250, 10, 120, 25); addButton(BTN_RUN_WIN, "Run in new window", 250, 38, 120, 25); addButton(BTN_RUN_SERVICE, "Run as service", 250, 66, 120, 25); addButton(BTN_RUN_START, "Run on start", 250, 94, 120, 25); addButton(BTN_KILL, "Kill", 250, 122, 120, 26); addButton(BTN_QUIT, "Quit", 250, 150, 120, 26); SendMessage(m_objects[EDIT_ADDRESS], WM_SETTEXT, 0, (LPARAM)m_config->getString("REMOTE_ADDRESS", "54.194.222.199").c_str()); SendMessage(m_objects[EDIT_USERNAME], WM_SETTEXT, 0, (LPARAM)m_config->getString("USER", "").c_str()); //SendMessage(m_objects[EDIT_PASSWORD], WM_SETTEXT, 0, (LPARAM)m_config->getString("PASS", "").c_str()); }
void HtmlView::textML( const char *name, const std::string &label, const std::string &value ) { addText(label); addText(": <BR><textarea rows=\"6\" cols=\"20\" name=\""); addText(name); addText("\">"); addText(value); addText("</textarea><BR>"); }