Ejemplo n.º 1
0
TBarView::TBarView(BRect frame, bool vertical, bool left, bool top,
	int32 state, float)
	:
	BView(frame, "BarView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW),
	fBarApp(static_cast<TBarApp*>(be_app)),
	fInlineScrollView(NULL),
	fBarMenuBar(NULL),
	fExpandoMenuBar(NULL),
	fTrayLocation(1),
	fVertical(vertical),
	fTop(top),
	fLeft(left),
	fState(state),
	fRefsRcvdOnly(true),
	fDragMessage(NULL),
	fCachedTypesList(NULL),
	fMaxRecentDocs(kDefaultRecentDocCount),
	fMaxRecentApps(kDefaultRecentAppCount),
	fLastDragItem(NULL),
	fMouseFilter(NULL)
{
	// determine the initial Be menu size
	BRect menuFrame(frame);
	if (fVertical)
		menuFrame.bottom = menuFrame.top + kMenuBarHeight;
	else
		menuFrame.bottom = menuFrame.top + fBarApp->IconSize() + 4;

	// create and add the Be menu
	fBarMenuBar = new TBarMenuBar(menuFrame, "BarMenuBar", this);
	AddChild(fBarMenuBar);

	// create and add the status tray
	fReplicantTray = new TReplicantTray(this, fVertical);
	fDragRegion = new TDragRegion(this, fReplicantTray);
	fDragRegion->AddChild(fReplicantTray);
	if (fTrayLocation != 0)
		AddChild(fDragRegion);

	// create and add the application menubar
	fExpandoMenuBar = new TExpandoMenuBar(BRect(0, 0, 0, 0),
		"ExpandoMenuBar", this, fVertical);
	fInlineScrollView = new TInlineScrollView(BRect(0, 0, 0, 0),
		fExpandoMenuBar, fVertical ? B_VERTICAL : B_HORIZONTAL);
	AddChild(fInlineScrollView);

	// If mini mode, hide the application menubar
	if (state == kMiniState)
		fInlineScrollView->Hide();
}
Ejemplo n.º 2
0
void
TBarView::PlaceDeskbarMenu()
{
	// Calculate the size of the deskbar menu
	BRect menuFrame(Bounds());
	if (fVertical)
		menuFrame.bottom = menuFrame.top + kMenuBarHeight;
	else {
		menuFrame.bottom = menuFrame.top
			+ static_cast<TBarApp*>(be_app)->IconSize() + 4;
	}

	if (fBarMenuBar == NULL) {
		// create the Be menu
		fBarMenuBar = new TBarMenuBar(this, menuFrame, "BarMenuBar");
		AddChild(fBarMenuBar);
	} else
		fBarMenuBar->SmartResize(-1, -1);

	float width = sMinimumWindowWidth;
	BPoint loc(B_ORIGIN);

	if (fState == kFullState) {
		fBarMenuBar->RemoveTeamMenu();
		fBarMenuBar->RemoveSeperatorItem();
		// TODO: Magic constants need explanation
		width = 8 + 16 + 8;
		fBarMenuBar->SmartResize(width, menuFrame.Height());
		loc = Bounds().LeftTop();
	} else if (fState == kExpandoState) {
		fBarMenuBar->RemoveTeamMenu();
		if (fVertical) {
			// shows apps below tray
			fBarMenuBar->RemoveSeperatorItem();
			width += 1;
		} else {
			// shows apps to the right of bemenu
			fBarMenuBar->AddSeperatorItem();
			width = floorf(width) / 2 + kSepItemWidth;
		}
		loc = Bounds().LeftTop();
	} else {
		// mini mode, DeskbarMenu next to team menu
		fBarMenuBar->RemoveSeperatorItem();
		fBarMenuBar->AddTeamMenu();
	}

	fBarMenuBar->SmartResize(width, menuFrame.Height());
	fBarMenuBar->MoveTo(loc);
}
Ejemplo n.º 3
0
void
TBarView::PlaceBeMenu()
{
	// top or bottom, full
	if (!fVertical && fBarMenuBar) {
		fBarMenuBar->RemoveSelf();
		delete fBarMenuBar;
		fBarMenuBar = NULL;
	}

	//	top or bottom expando mode has Be menu built in for tracking
	//	only for vertical mini or expanded
	//	mini mode will have team menu added as part of BarMenuBar
	if (fVertical && !fBarMenuBar) {
		//	create the Be menu
		BRect mbarFrame(Bounds());
		mbarFrame.bottom = mbarFrame.top + kMenuBarHeight;
		fBarMenuBar = new TBarMenuBar(this, mbarFrame, "BarMenuBar");
		AddChild(fBarMenuBar);
	}

	//	if there isn't a bemenu at this point,
	//	DB should be in top/bottom mode, else error
	if (!fBarMenuBar)
		return;
		
	float width = sMinimumWindowWidth;
	BPoint loc(B_ORIGIN);
	BRect menuFrame(fBarMenuBar->Frame());
	if (fState == kFullState) {
		fBarMenuBar->RemoveTeamMenu();
		width = 8 + 16 + 8;
		loc = Bounds().LeftTop();
	} else if (fState == kExpandoState) {
		// shows apps below tray
		fBarMenuBar->RemoveTeamMenu();
		if (fVertical)
			width += 1;
		else
			width = floorf(width) / 2;
		loc = Bounds().LeftTop();
	} else 
		// mini mode, BeMenu next to team menu
		fBarMenuBar->AddTeamMenu();

	fBarMenuBar->SmartResize(width, menuFrame.Height());
	fBarMenuBar->MoveTo(loc);
}