Example #1
0
bool
View::MarkAt(DrawingEngine* engine, const BPoint& where, int32 level)
{
    BRect rect(fFrame.left, fFrame.top, fFrame.right, fFrame.bottom);

    if (Parent() != NULL) {
        Parent()->ConvertToScreen(&rect);
        if (!rect.Contains(where))
            return false;

        engine->StrokeRect(rect, (rgb_color) {
            level * 30, level * 30, level * 30
        });
    }


    bool found = false;
    for (View* child = FirstChild(); child; child = child->NextSibling()) {
        found |= child->MarkAt(engine, where, level + 1);
    }

    if (!found) {
        rgb_color color = {0};
        switch (level % 2) {
        case 0:
            color.green = rand() % 256;
            break;
        case 1:
            color.blue = rand() % 256;
            break;
        }

        rect.InsetBy(1, 1);
        //engine->FillRegion(fLocalClipping, (rgb_color){255, 255, 0, 10});
        engine->StrokeRect(rect, color);
        rect.InsetBy(1, 1);
        engine->StrokeRect(rect, color);
    }

    return true;
}