void OptionsWidget::preUpdateUI( PageId const& page_id, Margins const& margins_mm, Alignment const& alignment) { m_pageId = page_id; m_marginsMM = margins_mm; m_alignment = alignment; typedef AlignmentByButton::value_type KeyVal; BOOST_FOREACH (KeyVal const& kv, m_alignmentByButton) { if (kv.second == m_alignment) { kv.first->setChecked(true); } } updateMarginsDisplay(); alignWithOthersCB->blockSignals(true); alignWithOthersCB->setChecked(!alignment.isNull()); alignWithOthersCB->blockSignals(false); enableDisableAlignmentButtons(); m_leftRightLinked = m_leftRightLinked && (margins_mm.left() == margins_mm.right()); m_topBottomLinked = m_topBottomLinked && (margins_mm.top() == margins_mm.bottom()); updateLinkDisplay(topBottomLink, m_topBottomLinked); updateLinkDisplay(leftRightLink, m_leftRightLinked); marginsGroup->setEnabled(false); alignmentGroup->setEnabled(false); }
bool OrderByHeightProvider::precedes( PageId const& lhs_page, bool const lhs_incomplete, PageId const& rhs_page, bool const rhs_incomplete) const { std::auto_ptr<Params> const lhs_params(m_ptrSettings->getPageParams(lhs_page)); std::auto_ptr<Params> const rhs_params(m_ptrSettings->getPageParams(rhs_page)); QSizeF lhs_size; if (lhs_params.get()) { Margins const margins(lhs_params->hardMarginsMM()); lhs_size = lhs_params->contentSizeMM(); lhs_size += QSizeF( margins.left() + margins.right(), margins.top() + margins.bottom() ); } QSizeF rhs_size; if (rhs_params.get()) { Margins const margins(rhs_params->hardMarginsMM()); rhs_size = rhs_params->contentSizeMM(); rhs_size += QSizeF( margins.left() + margins.right(), margins.top() + margins.bottom() ); } bool const lhs_valid = !lhs_incomplete && lhs_size.isValid(); bool const rhs_valid = !rhs_incomplete && rhs_size.isValid(); if (lhs_valid != rhs_valid) { // Invalid (unknown) sizes go to the back. return lhs_valid; } return lhs_size.height() < rhs_size.height(); }
void Page::setMargins(const Margins &margins, CuteReport::Unit unit) { if (!m_inited) { d->margins = margins; return; } Unit u = (unit == UnitNotDefined) ? d->unit : unit; QPointF p1 = convertUnit(QPointF(margins.left(), margins.top()), u, Millimeter, d->dpi); QPointF p2 = convertUnit(QPointF(margins.right(), margins.bottom()), u, Millimeter, d->dpi); Margins newMarginMM(p1.x(), p1.y(), p2.x(), p2.y()); if (d->margins == newMarginMM) return; d->margins = margins; if (d->margins.left() < 0) d->margins.setLeft(0); if (d->margins.top() < 0) d->margins.setTop(0); if (d->margins.right() < 0) d->margins.setRight(0); if (d->margins.bottom() < 0) d->margins.setBottom(0); afterGeometryChanged(); emit marginsChanged(this->margins(d->unit)); }
Margins XmlUnmarshaller::margins(QDomElement const& el) { Margins margins; margins.setLeft(el.attribute("left").toDouble()); margins.setRight(el.attribute("right").toDouble()); margins.setTop(el.attribute("top").toDouble()); margins.setBottom(el.attribute("bottom").toDouble()); return margins; }
Margins EditBox::draw(ISurface& master) { if (isHidden()) return Margins(); CST::Common::scoped_lock lock(mLock); Margins margins = getMargins(); if (!mFrameColor.isUndefined()) { Drawer drawer(master); drawer.rectangle(Point(0, 0), Point(master.getWidth() - 1, master.getHeight() - 1), mFrameColor); margins += Margins(1, 1, 1, 1); } if (!mBackgroundColor.isUndefined()) { Drawer drawer(master); drawer.filled_rectangle(Point(1, 1), Point(master.getWidth() - 2, master.getHeight() - 2), mBackgroundColor); } ViewPort basic_surface(master, margins.getTopLeft(master), margins.getRightBottom(master)); if (mCursor) { if (mCursorColor.isUndefined()) { Color color = getColor(); Componentality::Graphics::Color cursor_color(255 - color.operator Componentality::Graphics::ColorRGB().red, 255 - color.operator Componentality::Graphics::ColorRGB().green, 255 - color.operator Componentality::Graphics::ColorRGB().blue); mCursor->setColor(cursor_color); } else mCursor->setColor(mCursorColor); std::pair<Point, std::pair<size_t, size_t> > cursor_defs = positionCursor(basic_surface); mCursor->setLocation(cursor_defs.first + margins.getTopLeft(master)); mCursor->setSize(cursor_defs.second.first, cursor_defs.second.second); mCursor->reset(); } Font* font = System::getSystemProperties().getFontSet().find(this->getFont()); MovingPort surface(basic_surface, -(int) mScrolling, 0); if (font) { std::list<int> text = getText(); font->setForeground(mColor); font->print(surface, Point(1, 0), text); } IElement::draw(surface); return margins; }