* Moved WirelessNetworkMenuItem into its own file.

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39833 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-12-13 19:57:19 +00:00
parent f108cdbfab
commit 3ca00ffdbc
5 changed files with 110 additions and 88 deletions
+2
View File
@@ -15,6 +15,8 @@ Application NetworkStatus :
NetworkStatusView.cpp
NetworkStatus.cpp
RadioView.cpp
WirelessNetworkMenuItem.cpp
: be $(HAIKU_LOCALE_LIBS) $(icon_libs) $(TARGET_NETWORK_LIBS)
libbnetapi.so $(TARGET_LIBSTDC++)
: NetworkStatus.rdef NetworkStatusIcons.rdef
+4 -3
View File
@@ -66,9 +66,10 @@ our_image(image_info& image)
NetworkStatus::NetworkStatus()
: BApplication(kSignature),
fAutoInstallInDeskbar(false),
fQuitImmediately(false)
:
BApplication(kSignature),
fAutoInstallInDeskbar(false),
fQuitImmediately(false)
{
}
+1 -85
View File
@@ -45,6 +45,7 @@
#include "NetworkStatus.h"
#include "NetworkStatusIcons.h"
#include "RadioView.h"
#include "WirelessNetworkMenuItem.h"
#undef B_TRANSLATE_CONTEXT
@@ -70,31 +71,6 @@ const uint32 kMinIconWidth = 16;
const uint32 kMinIconHeight = 16;
class WirelessNetworkMenuItem : public BMenuItem {
public:
WirelessNetworkMenuItem(const char* name,
int32 signalQuality, bool encrypted,
BMessage* message);
virtual ~WirelessNetworkMenuItem();
void SetSignalQuality(int32 quality);
int32 SignalQuality() const
{ return fQuality; }
bool IsEncrypted() const
{ return fIsEncrypted; }
protected:
virtual void DrawContent();
virtual void Highlight(bool isHighlighted);
virtual void GetContentSize(float* width, float* height);
void DrawRadioIcon();
private:
int32 fQuality;
bool fIsEncrypted;
};
class SocketOpener {
public:
SocketOpener()
@@ -122,66 +98,6 @@ private:
};
// #pragma mark - WirelessNetworkMenuItem
WirelessNetworkMenuItem::WirelessNetworkMenuItem(const char* name,
int32 signalQuality, bool encrypted, BMessage* message)
:
BMenuItem(name, message),
fQuality(signalQuality),
fIsEncrypted(encrypted)
{
}
WirelessNetworkMenuItem::~WirelessNetworkMenuItem()
{
}
void
WirelessNetworkMenuItem::SetSignalQuality(int32 quality)
{
fQuality = quality;
}
void
WirelessNetworkMenuItem::DrawContent()
{
DrawRadioIcon();
BMenuItem::DrawContent();
}
void
WirelessNetworkMenuItem::Highlight(bool isHighlighted)
{
BMenuItem::Highlight(isHighlighted);
}
void
WirelessNetworkMenuItem::GetContentSize(float* width, float* height)
{
BMenuItem::GetContentSize(width, height);
*width += *height + 4;
}
void
WirelessNetworkMenuItem::DrawRadioIcon()
{
BRect bounds = Frame();
bounds.left = bounds.right - 4 - bounds.Height();
bounds.right -= 4;
bounds.bottom -= 2;
RadioView::Draw(Menu(), bounds, fQuality, RadioView::DefaultMax());
}
// #pragma mark -
@@ -0,0 +1,66 @@
/*
* Copyright 2010, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "WirelessNetworkMenuItem.h"
#include "RadioView.h"
WirelessNetworkMenuItem::WirelessNetworkMenuItem(const char* name,
int32 signalQuality, bool encrypted, BMessage* message)
:
BMenuItem(name, message),
fQuality(signalQuality),
fIsEncrypted(encrypted)
{
}
WirelessNetworkMenuItem::~WirelessNetworkMenuItem()
{
}
void
WirelessNetworkMenuItem::SetSignalQuality(int32 quality)
{
fQuality = quality;
}
void
WirelessNetworkMenuItem::DrawContent()
{
DrawRadioIcon();
BMenuItem::DrawContent();
}
void
WirelessNetworkMenuItem::Highlight(bool isHighlighted)
{
BMenuItem::Highlight(isHighlighted);
}
void
WirelessNetworkMenuItem::GetContentSize(float* width, float* height)
{
BMenuItem::GetContentSize(width, height);
*width += *height + 4;
}
void
WirelessNetworkMenuItem::DrawRadioIcon()
{
BRect bounds = Frame();
bounds.left = bounds.right - 4 - bounds.Height();
bounds.right -= 4;
bounds.bottom -= 2;
RadioView::Draw(Menu(), bounds, fQuality, RadioView::DefaultMax());
}
@@ -0,0 +1,37 @@
/*
* Copyright 2010, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef WIRELESS_NETWORK_MENU_ITEM_H
#define WIRELESS_NETWORK_MENU_ITEM_H
#include <MenuItem.h>
class WirelessNetworkMenuItem : public BMenuItem {
public:
WirelessNetworkMenuItem(const char* name,
int32 signalQuality, bool encrypted,
BMessage* message);
virtual ~WirelessNetworkMenuItem();
void SetSignalQuality(int32 quality);
int32 SignalQuality() const
{ return fQuality; }
bool IsEncrypted() const
{ return fIsEncrypted; }
protected:
virtual void DrawContent();
virtual void Highlight(bool isHighlighted);
virtual void GetContentSize(float* width, float* height);
void DrawRadioIcon();
private:
int32 fQuality;
bool fIsEncrypted;
};
#endif // WIRELESS_NETWORK_MENU_ITEM_H