some more cleanups. The AddItem() variation which accepts a BRect parameter now calls the debugger if called when the layout is not B_ITEMS_IN_MATRIX.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10556 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+21
-10
@@ -160,8 +160,7 @@ BMenu::BMenu(const char *name, float width, float height)
|
|||||||
|
|
||||||
BMenu::~BMenu()
|
BMenu::~BMenu()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < CountItems(); i++)
|
RemoveItems(0, CountItems(), true);
|
||||||
delete ItemAt(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -187,7 +186,7 @@ BMenu::Archive(BMessage *data, bool deep) const
|
|||||||
{
|
{
|
||||||
status_t err = BView::Archive(data, deep);
|
status_t err = BView::Archive(data, deep);
|
||||||
|
|
||||||
if (err != B_OK)
|
if (err < B_OK)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (Layout() != B_ITEMS_IN_ROW) {
|
if (Layout() != B_ITEMS_IN_ROW) {
|
||||||
@@ -287,10 +286,13 @@ BMenu::AddItem(BMenuItem *item, int32 index)
|
|||||||
bool
|
bool
|
||||||
BMenu::AddItem(BMenuItem *item, BRect frame)
|
BMenu::AddItem(BMenuItem *item, BRect frame)
|
||||||
{
|
{
|
||||||
|
if (fLayout != B_ITEMS_IN_MATRIX)
|
||||||
|
debugger("BMenu::AddItem(BMenuItem *, BRect) this method can only"
|
||||||
|
" be called if the menu layout is B_ITEMS_IN_MATRIX");
|
||||||
|
|
||||||
if (!item)
|
if (!item)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
frame.PrintToStream();
|
|
||||||
item->fBounds = frame;
|
item->fBounds = frame;
|
||||||
|
|
||||||
return AddItem(item, CountItems());
|
return AddItem(item, CountItems());
|
||||||
@@ -326,6 +328,10 @@ BMenu::AddItem(BMenu *submenu, int32 index)
|
|||||||
bool
|
bool
|
||||||
BMenu::AddItem(BMenu *submenu, BRect frame)
|
BMenu::AddItem(BMenu *submenu, BRect frame)
|
||||||
{
|
{
|
||||||
|
if (fLayout != B_ITEMS_IN_MATRIX)
|
||||||
|
debugger("BMenu::AddItem(BMenu *, BRect) this method can only"
|
||||||
|
" be called if the menu layout is B_ITEMS_IN_MATRIX");
|
||||||
|
|
||||||
BMenuItem *item = new BMenuItem(submenu);
|
BMenuItem *item = new BMenuItem(submenu);
|
||||||
submenu->fSuper = this;
|
submenu->fSuper = this;
|
||||||
item->fBounds = frame;
|
item->fBounds = frame;
|
||||||
@@ -1033,12 +1039,12 @@ void
|
|||||||
BMenu::_hide()
|
BMenu::_hide()
|
||||||
{
|
{
|
||||||
BWindow *window = Window();
|
BWindow *window = Window();
|
||||||
|
|
||||||
if (window) {
|
if (window) {
|
||||||
window->RemoveChild(this);
|
window->RemoveChild(this);
|
||||||
window->Lock();
|
window->Lock();
|
||||||
window->Quit();
|
window->Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1059,9 +1065,7 @@ BMenu::_track(int *action, long start)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item && fSelected != item) {
|
SelectItem(item);
|
||||||
SelectItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
Draw(Bounds());
|
Draw(Bounds());
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
@@ -1204,6 +1208,7 @@ BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems,
|
|||||||
case B_ITEMS_IN_MATRIX:
|
case B_ITEMS_IN_MATRIX:
|
||||||
{
|
{
|
||||||
printf("BMenu: B_ITEMS_IN_MATRIX not yet implemented\n");
|
printf("BMenu: B_ITEMS_IN_MATRIX not yet implemented\n");
|
||||||
|
frame = Frame();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1262,7 +1267,7 @@ BMenu::ScrollIntoView(BMenuItem *item)
|
|||||||
void
|
void
|
||||||
BMenu::DrawItems(BRect updateRect)
|
BMenu::DrawItems(BRect updateRect)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < fItems.CountItems(); i++) {
|
for (int32 i = 0; i < fItems.CountItems(); i++) {
|
||||||
if (ItemAt(i)->Frame().Intersects(updateRect)) {
|
if (ItemAt(i)->Frame().Intersects(updateRect)) {
|
||||||
ItemAt(i)->Draw();
|
ItemAt(i)->Draw();
|
||||||
}
|
}
|
||||||
@@ -1395,8 +1400,14 @@ BMenu::Uninstall()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenu::SelectItem(BMenuItem *m, uint32 showSubmenu,bool selectFirstItem)
|
BMenu::SelectItem(BMenuItem *menuItem, uint32 showSubmenu, bool selectFirstItem)
|
||||||
{
|
{
|
||||||
|
if (menuItem != fSelected) {
|
||||||
|
if (fSelected != NULL)
|
||||||
|
fSelected->Select(false);
|
||||||
|
menuItem->Select(true);
|
||||||
|
fSelected = menuItem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -382,7 +382,7 @@ BMenuItem::Draw()
|
|||||||
B_DISABLED_LABEL_TINT));
|
B_DISABLED_LABEL_TINT));
|
||||||
|
|
||||||
fSuper->MovePenTo(ContentLocation());
|
fSuper->MovePenTo(ContentLocation());
|
||||||
DrawContent();
|
//DrawContent();
|
||||||
|
|
||||||
if (fSuper->Layout() == B_ITEMS_IN_COLUMN) {
|
if (fSuper->Layout() == B_ITEMS_IN_COLUMN) {
|
||||||
if (IsMarked())
|
if (IsMarked())
|
||||||
|
|||||||
Reference in New Issue
Block a user