2 * Copyright 2010, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
7 #include "WirelessNetworkMenuItem.h"
10 #include <NetworkDevice.h>
13 #include "RadioView.h"
15 #undef B_TRANSLATION_CONTEXT
16 #define B_TRANSLATION_CONTEXT "WirelessNetworkMenuItem"
19 WirelessNetworkMenuItem::WirelessNetworkMenuItem(const char* name
,
20 int32 signalQuality
, int32 authenticationMode
, BMessage
* message
)
22 BMenuItem(name
, message
),
23 fQuality(signalQuality
)
25 // Append authentication mode to label
26 BString label
= B_TRANSLATE("%name% (%authenticationMode%)");
27 label
.Replace("%name%", name
, 1);
28 label
.Replace("%authenticationMode%",
29 AuthenticationName(authenticationMode
), 1);
31 SetLabel(label
.String());
35 WirelessNetworkMenuItem::~WirelessNetworkMenuItem()
41 WirelessNetworkMenuItem::SetSignalQuality(int32 quality
)
48 WirelessNetworkMenuItem::AuthenticationName(int32 mode
)
52 case B_NETWORK_AUTHENTICATION_NONE
:
53 return B_TRANSLATE_CONTEXT("open", "Open network");
55 case B_NETWORK_AUTHENTICATION_WEP
:
56 return B_TRANSLATE_CONTEXT("WEP", "WEP protected network");
58 case B_NETWORK_AUTHENTICATION_WPA
:
59 return B_TRANSLATE_CONTEXT("WPA", "WPA protected network");
61 case B_NETWORK_AUTHENTICATION_WPA2
:
62 return B_TRANSLATE_CONTEXT("WPA2", "WPA2 protected network");
64 case B_NETWORK_AUTHENTICATION_EAP
:
65 return B_TRANSLATE_CONTEXT("EAP", "EAP protected network");
72 WirelessNetworkMenuItem::DrawContent()
75 BMenuItem::DrawContent();
80 WirelessNetworkMenuItem::Highlight(bool isHighlighted
)
82 BMenuItem::Highlight(isHighlighted
);
87 WirelessNetworkMenuItem::GetContentSize(float* width
, float* height
)
89 BMenuItem::GetContentSize(width
, height
);
90 *width
+= *height
+ 4;
95 WirelessNetworkMenuItem::DrawRadioIcon()
97 BRect bounds
= Frame();
98 bounds
.left
= bounds
.right
- 4 - bounds
.Height();
102 RadioView::Draw(Menu(), bounds
, fQuality
, RadioView::DefaultMax());