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


C++ BTextView::TextHeight方法代码示例

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


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

示例1: PointForTip

void
DTipWatcherView::ShowTip(BPoint pt, const char *text)
{
    if (!text)
        return;
    
    Window()->SetWorkspaces(B_CURRENT_WORKSPACE);
    
    fTipView->SetText(text);
    
    // Figure the size of the tip. We do have a maximum width of 200 and a maximum height of 400, but
    // we only want to use the maximum size if it's necessary.
    fTipView->ResizeTo(200,400);
    fTipView->SetTextRect(BRect(2,2,198,398));
    
    int32 lineCount = fTipView->CountLines();
    float width = 200.0;
    
    if (lineCount == 1)
        width = fTipView->LineWidth() + 4;
    
    float height = fTipView->TextHeight(0,lineCount);
    height = (height < 400) ? height : 400;
    Window()->ResizeTo(width,height);
    
    fTipView->SetTextRect(BRect(2,2, width - 4, height - 4));
    
    BPoint winpt = PointForTip(pt);
    Window()->MoveTo(winpt.x,winpt.y);
    Window()->Show();
}
开发者ID:HaikuArchives,项目名称:LibWalter,代码行数:31,代码来源:DToolTip.cpp

示例2: BBitmap

void
ConfigWindow::MakeHowToView()
{
    BResources *resources = BApplication::AppResources();
    if (resources)
    {
        size_t length;
        char *buffer = (char *)resources->FindResource('ICON',101,&length);
        if (buffer)
        {
            BBitmap *bitmap = new BBitmap(BRect(0,0,63,63),B_CMAP8);
            if (bitmap && bitmap->InitCheck() == B_OK)
            {
                // copy and enlarge a 32x32 8-bit bitmap
                char *bits = (char *)bitmap->Bits();
                for (int32 i = 0,j = -64;i < length;i++)
                {
                    if ((i % 32) == 0)
                        j += 64;

                    char *b = bits + (i << 1) + j;
                    b[0] = b[1] = b[64] = b[65] = buffer[i];
                }
                fConfigView->AddChild(new BitmapView(bitmap));
            }
            else
                delete bitmap;
        }
    }

    BRect rect = fConfigView->Bounds();
    BTextView *text = new BTextView(rect,NULL,rect,B_FOLLOW_NONE,B_WILL_DRAW);
    text->SetViewColor(fConfigView->Parent()->ViewColor());
    text->SetAlignment(B_ALIGN_CENTER);
    text->SetText(
        MDR_DIALECT_CHOICE ("\n\nCreate a new account using the \"Add\" button.\n\n"
        "Delete accounts (or only the inbound/outbound) by using the \"Remove\" button on the selected item.\n\n"
        "Select an item in the list to edit its configuration.",
        "\n\nアカウントの新規作成は\"追加\"ボタンを\n使います。"
        "\n\nアカウント自体またはアカウントの\n送受信設定を削除するには\n項目を選択して\"削除\"ボタンを使います。"
        "\n\nアカウント内容の変更は、\nマウスで項目をクリックしてください。"));
    rect = text->Bounds();
    text->ResizeTo(rect.Width(),text->TextHeight(0,42));
    text->SetTextRect(rect);

    text->MakeEditable(false);
    text->MakeSelectable(false);

    fConfigView->AddChild(text);
    
    static_cast<CenterContainer *>(fConfigView)->Layout();
}
开发者ID:HaikuArchives,项目名称:BeMailDaemon,代码行数:52,代码来源:ConfigWindow.cpp

示例3:

int32_t
PTextViewTextHeight(void *pobject, void *in, void *out, void *extraData)
{
    if (!pobject || !in || !out)
        return B_ERROR;

    PView *parent = static_cast<PView*>(pobject);
    if (!parent)
        return B_BAD_TYPE;
    
    BTextView *backend = (BTextView*)parent->GetView();


    PArgs *inArgs = static_cast<PArgs*>(in);

    PArgs *outArgs = static_cast<PArgs*>(out);

    int32 start;
    if (inArgs->FindInt32("start", &start) != B_OK)
        return B_ERROR;

    int32 end;
    if (inArgs->FindInt32("end", &end) != B_OK)
        return B_ERROR;

    if (backend->Window())
        backend->Window()->Lock();

    float outValue1;

    outValue1 = backend->TextHeight(start, end);

    if (backend->Window())
        backend->Window()->Unlock();

    outArgs->MakeEmpty();

    return B_OK;
}
开发者ID:HaikuArchives,项目名称:PDesigner,代码行数:39,代码来源:PTextView.cpp

示例4: appFile

void
ConfigWindow::_MakeHowToView()
{
    app_info info;
    if (be_app->GetAppInfo(&info) == B_OK) {
        BFile appFile(&info.ref, B_READ_ONLY);
        BAppFileInfo appFileInfo(&appFile);
        if (appFileInfo.InitCheck() == B_OK) {
            BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, 63, 63),
                B_RGBA32);
            if (appFileInfo.GetIcon(bitmap, B_LARGE_ICON) == B_OK) {
                fConfigView->AddChild(new BitmapView(bitmap));
            } else
                delete bitmap;
        }
    }

    BRect rect = fConfigView->Bounds();
    BTextView *text = new BTextView(rect, NULL, rect, B_FOLLOW_NONE,
        B_WILL_DRAW);
    text->SetViewColor(fConfigView->Parent()->ViewColor());
    text->SetAlignment(B_ALIGN_CENTER);
    text->SetText(B_TRANSLATE(
        "\n\nCreate a new account with the Add button.\n\n"
        "Remove an account with the Remove button on the selected item.\n\n"
        "Select an item in the list to change its settings."));
    rect = text->Bounds();
    text->ResizeTo(rect.Width(), text->TextHeight(0, 42));
    text->SetTextRect(rect);

    text->MakeEditable(false);
    text->MakeSelectable(false);

    fConfigView->AddChild(text);

    fConfigView->Layout();
}
开发者ID:mylegacy,项目名称:haiku,代码行数:37,代码来源:ConfigWindow.cpp

示例5: labelAlignment

SGIView::SGIView(const char* name, uint32 flags, TranslatorSettings* settings)
    :
    BView(name, flags, new BGroupLayout(B_VERTICAL)),
    fSettings(settings)
{
    BPopUpMenu* menu = new BPopUpMenu("pick compression");

    uint32 currentCompression = 
        fSettings->SetGetInt32(SGI_SETTING_COMPRESSION);
    // create the menu items with the various compression methods
    add_menu_item(menu, SGI_COMP_NONE, B_TRANSLATE("None"), 
        currentCompression);
    //menu->AddSeparatorItem();
    add_menu_item(menu, SGI_COMP_RLE, B_TRANSLATE("RLE"), currentCompression);

    // DON'T turn this on, it's so slow that I didn't wait long enough
    // the one time I tested this. So I don't know if the code even works.
    // Supposedly, this would look for an already written scanline, and
    // modify the scanline tables so that the current row is not written
    // at all...

    //add_menu_item(menu, SGI_COMP_ARLE, "Agressive RLE", currentCompression);

    fCompressionMF = new BMenuField("compression", 
        B_TRANSLATE("Use compression:"), menu);

    BAlignment labelAlignment(B_ALIGN_LEFT, B_ALIGN_NO_VERTICAL);

    BStringView* titleView = new BStringView("title", 
        B_TRANSLATE("SGI image translator"));
    titleView->SetFont(be_bold_font);
    titleView->SetExplicitAlignment(labelAlignment);

    char detail[100];
    sprintf(detail, B_TRANSLATE("Version %d.%d.%d %s"),
        static_cast<int>(B_TRANSLATION_MAJOR_VERSION(SGI_TRANSLATOR_VERSION)),
        static_cast<int>(B_TRANSLATION_MINOR_VERSION(SGI_TRANSLATOR_VERSION)),
        static_cast<int>(B_TRANSLATION_REVISION_VERSION(
            SGI_TRANSLATOR_VERSION)), __DATE__);
    BStringView* detailView = new BStringView("details", detail);
    detailView->SetExplicitAlignment(labelAlignment);

    BTextView* infoView = new BTextView("info");
    infoView->SetText(BString(B_TRANSLATE("written by:\n"))
            .Append(author)
            .Append(B_TRANSLATE("\n\nbased on GIMP SGI plugin v1.5:\n"))
            .Append(kSGICopyright).String());
    infoView->SetExplicitAlignment(labelAlignment);
    infoView->SetWordWrap(false);
    infoView->MakeEditable(false);
    infoView->MakeResizable(true);
    infoView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

    float padding = 5.0f;
    BLayoutBuilder::Group<>(this, B_VERTICAL, padding)
        .SetInsets(padding)
        .Add(titleView)
        .Add(detailView)
        .AddGroup(B_HORIZONTAL)
            .Add(fCompressionMF)
            .AddGlue()
            .End()
        .Add(infoView)
        .AddGlue();

    BFont font;
    GetFont(&font);
    SetExplicitPreferredSize(BSize((font.Size() * 390) / 12,
        (font.Size() * 180) / 12));

    // TODO: remove this workaround for ticket #4217
    infoView->SetExplicitPreferredSize(
        BSize(infoView->LineWidth(4), infoView->TextHeight(0, 80)));
    infoView->SetExplicitMaxSize(infoView->ExplicitPreferredSize());
    infoView->SetExplicitMinSize(infoView->ExplicitPreferredSize());
}
开发者ID:DonCN,项目名称:haiku,代码行数:76,代码来源:SGIView.cpp

示例6: appFile

void
ConfigWindow::MakeHowToView()
{
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
    BResources *resources = BApplication::AppResources();
    if (resources) {
        size_t length;
        char *buffer = (char *)resources->FindResource(B_LARGE_ICON_TYPE, 101,
                       &length);
        if (buffer) {
            BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, 63, 63),
                                                    B_CMAP8);
            if (bitmap && bitmap->InitCheck() == B_OK) {
                // copy and enlarge a 32x32 8-bit bitmap
                char *bits = (char *)bitmap->Bits();
                for (int32 i = 0, j = -64; i < (int32)length; i++) {
                    if ((i % 32) == 0)
                        j += 64;

                    char *b = bits + (i << 1) + j;
                    b[0] = b[1] = b[64] = b[65] = buffer[i];
                }
                fConfigView->AddChild(new BitmapView(bitmap));
            } else
                delete bitmap;
        }
    }
#else
    app_info info;
    if (be_app->GetAppInfo(&info) == B_OK) {
        BFile appFile(&info.ref, B_READ_ONLY);
        BAppFileInfo appFileInfo(&appFile);
        if (appFileInfo.InitCheck() == B_OK) {
            BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, 63, 63),
                                                    B_RGBA32);
            if (appFileInfo.GetIcon(bitmap, B_LARGE_ICON) == B_OK) {
                fConfigView->AddChild(new BitmapView(bitmap));
            } else
                delete bitmap;
        }
    }
#endif // HAIKU_TARGET_PLATFORM_HAIKU

    BRect rect = fConfigView->Bounds();
    BTextView *text = new BTextView(rect, NULL, rect, B_FOLLOW_NONE,
                                    B_WILL_DRAW);
    text->SetViewColor(fConfigView->Parent()->ViewColor());
    text->SetAlignment(B_ALIGN_CENTER);
    text->SetText(B_TRANSLATE(
                      "\n\nCreate a new account with the Add button.\n\n"
                      "Remove an account with the Remove button on the selected item.\n\n"
                      "Select an item in the list to change its settings."));
    rect = text->Bounds();
    text->ResizeTo(rect.Width(), text->TextHeight(0, 42));
    text->SetTextRect(rect);

    text->MakeEditable(false);
    text->MakeSelectable(false);

    fConfigView->AddChild(text);

    static_cast<CenterContainer *>(fConfigView)->Layout();
}
开发者ID:mmadia,项目名称:haiku-1,代码行数:63,代码来源:ConfigWindow.cpp


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