当前位置: 首页>>代码示例>>C++>>正文


C++ TRect::MoveBy方法代码示例

本文整理汇总了C++中TRect::MoveBy方法的典型用法代码示例。如果您正苦于以下问题:C++ TRect::MoveBy方法的具体用法?C++ TRect::MoveBy怎么用?C++ TRect::MoveBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TRect的用法示例。


在下文中一共展示了TRect::MoveBy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CompatibleDraw

//! The fun part of the control
//!
//!	XXX need to test with vertically oriented images
void TMeterControl::CompatibleDraw(RgnHandle inLimitRgn, CGContextRef inContext, bool inCompositing)
{
#pragma unused(inLimitRgn)
    TRect bounds = Bounds();
    CGContextRef context = inContext;
    SliderOrientation boundsOrientation = OrientationForRect(bounds);
    TRect backBounds = RectForCGImage(mBackImage);
    
    float scaleY = ScaleY();
    // draw slider thumb
    if (mThumbImage)
    {
        TRect thumbBounds = ScaledThumbBounds();
        
        // compute a thumb bounds oriented the same as the slider
        TRect orientedThumbBounds = thumbBounds;
        if (boundsOrientation != mImageOrientation)
        {
            float temp = orientedThumbBounds.Width();
            orientedThumbBounds.SetWidth(orientedThumbBounds.Height());
            orientedThumbBounds.SetHeight(temp);
        }
        // the thumb image is assumed to be of the same orientation as the
        // background image
        float slideDistance;
        if (boundsOrientation == TSliderControl::kVerticalOrientation)
            slideDistance = orientedThumbBounds.Height();
        else
            slideDistance = orientedThumbBounds.Width();
        slideDistance -= (mTopInset + mBottomInset) * scaleY;
        float position = (float(GetValue() - GetMinimum()) / float(GetMaximum() - GetMinimum())) * slideDistance;
        
        orientedThumbBounds.SetAroundCenter(bounds.CenterX(), bounds.CenterY(),
                                            orientedThumbBounds.Width(), orientedThumbBounds.Height());
#if 0
        float xOffset, yOffset;
        if (boundsOrientation == TSliderControl::kVerticalOrientation)
        {
            xOffset = bounds.CenterX() + mXInset - orientedThumbBounds.Width()/2.0;
            yOffset = bounds.MinY() + mTopInset + (bounds.Height() + slideDistance) / 2.0;
        }
        else
        {
            xOffset = bounds.MinX() + mTopInset + (bounds.Width() + slideDistance) / 2.0;
            yOffset = bounds.CenterY() + mXInset - - orientedThumbBounds.Height()/2.0;;
        }
#else
        float xOffset, yOffset;
        if (boundsOrientation == TSliderControl::kVerticalOrientation)
        {
            xOffset = bounds.CenterX() + mXInset - orientedThumbBounds.Width()/2.0;
            yOffset = bounds.CenterY() + mTopInset - slideDistance / 2.0;
        }
        else
        {
            yOffset = bounds.CenterY() + mXInset - orientedThumbBounds.Height()/2.0;;
            xOffset = bounds.CenterX() + mTopInset - slideDistance / 2.0;
        }
#endif
        CGContextTranslateCTM(context, xOffset, yOffset);
        orientedThumbBounds.SetOrigin(thumbBounds.Origin());
        if (boundsOrientation == TSliderControl::kHorizontalOrientation) {
            orientedThumbBounds.SetWidth(position);
        } else {
            orientedThumbBounds.MoveBy(0, orientedThumbBounds.Height()-position);
            orientedThumbBounds.SetHeight(position);
        }
        CGContextClipToRect(context, orientedThumbBounds);
        
        if (mImageOrientation != boundsOrientation)
        {
            CGContextRotateCTM(context, DegreesToRadians(90.0));
        }
        HIViewDrawCGImage(context, &thumbBounds, mThumbImage);
    }
}
开发者ID:osoumen,项目名称:SFCEcho,代码行数:79,代码来源:TMeterControl.cpp


注:本文中的TRect::MoveBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。