void BOutlineListView::_CullInvisibleItems(BList& list) { int32 index = 0; while (index < list.CountItems()) { if (reinterpret_cast<BListItem*>(list.ItemAt(index))->IsItemVisible()) ++index; else list.RemoveItem(index); } }
// RemoveSelected void DragSortableListView::RemoveSelected() { BList indices; GetSelectedItems(indices); DeselectAll(); if (indices.CountItems() > 0) RemoveItemList(indices); }
PersonData *PeepsWindow::FindPerson(node_ref nref) { PersonData *pdata=NULL; for(int32 i=0; i<gPeopleData.CountItems(); i++) { pdata=(PersonData*)gPeopleData.ItemAtFast(i); if(pdata->NodeRef()==nref) return pdata; } return NULL; }
void NotifyList::UpdateList(BObjectList<NotifyListItem> *newList) { while (CountItems() > 0) delete RemoveItem ((int32)0); BList updateList; // make private copy of list items otherwise things go bad for (int32 i = 0; i < newList->CountItems(); i++) updateList.AddItem (new NotifyListItem (*newList->ItemAt(i))); AddList(&updateList); }
void RemoveFrontTest() { cout << "BList::remove_front" << endl; BList<int> hundred; GenerateBack(hundred, 0, 100); for (int i = 0; i < 100; ++i) { assert(hundred.size() == 100-i); assert(hundred.front() == i); assert(hundred.back() == 99); hundred.remove_front(); } }
TPolygon::TPolygon( TPolygon *polygon ) { m_PointList = new BList(); BList *ptList = polygon->GetPointList(); // Copy data over for (int32 index = 0; index < ptList->CountItems(); index++) { m_PointList->AddItem( ptList->ItemAt(index) ); } }
void RemoveAttribute::DoRemoveAttribute(PDocument *doc, BMessage *node, BMessage *valueContainer,BMessage *undoMessage) { node->PrintToStream(); valueContainer->PrintToStream(); undoMessage->PrintToStream(); status_t err = B_OK; int32 i = 0; int32 j = 0; BList *subGroupList = new BList(); BMessage *subGroup = NULL; BMessage *tmpSubGroup = new BMessage(); BList *changed = doc->GetChangedNodes(); //do char *name = NULL; char *tmpName = NULL; char *subGroupName = NULL; type_code type = B_ANY_TYPE; void* oldValue = NULL; int32 index = 0; int32 count = 0; ssize_t size = 0; err = valueContainer->FindString("name",(const char**)&name); err = err | valueContainer->FindInt32("index",(int32 *)&index); subGroup = node; subGroupList->AddItem(subGroup); while (valueContainer->FindString("subgroup",i,(const char**)&subGroupName) == B_OK) { subGroup->FindMessage(subGroupName,tmpSubGroup); subGroupList->AddItem(tmpSubGroup); subGroup = tmpSubGroup; tmpSubGroup = new BMessage(); i++; } delete tmpSubGroup; #ifdef B_ZETA_VERSION_1_0_0 while ((subGroup->GetInfo(B_ANY_TYPE, j, (const char **)&tmpName, &type, &count) == B_OK) && ((count-1) != index)) #else while((subGroup->GetInfo(B_ANY_TYPE, j, (char**)&tmpName, &type, &count) == B_OK) && ((count-1) != index)) #endif j++; subGroup->FindData(name,type,count-1,(const void **)&oldValue,&size); undoMessage->AddData("deletedAttribut",type,oldValue,size); undoMessage->AddString("deletedName",name); undoMessage->AddInt32("deletedType",type); subGroup->RemoveData(name,index); for (i=subGroupList->CountItems()-1;i>0;i--) { tmpSubGroup = (BMessage *)subGroupList->ItemAt(i-1); valueContainer->FindString("subgroup",i-1,(const char**)&subGroupName); if (tmpSubGroup) tmpSubGroup->ReplaceMessage(subGroupName,(BMessage *)subGroupList->ItemAt(i)); delete subGroupList->RemoveItem(i); } changed->AddItem(node); }
bool TCueSheetWindow::MyQuitRequested() { bool retVal = true; bool quit = false; // Ask user to save document if (fCueSheetView->IsDirty()) { long userVal = SaveAlert(); // Check user response switch( userVal) { // User does not want to save case 0: fCueSheetView->SetDirty(false); retVal = true; break; // User decided not to quit case 1: retVal = false; break; // User wants to save case 2: retVal = true; break; default: retVal = true; } } // Remove ourself from list if window is closing if (retVal) { BList* theList = static_cast<MuseumApp*>(be_app)->GetCueSheetList(); if (theList) { theList->RemoveItem(this); // If this is the last cue sheet open, tell application to quit if (theList->CountItems() == 0) be_app->PostMessage(B_QUIT_REQUESTED); } } // Now tell app to fix Windows menu to reflect new state if (quit == false) be_app->PostMessage(FIX_WINDOWS_MENU_MSG); // Return user response to application return retVal; }
// RemoveAll void DragSortableListView::RemoveAll() { BList indices; int32 count = CountItems(); for (int32 i = 0; i < count; i++) { if (!indices.AddItem((void*)(addr_t)i)) break; } if (indices.CountItems() > 0) RemoveItemList(indices); }
bool PairsView::_HasBitmap(BList& bitmaps, BBitmap* bitmap) { // TODO: if this takes too long, we could build a hash value for each // bitmap in a separate list for (int32 i = bitmaps.CountItems(); i-- > 0;) { BBitmap* item = (BBitmap*)bitmaps.ItemAtFast(i); if (!memcmp(item->Bits(), bitmap->Bits(), item->BitsLength())) return true; } return false; }
void CLVColumnLabelView::ShiftDragGroup(int32 NewPos) //Shift the drag group into a new position { int32 NumberOfGroups = fDragGroups.CountItems(); int32 GroupCounter; CLVDragGroup* ThisGroup; int32 ColumnCounter; BList NewDisplayList; //Copy the groups up to the new position for(GroupCounter = 0; GroupCounter < NewPos; GroupCounter++) { if(GroupCounter != fDragGroup) { ThisGroup = (CLVDragGroup*)fDragGroups.ItemAt(GroupCounter); for(ColumnCounter = ThisGroup->GroupStartDispListIndex; ColumnCounter <= ThisGroup->GroupStopDispListIndex; ColumnCounter++) NewDisplayList.AddItem(fDisplayList->ItemAt(ColumnCounter)); } } //Copy the group into the new position ThisGroup = (CLVDragGroup*)fDragGroups.ItemAt(fDragGroup); for(ColumnCounter = ThisGroup->GroupStartDispListIndex; ColumnCounter <= ThisGroup->GroupStopDispListIndex; ColumnCounter++) NewDisplayList.AddItem(fDisplayList->ItemAt(ColumnCounter)); //Copy the rest of the groups, but skip the dragging group for(GroupCounter = NewPos; GroupCounter < NumberOfGroups; GroupCounter++) { if(GroupCounter != fDragGroup) { ThisGroup = (CLVDragGroup*)fDragGroups.ItemAt(GroupCounter); for(ColumnCounter = ThisGroup->GroupStartDispListIndex; ColumnCounter <= ThisGroup->GroupStopDispListIndex; ColumnCounter++) NewDisplayList.AddItem(fDisplayList->ItemAt(ColumnCounter)); } } //Set the new order *fDisplayList = NewDisplayList; //Update columns and drag groups fParent->UpdateColumnSizesDataRectSizeScrollBars(); UpdateDragGroups(); SetSnapMinMax(); //Inform the program that the display order changed int32* NewOrder = new int32[fParent->CountColumns()]; fParent->GetDisplayOrder(NewOrder); fParent->DisplayOrderChanged(NewOrder); delete[] NewOrder; }
bool find_amc() { // sets amc_application be_roster->GetAppList(&team_list); for (int i=0;i<team_list.CountItems();i++) { teamid=(team_id)team_list.ItemAt(i); be_roster->GetRunningAppInfo(teamid, &appinfo); if (strcmp(appinfo.ref.name, "amc")==0) { puts("OKAY! amc found"); amc_application=BMessenger(0, teamid); amc_found=true; break; } } return amc_found; }
// Draw void TestView::Draw(BRect updateRect) { int32 count = fMouseSamples.CountItems(); if (count > 0) { BPoint* p = (BPoint*)fMouseSamples.ItemAtFast(0); MovePenTo(*p); } for (int32 i = 0; i < count; i++) { BPoint* p = (BPoint*)fMouseSamples.ItemAtFast(i); StrokeLine(*p); } }
// _GetBuffersFor // // Adds pointers to all buffers to the list that contain data of the // supplied interval. void MediaTrackAudioSupplier::_GetBuffersFor(BList& buffers, int64 position, int64 frames) const { buffers.MakeEmpty(); for (int32 i = 0; Buffer* buffer = _BufferAt(i); i++) { // Calculate the intersecting interval and add the buffer if it is // not empty. int32 startFrame = max(position, buffer->offset); int32 endFrame = min(position + frames, buffer->offset + buffer->size); if (startFrame < endFrame) buffers.AddItem(buffer); } }
TBarApp::TBarApp() : BApplication(kDeskbarSignature), fSettingsFile(NULL), fPreferencesWindow(NULL) { InitSettings(); InitIconPreloader(); fBarWindow = new TBarWindow(); fBarView = fBarWindow->BarView(); be_roster->StartWatching(this); gLocalizedNamePreferred = BLocaleRoster::Default()->IsFilesystemTranslationPreferred(); sBarTeamInfoList.MakeEmpty(); BList teamList; int32 numTeams; be_roster->GetAppList(&teamList); numTeams = teamList.CountItems(); for (int32 i = 0; i < numTeams; i++) { app_info appInfo; team_id tID = (team_id)teamList.ItemAt(i); if (be_roster->GetRunningAppInfo(tID, &appInfo) == B_OK) { AddTeam(appInfo.team, appInfo.flags, appInfo.signature, &appInfo.ref); } } sSubscribers.MakeEmpty(); fSwitcherMessenger = BMessenger(new TSwitchManager(fSettings.switcherLoc)); fBarWindow->Show(); // Call UpdatePlacement() after the window is shown because expanded apps // need to resize the window. if (fBarWindow->Lock()) { fBarView->UpdatePlacement(); fBarWindow->Unlock(); } // this messenger now targets the barview instead of the // statusview so that all additions to the tray // follow the same path fStatusViewMessenger = BMessenger(fBarWindow->FindView("BarView")); }
void gui_start_selection(struct gui_window *g) { current_selection.Truncate(0); while (current_selection_textruns.ItemAt(0)) { text_run *run = (text_run *)current_selection_textruns.RemoveItem(0L); delete run; } if (!g->view->LockLooper()) return; g->view->MakeFocus(); g->view->UnlockLooper(); }
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; }
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; }
// 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; } }
bool Model::_LoadHistory(BList& items) const { BFile file; status_t status = _OpenFile(&file, PREFS_FILE); if (status != B_OK) return false; status = file.Lock(); if (status != B_OK) return false; BMessage message; status = message.Unflatten(&file); if (status != B_OK) return false; file.Unlock(); BString string; for (int32 x = 0; message.FindString("string", x, &string) == B_OK; x++) { BString* copy = new (nothrow) BString(string); if (copy == NULL || !items.AddItem(copy)) { delete copy; break; } } return true; }
void Model::FillHistoryMenu(BMenu* menu) const { BList items; if (!_LoadHistory(items)) return; for (int32 t = items.CountItems() - 1; t >= 0; --t) { BString* item = static_cast<BString*>(items.ItemAtFast(t)); BMessage* message = new BMessage(MSG_SELECT_HISTORY); message->AddString("text", item->String()); menu->AddItem(new BMenuItem(item->String(), message)); } _FreeHistory(items); }
void dumpTree() { puts("\n*** Tree-Dump:\n"); bplustree_header *header = (bplustree_header *)gBlocks.ItemAt(0); dump_bplustree_header(header); for (int32 i = 1;i < gBlocks.CountItems();i++) { bplustree_node *node = (bplustree_node *)gBlocks.ItemAt(i); printf("\n--- %s node at %ld --------------------------------------\n", node->overflow_link == BPLUSTREE_NULL ? "leaf" : "index", i * BPLUSTREE_NODE_SIZE); dump_bplustree_node(node,header,gVolume); } }
// RemoveItemList void TransformerListView::RemoveItemList(BList& items) { if (!fCommandStack || !fShape) return; int32 count = items.CountItems(); int32 indices[count]; for (int32 i = 0; i < count; i++) indices[i] = IndexOf((BListItem*)items.ItemAtFast(i)); RemoveTransformersCommand* command = new (nothrow) RemoveTransformersCommand(fShape, indices, count); fCommandStack->Perform(command); }
bool enabled(const char* name, const char* arg) { gArgs.AddItem((void*)name); if (arg == NULL) return false; if (strcmp(arg, "all") == 0) return true; return strcmp(arg, name) == 0; }
void print_subscript(const BList<T, Size>& list) { for (unsigned i = 0; i < list.size(); i++) { std::cout << list[i] << " "; } }
int main(int argc, char **argv) { int32 mode = kStandardMode; // Don't have an BApplication as it is not needed for what we do int c; while ((c = getopt_long(argc, argv, "nth", kLongOptions, NULL)) != -1) { switch (c) { case 'n': mode |= kNameOnlyMode; break; case 't': mode |= kNoTruncateMode; break; case 0: break; case 'h': usage(0); break; default: usage(1); break; } } // print title line printf(" team %*s port flags signature\n", (int)kNameFieldWidth, mode & kNameOnlyMode ? "name" : "path"); printf("------ "); for (int32 i = 0; i < kNameFieldWidth; i++) putchar('-'); puts(" ----- ----- ---------"); // Retrieve the running list. BList applicationList; be_roster->GetAppList(&applicationList); // Iterate through the list. for (int32 i = 0; i < applicationList.CountItems(); i++) output_team((team_id)applicationList.ItemAt(i), mode); return 0; }
void AppView::SelectionChanged() { PRINT(("AppView::SelectionChanged()\n")); if(! m_applying) { int numViews = m_pick_list_view->CountViews(); if(numViews > 0) { BList list; int i=0; int selected; while((selected = m_list_view->CurrentSelection(i)) >= 0) { list.AddItem(m_list_view->ItemAt(selected)); i++; } BString buf; buf << list.CountItems(); buf << " / "; buf << m_list_view->CountItems(); buf << SELECTED_TEXT; m_selected_string_view->SetText(buf.String()); if(m_list_view->HasSelectionOfOnlyAcceptedItems()) { m_apply_button->SetEnabled(true); } else { m_apply_button->SetEnabled(false); } for(int i = 0; i < numViews; i++) { AddOnView* view = (AddOnView*)m_pick_list_view->ViewAt(i); if(view) { view->SelectionChanged(&list); } } } } }
// Function taken from Haiku ShowImage, // function originally written by Michael Pfeiffer bool SlideShowSaver::FindNextImage(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind) { // ASSERT(next || !rewind); BEntry curImage(in_current); entry_ref entry, *ref; BDirectory parent; BList entries; bool found = false; int32 cur; if (curImage.GetParent(&parent) != B_OK) return false; while (parent.GetNextRef(&entry) == B_OK) { if (entry != *in_current) { entries.AddItem(new entry_ref(entry)); } else { // insert current ref, so we can find it easily after sorting entries.AddItem(in_current); } } entries.SortItems(CompareEntries); cur = entries.IndexOf(in_current); // ASSERT(cur >= 0); // remove it so FreeEntries() does not delete it entries.RemoveItem(in_current); if (next) { // find the next image in the list if (rewind) cur = 0; // start with first for (; (ref = (entry_ref*)entries.ItemAt(cur)) != NULL; cur ++) { if (IsImage(ref)) { found = true; *out_image = (const entry_ref)*ref; break; } } } else { // find the previous image in the list cur --; for (; cur >= 0; cur --) { ref = (entry_ref*)entries.ItemAt(cur); if (IsImage(ref)) { found = true; *out_image = (const entry_ref)*ref; break; } } } FreeEntries(&entries); return found; }
void Accounts::Create(BListView *listView, BView *configView) { gListView = listView; gConfigView = configView; BList inbound,outbound; GetInboundMailChains(&inbound); GetOutboundMailChains(&outbound); // create inbound accounts and assign matching outbound chains for (int32 i = inbound.CountItems();i-- > 0;) { BMailChain *inChain = (BMailChain *)inbound.ItemAt(i); BMailChain *outChain = NULL; for (int32 j = outbound.CountItems();j-- > 0;) { outChain = (BMailChain *)outbound.ItemAt(j); if (!strcmp(inChain->Name(),outChain->Name())) break; outChain = NULL; } gAccounts.AddItem(new Account(inChain,outChain)); inbound.RemoveItem(i); if (outChain) outbound.RemoveItem(outChain); } // create remaining outbound only accounts for (int32 i = outbound.CountItems();i-- > 0;) { BMailChain *outChain = (BMailChain *)outbound.ItemAt(i); gAccounts.AddItem(new Account(NULL,outChain)); outbound.RemoveItem(i); } // sort the list alphabetically gAccounts.SortItems(Accounts::Compare); for (int32 i = 0;Account *account = (Account *)gAccounts.ItemAt(i);i++) account->AddToListView(); }
void RemoveAttribute::AddAttribute(PDocument *doc, BMessage *node, BMessage *valueContainer,BMessage *undoMessage) { node->PrintToStream(); valueContainer->PrintToStream(); undoMessage->PrintToStream(); int32 i = 0; status_t err = B_OK; BList *subGroupList = new BList(); BMessage *subGroup = NULL; BMessage *tmpSubGroup = new BMessage(); BList *changed = doc->GetChangedNodes(); //do char *name = NULL; char *subGroupName = NULL; type_code type = B_ANY_TYPE; ssize_t size = 0; //undo char *compareName = NULL; void* newValue = NULL; int32 lastIndex = -1; int32 count = 0; int32 index = 0; type_code typeFound = B_ANY_TYPE; err = undoMessage->FindString("deletedName",(const char**)&name); err = err | undoMessage->FindInt32("deletedType",(int32 *)&type); err = undoMessage->FindData("deletedAttribut", type,(const void **)&newValue, &size); subGroup = node; subGroupList->AddItem(subGroup); while (valueContainer->FindString("subgroup",i,(const char**)&subGroupName) == B_OK) { subGroup->FindMessage(subGroupName,tmpSubGroup); subGroupList->AddItem(tmpSubGroup); subGroup = tmpSubGroup; tmpSubGroup = new BMessage(); i++; } delete tmpSubGroup; subGroup->AddData(name,type,newValue,size); for (i=subGroupList->CountItems()-1;i>0;i--) { tmpSubGroup = (BMessage *)subGroupList->ItemAt(i-1); valueContainer->FindString("subgroup",i-1,(const char**)&subGroupName); if (tmpSubGroup) tmpSubGroup->ReplaceMessage(subGroupName,(BMessage *)subGroupList->ItemAt(i)); delete subGroupList->RemoveItem(i); } changed->AddItem(node); }