add item frames to BMenu archive

add class names to BMenuItem archives


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18069 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2006-07-08 00:38:31 +00:00
parent 8cc767ee45
commit 9b224ec82e
3 changed files with 22 additions and 5 deletions

View File

@ -291,7 +291,7 @@ BMenu::Archive(BMessage *data, bool deep) const
if (err != B_OK)
break;
if (fLayout == B_ITEMS_IN_MATRIX) {
// TODO Store location of items
err = data->AddRect("_i_frames", item->fBounds);
}
}
}
@ -1172,10 +1172,16 @@ BMenu::InitData(BMessage *data)
data->FindFloat("_maxwidth", &fMaxContentWidth);
BMessage msg;
for (int32 i = 0; data->FindMessage("_items", i, &msg) == B_OK; i++) {
for (int32 i = 0; data->FindMessage("_items", i, &msg) == B_OK; i++) {
BArchivable *object = instantiate_object(&msg);
if (BMenuItem *item = dynamic_cast<BMenuItem *>(object))
AddItem(item);
if (BMenuItem *item = dynamic_cast<BMenuItem *>(object)) {
BRect bounds;
if ((fLayout == B_ITEMS_IN_MATRIX)
&& (data->FindRect("_i_frames", i, &bounds) == B_OK))
AddItem(item, bounds);
else
AddItem(item);
}
}
}
}

View File

@ -179,11 +179,17 @@ BMenuItem::Instantiate(BMessage *data)
}
extern const char* B_CLASS_FIELD;
status_t
BMenuItem::Archive(BMessage *data, bool deep) const
{
status_t ret = B_OK;
if (fLabel)
if (!data->HasString(B_CLASS_FIELD))
ret = data->AddString(B_CLASS_FIELD, "BMenuItem");
if (ret == B_OK && fLabel)
ret = data->AddString("_label", Label());
if (ret == B_OK && !IsEnabled())

View File

@ -33,9 +33,14 @@ BSeparatorItem::~BSeparatorItem()
}
extern const char* B_CLASS_FIELD;
status_t
BSeparatorItem::Archive(BMessage* archive, bool deep) const
{
if (!archive->HasString(B_CLASS_FIELD))
archive->AddString(B_CLASS_FIELD, "BMenuItem");
return BMenuItem::Archive(archive, deep);
}