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


C++ MythRect::moveTopLeft方法代码示例

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


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

示例1: Create

bool MythUIVirtualKeyboard::Create()
{
    if (!LoadWindowFromXML("keyboard/keyboard.xml", "keyboard", this))
        return false;

    BuildFocusList();

    loadKeyDefinitions(gCoreContext->GetLanguageAndVariant());
    updateKeys(true);

    int screenWidth, screenHeight;
    float xmult, ymult;
    GetMythUI()->GetScreenSettings(screenWidth, xmult, screenHeight, ymult);
    MythRect editArea = m_parentEdit->GetArea();
    MythRect area = GetArea();
    MythPoint newPos;

    //FIXME this assumes the edit is a direct child of the parent screen
    MythUIType *parentScreen = NULL;
    parentScreen = dynamic_cast<MythUIType *>(m_parentEdit->parent());
    if (parentScreen)
    {
        editArea.moveTopLeft(QPoint(editArea.x() + parentScreen->GetArea().x(),
                                    editArea.y() + parentScreen->GetArea().y()));
    }

    switch (m_preferredPos)
    {
        case VK_POSABOVEEDIT:
            if (editArea.y() - area.height() - 5 > 0)
            {
                newPos = QPoint(editArea.x() + editArea.width() / 2 - area.width() / 2,
                                editArea.y() - area.height() - 5);
            }
            else
            {
                newPos = QPoint(editArea.x() + editArea.width() / 2 - area.width() / 2,
                                editArea.y() + editArea.height() + 5);
            }
            break;

        case VK_POSTOPDIALOG:
            newPos = QPoint(screenWidth / 2 - area.width() / 2, 5);
            break;

        case VK_POSBOTTOMDIALOG:
            newPos = QPoint(screenWidth / 2 - area.width() / 2, screenHeight - 5 - area.height());
            break;

        case VK_POSCENTERDIALOG:
            newPos = QPoint(screenWidth / 2 - area.width() / 2, screenHeight / 2 - area.height() / 2);
            break;

        default:
            // VK_POSBELOWEDIT
            if (editArea.y() + editArea.height() + area.height() + 5 < screenHeight)
            {
                newPos = QPoint(editArea.x() + editArea.width() / 2 - area.width() / 2,
                                editArea.y() + editArea.height() + 5);
            }
            else
            {
                newPos = QPoint(editArea.x() + editArea.width() / 2 - area.width() / 2,
                                editArea.y() - area.height() - 5);
            }
            break;
    }

    // make sure the popup doesn't go off screen
    if (newPos.x() < 5)
        newPos.setX(5);
    if (newPos.x() + area.width() + 5 > screenWidth)
        newPos.setX(screenWidth - area.width() - 5);
    if (newPos.y() < 5)
        newPos.setY(5);
    if (newPos.y() + area.height() + 5 > screenHeight)
        newPos.setY(screenHeight - area.height() - 5);

    SetPosition(newPos);

    return true;
}
开发者ID:Olti,项目名称:mythtv,代码行数:82,代码来源:mythvirtualkeyboard.cpp


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