本文整理汇总了C++中BList::HasItem方法的典型用法代码示例。如果您正苦于以下问题:C++ BList::HasItem方法的具体用法?C++ BList::HasItem怎么用?C++ BList::HasItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BList
的用法示例。
在下文中一共展示了BList::HasItem方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Undo
void Delete::Undo(PDocument *doc,BMessage *undo)
{
BMessage *undoMessage = new BMessage();
BMessage *settings = new BMessage();
BMessage *node = NULL;
BMessage *connection = NULL;
BList *parentGroupList = NULL;
BList *changed = doc->GetChangedNodes();
BList *allNodes = doc->GetAllNodes();
BList *allConnections = doc->GetAllConnections();
BMessage *commandMessage = new BMessage();
int32 i = 0;
PCommand::Undo(doc,undo);
undo->FindMessage("Delete::Undo" ,undoMessage);
while (undoMessage->FindPointer("node",i,(void **)&node) == B_OK)
{
if (undoMessage->FindPointer("parentGroupList",i,(void **)&parentGroupList) == B_OK)
parentGroupList->AddItem(node);
else
{
if (node->what != P_C_CONNECTION_TYPE)
allNodes->AddItem(node);
else
allConnections->AddItem(node);
}
//(doc->GetTrash())->RemoveItem(node);
(doc->GetSelected())->AddItem(node);
i++;
if (!changed->HasItem(node))
changed->AddItem(node);
}
doc->SetModified();
}
示例2: BMessage
void
TestWindow::AddTest(Test* test)
{
if (test == NULL || fTests.HasItem(test))
return;
if (!fTests.AddItem(test)) {
delete test;
return;
}
BMessage* message = new BMessage(MSG_SELECT_TEST);
message->AddInt32("index", fTests.CountItems() - 1);
BMenuItem* item = new BMenuItem(test->Name(), message);
if (!fTestSelectionField->Menu()->AddItem(item)) {
fTests.RemoveItem(fTests.CountItems() - 1);
delete test;
delete item;
return;
}
if (fTests.CountItems() == 1)
SetToTest(0);
}
示例3:
// contains_list
static
bool
contains_list(const BList &a, const BList &b)
{
int32 bCount = b.CountItems();
bool contains = true;
for (int32 i = 0; contains && i < bCount; i++)
contains = a.HasItem(b.ItemAt(i));
return contains;
}
示例4: if
int
main(int argc,char **argv)
{
srand(42);
// insert numbers in the array
for (int32 i = 0;i < gNumber;i++) {
int32 num = rand();
if (num == 0)
num++;
if (gArray.Insert(num) == B_OK)
gList.AddItem((void *)num);
else if (gArray.Find(num) < 0) {
printf("Could not insert entry in array, but it's not in there either...\n");
dumpArray();
} else
printf("hola\n");
}
// check for numbers in the array
for (int32 i = 0;i < gNumber;i++) {
int32 num = (int32)gList.ItemAt(i);
if (gArray.Find(num) < 0) {
printf("could not found entry %ld in array!\n",num);
dumpArray();
}
}
// iterate through the array
sorted_array *array = gArray.Array();
for (int32 i = 0;i < array->count;i++) {
if (!gList.HasItem((void *)array->values[i])) {
printf("Could not find entry %Ld at %ld in list!\n",array->values[i],i);
dumpArray();
}
}
return 0;
}
示例5: IndexOfSelectable
// ObjectChanged
void
DragSortableListView::ObjectChanged(const Observable* object)
{
if (object != fSelection || fModifyingSelection || fSyncingToSelection)
return;
//printf("%s - syncing start\n", Name());
fSyncingToSelection = true;
// try to sync to Selection
BList selectedItems;
int32 count = fSelection->CountSelected();
for (int32 i = 0; i < count; i++) {
int32 index = IndexOfSelectable(fSelection->SelectableAtFast(i));
if (index >= 0) {
BListItem* item = ItemAt(index);
if (item && !selectedItems.HasItem((void*)item))
selectedItems.AddItem((void*)item);
}
}
count = selectedItems.CountItems();
if (count == 0) {
if (CurrentSelection(0) >= 0)
DeselectAll();
} else {
count = CountItems();
for (int32 i = 0; i < count; i++) {
BListItem* item = ItemAt(i);
bool selected = selectedItems.RemoveItem((void*)item);
if (item->IsSelected() != selected) {
Select(i, true);
}
}
}
fSyncingToSelection = false;
//printf("%s - done\n", Name());
}
示例6: JudgeScore
// returns true if score is destined for greatness
bool Hall::JudgeScore(unsigned long gametime, unsigned long game, int tiles)
{
bool Yes = false;
BList *L;
switch(tiles)
{
case 14 * 6: L = List1; break;
case 18 * 8: L = List2; break;
case 24 * 12: L = List3; break;
case 28 * 16: L = List4; break;
case 32 * 20: L = List5; break;
default: L = NULL;
}
if (!L)
{
//printf("No game size!\n");
return false;
}
HSList *h = new HSList();
h->SetGameID(game);
h->SetGameTime(gametime);
h->SetNumberTiles(tiles);
h->SetTimeOfGame(time(NULL));
h->SetName(NULL);
/* Add the new item
*/
L->AddItem(h);
L->SortItems(cmpFunc);
/*
* Limit entries to 5
*/
if (L->CountItems() > 5)
{
HSList *hs;
hs = (HSList *)L->RemoveItem(5);
delete hs;
}
if (L->HasItem(h))
{
AskName *Ask = new AskName();
char *name;
name = Ask->Go();
Ask->Lock();
Ask->Quit();
be_app->SetCursor(B_HAND_CURSOR);
h->SetName(name);
free(name);
_changed = true;
Yes = true;
}
return Yes;
}
示例7: DebuggerPrintout
//.........这里部分代码省略.........
BBox* enclosingBox = new BBox( frame, "Weekend selector" );
if ( !enclosingBox )
{
/* Panic! */
exit(1);
}
enclosingBox->SetLabel( "Select the non-working days (weekends)" );
// Prepare the layout to be used
BGridLayout* layout = new BGridLayout();
if ( !layout)
{
/* Panic! */
exit(1);
}
enclosingBox->SetLayout( layout );
layout->SetInsets( 10, 15, 10, 5 );
layout->SetVerticalSpacing( 1 );
/* indexX is 0 for left column or 1 for right column.
* indexY is 0 for topmost row, 1 for second from top row, etc.
* Max value for indexY = (ceiling of (N/2)).
*/
int indexX = 0, indexY = 0;
for (uint32 day = prefs->GetFirstDayOfWeek(), i = 0; i < ( uint32 )daysInWeek; ++i )
{
/* Creating the message to be sent */
toSend = new BMessage( kCalendarModuleWeekendDaySelected );
if ( !toSend )
{
/* Panic! */
exit(1);
}
toSend->AddInt32( "Weekday const", day );
toSend->AddString( "Calendar module", id );
/* Set the name of the checkbox.
* This is used to identify if the checkbox was checked or unchecked.
*/
tempString.SetTo( "Weekday" );
tempString << day;
/* Creating the checkbox */
dayCheckBox = new BCheckBox( BRect(0, 0, 1, 1),
tempString.String(),
weekdayNames[ day ].longName.String(),
toSend );
if (!dayCheckBox)
{
// Panic!
exit(1);
}
dayCheckBox->ResizeToPreferred();
// Check if the checkbox should be checked
if ( weekends->HasItem( ( void* )day ) ) {
dayCheckBox->SetValue( 1 );
} else {
dayCheckBox->SetValue( 0 );
}
/* Adding the item to the BBox */
layoutItem = layout->AddView( dayCheckBox, indexX, indexY );
if ( layoutItem )
{
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
// layoutItem->SetExplicitMaxSize( BSize( (int )dayCheckBox->Bounds().Width(), (int )dayCheckBox->Bounds().Height() ) );
layout->SetMaxRowHeight( indexY, (int )dayCheckBox->Bounds().Height() + 10 );
layout->SetRowWeight( indexY, 0 );
}
/* Advancing to the next cell in grid */
// If arrived to the last item in the first column, advancing to second
// The +1 is needed because i starts from 0, but days are starting from 1
if ( ( i + 1 ) == ( unsigned int )( ( daysInWeek + 1 ) / 2 ) )
{
indexX = 1;
indexY = 0;
}
else // Staying in the same column, but advancing down
{
++indexY;
}
/* Advancing to the next day */
( day == daysInWeek ) ? day = kSunday : ++day;
} // <-- end of "for (all days in week)"
// Resizing the BBox to the correct size.
// Note: dayCheckBox is surely not NULL; if it were, we would exit earlier.
height =(int )( ( dayCheckBox->Bounds().Height() + 5 ) * ( int )( ( daysInWeek + 1 ) / 2 ) - 5 );
// Formula: ( ^height of one checkbox^ + ^separator^ ) * ( ^number of days in column^ ) - ^one unneeded extra separator^
enclosingBox->ResizeTo( enclosingBox->Bounds().Width() - 10, ( int )height );
// layout->SetExplicitMaxSize( BSize( enclosingBox->Bounds().Width() - 5, ( int )height + 25 ) );
return enclosingBox;
}