示例#1
0
Size HotKeyInputWindow::RenderContent(Renderer* renderer)
{
    RenderBorder(renderer);

    int textOffset = borderWidth + padding;
    int fontAscent = GetFont()->GetAscent();

    if (currentHotkey == 0)
    {
        currentTextPoistion = Point(textOffset, textOffset);
        renderer->PrintText(
            L"Not assigned",
            GetFont(),
            Colors::Gray,
            Point(textOffset, fontAscent + textOffset));
    }
    else
    {
        currentTextPoistion = renderer->PrintText(
            GetHotkeyDisplayString().c_str(),
            GetFont(),
            Colors::Black,
            RenderPosition(textOffset, fontAscent + textOffset));
    }

    return renderer->GetSize();
}
Size HeaderView::RenderEmptyResult(Renderer* renderer) const
{
    int curY = GetSize().GetHeight() / 2 + FontHeader->GetHeight() / 2;

    renderer->PrintText(wstring(L"No text data selected"), FontHeader, Colors::Gray, RenderPosition(PaddingX, curY));

    return renderer->GetSize();
}
Size SettingsView::RenderContent(Renderer* renderer)
{
    DestroyChildViews();

    RenderPosition renderPosition = RenderPosition(PaddingX, PaddingY);

    renderPosition = CreateSettingsGroups(RenderDescriptor(renderer, renderPosition));

    renderPosition = renderPosition.MoveY(LineHeight / 2).SetX(PaddingX);

    CreateControls(RenderDescriptor(renderer, renderPosition));

    SetButtonsState();

    return renderer->GetSize();
}
示例#4
0
Size DictionaryWindow::RenderContent(Renderer* renderer)
{
    DestroyChildWindows();

    RenderPosition renderPosition = RenderPosition(
        paddingX,
        paddingY / 2 + fontNormal->GetAscent());

    size_t countToShow = min(200, model.size());

    wstring title = L"Showing " + to_wstring(countToShow) + L" out of " + to_wstring(model.size());
    renderer->PrintText(title, fontItalic, Colors::Gray, renderPosition);

    for (size_t i = 0; i < countToShow; ++i)
    {
        renderPosition = renderPosition.MoveY(lineHeight);

        DictionaryRecord record = model[i];

        renderPosition = renderer->PrintText(
            record.GetWord(),
            fontNormal,
            Colors::Black,
            renderPosition.MoveX(paddingX));

        renderer->PrintText(L" (" + to_wstring(record.GetCount()) + L")", fontNormal, Colors::Gray, renderPosition);

        renderPosition = renderPosition.SetX(paddingX);

        HoverIconButtonWindow* translateButton = new HoverIconButtonWindow(context, this);
        translateButton->SetDimensions(
            renderPosition.MoveY(-fontNormal->GetAscent() + 1).GetPosition(),
            Size(iconSize, iconSize));
        translateButton->SetNormalIconResource(IDR_TRANSLATE_INACTIVE);
        translateButton->SetHoverIconResource(IDR_TRANSLATE);
        translateButton->OnClick.Subscribe([i, this]()
        {
            return OnShowTranslation.Notify(i);
        });
        translateButton->InitializeAndRender();
    }

    renderer->IncreaseWidth(paddingX);

    return renderer->GetSize();
}
Size HeaderView::RenderTranslationResult(Renderer* renderer, TranslateResult translateResult)
{
    RenderPosition renderPosition = RenderPosition(PaddingX, LineHeight);

    TranslateResultSentence sentence = translateResult.GetSentence();
    renderer->PrintText(sentence.GetTranslation(), FontHeader, Colors::Black, renderPosition);

    renderPosition = renderPosition.MoveY(LineHeight);

    int imageSize = FontSmall->GetAscent();
    HoverIconButtonControl* audioButton = new HoverIconButtonControl(Context, this);
    audioButton->SetDimensions(
        renderPosition.MoveY(-imageSize).MoveY(2, ScaleProvider).GetPosition(),
        Size(imageSize, imageSize));
    audioButton->SetHoverIconResource(IDR_AUDIO);
    audioButton->SetNormalIconResource(IDR_AUDIO_INACTIVE);
    audioButton->OnClick.Subscribe(&OnPlayText);
    audioButton->InitializeAndRender();

    renderPosition = renderPosition.MoveX(imageSize).MoveX(2, ScaleProvider);
    renderPosition = renderer->PrintText(sentence.GetOrigin(), FontSmall, Colors::Gray, renderPosition);

    RenderDescriptor actionRenderDescriptor = RenderDescriptor(renderer, renderPosition.MoveX(1));
    if (translateResult.IsInputCorrected())
    {
        PrintInputCorrectionWarning(actionRenderDescriptor, sentence.GetInput());
    }
    else if (!sentence.GetSuggestion().empty())
    {
        PrintSuggestion(actionRenderDescriptor, sentence.GetSuggestion());
    }

    renderer->IncreaseWidth(PaddingX);

    return renderer->GetSize();
}
RenderPosition RenderPosition::MoveY(int y) const
{
    return RenderPosition(Point(position.GetX(), position.GetY() + y));
}
RenderPosition RenderPosition::MoveX(int x) const
{
    return RenderPosition(Point(position.GetX() + x, position.GetY()));
}
RenderPosition RenderPosition::SetY(int y) const
{
    return RenderPosition(Point(position.GetX(), y));
}
RenderPosition RenderPosition::SetX(int x) const
{
    return RenderPosition(Point(x, position.GetY()));
}