void LLTextBox::reshapeToFitText() { reflow(); S32 width = getTextPixelWidth(); S32 height = getTextPixelHeight(); reshape( width + 2 * mHPad, height + 2 * mVPad, FALSE ); }
void LLChatEntry::draw() { if(mIsExpandable) { reflow(); expandText(); } LLTextEditor::draw(); }
void Line::moveToNextPage(BlockList& floats, double minX, double maxX, const WTextRenderer& renderer) { for (unsigned i = 0; i < blocks_.size(); ++i) { Block *b = blocks_[i]; if (b->isFloat()) Utils::erase(floats, b); } PageState ps; ps.floats = floats; ps.page = page_; Block::clearFloats(ps); page_ = ps.page; floats = ps.floats; double oldY = y_; y_ = 0; x_ = minX; ++page_; BlockList blocks = blocks_; blocks_.clear(); Range rangeX(x_, maxX); Block::adjustAvailableWidth(y_, page_, floats, rangeX); x_ = rangeX.start; maxX = rangeX.end; for (unsigned i = 0; i < blocks.size(); ++i) { Block *b = blocks[i]; if (b->isFloat()) { b->layoutFloat(y_, page_, floats, x_, height_, minX, maxX, false, renderer); reflow(b); } else { for (unsigned j = 0; j < b->inlineLayout.size(); ++j) { InlineBox& ib = b->inlineLayout[j]; if (ib.y == oldY && ib.page == page_ - 1) { if (ib.x != LEFT_MARGIN_X) { ib.x = x_; x_ += ib.width; } ib.page = page_; ib.y = y_; } } } blocks_.push_back(b); } }
void XUIObject::destroyChild(XUIObject *child) { int pos = m_children.searchItem(child); if (pos < 0) return; m_children.removeByPos(pos); svc_xuiObject *svc = child->getOwnerService(); if (svc == NULL) { DebugString("Owner service is NULL for XUIObject %s", getTagName()); } else { svc->destroy(child); } reflow(); }
void Inventory::removeItem(uint16 var) { _vm->_state->setVar(var, 0); for (ItemList::iterator it = _inventory.begin(); it != _inventory.end(); it++) { if (it->var == var) { _inventory.erase(it); break; } } reflow(); updateState(); }
void XUIObject::destroyChildren(PtrList<XUIObject> *deletelist) { foreach(*deletelist) XUIObject *child = deletelist->getfor(); int pos = m_children.searchItem(child); if (pos < 0) return; m_children.removeByPos(pos); svc_xuiObject *svc = child->getOwnerService(); if (svc == NULL) { DebugString("Owner service is NULL for XUIObject %s", getTagName()); } else { svc->destroy(child); } endfor; reflow(); }
void XUIObject::addChild(XUIObject *child, XUIObject *insertBefore) { int pos = -1; if (insertBefore) { pos = m_children.searchItem(insertBefore); } if (!child) return; XUIObject *prevparent = child->getParent(); if (prevparent) { prevparent->removeChild(child); } m_children.addItem(child, pos); child->setParent(this); if (getRootWnd()->isPostOnInit()) { child->getRootWnd()->init(getRootWnd()); reflow(); } }
void Inventory::addItem(uint16 var, bool atEnd) { // Only add objects once to the inventory if (!hasItem(var)) { _vm->_state->setVar(var, 1); InventoryItem i; i.var = var; if (atEnd) { _inventory.push_back(i); } else { _inventory.push_front(i); } reflow(); updateState(); } }
void XUIObject::onInit() { eventSource_onInit(); ASSERT(m_wnd); foreach(m_children) initChild(m_children.getfor()); endfor; if (!getParent()) { int w = m_w; int h = m_h; if (w == AUTOWH) w = getDefaultSize(XUI_DEFAULTSIZE_WIDTH); if (h == AUTOWH) h = getDefaultSize(XUI_DEFAULTSIZE_HEIGHT); int x = m_x; int y = m_y; if (x == AUTOWH) x = 0; if (y == AUTOWH) y = 0; m_wnd->resize(x, y, w, h); } reflow(); }
static void deleteSelect(struct edit *edit) { struct textLine *ln = edit->firstline; int passed = 0; while (ln && !ln->selected) { if (ln == edit->curline) passed = 1; ln = ln->next; } if (!ln) return; //将 curline 移过来, 否则 reflow 会有问题得 if (!passed) { while (edit->curline != ln) { edit->curline = edit->curline->prev; edit->line--; edit->linecur--; } } else { while (edit->curline != ln) { edit->curline = edit->curline->next; edit->line++; edit->linecur++; } } edit->col = edit->colcur = 0; while (ln && ln->selected) { ln->changed = 1; ln->br = 0; ln->selected = 0; ln->len = 0; ln = ln->next; } reflow(edit->curline, 0); }
static void insertChar(struct edit *edit, const char ch) { struct textLine *ln = edit->curline, *newln; int len, width; if (!edit->overwrite) memmove(ln->text + edit->col + 1, ln->text + edit->col, ln->len - edit->col); ln->text[edit->col] = ch; edit->col++; edit->colcur = measureWidth(ln->text, edit->col); if (!edit->overwrite || edit->col > ln->len) ln->len++; ln->changed = 1; len = measureLine(ln->text, ln->len, MAXLINELEN, 0, &width); if (len == ln->len && width < MAXLINELEN) { edit->position = edit->colcur; return; } newln = allocNextLine(ln); newln->br = ln->br; ln->br = 0; memcpy(newln->text, ln->text + len, ln->len - len); newln->len = ln->len - len; ln->len = len; edit->redrawall = 1; reflow(newln, 0); if (edit->col > len || edit->colcur >= MAXLINELEN) { edit->curline = ln->next; edit->col = edit->col - len; edit->colcur = measureWidth(edit->curline->text, edit->col); edit->line++; edit->linecur++; } edit->position = edit->colcur; }
/** constructors **/ WinOptions() : Window() { init(); reflowStatic(); reflow(); }
void Inventory::reset() { _inventory.clear(); reflow(); updateState(); }
SAWYER_EXPORT std::string TextMarkup::finalizeDocument(const std::string &s_) { std::string s = boost::trim_copy(s_); // Remove pairs of "=back =over" and spaces at the ends of lines { boost::regex backOverRe("(^=back\\s*=over[ \t]*)|[ \\t\\r\\f]+$"); std::ostringstream out(std::ios::out | std::ios::binary); std::ostream_iterator<char, char> oi(out); boost::regex_replace(oi, s.begin(), s.end(), backOverRe, ""); s = out.str(); } // Replace lots of blank lines with just one blank line { boost::regex blankLines("\\n{3,}"); std::ostringstream out(std::ios::out | std::ios::binary); std::ostream_iterator<char, char> oi(out); boost::regex_replace(oi, s.begin(), s.end(), blankLines, "\n\n"); s = out.str(); } std::vector<std::string> lines; boost::split(lines, s, boost::is_any_of("\n")); // Indent and reflow the text since it tends to not have enough linefeeds. Markup::Reflow reflow(80); // standard tty width of 80 columns reflow.indentationString(" "); // four is good breathing room without looking stretched static const size_t itemFieldWidth = 3; // one less than indentation std::vector<int> itemNumbers; // for numbered lists BOOST_FOREACH (const std::string &line, lines) { if (boost::starts_with(line, "=line")) { reflow.lineBreak(); } else if (boost::starts_with(line, "=over")) { ++reflow; itemNumbers.push_back(0); } else if (boost::starts_with(line, "=back")) { --reflow; if (!itemNumbers.empty()) itemNumbers.pop_back(); } else if (boost::starts_with(line, "=item")) { // =item is an implied =over std::string style = boost::trim_copy(line.substr(5)); if (style.empty()) { style = "*"; } else if (isdigit(style[0]) && !itemNumbers.empty()) { style = boost::lexical_cast<std::string>(++itemNumbers.back()) + "."; } reflow(BaseMarkup::leftJustify(style, itemFieldWidth) + " "); ++reflow; itemNumbers.push_back(0); } else { reflow(line + "\n"); } } s = reflow.toString(); // Add the header and footer { std::string page = boost::to_upper_copy(pageName()) + "(" + chapterNumberOrDefault() + ")"; std::string title = chapterTitleOrDefault(); std::string version = versionStringOrDefault(); std::string date = versionDateOrDefault(); size_t headSize = page.size() + title.size() + page.size(); size_t footSize = version.size() + date.size() + page.size(); std::string headPad = reflow.pageWidth() > headSize + 2 ? std::string(round(0.5 * (reflow.pageWidth() - (headSize+2))), ' ') : std::string(" "); std::string footPad = reflow.pageWidth() > footSize + 2 ? std::string(round(0.5 * (reflow.pageWidth() - (footSize+2))), ' ') : std::string(" "); s = (doPageHeader_ ? page + headPad + title + headPad + page + "\n\n" : std::string()) + s + (doPageFooter_ ? "\n" + version + footPad + date + footPad + page + "\n" : std::string()); } return s; }
void XUIObject::updateCoordinates() { if (m_parent) m_parent->reflow(); else reflow(); }
void XUIObject::onResize() { if (!m_wnd->isPostOnInit()) return; eventSource_onResize(); reflow(); }