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


C++ BMessage类代码示例

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


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

示例1:

status_t
TermWindow::SessionID::AddToMessage(BMessage& message, const char* field) const
{
    return message.AddInt32(field, fID);
}
开发者ID:looncraz,项目名称:haiku,代码行数:5,代码来源:TermWindow.cpp

示例2: BMessage

void InfoView::UpdateDisplay( BMessage* message ) {
    
    time_t *membersince;
    char theTime[100], stemp[100];
    BString origProfile;
    unsigned idletime;
    ssize_t size;
    bool away = false;
    
    // away?
    if( message->HasBool("away") && message->FindBool("away") )
        away = true;
    
    // username
    if( message->HasString("userid") ) {
        
        BMessage* msg = new BMessage(BEAIM_UPDATE_NAME_FORMAT);
        msg->AddString("userid", message->FindString("userid"));
        Window()->PostMessage( msg );
        
        char windowTitle[DISPLAY_NAME_MAX+35];
        sprintf( windowTitle, "%s: %s", Language.get("IW_USER_INFO"), message->FindString("userid") );
        if( away ) {
            strcat( windowTitle, "  (" );
            strcat( windowTitle, Language.get("STAT_AWAY") );
            strcat( windowTitle, ")" );
        }
        Window()->SetTitle( windowTitle );
    }

    // user class
    if( message->HasString("userclass") ) {
        label2->SetText( message->FindString( "userclass" ) );
        printf( "IW: userclass done.\n" );
        fflush(stdout);
    }

    // member since
    if( message->HasData("membersince", B_TIME_TYPE) ) {
        message->FindData( "membersince", B_TIME_TYPE, (const void**)(&membersince), &size );
        strftime( theTime, 100, "%B %e, %Y", localtime(membersince) );
        label4->SetText( theTime );
    }
    
    // onsince	
    /*if( message->HasData("onsince", B_TIME_TYPE) ) {
    
        message->FindData( "onsince", B_TIME_TYPE, (const void**)(&onsince), &size );
        MakeElapsedTimeString( *onsince, theTime );
        label6->SetText( theTime );
    }*/
    
    // session length
    if( message->HasInt32("sessionlen") ) { 
        MakeElapsedTimeString( message->FindInt32("sessionlen"), theTime );
        label6->SetText( theTime );
    }
    
    // warning level
    if( message->HasInt32("warninglevel") ) {
        sprintf( stemp, "%u%%", (unsigned)(message->FindInt32("warninglevel")) );
        label8->SetText( stemp );
    }
    
    // idle time
    if( message->HasInt32( "idletime" ) ) {
        idletime = (unsigned)message->FindInt32("idletime");
        if( idletime ) {
            label9->SetText( (char*)LangWithSuffix("STAT_IDLE_TIME", ":") );
            MakeElapsedTimeString( (idletime*60), stemp );
            label10->SetText( stemp );
            statNotIdle = false;
        } else {
            label10->SetText( Language.get("STAT_ACTIVE") );
        }
    }
        
    // profile
    if( message->HasString("profile" ) )
        origProfile = BString((char*)message->FindString("profile"));

    if( origProfile.Length() ) {
        HTMLParser parse;
        styleList styles;

        // first, convert it to UTF-8
        origProfile = ConvertToUTF8( origProfile, encoding );

        // handle the away message variables
        client->ReplaceTagVars( origProfile );
        
        // automatically link the web and mail addresses that weren't linked
        Linkify( origProfile );

        profile->SetText("");
        profile->ClearInsertStuff();
        profile->ResetFontToBase();
        parse.Parse( const_cast<char*>(origProfile.String()) );
        styles = parse.Styles();
        profile->SetViewColor( styles.bgColor.R(), styles.bgColor.G(), styles.bgColor.B() );
//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:BeAIM,代码行数:101,代码来源:InfoWindow.cpp

示例3: fTermPref

status_t
TerminalThemesAddon::MakeThemeHaiku(BMessage &theme, uint32 flags)
{
    BMessage termpref;
    BMessage lines;
    status_t err;
    BPath pTermPref;
    
    (void)flags;
    err = MyMessage(theme, termpref);
    if (err)
        termpref.MakeEmpty();
    
    err = LoadHaikuTerminalSettings(lines);
    
    //XXX: WRITEME

/*
    char buffer[1024];
    char key[B_FIELD_NAME_LENGTH], data[512];
    int n;
    FILE *file;
    while (fgets(buffer, sizeof(buffer), file) != NULL) {
        if (*buffer == '#')
            continue;

        n = sscanf(buffer, "%*[\"]%[^\"]%*[\"]%*[^\"]%*[\"]%[^\"]", key, data);
        if (n == 2) {
            if (strstr(key, " Color")) {
                rgb_color color;
                int r, g, b;
                n = sscanf(data, "%3d, %3d, %3d", &r, &g, &b);
                color.red = r;
                color.green = g;
                color.blue = b;
                color.alpha = 255;
                
            } else
                lines.AddString(key, data);
        }
    }
*/
/*
    BFile fTermPref(pTermPref.Path(), B_READ_ONLY);
    if (fTermPref.InitCheck() != B_OK)
        return fTermPref.InitCheck();
    if (fTermPref.Read(&tp, sizeof(struct termprefs)) < (ssize_t)sizeof(struct termprefs))
        return EIO;
    if ((tp.magic != TP_MAGIC) || (tp.version != TP_VERSION))
        return EINVAL;
    termpref.AddInt32(TP_COLS, tp.p.cols);
    termpref.AddInt32(TP_ROWS, tp.p.rows);
    termpref.AddInt32(TP_TABWIDTH, tp.p.tab_width);
    BFont tFont;
    font_family ff;
    font_style fs;
    BString str(tp.p.font);
    str.Truncate(str.FindFirst('/'));
    strncpy(ff, str.String(), sizeof(ff));
    str.SetTo(tp.p.font);
    str.Remove(0, str.FindFirst('/')+1);
    strncpy(fs, str.String(), sizeof(fs));
    tFont.SetFamilyAndStyle(ff, fs);
    tFont.SetSize(tp.p.font_size);
    AddFont(termpref, TP_FONT, &tFont);
    AddRGBColor(termpref, TP_BG, tp.p.bg);
    AddRGBColor(termpref, TP_FG, tp.p.fg);
    AddRGBColor(termpref, TP_CURBG, tp.p.curbg);
    AddRGBColor(termpref, TP_CURFG, tp.p.curfg);
    AddRGBColor(termpref, TP_SELBG, tp.p.selbg);
    AddRGBColor(termpref, TP_SELFG, tp.p.selfg);
    termpref.AddInt32(TP_ENCODING, tp.p.encoding);
*/
    err = SetMyMessage(theme, termpref);
    return B_OK;
}
开发者ID:luciang,项目名称:haiku,代码行数:76,代码来源:TerminalAddon.cpp

示例4: SendNotices

void
DataView::SetSelection(int32 start, int32 end, view_focus focus)
{
    // correct the values if necessary

    if (start > end) {
        int32 temp = start;
        start = end;
        end = temp;
    }

    if (start > (int32)fSizeInView - 1)
        start = (int32)fSizeInView - 1;
    if (start < 0)
        start = 0;

    if (end > (int32)fSizeInView - 1)
        end = (int32)fSizeInView - 1;
    if (end < 0)
        end = 0;

    if (fStart == start && fEnd == end) {
        // nothing has changed, no need to update
        return;
    }

    // notify our listeners
    if (fStart != start) {
        BMessage update;
        update.AddInt64("position", start);
        SendNotices(kDataViewCursorPosition, &update);
    }

    BMessage update;
    update.AddInt64("start", start);
    update.AddInt64("end", end);
    SendNotices(kDataViewSelection, &update);

    // Update selection - first, we need to remove the old selection, then
    // we redraw the selection with the current values.

    DrawSelection(focus == kNoFocus);
        // From the block selection, only the parts that need updating are
        // actually updated, if there is no focus change.

    if (IsFocus() && fIsActive && focus == kNoFocus) {
        // Update the selection block incrementally

        if (start > fStart) {
            // remove from the top
            DrawSelectionBlock(fFocus, fStart, start - 1);
        } else if (start < fStart) {
            // add to the top
            DrawSelectionBlock(fFocus, start, fStart - 1);
        }

        if (end < fEnd) {
            // remove from bottom
            DrawSelectionBlock(fFocus, end + 1, fEnd);
        } else if (end > fEnd) {
            // add to the bottom
            DrawSelectionBlock(fFocus, fEnd + 1, end);
        }
    }

    if (focus != kNoFocus)
        fFocus = focus;
    fStart = start;
    fEnd = end;

    DrawSelection(focus == kNoFocus);

    fBitPosition = 0;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:74,代码来源:DataView.cpp

示例5: printf

/**
 * Obtains all of the information currently available for this plugin.
 */
nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
{
    nsCAutoString fpath;
    nsresult rv = mPlugin->GetNativePath(fpath);
    if (NS_OK != rv) {
        return rv;
    }
    const char *path = fpath.get();
    int i;

#ifdef NS_PLUGIN_BEOS_DEBUG
    printf("nsPluginFile::GetPluginInfo() an attempt to load MIME String\n");
    printf("path = <%s>\n", path);
#endif

    // get supported mime types
    BFile file(path, B_READ_ONLY);
    if (file.InitCheck() != B_OK)
        return NS_ERROR_FAILURE;

    BAppFileInfo appinfo(&file);
    if (appinfo.InitCheck() != B_OK)
        return NS_ERROR_FAILURE;

    BMessage msg;
    if (appinfo.GetSupportedTypes(&msg) != B_OK)
        return NS_ERROR_FAILURE;

    uint32 type;
    int32 types_num;
    if (msg.GetInfo("types", &type, &types_num) != B_OK
        || type != B_STRING_TYPE)
        return NS_ERROR_FAILURE;

    // set mime types to plugin info
    info.fMimeTypeArray =(char **)PR_Malloc(types_num * sizeof(char *));
    info.fMimeDescriptionArray =(char **)PR_Malloc(types_num * sizeof(char *));
    info.fExtensionArray =(char **)PR_Malloc(types_num * sizeof(char *));

    for (i = 0 ; i < types_num ; i ++) {
        // get mime string
        const char *mtype;
        if (msg.FindString("types", i, &mtype) != B_OK) {
            types_num = i;
            break;
        }
        
        // get (short)description for the mime
        char desc[B_MIME_TYPE_LENGTH+1] = "";
        BMimeType mime(mtype) ;
        if (mime.InitCheck() == B_OK)
            mime.GetShortDescription(desc);
        
        // get file extensions for the mime
        char extensions[B_MIME_TYPE_LENGTH+1] = "";
        GetMimeExtensions(mtype, extensions, B_MIME_TYPE_LENGTH+1);

        #ifdef NS_PLUGIN_BEOS_DEBUG
            printf("  mime = %30s | %10s | %15s |\n", 
                mtype, extensions, desc);
        #endif
        
        info.fMimeTypeArray[i] = PL_strdup( mtype ? mtype : (char *)"" ) ;
        info.fMimeDescriptionArray[i] = PL_strdup( desc ) ;
        info.fExtensionArray[i] = PL_strdup( extensions );
    }

    // get name and description of this plugin
    version_info vinfo;
    if (appinfo.GetVersionInfo(&vinfo, B_APP_VERSION_KIND) == B_OK
        && *vinfo.short_info) {
        // XXX convert UTF-8 2byte chars to 1 byte chars, to avoid string corruption
        info.fName = ToNewCString(NS_ConvertUTF8toUTF16(vinfo.short_info));
        info.fDescription = ToNewCString(NS_ConvertUTF8toUTF16(vinfo.long_info));
    } else {
        // use filename as its name
        info.fName = GetFileName(path);
        info.fDescription = PL_strdup("");
    }

    info.fVariantCount = types_num;
    info.fFileName = PL_strdup(path);


#ifdef NS_PLUGIN_BEOS_DEBUG
    printf("info.fFileName = %s\n", info.fFileName);
    printf("info.fName = %s\n", info.fName);
    printf("info.fDescription = %s\n", info.fDescription);
#endif

    return NS_OK;
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:95,代码来源:nsPluginsDirBeOS.cpp

示例6: MyMessage

status_t
TerminalThemesAddon::ApplyThemeR5(BMessage &theme, uint32 flags)
{
    BMessage termpref;
    status_t err;
    struct termprefs tp;
    
    err = MyMessage(theme, termpref);
    if (err)
        return err;
    tp.magic = TP_MAGIC;
    tp.version = TP_VERSION;
    tp.x = 0; // don't open at specific coords
    tp.y = 0;
    if (termpref.FindInt32(TP_COLS, (int32 *)&tp.p.cols) != B_OK)
        tp.p.cols = 80;
    if (termpref.FindInt32(TP_ROWS, (int32 *)&tp.p.rows) != B_OK)
        tp.p.rows = 25;
    if (termpref.FindInt32(TP_TABWIDTH, (int32 *)&tp.p.tab_width) != B_OK)
        tp.p.tab_width = 8;
    BFont tFont;
    tp.p.font_size = 12;
    strcpy(tp.p.font, "Courier10 BT/Roman");
    if (FindFont(termpref, TP_FONT, 0, &tFont) == B_OK) {
        font_family ff;
        font_style fs;
        tFont.GetFamilyAndStyle(&ff, &fs);
        strcpy(tp.p.font, ff);
        strcat(tp.p.font, "/");
        strcat(tp.p.font, fs);
        tp.p.font_size = (uint32)tFont.Size();
    }
    tp.p.cursor_blink_rate = 1000000;
    tp.p.refresh_rate = 0;
    
    if (FindRGBColor(termpref, TP_BG, 0, &tp.p.bg) != B_OK)
        tp.p.bg = make_color(255,255,255,255);
    if (FindRGBColor(termpref, TP_FG, 0, &tp.p.fg) != B_OK)
        tp.p.fg = make_color(0,0,0,255);
    if (FindRGBColor(termpref, TP_CURBG, 0, &tp.p.curbg) != B_OK)
        tp.p.curbg = make_color(255,255,255,255);
    if (FindRGBColor(termpref, TP_CURFG, 0, &tp.p.curfg) != B_OK)
        tp.p.curfg = make_color(0,0,0,255);
    if (FindRGBColor(termpref, TP_SELBG, 0, &tp.p.selbg) != B_OK)
        tp.p.selbg = make_color(0,0,0,255);
    if (FindRGBColor(termpref, TP_SELFG, 0, &tp.p.selfg) != B_OK)
        tp.p.selfg = make_color(255,255,255,255);
    
    if (termpref.FindInt32(TP_ENCODING, (int32 *)&tp.p.encoding) != B_OK)
        tp.p.encoding = 0; // UTF-8
    
    if (flags & UI_THEME_SETTINGS_SAVE && AddonFlags() & Z_THEME_ADDON_DO_SAVE) {
        BPath pTermPref;
        if (find_directory(B_USER_SETTINGS_DIRECTORY, &pTermPref) < B_OK)
            return EINVAL;
        pTermPref.Append("Terminal");
        BFile fTermPref(pTermPref.Path(), B_WRITE_ONLY|B_CREATE_FILE|B_ERASE_FILE);
        if (fTermPref.InitCheck() != B_OK) {
            return fTermPref.InitCheck();
        }
        fTermPref.Write(&tp, sizeof(struct termprefs));
        BNodeInfo ni(&fTermPref);
        if (ni.InitCheck() == B_OK)
            ni.SetType("application/x-vnd.Be-pref");
    }

    if (flags & UI_THEME_SETTINGS_APPLY && AddonFlags() & Z_THEME_ADDON_DO_APPLY) {
        BList teamList;
        app_info ainfo;
        int32 count, i;
        be_roster->GetAppList(&teamList);
        count = teamList.CountItems();
        for (i = 0; i < count; i++) {
            if (be_roster->GetRunningAppInfo((team_id)(teamList.ItemAt(i)), &ainfo) == B_OK) {
                if (!strcmp(ainfo.signature, kBeOSTerminalAppSig)) {
                    err = B_OK;
                    BMessage msg(MSG_R5_SET_PREF);
                    BMessenger msgr(NULL, ainfo.team);
                    tp.x = 0;
                    tp.y = 0;
                    
                    //msg.AddData("", 'UBYT', &(tp.p), sizeof(struct tpref));
                    msg.AddData("", 'UBYT', &(tp), sizeof(struct termprefs));
                    msg.AddSpecifier("Window", 0L);
                    err = msgr.SendMessage(&msg);
                }
            }
        }
    }
    
    return B_OK;
}
开发者ID:luciang,项目名称:haiku,代码行数:92,代码来源:TerminalAddon.cpp

示例7: BMessage

BMessage* PrefsWindow::GetPrefsMessage(BString prefsID)
{
    BMessage *prefsMessage = new BMessage(PrefsConstants::K_PREFS_UPDATE);
    prefsMessage->AddString(K_PREFS_ID, prefsID);
    return prefsMessage;
}
开发者ID:HaikuArchives,项目名称:BeTeX,代码行数:6,代码来源:PrefsWindow.cpp

示例8: BWindow

ToolSelectionWindow::ToolSelectionWindow(BRect frame)
    : BWindow(frame, StringServer::ReturnString(TOOLS_STRING),
              B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_H_RESIZABLE |
              B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK | B_AVOID_FRONT)
{
    int32 pictureSize = LARGE_TOOL_ICON_SIZE + 4.0;

    window_feel feel = B_NORMAL_WINDOW_FEEL;
    if (SettingsServer* server = SettingsServer::Instance()) {
        server->SetValue(SettingsServer::Application, skSelectToolWindowVisible,
                         true);

        BMessage settings;
        server->GetApplicationSettings(&settings);
        settings.FindInt32(skSelectToolWindowFeel, (int32*)&feel);
    }

    fMatrixView = new MatrixView(pictureSize, pictureSize, kExtraEdge);

    _AddTool(ToolManager::Instance().ReturnTool(FREE_LINE_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(STRAIGHT_LINE_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(RECTANGLE_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(ELLIPSE_TOOL));

    // Here we could add a separator to the tool window.

    _AddTool(ToolManager::Instance().ReturnTool(BRUSH_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(HAIRY_BRUSH_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(AIR_BRUSH_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(BLUR_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(FILL_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(TEXT_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(TRANSPARENCY_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(ERASER_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(SELECTOR_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(COLOR_SELECTOR_TOOL));

    ToolMap::iterator it = gToolMap.find(ToolManager::Instance().ReturnActiveToolType());
    if (it != gToolMap.end())
        it->second->SetValue(B_CONTROL_ON);

    AddChild(fMatrixView);
    fMatrixView->ResizeTo(Bounds().Width(), Bounds().Height());

    SetFeel(feel);
    if (feel == B_NORMAL_WINDOW_FEEL)
        SetLook(B_TITLED_WINDOW_LOOK);
    else
        SetLook(B_FLOATING_WINDOW_LOOK);

    float minDimension = 2 * kExtraEdge + pictureSize;
    float maxDimension = 1 + kExtraEdge + fMatrixView->CountChildren() *
                         (pictureSize + kExtraEdge);
    SetSizeLimits(minDimension, maxDimension, minDimension, maxDimension);

    if (Lock()) {
        AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE,
                                           B_MOUSE_DOWN, window_activation_filter));
        AddCommonFilter(new BMessageFilter(B_KEY_DOWN, AppKeyFilterFunction));
        Unlock();
    }

    Show();

    // NOTE: this is broken/ not implemented in Haiku, so the tools window
    //		 will not show up horizontal as it should be, enable if implemented
    //SetWindowAlignment(B_PIXEL_ALIGNMENT, 0, 0, picture_size + kExtraEdge,
    //	kExtraEdge + 1, 0, 0, picture_size + kExtraEdge, kExtraEdge + 1);

    // remove this if SetWindowAlignment is implemented
    ResizeBy(0.0, maxDimension - pictureSize);

    fSelectionWindow = this;
    FloaterManager::AddFloater(this);
}
开发者ID:puckipedia,项目名称:ArtPaint,代码行数:75,代码来源:ToolSelectionWindow.cpp

示例9: switch

void ChatWindow::MessageReceived( BMessage* aMessage ) {
    switch( aMessage->what ) {
        case SHOW_MESSAGE:
            {
            const char *msg;
            aMessage->FindString( "msg", &msg );
            time_t _now = time( NULL );
            struct tm *now = localtime( &_now );
            BString *str = NULL;
            BString *str2 = NULL;
            char *string = NULL;
            Person *person = NULL;
            for( int i = 0; i < iWindow->GetProfile()->GetUserlist()->GetList()->CountItems(); i++ ) {
                person = ( Person* ) iWindow->GetProfile()->GetUserlist()->GetList()->ItemAt( i );
                if( iWho == person->GetUIN() ) {
                    str = new BString();
                    str->SetTo( person->GetDisplay() );
                    break;
                }
            }
            if( !str ) {
                str = new BString();
                *str << ( int32 ) iWho;
            }
            BFont *font = new BFont( be_plain_font );
            font->SetSize( 16.0 );
            font->SetEncoding( B_ISO_8859_2 );
            rgb_color yellow = { 255, 255, 0, 0 };
            rgb_color red = { 255, 0, 0, 0 };
            rgb_color white = { 255, 255, 255, 0 };
            string = ( char* ) calloc( strlen( "[00:00] " ), 1 );
            sprintf( string, "[%02d:%02d] ", now->tm_hour, now->tm_min);
            str2 = new BString();
            str2->SetTo( string );
            free( string );
            iChat->SetFontAndColor( iChat->TextLength(), iChat->TextLength() + str2->Length(), font, B_FONT_ALL, &yellow );
            iChat->Insert( iChat->TextLength(), str2->String(), str2->Length() );
            str->Append( ": " );

            iChat->SetFontAndColor( iChat->TextLength(), iChat->TextLength() + str->Length(), font, B_FONT_ALL, &red );
            iChat->Insert( iChat->TextLength(), str->String(), str->Length() );

            str2->SetTo( msg );
            str2->Append( "\n" );
            iChat->SetFontAndColor( iChat->TextLength(), iChat->TextLength() + str2->Length(), font, B_FONT_ALL, &white );
            iChat->Insert( iChat->TextLength(), str2->String(), str2->Length() );
            BScrollBar * scrollBar = iScrollView->ScrollBar( B_VERTICAL );
            if( scrollBar->LockLooper() ) {
                float max,min;
                scrollBar->GetRange( &min, &max );
                scrollBar->SetValue( max );
                scrollBar->UnlockLooper();
            }
            delete str;
            delete str2;
            break;			
            }
        case BEGG_SEND:
            {
            if( iSayControl->LockLooper()) {
                if( !(*iSayControl->Text() ) ) {
                    /* nothing to send */
                    iSayControl->UnlockLooper();
                    break;
                }
                /* first we add message into chat window */
                time_t _now = time( NULL );
                struct tm * now = localtime( &_now );
                BString str;
                BString str2;
                char *string;
//				int id = iNetwork->GetIdent();

                BFont *font = new BFont( be_plain_font );
                font->SetSize( 16.0 );
                font->SetEncoding( B_ISO_8859_2 );
                rgb_color yellow = { 255, 255, 0, 0 };
                rgb_color green = { 0, 255, 0, 0 };
                rgb_color white = { 255, 255, 255, 0 };
                string = ( char* ) calloc( strlen( "[00:00] " ), 1 );
                sprintf( string, "[%02d:%02d] ", now->tm_hour, now->tm_min );
                str2.SetTo( string );
                free( string );
                iChat->SetFontAndColor( iChat->TextLength(), iChat->TextLength() + str2.Length(), font, B_FONT_ALL, &yellow );
                iChat->Insert( iChat->TextLength(), str2.String(), str2.Length() );

                str.SetTo( iWindow->GetProfile()->GetProfileName() );
                str.Append( ": " );
                iChat->SetFontAndColor( iChat->TextLength(), iChat->TextLength() + str.Length(), font, B_FONT_ALL, &green );
                iChat->Insert( iChat->TextLength(), str.String(), str.Length() );

                str2.SetTo( iSayControl->Text() );
                str2.Append( "\n" );
                iChat->SetFontAndColor( iChat->TextLength(), iChat->TextLength() + str2.Length(), font, B_FONT_ALL, &white );
                iChat->Insert( iChat->TextLength(), str2.String(), str2.Length() );

                /* scroll down */
                BScrollBar * scrollBar = iScrollView->ScrollBar( B_VERTICAL );
                if( scrollBar->LockLooper() ) {
                    float max,min;
//.........这里部分代码省略.........
开发者ID:louisdem,项目名称:beos-begadu,代码行数:101,代码来源:Chat.cpp

示例10: BPopUpMenu

void
CAssemblyWindow::AddToolBar()
{
    BMessage *message;

    // make the pop up menu for 'Select' tool
    BPopUpMenu *selectMenu = new BPopUpMenu("", false, false);
    selectMenu->SetFont(be_plain_font);	
    message = new BMessage(SELECT_MODE_CHANGED);
    message->AddInt32("mev:mode", CEventEditor::RECTANGLE_SELECTION);
    selectMenu->AddItem(new CIconMenuItem("Rectangle", message,
                                          ResourceUtils::LoadImage("ArrowTool")));
    message = new BMessage(*message);
    message->ReplaceInt32("mev:mode", CEventEditor::LASSO_SELECTION);
    selectMenu->AddItem(new CIconMenuItem("Lasso", message,
                                          ResourceUtils::LoadImage("LassoTool")));
    selectMenu->SetTargetForItems(this);

    // make the pop up menu for 'Create' tool
    BPopUpMenu *createMenu = new BPopUpMenu("", false, false);
    createMenu->SetFont(be_plain_font);
    message = new BMessage(NEW_EVENT_TYPE_CHANGED);
    message->AddInt32("type", EvtType_Count);
    createMenu->AddItem(new CIconMenuItem("Default", message,
                                          ResourceUtils::LoadImage("PencilTool")));
    createMenu->AddSeparatorItem();
    message = new BMessage(*message);
    message->ReplaceInt32("type", EvtType_Tempo);
    createMenu->AddItem(new CIconMenuItem("Tempo", message,
                                          ResourceUtils::LoadImage("MetroTool")));
    message = new BMessage(*message);
    message->ReplaceInt32("type", EvtType_TimeSig);
    createMenu->AddItem(new CIconMenuItem("Time Signature", message,
                                          ResourceUtils::LoadImage("TimeSigTool")));
    message = new BMessage(*message);
    message->ReplaceInt32("type", EvtType_Repeat);
    createMenu->AddItem(new CIconMenuItem("Repeat", message,
                                          ResourceUtils::LoadImage("RepeatTool")));
    message = new BMessage(*message);
    message->ReplaceInt32("type", EvtType_End);
    createMenu->AddItem(new CIconMenuItem("Part End", message,
                                          ResourceUtils::LoadImage("EndTool")));
    createMenu->SetTargetForItems(this);

    BRect rect(Bounds());
    if (KeyMenuBar())
        rect.top = KeyMenuBar()->Frame().bottom + 1.0;
    rect.right += 1.0;

    // add the tool bar
    CToolBar *toolBar = new CToolBar(rect, "General");
    CTool *tool;
    toolBar->AddTool(tool = new CBitmapTool("Snap To Grid",
                                            ResourceUtils::LoadImage("GridTool"),
                                            new BMessage(CEventEditor::TOOL_GRID)));
    tool->SetValue(B_CONTROL_ON);
    toolBar->AddSeparator();

    toolBar->AddTool(tool = new CMenuTool("Select",
                                          ResourceUtils::LoadImage("ArrowTool"),
                                          selectMenu,
                                          new BMessage(CEventEditor::TOOL_SELECT)));
    tool->SetValue(B_CONTROL_ON);
    toolBar->AddTool(new CMenuTool("Create", ResourceUtils::LoadImage("PencilTool"),
                                   createMenu, new BMessage(CEventEditor::TOOL_CREATE)));
    toolBar->AddTool(tool = new CBitmapTool("Eraser",
                                            ResourceUtils::LoadImage("EraserTool"),
                                            new BMessage(CEventEditor::TOOL_ERASE)));
    toolBar->MakeRadioGroup("Select", "Eraser", true);

    SetToolBar(toolBar);
}
开发者ID:HaikuArchives,项目名称:MeV,代码行数:72,代码来源:AssemblyWindow.cpp

示例11: beFakTab

tabTowar::tabTowar(BTabView *tv, sqlite *db, BHandler *hr) : beFakTab(tv, db, hr) {

    curdata = new towardat(db);
    this->dirty = false;

    this->tab->SetLabel("Towary [F3]");
    BRect r;
    r = this->view->Bounds();

    // columnlistview
    r.left = 5; r.right = 160; r.top = 30; r.bottom = 490;
    CLVContainerView *containerView;
    list = new ColumnListView(r, &containerView, NULL, B_FOLLOW_LEFT|B_FOLLOW_TOP_BOTTOM,
        B_WILL_DRAW|B_FRAME_EVENTS|B_NAVIGABLE, B_SINGLE_SELECTION_LIST, false, true, true, true,
        B_FANCY_BORDER);
    list->AddColumn(new CLVColumn("Symbol", 54, CLV_TELL_ITEMS_WIDTH|CLV_HEADER_TRUNCATE|CLV_SORT_KEYABLE));
    list->AddColumn(new CLVColumn("Nazwa", 100, CLV_TELL_ITEMS_WIDTH|CLV_HEADER_TRUNCATE|CLV_SORT_KEYABLE));
    list->SetSortFunction(CLVEasyItem::CompareItems);
    this->view->AddChild(containerView);
    list->SetInvocationMessage(new BMessage(LIST_INV));
    list->SetSelectionMessage(new BMessage(LIST_SEL));
    // buttons
    but_new = new BButton(BRect(30,0,140,24), "tt_but_new", "Nowy towar [F5]", new BMessage(BUT_NEW), B_FOLLOW_LEFT|B_FOLLOW_TOP);
    but_del = new BButton(BRect(30,510,140,534), "tt_but_del", "Usuń zaznaczone [F8]", new BMessage(BUT_DEL), B_FOLLOW_LEFT|B_FOLLOW_BOTTOM);
    but_restore = new BButton(BRect(235,510,325,534), "tt_but_restore", "Przywróć [F6]", new BMessage(BUT_RESTORE), B_FOLLOW_LEFT|B_FOLLOW_BOTTOM);
    but_save = new BButton(BRect(580,510,670,534), "tt_but_save", "Zapisz", new BMessage(BUT_SAVE), B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM);
    this->view->AddChild(but_new);
    this->view->AddChild(but_del);
    this->view->AddChild(but_restore);
    this->view->AddChild(but_save);
    but_new->ResizeToPreferred();
    but_del->ResizeToPreferred();
    but_restore->ResizeToPreferred();
    but_save->ResizeToPreferred();
    // box1
    box1 = new BBox(BRect(230,30,710,140), "tt_box1");
    box1->SetLabel("Dane towaru");
    this->view->AddChild(box1);
    // box1-stuff
    data[0] = new BTextControl(BRect(10,15,270,35), "ttd0", "Nazwa", NULL, new BMessage(DC));
    data[1] = new BTextControl(BRect(280,15,420,35), "ttd1", "Symbol", NULL, new BMessage(DC));
    data[2] = new BTextControl(BRect(10,50,150,65), "ttd2", "PKWiU", NULL, new BMessage(DC));
    data[3] = new BTextControl(BRect(160,50,270,65), "ttd3", "j.m.", NULL, new BMessage(DC));
    box1->AddChild(data[0]); box1->AddChild(data[1]);
    box1->AddChild(data[2]); box1->AddChild(data[3]);
    usluga = new BCheckBox(BRect(350,50,420,65), "ttdo", "Usługa", new BMessage(DC));
    box1->AddChild(usluga);
    dodany = new BStringView(BRect(280,80,340,95), "tts0", "Dodano:");
    dodany->SetAlignment(B_ALIGN_RIGHT);
    box1->AddChild(dodany);
    dodany = new BStringView(BRect(350,80,420,95), "ttsd", "");
    box1->AddChild(dodany);
    // box1-menu
    BMenu *menujm = new BMenu("");
    BMessage *msg;
    int j=0;
    while (jmiary[j] != NULL) {
        msg = new BMessage(MENUJM); msg->AddString("_jm",jmiary[j]);
        menujm->AddItem(new BMenuItem(jmiary[j], msg));
        j++;
    }
    BMenuField *menujmField = new BMenuField(BRect(280,50,340,65), "ttmf", NULL, menujm);
    box1->AddChild(menujmField);
    // box2
    box2 = new BBox(BRect(230,150,710,300), "tt_box2");
    box2->SetLabel("Ceny");
    this->view->AddChild(box2);
    // box2-stuff
    ceny[0] = new BTextControl(BRect(10,15,190,35), "ttc0", "Cena netto (zł)", NULL, new BMessage(DC));
    ceny[1] = new BTextControl(BRect(10,50,190,65), "ttc1", "Netto zakupu", NULL, new BMessage(DC));
    ceny[2] = new BTextControl(BRect(10,80,190,95), "ttc2", "Marża (%)", NULL, new BMessage(DC));
    ceny[3] = new BTextControl(BRect(200,50,310,65), "ttc3", "Rabat (%)", NULL, new BMessage(DC));
    ceny[4] = new BTextControl(BRect(10,110,190,125), "ttc4", "Kurs waluty", "1", new BMessage(DC));
    ceny[5] = new BTextControl(BRect(200,110,310,125), "ttc5", "Cło (%)", NULL, new BMessage(DC));
    box2->AddChild(ceny[0]);
    box2->AddChild(ceny[1]);
    box2->AddChild(ceny[2]);
    box2->AddChild(ceny[3]);
    box2->AddChild(ceny[4]);
    box2->AddChild(ceny[5]);
    but_sell = new BButton(BRect(340,50,420,65), "tt_but_sell", "Cena sprzedaży", new BMessage(BUT_SELL));
    but_marza = new BButton(BRect(340,80,420,95), "tt_but_marza", "Marża", new BMessage(BUT_MARZA));
    but_import = new BButton(BRect(340,110,420,125), "tt_but_import", "Import", new BMessage(BUT_IMPORT));
    box2->AddChild(but_sell);
    box2->AddChild(but_marza);
    box2->AddChild(but_import);
    but_sell->ResizeToPreferred();
    but_marza->ResizeToPreferred();
    but_import->ResizeToPreferred();
    brutto = new BStringView(BRect(330,15,390,35), "ttb0", "Cena brutto:");
    box2->AddChild(brutto);
    brutto = new BStringView(BRect(400,15,475,35), "ttbr", NULL);
    box2->AddChild(brutto);
    // box2-menu
    menuvat = new BPopUpMenu("[wybierz]");
    vatRows = 0; vatIds = NULL;
    RefreshVatSymbols();
    BMenuField *menuvatField = new BMenuField(BRect(200,15,330,35), "ttmv", "VAT", menuvat);
    menuvatField->SetDivider(be_plain_font->StringWidth(menuvatField->Label())+15);
    box2->AddChild(menuvatField);
//.........这里部分代码省略.........
开发者ID:Premislaus,项目名称:beos-fakBEtur,代码行数:101,代码来源:tabtowar.cpp

示例12: UT_ASSERT


//.........这里部分代码省略.........
                    //	key=B_DELETE;
                    }
                    else
                    {
                        key=betterString[0];
                    }	
                }
            }

            xxx_UT_DEBUGMSG(("NORM MENU: L:[%s] MN:[%s] \n", 
                (szLabelName) ? szLabelName : "NULL", 
                (szMnemonicName) ? szMnemonicName : "NULL")); 
            if (szLabelName && *szLabelName) {
            

        
                char buf[1024];
                // convert label into proper version and get accelerators
                
                int32 iLength = strlen(szLabelName);
                char* buffer = new char[2*(iLength+1)];
                    
        		memset(buffer, 0, 2*(iLength+1));

                int32 destLength = 2*(iLength + 1);
                int32 state =0;
            
                convert_to_utf8(B_ISO1_CONVERSION , szLabelName , &iLength ,  buffer , &destLength , &state);
                buffer[destLength] = '\0';
                
                accel = _ev_convert(buf, buffer);
                
                //UT_ASSERT(pMenu);
                BMessage *newmesg = new BMessage(ABI_BEOS_MENU_EV);
                newmesg->AddInt32(ABI_BEOS_MENU_EV_NAME, id);
                
                BMenuItem *pMenuItem = new BMenuItem(buf, newmesg, key,modifiers);
                pMenuBar->AddItem(pMenuItem);
                
                delete [] buffer;
            }
            else {
                //We are reserving a spot in the menu for something
                //printf("Spot being reserved \n");
            }
            break;
        }
        case EV_MLF_BeginSubMenu: {
            const char **data= _ev_GetLabelName(m_pBeOSApp, m_pFrame, pAction, pLabel);
            //char ** data = _ev_GetLabelName(m_pBeOSApp, m_pBeOSFrame, pAction, pLabel);
                        szLabelName = data[0];

                        szMnemonicName = data[1];           
            xxx_UT_DEBUGMSG(("START SUB MENU: L:[%s] MN:[%s] \n", 
                (szLabelName) ? szLabelName : "NULL", 
                (szMnemonicName) ? szMnemonicName : "NULL")); 

            if (szLabelName && *szLabelName) {
                // convert label into underscored version
                char buf[1024];
                
                int32 iLength = strlen(szLabelName);
                char* buffer = new char[2*(iLength+1)];

                int32 destLength = 2*(iLength + 1);
                int32 state =0;
开发者ID:HaikuArchives,项目名称:AbiWord,代码行数:67,代码来源:ev_BeOSMenu.cpp

示例13: BView

// constructor
StyleView::StyleView(BRect frame)
    :
#ifdef __HAIKU__
    BView("style view", 0),
#else
    BView(frame, "style view", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_FRAME_EVENTS),
#endif
    fCommandStack(NULL),
    fCurrentColor(NULL),
    fStyle(NULL),
    fGradient(NULL),
    fIgnoreCurrentColorNotifications(false),
    fIgnoreControlGradientNotifications(false),
    fPreviousBounds(frame.OffsetToCopy(B_ORIGIN))
{
    SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

    // style type
    BMenu* menu = new BPopUpMenu("<unavailable>");
    BMessage* message = new BMessage(MSG_SET_STYLE_TYPE);
    message->AddInt32("type", STYLE_TYPE_COLOR);
    menu->AddItem(new BMenuItem("Color", message));
    message = new BMessage(MSG_SET_STYLE_TYPE);
    message->AddInt32("type", STYLE_TYPE_GRADIENT);
    menu->AddItem(new BMenuItem("Gradient", message));

#ifdef __HAIKU__
    BGridLayout* layout = new BGridLayout(5, 5);
    SetLayout(layout);

    fStyleType = new BMenuField( "Style type", menu, NULL);

#else
    frame.OffsetTo(B_ORIGIN);
    frame.InsetBy(5, 5);
    frame.bottom = frame.top + 15;

    fStyleType = new BMenuField(frame, "style type", "Style type",
        menu, true);
    AddChild(fStyleType);

    float width;
    float height;
    fStyleType->MenuBar()->GetPreferredSize(&width, &height);
    fStyleType->MenuBar()->ResizeTo(width, height);
    fStyleType->ResizeTo(frame.Width(), height + 6);
    fStyleType->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
    fStyleType->MenuBar()->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
#endif // __HAIKU__

    // gradient type
    menu = new BPopUpMenu("<unavailable>");
    message = new BMessage(MSG_SET_GRADIENT_TYPE);
    message->AddInt32("type", GRADIENT_LINEAR);
    menu->AddItem(new BMenuItem("Linear", message));
    message = new BMessage(MSG_SET_GRADIENT_TYPE);
    message->AddInt32("type", GRADIENT_CIRCULAR);
    menu->AddItem(new BMenuItem("Radial", message));
    message = new BMessage(MSG_SET_GRADIENT_TYPE);
    message->AddInt32("type", GRADIENT_DIAMOND);
    menu->AddItem(new BMenuItem("Diamond", message));
    message = new BMessage(MSG_SET_GRADIENT_TYPE);
    message->AddInt32("type", GRADIENT_CONIC);
    menu->AddItem(new BMenuItem("Conic", message));

#if __HAIKU__
    fGradientType = new BMenuField("Gradient type", menu, NULL);
    fGradientControl = new GradientControl(new BMessage(MSG_SET_COLOR), this);

    layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(3), 0, 0, 4);
    layout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(3), 0, 1, 1, 3);

    layout->AddItem(fStyleType->CreateLabelLayoutItem(), 1, 1);
    layout->AddItem(fStyleType->CreateMenuBarLayoutItem(), 2, 1);

    layout->AddItem(fGradientType->CreateLabelLayoutItem(), 1, 2);
    layout->AddItem(fGradientType->CreateMenuBarLayoutItem(), 2, 2);

    layout->AddView(fGradientControl, 1, 3, 2);

    layout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(3), 3, 1, 1, 3);
    layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(3), 0, 4, 4);

#else // !__HAIKU__
    frame.OffsetBy(0, fStyleType->Frame().Height() + 6);
    fGradientType = new BMenuField(frame, "gradient type", "Gradient type",
        menu, true);
    AddChild(fGradientType);

    fGradientType->MenuBar()->GetPreferredSize(&width, &height);
    fGradientType->MenuBar()->ResizeTo(width, height);
    fGradientType->ResizeTo(frame.Width(), height + 6);
    fGradientType->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
    fGradientType->MenuBar()->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);

    // create gradient control
    frame.top = fGradientType->Frame().bottom + 8;
    frame.right = Bounds().right - 5;
    fGradientControl = new GradientControl(new BMessage(MSG_SET_COLOR),
//.........这里部分代码省略.........
开发者ID:mariuz,项目名称:haiku,代码行数:101,代码来源:StyleView.cpp

示例14: MouseWatcher

int32 MouseWatcher(void* data)
{
    BMessenger	*TheMessenger = (BMessenger*)data;
    BPoint 		PreviousPos;
    uint32 		PreviousButtons = 0;
    bool 		FirstCheck = true;
    BMessage 	MessageToSend;
    
    MessageToSend.AddPoint("where",BPoint(0,0));
    MessageToSend.AddInt32("buttons",0);
    
    while(true)
    {
        if (!TheMessenger->LockTarget())
        {
            delete TheMessenger;
            return 0;			// window is dead so exit
        }
        
        BLooper *TheLooper;
        BView	*TheView = (BView*)TheMessenger->Target(&TheLooper);
        BPoint 	Where;
        uint32 	Buttons;
        TheView->GetMouse(&Where,&Buttons,false);
        
        if(FirstCheck)
        {
            PreviousPos = Where;
            PreviousButtons = Buttons;
            FirstCheck = false;
        }
        
        bool Send = false;
        if(Buttons != PreviousButtons || Buttons == 0 || Where != PreviousPos)
        {
            if(Buttons == 0)
                MessageToSend.what = MW_MOUSE_UP;
            else if(Buttons != PreviousButtons)
                MessageToSend.what = MW_MOUSE_DOWN;
            else
                MessageToSend.what = MW_MOUSE_MOVED;
            
            MessageToSend.ReplacePoint("where",Where);
            MessageToSend.ReplaceInt32("buttons",Buttons);
            Send = true;
        }
        
        TheLooper->Unlock();
        
        if(Send)
            TheMessenger->SendMessage(&MessageToSend);
        
        if(Buttons == 0)
        {
            //Button was released
            delete TheMessenger;
            return 0;
        }
        
        snooze(50 * 1000);
    }
}
开发者ID:HaikuArchives,项目名称:UltraEncode,代码行数:62,代码来源:TMouseWatcher.cpp

示例15: _emptyInactiveNodeState

status_t MediaRoutingView::importState(
    const BMessage*						archive) {

    status_t err;

    _emptyInactiveNodeState();

    layout_t layout;
    err = archive->FindInt32("layout", (int32*)&layout);
    if(err == B_OK && layout != m_layout) {
        layoutChanged(layout);
    }
    
    const char* path;
    err = archive->FindString("bgBitmap", &path);
    if(err == B_OK) {
        BEntry entry(path);
        entry_ref ref;
        err = entry.GetRef(&ref);
        if(err == B_OK)
            _changeBackground(&ref);
    }
    else {
        rgb_color color;
        color.alpha = 255;
        if(
            archive->FindInt8("bgRed", (int8*)&color.red) == B_OK &&
            archive->FindInt8("bgGreen", (int8*)&color.green) == B_OK &&
            archive->FindInt8("bgBlue", (int8*)&color.blue) == B_OK)
                _changeBackground(color);
    }	
    
    for(int32 n = 0; ; ++n) {

        // find panel state info; stop when exhausted
        BMessage m;
        err = archive->FindMessage("panel", n, &m);
        if(err < B_OK)
            break;
        
        const char* nodeName;
        err = archive->FindString("nodeName", n, &nodeName);
        if(err < B_OK)
            break;
            
        uint32 nodeKind;
        err = archive->FindInt32("nodeKind", n, (int32*)&nodeKind);
        if(err < B_OK)
            break;

        // look up matching panel +++++ SLOW +++++
        uint32 panelIndex;
        uint32 items = CountItems(DiagramItem::M_BOX);
        for(
            panelIndex = 0;
            panelIndex < items;
            ++panelIndex) {
        
            MediaNodePanel* panel = dynamic_cast<MediaNodePanel*>(
                ItemAt(panelIndex, DiagramItem::M_BOX));
                
            if(panel &&
                !strcmp(panel->ref->name(), nodeName) &&
                panel->ref->kind() == nodeKind) {
                
                // found match; hand message to panel
                panel->importState(&m);
                break;
            }
        }
        if(panelIndex == items) {
            // no panel found
            // if a "system node" hang onto (and re-export) state info
            bool sysOwned;
            if(m.FindBool("sysOwned", &sysOwned) == B_OK && sysOwned) {
                m_inactiveNodeState.AddItem(
                    new _inactive_node_state_entry(
                        nodeName, nodeKind, m));
            }
        }
    }

    updateDataRect();
    
    return B_OK;
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:86,代码来源:MediaRoutingView.cpp


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