Exemple #1
0
void SetKeyWindow::MessageReceived(BMessage* msg){
	switch(msg->what){
	case SET:
		key = control1->GetKey();
		mod = control1->GetMod();
		key2 = control2->GetKey();
		mod2 = control2->GetMod();
		KeyBind.Install(menu, KeyBind.GetID(index), key, mod, key2, mod2, message);
		parent->LockLooper();
		parent->Pulse();
		parent->UnlockLooper();
		Quit();
		break;
	
	case CLEAR1:
		mod = key = 0;
		control1->SetBinding(key,mod);
		break;
		
	case CLEAR2:
		mod2 = key2 = 0;
		control2->SetBinding(key2,mod2);
		break;
		
	default:
		BWindow::MessageReceived(msg);
	}
}
Exemple #2
0
void PrefWindow::MessageReceived(BMessage *message){
	BView *tmpV;
	int32 k;

	switch (message->what){
	case QUIT:
		Hide();
		break;
	
	case CHANGE_LANGUAGE:
		tmpV = ChildAt(0);
		if (tmpV != NULL){
			tmpV->RemoveSelf();
			delete tmpV;
		}
		BLayoutBuilder::Group<>(this)
		.AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING)
			.Add(new PrefView());
		break;
	
	case SET_FACTORY:
		k = (new BAlert(NULL,Language.get("FACTORY_SURE"),Language.get("APPLY"),Language.get("CANCEL")))->Go();
		if (k==0){
			Prefs.FactorySettings();
			KeyBind.InstallDefaults();
			tmpV = FindView("Prefs color");
			if (tmpV != NULL){
				PostMessage(COLOR_SELECT, tmpV);
			}
			tmpV = FindView("Prefs keys");
			if (tmpV != NULL){
				tmpV->LockLooper();
				tmpV->Pulse();
				tmpV->UnlockLooper();
			}else{
				be_app->PostMessage(CHANGE_LANGUAGE);
			}
			Pool.sample_view_dirty = true;	// update the sample-view
			Pool.update_draw_cache = true;	// update the draw cache
			Pool.update_index = true;		// update the index cache
			Pool.RedrawWindow();
		}
		break;

	default:
		BWindow::MessageReceived(message);
	}
}
Exemple #3
0
void
SetKeyWindow::MessageReceived(BMessage* msg)
{
	switch(msg->what) {
		case SET:
		{
			KeyBind* key = new KeyBind();
	
			key->key = control1->GetKey();
			key->mod = control1->GetMod();
			key->altKey = control2->GetKey();
			key->altMod = control2->GetMod();
			key->label = gKeyBind->GetLabel(index);
			key->message = MessageBuilder(message);
			key->isMenuItem = menu;
	
			gKeyBind->AddKeyBind(key);
	
			if (parent->LockLooper()) {
				parent->Pulse();
				parent->UnlockLooper();
			}
			Quit();
			break;
		}

		case CLEAR1:
			mod = key = 0;
			control1->SetBinding(key,mod);
			break;
			
		case CLEAR2:
			mod2 = key2 = 0;
			control2->SetBinding(key2,mod2);
			break;
			
		default:
			BWindow::MessageReceived(msg);
	}
}
Exemple #4
0
void
SetKeyWindow::MessageReceived(BMessage* msg)
{
	switch(msg->what) {
		case SET:
		{
			KeyBind* key = new KeyBind();
	
			key->key = control1->GetKey();
			key->mod = control1->GetMod();
			key->label = FaberShortcut::KeyBindAt(index)->label;
			key->message = FaberShortcut::KeyBindAt(index)->message;
			key->itemType = FaberShortcut::KeyBindAt(index)->itemType;
			
	
			FaberShortcut::AddKeyBind(key);
	
			if (parent->LockLooper()) {
				parent->Pulse();
				parent->UnlockLooper();
			}
			Quit();
			break;
		}

		case CLEAR1:
			mod = key = 0;
			control1->SetBinding(key,mod);
			break;
			
		case CLEAR2:
			mod2 = key2 = 0;
			control2->SetBinding(key2,mod2);
			break;
			
		default:
			BWindow::MessageReceived(msg);
	}
}
void
NetPulseView::MessageReceived(BMessage* message)
{
	if (message->what == kMsgUpdate) {
		Update();
		Draw(Bounds());
	} else if (message->what == kMsgQuit) {
		SettingsFile settings("Settings", "NetPulse");
		settings.AddInt32("Interface", fCookie);
		settings.AddInt32("InputColor", *((int32 *) &fInputColor));
		settings.AddInt32("OutputColor", *((int32 *) &fOutputColor));
		settings.AddFloat("DecayRate", fDecayRate);
		settings.AddInt64("UpdateInterval", fUpdateInterval);
		settings.Save();

		BDeskbar deskbar;
		deskbar.RemoveItem(Name());
	} else if (message->what == kMsgConnect) {
		if (fCookie != 0) {
			BNetworkInterface interface(fCookie);
			interface.SetFlags(interface.Flags() & IFF_UP);
		}
	} else if (message->what == kMsgDisconnect) {
		if (fCookie != 0) {
			BNetworkInterface interface(fCookie);
			interface.SetFlags(interface.Flags() & ~IFF_UP);
		}
	} else if (message->what >= kMsgChangeInterface + 1
		&& message->what <= kMsgChangeInterface + 1000) {
		fCookie = message->what - kMsgChangeInterface;
		fInputRate = fOutputRate = 0;
		fMaxInputRate = fMaxOutputRate = 0;

		BNetworkInterface interface(fCookie);
		ifreq_stats stats;
		if (interface.GetStats(stats) == B_OK) {
			fInputBytes = stats.receive.bytes;
			fOutputBytes = stats.send.bytes;
		}

		Update();

		if (fMessenger != NULL) {
			BMessage message(kMsgChangeInterface);
			message.AddInt32("interface_index", fCookie);
			if (fMessenger->SendMessage(&message) != B_OK)
				fMessenger = NULL;
		}
		SettingsFile settings("Settings", "NetPulse");
		settings.AddInt32("Interface", fCookie);
		settings.AddInt32("InputColor", *((int32 *) &fInputColor));
		settings.AddInt32("OutputColor", *((int32 *) &fOutputColor));
		settings.AddFloat("DecayRate", fDecayRate);
		settings.AddInt64("UpdateInterval", fUpdateInterval);
		settings.Save();
		
	} else if (message->what == kMsgStatistics) {
		if (fMessenger == NULL || !fMessenger->IsValid()) {
			BRect frame(BScreen().Frame());
			BWindow* window = new BWindow(
				BRect(frame.right - kViewWidth - 20, frame.top + 60,
					frame.right - 20 - 1, frame.top + 60 + kViewHeight - 1),
				"Statistics", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
					B_NOT_ZOOMABLE | B_NOT_RESIZABLE
						| B_AUTO_UPDATE_SIZE_LIMITS);
			BView* view = new NetPulseStatsView("Statistics", fCookie);
			view->Pulse();
			BLayoutBuilder::Group<>(window, B_VERTICAL)
				.Add(view)
				.End();
			window->SetPulseRate(1000000LL);
			window->Show();
			fMessenger = new BMessenger(view);
		}
	} else
		BView::MessageReceived(message);
}