示例#1
0
status_t
TermWindow::SessionID::AddToMessage(BMessage& message, const char* field) const
{
	return message.AddInt32(field, fID);
}
示例#2
0
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() );
		profile->Invalidate();
		profile->AddStyledText( parse.ParsedString(), styles );
		styles.Clear();
		profile->AddStatement();
	} 
	
	// put up a generic "no profile" message
	else
		profile->SetText( Language.get("IW_NO_PROFILE") );
	BView::Invalidate();
}
示例#3
0
void
NetworkSetupWindow::_BuildShowTabView(int32 msg_what)
{
    BPath path;
    BPath addon_path;
    BDirectory dir;
    BEntry entry;

    char* search_paths = getenv("ADDON_PATH");
    if (!search_paths)
        return;

    float minimumWidth = be_control_look->DefaultItemSpacing() * 37;
    float minimumHight = be_control_look->DefaultItemSpacing() * 25;

    fMinAddonViewRect.Set(0, 0, minimumWidth, minimumHight);
    // Minimum size

    search_paths = strdup(search_paths);
    char* next_path_token;
    char* search_path = strtok_r(search_paths, ":", &next_path_token);

    while (search_path) {
        if (strncmp(search_path, "%A/", 3) == 0) {
            app_info ai;
            be_app->GetAppInfo(&ai);
            entry.SetTo(&ai.ref);
            entry.GetPath(&path);
            path.GetParent(&path);
            path.Append(search_path + 3);
        } else {
            path.SetTo(search_path);
            path.Append("Network Setup");
        }

        search_path = strtok_r(NULL, ":", &next_path_token);

        dir.SetTo(path.Path());
        if (dir.InitCheck() != B_OK)
            continue;

        dir.Rewind();
        while (dir.GetNextEntry(&entry) >= 0) {
            if (entry.IsDirectory())
                continue;

            entry.GetPath(&addon_path);
            image_id addon_id = load_add_on(addon_path.Path());
            if (addon_id < 0) {
                printf("Failed to load %s addon: %s.\n", addon_path.Path(),
                       strerror(addon_id));
                continue;
            }

            network_setup_addon_instantiate get_nth_addon;
            status_t status = get_image_symbol(addon_id, "get_nth_addon",
                                               B_SYMBOL_TYPE_TEXT, (void **) &get_nth_addon);

            int tabCount = 0;

            if (status != B_OK) {
                //  No "addon instantiate function" symbol found in this addon
                printf("No symbol \"get_nth_addon\" found in %s addon: not a "
                       "network setup addon!\n", addon_path.Path());
                unload_add_on(addon_id);
                continue;
            }

            while ((fNetworkAddOnMap[fAddonCount]
                    = get_nth_addon(addon_id, tabCount)) != NULL) {
                printf("Adding Tab: %d\n", fAddonCount);
                BMessage* msg = new BMessage(msg_what);

                BRect r(0, 0, 0, 0);
                BView* addon_view
                    = fNetworkAddOnMap[fAddonCount]->CreateView(&r);
                fMinAddonViewRect = fMinAddonViewRect | r;

                msg->AddInt32("image_id", addon_id);
                msg->AddString("addon_path", addon_path.Path());
                msg->AddPointer("addon", fNetworkAddOnMap[fAddonCount]);
                msg->AddPointer("addon_view", addon_view);

                BTab* tab = new BTab;
                fPanel->AddTab(addon_view, tab);
                tab->SetLabel(fNetworkAddOnMap[fAddonCount]->Name());
                fAddonCount++;
                // Number of tab addons total
                tabCount++;
                // Tabs for *this* addon
            }
        }
    }

    free(search_paths);
}
示例#4
0
TermWindow::SessionID::SessionID(const BMessage& message, const char* field)
{
	if (message.FindInt32(field, &fID) != B_OK)
		fID = -1;
}
示例#5
0
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;
}
示例#6
0
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;
}
/**
 * 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;
}
示例#8
0
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;
}
示例#9
0
BMessage* PrefsWindow::GetPrefsMessage(BString prefsID)
{
	BMessage *prefsMessage = new BMessage(PrefsConstants::K_PREFS_UPDATE);
	prefsMessage->AddString(K_PREFS_ID, prefsID);
	return prefsMessage;
}
示例#10
0
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);
}
示例#11
0
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;
					scrollBar->GetRange( &min, &max );
					scrollBar->SetValue( max );
					scrollBar->UnlockLooper();
				}
				/* sending... */
				BMessage *newmessage;
				newmessage = new BMessage( SEND_MESSAGE );
				newmessage->AddInt32( "who", iWho );
				newmessage->AddString( "msg", iSayControl->Text());
				BMessenger( iNetwork ).SendMessage( newmessage );
				delete newmessage;
				/* clearing edit box */
				iSayControl->SetText( NULL );
				iSayControl->UnlockLooper();
			}
			break;
			}			
		default:
			BWindow::MessageReceived( aMessage );
			break;
	}
}
示例#12
0
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);
}
示例#13
0
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);
	// box3
	box3 = new BBox(BRect(230,310,710,390), "tt_box3");
	box3->SetLabel("Magazyn");
	this->view->AddChild(box3);
	// box3-stuff
	magazyn = new BTextControl(BRect(10,30,250,40), "ttm0", "Stan:", NULL, new BMessage(DC));
	magzmiana = new BStringView(BRect(230,30,370,45), "ttm1", "Ostatnia zmiana:");
	magzmiana->SetAlignment(B_ALIGN_RIGHT);
	box3->AddChild(magzmiana);
	magzmiana = new BStringView(BRect(380,35,470,45), "ttm2", NULL);
	box3->AddChild(magzmiana);
	box3->AddChild(magazyn);
	// box4
	box4 = new BBox(BRect(230,400,710,480), "tt_box4");
	box4->SetLabel("Notatki");
	this->view->AddChild(box4);
	// box4-stuff
	r = box4->Bounds();
	r.InsetBy(10,15);
	BRect s = r; s.OffsetTo(0,0);
	notatki = new BTextView(r, "ttno", s, B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW);
	box4->AddChild(notatki);
	// fix widths
	int i;
	// first set them to be enough
	for (i=0;i<=3;i++) {
		data[i]->SetDivider(be_plain_font->StringWidth(data[i]->Label())+5);
	}
	for (i=0;i<=5;i++) {
		ceny[i]->SetDivider(be_plain_font->StringWidth(ceny[i]->Label())+5);
	}
	magazyn->SetDivider(be_plain_font->StringWidth(magazyn->Label())+5);
	// align in columns
	float d;
	d = max(data[0]->Divider(), data[2]->Divider());
	data[0]->SetDivider(d); data[2]->SetDivider(d);
	d = max(ceny[0]->Divider(), ceny[1]->Divider());
	d = max(ceny[2]->Divider(), d);
	d = max(ceny[4]->Divider(), d);
	ceny[0]->SetDivider(d); ceny[1]->SetDivider(d);
	ceny[2]->SetDivider(d); ceny[4]->SetDivider(d);
	//
	but_save->MakeDefault(true);
	updateTab();
	RefreshIndexList();
}
示例#14
0
bool EV_BeOSMenuPopup::synthesizeMenuPopup(XAP_BeOSFrameImpl * pFrame)
{
	BPopUpMenu	*pMenuBar = NULL;
	BMenu 		*pMenu = NULL;
//	BMenuBar 	*pMenuBar = NULL;

	//Future reference, use the UT_Stack stack;
	my_stack_t	*stack = NULL;
	int			accel;

	UT_ASSERT(pFrame);
		
    // Get the list of actions, and a count.
	const EV_Menu_ActionSet * pMenuActionSet = m_pBeOSApp->getMenuActionSet();
	UT_ASSERT(pMenuActionSet);
	
	UT_uint32 nrLabelItemsInLayout = m_pMenuLayout->getLayoutItemCount();
	UT_ASSERT(nrLabelItemsInLayout > 0);

	//Create the top level menubar
	//BRect all = pBWin->m_winRectAvailable;
	//all.bottom = all.top + 18;
	//pBWin->m_winRectAvailable.top = all.bottom + 1;
	pMenuBar = new BPopUpMenu("popup" , false, false);//BMenuBar(all, "Menubar");
	m_pPopup = pMenuBar;
	
	UT_ASSERT(pMenuBar);
	
	// we keep a stack of the widgets so that we can properly
	// parent the menu items and deal with nested pull-rights.
	for (UT_uint32 k=0; (k < nrLabelItemsInLayout); k++)
	{
		EV_Menu_LayoutItem * pLayoutItem = m_pMenuLayout->getLayoutItem(k);
		UT_ASSERT(pLayoutItem);
		
		XAP_Menu_Id id = pLayoutItem->getMenuId();

		const EV_Menu_Action * pAction = pMenuActionSet->getAction(id);
		UT_ASSERT(pAction);


		EV_Menu_Label * pLabel = m_pMenuLabelSet->getLabel(id);
		UT_ASSERT(pLabel);

		// get the name for the menu item
		const char * szLabelName = NULL;
                const char * szMnemonicName = NULL;

		switch (pLayoutItem->getMenuLayoutFlags())
		{
		case EV_MLF_Normal:	{
#if 0
			bool bEnable = true;
                        bool bCheck = false;

                        if (pAction->hasGetStateFunction()) {
                        	EV_Menu_ItemState mis = pAction->getMenuItemState(pView);
                                if (mis & EV_MIS_Gray)
                                	bEnable = false;
                                if (mis & EV_MIS_Toggled)
                                	bCheck = true;
                        }                 
#endif

			const char **data = _ev_GetLabelName(m_pBeOSApp, m_pFrame, pAction, pLabel);
                        //const char ** data = _ev_GetLabelName(m_pBeOSApp, m_pBeOSFrame, pAction, pLabel);
                        szLabelName = data[0];
                        szMnemonicName = data[1];

			BString betterString(szMnemonicName);
			int index,modifiers;
			char key;
			key=0;
			modifiers=0;
			if (szMnemonicName != NULL)
			{
				if ((index=betterString.FindFirst("Ctrl+")) != B_ERROR)
				{
					modifiers=0; // Command is implied.
					if (betterString.FindFirst("F4") != B_ERROR)
					{
						//key=B_F4_KEY;
					}
					else if (betterString.FindFirst("F7") !=B_ERROR)
					{
						//key=B_F7_KEY;
					}
					else if (betterString.FindFirst("Del") != B_ERROR)
					{
						//key=B_DELETE;
					}
					else
					{
						key=betterString[5];
					}
				}
				else if ((index=betterString.FindFirst("Alt+")) != B_ERROR)
				{
					modifiers=B_OPTION_KEY;
					if (betterString.FindFirst("F4") != B_ERROR)
					{
					//	key=B_F4_KEY;
					}
					else if (betterString.FindFirst("F7") !=B_ERROR)
					{
					//	key=B_F7_KEY;
					}
					else if	(betterString.FindFirst("Del") != B_ERROR)
					{
					//	key=B_DELETE;
					}
					else
					{
						key=betterString[4];
					}
				}
				else 
				{
					modifiers=0;
					if (betterString.FindFirst("F4") != B_ERROR)
					{
					//	key=B_F4_KEY;
					}
					else if (betterString.FindFirst("F7") !=B_ERROR)
					{
					//	key=B_F7_KEY;
					}
					else if	(betterString.FindFirst("Del") != B_ERROR)
					{
					//	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;
			
				convert_to_utf8(B_ISO1_CONVERSION , szLabelName , &iLength ,  buffer , &destLength , &state);
				buffer[destLength] = '\0';

				accel = _ev_convert(buf, buffer);

				pMenu = new BMenu(buf);		//Accellerator ignored
				if (!pMenu) 
				{
					delete [] buffer;
					break;
				}
				//printf("----- Before push ---\n");
				//print_stack(stack);
				stack = push(stack, pMenu);
				//printf("----- After push ---\n");
				//print_stack(stack);
				delete [] buffer;
			}
			break;
		}
		case EV_MLF_EndSubMenu:	{
			pMenu = top(stack); 
			if (!pMenu)		//Skip bogus first entry
				break;
			//UT_ASSERT(pMenu);
	
			//printf("----- Before pop ---\n");
			//print_stack(stack);
			stack = pop(stack);
			//printf("----- After pop ---\n");
			//print_stack(stack);
			BMenu *parentMenu = top(stack);
			if (!parentMenu) {
				pMenuBar->AddItem(pMenu);
			}
			else { 
				parentMenu->AddItem(pMenu);
			}
			break;
		}
		case EV_MLF_Separator:	{	
			pMenu = top(stack);
			if (pMenu)
				pMenu->AddSeparatorItem();
			else
				pMenuBar->AddSeparatorItem();
				
			break;
		}

		case EV_MLF_BeginPopupMenu:
			xxx_UT_DEBUGMSG(("MENU: Begin popup menu \n"));
                        break;
                case EV_MLF_EndPopupMenu:
			xxx_UT_DEBUGMSG(("MENU: End popup menu \n"));
                        break;

		default:
			UT_ASSERT(0);
			break;
		}
	}
		
	return true;
}
示例#15
0
// 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),
										   this);

	width = frame.Width();
	height = max_c(fGradientControl->Frame().Height(), 30);

	fGradientControl->ResizeTo(width, height);
	fGradientControl->FrameResized(width, height);
	fGradientControl->MoveTo(frame.left, frame.top);
	fGradientControl->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);

	AddChild(fGradientControl);

	// align label divider
	float divider = fGradientType->StringWidth(fGradientType->Label());
	divider = max_c(divider, fStyleType->StringWidth(fStyleType->Label()));
	fGradientType->SetDivider(divider + 8);
	fStyleType->SetDivider(divider + 8);

#endif // __HAIKU__

	fStyleType->SetEnabled(false);
	fGradientType->SetEnabled(false);
	fGradientControl->SetEnabled(false);
	fGradientControl->Gradient()->AddObserver(this);
}
示例#16
0
status_t
thread_popup(void *arg)
{
	Tpopup_param* param = (Tpopup_param*) arg;
	int32 mcookie, hcookie;
	long m, h;
	BMenuItem* item;
	bool top = param->top;

	system_info systemInfo;
	get_system_info(&systemInfo);
	info_pack* infos = new info_pack[systemInfo.used_teams];
	// TODO: this doesn't necessarily get all teams
	for (m = 0, mcookie = 0; m < systemInfo.used_teams; m++) {
		infos[m].team_icon = NULL;
		infos[m].team_name[0] = 0;
		infos[m].thread_info = NULL;
		if (get_next_team_info(&mcookie, &infos[m].team_info) == B_OK) {
			infos[m].thread_info = new thread_info[infos[m].team_info.thread_count];
			for (h = 0, hcookie = 0; h < infos[m].team_info.thread_count; h++) {
				if (get_next_thread_info(infos[m].team_info.team, &hcookie,
						&infos[m].thread_info[h]) != B_OK)
					infos[m].thread_info[h].thread = -1;
			}
			get_team_name_and_icon(infos[m], true);
		} else {
			systemInfo.used_teams = m;
			infos[m].team_info.team = -1;
		}
	}

	BPopUpMenu* popup = new BPopUpMenu("Global Popup", false, false);
	popup->SetFont(be_plain_font);

	// Quit section
	BMenu* QuitPopup = new QuitMenu(B_TRANSLATE("Quit an application"),
	infos, systemInfo.used_teams);
	QuitPopup->SetFont(be_plain_font);
	popup->AddItem(QuitPopup);

	// Memory Usage section
	MemoryBarMenu* MemoryPopup = new MemoryBarMenu(B_TRANSLATE("Memory usage"),
	infos, systemInfo);
	int commitedMemory = int(systemInfo.used_pages * B_PAGE_SIZE / 1024);
	for (m = 0; m < systemInfo.used_teams; m++) {
		if (infos[m].team_info.team >= 0) {
			MemoryBarMenuItem* memoryItem =
				new MemoryBarMenuItem(infos[m].team_name,
					infos[m].team_info.team, infos[m].team_icon, false, NULL);
			MemoryPopup->AddItem(memoryItem);
			memoryItem->UpdateSituation(commitedMemory);
		}
	}

	addtopbottom(MemoryPopup);

	// CPU Load section
	TeamBarMenu* CPUPopup = new TeamBarMenu(B_TRANSLATE("Threads and CPU "
	"usage"), infos, systemInfo.used_teams);
	for (m = 0; m < systemInfo.used_teams; m++) {
		if (infos[m].team_info.team >= 0) {
			ThreadBarMenu* TeamPopup = new ThreadBarMenu(infos[m].team_name,
				infos[m].team_info.team, infos[m].team_info.thread_count);
			BMessage* kill_team = new BMessage('KlTm');
			kill_team->AddInt32("team", infos[m].team_info.team);
			TeamBarMenuItem* item = new TeamBarMenuItem(TeamPopup, kill_team,
				infos[m].team_info.team, infos[m].team_icon, false);
			item->SetTarget(gPCView);
			CPUPopup->AddItem(item);
		}
	}

	addtopbottom(CPUPopup);
	addtopbottom(new BSeparatorItem());

	// CPU on/off section
	if (gCPUcount > 1) {
		for (int i = 0; i < gCPUcount; i++) {
			char item_name[32];
			sprintf (item_name, B_TRANSLATE("Processor %d"), i + 1);
			BMessage* m = new BMessage ('CPU ');
			m->AddInt32 ("cpu", i);
			item = new IconMenuItem (gPCView->fProcessorIcon, item_name, m);
			if (_kern_cpu_enabled(i))
				item->SetMarked (true);
			item->SetTarget(gPCView);
			addtopbottom(item);
		}
		addtopbottom (new BSeparatorItem ());
	}

	if (!be_roster->IsRunning(kTrackerSig)) {
		item = new IconMenuItem(gPCView->fTrackerIcon,
		B_TRANSLATE("Restart Tracker"), new BMessage('Trac'));
		item->SetTarget(gPCView);
		addtopbottom(item);
	}
	if (!be_roster->IsRunning(kDeskbarSig)) {
		item = new IconMenuItem(gPCView->fDeskbarIcon,
		B_TRANSLATE("Restart Deskbar"), new BMessage('Dbar'));
		item->SetTarget(gPCView);
		addtopbottom(item);
	}

	item = new IconMenuItem(gPCView->fTerminalIcon,
	B_TRANSLATE("New Terminal"), new BMessage('Term'));
	item->SetTarget(gPCView);
	addtopbottom(item);

	addtopbottom(new BSeparatorItem());

	bool showLiveInDeskbarItem = gInDeskbar;
	if (!showLiveInDeskbarItem) {
		int32 cookie = 0;
		image_info info;
		while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
			if (info.type == B_APP_IMAGE) {
				// only show the Live in Deskbar item if a) we're running in
				// deskbar itself, or b) we're running in PC's team.
				if (strstr(info.name, "ProcessController") != NULL) {
					showLiveInDeskbarItem = true;
					break;
				}
			}
		}
	}

	if (showLiveInDeskbarItem && be_roster->IsRunning(kDeskbarSig)) {
		item = new BMenuItem(B_TRANSLATE("Live in the Deskbar"),
			new BMessage('AlDb'));
		BDeskbar deskbar;
		item->SetMarked(gInDeskbar || deskbar.HasItem(kDeskbarItemName));
		item->SetTarget(gPCView);
		addtopbottom(item);
		addtopbottom(new BSeparatorItem ());
	}


	item = new IconMenuItem(gPCView->fProcessControllerIcon,
	B_TRANSLATE("About ProcessController"B_UTF8_ELLIPSIS),
		new BMessage(B_ABOUT_REQUESTED));
	item->SetTarget(gPCView);
	addtopbottom(item);

	param->where.x -= 5;
	param->where.y -= 8;
	popup->Go(param->where, true, true, param->clickToOpenRect);

	delete popup;
	for (m = 0; m < systemInfo.used_teams; m++) {
		if (infos[m].team_info.team >= 0) {
			delete[] infos[m].thread_info;
			delete infos[m].team_icon;
		}
	}
	delete[] infos;
	delete param;
	atomic_add (&gPopupFlag, -1);
	gPopupThreadID = 0;

	return B_OK;
}
示例#17
0
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);
	}
}
示例#18
0
status_t
TerminalThemesAddon::ApplyThemeHaiku(BMessage &theme, uint32 flags)
{
	BMessage termpref;
	BMessage lines;
	status_t err;
	struct termprefs tp;
	int32 ival;
	rgb_color color;
	BString s;

	err = MyMessage(theme, termpref);
	if (err)
		return err;

	if (termpref.FindInt32(TP_COLS, &ival) < B_OK)
		ival = 80;
	s = "";
	s << ival;
	lines.AddString(PREF_COLS, s.String());

	if (termpref.FindInt32(TP_ROWS, &ival) < B_OK)
		ival = 25;
	s = "";
	s << ival;
	lines.AddString(PREF_ROWS, s.String());

	if (termpref.FindInt32(TP_TABWIDTH, &ival) >= B_OK) {
		//XXX: handle that ?
	}

	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);
		s = "";
		s << ff;
		lines.AddString(PREF_HALF_FONT_FAMILY, s.String());
		s = "";
		s << fs;
		lines.AddString(PREF_HALF_FONT_STYLE, s.String());
		s = "";
		s << tFont.Size();
		lines.AddString(PREF_HALF_FONT_SIZE, s.String());
	}
	
	if (FindRGBColor(termpref, TP_BG, 0, &color) != B_OK)
		color = make_color(255,255,255,255);
	s = "";
	s << color.red << ", " << color.green << ", " << color.blue;
	lines.AddString(PREF_TEXT_BACK_COLOR, s.String());
	
	if (FindRGBColor(termpref, TP_FG, 0, &color) != B_OK)
		color = make_color(0,0,0,255);
	s = "";
	s << color.red << ", " << color.green << ", " << color.blue;
	lines.AddString(PREF_TEXT_FORE_COLOR, s.String());

	if (FindRGBColor(termpref, TP_CURBG, 0, &color) != B_OK)
		color = make_color(255,255,255,255);
	s = "";
	s << color.red << ", " << color.green << ", " << color.blue;
	lines.AddString(PREF_CURSOR_BACK_COLOR, s.String());

	if (FindRGBColor(termpref, TP_CURFG, 0, &color) != B_OK)
		color = make_color(0,0,0,255);
	s = "";
	s << color.red << ", " << color.green << ", " << color.blue;
	lines.AddString(PREF_CURSOR_FORE_COLOR, s.String());

	if (FindRGBColor(termpref, TP_SELBG, 0, &color) != B_OK)
		color = make_color(0,0,0,255);
	s = "";
	s << color.red << ", " << color.green << ", " << color.blue;
	lines.AddString(PREF_SELECT_BACK_COLOR, s.String());

	if (FindRGBColor(termpref, TP_SELFG, 0, &color) != B_OK)
		color = make_color(255,255,255,255);
	s = "";
	s << color.red << ", " << color.green << ", " << color.blue;
	lines.AddString(PREF_SELECT_FORE_COLOR, s.String());
	
	/* XXX: handle PREF_IM_FORE_COLOR PREF_IM_BACK_COLOR PREF_IM_SELECT_COLOR */

	
	if (termpref.FindInt32(TP_ENCODING, &ival) != B_OK)
		ival = 0; // UTF-8
	s = "";
	s << ival;
	//XXX: shouldn't really be touched...
	//lines.AddString(, s.String());
	
	if (flags & UI_THEME_SETTINGS_SAVE && AddonFlags() & Z_THEME_ADDON_DO_SAVE) {
		SaveHaikuTerminalSettings(lines);
	}

	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, kHaikuTerminalAppSig)) {
					err = B_OK;
					//XXX: WRITEME
/*					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;
}
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;
}
示例#20
0
文件: AIM.cpp 项目: louisdem/IMKit
status_t AIMProtocol::Process(BMessage * msg) {
	switch (msg->what) {
		case IM::MESSAGE: {
			int32 im_what=0;
			
			msg->FindInt32("im_what",&im_what);
		
			switch (im_what) {
				case IM::SERVER_LIST_ADD_CONTACT: {
					entry_ref ref;
					if (msg->FindRef("contact", &ref) != B_OK) return B_ERROR;
										
					IM::Contact contact(&ref);
					grouplist_t groups;
					int32 groupCount = contact.CountGroups();
					
					for (int32 i = 0; i < groupCount; i++) {
						groups.push_back(contact.GroupAt(i));
					};
					
					return fManager->AddSSIBuddy(msg->FindString("id"), groups);
				} break;
			
				case IM::UNREGISTER_CONTACTS: {
					fManager->RemoveBuddy(msg->FindString("id"));
				} break;
				case IM::REGISTER_CONTACTS:
				{
					if ( !fManager->IsConnected() )
						break;
					
					type_code garbage;
					int32 count = 0;
					msg->GetInfo("id", &garbage, &count);
					
					if (count > 0) {
						list<char *> buddies;
						for ( int i=0; msg->FindString("id",i); i++ )
						{
							const char * id = msg->FindString("id",i);
							buddies.push_back(strdup(id));
						};
						fManager->AddBuddies(buddies);
					} else {
						fManager->AddBuddy(msg->FindString("id"));
					};
				}	break;
				
				case IM::SET_STATUS: {
					const char *status = NULL;
					if (msg->FindString("status", &status) != B_OK) {
						LOG(fManager->Protocol(), liHigh, "Status set to NULL!");
						return B_ERROR;
					};

					LOG(fManager->Protocol(), liMedium, "Set status to %s", status);
					
					if (strcmp(status, OFFLINE_TEXT) == 0) {
						fManager->LogOff();
					} else
					if (strcmp(status, AWAY_TEXT) == 0) {
						if (fManager->ConnectionState() == (uchar)OSCAR_ONLINE) {
							const char *away_msg;
							if (msg->FindString("away_msg", &away_msg) == B_OK) {
								LOG(fManager->Protocol(), liMedium, "Setting away message: %s", away_msg);
								fManager->SetAway(away_msg);
							};
						};
					} else
					if (strcmp(status, ONLINE_TEXT) == 0) {
						if (fManager->IsConnected() == OSCAR_AWAY) {
							fManager->SetAway(NULL);
						} else {
							LOG(fManager->Protocol(), liDebug, "Calling fManager.Login()");
							fManager->Login("login.oscar.aol.com", (uint16)5190,
								fScreenName, fPassword);
						};
					} else
					{
						LOG(fManager->Protocol(), liHigh, "Invalid status when setting status: '%s'", status);
					}
				} break;

				case IM::GET_CONTACT_INFO:
				{
					LOG(fManager->Protocol(), liLow, "Getting contact info", msg);
					const char * id = NormalizeNick(msg->FindString("id")).String();
					
					BMessage *infoMsg = new BMessage(IM::MESSAGE);
					Buddy *buddy = fManager->GetBuddy(id);
					
					infoMsg->AddInt32("im_what", IM::CONTACT_INFO);
					infoMsg->AddString("protocol", fManager->Protocol());
					infoMsg->AddString("id", id);
					infoMsg->AddString("nick", id);
					infoMsg->AddString("first name", id);
					if (buddy) infoMsg->AddBool("mobileuser", buddy->IsMobileUser());

					msg->SendReply(infoMsg);
//					fMsgr.SendMessage(infoMsg);
				}	break;
		
				case IM::SEND_MESSAGE:
				{
					const char * message_text = msg->FindString("message");
					BString srcid = msg->FindString("id");
					BString normal = NormalizeNick(srcid.String());
					BString screen = GetScreenNick(normal.String());
					
					const char * id = screen.String();
					
					LOG(fManager->Protocol(), liDebug, "SEND_MESSAGE (%s, %s)", msg->FindString("id"), msg->FindString("message"));
					LOG(fManager->Protocol(), liDebug, "  %s > %s > %s", srcid.String(), normal.String(), screen.String() );
					
					if ( !id )
						return B_ERROR;
					
					if ( !message_text )
						return B_ERROR;
					
					fManager->MessageUser(id, message_text);
					
					BMessage newMsg(*msg);
					
					newMsg.RemoveName("contact");
					newMsg.ReplaceInt32("im_what", IM::MESSAGE_SENT);
					
					fMsgr.SendMessage(&newMsg);
					
				}	break;
				case IM::USER_STARTED_TYPING: {
					const char *id = msg->FindString("id");
					if (!id) return B_ERROR;
				
					fManager->TypingNotification(id, STARTED_TYPING);
				} break;
				case IM::USER_STOPPED_TYPING: {
					const char *id = msg->FindString("id");
					if (!id) return B_ERROR;
					
					fManager->TypingNotification(id, FINISHED_TYPING);
				} break;
				
				case IM::GET_AWAY_MESSAGE: {
					const char *id = msg->FindString("id");
					if (!id) return B_ERROR;
					
				};
				
				default:
					break;
			}
			
		}	break;
		default:
			break;
	}
	
	return B_OK;
}
示例#21
0
void DeskbarView::MessageReceived(BMessage *message) {
//	message->PrintToStream();
	switch (message->what)
	{
		case 'LIVE':
			{
				ticks++;				
				Invalidate();
				team_info teamInfo;
				status_t error = get_team_info(team, &teamInfo);
				if (error != B_OK && id>0) {
					BDeskbar deskbar;
					deskbar.RemoveItem(id);
				} else {
					BMessage *mes=new BMessage(*message);
					mes->AddRect("rect",ConvertToScreen(Bounds()));
					ReplyMessenger.SendMessage(mes);
				}
				break;
			}
		case B_SET_PROPERTY:
			{
				switch( message->FindInt32("what2") ) {
					case 'TTIP':
						{							
							const char *tip=NULL;
							status_t res = message->FindString("tooltip",&tip);
							
							if(!tip || res!=B_OK)
								tip = applicationName.String();
							if(strlen(tip)==0)
								tip = applicationName.String();													
							if(strlen(tip)!=0)		
								SetToolTip(tip);
								
							break;
						}					
					case 'BITS':
						{
							BBitmap *oldicon=icon;
							icon=NULL;
							delete oldicon;
							BMessage bits;
							message->FindMessage("icon", &bits);
							icon = new BBitmap(&bits);
							bits.MakeEmpty();
							Invalidate();
							break;
						}
					case '_ID_':
						{
							message->FindInt32("ReplicantID",&id);
							break;
						}
					case 'MSGR':
						{
							ssize_t numBytes;
							const char *name=NULL;
							message->FindMessenger("messenger", &ReplyMessenger);
							message->FindData("qtrayobject",B_ANY_TYPE,&traysysobject,&numBytes);
							if(message->FindString("application_name",&name)==B_OK)
								applicationName.SetTo(name);
							break;
						}
				}
			}
			break;		
		default:
			BView::MessageReceived(message);
			break;
	}
}