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:
parent
0a42083169
commit
f7008de829
@ -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,36 +127,41 @@ InterfacesAddOn::MessageReceived(BMessage* msg)
|
||||
}
|
||||
|
||||
switch (msg->what) {
|
||||
case INTERFACE_SELECTED_MSG: {
|
||||
fOnOff->SetEnabled(item != NULL);
|
||||
fConfigure->SetEnabled(item != NULL);
|
||||
if (!item)
|
||||
case kMsgInterfaceSel:
|
||||
{
|
||||
fOnOff->SetEnabled(item != NULL);
|
||||
fConfigure->SetEnabled(item != NULL);
|
||||
if (!item)
|
||||
break;
|
||||
fConfigure->SetEnabled(!item->IsDisabled());
|
||||
fOnOff->SetLabel(item->IsDisabled() ? "Enable" : "Disable");
|
||||
break;
|
||||
fConfigure->SetEnabled(!item->IsDisabled());
|
||||
fOnOff->SetLabel(item->IsDisabled() ? "Enable" : "Disable");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case CONFIGURE_INTERFACE_MSG: {
|
||||
if (!item)
|
||||
case kMsgInterfaceAct:
|
||||
case kMsgInterfaceCfg:
|
||||
{
|
||||
if (!item)
|
||||
break;
|
||||
|
||||
InterfaceWindow* sw = new InterfaceWindow(item->GetSettings());
|
||||
sw->Show();
|
||||
break;
|
||||
}
|
||||
|
||||
InterfaceWindow* sw = new InterfaceWindow(item->GetSettings());
|
||||
sw->Show();
|
||||
break;
|
||||
}
|
||||
case kMsgInterfaceTog:
|
||||
{
|
||||
if (!item)
|
||||
break;
|
||||
|
||||
case ONOFF_INTERFACE_MSG:
|
||||
if (!item)
|
||||
item->SetDisabled(!item->IsDisabled());
|
||||
fOnOff->SetLabel(item->IsDisabled() ? "Enable" : "Disable");
|
||||
fConfigure->SetEnabled(!item->IsDisabled());
|
||||
fListview->Invalidate();
|
||||
break;
|
||||
}
|
||||
|
||||
item->SetDisabled(!item->IsDisabled());
|
||||
fOnOff->SetLabel(item->IsDisabled() ? "Enable" : "Disable");
|
||||
fConfigure->SetEnabled(!item->IsDisabled());
|
||||
fListview->Invalidate();
|
||||
break;
|
||||
|
||||
default:
|
||||
BBox::MessageReceived(msg);
|
||||
default:
|
||||
BBox::MessageReceived(msg);
|
||||
}
|
||||
}
|
||||
|
@ -23,27 +23,26 @@
|
||||
class InterfacesAddOn : public NetworkSetupAddOn, public BBox
|
||||
{
|
||||
public:
|
||||
InterfacesAddOn(image_id addon_image);
|
||||
~InterfacesAddOn();
|
||||
InterfacesAddOn(image_id addon_image);
|
||||
~InterfacesAddOn();
|
||||
|
||||
const char* Name();
|
||||
status_t Save();
|
||||
const char* Name();
|
||||
status_t Save();
|
||||
|
||||
BView* CreateView(BRect *bounds);
|
||||
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);
|
||||
void AttachedToWindow();
|
||||
void MessageReceived(BMessage* msg);
|
||||
|
||||
private:
|
||||
InterfacesListView* fListview;
|
||||
BButton* fConfigure;
|
||||
BButton* fOnOff;
|
||||
InterfacesListView* fListview;
|
||||
BButton* fConfigure;
|
||||
BButton* fOnOff;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user