btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / networkstatus / WirelessNetworkMenuItem.cpp
blobf42f8ce7d289d93043e023d50db47c52f82fb4d3
1 /*
2 * Copyright 2010, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include "WirelessNetworkMenuItem.h"
9 #include <Catalog.h>
10 #include <NetworkDevice.h>
11 #include <String.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()
40 void
41 WirelessNetworkMenuItem::SetSignalQuality(int32 quality)
43 fQuality = quality;
47 BString
48 WirelessNetworkMenuItem::AuthenticationName(int32 mode)
50 switch (mode) {
51 default:
52 case B_NETWORK_AUTHENTICATION_NONE:
53 return B_TRANSLATE_CONTEXT("open", "Open network");
54 break;
55 case B_NETWORK_AUTHENTICATION_WEP:
56 return B_TRANSLATE_CONTEXT("WEP", "WEP protected network");
57 break;
58 case B_NETWORK_AUTHENTICATION_WPA:
59 return B_TRANSLATE_CONTEXT("WPA", "WPA protected network");
60 break;
61 case B_NETWORK_AUTHENTICATION_WPA2:
62 return B_TRANSLATE_CONTEXT("WPA2", "WPA2 protected network");
63 break;
64 case B_NETWORK_AUTHENTICATION_EAP:
65 return B_TRANSLATE_CONTEXT("EAP", "EAP protected network");
66 break;
71 void
72 WirelessNetworkMenuItem::DrawContent()
74 DrawRadioIcon();
75 BMenuItem::DrawContent();
79 void
80 WirelessNetworkMenuItem::Highlight(bool isHighlighted)
82 BMenuItem::Highlight(isHighlighted);
86 void
87 WirelessNetworkMenuItem::GetContentSize(float* width, float* height)
89 BMenuItem::GetContentSize(width, height);
90 *width += *height + 4;
94 void
95 WirelessNetworkMenuItem::DrawRadioIcon()
97 BRect bounds = Frame();
98 bounds.left = bounds.right - 4 - bounds.Height();
99 bounds.right -= 4;
100 bounds.bottom -= 2;
102 RadioView::Draw(Menu(), bounds, fQuality, RadioView::DefaultMax());