Пример #1
0
status_t
TWindowMenuItem::Invoke(BMessage* /*message*/)
{
	if (!fDragging) {
		if (fID >= 0) {
			int32 action = (modifiers() & B_CONTROL_KEY) != 0
				? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT;

			bool doZoom = false;
			BRect zoomRect(0.0f, 0.0f, 0.0f, 0.0f);
			BMenuItem* item;
			if (!fExpanded)
				item = Menu()->Superitem();
			else
				item = this;

			if (item->Menu()->Window() != NULL) {
				zoomRect = item->Menu()->ConvertToScreen(item->Frame());
				doZoom = (fMini && action == B_BRING_TO_FRONT)
					|| (!fMini && action == B_MINIMIZE_WINDOW);
			}

			do_window_action(fID, action, zoomRect, doZoom);
		}
	}
	return B_OK;
}
Пример #2
0
status_t
PMenuItem::GetProperty(const char *name, PValue *value, const int32 &index) const
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	BMenuItem *backend = (BMenuItem*)fBackend;
	if (str.ICompare("Message") == 0)
		((IntProperty*)prop)->SetValue(backend->Command());
	else if (str.ICompare("Trigger") == 0)
		((CharProperty*)prop)->SetValue(backend->Trigger());
	else if (str.ICompare("Label") == 0)
		((StringProperty*)prop)->SetValue(backend->Label());
	else if (str.ICompare("Frame") == 0)
		((RectProperty*)prop)->SetValue(backend->Frame());
	else if (str.ICompare("Marked") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsMarked());
	else if (str.ICompare("Enabled") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsEnabled());
	else
	{
		return PObject::GetProperty(name, value, index);
	}

	return prop->GetValue(value);
}
Пример #3
0
/*!	Returns the team menu item that belongs to the item under the
	specified \a point.
	If \a _item is given, it will return the exact menu item under
	that point (which might be a window item when the expander is on).
*/
TTeamMenuItem*
TExpandoMenuBar::TeamItemAtPoint(BPoint point, BMenuItem** _item)
{
	TTeamMenuItem* lastApp = NULL;
	int32 count = CountItems();

	for (int32 i = fFirstApp; i < count; i++) {
		BMenuItem* item = ItemAt(i);

		if (dynamic_cast<TTeamMenuItem*>(item) != NULL)
			lastApp = (TTeamMenuItem*)item;

		if (item && item->Frame().Contains(point)) {
			if (_item != NULL)
				*_item = item;

			return lastApp;
		}
	}

	// no item found

	if (_item != NULL)
		*_item = NULL;

	return NULL;
}
status_t
TShowHideMenuItem::Invoke(BMessage *)
{
	bool doZoom = false;
	BRect zoomRect(0, 0, 0, 0);
	BMenuItem *item = Menu()->Superitem();

	if (item->Menu()->Window() != NULL) { 
		zoomRect = item->Menu()->ConvertToScreen(item->Frame());
		doZoom = true;
	}
	return TeamShowHideCommon(static_cast<int32>(fAction), fTeams, zoomRect, doZoom);
}
/*!	\brief	Update menu of years
 *	\details	After the user selects another year, the whole 
 *				years' menu should be changed. The selected year
 *				becomes the middle of the menu, with years before
 *				and after it surrounding it from top and bottom
 *				(respectively).
 *	\param[in]	prevYear		The year that was previously selected.
 *	\param[in]	curYear		The year that is selected now.
 */
void CalendarControl::UpdateYearsMenu(int prevYear, int curYear) {
	BMenuItem* item; BMenu* menu;
	BString sb;
	BRect fr;
	sb << prevYear;
	if (!fDateSelector) return;
	if ( (item = fDateSelector->FindItem(sb.String())) == NULL) {
		return;
	}
	fr = item->Frame();
	fDateSelector->RemoveItem( item );
	delete item;
	menu = CreateYearsMenu( curYear );
	if ( menu ) {
		fDateSelector->AddItem( menu, fr );
	}
}	// <-- end of function "CalendarControl::UpdateYearsMenu"
Пример #6
0
void
BMenuField::AllAttached()
{
	CALLED();

	TRACE("width: %.2f, height: %.2f\n", Frame().Width(), Frame().Height());

	float width = Bounds().Width();
	if (!fFixedSizeMB && _MenuBarWidth() < kMinMenuBarWidth) {
		// The menu bar is too narrow, resize it to fit the menu items
		BMenuItem* item = fMenuBar->ItemAt(0);
		if (item != NULL) {
			float right;
			fMenuBar->GetItemMargins(NULL, NULL, &right, NULL);
			width = item->Frame().Width() + kVMargin + _MenuBarOffset() + right;
		}
	}

	ResizeTo(width, fMenuBar->Bounds().Height() + kVMargin * 2);

	TRACE("width: %.2f, height: %.2f\n", Frame().Width(), Frame().Height());
}