void
MediaConverterWindow::BuildFormatMenu()
{
	BMenu* menu = fFormatMenu->Menu();
	BMenuItem* item;

	// clear out old format menu items
	while ((item = menu->RemoveItem((int32)0)) != NULL)
		delete item;

	// add menu items for each file format
	media_file_format mfi;
	int32 cookie = 0;
	FileFormatMenuItem* ff_item;
	while (get_next_file_format(&cookie, &mfi) == B_OK) {
		if ((mfi.capabilities & media_file_format::B_WRITABLE) == 0)
			continue;
		ff_item = new FileFormatMenuItem(&mfi);
		menu->AddItem(ff_item);
	}

	// mark first item
	item = menu->ItemAt(0);
	if (item != NULL) {
		item->SetMarked(true);
		((BInvoker*)item)->Invoke();
	}
}
Example #2
0
void CFtpDialog::UpdateDirectoryPopup()
{
	BMenu* menu = fDirectoryField->Menu();
	BMenuItem *item;

	while ((item = menu->ItemAt(menu->CountItems() - 1)) != NULL)
	{
		menu->RemoveItem(item);
		delete item;
	}

	char p[PATH_MAX], *l;
	strcpy(p, fPath);

	l = strtok(p, "/");

	menu->AddItem(new BMenuItem("/", new BMessage(msg_SelectedDirectory)));

	while (l)
	{
		menu->AddItem(new BMenuItem(l, new BMessage(msg_SelectedDirectory)));
		l = strtok(NULL, "/");
	}

	menu->ItemAt(menu->CountItems() - 1)->SetMarked(true);
} // CFtpDialog::UpdateDirectoryPopup
Example #3
0
void ChatWindow::BuildProtocolMenu(void) {
	BMessage getStatus(IM::GET_CONTACT_STATUS);
	getStatus.AddRef("contact", &fEntry);
	BMessage statusMsg;

	BMenu *menu = fProtocolMenu->Menu();
	if (menu == NULL) {
		LOG("im_emoclient", liHigh, "BuildProtocolMenu(): fProtocolMenu is NULL.");
		return;
	}

//	You have to do this twice... buggered if I know why...
	for (int32 i = 0; i < menu->CountItems(); i++) delete menu->RemoveItem(0L);
	for (int32 i = 0; i < menu->CountItems(); i++) delete menu->RemoveItem(0L);

	menu->AddItem(new IconMenuItem(NULL, _T("Any Protocol"), NULL,
		new BMessage(PROTOCOL_SELECTED)));
	
	if (fMan->SendMessage(&getStatus, &statusMsg) != B_OK) {
		LOG("im_emoclient", liHigh, "Failed to get contact statues");
		return;
	};
	
	BPath iconDir;
	find_directory(B_USER_ADDONS_DIRECTORY, &iconDir, true);
	iconDir.Append("im_kit/protocols");
			
	menu->AddSeparatorItem();
	
	for (int32 i = 0; statusMsg.FindString("connection", i); i++) {
		BString status = statusMsg.FindString("status", i);
		IM::Connection connection( statusMsg.FindString("connection", i) );

		BString iconPath = iconDir.Path();
		iconPath << "/" << connection.Protocol();
			
		BBitmap *icon = ReadNodeIcon(iconPath.String(), kSmallIcon, true);
		BString label = connection.String();
		label << " (" << _T(status.String()) << ")";
			
		menu->AddItem(
			new IconMenuItem(
				icon, 
				label.String(), 
				connection.String(), 
				new BMessage(PROTOCOL_SELECTED)
			)
		);
	};
	
	// TODO: Is this call needed or not?
	//menu->SetFont(be_plain_font);
	
	fStatusBar->PositionViews();

	fInfoView->ResizeTo(fStatusBar->Bounds().Width() - fInfoView->Frame().left,
		fInfoView->Bounds().Height());
};
Example #4
0
/*! \brief Removes the option at the given index.
	\param index The index of the option to remove.
*/
void
BOptionPopUp::RemoveOptionAt(int32 index)
{
	BMenu *menu = fMenuField->Menu();
	if (menu != NULL) {
		BMenuItem *item = menu->ItemAt(index);
		if (item != NULL) {
			menu->RemoveItem(item);
			delete item;
		}
	}		
}
Example #5
0
void
PPPoEView::ReloadInterfaces()
{
	// delete all items and request a new bunch from the pppoe kernel module
	BMenu *menu = fInterface->Menu();
	while(menu->CountItems() > 2)
		delete menu->RemoveItem((int32) 0);
	fOtherInterface->SetLabel(kLabelOtherInterface);
	
	PPPManager manager;
	char *interfaces = new char[8192];
		// reserve enough space for approximately 512 entries
	int32 count = manager.ControlModule("pppoe", PPPoE_GET_INTERFACES, interfaces,
		8192);
	
	BMenuItem *item;
	char *name = interfaces;
	int32 insertAt;
	for(int32 index = 0; index < count; index++) {
		item = new BMenuItem(name, new BMessage(kMsgSelectInterface));
		insertAt = FindNextMenuInsertionIndex(menu, name);
		if(insertAt > menu->CountItems() - 2)
			insertAt = menu->CountItems() - 2;
		
		item->SetTarget(this);
		menu->AddItem(item, insertAt);
		name += strlen(name) + 1;
	}
	
	// set interface or some default value if nothing was found
	if(Addon()->InterfaceName() && strlen(Addon()->InterfaceName()) > 0)
		fInterfaceName = Addon()->InterfaceName();
	else if(count > 0)
		fInterfaceName = interfaces;
	else
		fInterfaceName = "";
	
	delete interfaces;
	
	item = menu->FindItem(fInterfaceName.String());
	if(item && menu->IndexOf(item) <= menu->CountItems() - 2)
		item->SetMarked(true);
	else if(Addon()->InterfaceName()) {
		BString label(kLabelOtherInterface);
		label << " " << fInterfaceName;
		fOtherInterface->SetLabel(label.String());
		fOtherInterface->SetMarked(true);
	}
}
Example #6
0
void BWebPage::handleMouseEvent(const BMessage* message)
{
    WebCore::Frame* frame = fMainFrame->Frame();
    if (!frame->view() || !frame->document())
        return;

    PlatformMouseEvent event(message);
    switch (message->what) {
    case B_MOUSE_DOWN:
        // Handle context menus, if necessary.
        if (event.button() == RightButton) {
            fPage->contextMenuController()->clearContextMenu();

            WebCore::Frame* focusedFrame = fPage->focusController()->focusedOrMainFrame();
            focusedFrame->eventHandler()->sendContextMenuEvent(event);
            // If the web page implements it's own context menu handling, then
            // the contextMenu() pointer will be zero. In this case, we should
            // also swallow the event.
            ContextMenu* contextMenu = fPage->contextMenuController()->contextMenu();
            if (contextMenu) {
            	BMenu* platformMenu = contextMenu->releasePlatformDescription();
            	if (platformMenu) {
            		// Need to convert the BMenu into BPopUpMenu.
	            	BPopUpMenu* popupMenu = new BPopUpMenu("context menu");
					for (int32 i = platformMenu->CountItems() - 1; i >= 0; i--) {
					    BMenuItem* item = platformMenu->RemoveItem(i);
					    popupMenu->AddItem(item, 0);
					}
					BPoint screenLocation(event.globalPosition().x() + 2,
					    event.globalPosition().y() + 2);
            	    popupMenu->Go(screenLocation, true, true, true);
            	    delete platformMenu;
            	}
            }
            break;
    	}
    	// Handle regular mouse events.
        frame->eventHandler()->handleMousePressEvent(event);
        break;
    case B_MOUSE_UP:
        frame->eventHandler()->handleMouseReleaseEvent(event);
        break;
    case B_MOUSE_MOVED:
    default:
        frame->eventHandler()->mouseMoved(event);
        break;
    }
}
// Read data
void AppWindow::OnOpen(BMessage *msg) {
entry_ref ref;
BMessage archive;
	msg->FindRef("refs", &ref);
	BFile file(&ref, B_READ_ONLY);
	archive.Unflatten(&file);
	Graph *g = (Graph*)Graph::Instantiate(&archive);
	if (g != NULL) {
		delete view->graph; view->graph = g;
		BMenu *menu = data->functions->Menu();
		while (menu->RemoveItem((int32)0) != NULL);
		Function1 *f;
		int i;

		if (program->Lock()) {
			program->view->SetText(g->GetDefinitions()->GetText());
			program->Unlock();
		}
		
		MarkColorMenuItem(bg_color, view->graph->bg_color);
		MarkColorMenuItem(axes_color, view->graph->axes_color);
		
		ExprList *el = g->GetGraphExprs();
		for (i = 0; i < 6; i++) 
			data->gCtrls[i]->SetText(el->GetText(i));
		
		for (i = 0; i < 5; i++)
			data->fCtrls[i]->SetText("");

		UpdateGraph();
		for (i = 0; NULL != (f = g->GetFunction(i)); i++) {
			CompileFunction(f, false);
		}
		
		for (i = 0; NULL != (f = g->GetFunction(i)); i++)
			AddFunction(f);
		OnSelect();
		
		OnUpdate();	
	} else {
		BAlert *a = new BAlert("Open Error", "Could not read file.", "OK");
		a->Go();
	}
}
Example #8
0
void
TFilePanel::Init(const BMessage*)
{
	BRect windRect(Bounds());
	AddChild(fBackView = new BackgroundView(windRect));

	// add poseview menu bar
	fMenuBar = new BMenuBar(BRect(0, 0, windRect.Width(), 1), "MenuBar");
	fMenuBar->SetBorder(B_BORDER_FRAME);
	fBackView->AddChild(fMenuBar);

	AddMenus();
	AddContextMenus();

	FavoritesMenu* favorites = new FavoritesMenu(B_TRANSLATE("Favorites"),
		new BMessage(kSwitchDirectory), new BMessage(B_REFS_RECEIVED),
		BMessenger(this), IsSavePanel(), fPoseView->RefFilter());
	favorites->AddItem(new BMenuItem(B_TRANSLATE("Add current folder"),
		new BMessage(kAddCurrentDir)));
	favorites->AddItem(new BMenuItem(
		B_TRANSLATE("Edit favorites" B_UTF8_ELLIPSIS),
		new BMessage(kEditFavorites)));

	fMenuBar->AddItem(favorites);

	// configure menus
	BMenuItem* item = fMenuBar->FindItem(B_TRANSLATE("Window"));
	if (item) {
		fMenuBar->RemoveItem(item);
		delete item;
	}

	item = fMenuBar->FindItem(B_TRANSLATE("File"));
	if (item) {
		BMenu* menu = item->Submenu();
		if (menu) {
			item = menu->FindItem(kOpenSelection);
			if (item && menu->RemoveItem(item))
				delete item;

			item = menu->FindItem(kDuplicateSelection);
			if (item && menu->RemoveItem(item))
				delete item;

			// remove add-ons menu, identifier menu, separator
			item = menu->FindItem(B_TRANSLATE("Add-ons"));
			if (item) {
				int32 index = menu->IndexOf(item);
				delete menu->RemoveItem(index);
				delete menu->RemoveItem(--index);
				delete menu->RemoveItem(--index);
			}

			// remove separator
			item = menu->FindItem(B_CUT);
			if (item) {
				item = menu->ItemAt(menu->IndexOf(item)-1);
				if (item && menu->RemoveItem(item))
					delete item;
			}
		}
	}

	// add directory menu and menufield
	fDirMenu = new BDirMenu(0, this, kSwitchDirectory, "refs");

	font_height ht;
	be_plain_font->GetHeight(&ht);
	float f_height = ht.ascent + ht.descent + ht.leading;

	BRect rect;
	rect.top = fMenuBar->Bounds().Height() + 8;
	rect.left = windRect.left + 8;
	rect.right = rect.left + 300;
	rect.bottom = rect.top + (f_height > 22 ? f_height : 22);

	fDirMenuField = new BMenuField(rect, "DirMenuField", "", fDirMenu);
	fDirMenuField->MenuBar()->SetFont(be_plain_font);
	fDirMenuField->SetDivider(0);
	fDirMenuField->MenuBar()->SetMaxContentWidth(rect.Width() - 26.0f);
		// Make room for the icon

	fDirMenuField->MenuBar()->RemoveItem((int32)0);
	fDirMenu->SetMenuBar(fDirMenuField->MenuBar());
		// the above is a weird call from BDirMenu
		// ToDo: clean up

	BEntry entry(TargetModel()->EntryRef());
	if (entry.InitCheck() == B_OK)
		fDirMenu->Populate(&entry, 0, true, true, false, true);
	else
		fDirMenu->Populate(0, 0, true, true, false, true);

	fBackView->AddChild(fDirMenuField);

	// add file name text view
	if (fIsSavePanel) {
		BRect rect(windRect);
		rect.top = rect.bottom - 35;
		rect.left = 8;
		rect.right = rect.left + 170;
		rect.bottom = rect.top + 13;

		fTextControl = new BTextControl(rect, "text view",
			B_TRANSLATE("save text"), "", NULL,
			B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
		DisallowMetaKeys(fTextControl->TextView());
		DisallowFilenameKeys(fTextControl->TextView());
		fBackView->AddChild(fTextControl);
		fTextControl->SetDivider(0.0f);
		fTextControl->TextView()->SetMaxBytes(B_FILE_NAME_LENGTH - 1);

		fButtonText.SetTo(B_TRANSLATE("Save"));
	} else
		fButtonText.SetTo(B_TRANSLATE("Open"));

	rect = windRect;
	rect.OffsetTo(10, fDirMenuField->Frame().bottom + 10);
	rect.bottom = windRect.bottom - 60;
	rect.right -= B_V_SCROLL_BAR_WIDTH + 20;

	// re-parent the poseview to our backview
	// ToDo:
	// This is terrible, fix it up
	PoseView()->RemoveSelf();
	if (fIsSavePanel)
		fBackView->AddChild(PoseView(), fTextControl);
	else
		fBackView->AddChild(PoseView());

	PoseView()->MoveTo(rect.LeftTop());
	PoseView()->ResizeTo(rect.Width(), rect.Height());
	PoseView()->AddScrollBars();
	PoseView()->SetDragEnabled(false);
	PoseView()->SetDropEnabled(false);
	PoseView()->SetSelectionHandler(this);
	PoseView()->SetSelectionChangedHook(true);
	PoseView()->DisableSaveLocation();
	PoseView()->VScrollBar()->MoveBy(0, -1);
	PoseView()->VScrollBar()->ResizeBy(0, 1);


	AddShortcut('W', B_COMMAND_KEY, new BMessage(kCancelButton));
	AddShortcut('H', B_COMMAND_KEY, new BMessage(kSwitchToHome));
	AddShortcut('A', B_COMMAND_KEY | B_SHIFT_KEY,
		new BMessage(kShowSelectionWindow));
	AddShortcut('A', B_COMMAND_KEY, new BMessage(B_SELECT_ALL), PoseView());
	AddShortcut('S', B_COMMAND_KEY, new BMessage(kInvertSelection),
		PoseView());
	AddShortcut('Y', B_COMMAND_KEY, new BMessage(kResizeToFit), PoseView());
	AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY, new BMessage(kOpenDir));
	AddShortcut(B_DOWN_ARROW, B_COMMAND_KEY | B_OPTION_KEY,
		new BMessage(kOpenDir));
	AddShortcut(B_UP_ARROW, B_COMMAND_KEY, new BMessage(kOpenParentDir));
	AddShortcut(B_UP_ARROW, B_COMMAND_KEY | B_OPTION_KEY,
		new BMessage(kOpenParentDir));

	// New code to make buttons font sensitive
	rect = windRect;
	rect.top = rect.bottom - 35;
	rect.bottom -= 10;
	rect.right -= 25;
	float default_width
		= be_plain_font->StringWidth(fButtonText.String()) + 20;
	rect.left = default_width > 75
		? rect.right - default_width : rect.right - 75;

	BButton* default_button = new BButton(rect, "default button",
		fButtonText.String(), new BMessage(kDefaultButton),
		B_FOLLOW_RIGHT + B_FOLLOW_BOTTOM);
	fBackView->AddChild(default_button);

	rect.right = rect.left -= 10;
	float cancel_width
		= be_plain_font->StringWidth(B_TRANSLATE("Cancel")) + 20;
	rect.left = cancel_width > 75
		? rect.right - cancel_width : rect.right - 75;

	BButton* cancel_button = new BButton(rect, "cancel button",
		B_TRANSLATE("Cancel"), new BMessage(kCancelButton),
		B_FOLLOW_RIGHT + B_FOLLOW_BOTTOM);
	fBackView->AddChild(cancel_button);

	if (!fIsSavePanel)
		default_button->SetEnabled(false);

	default_button->MakeDefault(true);

	RestoreState();

	PoseView()->ScrollTo(B_ORIGIN);
	PoseView()->UpdateScrollRange();
	PoseView()->ScrollTo(B_ORIGIN);

	if (fTextControl) {
		fTextControl->MakeFocus();
		fTextControl->TextView()->SelectAll();
	} else
		PoseView()->MakeFocus();

	app_info info;
	BString title;
	if (be_app->GetAppInfo(&info) == B_OK) {
		if (!gLocalizedNamePreferred
			|| BLocaleRoster::Default()->GetLocalizedFileName(
				title, info.ref, false) != B_OK)
			title = info.ref.name;
		title << ": ";
	}
	title << fButtonText;	// Open or Save

	SetTitle(title.String());

	SetSizeLimits(370, 10000, 200, 10000);
}
void
MediaConverterWindow::BuildAudioVideoMenus()
{
	BMenu* menu = fAudioMenu->Menu();
	BMenuItem* item;

	// clear out old audio codec menu items
	while ((item = menu->RemoveItem((int32)0)) != NULL)
		delete item;

	bool separator = true;

	// get selected file format
	FileFormatMenuItem* ffmi
		= (FileFormatMenuItem*)fFormatMenu->Menu()->FindMarked();
	media_file_format* mf_format = &(ffmi->fFileFormat);

	media_format format, outfmt;
	memset(&format, 0, sizeof(format));
	media_codec_info codec_info;
	int32 cookie = 0;
	CodecMenuItem* cmi;

	// add available audio encoders to menu
	format.type = B_MEDIA_RAW_AUDIO;
	format.u.raw_audio = media_raw_audio_format::wildcard;
	while (get_next_encoder(&cookie, mf_format, &format, &outfmt, &codec_info)
			== B_OK) {
		if (separator) {
			menu->AddItem(new BMenuItem(
				B_TRANSLATE_CONTEXT("No audio", "Audio codecs list"),
				new BMessage(AUDIO_CODEC_SELECT_MESSAGE)));
			menu->AddSeparatorItem();
			separator = false;
		}

		cmi = new CodecMenuItem(&codec_info, AUDIO_CODEC_SELECT_MESSAGE);
		menu->AddItem(cmi);
		// reset media format struct
/*
		format.type = B_MEDIA_RAW_AUDIO;
		format.u.raw_audio = media_raw_audio_format::wildcard;
*/
	}

	// mark first audio encoder
	item = menu->ItemAt(0);
	if (item != NULL) {
		fAudioMenu->SetEnabled(fEnabled);
		fAudioQualitySlider->SetEnabled(fEnabled);
		item->SetMarked(true);
		((BInvoker*)item)->Invoke();
	} else {
		item = new BMenuItem(
			B_TRANSLATE_CONTEXT("None available", "Audio codecs"), NULL);
		menu->AddItem(item);
		item->SetMarked(true);
		fAudioMenu->SetEnabled(false);
		fAudioQualitySlider->SetEnabled(false);
	}

	// clear out old video codec menu items
	menu = fVideoMenu->Menu();
	while ((item = menu->RemoveItem((int32)0)) != NULL)
		delete item;

	separator = true;

	// construct a generic video format.  Some of these parameters
	// seem silly, but are needed for R4.5.x, which is more picky
	// than subsequent BeOS releases will be.
	memset(&format, 0, sizeof(format));
	format.type = B_MEDIA_RAW_VIDEO;
	format.u.raw_video.last_active = (uint32)(240 - 1);
	format.u.raw_video.orientation = B_VIDEO_TOP_LEFT_RIGHT;
	format.u.raw_video.display.format = B_RGB32;
	format.u.raw_video.display.line_width = (int32)320;
	format.u.raw_video.display.line_count = (int32)240;
	format.u.raw_video.display.bytes_per_row = 4 * 320;

	// add available video encoders to menu
	cookie = 0;
	while (get_next_encoder(&cookie, mf_format, &format, &outfmt, &codec_info)
			== B_OK) {
		if (separator) {
			menu->AddItem(new BMenuItem(
				B_TRANSLATE_CONTEXT("No video", "Video codecs list"),
				new BMessage(VIDEO_CODEC_SELECT_MESSAGE)));
			menu->AddSeparatorItem();
			separator = false;
		}

		cmi = new CodecMenuItem(&codec_info, VIDEO_CODEC_SELECT_MESSAGE);
		menu->AddItem(cmi);
	}

	// mark first video encoder
	item = menu->ItemAt(0);
	if (item != NULL) {
		fVideoMenu->SetEnabled(fEnabled);
		fVideoQualitySlider->SetEnabled(fEnabled);
		item->SetMarked(true);
		((BInvoker*)item)->Invoke();
	} else {
		item = new BMenuItem(
			B_TRANSLATE_CONTEXT("None available", "Video codecs"), NULL);
		menu->AddItem(item);
		item->SetMarked(true);
		fVideoMenu->SetEnabled(false);
		fVideoQualitySlider->SetEnabled(false);
	}
}
Example #10
0
void
NetworkPrefsView::MessageReceived (BMessage * msg)
{
	switch (msg->what)
	{
		case M_NETWORK_DEFAULTS:
			if (fActiveNetwork.HasString ("name"))
				vision_app->SetNetwork (fActiveNetwork.FindString ("name"), &fActiveNetwork);
			fActiveNetwork = vision_app->GetNetwork ("defaults");
			fNetworkMenu->MenuItem ()->SetLabel ("Defaults");
			SetupDefaults (fActiveNetwork);
			fDupeItem->SetEnabled (false);
			fRemoveItem->SetEnabled (false);
			break;

		case M_CHOOSE_NETWORK:
			{
				BMenuItem *item (NULL);
				msg->FindPointer ("source", reinterpret_cast < void **>(&item));
				SaveCurrentNetwork ();
				fActiveNetwork = vision_app->GetNetwork (item->Label ());
				fNetworkMenu->MenuItem ()->SetLabel (item->Label ());
				UpdatePersonalData (fActiveNetwork);
				UpdateNetworkData (fActiveNetwork);
				if (BMessenger (fServerPrefs).IsValid ())
					fServerPrefs->SetNetworkData (&fActiveNetwork);
				fDupeItem->SetEnabled (true);
				fRemoveItem->SetEnabled (true);
			}
			break;

		case M_ADD_NEW_NETWORK:
			{
				if (msg->HasString ("text"))
				{
					fNetPrompt = NULL;
					BString network (msg->FindString ("text"));
					network.RemoveAll (" ");
					BMenu *menu (fNetworkMenu->Menu ());
					for (int32 i = 0; i < menu->CountItems (); i++)
				{
						BMenuItem *item (menu->ItemAt (i));
						if (item && network == item->Label ())
						{
							dynamic_cast < BInvoker * >(item)->Invoke ();
							return;
						}
					}
					BMessage newNet (VIS_NETWORK_DATA);
					newNet.AddString ("name", network.String ());
					vision_app->SetNetwork (network.String (), &newNet);
					BMenuItem *item (new BMenuItem (network.String (), new BMessage (M_CHOOSE_NETWORK)));
					menu->AddItem (item, 0);
					item->SetTarget (this);
					dynamic_cast < BInvoker * >(item)->Invoke ();
			}
				else
				{
					BString promptText = B_TRANSLATE("Network Name");
					promptText += ": ";
					fNetPrompt = new PromptWindow (BPoint (Window ()->Frame ().left + Window ()->Frame ().Width () / 2, Window ()->Frame ().top + Window ()->Frame ().Height () / 2),
						promptText.String(), B_TRANSLATE("Add Network"), NULL, this, new BMessage (M_ADD_NEW_NETWORK), NULL, false);
					fNetPrompt->Show ();
				}
			}
			break;

		case M_REMOVE_CURRENT_NETWORK:
			{
				const char *name (fActiveNetwork.FindString ("name"));
				vision_app->RemoveNetwork (name);
				BMenu *menu (fNetworkMenu->Menu ());
				for (int32 i = 0; i < menu->CountItems (); i++)
				{
					BMenuItem *item (menu->ItemAt (i));
					if (!strcmp (item->Label (), name))
					{
						delete menu->RemoveItem (i);
						fActiveNetwork.MakeEmpty ();
						dynamic_cast < BInvoker * >(menu->ItemAt (0))->Invoke ();
						break;
					}
				}
			}
			break;

		case M_DUPE_CURRENT_NETWORK:
			{
				if (msg->HasString ("text"))
				{
					fDupePrompt = NULL;
					BString network (msg->FindString ("text"));
					network.RemoveAll (" ");
					BMenu *menu (fNetworkMenu->Menu ());
					for (int32 i = 0; i < menu->CountItems (); i++)
					{
						BMenuItem *item (menu->ItemAt (i));
						if (item && network == item->Label ())
						{
							dynamic_cast < BInvoker * >(item)->Invoke ();
							return;
						}
					}
					BMessage newNet = fActiveNetwork;
					newNet.ReplaceString ("name", network.String ());
					vision_app->SetNetwork (network.String (), &newNet);
					BMenuItem *item (new BMenuItem (network.String (), new BMessage (M_CHOOSE_NETWORK)));
					menu->AddItem (item, 0);
					item->SetTarget (this);
					dynamic_cast < BInvoker * >(item)->Invoke ();
				}
				else
				{
					BString promptText = B_TRANSLATE("Network Name");
					promptText += ": ";
					fDupePrompt = new PromptWindow (BPoint (Window ()->Frame ().left + Window ()->Frame ().Width () / 2, Window ()->Frame ().top + Window ()->Frame ().Height () / 2),
						promptText.String(), B_TRANSLATE("Duplicate Current Network"), NULL, this, new BMessage (M_DUPE_CURRENT_NETWORK), NULL, false);
					fDupePrompt->Show ();
				}
			}
			break;

		case M_SERVER_DATA_CHANGED:
			{
				UpdateNetworkData (fActiveNetwork);
			}
			break;

		case M_SERVER_DIALOG:
			{
				BMessenger msgr (fServerPrefs);
				if (msgr.IsValid ())
					fServerPrefs->Activate ();
				else
				{
					fServerPrefs = new NetPrefServerWindow (this);
					fServerPrefs->SetNetworkData (&fActiveNetwork);
					fServerPrefs->Show ();
				}
			}
			break;

		case M_NET_CHECK_LAG:
			{
				bool value = msg->FindInt32 ("be:value");
				if (fActiveNetwork.HasBool ("lagCheck"))
					fActiveNetwork.ReplaceBool ("lagCheck", value);
				else
					fActiveNetwork.AddBool ("lagCheck", value);
			}
			break;

		case M_CONNECT_ON_STARTUP:
			{
				bool value = msg->FindInt32 ("be:value");
				if (fActiveNetwork.HasBool ("connectOnStartup"))
					fActiveNetwork.ReplaceBool ("connectOnStartup", value);
				else
					fActiveNetwork.AddBool ("connectOnStartup", value);
			}
			break;

		case M_USE_NICK_DEFAULTS:
			{
				bool value = msg->FindInt32 ("be:value");
				if (fActiveNetwork.HasBool ("useDefaults"))
					fActiveNetwork.ReplaceBool ("useDefaults", value);
				else
					fActiveNetwork.AddBool ("useDefaults", value);
				UpdatePersonalData (fActiveNetwork);
			}
			break;

		case M_NETPREFS_TEXT_INVOKE:
			{
				if (fActiveNetwork.HasString("autoexec"))
					fActiveNetwork.ReplaceString("autoexec", fTextView->Text());
				else
					fActiveNetwork.AddString("autoexec", fTextView->Text());
			}
			break;

		case M_ADD_NICK:
			if (msg->HasString ("text"))
			{
				fNickPrompt = NULL;
				BString nick (msg->FindString ("text"));
				nick.RemoveAll (" ");
				for (int32 i = 0; i < fListView->CountItems (); i++)
				{
					BStringItem *item ((BStringItem *) fListView->ItemAt (i));
					if (item && nick == item->Text ())
						return;
				}
			fActiveNetwork.AddString ("nick", nick.String ());
			fListView->AddItem (new BStringItem (nick.String ()));
			}
			else
			{
				BString promptString = B_TRANSLATE("Nickname");
				promptString += ": ";
				fNickPrompt = new PromptWindow (BPoint (Window ()->Frame ().left + Window ()->Frame ().Width () / 2, Window ()->Frame ().top + Window ()->Frame ().Height () / 2),
					promptString.String(), B_TRANSLATE("Add Nickname"), NULL, this, new BMessage (M_ADD_NICK), NULL, false);
				fNickPrompt->Show ();
			}
			break;

		case M_REMOVE_NICK:
			{
				int32 current (fListView->CurrentSelection ());
				if (current >= 0)
			{
					delete fListView->RemoveItem (current);
					fActiveNetwork.RemoveData ("nick", current);
				}
			}
			break;

		case M_NICK_UP:
			{
				int32 current (fListView->CurrentSelection ());
				BString nick1, nick2;
				nick1 = fActiveNetwork.FindString ("nick", current);
				nick2 = fActiveNetwork.FindString ("nick", current - 1);
				fListView->SwapItems (current, current - 1);
				fActiveNetwork.ReplaceString ("nick", current - 1, nick1.String ());
				fActiveNetwork.ReplaceString ("nick", current, nick2.String ());
				current = fListView->CurrentSelection ();
				Window ()->DisableUpdates ();
				fListView->DeselectAll ();
				fListView->Select (current);
				Window ()->EnableUpdates ();
			}
			break;

		case M_NICK_DOWN:
			{
				int32 current (fListView->CurrentSelection ());
				BString nick1, nick2;
				nick1 = fActiveNetwork.FindString ("nick", current);
				nick2 = fActiveNetwork.FindString ("nick", current + 1);
				fListView->SwapItems (current, current + 1);
				fActiveNetwork.ReplaceString ("nick", current + 1, nick1.String ());
				fActiveNetwork.ReplaceString ("nick", current, nick2.String ());
				current = fListView->CurrentSelection ();
				Window ()->DisableUpdates ();
				fListView->DeselectAll ();
				fListView->Select (current);
				Window ()->EnableUpdates ();
			}
			break;

		case M_NICK_SELECTED:
			{
				int32 index (msg->FindInt32 ("index"));
				if (index >= 0 && !fNickDefaultsBox->Value ())
				{
					fNickUpButton->SetEnabled (index > 0);
					fNickDnButton->SetEnabled (index != (fListView->CountItems () - 1));
					fNickRemoveButton->SetEnabled (true);
				}
				else
				{
					fNickUpButton->SetEnabled (false);
					fNickDnButton->SetEnabled (false);
					fNickRemoveButton->SetEnabled (false);
				}
			}
			break;

		default:
			BView::MessageReceived (msg);
			break;
	}
}