Example #1
0
status_t
BIconRule::Invoke(BMessage* message)
{
	bool notify = false;
	uint32 kind = InvokeKind(&notify);

	BMessage clone(kind);
	status_t err = B_BAD_VALUE;

	if (!message && !notify)
		message = Message();

	if (!message) {
		if (!IsWatched())
			return err;
	} else
		clone = *message;

	clone.AddInt64("when", (int64)system_time());
	clone.AddPointer("source", this);
	clone.AddMessenger("be:sender", BMessenger(this));
	clone.AddInt32("index", fSelIndex);

	if (message)
		err = BInvoker::Invoke(&clone);

	SendNotices(kind, &clone);

	return err;
}
Example #2
0
status_t
BControl::Invoke(BMessage* message)
{
	bool notify = false;
	uint32 kind = InvokeKind(&notify);

	if (!message && !notify)
		message = Message();

	BMessage clone(kind);

	if (!message) {
		if (!IsWatched())
			return B_BAD_VALUE;
	} else
		clone = *message;

	clone.AddInt64("when", (int64)system_time());
	clone.AddPointer("source", this);
	clone.AddInt32("be:value", fValue);
	clone.AddMessenger("be:sender", BMessenger(this));

	// ToDo: is this correct? If message == NULL (even if IsWatched()), we always return B_BAD_VALUE
	status_t err;
	if (message)
		err = BInvoker::Invoke(&clone);
	else
		err = B_BAD_VALUE;

	// TODO: asynchronous messaging
	SendNotices(kind, &clone);

	return err;
}
Example #3
0
void
TTracker::Pulse()
{
	if (!TrackerSettings().ShowVolumeSpaceBar())
		return;

	// update the volume icon's free space bars
	BVolumeRoster roster;

 	BVolume volume;
	while (roster.GetNextVolume(&volume) == B_NO_ERROR)
	{
		BDirectory dir;
		volume.GetRootDirectory(&dir);
		node_ref nodeRef;
		dir.GetNodeRef(&nodeRef);

		BMessage notificationMessage;
		notificationMessage.AddInt32("device", *(int32 *)&nodeRef.device);

		LockLooper();
		SendNotices(kUpdateVolumeSpaceBar, &notificationMessage);
		UnlockLooper();
	}
}
Example #4
0
void
Controller::SetVideoDepth(const color_space &space)
{
	BAutolock _(this);
	fEncoder->SetColorSpace(space);
	Settings().SetClipDepth(space);
	SendNotices(kMsgControllerVideoDepthChanged);
}
Example #5
0
void
Controller::_ResumeCapture()
{
	BAutolock _(this);
	resume_thread(fCaptureThread);
	fPaused = false;
	
	SendNotices(kMsgControllerCaptureResumed);
}
Example #6
0
void
Controller::SetCaptureArea(const BRect& rect)
{
	BAutolock _(this);
	Settings().SetCaptureArea(rect);
	
	fEncoder->SetDestFrame(Settings().TargetRect());
			
	BMessage message(kMsgControllerSourceFrameChanged);
	message.AddRect("frame", rect);
	SendNotices(kMsgControllerSourceFrameChanged, &message);

	BMessage targetFrameMessage(kMsgControllerTargetFrameChanged);
	// TODO: Move this to its own method
	BRect targetRect = Settings().TargetRect();
	targetFrameMessage.AddRect("frame", targetRect);
	SendNotices(kMsgControllerTargetFrameChanged, &targetFrameMessage);
}
Example #7
0
void
Controller::_PauseCapture()
{
	SendNotices(kMsgControllerCapturePaused);
	
	BAutolock _(this);
	fPaused = true;
	suspend_thread(fCaptureThread);
}
Example #8
0
void
Controller::MessageReceived(BMessage *message)
{
	switch (message->what) {
		case kSelectionWindowClosed:
		{
			SendNotices(kMsgControllerSelectionWindowClosed, message);
			
			BRect rect;
			if (message->FindRect("selection", &rect) == B_OK) {
				SetCaptureArea(rect);
			}
			break;
		}
		
		case kMsgGUIStartCapture:
		case kMsgGUIStopCapture:
			if (fEncoderThread < 0)
				ToggleCapture(message->what == kMsgGUIStartCapture);
			break;
		
		case kPauseCapture:
		case kResumeCapture:
			TogglePause(message->what == kPauseCapture);
			break;
			
		case kEncodingFinished:
		{
			status_t error;
			message->FindInt32("status", (int32*)&error);
			_EncodingFinished(error);
			break;
		}
		
		case B_UPDATE_STATUS_BAR:
		case B_RESET_STATUS_BAR:
			SendNotices(message->what, message);
			break;
				
		default:	
			BLooper::MessageReceived(message);
			break;
	}
}
void AmEventTimeView::SetNewTime(AmTime newTime)
{
	if (!mContainer || !mEvent) return;
	// WRITE SONG BLOCK
	AmSong*		song = WriteLock();
	if (song) mContainer->SetEventStartTime(mEvent, newTime);
	WriteUnlock(song);
	// END WRITE SONG BLOCK
	SendNotices(ARPMSG_TIME_VIEW_CHANGED);
}
Example #10
0
void
Controller::SetCaptureFrameDelay(const int milliSeconds)
{
	BAutolock _(this);
	Settings().SetCaptureFrameDelay(milliSeconds);
	
	BMessage message(kMsgControllerCaptureFrameDelayChanged);
	message.AddInt32("delay", milliSeconds);
	SendNotices(kMsgControllerCaptureFrameDelayChanged, &message);
}
Example #11
0
int32
Controller::CaptureThread()
{
	Settings settings;
	BScreen screen;
	BRect bounds = settings.CaptureArea();
	bigtime_t captureDelay = (bigtime_t)settings.CaptureFrameDelay() * 1000;
	
	// TODO: Validate captureDelay with some limits
	
	_DumpSettings();
	_TestWaitForRetrace();
	
	const int32 windowBorder = settings.WindowFrameBorderSize();
	int32 token = GetWindowTokenForFrame(bounds, windowBorder);
	bigtime_t waitTime = 0;
	status_t error = B_ERROR;
	while (!fKillThread) {
		if (!fPaused) {		
			if (token != -1) {
				BRect windowBounds = GetWindowFrameForToken(token, windowBorder);
				if (windowBounds.IsValid())
					bounds.OffsetTo(windowBounds.LeftTop());
			}
				
			_WaitForRetrace(captureDelay); // Wait for Vsync
			BBitmap *bitmap = new BBitmap(bounds, screen.ColorSpace());
			error = ReadBitmap(bitmap, true, bounds);
			bigtime_t currentTime = system_time();
			// Takes ownership of the bitmap
	    	if (error == B_OK && fFileList->AddItem(bitmap, currentTime))
				atomic_add(&fNumFrames, 1);
			else {
				delete bitmap;
				break;
			}
		} else
			snooze(500000);
	}
	
	fCaptureThread = -1;
	fKillThread = true;
	
	if (error != B_OK) {
		BMessage message(kMsgControllerCaptureStopped);
		message.AddInt32("status", (int32)error);
		SendNotices(kMsgControllerCaptureStopped, &message);
		
		delete fFileList;
		fFileList = NULL;
	}
		
	return B_OK;
}
Example #12
0
void
Controller::SetScale(const float &scale)
{
	BAutolock _(this);
	Settings().SetScale(scale);
	BRect rect(Settings().TargetRect());
	fEncoder->SetDestFrame(rect);
	BMessage message(kMsgControllerTargetFrameChanged);
	message.AddRect("frame", rect);
	message.AddFloat("scale", scale);
	SendNotices(kMsgControllerTargetFrameChanged, &message);
}
Example #13
0
void
Controller::EncodeMovie()
{
	BAutolock _(this);
	
	int32 numFrames = fFileList->CountItems();
	if (numFrames <= 0) {
		std::cout << "Aborted" << std::endl;
		_EncodingFinished(B_ERROR);
		return;
	}
	
	_DumpSettings();
			
	BString fileName;
	Settings().GetOutputFileName(fileName);
	BEntry entry(fileName.String());
	if (entry.Exists()) {
		// file exists.
		fileName = GetUniqueFileName(fileName, MediaFileFormat().file_extension);
	}
	
	fEncoder->SetOutputFile(fileName);
	
	SendNotices(kMsgControllerEncodeStarted);
		 
	BMessage message(kMsgControllerEncodeProgress);
	message.AddInt32("num_files", numFrames);
	
	SendNotices(kMsgControllerEncodeProgress, &message);
	
	fEncoder->SetSource(fFileList);
	
	BMessenger messenger(this);
	fEncoder->SetMessenger(messenger);

	fEncoderThread = fEncoder->EncodeThreaded();
}
Example #14
0
void
Controller::StartCapture()
{
	fNumFrames = 0;
	try {
		if (fFileList == NULL)
			fFileList = new FileList();
	} catch (status_t error) { 
		BMessage message(kMsgControllerCaptureStopped);
		message.AddInt32("status", error);
		SendNotices(kMsgControllerCaptureStopped, &message);
		return;
	}
	
	fKillThread = false;
	fPaused = false;
	
	fCaptureThread = spawn_thread((thread_entry)CaptureStarter,
		"Capture Thread", B_DISPLAY_PRIORITY, this);
					
	if (fCaptureThread < 0) {
		BMessage message(kMsgControllerCaptureStopped);
		message.AddInt32("status", fCaptureThread);
		SendNotices(kMsgControllerCaptureStopped, &message);	
		return;
	}
		
	status_t status = resume_thread(fCaptureThread);
	if (status < B_OK) {
		kill_thread(fCaptureThread);
		BMessage message(kMsgControllerCaptureStopped);
		message.AddInt32("status", status);
		SendNotices(kMsgControllerCaptureStopped, &message);
		return;
	}

	SendNotices(kMsgControllerCaptureStarted);
}
Example #15
0
void
Controller::SetMediaFileFormat(const media_file_format& fileFormat)
{
	BAutolock _(this);
	fEncoder->SetMediaFileFormat(fileFormat);

	Settings().SetOutputFileFormat(fileFormat.pretty_name);
	
	BMessage message(kMsgControllerMediaFileFormatChanged);
	message.AddString("format_name", fileFormat.pretty_name);
	SendNotices(kMsgControllerMediaFileFormatChanged, &message);
	
	UpdateMediaFormatAndCodecsForCurrentFamily();
}
Example #16
0
void
DataView::UpdateFromEditor(BMessage *message)
{
	if (fData == NULL)
		return;

	BAutolock locker(fEditor);

	fFileSize = fEditor.FileSize();

	// get the range of the changes

	int32 start = 0, end = fDataSize - 1;
	off_t offset, size;
	if (message != NULL
		&& message->FindInt64("offset", &offset) == B_OK
		&& message->FindInt64("size", &size) == B_OK) {
		if (offset > fOffset + (off_t)fDataSize
			|| offset + (off_t)size < fOffset) {
			// the changes are not within our scope, so we can ignore them
			return;
		}

		if (offset > fOffset)
			start = offset - fOffset;
		if (offset + (off_t)size < fOffset + (off_t)fDataSize)
			end = offset + size - fOffset;
	}

	if (fOffset + (off_t)fDataSize > fFileSize)
		fSizeInView = fFileSize - fOffset;
	else
		fSizeInView = fDataSize;

	const uint8 *data;
	if (fEditor.GetViewBuffer(&data) == B_OK)
		// ToDo: copy only the relevant part
		memcpy(fData, data, fDataSize);

	InvalidateRange(start, end);

	// we notify our selection listeners also if the
	// data in the selection has changed
	if (start <= fEnd && end >= fStart) {
		BMessage update;
		update.AddInt64("start", fStart);
		update.AddInt64("end", fEnd);
		SendNotices(kDataViewSelection, &update);
	}
}
Example #17
0
void
Controller::_EncodingFinished(const status_t status)
{
	// Deleting the filelist deletes the files referenced by it
	// and also the temporary folder
	delete fFileList;
	fFileList = NULL;
	
	fEncoderThread = -1;
	fNumFrames = 0;
		
	BMessage message(kMsgControllerEncodeFinished);
	message.AddInt32("status", (int32)status);
	SendNotices(kMsgControllerEncodeFinished, &message);
}
Example #18
0
void
Controller::EndCapture()
{
	BAutolock _(this);
	if (fCaptureThread > 0) {
		fPaused = false;
		fKillThread = true;
		status_t unused;
		wait_for_thread(fCaptureThread, &unused);
	}
	
	SendNotices(kMsgControllerCaptureStopped);
	
	EncodeMovie();
}
Example #19
0
void
DataView::SetFontSize(float point)
{
	bool fit = (point == 0.0f);
	if (fit) {
		if (!fFitFontSize)
			SendNotices(kDataViewPreferredSize);
		fFitFontSize = fit;

		FrameResized(Bounds().Width(), Bounds().Height());
		return;
	}

	fFitFontSize = false;

	BFont font = be_fixed_font;
	font.SetSize(point);

	SetFont(&font);
	UpdateScroller();
	Invalidate();

	SendNotices(kDataViewPreferredSize);
}
Example #20
0
void
Controller::SetMediaCodec(const char* codecName)
{
	BAutolock _(this);
	for (int32 i = 0; i < fCodecList->CountItems(); i++) {
		media_codec_info* codec = fCodecList->ItemAt(i);
		if (!strcmp(codec->pretty_name, codecName)) {
			fEncoder->SetMediaCodecInfo(*codec);
			Settings().SetOutputCodec(codec->pretty_name);
			BMessage message(kMsgControllerCodecChanged);
			message.AddString("codec_name", codec->pretty_name);
			SendNotices(kMsgControllerCodecChanged, &message);
			break;
		}
	}
}
Example #21
0
status_t
BSCWindow::_CaptureFinished()
{
	fCapturing = false;

	fStartStopButton->SetEnabled(false);
	fStartStopButton->SetLabel("Start Recording");

	SendNotices(kMsgGUIStopCapture);	

	if (IsHidden())
		Show();
	if (IsMinimized())
		Minimize(false);

	return B_OK;
}
Example #22
0
status_t
BSCWindow::_CaptureStarted()
{
	fCapturing = true;
	
	Settings settings;
						
	if (settings.MinimizeOnRecording())
		Minimize(true);
	
	fCardLayout->SetVisibleItem((int32)0);
	fStatusBar->Reset();
	
	fStartStopButton->SetLabel("Stop Recording");

	SendNotices(kMsgGUIStartCapture);
	
	return B_OK;
}
Example #23
0
status_t
BListView::Invoke(BMessage* message)
{
	// Note, this is more or less a copy of BControl::Invoke() and should
	// stay that way (ie. changes done there should be adopted here)

	bool notify = false;
	uint32 kind = InvokeKind(&notify);

	BMessage clone(kind);
	status_t err = B_BAD_VALUE;

	if (!message && !notify)
		message = Message();

	if (!message) {
		if (!IsWatched())
			return err;
	} else
		clone = *message;

	clone.AddInt64("when", (int64)system_time());
	clone.AddPointer("source", this);
	clone.AddMessenger("be:sender", BMessenger(this));

	if (fListType == B_SINGLE_SELECTION_LIST)
		clone.AddInt32("index", fFirstSelected);
	else {
		if (fFirstSelected >= 0) {
			for (int32 i = fFirstSelected; i <= fLastSelected; i++) {
				if (ItemAt(i)->IsSelected())
					clone.AddInt32("index", i);
			}
		}
	}

	if (message)
		err = BInvoker::Invoke(&clone);

	SendNotices(kind, &clone);

	return err;
}
Example #24
0
// Should be called every time the media_format_family is changed
status_t
Controller::UpdateMediaFormatAndCodecsForCurrentFamily()
{
	BAutolock _(this);
	
	Settings settings;
	BRect targetRect = settings.TargetRect();
	targetRect.right++;
	targetRect.bottom++;
	
	targetRect.PrintToStream();
	
	const int32 frameRate = 10;
	media_format mediaFormat = _ComputeMediaFormat(targetRect.IntegerWidth(),
									targetRect.IntegerHeight(),
									settings.ClipDepth(), frameRate);
	
	fEncoder->SetMediaFormat(mediaFormat);
	
	delete fCodecList;
	fCodecList = new BObjectList<media_codec_info> (1, true);
	
	int32 cookie = 0;
	media_codec_info codec;
	media_format dummyFormat;
	media_file_format fileFormat = fEncoder->MediaFileFormat();
	while (get_next_encoder(&cookie, &fileFormat, &mediaFormat,
			&dummyFormat, &codec) == B_OK) {
		media_codec_info* newCodec = new media_codec_info;
		*newCodec = codec;
		fCodecList->AddItem(newCodec);
	}
		
	SendNotices(kMsgControllerCodecListUpdated);
	return B_OK;
}
Example #25
0
void
TTracker::MessageReceived(BMessage *message)
{
	if (HandleScriptingMessage(message))
		return;

	switch (message->what) {
		case kGetInfo:
			OpenInfoWindows(message);
			break;

		case kMoveToTrash:
			MoveRefsToTrash(message);
			break;

		case kCloseWindowAndChildren:
			{
				const node_ref *itemNode;
				int32 bytes;
				message->FindData("node_ref", B_RAW_TYPE,
					(const void **)&itemNode, &bytes);
				CloseWindowAndChildren(itemNode);
				break;
			}
			
		case kCloseAllWindows:
			CloseAllWindows();
			break;

		case kFindButton:
			(new FindWindow())->Show();
			break;

		case kEditQuery:
			EditQueries(message);
			break;

		case kUnmountVolume:
			//	When the user attempts to unmount a volume from the mount
			//	context menu, this is where the message gets received.  Save
			//	pose locations and forward this to the automounter
			SaveAllPoseLocations();
			fAutoMounter->PostMessage(message);
			break;

		case kRunAutomounterSettings:
			AutomountSettingsDialog::RunAutomountSettings(fAutoMounter);
			break;

		case kShowSplash:
			{
				// The AboutWindow was moved out of the Tracker in preparation
				// for when we open source it. The AboutBox contains important
				// credit and license issues that shouldn't be modified, and
				// therefore shouldn't be open sourced. However, there is a public
				// API for 3rd party apps to tell the Tracker to open the AboutBox.
				run_be_about();
				break;
			}

		case kAddPrinter:
			// show the addprinter window
			run_add_printer_panel();
			break;
			
		case kMakeActivePrinter:
			// get the current selection
			SetDefaultPrinter(message);
			break;

#ifdef MOUNT_MENU_IN_DESKBAR

		case 'gmtv':
			{
				// Someone (probably the deskbar) has requested a list of
				// mountable volumes.
				BMessage reply;
				AutoMounterLoop()->EachMountableItemAndFloppy(&AddMountableItemToMessage,
				  &reply);
				message->SendReply(&reply);
				break;
			}

#endif

		case kMountVolume:
		case kMountAllNow:
			AutoMounterLoop()->PostMessage(message);
			break;


		case kRestoreBackgroundImage:
			{
				BDeskWindow *desktop = GetDeskWindow();
				AutoLock<BWindow> lock(desktop);
				desktop->UpdateDesktopBackgroundImages();
			}
			break;

 		case kShowSettingsWindow:
 			ShowSettingsWindow();
 			break;

		case kFavoriteCountChangedExternally:
			SendNotices(kFavoriteCountChangedExternally, message);
			break;

		case kStartWatchClipboardRefs:
		{
			BMessenger messenger;
			message->FindMessenger("target", &messenger);
			if (messenger.IsValid())
				fClipboardRefsWatcher->AddToNotifyList(messenger);
			break;
		}

		case kStopWatchClipboardRefs:
		{
			BMessenger messenger;
			message->FindMessenger("target", &messenger);
			if (messenger.IsValid())
				fClipboardRefsWatcher->RemoveFromNotifyList(messenger);
			break;
		}

		default:
			_inherited::MessageReceived(message);
			break;
	}
}
void AmTimeView::SetDisplayTime(AmTime newTime)
{
	mTime = newTime;
	SendNotices(ARPMSG_TIME_VIEW_CHANGED);
}
Example #27
0
void
TTracker::MessageReceived(BMessage *message)
{
	if (HandleScriptingMessage(message))
		return;

	switch (message->what) {
		case kGetInfo:
			OpenInfoWindows(message);
			break;

		case kMoveToTrash:
			MoveRefsToTrash(message);
			break;

		case kCloseWindowAndChildren:
			{
				const node_ref *itemNode;
				int32 bytes;
				message->FindData("node_ref", B_RAW_TYPE,
					(const void **)&itemNode, &bytes);
				CloseWindowAndChildren(itemNode);
				break;
			}

		case kCloseAllWindows:
			CloseAllWindows();
			break;

		case kCloseAllInWorkspace:
			CloseAllInWorkspace();
			break;

		case kFindButton:
			(new FindWindow())->Show();
			break;

		case kEditQuery:
			EditQueries(message);
			break;

		case kShowSplash:
			run_be_about();
			break;

		case kAddPrinter:
			// show the addprinter window
			run_add_printer_panel();
			break;

		case kMakeActivePrinter:
			// get the current selection
			SetDefaultPrinter(message);
			break;

#ifdef MOUNT_MENU_IN_DESKBAR

		case 'gmtv':
		{
			// Someone (probably the deskbar) has requested a list of
			// mountable volumes.
			BMessage reply;
			AutoMounterLoop()->EachMountableItemAndFloppy(&AddMountableItemToMessage,
			  &reply);
			message->SendReply(&reply);
			break;
		}

#endif

		case kUnmountVolume:
			// When the user attempts to unmount a volume from the mount
			// context menu, this is where the message gets received.
			// Save pose locations and forward this to the automounter
			SaveAllPoseLocations();
			// Fall through...
		case kMountVolume:
		case kMountAllNow:
			MountServer().SendMessage(message);
			break;

		case kRunAutomounterSettings:
			AutomountSettingsDialog::RunAutomountSettings(MountServer());
			break;

		case kRestoreBackgroundImage:
		{
			BDeskWindow *desktop = GetDeskWindow();
			AutoLock<BWindow> lock(desktop);
			desktop->UpdateDesktopBackgroundImages();
			break;
		}

 		case kShowSettingsWindow:
 			ShowSettingsWindow();
 			break;

		case kFavoriteCountChangedExternally:
			SendNotices(kFavoriteCountChangedExternally, message);
			break;

		case kStartWatchClipboardRefs:
		{
			BMessenger messenger;
			message->FindMessenger("target", &messenger);
			if (messenger.IsValid())
				fClipboardRefsWatcher->AddToNotifyList(messenger);
			break;
		}

		case kStopWatchClipboardRefs:
		{
			BMessenger messenger;
			message->FindMessenger("target", &messenger);
			if (messenger.IsValid())
				fClipboardRefsWatcher->RemoveFromNotifyList(messenger);
			break;
		}

		case kFSClipboardChanges:
			fClipboardRefsWatcher->UpdatePoseViews(message);
			break;

		case kShowVolumeSpaceBar:
		case kSpaceBarColorChanged:
			gPeriodicUpdatePoses.DoPeriodicUpdate(true);
			break;

		case B_LOCALE_CHANGED:
		{
			BLocaleRoster::Default()->Refresh();
			bool localize;
			if (message->FindBool("filesys", &localize) == B_OK)
				gLocalizedNamePreferred = localize;
			break;
		}

		default:
			_inherited::MessageReceived(message);
			break;
	}
}
Example #28
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;
}
Example #29
0
void
DataView::MessageReceived(BMessage *message)
{
	switch (message->what) {
		case kMsgUpdateData:
		case kMsgDataEditorUpdate:
			UpdateFromEditor(message);
			break;

		case kMsgDataEditorParameterChange:
		{
			int32 viewSize;
			off_t offset;
			if (message->FindInt64("offset", &offset) == B_OK) {
				fOffset = offset;
				SetSelection(0, 0);
				MakeVisible(0);
			}
			if (message->FindInt32("view_size", &viewSize) == B_OK) {
				fDataSize = viewSize;
				fData = (uint8 *)realloc(fData, fDataSize);
				UpdateScroller();
				SendNotices(kDataViewPreferredSize);
			}
			if (message->FindInt64("file_size", &offset) == B_OK)
				UpdateFromEditor();
			break;
		}

		case kMsgBaseType:
		{
			int32 type;
			if (message->FindInt32("base", &type) != B_OK)
				break;

			SetBase((base_type)type);
			break;
		}

		case kMsgSetSelection:
		{
			int64 start, end;
			if (message->FindInt64("start", &start) != B_OK
				|| message->FindInt64("end", &end) != B_OK)
				break;

			SetSelection(start, end);
			break;
		}

		case B_SELECT_ALL:
			SetSelection(0, fDataSize - 1);
			break;

		case B_COPY:
			Copy();
			break;

		case B_PASTE:
			Paste();
			break;

		case B_UNDO:
			fEditor.Undo();
			break;

		case B_REDO:
			fEditor.Redo();
			break;

		case B_MIME_DATA:
			if (AcceptsDrop(message)) {
				const void *data;
				ssize_t size;
				if (message->FindData("text/plain", B_MIME_TYPE, &data, &size) == B_OK
					|| message->FindData(B_FILE_MIME_TYPE, B_MIME_TYPE, &data, &size) == B_OK) {
					if (fEditor.Replace(fOffset + fStart, (const uint8 *)data, size) != B_OK)
						SetSelection(fStoredStart, fStoredEnd);

					fDragMessageSize = -1;
				}
			}
			break;

		default:
			BView::MessageReceived(message);
	}
}
Example #30
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;
	}
}