Added test for adding a BMenu instead of a BMenuItem, but everything works
fine, at least in the context of the layout management. I am investigating a bug though that shows at least in WonderBrush (missing Filter menu). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27284 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
57b269650e
commit
86dab989e5
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
MSG_THIRD_ITEM = '3rdi',
|
MSG_THIRD_ITEM = '3rdi',
|
||||||
|
MSG_CHILD_MENU = 'chmn',
|
||||||
MSG_CHANGE_ITEM_TEXT = 'chit'
|
MSG_CHANGE_ITEM_TEXT = 'chit'
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ MenuBarTest::MenuBarTest()
|
|||||||
fMenuBar->AddItem(fFirstItem = new BMenuItem("Menu item 1", NULL));
|
fMenuBar->AddItem(fFirstItem = new BMenuItem("Menu item 1", NULL));
|
||||||
fMenuBar->AddItem(new BMenuItem("Menu item 2", NULL));
|
fMenuBar->AddItem(new BMenuItem("Menu item 2", NULL));
|
||||||
fThirdItem = new BMenuItem("Menu item 3", NULL);
|
fThirdItem = new BMenuItem("Menu item 3", NULL);
|
||||||
|
fChildMenu = new BMenu("Child menu");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -53,6 +55,11 @@ MenuBarTest::ActivateTest(View* controls)
|
|||||||
new BMessage(MSG_THIRD_ITEM), this);
|
new BMessage(MSG_THIRD_ITEM), this);
|
||||||
group->AddChild(fThirdItemCheckBox);
|
group->AddChild(fThirdItemCheckBox);
|
||||||
|
|
||||||
|
// child menu
|
||||||
|
fChildMenuCheckBox = new LabeledCheckBox("Child menu",
|
||||||
|
new BMessage(MSG_CHILD_MENU), this);
|
||||||
|
group->AddChild(fChildMenuCheckBox);
|
||||||
|
|
||||||
// long text
|
// long text
|
||||||
fLongTextCheckBox = new LabeledCheckBox("Long label text",
|
fLongTextCheckBox = new LabeledCheckBox("Long label text",
|
||||||
new BMessage(MSG_CHANGE_ITEM_TEXT), this);
|
new BMessage(MSG_CHANGE_ITEM_TEXT), this);
|
||||||
@ -80,6 +87,9 @@ MenuBarTest::MessageReceived(BMessage* message)
|
|||||||
case MSG_THIRD_ITEM:
|
case MSG_THIRD_ITEM:
|
||||||
UpdateThirdItem();
|
UpdateThirdItem();
|
||||||
break;
|
break;
|
||||||
|
case MSG_CHILD_MENU:
|
||||||
|
UpdateChildMenu();
|
||||||
|
break;
|
||||||
case MSG_CHANGE_ITEM_TEXT:
|
case MSG_CHANGE_ITEM_TEXT:
|
||||||
UpdateLongText();
|
UpdateLongText();
|
||||||
break;
|
break;
|
||||||
@ -107,6 +117,23 @@ MenuBarTest::UpdateThirdItem()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// UpdateChildMenu
|
||||||
|
void
|
||||||
|
MenuBarTest::UpdateChildMenu()
|
||||||
|
{
|
||||||
|
if (!fChildMenuCheckBox || !fMenuBar)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fChildMenuCheckBox->IsSelected() == (fChildMenu->Supermenu() != NULL))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fChildMenuCheckBox->IsSelected())
|
||||||
|
fMenuBar->AddItem(fChildMenu);
|
||||||
|
else
|
||||||
|
fMenuBar->RemoveItem(fChildMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// UpdateLongText
|
// UpdateLongText
|
||||||
void
|
void
|
||||||
MenuBarTest::UpdateLongText()
|
MenuBarTest::UpdateLongText()
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "Test.h"
|
#include "Test.h"
|
||||||
|
|
||||||
|
|
||||||
|
class BMenu;
|
||||||
class BMenuBar;
|
class BMenuBar;
|
||||||
class BMenuItem;
|
class BMenuItem;
|
||||||
class LabeledCheckBox;
|
class LabeledCheckBox;
|
||||||
@ -27,13 +28,16 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateThirdItem();
|
void UpdateThirdItem();
|
||||||
|
void UpdateChildMenu();
|
||||||
void UpdateLongText();
|
void UpdateLongText();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BMenuBar* fMenuBar;
|
BMenuBar* fMenuBar;
|
||||||
BMenuItem* fFirstItem;
|
BMenuItem* fFirstItem;
|
||||||
BMenuItem* fThirdItem;
|
BMenuItem* fThirdItem;
|
||||||
|
BMenu* fChildMenu;
|
||||||
LabeledCheckBox* fThirdItemCheckBox;
|
LabeledCheckBox* fThirdItemCheckBox;
|
||||||
|
LabeledCheckBox* fChildMenuCheckBox;
|
||||||
LabeledCheckBox* fLongTextCheckBox;
|
LabeledCheckBox* fLongTextCheckBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user