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


C++ BShape::Bounds方法代码示例

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


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

示例1: drawShape

static void
draw_shape(void* _context, const BShape& shape, bool fill)
{
    DrawingContext* context = reinterpret_cast<DrawingContext *>(_context);
    ShapePainter drawShape(context);

    drawShape.Iterate(&shape);
    drawShape.Draw(shape.Bounds(), fill);
}
开发者ID:simonsouth,项目名称:haiku,代码行数:9,代码来源:ServerPicture.cpp

示例2: drawShape

static void
draw_shape(void* _canvas, const BShape& shape, bool fill)
{
    Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas);
    ShapePainter drawShape(canvas);

    drawShape.Iterate(&shape);
    drawShape.Draw(shape.Bounds(), fill);
}
开发者ID:bhanug,项目名称:haiku,代码行数:9,代码来源:ServerPicture.cpp

示例3: str

// _Import
status_t
StyledTextImporter::_Import(Icon* icon, const char *text, text_run_array *runs)
{
    CALLED();
    status_t ret = Init(icon);
    if (ret < B_OK) {
        printf("StyledTextImporter::Import() - "
               "Init() error: %s\n", strerror(ret));
        return ret;
    }

    BString str(text);
    if (str.Length() > 50) {
        BAlert* alert = new BAlert("too big",
            "The text you are trying to import is quite long, are you sure?",
            "Yes", "No", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
        if (alert->Go())
            return B_CANCELED;
    }

    // import run colors as styles
    if (runs) {
        delete[] fStyleMap;
        fStyleMap = new struct style_map[runs->count];
        for (int32 i = 0; runs && i < runs->count; i++) {
            _AddStyle(icon, &runs->runs[i]);
        }
    }

    int32 currentRun = 0;
    text_run *run = NULL;
    if (runs)
        run = &runs->runs[0];
    int32 len = str.Length();
    int32 chars = str.CountChars();
    BPoint origin(0,0);
    BPoint offset(origin);

    for (int32 i = 0, c = 0; i < len && c < chars; c++) {
        // make sure we are still on the (good) run
        while (run && currentRun < runs->count - 1 &&
            i >= runs->runs[currentRun + 1].offset) {
            run = &runs->runs[++currentRun];
            //printf("switching to run %d\n", currentRun);
        }

        int charLen;
        for (charLen = 1; str.ByteAt(i + charLen) & 0x80; charLen++);

        BShape glyph;
        BShape *glyphs[1] = { &glyph };
        BFont font(be_plain_font);
        if (run)
            font = run->font;

        // first char
        if (offset == BPoint(0,0)) {
            font_height height;
            font.GetHeight(&height);
            origin.y += height.ascent;
            offset = origin;
        }
        // LF
        if (str[i] == '\n') {
            // XXX: should take the MAX() for the line
            // XXX: should use descent + leading from previous line
            font_height height;
            font.GetHeight(&height);
            origin.y += height.ascent + height.descent + height.leading;
            offset = origin;
            i++;
            continue;
        }

        float charWidth;
        charWidth = font.StringWidth(str.String() + i, charLen);
        //printf("StringWidth( %d) = %f\n", charLen, charWidth);
        BString glyphName(str.String() + i, charLen);
        glyphName.Prepend("Glyph (");
        glyphName.Append(")");

        font.GetGlyphShapes((str.String() + i), 1, glyphs);
        if (glyph.Bounds().IsValid()) {
            //offset.x += glyph.Bounds().Width();
            offset.x += charWidth;
            Shape* shape = new (nothrow) Shape(NULL);
            shape->SetName(glyphName.String());
            if (!shape || !icon->Shapes()->AddShape(shape)) {
                delete shape;
                return B_NO_MEMORY;
            }
            for (int j = 0; run && j < fStyleCount; j++) {
                if (fStyleMap[j].run == run) {
                    shape->SetStyle(fStyleMap[j].style);
                    break;
                }
            }
            ShapeIterator iterator(icon, shape, offset, glyphName.String());
            if (iterator.Iterate(&glyph) < B_OK)
//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,代码来源:StyledTextImporter.cpp


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