Esempio n. 1
0
void 
BackgroundImage::Show(BackgroundImageInfo *info, BView *view)
{
	BPoseView *poseView = dynamic_cast<BPoseView *>(view);
	if (poseView)
		poseView->SetWidgetTextOutline(info->fTextWidgetOutline);

	if (info->fBitmap == NULL) {
		view->ClearViewBitmap();
		view->Invalidate();
		fShowingBitmap = info;
		return;
	}
	BRect viewBounds(view->Bounds());
	BRect bitmapBounds(info->fBitmap->Bounds());
	BRect destinationBitmapBounds(bitmapBounds);

	uint32 tile = 0;
	uint32 followFlags = B_FOLLOW_TOP | B_FOLLOW_LEFT;

	// figure out the display mode and the destination bounds for the bitmap
	switch (info->fMode) {
		case kCentered:
			if (fIsDesktop) {
				destinationBitmapBounds.OffsetBy(
					(viewBounds.Width() - bitmapBounds.Width()) / 2,
					(viewBounds.Height() - bitmapBounds.Height()) / 2);
				break;
			}
			// else fall thru
		case kScaledToFit:
			if (fIsDesktop) {
				destinationBitmapBounds = viewBounds;
				followFlags = B_FOLLOW_ALL;
				break;
			}
			// else fall thru
		case kAtOffset:
			destinationBitmapBounds.OffsetTo(info->fOffset);
			break;
		case kTiled:
			if (fIsDesktop) {
				destinationBitmapBounds.OffsetBy(
					(viewBounds.Width() - bitmapBounds.Width()) / 2,
					(viewBounds.Height() - bitmapBounds.Height()) / 2);
			}
			tile = B_TILE_BITMAP;
			break;
	}
	
	// switch to the bitmap and force a redraw
	view->SetViewBitmap(info->fBitmap, bitmapBounds, destinationBitmapBounds,
		followFlags, tile);
	view->Invalidate();
	fShowingBitmap = info;
}
Esempio n. 2
0
void 
BackgroundImage::Remove()
{
	if (fShowingBitmap) {
		fView->ClearViewBitmap();
		fView->Invalidate();
		BPoseView *poseView = dynamic_cast<BPoseView *>(fView);
		// make sure text widgets draw the default way, erasing their background
		if (poseView)
			poseView->SetWidgetTextOutline(true);
	}
	fShowingBitmap = NULL;
}
Esempio n. 3
0
void 
BackgroundImage::Show(BView *view, int32 workspace)
{
	fView = view;

	BackgroundImageInfo *info = ImageInfoForWorkspace(workspace);
	if (info) {
		BPoseView *poseView = dynamic_cast<BPoseView *>(fView);
		if (poseView)
			poseView->SetWidgetTextOutline(info->fTextWidgetOutline);
		Show(info, fView);
	}
}
Esempio n. 4
0
void
ColumnResizeState::DrawLine()
{
	BPoseView *poseView = fTitleView->PoseView();
	ASSERT(!poseView->IsDesktopWindow());

	BRect poseViewBounds(poseView->Bounds());
	// remember the line location
	poseViewBounds.left = fTitle->Bounds().right;
	fLastLineDrawPos = poseViewBounds.left;

	// draw the line in the new location
	_DrawLine(poseView, poseViewBounds.LeftTop(), poseViewBounds.LeftBottom());
}
Esempio n. 5
0
void
ColumnResizeState::Moved(BPoint where, uint32)
{
	float newWidth = where.x + fInitialTrackOffset - fTitle->fColumn->Offset();
	if (newWidth < kMinColumnWidth)
		newWidth = kMinColumnWidth;
	
	BPoseView *poseView = fTitleView->PoseView();

//	bool shrink = (newWidth < fTitle->fColumn->Width());

	// resize the column 
	poseView->ResizeColumn(fTitle->fColumn, newWidth, &fLastLineDrawPos,
		_DrawLine, _UndrawLine);

	BRect bounds(fTitleView->Bounds());
	bounds.left = fTitle->fColumn->Offset();

	// force title redraw
	fTitleView->Draw(bounds, true, false); 
}
Esempio n. 6
0
bool 
TTracker::SelectChildInParent(const entry_ref *parent, const node_ref *child)
{
	AutoLock<WindowList> lock(&fWindowList);
	
	BContainerWindow *window = FindContainerWindow(parent);
	if (!window) 
		// parent window already closed, give up
		return false;

	AutoLock<BWindow> windowLock(window);
	
	if (windowLock.IsLocked()) {
		BPoseView *view = window->PoseView();
		int32 index;
		BPose *pose = view->FindPose(child, &index);
		if (pose) {
			view->SelectPose(pose, index);
			return true;
		}
	}
	return false;	
}
Esempio n. 7
0
static filter_result
TextViewFilter(BMessage* message, BHandler**, BMessageFilter* filter)
{
	uchar key;
	if (message->FindInt8("byte", (int8*)&key) != B_OK)
		return B_DISPATCH_MESSAGE;

	ThrowOnAssert(filter != NULL);

	BContainerWindow* window = dynamic_cast<BContainerWindow*>(
		filter->Looper());
	ThrowOnAssert(window != NULL);

	BPoseView* poseView = window->PoseView();
	ThrowOnAssert(poseView != NULL);

	if (key == B_RETURN || key == B_ESCAPE) {
		poseView->CommitActivePose(key == B_RETURN);
		return B_SKIP_MESSAGE;
	}

	if (key == B_TAB) {
		if (poseView->ActivePose()) {
			if (message->FindInt32("modifiers") & B_SHIFT_KEY)
				poseView->ActivePose()->EditPreviousWidget(poseView);
			else
				poseView->ActivePose()->EditNextWidget(poseView);
		}

		return B_SKIP_MESSAGE;
	}

	// the BTextView doesn't respect window borders when resizing itself;
	// we try to work-around this "bug" here.

	// find the text editing view
	BView* scrollView = poseView->FindView("BorderView");
	if (scrollView != NULL) {
		BTextView* textView = dynamic_cast<BTextView*>(
			scrollView->FindView("WidgetTextView"));
		if (textView != NULL) {
			BRect rect = scrollView->Frame();

			if (rect.right + 3 > poseView->Bounds().right
				|| rect.left - 3 < 0)
				textView->MakeResizable(true, NULL);
		}
	}

	return B_DISPATCH_MESSAGE;
}
Esempio n. 8
0
static filter_result
key_down_filter(BMessage* message, BHandler** handler, BMessageFilter* filter)
{
	ASSERT(filter != NULL);
	if (filter == NULL)
		return B_DISPATCH_MESSAGE;

	TFilePanel* panel = dynamic_cast<TFilePanel*>(filter->Looper());
	ASSERT(panel != NULL);

	if (panel == NULL)
		return B_DISPATCH_MESSAGE;

	BPoseView* view = panel->PoseView();
	if (panel->TrackingMenu())
		return B_DISPATCH_MESSAGE;

	uchar key;
	if (message->FindInt8("byte", (int8*)&key) != B_OK)
		return B_DISPATCH_MESSAGE;

	int32 modifier = 0;
	message->FindInt32("modifiers", &modifier);
	if (!modifier && key == B_ESCAPE) {
		if (view->ActivePose())
			view->CommitActivePose(false);
		else if (view->IsFiltering())
			filter->Looper()->PostMessage(B_CANCEL, *handler);
		else
			filter->Looper()->PostMessage(kCancelButton);

		return B_SKIP_MESSAGE;
	}

	if (key == B_RETURN && view->ActivePose()) {
		view->CommitActivePose();

		return B_SKIP_MESSAGE;
	}

	return B_DISPATCH_MESSAGE;
}
Esempio n. 9
0
void
ColumnDragState::Clicked(BPoint /*where*/)
{
	BPoseView *poseView = fTitleView->PoseView();
	uint32 hash = fTitle->Column()->AttrHash();
	uint32 primarySort = poseView->PrimarySort();
	uint32 secondarySort = poseView->SecondarySort();
	bool shift = (modifiers() & B_SHIFT_KEY) != 0;
	
	// For now:
	// if we hit the primary sort field again
	// then if shift key was down, switch primary and secondary
	if (hash == primarySort) {
		if (shift && secondarySort) {
			poseView->SetPrimarySort(secondarySort);
			poseView->SetSecondarySort(primarySort);
		} else
			poseView->SetReverseSort(!poseView->ReverseSort());
	} else if (shift) {
		// hit secondary sort column with shift key, disable
		if (hash == secondarySort)
			poseView->SetSecondarySort(0);
		else
			poseView->SetSecondarySort(hash);
	} else {
		poseView->SetPrimarySort(hash);
		poseView->SetReverseSort(false);
	}

	if (poseView->PrimarySort() == poseView->SecondarySort())
		poseView->SetSecondarySort(0);

	UndrawOutline();

	poseView->SortPoses();
	poseView->Invalidate();
}
/*!
	\brief Tracker add-on entry
*/
extern "C" void
process_refs(entry_ref dir, BMessage* refs, void* /*reserved*/)
{
	status_t status;
	BAlert *alert;
	BMessenger msgr;
	BPoseView *view = NULL;
	BMessage poseViewBackup;
	BMessage poseViewColumnBackup;
	uint32 poseViewModeBackup;
	BString windowTitleBackup;

	refs->PrintToStream();
	
	status = refs->FindMessenger("TrackerViewToken", &msgr);
	if (status < B_OK) {
		Error(view, status);
		return;
	}

	status = B_ERROR;
	if (!msgr.LockTarget()) {
		Error(view, status);
		return;
	}

	status = B_BAD_HANDLER;
	view = dynamic_cast<BPoseView *>(msgr.Target(NULL));
	if (!view) {
		Error(view, status);
		return;
	}
	if (dynamic_cast<BWindow *>(view->Looper()) == NULL) {
		Error(view, status, true);
		return;
	}

	windowTitleBackup = view->Window()->Title();

	view->SaveColumnState(poseViewColumnBackup);
	view->SaveState(poseViewBackup);
	view->SetDragEnabled(false);
	view->SetSelectionRectEnabled(false);
	view->SetPoseEditing(false);
	poseViewModeBackup = view->ViewMode();
	

	view->SetViewMode(kIconMode);

	view->ShowBarberPole();


	view->UnlockLooper();



	alert = new BAlert("Error", "IconVader:\nClick on the icons to get points."
		"\nAvoid symlinks!", "OK");
	alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
	alert->Go();


	int32 score = 0;
	int32 count = 300;
	while (count--) {
		status = B_ERROR;
		if (!msgr.LockTarget()) {
			Error(view, status);
			return;
		}

		BPose *pose;
		for (int32 i = 0; (pose = view->PoseAtIndex(i)); i++) {
			if (pose->IsSelected()) {
				if (pose->TargetModel()->IsFile())
					score++;
				if (pose->TargetModel()->IsDirectory())
					score+=2;
				if (pose->TargetModel()->IsSymLink())
					score-=10;
				pose->Select(false);
			}
#ifdef __HAIKU__
			BPoint location = pose->Location(view);
#else
			BPoint location = pose->Location();
#endif
			location.x += ((rand() % 20) - 10);
			location.y += ((rand() % 20) - 10);
#ifdef __HAIKU__
			pose->SetLocation(location, view);
#else
			pose->SetLocation(location);
#endif
		}

		view->CheckPoseVisibility();

		view->Invalidate();

		BString str("Score: ");
		str << score;
		view->Window()->SetTitle(str.String());
		
		view->UnlockLooper();
		snooze(100000);
	}

	BString scoreStr("You scored ");
	scoreStr << score << " points!";
	alert = new BAlert("Error", scoreStr.String(), "Cool!");
	alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
	alert->Go();


	status = B_ERROR;
	if (!msgr.LockTarget()) {
		Error(view, status);
		return;
	}

	/*
	status = B_BAD_HANDLER;
	view = dynamic_cast<BPoseView *>(msgr.Target(NULL));
	if (!view)
		goto err1;
	*/

	view->HideBarberPole();
	view->SetViewMode(poseViewModeBackup);
	view->RestoreState(poseViewBackup);
	view->RestoreColumnState(poseViewColumnBackup);

	view->Window()->SetTitle(windowTitleBackup.String());
	
/*
	BMessage('_RRC') {
        TrackerViewToken = BMessenger(port=32004, team=591, target=direct:0x131)
} */


	//be_roster->Launch("application/x-vnd.haiku-filetypes", refs);
	
	view->UnlockLooper();
	return;

}