本文整理汇总了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()));
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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();
}
示例9: RemovePLItemsCommand
void
PlaylistListView::RemoveItemList(const BList& indices, bool intoTrash)
{
fCommandStack->Perform(new (nothrow) RemovePLItemsCommand(fPlaylist,
(int32*)indices.Items(), indices.CountItems(), intoTrash));
}
示例10: CopyPLItemsCommand
void
PlaylistListView::CopyItems(const BList& indices, int32 toIndex)
{
fCommandStack->Perform(new (nothrow) CopyPLItemsCommand(fPlaylist,
(int32*)indices.Items(), indices.CountItems(), toIndex));
}