ideal IdealOfPoints(const SparsePolyRing& P, const ConstMatrixView& M) { if (CoeffRing(P) != RingOf(M)) CoCoA_ERROR(ERR::MixedRings, "IdealOfPoints"); if (NumIndets(P) != NumCols(M)) CoCoA_ERROR(ERR::BadMatrixSize, "IdealOfPoints"); if (DuplicateRows(M)) CoCoA_ERROR("Duplicate points", "IdealOfPoints"); ideal I(P, std::vector<RingElem>(0)); if (IsFiniteField(CoeffRing(P))) I = ideal(P, BM_modp(P, M)); else if (IsQQ(CoeffRing(P))) I = ideal(P, BM_QQ(P, M)); // generic case else I = ideal(P, BM_generic(P, M)); SetGBasisAsGens(I); return I; }
void nuiLayout::DoLayout(const nuiRect& rRect) { nuiRect r(GetRect()); float width = r.GetWidth(); float height = r.GetHeight(); SetHorizontalAnchor("left", 0, eAnchorAbsolute); SetHorizontalAnchor("right", width, eAnchorAbsolute); SetVerticalAnchor("top", 0, eAnchorAbsolute); SetVerticalAnchor("bottom", height, eAnchorAbsolute); auto it = mConstraints.begin(); while (it != mConstraints.end()) { nuiWidget* pWidget = it->first; float left = 0, right = width, top = 0, bottom = height; nuiRect ideal(pWidget->GetIdealRect()); float l = ideal.Left(), r = ideal.Right(), t = ideal.Top(), b = ideal.Bottom(); const nuiLayoutConstraint& rH(it->second.first); const nuiLayoutConstraint& rV(it->second.second); // Horizontal Layout: ComputeConstraint(rH, l, r, left, right, ideal.GetWidth(), 0); // Vertical Layout: ComputeConstraint(rV, t, b, top, bottom, ideal.GetHeight(), 1); pWidget->SetLayout(nuiRect(l, t, r, b, false)); ++it; } }
WebString BooleanConstraint::toString() const { StringBuilder builder; builder.append('{'); maybeEmitNamedBoolean(builder, m_hasExact, "exact", exact()); maybeEmitNamedBoolean(builder, m_hasIdeal, "ideal", ideal()); builder.append('}'); return builder.toString(); }
bool nuiLabel::SetRect(const nuiRect& rRect) { bool needRecalcLayout = false; if (mUseEllipsis || mWrapping) needRecalcLayout = (rRect.GetWidth() != mRect.GetWidth()); nuiWidget::SetRect(rRect); nuiRect ideal(mIdealLayoutRect); if (needRecalcLayout || ideal.GetWidth() > mRect.GetWidth()) { if (mUseEllipsis) { CalcLayout(); nuiSize diff = ideal.GetWidth() - mRect.GetWidth(); int NbLetterToRemove = ToNearest(diff / (ideal.GetWidth() / mText.GetLength())) + 3; nglString text = mText; if (NbLetterToRemove > 0) { int len = text.GetLength(); text.DeleteRight(MIN(NbLetterToRemove, len)); text.Append(_T("...")); } delete mpLayout; mpLayout = new nuiTextLayout(mpFont); mpLayout->SetWrapX(0); mpLayout->Layout(text); GetLayoutRect(); } else if (mWrapping) { CalcLayout(); delete mpLayout; mpLayout = new nuiTextLayout(mpFont); delete mpIdealLayout; mpIdealLayout = new nuiTextLayout(mpFont); mpLayout->SetWrapX(mRect.GetWidth() - mBorderLeft - mBorderRight); mpIdealLayout->SetWrapX(mRect.GetWidth() - mBorderLeft - mBorderRight); mpLayout->Layout(mText); mpIdealLayout->Layout(mText); GetLayoutRect(); } SetToolTip(mText); } else { if (GetToolTip() == mText) SetToolTip(nglString::Empty); } return true; }
ideal NewFieldIdeal(const ring& k, const std::vector<RingElem>& gens) { // Check that k is indeed a field, and that all gens belong to k if (!IsField(k)) CoCoA_ERROR(ERR::NotField, "NewFieldIdeal"); const long n = len(gens); for (long i=0; i < n; ++i) if (owner(gens[i]) != k) CoCoA_ERROR(ERR::MixedRings, "NewFieldIdeal"); return ideal(new FieldIdealImpl(k, gens)); }
glm::uvec2 Indigo::UIGroup::ideal_size() const { glm::uvec2 ideal(0); for (OOBase::Vector<OOBase::SharedPtr<UIWidget>,OOBase::ThreadLocalAllocator>::const_iterator i=m_children.begin();i;++i) { if ((*i)->visible()) { glm::uvec2 ideal1((*i)->ideal_size()); ideal1 += (*i)->position(); ideal = glm::max(ideal1,ideal); } } return ideal; }
void nuiContainer::InternalSetLayout(const nuiRect& rect, bool PositionChanged, bool SizeChanged) { CheckValid(); if (mNeedSelfLayout || SizeChanged) { mInSetRect = true; SetRect(rect); mInSetRect = false; Invalidate(); } else { // Is this case the widget have just been moved inside its parent. No need to re layout it, only change the rect... mRect = rect; if (mNeedLayout) { // The children need to be re layed out (at least one of them!). nuiContainer::IteratorPtr pIt = GetFirstChild(false); do { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem) { // The rect of each child doesn't change BUT we still ask for its ideal rect. nuiRect rect(pItem->GetBorderedRect()); nuiRect ideal(pItem->GetIdealRect()); if (pItem->HasUserPos()) { rect = ideal; } else if (pItem->HasUserSize()) { rect.SetSize(ideal.GetWidth(), ideal.GetHeight()); } else { // Set the widget to the size of the parent } pItem->SetLayout(rect); } } while (GetNextChild(pIt)); delete pIt; } } //#TEST: #ifdef NUI_CHECK_LAYOUTS IteratorPtr pIt; for (pIt = GetFirstChild(); pIt && pIt->IsValid(); GetNextChild(pIt)) { nuiWidgetPtr pItem = pIt->GetWidget(); if (pItem->IsVisible()) { NGL_ASSERT(!pItem->GetNeedLayout()); } } delete pIt; //#TEST end #endif }