change to kMsg style BMessage; introduce a new BMessage for listitem click events so I can implement a BPopUpMenu; style cleanup

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40770 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Alexander von Gluck IV
2011-03-01 22:21:21 +00:00
parent 0a42083169
commit f7008de829
2 changed files with 47 additions and 43 deletions
@@ -65,20 +65,20 @@ InterfacesAddOn::CreateView(BRect *bounds)
// Construct the ListView
fListview = new InterfacesListView(intViewRect,
"interfaces", B_FOLLOW_ALL_SIDES);
fListview->SetSelectionMessage(new BMessage(INTERFACE_SELECTED_MSG));
fListview->SetInvocationMessage(new BMessage(CONFIGURE_INTERFACE_MSG));
fListview->SetSelectionMessage(new BMessage(kMsgInterfaceSel));
fListview->SetInvocationMessage(new BMessage(kMsgInterfaceAct));
BScrollView* scrollView = new BScrollView(NULL, fListview,
B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS, false, true);
// Construct the BButtons
fConfigure = new BButton(intViewRect, "configure",
"Configure" B_UTF8_ELLIPSIS, new BMessage(CONFIGURE_INTERFACE_MSG));
"Configure" B_UTF8_ELLIPSIS, new BMessage(kMsgInterfaceCfg));
fConfigure->SetEnabled(false);
fOnOff = new BButton(intViewRect, "onoff", "Disable",
new BMessage(ONOFF_INTERFACE_MSG));
new BMessage(kMsgInterfaceTog));
fOnOff->SetEnabled(false);
@@ -127,7 +127,8 @@ InterfacesAddOn::MessageReceived(BMessage* msg)
}
switch (msg->what) {
case INTERFACE_SELECTED_MSG: {
case kMsgInterfaceSel:
{
fOnOff->SetEnabled(item != NULL);
fConfigure->SetEnabled(item != NULL);
if (!item)
@@ -137,7 +138,9 @@ InterfacesAddOn::MessageReceived(BMessage* msg)
break;
}
case CONFIGURE_INTERFACE_MSG: {
case kMsgInterfaceAct:
case kMsgInterfaceCfg:
{
if (!item)
break;
@@ -146,7 +149,8 @@ InterfacesAddOn::MessageReceived(BMessage* msg)
break;
}
case ONOFF_INTERFACE_MSG:
case kMsgInterfaceTog:
{
if (!item)
break;
@@ -155,6 +159,7 @@ InterfacesAddOn::MessageReceived(BMessage* msg)
fConfigure->SetEnabled(!item->IsDisabled());
fListview->Invalidate();
break;
}
default:
BBox::MessageReceived(msg);
@@ -31,11 +31,10 @@ public:
BView* CreateView(BRect *bounds);
enum {
INTERFACE_SELECTED_MSG = 'ifce',
CONFIGURE_INTERFACE_MSG = 'conf',
ONOFF_INTERFACE_MSG = 'onof'
};
static const uint32 kMsgInterfaceSel = 'ifce';
static const uint32 kMsgInterfaceAct = 'ifac';
static const uint32 kMsgInterfaceCfg = 'ifcf';
static const uint32 kMsgInterfaceTog = 'onof';
void AttachedToWindow();
void MessageReceived(BMessage* msg);