示例#1
0
void
BSCWindow::MessageReceived(BMessage *message)
{
	switch (message->what) {			
		case kPauseResumeCapture:
			fController->TogglePause();
			break;
		
		case kSelectArea:
		{
			Minimize(true);
			SelectionWindow *window = new SelectionWindow();
			window->SetTarget(this);
			window->SetCommand(kAreaSelected);
			window->Show();
			break;
		}
		
		case kAreaSelected:
		{
			SendNotices(kAreaSelected, message);
			break;
		}
								
		case kMsgControllerAreaSelectionChanged:
			if (IsMinimized())
				Minimize(false);
			break;
				
		case kMsgGUIToggleCapture:
			if (fCapturing)
				_CaptureFinished();
			else
				_CaptureStarted();
			SendNotices(kMsgGUIToggleCapture);
			break;
		
		
		case B_OBSERVER_NOTICE_CHANGE:
		{
			int32 code;
			message->FindInt32("be:observe_change_what", &code);
			switch (code) {		
				case B_UPDATE_STATUS_BAR:
				case B_RESET_STATUS_BAR:
				{
					BMessage newMessage(*message);
					message->what = code;
					PostMessage(message, fStatusBar);
					break;
				}
				case kMsgControllerEncodeStarted:
					fStringView->Show();
					fStatusBar->Show();
					break;
					
				case kMsgControllerEncodeProgress:
				{
					int32 numFiles = 0;
					message->FindInt32("num_files", &numFiles);
					
					fStatusBar->SetMaxValue(float(numFiles));
					
					break;
				}
		
				case kMsgControllerEncodeFinished:
				{
					fStartStopButton->SetEnabled(true);
					fStringView->Hide();
					fStatusBar->Hide();
					
					status_t status = B_OK;
					if (message->FindInt32("status", (int32*)&status) == B_OK
						&& status != B_OK) {
						char errorString[128];
						snprintf(errorString, 128, "A problem has occurred:\n"
							"%s", strerror(status));
						(new BAlert("yo", errorString, "Ok"))->Go();
					}
					
					break;
				}
				default:
					break;
			}
		}
		

		default:
			BWindow::MessageReceived(message);
			break;
	}
}
示例#2
0
void
BSCWindow::MessageReceived(BMessage *message)
{
	switch (message->what) {				
		case kSelectArea:
		{
			Minimize(true);
			BMessenger messenger(this);
			SelectionWindow *window = new SelectionWindow(messenger, kSelectionWindowClosed);			
			window->Show();
			break;
		}
		
		case kSelectionWindowClosed:
		{
			if (IsMinimized())
				Minimize(false);
				
			SendNotices(kSelectionWindowClosed, message);
			break;
		}
		
		case kCmdToggleRecording:
			fStartStopButton->Invoke();
			break;
		
		case B_OBSERVER_NOTICE_CHANGE:
		{
			int32 code;
			message->FindInt32("be:observe_change_what", &code);
			switch (code) {		
				case B_UPDATE_STATUS_BAR:
				case B_RESET_STATUS_BAR:
				{
					BMessage newMessage(*message);
					message->what = code;
					PostMessage(message, fStatusBar);
					break;
				}
	
				case kMsgControllerCaptureStarted:
					_CaptureStarted();
					break;
	
				case kMsgControllerCaptureStopped:
					_CaptureFinished();
					break;
	
				case kMsgControllerEncodeStarted:
					fStringView->SetText(kEncodingString);
					fCardLayout->SetVisibleItem(1);
					break;
					
				case kMsgControllerEncodeProgress:
				{
					int32 numFiles = 0;
					message->FindInt32("num_files", &numFiles);
					
					fStatusBar->SetMaxValue(float(numFiles));
					
					break;
				}
		
				case kMsgControllerEncodeFinished:
				{
					fStartStopButton->SetEnabled(true);
					//fStringView->SetText(kDoneString);
					fCardLayout->SetVisibleItem((int32)0);
					status_t status = B_OK;
					if (message->FindInt32("status", (int32*)&status) == B_OK
						&& status != B_OK) {
						char errorString[128];
						snprintf(errorString, 128, "A problem has occurred:\n"
							"%s", strerror(status));
						(new BAlert("yo", errorString, "Ok"))->Go();
					}
					
					break;
				}
				default:
					break;
			}
			break;
		}
		

		default:
			BWindow::MessageReceived(message);
			break;
	}
}