示例#1
0
文件: Pose.cpp 项目: mylegacy/haiku
void
BPose::DeselectWithoutErasingBackground(BRect, BPoseView* poseView)
{
	ASSERT(poseView->ViewMode() != kListMode);
	ASSERT(!IsSelected());

	BPoint location(Location(poseView));

	// draw icon directly
	if (fPercent == -1)
		DrawIcon(location, poseView, poseView->IconSize(), true);
	else
		UpdateIcon(location, poseView);

	BColumn* column = poseView->FirstColumn();
	if (column == NULL)
		return;

	BTextWidget* widget = WidgetFor(column->AttrHash());
	if (widget == NULL || !widget->IsVisible())
		return;

	// just invalidate the background, don't draw anything
	poseView->Invalidate(widget->CalcRect(location, 0, poseView));
}
示例#2
0
文件: Pose.cpp 项目: mylegacy/haiku
bool
BPose::PointInPose(BPoint loc, const BPoseView* poseView, BPoint where,
	BTextWidget** hitWidget) const
{
	if (hitWidget)
		*hitWidget = NULL;

	// check intersection with icon
	BRect rect;
	rect.left = loc.x + kListOffset;
	rect.right = rect.left + B_MINI_ICON;
	rect.bottom = loc.y + poseView->ListElemHeight();
	rect.top = rect.bottom - B_MINI_ICON;
	if (rect.Contains(where))
		return true;

	for (int32 index = 0; ; index++) {
		BColumn* column = poseView->ColumnAt(index);
		if (column == NULL)
			break;
		BTextWidget* widget = WidgetFor(column->AttrHash());
		if (widget
			&& widget->CalcClickRect(loc, column, poseView).Contains(where)) {
			if (hitWidget)
				*hitWidget = widget;
			return true;
		}
	}

	return false;
}
示例#3
0
文件: Pose.cpp 项目: mylegacy/haiku
void
BPose::EditPreviousNextWidgetCommon(BPoseView* poseView, bool next)
{
	bool found = false;
	int32 delta = next ? 1 : -1;
	for (int32 index = next ? 0 : poseView->CountColumns() - 1; ;
			index += delta) {
		BColumn* column = poseView->ColumnAt(index);
		if (column == NULL)
			break;

		BTextWidget* widget = WidgetFor(column->AttrHash());
		if (widget != NULL && widget->IsActive()) {
			poseView->CommitActivePose();
			found = true;
			continue;
		}

		if (found && column->Editable()) {
			BRect bounds;
			if (poseView->ViewMode() == kListMode) {
				int32 poseIndex = poseView->IndexOfPose(this);
				BPoint poseLoc(0, poseIndex* poseView->ListElemHeight());
				bounds = widget->CalcRect(poseLoc, column, poseView);
			} else
				bounds = widget->CalcRect(Location(poseView), 0, poseView);

			widget->StartEdit(bounds, poseView, this);
			break;
		}
	}
}
示例#4
0
void
OpenWithPoseView::SetUpDefaultColumnsIfNeeded()
{
	// in case there were errors getting some columns
	if (fColumnList->CountItems() != 0)
		return;

	BColumn* nameColumn = new BColumn(B_TRANSLATE("Name"), kColumnStart, 125,
		B_ALIGN_LEFT, kAttrStatName, B_STRING_TYPE, true, true);
	fColumnList->AddItem(nameColumn);
	BColumn* relationColumn = new BColumn(B_TRANSLATE("Relation"), 180, 100,
		B_ALIGN_LEFT, kAttrOpenWithRelation, B_STRING_TYPE, false, false);
	fColumnList->AddItem(relationColumn);
	fColumnList->AddItem(new BColumn(B_TRANSLATE("Location"), 290, 225,
		B_ALIGN_LEFT, kAttrPath, B_STRING_TYPE, true, false));
	fColumnList->AddItem(new BColumn(B_TRANSLATE("Version"), 525, 70,
		B_ALIGN_LEFT, kAttrAppVersion, B_STRING_TYPE, false, false));

	// sort by relation and by name
	SetPrimarySort(relationColumn->AttrHash());
	SetSecondarySort(nameColumn->AttrHash());
}
示例#5
0
文件: Pose.cpp 项目: mylegacy/haiku
void
BPose::EditFirstWidget(BPoint poseLoc, BPoseView* poseView)
{
	// find first editable widget
	BColumn* column;
	for (int32 i = 0;(column = poseView->ColumnAt(i)) != NULL;i++) {
		BTextWidget* widget = WidgetFor(column->AttrHash());

		if (widget && widget->IsEditable()) {
			BRect bounds;
			// ToDo:
			// fold the three StartEdit code sequences into a cover call
			if (poseView->ViewMode() == kListMode)
				bounds = widget->CalcRect(poseLoc, column, poseView);
			else
				bounds = widget->CalcRect(Location(poseView), NULL, poseView);
			widget->StartEdit(bounds, poseView, this);
			break;
		}
	}
}
示例#6
0
文件: Pose.cpp 项目: mylegacy/haiku
void
BPose::UpdateWidgetAndModel(Model* resolvedModel, const char* attrName,
	uint32 attrType, int32, BPoint poseLoc, BPoseView* poseView, bool visible)
{
	if (poseView->ViewMode() != kListMode)
		poseLoc = Location(poseView);

	ASSERT(resolvedModel == NULL || resolvedModel->IsNodeOpen());

	if (attrName != NULL) {
		// pick up new attributes and find out if icon needs updating
		if (resolvedModel->AttrChanged(attrName) && visible)
			UpdateIcon(poseLoc, poseView);

		// ToDo: the following code is wrong, because this sort of hashing
		// may overlap and we get aliasing
		uint32 attrHash = AttrHashString(attrName, attrType);
		BTextWidget* widget = WidgetFor(attrHash);
		if (widget) {
			BColumn* column = poseView->ColumnFor(attrHash);
			if (column)
				widget->CheckAndUpdate(poseLoc, column, poseView, visible);
		} else if (attrType == 0) {
			// attribute got likely removed, so let's search the
			// column for the matching attribute name
			int32 count = fWidgetList.CountItems();
			for (int32 i = 0; i < count; i++) {
				BTextWidget* widget = fWidgetList.ItemAt(i);
				BColumn* column = poseView->ColumnFor(widget->AttrHash());
				if (column != NULL && !strcmp(column->AttrName(), attrName)) {
					widget->CheckAndUpdate(poseLoc, column, poseView,
						visible);
					break;
				}
			}
		}
	} else {
		// no attr name means check all widgets for stat info changes

		// pick up stat changes
		if (resolvedModel && resolvedModel->StatChanged()) {
			if (resolvedModel->InitCheck() != B_OK)
				return;

			if (visible)
				UpdateIcon(poseLoc, poseView);
		}

		// distribute stat changes
		for (int32 index = 0; ; index++) {
			BColumn* column = poseView->ColumnAt(index);
			if (column == NULL)
				break;

			if (column->StatField()) {
				BTextWidget* widget = WidgetFor(column->AttrHash());
				if (widget) {
					widget->CheckAndUpdate(poseLoc, column, poseView,
						visible);
				}
			}
		}
	}
}