Made ActivityMonitor buildable under BeOS (at least BONE).
This is only temporary, to help test adding data sources, so the gross #ifdef __HAIKU__ are intentional to keep BeOS-only code (without layout support) trackable. It is not fully functional but sufficient for testing and will go away later. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25009 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
3ddc1cdb8b
commit
cbd4bc9573
@ -140,7 +140,11 @@ ActivityView::ActivityView(BRect frame, const char* name,
|
||||
|
||||
|
||||
ActivityView::ActivityView(const char* name, const BMessage* settings)
|
||||
#ifdef __HAIKU__
|
||||
: BView(name, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS)
|
||||
#else
|
||||
: BView(BRect(0,0,300,200), name, B_FOLLOW_NONE, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS)
|
||||
#endif
|
||||
{
|
||||
_Init(settings);
|
||||
|
||||
@ -359,6 +363,7 @@ ActivityView::DetachedFromWindow()
|
||||
}
|
||||
|
||||
|
||||
#ifdef __HAIKU__
|
||||
BSize
|
||||
ActivityView::MinSize()
|
||||
{
|
||||
@ -368,6 +373,7 @@ ActivityView::MinSize()
|
||||
|
||||
return size;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
|
@ -64,7 +64,9 @@ protected:
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
|
||||
#ifdef __HAIKU__
|
||||
virtual BSize MinSize();
|
||||
#endif
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
virtual void MouseDown(BPoint where);
|
||||
|
@ -11,7 +11,9 @@
|
||||
#include <Application.h>
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
#ifdef __HAIKU__
|
||||
#include <GroupLayout.h>
|
||||
#endif
|
||||
#include <Menu.h>
|
||||
#include <MenuBar.h>
|
||||
#include <MenuItem.h>
|
||||
@ -39,6 +41,7 @@ ActivityWindow::ActivityWindow()
|
||||
ResizeTo(frame.Width(), frame.Height());
|
||||
}
|
||||
|
||||
#ifdef __HAIKU__
|
||||
BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
|
||||
SetLayout(layout);
|
||||
|
||||
@ -66,6 +69,41 @@ ActivityWindow::ActivityWindow()
|
||||
if (count == 0)
|
||||
fLayout->AddView(new ActivityView("ActivityMonitor", NULL));
|
||||
|
||||
#else
|
||||
BView *layout = new BView(Bounds(), "topmost", B_FOLLOW_NONE, 0);
|
||||
AddChild(layout);
|
||||
|
||||
// create GUI
|
||||
BRect mbRect(Bounds());
|
||||
mbRect.bottom = 10;
|
||||
BMenuBar* menuBar = new BMenuBar(mbRect, "menu");
|
||||
layout->AddChild(menuBar);
|
||||
|
||||
BRect topRect(Bounds());
|
||||
topRect.top = menuBar->Bounds().bottom + 1;
|
||||
|
||||
BView* top = new BView(topRect, "top", B_FOLLOW_ALL, 0);
|
||||
top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
layout->AddChild(top);
|
||||
|
||||
BMessage viewState;
|
||||
int32 count = 0;
|
||||
ActivityView *aview;
|
||||
BRect rect;
|
||||
for (int32 i = 0; settings.FindMessage("activity view", i, &viewState)
|
||||
== B_OK; i++) {
|
||||
aview = new ActivityView("ActivityMonitor", &viewState);
|
||||
if (!rect.IsValid())
|
||||
rect = aview->Bounds();
|
||||
else
|
||||
rect.OffsetBySelf(0.0, aview->Bounds().Height());
|
||||
top->AddChild(aview);
|
||||
count++;
|
||||
}
|
||||
if (count == 0)
|
||||
top->AddChild(new ActivityView("ActivityMonitor", NULL));
|
||||
|
||||
#endif
|
||||
// add menu
|
||||
|
||||
// "File" menu
|
||||
@ -134,7 +172,11 @@ ActivityWindow::_SaveSettings()
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
#ifdef __HAIKU__
|
||||
BView* top = GetLayout()->View();
|
||||
#else
|
||||
BView *top = ChildAt(0);
|
||||
#endif
|
||||
int32 count = top->CountChildren();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
ActivityView* view = dynamic_cast<ActivityView*>(top->ChildAt(i));
|
||||
@ -161,10 +203,12 @@ ActivityWindow::_SaveSettings()
|
||||
void
|
||||
ActivityWindow::_UpdateRemoveItem()
|
||||
{
|
||||
#ifdef __HAIKU__
|
||||
BView* view = fLayout->View();
|
||||
int32 count = view->CountChildren();
|
||||
|
||||
fRemoveItem->SetEnabled(count >= 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -194,16 +238,19 @@ ActivityWindow::MessageReceived(BMessage* message)
|
||||
|
||||
case kMsgAddView:
|
||||
{
|
||||
#ifdef __HAIKU__
|
||||
BView* view = fLayout->View()->ChildAt(0);
|
||||
fLayout->AddView(new ActivityView("ActivityMonitor", NULL));
|
||||
if (view != NULL)
|
||||
ResizeBy(0, view->Bounds().Height() + fLayout->Spacing());
|
||||
#endif
|
||||
_UpdateRemoveItem();
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgRemoveView:
|
||||
{
|
||||
#ifdef __HAIKU__
|
||||
BView* view = fLayout->View();
|
||||
int32 count = view->CountChildren();
|
||||
if (count == 1)
|
||||
@ -213,6 +260,7 @@ ActivityWindow::MessageReceived(BMessage* message)
|
||||
fLayout->RemoveView(last);
|
||||
ResizeBy(0, -last->Bounds().Height() - fLayout->Spacing());
|
||||
delete last;
|
||||
#endif
|
||||
|
||||
_UpdateRemoveItem();
|
||||
break;
|
||||
|
@ -30,7 +30,9 @@ private:
|
||||
void _UpdateRemoveItem();
|
||||
void _MessageDropped(BMessage *message);
|
||||
|
||||
#ifdef __HAIKU__
|
||||
BGroupLayout* fLayout;
|
||||
#endif
|
||||
BMenuItem* fRemoveItem;
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
SubDir HAIKU_TOP src apps activitymonitor ;
|
||||
|
||||
# XXX: Temporary only
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
UsePrivateHeaders shared ;
|
||||
|
||||
Application ActivityMonitor :
|
||||
@ -9,6 +12,6 @@ Application ActivityMonitor :
|
||||
DataSource.cpp
|
||||
SystemInfo.cpp
|
||||
|
||||
: be tracker $(TARGET_LIBSTDC++) libnetwork.so
|
||||
: be tracker $(TARGET_LIBSTDC++) $(TARGET_NETWORK_LIBS)
|
||||
: ActivityMonitor.rdef
|
||||
;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <net/if.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
|
||||
@ -30,7 +31,11 @@ SystemInfo::~SystemInfo()
|
||||
uint64
|
||||
SystemInfo::CachedMemory() const
|
||||
{
|
||||
#ifdef __HAIKU__
|
||||
return fSystemInfo.cached_pages * B_PAGE_SIZE;
|
||||
#else
|
||||
return 0LL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -122,10 +127,12 @@ SystemInfo::_RetrieveNetwork()
|
||||
ifreq request;
|
||||
strlcpy(request.ifr_name, interface->ifr_name, IF_NAMESIZE);
|
||||
|
||||
#ifdef __HAIKU__
|
||||
if (ioctl(socket, SIOCGIFSTATS, &request, sizeof(struct ifreq)) == 0) {
|
||||
fBytesReceived += request.ifr_stats.receive.bytes;
|
||||
fBytesSent += request.ifr_stats.send.bytes;
|
||||
}
|
||||
#endif
|
||||
|
||||
interface = (ifreq *)((addr_t)interface + IF_NAMESIZE
|
||||
+ interface->ifr_addr.sa_len);
|
||||
|
Loading…
Reference in New Issue
Block a user