当前位置: 首页>>代码示例>>C++>>正文


C++ BList::Items方法代码示例

本文整理汇总了C++中BList::Items方法的典型用法代码示例。如果您正苦于以下问题:C++ BList::Items方法的具体用法?C++ BList::Items怎么用?C++ BList::Items使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BList的用法示例。


在下文中一共展示了BList::Items方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CountItems

void
PlaylistListView::Randomize()
{
    int32 count = CountItems();
    if (count == 0)
        return;

    BList indices;

    // add current selection
    count = 0;
    while (true) {
        int32 index = CurrentSelection(count);
        if (index < 0)
            break;
        if (!indices.AddItem((void*)index))
            return;
        count++;
    }

    // was anything selected?
    if (count == 0) {
        // no selection, simply add all items
        count = CountItems();
        for (int32 i = 0; i < count; i++) {
            if (!indices.AddItem((void*)i))
                return;
        }
    }

    fCommandStack->Perform(new (nothrow) RandomizePLItemsCommand(fPlaylist,
                           (int32*)indices.Items(), indices.CountItems()));
}
开发者ID:mmanley,项目名称:Antares,代码行数:33,代码来源:PlaylistListView.cpp

示例2: SortItemsInThisLevel

BList* ColumnListView::SortItemsInThisLevel(int32 OriginalListStartIndex)
{
	uint32 ThisLevel = ((CLVListItem*)fFullItemList.ItemAt(OriginalListStartIndex))->fOutlineLevel;

	//Create a new BList of the items in this level
	int32 Counter = OriginalListStartIndex;
	int32 ItemsInThisLevel = 0;
	BList* ThisLevelItems = new BList(16);
	while(true)
	{
		CLVListItem* ThisItem = (CLVListItem*)fFullItemList.ItemAt(Counter);
		if(ThisItem == NULL)
			break;
		uint32 ThisItemLevel = ThisItem->fOutlineLevel;
		if(ThisItemLevel == ThisLevel)
		{
			ThisLevelItems->AddItem(ThisItem);
			ItemsInThisLevel++;
		}
		else if(ThisItemLevel < ThisLevel)
			break;
		Counter++;
	}

	//Sort the BList of the items in this level
	CLVListItem** SortArray = new CLVListItem*[ItemsInThisLevel];
	CLVListItem** ListItems = (CLVListItem**)ThisLevelItems->Items();
	for(Counter = 0; Counter < ItemsInThisLevel; Counter++)
		SortArray[Counter] = ListItems[Counter];
	ThisLevelItems->MakeEmpty();
	SortListArray(SortArray,ItemsInThisLevel);
	for(Counter = 0; Counter < ItemsInThisLevel; Counter++)
		ThisLevelItems->AddItem(SortArray[Counter]);
	return ThisLevelItems;
}
开发者ID:mariuz,项目名称:haiku,代码行数:35,代码来源:ColumnListView.cpp

示例3: ResetTransformationCommand

// MessageReceived
void
ShapeListView::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case MSG_REMOVE:
			RemoveSelected();
			break;
		case MSG_DUPLICATE: {
			int32 count = CountSelectedItems();
			int32 index = 0;
			BList items;
			for (int32 i = 0; i < count; i++) {
				index = CurrentSelection(i);
				BListItem* item = ItemAt(index);
				if (item)
					items.AddItem((void*)item);
			}
			CopyItems(items, index + 1);
			break;
		}
		case MSG_RESET_TRANSFORMATION: {
			BList shapes;
			_GetSelectedShapes(shapes);
			int32 count = shapes.CountItems();
			if (count < 0)
				break;

			Transformable* transformables[count];
			for (int32 i = 0; i < count; i++) {
				Shape* shape = (Shape*)shapes.ItemAtFast(i);
				transformables[i] = shape;
			}

			ResetTransformationCommand* command = 
				new ResetTransformationCommand(transformables, count);

			fCommandStack->Perform(command);
			break;
		}
		case MSG_FREEZE_TRANSFORMATION: {
			BList shapes;
			_GetSelectedShapes(shapes);
			int32 count = shapes.CountItems();
			if (count < 0)
				break;

			FreezeTransformationCommand* command = 
				new FreezeTransformationCommand((Shape**)shapes.Items(),
					count);

			fCommandStack->Perform(command);
			break;
		}
		default:
			SimpleListView::MessageReceived(message);
			break;
	}
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:59,代码来源:ShapeListView.cpp

示例4: new

// HandleDropMessage
Command*
InsertClipsDropState::HandleDropMessage(BMessage* dropMessage)
{
	if (dropMessage->what == MSG_DRAG_CLIP) {

		// inspect the message to retrieve the clips
		ServerObjectManager* library;
		if (dropMessage->FindPointer("library", (void**)&library) != B_OK)
			return NULL;
	
		if (!library || !library->ReadLock())
			return NULL;

		// temporary list to hold the created items
		BList items;

		Clip* clip;
		for (int32 i = 0; dropMessage->FindPointer("clip", i,
												   (void**)&clip) == B_OK; i++) {
			if (!library->HasObject(clip)) {
				// the message has arrived asynchronously,
				// so the clip pointer might be stale
				continue;
			}

			Playlist* playlist = dynamic_cast<Playlist*>(clip);
			if (playlist && playlist == fView->Playlist()) {
				BAlert* alert = new BAlert("error", "You probably do not "
					"want to insert a playlist into itself.", "Insert",
					"Cancel", NULL, B_WIDTH_FROM_WIDEST, B_STOP_ALERT);
				int32 choice = alert->Go();
				if (choice != 0)
					continue;
			}

			PlaylistItem* item = gItemForClipFactory->PlaylistItemForClip(clip);

			if (!items.AddItem(item)) {
				fprintf(stderr, "InsertClipsDropState::HandleDropMessage() "
								"no memory to insert item in list\n");
				delete item;
				break;
			}
		}

		library->ReadUnlock();

		return new (nothrow) InsertCommand(fView->Playlist(),
										   fView->Selection(),
										   (PlaylistItem**)items.Items(),
										   items.CountItems(),
										   fDropFrame, fDropTrack);
	}
	return NULL;
}
开发者ID:stippi,项目名称:Clockwerk,代码行数:56,代码来源:InsertClipsDropState.cpp

示例5: new

bool
StyleListView::HandleDropMessage(const BMessage* message, int32 dropIndex)
{
	// Let SimpleListView handle drag-sorting (when drag came from ourself)
	if (SimpleListView::HandleDropMessage(message, dropIndex))
		return true;

	if (fCommandStack == NULL || fStyleContainer == NULL)
		return false;

	// Drag may have come from another instance, like in another window.
	// Reconstruct the Styles from the archive and add them at the drop
	// index.
	int index = 0;
	BList styles;
	while (true) {
		BMessage archive;
		if (message->FindMessage("style archive", index, &archive) != B_OK)
			break;
		Style* style = new(std::nothrow) Style(&archive);
		if (style == NULL)
			break;
		
		if (!styles.AddItem(style)) {
			delete style;
			break;
		}

		index++;
	}

	int32 count = styles.CountItems();
	if (count == 0)
		return false;

	AddStylesCommand* command = new(std::nothrow) AddStylesCommand(
		fStyleContainer, (Style**)styles.Items(), count, dropIndex);

	if (command == NULL) {
		for (int32 i = 0; i < count; i++)
			delete (Style*)styles.ItemAtFast(i);
		return false;
	}

	fCommandStack->Perform(command);

	return true;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:48,代码来源:StyleListView.cpp

示例6: new

bool
PathListView::HandleDropMessage(const BMessage* message, int32 dropIndex)
{
	// Let SimpleListView handle drag-sorting (when drag came from ourself)
	if (SimpleListView::HandleDropMessage(message, dropIndex))
		return true;

	if (fCommandStack == NULL || fPathContainer == NULL)
		return false;

	// Drag may have come from another instance, like in another window.
	// Reconstruct the Styles from the archive and add them at the drop
	// index.
	int index = 0;
	BList paths;
	while (true) {
		BMessage archive;
		if (message->FindMessage("path archive", index, &archive) != B_OK)
			break;

		VectorPath* path = new(std::nothrow) VectorPath(&archive);
		if (path == NULL)
			break;
		
		if (!paths.AddItem(path)) {
			delete path;
			break;
		}

		index++;
	}

	int32 count = paths.CountItems();
	if (count == 0)
		return false;

	AddPathsCommand* command = new(nothrow) AddPathsCommand(fPathContainer,
		(VectorPath**)paths.Items(), count, true, dropIndex);
	if (command == NULL) {
		for (int32 i = 0; i < count; i++)
			delete (VectorPath*)paths.ItemAtFast(i);
		return false;
	}

	fCommandStack->Perform(command);

	return true;
}
开发者ID:DonCN,项目名称:haiku,代码行数:48,代码来源:PathListView.cpp

示例7:

void
BOutlineListView::_PopulateTree(BList* tree, BList& target,
	int32& firstIndex, bool onlyVisible)
{
	BListItem** items = (BListItem**)target.Items();
	int32 count = tree->CountItems();

	for (int32 index = 0; index < count; index++) {
		BListItem* item = (BListItem*)tree->ItemAtFast(index);

		items[firstIndex++] = item;

		if (item->HasSubitems() && (!onlyVisible || item->IsExpanded()))
			_PopulateTree(item->fTemporaryList, target, firstIndex, onlyVisible);
	}
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例8: locker


//.........这里部分代码省略.........
                                              B_TRANSLATE_CONTEXT("Add shape with style",
                                                      "Icon-O-Matic-Menu-Shape"),
                                              0);
            } else {
                Command** commands = new Command*[2];
                commands[0] = pathCommand;
                commands[1] = shapeCommand;
                command = new CompoundCommand(commands, 2,
                                              B_TRANSLATE_CONTEXT("Add shape with path",
                                                      "Icon-O-Matic-Menu-Shape"),
                                              0);
            }
        } else {
            command = shapeCommand;
        }
        fDocument->CommandStack()->Perform(command);
        break;
    }

// TODO: listen to selection in CanvasView to add a manipulator
    case MSG_PATH_SELECTED: {
        VectorPath* path;
        if (message->FindPointer("path", (void**)&path) < B_OK)
            path = NULL;

        fPathListView->SetCurrentShape(NULL);
        fStyleListView->SetCurrentShape(NULL);
        fTransformerListView->SetShape(NULL);

        fState->DeleteManipulators();
        if (fDocument->Icon()->Paths()->HasPath(path)) {
            PathManipulator* pathManipulator = new (nothrow) PathManipulator(path);
            fState->AddManipulator(pathManipulator);
        }
        break;
    }
    case MSG_STYLE_SELECTED:
    case MSG_STYLE_TYPE_CHANGED: {
        Style* style;
        if (message->FindPointer("style", (void**)&style) < B_OK)
            style = NULL;
        if (!fDocument->Icon()->Styles()->HasStyle(style))
            style = NULL;

        fStyleView->SetStyle(style);
        fPathListView->SetCurrentShape(NULL);
        fStyleListView->SetCurrentShape(NULL);
        fTransformerListView->SetShape(NULL);

        fState->DeleteManipulators();
        Gradient* gradient = style ? style->Gradient() : NULL;
        if (gradient != NULL) {
            TransformGradientBox* transformBox
                = new (nothrow) TransformGradientBox(fCanvasView, gradient, NULL);
            fState->AddManipulator(transformBox);
        }
        break;
    }
    case MSG_SHAPE_SELECTED: {
        Shape* shape;
        if (message->FindPointer("shape", (void**)&shape) < B_OK)
            shape = NULL;
        if (!fIcon || !fIcon->Shapes()->HasShape(shape))
            shape = NULL;

        fPathListView->SetCurrentShape(shape);
        fStyleListView->SetCurrentShape(shape);
        fTransformerListView->SetShape(shape);

        BList selectedShapes;
        ShapeContainer* shapes = fDocument->Icon()->Shapes();
        int32 count = shapes->CountShapes();
        for (int32 i = 0; i < count; i++) {
            shape = shapes->ShapeAtFast(i);
            if (shape->IsSelected()) {
                selectedShapes.AddItem((void*)shape);
            }
        }

        fState->DeleteManipulators();
        if (selectedShapes.CountItems() > 0) {
            TransformShapesBox* transformBox = new (nothrow) TransformShapesBox(
                fCanvasView,
                (const Shape**)selectedShapes.Items(),
                selectedShapes.CountItems());
            fState->AddManipulator(transformBox);
        }
        break;
    }
    case MSG_RENAME_OBJECT:
        fPropertyListView->FocusNameProperty();
        break;

    default:
        BWindow::MessageReceived(message);
    }

    if (requiresWriteLock)
        fDocument->WriteUnlock();
}
开发者ID:yunxiaoxiao110,项目名称:haiku,代码行数:101,代码来源:MainWindow.cpp

示例9: RemovePLItemsCommand

void
PlaylistListView::RemoveItemList(const BList& indices, bool intoTrash)
{
    fCommandStack->Perform(new (nothrow) RemovePLItemsCommand(fPlaylist,
                           (int32*)indices.Items(), indices.CountItems(), intoTrash));
}
开发者ID:mmanley,项目名称:Antares,代码行数:6,代码来源:PlaylistListView.cpp

示例10: CopyPLItemsCommand

void
PlaylistListView::CopyItems(const BList& indices, int32 toIndex)
{
    fCommandStack->Perform(new (nothrow) CopyPLItemsCommand(fPlaylist,
                           (int32*)indices.Items(), indices.CountItems(), toIndex));
}
开发者ID:mmanley,项目名称:Antares,代码行数:6,代码来源:PlaylistListView.cpp


注:本文中的BList::Items方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。