예제 #1
0
void
ReplicantView::MessageReceived(BMessage* msg)
{
	switch(msg->what)
	{
		case B_ABOUT_REQUESTED:
			AboutRequested();
			break;
/*		case RESET_QUERIES:
			{
				for(int32 viewCtr=0; viewCtr < CountChildren(); viewCtr ++ )
				{
					BView* child = ChildAt(viewCtr);
					if( dynamic_cast<QueryView*>(child) != NULL )
					{
						((QueryView*)child)->Reset();
					}
				}
			}
			break;*/
		
		default:
			BView::MessageReceived(msg);
	}
}
예제 #2
0
void
HWindow::MessageReceived(BMessage* msg)
{
	if (msg->what == B_ABOUT_REQUESTED) {
		AboutRequested();
	} else {
		inherited::MessageReceived(msg);
	}
}
예제 #3
0
void
CronoView::MessageReceived(BMessage *message)
{
	switch(message->what)
	{
		case MSG_CLOSE:
		{
			be_app->PostMessage(B_QUIT_REQUESTED);
			break;
		}

		case MSG_ABOUT:
		{
			AboutRequested();
			break;
		}

		case MSG_HOMEPAGE:
		{
			const char* homepage = CRONO_HOMEPAGE_URL;
			be_roster->Launch("text/html",1, const_cast<char**>(&homepage));
			break;
		}

		case MSG_HELP:
		{
			const char* guide = CRONO_USERGUIDE_URL;
			be_roster->Launch("text/html",1, const_cast<char**>(&guide));
			break;
		}

		case MSG_SETTINGS:
		{
			BRect windowRect(150,150,460,445);
			SettingsWindow *settWindow = new SettingsWindow(windowRect, fCore);
			settWindow->Show();
			break;
		}

		case MSG_START:
		{
			status_t ret = fCore->Start();
			if (ret != B_OK) {
				BString str("\nError starting Crono :\n");
				str << strerror(ret);
				BAlert *alert = new BAlert("Error", 
					str.String(),
					"OK", NULL, NULL, B_WIDTH_FROM_WIDEST, B_EVEN_SPACING,
					B_INFO_ALERT);
					alert->Go();
				break;
			}
			fStartButton->SetEnabled(false);
			fStopButton->SetEnabled(true);
			fStopButton->MakeDefault(true);
			fEditMenu->FindItem(MSG_SETTINGS)->SetEnabled(false);
			fFileMenu->FindItem(MSG_START)->SetEnabled(false);
			fFileMenu->FindItem(MSG_STOP)->SetEnabled(true);
			break;
		}

		case MSG_STOP:
		{
			fCore->Stop();
			fStopButton->SetEnabled(false);
			fStartButton->SetEnabled(true);
			fStartButton->MakeDefault(true);
			fEditMenu->FindItem(MSG_SETTINGS)->SetEnabled(true);
			fFileMenu->FindItem(MSG_START)->SetEnabled(true);
			fFileMenu->FindItem(MSG_STOP)->SetEnabled(false);
			break;
		}

		case MSG_VOLUME:
		{
			float position = fVolumeSlider->Position();
			fCore->SetVolume(position);
			fVolumeSlider->SetLabel(BString() << position);
			break;
		}

		case MSG_METER_RADIO:
		{
			int selected = _GetCurrentMeter();

			// If "Other" is selected, enable the fTempoEntry
			if (fTempoRadios[4]->Value() == true) {
				fTempoEntry->SetEnabled(true);
			} else {
				fTempoEntry->SetEnabled(false);
			}
			fCore->SetMeter(selected);

			if (gCronoSettings.AccentTable)
				_SetAccentCheckBox(selected);
			break;
		}

		case MSG_METER_ENTRY:
		{
			int position = abs(atoi(fTempoEntry->Text()));
			if (position < 1) {
				fTempoEntry->SetText("1");
				position = 1;
				return;
			} else if (position > 100) {
				fTempoEntry->SetText("100");
				position = 100;		
			}

			fCore->SetMeter(position);
			_SetAccentCheckBox(position);
			break;
		}

		case MSG_SPEED_ENTRY:
		{
			unsigned bpm = abs(atoi(fSpeedEntry->Text()));

			if (bpm > MAX_SPEED) {
				fSpeedEntry->SetText(BString() << MAX_SPEED);
				bpm = MAX_SPEED;
			} else if (bpm < MIN_SPEED) {
				fSpeedEntry->SetText(BString() << MIN_SPEED);
				bpm = MIN_SPEED;
			}

			fCore->SetSpeed(((int) bpm));
			fSpeedSlider->SetPosition(((float) bpm / MAX_SPEED));
			printf("Crono Speed: %s %d\n", fSpeedEntry->Text(), bpm);
			_UpdateTempoName(bpm);
			break;
		}

		case MSG_SPEED_SLIDER:
		{
			int v = fSpeedSlider->Value();

			BString str;
			fSpeedEntry->SetText(str << v);
			fCore->SetSpeed(v);
			_UpdateTempoName(v);
			break;
		}

		case MSG_ACCENT_TABLE:
		{
			bool marked = !fAccentTableItem->IsMarked();
			gCronoSettings.AccentTable = marked;

			_ShowTable(marked);
			break;
		}

		default:
			BView::MessageReceived(message);
	}
}
예제 #4
0
void
MainWindow::MessageReceived(BMessage *msg)
{
	switch (msg->what)
	{
		case B_ABOUT_REQUESTED:
		{
			AboutRequested();
			break;
		}
		case M_SHOW_HELP:
		{
			HelpWindow *helpwin = new HelpWindow();
			helpwin->Show();
			break;
		}
		case M_SHOW_CUSTOM:
		{
			CustomWindow *cswin = new CustomWindow();
			cswin->Show();
			break;
		}
		case M_NEW_GAME:
		{
			SetFace(FACE_NORMAL);
			SetupGame();
			break;
		}
		case M_SHOW_SCORES:
		{
			ScoreWindow *scorewin = new ScoreWindow();
			scorewin->Show();
			break;
		}
		case M_PAUSE_GAME:
		{
			BMenuItem *item = fMenuBar->FindItem(M_PAUSE_GAME);
			if (fTimerView->GetState() == TIMER_START)
			{
				fTimerView->SetState(TIMER_STOP);
				if (item)
					item->SetMarked(true);
				fFieldView->SetPauseMode(true);
			}
			else
			{
				if (item->IsMarked())
				{
					fTimerView->SetState(TIMER_START);
					if (item)
						item->SetMarked(false);
					fFieldView->SetPauseMode(false);
				}
			}
			break;
		}
		case M_SET_DIFFICULTY:
		{
			int32 level;
			if (msg->FindInt32("level",&level) != B_OK)
				break;

			BMenuItem *item = fMenuBar->FindItem(M_SET_DIFFICULTY);
			BMenu *menu = item ? item->Menu() : NULL;

			item = menu->FindMarked();
			if (item)
				item->SetMarked(false);
			menu->ItemAt(level)->SetMarked(true);

			gDifficulty = level;
			SetupGame();
			fFieldView->SetPauseMode(false);
			break;
		}
		case M_UPDATE_COUNT:
		{
			fCounterView->SetCount(fFieldView->MineCount() - fFieldView->FlagCount());
			break;
		}
		case M_START_TIMER:
		{
			fTimerView->SetState(TIMER_RESET);
			fTimerView->SetState(TIMER_START);
			gGameState = GAME_STARTED;
			break;
		}
		case M_SONAR_PENALTY:
		{
			fTimerView->SetState(TIMER_STOP);
			if (fTimerView->GetTime() < 979)
				fTimerView->SetTime(fTimerView->GetTime() + 20);
			else
				fTimerView->SetTime(999);
			fTimerView->SetState(TIMER_START);
			if (fFieldView->CheckWin())
				fFieldView->DoWin();
			break;
		}
		case M_SIZE_CHANGED:
		{
			ResizeTo(fFieldView->Frame().right + 10,fFieldView->Frame().bottom + 10);
			break;
		}
		case M_SET_THEME:
		{
			BString name;
			if (msg->FindString("name",&name) == B_OK)
				SetTheme(name.String());

			break;
		}
		case M_TOGGLE_SOUNDS:
		{
			gPlaySounds = gPlaySounds ? false : true;
			BMenuItem *item = fMenuBar->FindItem(M_TOGGLE_SOUNDS);
			if (item)
				item->SetMarked(!item->IsMarked());
			break;
		}
		default:
		{
			BWindow::MessageReceived(msg);
			break;
		}
	}
}
예제 #5
0
파일: CalcView.cpp 프로젝트: RTOSkit/haiku
void
CalcView::MessageReceived(BMessage* message)
{
	if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
		// if we are embedded in desktop we need to receive these
		// message here since we don't have a parent BWindow
		switch (message->what) {
			case MSG_OPTIONS_AUTO_NUM_LOCK:
				ToggleAutoNumlock();
				return;

			case MSG_OPTIONS_AUDIO_FEEDBACK:
				ToggleAudioFeedback();
				return;

			case MSG_OPTIONS_ANGLE_MODE_RADIAN:
				SetDegreeMode(false);
				return;

			case MSG_OPTIONS_ANGLE_MODE_DEGREE:
				SetDegreeMode(true);
				return;
		}
	}

	// check if message was dropped
	if (message->WasDropped()) {
		// pass message on to paste
		if (message->IsSourceRemote())
			Paste(message);
	} else {
		// act on posted message type
		switch (message->what) {

			// handle "cut"
			case B_CUT:
				Cut();
				break;

			// handle copy
			case B_COPY:
				Copy();
				break;

			// handle paste
			case B_PASTE:
				// access system clipboard
				if (be_clipboard->Lock()) {
					BMessage* clipper = be_clipboard->Data();
					//clipper->PrintToStream();
					Paste(clipper);
					be_clipboard->Unlock();
				}
				break;

			// (replicant) about box requested
			case B_ABOUT_REQUESTED:
				AboutRequested();
				break;

			case MSG_UNFLASH_KEY:
			{
				int32 key;
				if (message->FindInt32("key", &key) == B_OK)
					_FlashKey(key, 0);
				break;
			}

			default:
				BView::MessageReceived(message);
				break;
		}
	}
}
예제 #6
0
void
AppWindow::MessageReceived(BMessage* message)
{
	//PRINT(("AppWindow::MessageReceived(BMessage*)\n"));

	switch(message->what)
	{
		case MSG_FILE_OPEN:
		{
			fOpenPanel->Show();
			break;
		}
		case B_ABOUT_REQUESTED:
			AboutRequested();
			break;

		case MSG_EDITOR_MODE:
			m_app_view->SelectView(0);
			break;
		case MSG_TA_MODE:
			m_app_view->SelectView(1);
			break;
		case MSG_NA_MODE:
			m_app_view->SelectView(2);
			break;
		case MSG_MPEG_MODE:
			m_app_view->SelectView(3);
			break;
#ifdef _TTE_
		case MSG_TT_INFO_MODE:
			m_app_view->SelectView(4);
			break;
#endif
		case MSG_PREVIOUS_MODE:
			m_app_view->SetPreviousMode();
			break;
		case MSG_NEXT_MODE:
			m_app_view->SetNextMode();
			break;

		case MSG_RESET:
			m_app_view->Reset();
			break;
		case MSG_CLEAR_LIST:
			m_app_view->ClearList();
			break;

		case MSG_PREVIOUS_FILE:
			m_app_view->SelectPreviousFile();
			break;
		case MSG_NEXT_FILE:
			m_app_view->SelectNextFile();
			break;

		case MSG_FIRST_FILE:
			m_app_view->SelectFirstFile();
			break;
		case MSG_LAST_FILE:
			m_app_view->SelectLastFile();
			break;

		case B_REFS_RECEIVED:
			m_app_view->MessageReceived(message);
			break;

		case MSG_MAKE_APPLY_BUTTON_DEFAULT:
			m_app_view->m_apply_button->MakeDefault(true);
			break;

		case MSG_MAKE_APPLY_BUTTON_NOT_DEFAULT:
			m_app_view->m_apply_button->MakeDefault(false);
			break;

		case MSG_EDIT_CUT:
			{
				message->what = B_CUT;
				BView *view = CurrentFocus();
				if (view)
					view->MessageReceived(message);
			}
			break;

		case MSG_EDIT_COPY:
			{
				message->what = B_COPY;
				BView *view = CurrentFocus();
				if (view)
					view->MessageReceived(message);
			}
			break;

		case MSG_EDIT_PASTE:
			{
				message->what = B_PASTE;
				BView *view = CurrentFocus();
				if (view)
					view->MessageReceived(message);
			}
			break;

		case MSG_SELECT_ALL:
			{
				message->what = B_SELECT_ALL;
				BView *view = CurrentFocus();
				if (view)
					view->MessageReceived(message);
				else
					m_app_view->SelectAll();
			}
			break;

		case MSG_SELECT_ALL_UNSUPPORTED:
			m_app_view->SelectAllUnsupported();
			break;
		
		case MSG_README:
		{
			BPath path;
			app_info info;
			be_roster->GetActiveAppInfo(&info);
			BEntry entry(&info.ref);
			
			entry.GetPath(&path);
			path.GetParent(&path);
			path.Append(DOCUMENTATION_DIR);
			path.Append(README_FILE);
			
			BMessage message(B_REFS_RECEIVED);
 			message.AddString("url", path.Path());
 			be_roster->Launch("text/html", &message);
			break;
		}

		case MSG_CHANGELOG:
		{
			BPath path;
			app_info info;
			be_roster->GetActiveAppInfo(&info);
			BEntry entry(&info.ref);
			
			entry.GetPath(&path);
			path.GetParent(&path);
			path.Append(DOCUMENTATION_DIR);
			path.Append(CHANGELOG_FILE);
			
			BMessage message(B_REFS_RECEIVED);
 			message.AddString("url", path.Path());
 			be_roster->Launch("text/html", &message);
			break;
		}
		
		default:
			BWindow::MessageReceived(message);
	}
}
예제 #7
0
void
ProcessController::MessageReceived(BMessage *message)
{
	team_id team;
	thread_id thread;
	BAlert *alert;
	char	question[1000];
	switch (message->what) {
		case 'Puls':
			Update ();
			DoDraw (false);
			break;

		case 'QtTm':
			if (message->FindInt32("team", &team) == B_OK) {
				resume_thread(spawn_thread(thread_quit_application,
					B_TRANSLATE("Quit application"), B_NORMAL_PRIORITY,
					(void*)(addr_t)team));
			}
			break;

		case 'KlTm':
			if (message->FindInt32("team", &team) == B_OK) {
				info_pack infos;
				if (get_team_info(team, &infos.team_info) == B_OK) {
					get_team_name_and_icon(infos);
					snprintf(question, sizeof(question),
					B_TRANSLATE("What do you want to do with the team \"%s\"?"),
					infos.team_name);
					alert = new BAlert(B_TRANSLATE("Please confirm"), question,
					B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this team!"),
					B_TRANSLATE("Kill this team!"), B_WIDTH_AS_USUAL,
					B_STOP_ALERT);
					alert->SetShortcut(0, B_ESCAPE);
					int result = alert->Go();
					switch (result) {
						case 1:
							_HandleDebugRequest(team, -1);
							break;
						case 2:
							kill_team(team);
							break;
						default:
							break;
					}
				} else {
					alert = new BAlert(B_TRANSLATE("Info"),
						B_TRANSLATE("This team is already gone" B_UTF8_ELLIPSIS),
						B_TRANSLATE("Ok!"), NULL, NULL, B_WIDTH_AS_USUAL,
						B_STOP_ALERT);
					alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
					alert->Go();
				}
			}
			break;

		case 'KlTh':
			if (message->FindInt32("thread", &thread) == B_OK) {
				thread_info	thinfo;
				if (get_thread_info(thread, &thinfo) == B_OK) {
					#if DEBUG_THREADS
					snprintf(question, sizeof(question),
						B_TRANSLATE("What do you want to do "
						"with the thread \"%s\"?"), thinfo.name);
					alert = new BAlert(B_TRANSLATE("Please confirm"), question,
						B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this thread!"),
						B_TRANSLATE("Kill this thread!"), B_WIDTH_AS_USUAL,
						B_STOP_ALERT);
					alert->SetShortcut(0, B_ESCAPE);

					#define KILL 2
					#else
					snprintf(question, sizeof(question),
						B_TRANSLATE("Are you sure you want "
						"to kill the thread \"%s\"?"), thinfo.name);
					alert = new BAlert(B_TRANSLATE("Please confirm"), question,
						B_TRANSLATE("Cancel"), B_TRANSLATE("Kill this thread!"),
						NULL, B_WIDTH_AS_USUAL,	B_STOP_ALERT);
					alert->SetShortcut(0, B_ESCAPE);

					#define KILL 1
					#endif
					alert->SetShortcut(0, B_ESCAPE);
					int r = alert->Go();
					if (r == KILL)
						kill_thread(thread);
					#if DEBUG_THREADS
					else if (r == 1)
						_HandleDebugRequest(thinfo.team, thinfo.thread);
					#endif
				} else {
					alert = new BAlert(B_TRANSLATE("Info"),
						B_TRANSLATE("This thread is already gone" B_UTF8_ELLIPSIS),
						B_TRANSLATE("Ok!"),	NULL, NULL,
						B_WIDTH_AS_USUAL, B_STOP_ALERT);
					alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
					alert->Go();
				}
			}
			break;

		case 'PrTh':
			if (message->FindInt32("thread", &thread) == B_OK) {
				int32 new_priority;
				if (message->FindInt32("priority", &new_priority) == B_OK)
					set_thread_priority(thread, new_priority);
			}
			break;

		case 'Trac':
		{
			BPath trackerPath;
			if (find_directory(B_SYSTEM_DIRECTORY, &trackerPath) == B_OK
				&& trackerPath.Append("Tracker") == B_OK) {
				launch(kTrackerSig, trackerPath.Path());
			}
			break;
		}

		case 'Dbar':
		{
			BPath deskbarPath;
			if (find_directory(B_SYSTEM_DIRECTORY, &deskbarPath) == B_OK
				&& deskbarPath.Append("Deskbar") == B_OK) {
				launch(kDeskbarSig, deskbarPath.Path());
			}
			break;
		}

		case 'Term':
		{
			BPath terminalPath;
			if (find_directory(B_SYSTEM_APPS_DIRECTORY, &terminalPath) == B_OK
				&& terminalPath.Append("Terminal") == B_OK) {
				launch(kTerminalSig, terminalPath.Path());
			}
			break;
		}

		case 'AlDb':
		{
			if (!be_roster->IsRunning(kDeskbarSig)) {
				BPath deskbarPath;
				if (find_directory(B_SYSTEM_DIRECTORY, &deskbarPath) == B_OK
					&& deskbarPath.Append("Deskbar") == B_OK) {
					launch(kDeskbarSig, deskbarPath.Path());
				}
			}
			BDeskbar deskbar;
			if (gInDeskbar || deskbar.HasItem (kDeskbarItemName))
				deskbar.RemoveItem (kDeskbarItemName);
			else
				move_to_deskbar(deskbar);
			break;
		}

		case 'CPU ':
		{
			uint32 cpu;
			if (message->FindInt32("cpu", (int32*)&cpu) == B_OK) {
				bool last = true;
				for (unsigned int p = 0; p < gCPUcount; p++) {
					if (p != cpu && _kern_cpu_enabled(p)) {
						last = false;
						break;
					}
				}
				if (last) {
					alert = new BAlert(B_TRANSLATE("Info"),
						B_TRANSLATE("This is the last active processor...\n"
						"You can't turn it off!"),
						B_TRANSLATE("That's no Fun!"), NULL, NULL,
						B_WIDTH_AS_USUAL, B_WARNING_ALERT);
					alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
					alert->Go();
				} else
					_kern_set_cpu_enabled(cpu, !_kern_cpu_enabled(cpu));
			}
			break;
		}

		case 'Schd':
		{
			int32 mode;
			if (message->FindInt32 ("mode", &mode) == B_OK)
				set_scheduler_mode(mode);
			break;
		}

		case B_ABOUT_REQUESTED:
			AboutRequested();
			break;

		default:
			BView::MessageReceived(message);
	}
}
예제 #8
0
void BeCheckersWindow::MessageReceived(BMessage *message) {
	switch(message->what) {
		case B_ABOUT_REQUESTED:
			AboutRequested(); break;
		case BECHECKERS_NEW:
			if(openedFile != NULL) openedFile = NULL;	// I think there is a small mem leak here??
			StartGame();
			break;
		case BECHECKERS_OPEN: {
			// This is a cludge, because I was too lazy to create another class, but it works ;)
			// Create the open saved game window here

			BRect frame(Frame());
			// The bounds are (0,0,350,125), I hate magic numbers too but oh well.  BeCheckers is full of em!
			openWindow = new BWindow(BRect(frame.left+48, frame.top+40, frame.left+398, frame.top+165),
							 "Saved Games",
							 B_FLOATING_WINDOW_LOOK,B_MODAL_APP_WINDOW_FEEL,
							 B_NOT_RESIZABLE | B_NOT_ZOOMABLE);

			BView *v = new BView(BRect(0, 0, 350, 125), "v", B_NOT_RESIZABLE, B_WILL_DRAW);
			v->SetViewColor(216, 216, 216);

			BButton *b = new BButton(BRect(10, 16, 70, 41), "Open", "Open", new BMessage(BECHECKERS_OPEN_OPEN));
			b->MakeDefault(true);
			b->SetTarget(this);
			v->AddChild(b);

			BButton *b1 = new BButton(BRect(10, 51, 70, 76), "Delete", "Delete", new BMessage(BECHECKERS_OPEN_DELETE));
			b1->SetTarget(this);
			v->AddChild(b1);

			BButton *b2 = new BButton(BRect(10, 86, 70, 111), "Close", "Close", new BMessage(BECHECKERS_OPEN_CLOSE));
			b2->SetTarget(this);
			v->AddChild(b2);

			savedGameList = new BListView(BRect(95, 15, 320, 108), "City");
			SavedGames(savedGameList);	// Get the saved games from disk

			BScrollView *sv = new BScrollView("ScrollView", savedGameList,B_FOLLOW_LEFT|B_FOLLOW_TOP, 0, false, true, B_FANCY_BORDER);
			v->AddChild(sv);

			openWindow->AddChild(v);
			openWindow->Show();
		} break;
		case BECHECKERS_OPEN_OPEN: {
			int index = savedGameList->CurrentSelection();
			if(index >= 0) {
				// Set seleted file as openedFile and open it
				openedFile = File(((BStringItem *) savedGameList->ItemAt(index))->Text());
				OpenGame(openedFile);
				openWindow->Lock();
				openWindow->Quit();
			}
			else (new BAlert("NoFile",
							 "A saved game must be selected before opening.",
							 "Okay"))->Go();
		} break;
		case BECHECKERS_OPEN_CLOSE:
			openWindow->Lock();
			openWindow->Quit();
			break;
		case BECHECKERS_OPEN_DELETE: {
			int index = savedGameList->CurrentSelection();
			if(index >= 0) {
				// If the file being deleted was the last file opened then set openedFile to (null)
				if(openedFile != NULL && strcmp(File(((BStringItem *) savedGameList->ItemAt(index))->Text()), openedFile) == 0)
					openedFile = NULL;
				// Delete saved game from harddisk
				BEntry entry(File(((BStringItem *) savedGameList->ItemAt(index))->Text()));
				entry.Remove();
				// Delete the filename from the BListView
				openWindow->Lock();
				savedGameList->RemoveItem(index);
				openWindow->Unlock();
			}
			else (new BAlert("NoFile",
							 "A saved game must be selected before deleting.",
							 "Okay"))->Go();
		} break;
		case BECHECKERS_SAVE:
			if(openedFile != NULL) SaveGame(openedFile);
			else this->PostMessage(BECHECKERS_SAVEAS);
			break;
		case BECHECKERS_SAVEAS:
			// Set the new file as the last openedFile and save to harddisk
			openedFile = File(CreateFileName());
			SaveGame(openedFile);
			break;
		case CHECKER_WIN:
			bool color;
			message->FindBool("Color", &color);
			mvIndicationLabel->SetText(color == DARK ? "Dark won" : "Light won");
			if((new BAlert("Winner",
						   color == DARK ? "The dark colored checkers won the game!" :
						   				   "The light colored checkers won the game!",
						   "Quit", "Play again"))->Go() == 0)
				 be_app->PostMessage(B_QUIT_REQUESTED);
			else this->PostMessage(BECHECKERS_NEW);
			break;
		case CHECKER_TURN:
			bool turn;
			message->FindBool("Turn", &turn);
			mvIndicationLabel->SetText(turn == DARK ? "Dark to move" : "Light to move");
			break;
		default:
			BWindow::MessageReceived(message); break;
	}
}
예제 #9
0
void
ProcessController::MessageReceived(BMessage *message)
{
	team_id team;
	thread_id thread;
	BAlert *alert;
	char	question[1000];
	switch (message->what) {
		case 'Puls':
			Update ();
			DoDraw (false);
			break;

		case 'QtTm':
			if (message->FindInt32("team", &team) == B_OK) {
				resume_thread(spawn_thread(thread_quit_application,
					B_TRANSLATE("Quit application"), B_NORMAL_PRIORITY,
					(void*) team));
			}
			break;

		case 'KlTm':
			if (message->FindInt32("team", &team) == B_OK) {
				info_pack infos;
				if (get_team_info(team, &infos.team_info) == B_OK) {
					get_team_name_and_icon(infos);
					snprintf(question, sizeof(question),
					B_TRANSLATE("Do you really want to kill the team \"%s\"?"),
					infos.team_name);
					alert = new BAlert(B_TRANSLATE("Please confirm"), question,
					B_TRANSLATE("Cancel"), B_TRANSLATE("Yes, kill this team!"),
					NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
					alert->SetShortcut(0, B_ESCAPE);
					if (alert->Go())
						kill_team(team);
				} else {
					alert = new BAlert(B_TRANSLATE("Info"),
						B_TRANSLATE("This team is already gone"B_UTF8_ELLIPSIS),
						B_TRANSLATE("Ok!"), NULL, NULL, B_WIDTH_AS_USUAL,
						B_STOP_ALERT);
					alert->SetShortcut(0, B_ESCAPE);
					alert->Go();
				}
			}
			break;

		case 'KlTh':
			if (message->FindInt32("thread", &thread) == B_OK) {
				thread_info	thinfo;
				if (get_thread_info(thread, &thinfo) == B_OK) {
					#if DEBUG_THREADS
					snprintf(question, sizeof(question),
						B_TRANSLATE("What do you want to do "
						"with the thread \"%s\"?"), thinfo.name);
					alert = new BAlert(B_TRANSLATE("Please confirm"), question,
						B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this thread!"),
						B_TRANSLATE("Kill this thread!"), B_WIDTH_AS_USUAL,
						B_STOP_ALERT);
					#define KILL 2
					#else
					snprintf(question, sizeof(question),
						B_TRANSLATE("Are you sure you want "
						"to kill the thread \"%s\"?"), thinfo.name);
					alert = new BAlert(B_TRANSLATE("Please confirm"), question,
						B_TRANSLATE("Cancel"), B_TRANSLATE("Kill this thread!"),
						NULL, B_WIDTH_AS_USUAL,	B_STOP_ALERT);
					#define KILL 1
					#endif
					alert->SetShortcut(0, B_ESCAPE);
					int r = alert->Go();
					if (r == KILL)
						kill_thread(thread);
					#if DEBUG_THREADS
					else if (r == 1) {
						Tdebug_thead_param* param = new Tdebug_thead_param;
						param->thread = thread;
						if (thinfo.state == B_THREAD_WAITING)
							param->sem = thinfo.sem;
						else
							param->sem = -1;
						param->totalTime = thinfo.user_time+thinfo.kernel_time;
						resume_thread(spawn_thread(thread_debug_thread,
						B_TRANSLATE("Debug thread"), B_NORMAL_PRIORITY, param));
					}
					#endif
				} else {
					alert = new BAlert(B_TRANSLATE("Info"),
						B_TRANSLATE("This thread is already gone"B_UTF8_ELLIPSIS),
						B_TRANSLATE("Ok!"),	NULL, NULL,
						B_WIDTH_AS_USUAL, B_STOP_ALERT);
					alert->SetShortcut(0, B_ESCAPE);
					alert->Go();
				}
			}
			break;

		case 'PrTh':
			if (message->FindInt32("thread", &thread) == B_OK) {
				long new_priority;
				if (message->FindInt32("priority", &new_priority) == B_OK)
					set_thread_priority(thread, new_priority);
			}
			break;

		case 'Trac':
			launch(kTrackerSig, "/boot/system/Tracker");
			break;

		case 'Dbar':
			launch(kDeskbarSig, "/boot/system/Deskbar");
			break;

		case 'Term':
			launch(kTerminalSig, "/boot/system/apps/Terminal");
			break;

		case 'AlDb':
		{
			if (!be_roster->IsRunning(kDeskbarSig))
				launch(kDeskbarSig, "/boot/system/Deskbar");
			BDeskbar deskbar;
			if (gInDeskbar || deskbar.HasItem (kDeskbarItemName))
				deskbar.RemoveItem (kDeskbarItemName);
			else
				move_to_deskbar(deskbar);
			break;
		}

		case 'CPU ':
		{
			int32 cpu;
			if (message->FindInt32 ("cpu", &cpu) == B_OK) {
				bool last = true;
				for (int p = 0; p < gCPUcount; p++) {
					if (p != cpu && _kern_cpu_enabled(p)) {
						last = false;
						break;
					}
				}
				if (last) {
					alert = new BAlert(B_TRANSLATE("Info"),
						B_TRANSLATE("This is the last active processor...\n"
						"You can't turn it off!"),
						B_TRANSLATE("That's no Fun!"), NULL, NULL,
						B_WIDTH_AS_USUAL, B_WARNING_ALERT);
					alert->SetShortcut(0, B_ESCAPE);
					alert->Go();
				} else
					_kern_set_cpu_enabled(cpu, !_kern_cpu_enabled(cpu));
			}
			break;
		}

		case B_ABOUT_REQUESTED:
			AboutRequested();
			break;

		default:
			BView::MessageReceived(message);
	}
}