void ActionBarContainer::OnMeasure(
    /* [in] */ Int32 widthMeasureSpec,
    /* [in] */ Int32 heightMeasureSpec)
{
    FrameLayout::OnMeasure(widthMeasureSpec, heightMeasureSpec);

    if (mActionBarView == NULL) return;

    AutoPtr<IViewGroupLayoutParams> lp;
    mActionBarView->GetLayoutParams((IViewGroupLayoutParams**)&lp);
    AutoPtr<CFrameLayoutLayoutParams> cp = (CFrameLayoutLayoutParams*)lp.Get();

    Int32 h = 0;
    mActionBarView->GetMeasuredHeight(&h);
    Boolean res = FALSE;
    Int32 actionBarViewHeight = (mActionBarView->IsCollapsed(&res), res) ? 0 : h + cp->mTopMargin + cp->mBottomMargin;

    Int32 visible = 0;
    if (mTabContainer != NULL && (mTabContainer->GetVisibility(&visible), visible) != IView::GONE) {
        Int32 mode = MeasureSpec::GetMode(heightMeasureSpec);
        if (mode == MeasureSpec::AT_MOST) {
            Int32 maxHeight = MeasureSpec::GetSize(heightMeasureSpec);
            SetMeasuredDimension(GetMeasuredWidth(),
                Elastos::Core::Math::Min(actionBarViewHeight + (mTabContainer->GetMeasuredHeight(&h), h),
                            maxHeight));
        }
    }
}
Beispiel #2
0
void CComposingView::OnMeasure(
    /* [in] */ Int32 widthMeasureSpec,
    /* [in] */ Int32 heightMeasureSpec)
{
    Float width = 0.f;
    Int32 height = 0, bottom = 0, top = 0;
    height = (mFmi->GetBottom(&bottom), bottom) - (mFmi->GetTop(&top), top) + mPaddingTop + mPaddingBottom;

    if (NULL == mDecInfo) {
        width = 0;
    } else {
        width = mPaddingLeft + mPaddingRight + LEFT_RIGHT_MARGIN * 2;

        String str;
        if (ComposingStatus_SHOW_STRING_LOWERCASE == mComposingStatus) {
            AutoPtr<IStringBuffer> strBuf;
            mDecInfo->GetOrigianlSplStr((IStringBuffer**)&strBuf);
            strBuf->ToString(&str);
        } else {
            mDecInfo->GetComposingStrForDisplay(&str);
        }
        Float value = 0.f;
        mPaint->MeasureText(str, 0, str.GetLength(), &value);
        width += value;
    }
    SetMeasuredDimension((Int32) (width + 0.5f), height);
}
void CBalloonView::OnMeasure(
    /* [in] */ Int32 widthMeasureSpec,
    /* [in] */ Int32 heightMeasureSpec)
{
    const Int32 widthMode = MeasureSpec::GetMode(widthMeasureSpec);
    const Int32 heightMode = MeasureSpec::GetMode(heightMeasureSpec);
    const Int32 widthSize = MeasureSpec::GetSize(widthMeasureSpec);
    const Int32 heightSize = MeasureSpec::GetSize(heightMeasureSpec);

    if (widthMode == MeasureSpec::EXACTLY) {
        SetMeasuredDimension(widthSize, heightSize);
        return;
    }

    Int32 measuredWidth = mPaddingLeft + mPaddingRight;
    Int32 measuredHeight = mPaddingTop + mPaddingBottom;
    if (NULL != mIcon) {
        Int32 value = 0;
        measuredWidth += (mIcon->GetIntrinsicWidth(&value), value);
        measuredHeight += (mIcon->GetIntrinsicHeight(&value), value);
    }
    else if (NULL != mLabel) {
        Float value = 0.f;
        measuredWidth += (Int32) (mPaintLabel->MeasureText(mLabel, &value), value);

        Int32 bottom = 0, top = 0;
        mFmi->GetBottom(&bottom);
        mFmi->GetTop(&top);
        measuredHeight += bottom - top;
    }
    if (widthSize > measuredWidth || widthMode == MeasureSpec::AT_MOST) {
        measuredWidth = widthSize;
    }

    if (heightSize > measuredHeight
            || heightMode == MeasureSpec::AT_MOST) {
        measuredHeight = heightSize;
    }

    Int32 width = Environment::GetInstance()->GetScreenWidth();
    Int32 maxWidth = width - mPaddingLeft - mPaddingRight;
    if (measuredWidth > maxWidth) {
        measuredWidth = maxWidth;
    }
    SetMeasuredDimension(measuredWidth, measuredHeight);
}
void IconMerger::OnMeasure(
    /* [in] */ Int32 widthMeasureSpec,
    /* [in] */ Int32 heightMeasureSpec)
{
    LinearLayout::OnMeasure(widthMeasureSpec, heightMeasureSpec);
    // we need to constrain this to an integral multiple of our children
    Int32 width = GetMeasuredWidth();
    SetMeasuredDimension(width - (width % mIconSize), GetMeasuredHeight());
}
void RatingBar::OnMeasure(
    /* [in] */ Int32 widthMeasureSpec,
    /* [in] */ Int32 heightMeasureSpec)
{
    AbsSeekBar::OnMeasure(widthMeasureSpec, heightMeasureSpec);

    if(mSampleTile != NULL) {
        Int32 width = 0;
        mSampleTile->GetWidth(&width);
        width *= mNumStars;
        SetMeasuredDimension(ResolveSizeAndState(width, widthMeasureSpec, 0), GetMeasuredHeight());
    }
}
void AbsoluteLayout::OnMeasure(
    /* [in] */ Int32 widthMeasureSpec,
    /* [in] */ Int32 heightMeasureSpec)
{
    Int32 count = GetChildCount();

    Int32 maxHeight = 0;
    Int32 maxWidth = 0;

    // Find out how big everyone wants to be
    MeasureChildren(widthMeasureSpec, heightMeasureSpec);

    // Find rightmost and bottom-most child
    for (Int32 i = 0; i < count; i++)
    {
        AutoPtr<IView> child = GetChildAt(i);

        Int32 visible;
        child->GetVisibility(&visible);
        if (visible != IView::GONE) {
            Int32 childRight;
            Int32 childBottom;

            AutoPtr<IAbsoluteLayoutLayoutParams> lp;
            child->GetLayoutParams((IViewGroupLayoutParams**)&lp);

            Int32 w, h;
            child->GetMeasuredWidth(&w);
            child->GetMeasuredHeight(&h);
            Int32 lx, ly;
            lp->GetX(&lx);
            lp->GetY(&ly);
            childRight = lx + w;
            childBottom = ly + h;

            maxWidth = Elastos::Core::Math::Max(maxWidth, childRight);
            maxHeight = Elastos::Core::Math::Max(maxHeight, childBottom);
        }
    }

    // Account for padding too
    maxWidth += mPaddingLeft + mPaddingRight;
    maxHeight += mPaddingTop + mPaddingBottom;

    // Check against minimum height and width
    maxHeight = Elastos::Core::Math::Max(maxHeight, GetSuggestedMinimumHeight());
    maxWidth = Elastos::Core::Math::Max(maxWidth, GetSuggestedMinimumWidth());

    SetMeasuredDimension(ResolveSizeAndState(maxWidth, widthMeasureSpec, 0),
            ResolveSizeAndState(maxHeight, heightMeasureSpec, 0));
}
void ShortcutAndWidgetContainer::OnMeasure(
    /* [in] */ Int32 widthMeasureSpec,
    /* [in] */ Int32 heightMeasureSpec)
{
    Int32 count;
    GetChildCount(&count);
    for (Int32 i = 0; i < count; i++) {
        AutoPtr<IView> child;
        ViewGroup::GetChildAt(i, (IView**)&child);
        MeasureChild(child);
    }
    Int32 widthSpecSize = View::MeasureSpec::GetSize(widthMeasureSpec);
    Int32 heightSpecSize = View::MeasureSpec::GetSize(heightMeasureSpec);
    SetMeasuredDimension(widthSpecSize, heightSpecSize);
}
void HTML5VideoFullScreen::VideoSurfaceView::OnMeasure(
    /* [in] */ Int32 widthMeasureSpec,
    /* [in] */ Int32 heightMeasureSpec)
{
    Int32 width = GetDefaultSize(mOwner->mVideoWidth, widthMeasureSpec);
    Int32 height = GetDefaultSize(mOwner->mVideoHeight, heightMeasureSpec);
    if (mOwner->mVideoWidth > 0 && mOwner->mVideoHeight > 0) {
        if ( mOwner->mVideoWidth * height  > width * mOwner->mVideoHeight ) {
            height = width * mOwner->mVideoHeight / mOwner->mVideoWidth;
        }
        else if ( mOwner->mVideoWidth * height  < width * mOwner->mVideoHeight ) {
            width = height * mOwner->mVideoWidth / mOwner->mVideoHeight;
        }
    }

    SetMeasuredDimension(width, height);
}
Beispiel #9
0
void CCandidateView::OnMeasure(
    /* [in] */ Int32 widthMeasureSpec,
    /* [in] */ Int32 heightMeasureSpec)
{
    Int32 measuredWidth = ResolveSize(50, widthMeasureSpec);

    // Get the desired height of the icon menu view (last row of items does
    // not have a divider below)
    AutoPtr<IRect> padding;
    CRect::New((IRect**)&padding);
    Boolean isPadding = FALSE;
    mSelectionHighlight->GetPadding(padding, &isPadding);
    Float size;
    Int32 top = 0, bottom = 0;
    mPaint->GetTextSize(&size);
    padding->GetTop(&top);
    padding->GetBottom(&bottom);
    Int32 desiredHeight = (Int32)size + mVerticalPadding + top + bottom;

    // Maximum possible width and desired height
    SetMeasuredDimension(measuredWidth,
            ResolveSize(desiredHeight, heightMeasureSpec));
}