LPDISPATCH Change::GetParagraph() { Paragraph *pPara = new Paragraph; pPara->Init(m_hWnd, m_lParagraph, m_pDoc); return pPara->GetIDispatch(FALSE); }
/* * Update Message in Message Window */ void updateMessageText( const std::string text ) { //Dialog Test Component* root = getGameView(); if(!root) { //happens while in menu. std::cerr << "Root not found.\n"; return; } while( root->getParent() ) root = root->getParent(); Desktop* desktop = dynamic_cast<Desktop*> (root); if(!desktop) { std::cerr << "Root not a desktop!?!\n"; return; } try { //test if message Windows is open Component* messageTextComponent = 0; messageTextComponent = root->findComponent( "messageText" ); if(messageTextComponent == 0) { messageTextComponent = loadGUIFile("gui/messagearea.xml"); assert(messageTextComponent != 0); desktop->addChildComponent(messageTextComponent); } Paragraph* messageText = getParagraph(*messageTextComponent, "messageText"); messageText->setText( text ); } catch(std::exception& e) { std::cerr << "Couldn't display message '" << text << "': " << e.what() << "\n"; return; } }
void updateDate() { std::ostringstream dateText; int day = total_time % NUMOF_DAYS_IN_MONTH +1; // 1..NUMOF_DAYS_IN_MONTH day = 1 + ( 29 * day / NUMOF_DAYS_IN_MONTH ); // 1..30 dateText << day << ". "; dateText << current_month( total_time ); dateText << " "<< current_year( total_time ); Component* root = getGameView(); if( !root ) return; while( root->getParent() ) root = root->getParent(); if( dateText.str() == lastDateText ){ return; } Component* dateParagraphComponent = 0; dateParagraphComponent = root->findComponent( "dateParagraph" ); if( dateParagraphComponent == 0 ) { return;} Paragraph* dateParagraph = getParagraph( *root, "dateParagraph"); if( !dateParagraph ) { return;} dateParagraph->setText( dateText.str() ); lastDateText = dateText.str(); }
void Dialog::askRocket(){ if( !desktop ) { std::cerr << "No desktop found.\n"; return; } try { myDialogComponent = loadGUIFile( "gui/launch_rocket_yn.xml" ); assert( myDialogComponent != 0); registerDialog(); blockingDialogIsOpen = true; iAmBlocking = true; } catch(std::exception& e) { std::cerr << "Couldn't display message 'launch_rocket_yn': " << e.what() << "\n"; return; } Paragraph* p = getParagraph( *myDialogComponent, "DialogTitle" ); std::stringstream title; title << _("Launchsite") << " ( " << pointX <<" , " << pointY << " )"; p->setText( title.str() ); // connect signals Button* yesButton = getButton( *myDialogComponent, "Yes" ); yesButton->clicked.connect( makeCallback(*this, &Dialog::okayLaunchRocketButtonClicked ) ); Button* noButton = getButton( *myDialogComponent, "No" ); noButton->clicked.connect( makeCallback( *this, &Dialog::closeDialogButtonClicked ) ); Button* gotoButton = getButton( *myDialogComponent, "goto" ); gotoButton->clicked.connect( makeCallback( *this, &Dialog::gotoButtonClicked ) ); }
void Dialog::editMarket(){ if( !desktop ) { std::cerr << "No desktop found.\n"; return; } try { myDialogComponent = loadGUIFile( "gui/tradedialog.xml" ); assert( myDialogComponent != 0); registerDialog(); blockingDialogIsOpen = true; iAmBlocking = true; } catch(std::exception& e) { std::cerr << "Couldn't display dialog 'tradedialog.xml': " << e.what() << "\n"; return; } // set Dialog to Market-Data Paragraph* p = getParagraph( *myDialogComponent, "DialogTitle" ); std::stringstream title; title << _("Market") << " ( " << pointX <<" , " << pointY << " )"; p->setText( title.str() ); Market * market = static_cast <Market *> (world(pointX, pointY)->reportingConstruction); CheckButton* cb; cb = getCheckButton( *myDialogComponent, "BuyJobs" ); if( market->commodityRuleCount[Construction::STUFF_JOBS].take ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellJobs" ); if( market->commodityRuleCount[Construction::STUFF_JOBS].give ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyFood" ); if( market->commodityRuleCount[Construction::STUFF_FOOD].take ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellFood" ); if( market->commodityRuleCount[Construction::STUFF_FOOD].give ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyCoal" ); if( market->commodityRuleCount[Construction::STUFF_COAL].take ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellCoal" ); if( market->commodityRuleCount[Construction::STUFF_COAL].give ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyOre" ); if( market->commodityRuleCount[Construction::STUFF_ORE].take ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellOre" ); if( market->commodityRuleCount[Construction::STUFF_ORE].give ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyGoods" ); if( market->commodityRuleCount[Construction::STUFF_GOODS].take ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellGoods" ); if( market->commodityRuleCount[Construction::STUFF_GOODS].give ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuySteel" ); if( market->commodityRuleCount[Construction::STUFF_STEEL].take ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellSteel" ); if( market->commodityRuleCount[Construction::STUFF_STEEL].give) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyWaste" ); if( market->commodityRuleCount[Construction::STUFF_WASTE].take ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellWaste" ); if( market->commodityRuleCount[Construction::STUFF_WASTE].give) cb->check(); else cb->uncheck(); // connect signals Button* applyButton = getButton( *myDialogComponent, "Apply" ); applyButton->clicked.connect( makeCallback(*this, &Dialog::applyMarketButtonClicked ) ); Button* gotoButton = getButton( *myDialogComponent, "goto" ); gotoButton->clicked.connect( makeCallback( *this, &Dialog::gotoButtonClicked ) ); }
Paragraph Paragraph::operator+(const Paragraph &p1){ Paragraph p = *this; Node_S * iterator = p1.head; while(iterator){ p.append(iterator->data); iterator = iterator->next; } return p; }
void LxDcViCtl::insert(TCHAR* src, size_t count, size_t src_font, COLORREF src_color, size_t phy_pgh_index, size_t pos_global, size_t pos_inner) { //在cursor处执行插入操作 Paragraph* pgh = document.get_pgh(phy_pgh_index); pgh->Insert(pos_inner, src, count); font_tree.insert(pos_global, count, src_font); color_tree.insert(pos_global, count, src_color); }
Paragraph Paragraph::rest(){ Node_S * iterator = head->next; Paragraph p = Paragraph(); while(iterator){ p.append(iterator->data); iterator = iterator->next; } return p; }
void Dialog::setParagraph( const std::string paragraphName, const std::string text ){ Paragraph* p; try{ p = getParagraph( *myDialogComponent, paragraphName ); p->setText( text ); } catch(std::exception& e) { std::cerr << "Couldn't set " << paragraphName << " to '" << text << "': " << e.what() << "\n"; } }
Paragraph Paragraph::copy() const { Paragraph p; p.m_p->sPstyle = m_p->sPstyle; for (int i=0;i<textNodeCount();i++) p.addTextNode(textNode(i).copy()); return p; }
void Document::build_from_stream(FILE* file) { int pgh_cnt = read_stream_int(file); for (int i = 0; i < pgh_cnt; i++) { Paragraph* pgh = new Paragraph(); add_paragraph(pgh); pgh->build_from_stream(file); } }
void ParagraphLayout::SetParagraph(const Paragraph& paragraph) { fTextSpans = paragraph.TextSpans(); fParagraphStyle = paragraph.Style(); _Init(); fLayoutValid = false; }
void Dialog::editMarket(){ if( !desktop ) { std::cerr << "No desktop found.\n"; return; } try { myDialogComponent = loadGUIFile( "gui/tradedialog.xml" ); assert( myDialogComponent != 0); registerDialog(); blockingDialogIsOpen = true; iAmBlocking = true; } catch(std::exception& e) { std::cerr << "Couldn't display dialog 'tradedialog.xml': " << e.what() << "\n"; return; } // set Dialog to Market-Data Paragraph* p = getParagraph( *myDialogComponent, "DialogTitle" ); std::stringstream title; title << _("Market") << " ( " << pointX <<" , " << pointY << " )"; p->setText( title.str() ); CheckButton* cb; cb = getCheckButton( *myDialogComponent, "BuyJobs" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MB_JOBS ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellJobs" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MS_JOBS ) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyFood" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MB_FOOD) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellFood" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MS_FOOD) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyCoal" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MB_COAL) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellCoal" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MS_COAL) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyOre" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MB_ORE) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellOre" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MS_ORE) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuyGoods" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MB_GOODS) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellGoods" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MS_GOODS) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "BuySteel" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MB_STEEL) cb->check(); else cb->uncheck(); cb = getCheckButton( *myDialogComponent, "SellSteel" ); if( MP_INFO( pointX,pointY ).flags & FLAG_MS_STEEL) cb->check(); else cb->uncheck(); // connect signals Button* applyButton = getButton( *myDialogComponent, "Apply" ); applyButton->clicked.connect( makeCallback(*this, &Dialog::applyMarketButtonClicked ) ); Button* gotoButton = getButton( *myDialogComponent, "goto" ); gotoButton->clicked.connect( makeCallback( *this, &Dialog::gotoButtonClicked ) ); }
ParagraphLayout::ParagraphLayout(const Paragraph& paragraph) : fTextSpans(paragraph.TextSpans()), fParagraphStyle(paragraph.Style()), fWidth(0.0f), fLayoutValid(false), fGlyphInfos(), fLineInfos() { _Init(); }
nuiTextLayout::~nuiTextLayout() { for (uint32 p = 0; p < mpParagraphs.size(); p++) { Paragraph* pParagraph = mpParagraphs[p]; for (uint32 l = 0; l < pParagraph->size(); l++) { nuiTextLine* pLine = (*pParagraph)[l]; delete pLine; } delete pParagraph; } }
void DocReport::Put(const Paragraph& p) { if(dortf) rtf.Put(p); SkipBefore(p.GetBefore()); if(valrects) { int y = ypos; Vector<ValueRect> v; p.GetValueRects(1024, *this, lm, y, pgsz.cx - lm, v); AddVR(v); } Paragraph::PaintInfo pi; while(p.Paint(*this, lm, ypos, pgsz.cx - lm, GetYLim(), pi)) Page(); SetYPos(pi.ypos); SkipAfter(p.GetAfter()); }
istream* XhtmlPwiExporter::exportPwi () { string* resstr = new string(); string& res = *resstr; res += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; res += "<html>"; res += "<head>\n<meta http-equiv=\"content-type\" content=\"text/html; utf-8\"/>\n</head>\n"; res += "<body>"; vector<Paragraph*>& paragraphs = this->doc->getParagraphs(); for (int i = 0; i < paragraphs.size(); i++) { Paragraph* crtPara = paragraphs[i]; string paragraphText = crtPara->getText(); // TODO: here I get inside the guts of Paragraph from outside. This is not good but for now I'm not sure how inline markup should be properly implemented. map<int, int>& markup = crtPara -> getMarkup(); // position => markup type res += "\n<p>"; map<int, int>::iterator i = markup.begin(); int strIndex = 0; while (i != markup.end()) { pair<const int, int>& elem = *i; int pos = elem.first; int whatMarkup = elem.second; res += string(paragraphText.substr(strIndex, pos - strIndex)); res += this->getMarkup(whatMarkup); strIndex = pos; i++; } res += paragraphText.substr(strIndex, paragraphText.length()); // close formatting tags if not already closed. FIXME: /* if (crtPara->isBoldON()) res += this->getMarkup(Paragraph::MARKUP_BOLD_END); if (crtPara->isItalicON()) res += this->getMarkup(Paragraph::MARKUP_ITALIC_END);*/ res += "</p>"; } res += "\n</body>\n</html>"; return new istringstream(res); }
void LxDcViCtl::init(CDC* pDC) { CFont* font = new CFont; font->CreateFont(-18, 0, 0, 0, 100, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_SWISS, L"Consolas"); LOGFONT logfont; font->GetLogFont(&logfont); default_font_index = SrcFontFactory::GetFontFactInstance()->insert_src_font(logfont); font_tree.insert(0, 0, default_font_index); pDC->SelectObject(font); TEXTMETRIC trx; pDC->GetTextMetrics(&trx); cursor.height = trx.tmHeight; delete font; default_color_index = RGB(0, 50, 150); color_tree.insert(0, 0, default_color_index); Paragraph* paragraph = new Paragraph(); //设置默认的排版算法,对象应从排版算法管理结构中获取 paragraph->SetComposeAlgom(ComposeAlgoType::COMPOSE_ALGO_SIMPLE); document.add_paragraph(paragraph); compose_doc.AttachColorInfo(&color_tree); compose_doc.AttachFontInfo(&font_tree); compose_doc.AttachPhyDoc(&document); compose_doc.compose_complete(pDC); cursor.point_x = LxPaper::left_margin; cursor.point_y = ViewWindow::GetViewWindowInstance()->border_height + LxPaper::top_margin; cursor.page = compose_doc.begin(); cursor.paragraph = (*cursor.page)->begin(); cursor.row = (*cursor.paragraph)->begin(); cursor.index_inner = 0; //cursor.width_used = 0; section.cursor_begin = cursor; section.cursor_end = cursor; section.trace = false; gd_proxy.init(); gd_proxy.set_color(default_color_index); gd_proxy.set_font_index(default_font_index); render = new LxScrollRender(new LxBorderRender(new LxContexRender(&compose_doc, &gd_proxy))); }
bool Bidi::isBoundary(Buffer const & buf, Paragraph const & par, pos_type pos, Font const & font) const { bool const rtl = font.isVisibleRightToLeft(); bool const rtl2 = inRange(pos) ? level(pos) % 2 : par.isRTL(buf.params()); return rtl != rtl2; }
//To visit a Paragraph visit all its Lines void PrintVisitor::visitParagraph(Paragraph& paragraph) { LineVector& vector = paragraph.getLines(); LineVector::iterator iter; cout << "\nNew Paragraph\n"; for(iter = vector.begin(); iter != vector.end(); iter++) { iter->accept(*this); } }
void InsetTOC::makeTOCEntry(XHTMLStream & xs, Paragraph const & par, OutputParams const & op) const { string const attr = "href='#" + par.magicLabel() + "' class='tocentry'"; xs << html::StartTag("a", attr); // First the label, if there is one docstring const & label = par.params().labelString(); if (!label.empty()) xs << label << " "; // Now the content of the TOC entry, taken from the paragraph itself OutputParams ours = op; ours.for_toc = true; Font const dummy; par.simpleLyXHTMLOnePar(buffer(), xs, ours, dummy); xs << html::EndTag("a") << html::CR(); }
// Note that this is supposed to return a fully realized font. FontInfo Text::labelFont(Paragraph const & par) const { Buffer const & buffer = owner_->buffer(); Layout const & layout = par.layout(); if (!par.getDepth()) { FontInfo lf = layout.reslabelfont; // In case the default family has been customized if (layout.labelfont.family() == INHERIT_FAMILY) lf.setFamily(buffer.params().getFont().fontInfo().family()); return lf; } FontInfo font = layout.labelfont; // Realize with the fonts of lesser depth. font.realize(buffer.params().getFont().fontInfo()); return font; }
bool LxDcViCtl::single_remove(size_t phy_pgh_index_, size_t pos_global_, size_t pos_inner_, TCHAR& ch, size_t& font_index, size_t& color_index) { Paragraph* pgh = document.get_pgh(phy_pgh_index_); if (pgh->size() == 0 || pos_inner_ == 0) return false; ch = pgh->Get(pos_inner_ - 1); pgh->Delete(pos_inner_ - 1); font_index = font_tree.get_src_index(pos_global_); color_index = color_tree.get_src_index(pos_global_); font_tree.remove(pos_global_ - 1, pos_global_); color_tree.remove(pos_global_ - 1, pos_global_); if (font_tree.empty() && color_tree.empty()) { font_tree.insert(0, 0, default_font_index); color_tree.insert(0, 0, default_color_index); } return true; }
void updateMoney() { if( lastMoney == total_money ){ return; } //Prevent overflow if (total_money > 2000000000) total_money = 2000000000; else if (total_money < -2000000000) total_money = -2000000000; std::ostringstream moneyText; int money = total_money; if( abs(money) > 100000000 ){ moneyText << money/1000000 << _("M"); } else { if( abs(money) > 1000000 ){ moneyText << money/1000000 << " "; money %= 1000000; money = abs(money); moneyText << std::setw(6); moneyText << std::setfill('0'); } moneyText << money; } moneyText << _("$"); Component* root = getGameView(); if( !root ) return; while( root->getParent() ) root = root->getParent(); Component* moneyParagraphComponent = 0; moneyParagraphComponent = root->findComponent( "moneyParagraph" ); if( moneyParagraphComponent == 0 ) { return; } Paragraph* moneyParagraph = getParagraph( *root, "moneyParagraph"); if( !moneyParagraph ) return; moneyParagraph->setText( moneyText.str() ); lastMoney = total_money; }
///////////////////////// Old nuiFontLayout interface int32 nuiTextLayout::GetMetrics(nuiGlyphInfo& rInfo) const { int32 count = GetGlyphCount(); rInfo.Index = -count; if (count > 0) { rInfo.Width = mXMax - mXMin; rInfo.Height = mYMax - mYMin; rInfo.BearingX = mXMin; rInfo.BearingY = mYMax; float penx = 0; float peny = 0; if (!mpParagraphs.empty()) { Paragraph* pLastParagraph = mpParagraphs.back(); if (!pLastParagraph->empty()) { nuiTextLine* pLastLine = pLastParagraph->back(); penx = pLastLine->GetAdvanceX(); peny = pLastLine->GetAdvanceY(); } } rInfo.AdvanceX = penx; rInfo.AdvanceY = peny; } else { rInfo.Width = 0.0f; rInfo.Height = 0.0f; rInfo.BearingX = 0.0f; rInfo.BearingY = 0.0f; rInfo.AdvanceX = 0.0f; rInfo.AdvanceY = 0.0f; } return count; }
bool Bidi::isBoundary(Buffer const & buf, Paragraph const & par, pos_type pos, Font const & font) const { if (!lyxrc.rtl_support) return false; // This is just for speedup bool const rtl = font.isVisibleRightToLeft(); bool const rtl2 = inRange(pos) ? level(pos) % 2 : par.isRTL(buf.params()); return rtl != rtl2; }
int main() { Webpage myPage( "My Webpage" ); myPage.Open( "Web.html" ); Link link; link.SetID( "toIndex" ); link.SetLink( "index.html" ); link.SetText( "Go Home" ); myPage.AddElement( link ); Button btn; btn.SetID( "btnReset" ); btn.SetValue( "Reset" ); myPage.AddElement( btn ); Paragraph text; text.SetID( "welcome" ); text.SetText( "Welcome to this page!" ); myPage.AddElement( text ); myPage.Close(); }
void sgml::openTag(Buffer const & buf, odocstream & os, OutputParams const & runparams, Paragraph const & par) { Layout const & style = par.layout(); string const & name = style.latexname(); string param = style.latexparam(); Counters & counters = buf.params().documentClass().counters(); string id = par.getID(buf, runparams); string attribute; if (!id.empty()) { if (param.find('#') != string::npos) { string::size_type pos = param.find("id=<"); string::size_type end = param.find(">"); if( pos != string::npos && end != string::npos) param.erase(pos, end-pos + 1); } attribute = id + ' ' + param; } else { if (param.find('#') != string::npos) { // FIXME UNICODE if (!style.counter.empty()) // This uses InternalUpdate at the moment becuase sgml output // does not do anything with tracked counters, and it would need // to track layouts if it did want to use them. counters.step(style.counter, InternalUpdate); else counters.step(from_ascii(name), InternalUpdate); int i = counters.value(from_ascii(name)); attribute = subst(param, "#", convert<string>(i)); } else { attribute = param; } } openTag(os, name, attribute); }
void params2string(Paragraph const & par, string & data) { // A local copy ParagraphParameters params = par.params(); // This needs to be done separately params.labelWidthString(par.getLabelWidthString()); ostringstream os; params.write(os); Layout const & layout = par.layout(); // Is alignment possible os << "\\alignpossible " << layout.alignpossible << '\n'; /// set default alignment os << "\\aligndefault " << layout.align << '\n'; /// paragraph is always in inset. This is redundant. os << "\\ininset " << 1 << '\n'; data = os.str(); }
// This method requires a previous call to computeTables() bool Bidi::isBoundary(Buffer const & buf, Paragraph const & par, pos_type pos) const { if (!lyxrc.rtl_support || pos == 0) return false; if (!inRange(pos - 1)) { // This can happen if pos is the first char of a row. // Returning false in this case is incorrect! return false; } bool const rtl = level(pos - 1) % 2; bool const rtl2 = inRange(pos) ? level(pos) % 2 : par.isRTL(buf.params()); return rtl != rtl2; }