示例#1
0
MethodReplicant::MethodReplicant(const char* signature)
	:
	BView(BRect(0, 0, 15, 15), REPLICANT_CTL_NAME, B_FOLLOW_ALL, B_WILL_DRAW),
	fMenu("", false, false)
{
	// Background Bitmap
	fSegments = new BBitmap(BRect(0, 0, kRemoteWidth - 1, kRemoteHeight - 1),
		kRemoteColorSpace);
	fSegments->SetBits(kRemoteBits, kRemoteWidth * kRemoteHeight, 0,
		kRemoteColorSpace);
	// Background Color

	// add dragger
	BRect rect(Bounds());
	rect.left = rect.right - 7.0;
	rect.top = rect.bottom - 7.0;
	BDragger* dragger = new BDragger(rect, this,
		B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	dragger->SetViewColor(B_TRANSPARENT_32_BIT);
	AddChild(dragger);

	ASSERT(signature != NULL);
	fSignature = strdup(signature);

	fMenu.SetFont(be_plain_font);
	fMenu.SetRadioMode(true);
}
示例#2
0
文件: Shelf.cpp 项目: mariuz/haiku
filter_result
ShelfContainerViewFilter::_ObjectDropFilter(BMessage *msg, BHandler **_handler)
{
	BView *mouseView = NULL;
	if (*_handler)
		mouseView = dynamic_cast<BView*>(*_handler);

	if (msg->WasDropped()) {
		if (!fShelf->fAllowDragging) {
			printf("Dragging replicants isn't allowed to this shelf.");
			beep();
			return B_SKIP_MESSAGE;
		}
	}

	BPoint point;
	BPoint offset;

	if (msg->WasDropped()) {
		point = msg->DropPoint(&offset);
		point = mouseView->ConvertFromScreen(point - offset);
	}

	BLooper *looper = NULL;
	BHandler *handler = msg->ReturnAddress().Target(&looper);

	if (Looper() == looper) {
		BDragger *dragger = NULL;
		if (handler)
			dragger = dynamic_cast<BDragger*>(handler);

		BRect rect;
		if (dragger->fRelation == BDragger::TARGET_IS_CHILD)
			rect = dragger->Frame();
		else
			rect = dragger->fTarget->Frame();
		rect.OffsetTo(point);
		point = rect.LeftTop() + fShelf->AdjustReplicantBy(rect, msg);

		if (dragger->fRelation == BDragger::TARGET_IS_PARENT)
			dragger->fTarget->MoveTo(point);
		else if (dragger->fRelation == BDragger::TARGET_IS_CHILD)
			dragger->MoveTo(point);
		else {
			//TODO: TARGET_UNKNOWN/TARGET_SIBLING
		}

	} else {
		if (fShelf->_AddReplicant(msg, &point, fShelf->fGenCount++) == B_OK)
			Looper()->DetachCurrentMessage();
	}

	return B_SKIP_MESSAGE;
}
示例#3
0
Window::Window(BRect rect)
	: BWindow( rect, "QueryWatcher", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS)
{
	fBackground = new ReplicantView( Bounds() );
	fBackground->SetViewColor(B_TRANSPARENT_COLOR);

	BRect draggerFrame = Bounds();
	draggerFrame.top = draggerFrame.bottom - 7;
	draggerFrame.left = draggerFrame.right - 7;

	BDragger* dragger = new BDragger(draggerFrame, fBackground);
	dragger->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(fBackground);
	fBackground->AddChild(dragger);
	
	
}
示例#4
0
FrissWindow::FrissWindow(FrissConfig* config, XmlNode* theList, BRect frame,
	const char* Title) : 
	BWindow(frame, Title, B_TITLED_WINDOW,
		B_FRAME_EVENTS | B_AUTO_UPDATE_SIZE_LIMITS)
{	
	SetLayout(new BGroupLayout(B_VERTICAL));
	BGridView* background = new BGridView("background");
	background->GridLayout()->SetSpacing(0, 0);
	background->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(background);

	feedList = new BListView("feedlist", B_SINGLE_SELECTION_LIST);
	myf = new FrissView(config, theList);

	/* Nun noch den Dragger einbauen.
	 * B_ORIGIN scheint unten rechts zu sein, also noch entsprechend
	 * die linke obere Ecke setzen (ich wusste vorher auch nicht, dass
	 * der Dragger 7x7 Pixel groß ist :-)
	 */
	BDragger* myd = new BDragger(myf, B_WILL_DRAW );
	myd->SetExplicitMaxSize(BSize(7, 7));

	BGridLayoutBuilder(background)
		.SetInsets(7, 7, 0, 0)
		.Add(new BScrollView("scroll", feedList, 0, false, true), 0, 0)
		.Add(myf, 1, 0)
		.Add(myd, 2, 1);

	background->GridLayout()->SetColumnWeight(0, 0.4);
	background->GridLayout()->SetMaxColumnWidth(0, 200);

	BMessage* m = new BMessage(msg_SelFeed);
	feedList->SetSelectionMessage(m);

	m = new BMessage(msg_EditFeed);
	feedList->SetInvocationMessage(m);

	PopulateFeeds(theList);
}